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

twin

  • twin
utils.h
1 /*****************************************************************
2  KWin - the KDE window manager
3  This file is part of the KDE project.
4 
5 Copyright (C) 1999, 2000 Matthias Ettrich <ettrich@kde.org>
6 Copyright (C) 2003 Lubos Lunak <l.lunak@kde.org>
7 
8 You can Freely distribute this program under the GNU General Public
9 License. See the file "COPYING" for the exact licensing terms.
10 ******************************************************************/
11 
12 #ifndef KWIN_UTILS_H
13 #define KWIN_UTILS_H
14 
15 #include <tqvaluelist.h>
16 #include <tqwidget.h>
17 #include <kmanagerselection.h>
18 #include <netwm_def.h>
19 #include <tdeshortcutdialog.h>
20 
21 namespace KWinInternal
22 {
23 
24 const int SUPPORTED_WINDOW_TYPES_MASK = NET::NormalMask | NET::DesktopMask | NET::DockMask
25  | NET::ToolbarMask | NET::MenuMask | NET::DialogMask /*| NET::OverrideMask*/ | NET::TopMenuMask
26  | NET::UtilityMask | NET::SplashMask;
27 
28 const long ClientWinMask = KeyPressMask | KeyReleaseMask |
29  ButtonPressMask | ButtonReleaseMask |
30  KeymapStateMask |
31  ButtonMotionMask |
32  PointerMotionMask | // need this, too!
33  EnterWindowMask | LeaveWindowMask |
34  FocusChangeMask |
35  ExposureMask |
36  StructureNotifyMask |
37  SubstructureRedirectMask;
38 
39 const TQPoint invalidPoint( INT_MIN, INT_MIN );
40 
41 class Client;
42 class Group;
43 class Options;
44 
45 typedef TQValueList< Client* > ClientList;
46 typedef TQValueList< const Client* > ConstClientList;
47 
48 typedef TQValueList< Group* > GroupList;
49 typedef TQValueList< const Group* > ConstGroupList;
50 
51 extern Options* options;
52 
53 enum Layer
54  {
55  UnknownLayer = -1,
56  FirstLayer = 0,
57  DesktopLayer = FirstLayer,
58  BelowLayer,
59  NormalLayer,
60  DockLayer,
61  AboveLayer,
62  ActiveLayer, // active fullscreen, or active dialog
63  NumLayers // number of layers, must be last
64  };
65 
66 // yes, I know this is not 100% like standard operator++
67 inline void operator++( Layer& lay )
68  {
69  lay = static_cast< Layer >( lay + 1 );
70  }
71 
72 // for Client::takeActivity()
73 enum ActivityFlags
74  {
75  ActivityFocus = 1 << 0, // focus the window
76  ActivityFocusForce = 1 << 1, // focus even if Dock etc.
77  ActivityRaise = 1 << 2 // raise the window
78  };
79 
80 // Some KWin classes, mainly Client and Workspace, are very tighly coupled,
81 // and some of the methods of one class may be called only from speficic places.
82 // Those methods have additional allowed_t argument. If you pass Allowed
83 // as an argument to any function, make sure you really know what you're doing.
84 enum allowed_t { Allowed };
85 
86 // some enums to have more readable code, instead of using bools
87 enum ForceGeometry_t { NormalGeometrySet, ForceGeometrySet };
88 
89 // Areas, mostly related to Xinerama
90 enum clientAreaOption
91  {
92  PlacementArea, // geometry where a window will be initially placed after being mapped
93  MovementArea, // ??? window movement snapping area? ignore struts
94  MaximizeArea, // geometry to which a window will be maximized
95  MaximizeFullArea, // like MaximizeArea, but ignore struts - used e.g. for topmenu
96  FullScreenArea, // area for fullscreen windows
97  // these below don't depend on xinerama settings
98  WorkArea, // whole workarea (all screens together)
99  FullArea, // whole area (all screens together), ignore struts
100  ScreenArea // one whole screen, ignore struts
101  };
102 
103 enum ShadeMode
104  {
105  ShadeNone, // not shaded
106  ShadeNormal, // normally shaded - isShade() is true only here
107  ShadeHover, // "shaded", but visible due to hover unshade
108  ShadeActivated // "shaded", but visible due to alt+tab to the window
109  };
110 
111 enum ActiveBorder
112  {
113  ActiveNone = 0,
114 
115  ActiveLeft = 1,
116  ActiveRight = 2,
117  ActiveTop = 4,
118  ActiveBottom = 8,
119 
120  ActiveTopLeft = ActiveTop | ActiveLeft,
121  ActiveTopRight = ActiveTop | ActiveRight,
122  ActiveBottomLeft = ActiveBottom | ActiveLeft,
123  ActiveBottomRight = ActiveBottom | ActiveRight,
124 
125  ACTIVE_BORDER_COUNT
126  };
127 
128 enum ActiveMaximizingMode
129 {
130  ActiveNoMode,
131  ActiveTilingMode,
132  ActiveMaximizeMode
133 };
134 
135 class Shape
136  {
137  public:
138  static bool available() { return twin_shape_version > 0; }
139  static int version() { return twin_shape_version; } // as 16*major+minor, i.e. two hex digits
140  static bool hasShape( WId w);
141  static int shapeEvent();
142  static void init();
143  private:
144  static int twin_shape_version;
145  static int twin_shape_event;
146  };
147 
148 // compile with XShape older than 1.0
149 #ifndef ShapeInput
150 const int ShapeInput = 2;
151 #endif
152 
153 class Motif
154  {
155  public:
156  static void readFlags( WId w, bool& noborder, bool& resize, bool& move,
157  bool& minimize, bool& maximize, bool& close );
158  struct MwmHints
159  {
160  ulong flags;
161  ulong functions;
162  ulong decorations;
163  long input_mode;
164  ulong status;
165  };
166  enum {
167  MWM_HINTS_FUNCTIONS = (1L << 0),
168  MWM_HINTS_DECORATIONS = (1L << 1),
169 
170  MWM_FUNC_ALL = (1L << 0),
171  MWM_FUNC_RESIZE = (1L << 1),
172  MWM_FUNC_MOVE = (1L << 2),
173  MWM_FUNC_MINIMIZE = (1L << 3),
174  MWM_FUNC_MAXIMIZE = (1L << 4),
175  MWM_FUNC_CLOSE = (1L << 5)
176  };
177  };
178 
179 class KWinSelectionOwner
180  : public TDESelectionOwner
181  {
182  TQ_OBJECT
183  public:
184  KWinSelectionOwner( int screen );
185  protected:
186  virtual bool genericReply( Atom target, Atom property, Window requestor );
187  virtual void replyTargets( Atom property, Window requestor );
188  virtual void getAtoms();
189  private:
190  Atom make_selection_atom( int screen );
191  static Atom xa_version;
192  };
193 
194 // Class which saves original value of the variable, assigns the new value
195 // to it, and in the destructor restores the value.
196 // Used in Client::isMaximizable() and so on.
197 // It also casts away contness and generally this looks like a hack.
198 template< typename T >
199 class TemporaryAssign
200  {
201  public:
202  TemporaryAssign( const T& var, const T& value )
203  : variable( var ), orig( var )
204  {
205  const_cast< T& >( variable ) = value;
206  }
207  ~TemporaryAssign()
208  {
209  const_cast< T& >( variable ) = orig;
210  }
211  private:
212  const T& variable;
213  T orig;
214  };
215 
216 TQCString getStringProperty(WId w, Atom prop, char separator=0);
217 void updateXTime();
218 void grabXServer();
219 void ungrabXServer();
220 bool grabbedXServer();
221 
222 // the docs say it's UrgencyHint, but it's often #defined as XUrgencyHint
223 #ifndef UrgencyHint
224 #define UrgencyHint XUrgencyHint
225 #endif
226 
227 // for STL-like algo's
228 #define KWIN_CHECK_PREDICATE( name, check ) \
229 struct name \
230  { \
231  inline bool operator()( const Client* cl ) { return check; }; \
232  }
233 
234 #define KWIN_COMPARE_PREDICATE( name, type, check ) \
235 struct name \
236  { \
237  typedef type type_helper; /* in order to work also with type being 'const Client*' etc. */ \
238  inline name( const type_helper& compare_value ) : value( compare_value ) {}; \
239  inline bool operator()( const Client* cl ) { return check; }; \
240  const type_helper& value; \
241  }
242 
243 #define KWIN_PROCEDURE( name, action ) \
244 struct name \
245  { \
246  inline void operator()( Client* cl ) { action; }; \
247  }
248 
249 KWIN_CHECK_PREDICATE( TruePredicate, cl == cl /*true, avoid warning about 'cl' */ );
250 
251 template< typename T >
252 Client* findClientInList( const ClientList& list, T predicate )
253  {
254  for ( ClientList::ConstIterator it = list.begin(); it != list.end(); ++it)
255  {
256  if ( predicate( const_cast< const Client* >( *it)))
257  return *it;
258  }
259  return NULL;
260  }
261 
262 inline
263 int timestampCompare( Time time1, Time time2 ) // like strcmp()
264  {
265  return NET::timestampCompare( time1, time2 );
266  }
267 
268 inline
269 Time timestampDiff( Time time1, Time time2 ) // returns time2 - time1
270  {
271  return NET::timestampDiff( time1, time2 );
272  }
273 
274 bool isLocalMachine( const TQCString& host );
275 
276 void checkNonExistentClients();
277 
278 #ifndef KCMRULES
279 // Qt dialogs emit no signal when closed :(
280 class ShortcutDialog
281  : public TDEShortcutDialog
282  {
283  TQ_OBJECT
284  public:
285  ShortcutDialog( const TDEShortcut& cut );
286  virtual void accept();
287  virtual void hide();
288  signals:
289  void dialogDone( bool ok );
290  protected:
291  virtual void done( int r ) { TDEShortcutDialog::done( r ); emit dialogDone( r == Accepted ); }
292  };
293 #endif
294 
295 } // namespace
296 
297 #endif
KWinInternal
Definition: activation.cpp:34

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.8.13
This website is maintained by Timothy Pearson.