• Skip to content
  • Skip to link menu
Trinity API Reference
  • Trinity API Reference
  • twin
 

twin

  • twin
rules.h
1 /*****************************************************************
2  KWin - the KDE window manager
3  This file is part of the KDE project.
4 
5 Copyright (C) 2004 Lubos Lunak <l.lunak@kde.org>
6 
7 You can Freely distribute this program under the GNU General Public
8 License. See the file "COPYING" for the exact licensing terms.
9 ******************************************************************/
10 
11 #ifndef KWIN_RULES_H
12 #define KWIN_RULES_H
13 
14 #include <tqstring.h>
15 #include <netwm_def.h>
16 #include <tqrect.h>
17 #include <tqvaluevector.h>
18 #include <kdebug.h>
19 
20 #include "placement.h"
21 #include "lib/kdecoration.h"
22 #include "options.h"
23 #include "utils.h"
24 
25 class TDEConfig;
26 
27 namespace KWinInternal
28 {
29 
30 class Client;
31 class Rules;
32 
33 #ifndef KCMRULES // only for twin core
34 
35 class WindowRules
36  : public KDecorationDefines
37  {
38  public:
39  WindowRules( const TQValueVector< Rules* >& rules );
40  WindowRules();
41  void update( Client* );
42  void discardTemporary();
43  bool contains( const Rules* rule ) const;
44  void remove( Rules* rule );
45  Placement::Policy checkPlacement( Placement::Policy placement ) const;
46  TQRect checkGeometry( TQRect rect, bool init = false ) const;
47  // use 'invalidPoint' with checkPosition, unlike TQSize() and TQRect(), TQPoint() is a valid point
48  TQPoint checkPosition( TQPoint pos, bool init = false ) const;
49  TQSize checkSize( TQSize s, bool init = false ) const;
50  TQSize checkMinSize( TQSize s ) const;
51  TQSize checkMaxSize( TQSize s ) const;
52  int checkOpacityActive(int s) const;
53  int checkOpacityInactive(int s) const;
54  bool checkIgnoreGeometry( bool ignore ) const;
55  int checkDesktop( int desktop, bool init = false ) const;
56  NET::WindowType checkType( NET::WindowType type ) const;
57  MaximizeMode checkMaximize( MaximizeMode mode, bool init = false ) const;
58  bool checkMinimize( bool minimized, bool init = false ) const;
59  ShadeMode checkShade( ShadeMode shade, bool init = false ) const;
60  bool checkSkipTaskbar( bool skip, bool init = false ) const;
61  bool checkSkipPager( bool skip, bool init = false ) const;
62  bool checkKeepAbove( bool above, bool init = false ) const;
63  bool checkKeepBelow( bool below, bool init = false ) const;
64  bool checkFullScreen( bool fs, bool init = false ) const;
65  bool checkNoBorder( bool noborder, bool init = false ) const;
66  int checkFSP( int fsp ) const;
67  bool checkAcceptFocus( bool focus ) const;
68  Options::MoveResizeMode checkMoveResizeMode( Options::MoveResizeMode mode ) const;
69  bool checkCloseable( bool closeable ) const;
70  bool checkStrictGeometry( bool strict ) const;
71  TQString checkShortcut( TQString s, bool init = false ) const;
72  bool checkDisableGlobalShortcuts( bool disable ) const;
73  bool checkIgnorePosition( bool ignore ) const; // obsolete
74  private:
75  MaximizeMode checkMaximizeVert( MaximizeMode mode, bool init ) const;
76  MaximizeMode checkMaximizeHoriz( MaximizeMode mode, bool init ) const;
77  TQValueVector< Rules* > rules;
78  };
79 #endif
80 
81 class Rules
82  : public KDecorationDefines
83  {
84  public:
85  Rules();
86  Rules( TDEConfig& );
87  Rules( const TQString&, bool temporary );
88  void write( TDEConfig& ) const;
89  bool isEmpty() const;
90 #ifndef KCMRULES
91  void discardUsed( bool withdrawn );
92  bool match( const Client* c ) const;
93  bool update( Client* );
94  bool isTemporary() const;
95  bool discardTemporary( bool force ); // removes if temporary and forced or too old
96  bool applyPlacement( Placement::Policy& placement ) const;
97  bool applyGeometry( TQRect& rect, bool init ) const;
98  // use 'invalidPoint' with applyPosition, unlike TQSize() and TQRect(), TQPoint() is a valid point
99  bool applyPosition( TQPoint& pos, bool init ) const;
100  bool applySize( TQSize& s, bool init ) const;
101  bool applyMinSize( TQSize& s ) const;
102  bool applyMaxSize( TQSize& s ) const;
103  bool applyOpacityActive(int& s) const;
104  bool applyOpacityInactive(int& s) const;
105  bool applyIgnoreGeometry( bool& ignore ) const;
106  bool applyDesktop( int& desktop, bool init ) const;
107  bool applyType( NET::WindowType& type ) const;
108  bool applyMaximizeVert( MaximizeMode& mode, bool init ) const;
109  bool applyMaximizeHoriz( MaximizeMode& mode, bool init ) const;
110  bool applyMinimize( bool& minimized, bool init ) const;
111  bool applyShade( ShadeMode& shade, bool init ) const;
112  bool applySkipTaskbar( bool& skip, bool init ) const;
113  bool applySkipPager( bool& skip, bool init ) const;
114  bool applyKeepAbove( bool& above, bool init ) const;
115  bool applyKeepBelow( bool& below, bool init ) const;
116  bool applyFullScreen( bool& fs, bool init ) const;
117  bool applyNoBorder( bool& noborder, bool init ) const;
118  bool applyFSP( int& fsp ) const;
119  bool applyAcceptFocus( bool& focus ) const;
120  bool applyMoveResizeMode( Options::MoveResizeMode& mode ) const;
121  bool applyCloseable( bool& closeable ) const;
122  bool applyStrictGeometry( bool& strict ) const;
123  bool applyShortcut( TQString& shortcut, bool init ) const;
124  bool applyDisableGlobalShortcuts( bool& disable ) const;
125  bool applyIgnorePosition( bool& ignore ) const; // obsolete
126  private:
127 #endif
128  bool matchType( NET::WindowType match_type ) const;
129  bool matchWMClass( const TQCString& match_class, const TQCString& match_name ) const;
130  bool matchRole( const TQCString& match_role ) const;
131  bool matchTitle( const TQString& match_title ) const;
132  bool matchClientMachine( const TQCString& match_machine ) const;
133  // All these values are saved to the cfg file, and are also used in kstart!
134  enum
135  {
136  Unused = 0,
137  DontAffect, // use the default value
138  Force, // force the given value
139  Apply, // apply only after initial mapping
140  Remember, // like apply, and remember the value when the window is withdrawn
141  ApplyNow, // apply immediatelly, then forget the setting
142  ForceTemporarily // apply and force until the window is withdrawn
143  };
144  enum SetRule
145  {
146  UnusedSetRule = Unused,
147  SetRuleDummy = 256 // so that it's at least short int
148  };
149  enum ForceRule
150  {
151  UnusedForceRule = Unused,
152  ForceRuleDummy = 256 // so that it's at least short int
153  };
154  enum StringMatch
155  {
156  FirstStringMatch,
157  UnimportantMatch = FirstStringMatch,
158  ExactMatch,
159  SubstringMatch,
160  RegExpMatch,
161  LastStringMatch = RegExpMatch
162  };
163  void readFromCfg( TDEConfig& cfg );
164  static SetRule readSetRule( TDEConfig&, const TQString& key );
165  static ForceRule readForceRule( TDEConfig&, const TQString& key );
166  static NET::WindowType readType( TDEConfig&, const TQString& key );
167 #ifndef KCMRULES
168  static bool checkSetRule( SetRule rule, bool init );
169  static bool checkForceRule( ForceRule rule );
170  static bool checkSetStop( SetRule rule );
171  static bool checkForceStop( ForceRule rule );
172 #endif
173  int temporary_state; // e.g. for kstart
174  TQString description;
175  TQCString wmclass;
176  StringMatch wmclassmatch;
177  bool wmclasscomplete;
178  TQCString windowrole;
179  StringMatch windowrolematch;
180  TQString title; // TODO "caption" ?
181  StringMatch titlematch;
182  TQCString extrarole;
183  StringMatch extrarolematch;
184  TQCString clientmachine;
185  StringMatch clientmachinematch;
186  unsigned long types; // types for matching
187  Placement::Policy placement;
188  ForceRule placementrule;
189  TQPoint position;
190  SetRule positionrule;
191  TQSize size;
192  SetRule sizerule;
193  TQSize minsize;
194  ForceRule minsizerule;
195  TQSize maxsize;
196  ForceRule maxsizerule;
197  int opacityactive;
198  ForceRule opacityactiverule;
199  int opacityinactive;
200  ForceRule opacityinactiverule;
201  bool ignoreposition;
202  ForceRule ignorepositionrule;
203  int desktop;
204  SetRule desktoprule;
205  NET::WindowType type; // type for setting
206  ForceRule typerule;
207  bool maximizevert;
208  SetRule maximizevertrule;
209  bool maximizehoriz;
210  SetRule maximizehorizrule;
211  bool minimize;
212  SetRule minimizerule;
213  bool shade;
214  SetRule shaderule;
215  bool skiptaskbar;
216  SetRule skiptaskbarrule;
217  bool skippager;
218  SetRule skippagerrule;
219  bool above;
220  SetRule aboverule;
221  bool below;
222  SetRule belowrule;
223  bool fullscreen;
224  SetRule fullscreenrule;
225  bool noborder;
226  SetRule noborderrule;
227  int fsplevel;
228  ForceRule fsplevelrule;
229  bool acceptfocus;
230  ForceRule acceptfocusrule;
231  Options::MoveResizeMode moveresizemode;
232  ForceRule moveresizemoderule;
233  bool closeable;
234  ForceRule closeablerule;
235  bool strictgeometry;
236  ForceRule strictgeometryrule;
237  TQString shortcut;
238  SetRule shortcutrule;
239  bool disableglobalshortcuts;
240  ForceRule disableglobalshortcutsrule;
241  friend kdbgstream& operator<<( kdbgstream& stream, const Rules* );
242  };
243 
244 #ifndef KCMRULES
245 inline
246 bool Rules::checkSetRule( SetRule rule, bool init )
247  {
248  if( rule > ( SetRule )DontAffect) // Unused or DontAffect
249  {
250  if( rule == ( SetRule )Force || rule == ( SetRule ) ApplyNow
251  || rule == ( SetRule ) ForceTemporarily || init )
252  return true;
253  }
254  return false;
255  }
256 
257 inline
258 bool Rules::checkForceRule( ForceRule rule )
259  {
260  return rule == ( ForceRule )Force || rule == ( ForceRule ) ForceTemporarily;
261  }
262 
263 inline
264 bool Rules::checkSetStop( SetRule rule )
265  {
266  return rule != UnusedSetRule;
267  }
268 
269 inline
270 bool Rules::checkForceStop( ForceRule rule )
271  {
272  return rule != UnusedForceRule;
273  }
274 
275 inline
276 WindowRules::WindowRules( const TQValueVector< Rules* >& r )
277  : rules( r )
278  {
279  }
280 
281 inline
282 WindowRules::WindowRules()
283  {
284  }
285 
286 inline
287 bool WindowRules::contains( const Rules* rule ) const
288  {
289  return tqFind( rules.begin(), rules.end(), rule ) != rules.end();
290  }
291 
292 inline
293 void WindowRules::remove( Rules* rule )
294  {
295  TQValueVector< Rules* >::Iterator pos = tqFind( rules.begin(), rules.end(), rule );
296  if( pos != rules.end())
297  rules.erase( pos );
298  }
299 
300 #endif
301 
302 #ifdef NDEBUG
303 inline
304 kndbgstream& operator<<( kndbgstream& stream, const Rules* ) { return stream; }
305 #else
306 kdbgstream& operator<<( kdbgstream& stream, const Rules* );
307 #endif
308 
309 } // namespace
310 
311 #endif

twin

Skip menu "twin"
  • Main Page
  • Alphabetical List
  • Class List
  • File List
  • Class Members

twin

Skip menu "twin"
  • kate
  • libkonq
  • twin
  •   lib
Generated for twin by doxygen 1.9.1
This website is maintained by Timothy Pearson.