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

twin

Skip menu "twin"
  • Main Page
  • Modules
  • 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.