• 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  ActiveTop = 0,
114  ActiveTopRight,
115  ActiveRight,
116  ActiveBottomRight,
117  ActiveBottom,
118  ActiveBottomLeft,
119  ActiveLeft,
120  ActiveTopLeft,
121  ACTIVE_BORDER_COUNT,
122  ActiveNone
123  };
124 
125 enum ActiveMaximizingMode
126 {
127  ActiveNoMode,
128  ActiveTilingMode,
129  ActiveMaximizeMode
130 };
131 
132 class Shape
133  {
134  public:
135  static bool available() { return twin_shape_version > 0; }
136  static int version() { return twin_shape_version; } // as 16*major+minor, i.e. two hex digits
137  static bool hasShape( WId w);
138  static int shapeEvent();
139  static void init();
140  private:
141  static int twin_shape_version;
142  static int twin_shape_event;
143  };
144 
145 // compile with XShape older than 1.0
146 #ifndef ShapeInput
147 const int ShapeInput = 2;
148 #endif
149 
150 class Motif
151  {
152  public:
153  static void readFlags( WId w, bool& noborder, bool& resize, bool& move,
154  bool& minimize, bool& maximize, bool& close );
155  struct MwmHints
156  {
157  ulong flags;
158  ulong functions;
159  ulong decorations;
160  long input_mode;
161  ulong status;
162  };
163  enum {
164  MWM_HINTS_FUNCTIONS = (1L << 0),
165  MWM_HINTS_DECORATIONS = (1L << 1),
166 
167  MWM_FUNC_ALL = (1L << 0),
168  MWM_FUNC_RESIZE = (1L << 1),
169  MWM_FUNC_MOVE = (1L << 2),
170  MWM_FUNC_MINIMIZE = (1L << 3),
171  MWM_FUNC_MAXIMIZE = (1L << 4),
172  MWM_FUNC_CLOSE = (1L << 5)
173  };
174  };
175 
176 class KWinSelectionOwner
177  : public TDESelectionOwner
178  {
179  TQ_OBJECT
180  public:
181  KWinSelectionOwner( int screen );
182  protected:
183  virtual bool genericReply( Atom target, Atom property, Window requestor );
184  virtual void replyTargets( Atom property, Window requestor );
185  virtual void getAtoms();
186  private:
187  Atom make_selection_atom( int screen );
188  static Atom xa_version;
189  };
190 
191 // Class which saves original value of the variable, assigns the new value
192 // to it, and in the destructor restores the value.
193 // Used in Client::isMaximizable() and so on.
194 // It also casts away contness and generally this looks like a hack.
195 template< typename T >
196 class TemporaryAssign
197  {
198  public:
199  TemporaryAssign( const T& var, const T& value )
200  : variable( var ), orig( var )
201  {
202  const_cast< T& >( variable ) = value;
203  }
204  ~TemporaryAssign()
205  {
206  const_cast< T& >( variable ) = orig;
207  }
208  private:
209  const T& variable;
210  T orig;
211  };
212 
213 TQCString getStringProperty(WId w, Atom prop, char separator=0);
214 void updateXTime();
215 void grabXServer();
216 void ungrabXServer();
217 bool grabbedXServer();
218 
219 // the docs say it's UrgencyHint, but it's often #defined as XUrgencyHint
220 #ifndef UrgencyHint
221 #define UrgencyHint XUrgencyHint
222 #endif
223 
224 // for STL-like algo's
225 #define KWIN_CHECK_PREDICATE( name, check ) \
226 struct name \
227  { \
228  inline bool operator()( const Client* cl ) { return check; }; \
229  }
230 
231 #define KWIN_COMPARE_PREDICATE( name, type, check ) \
232 struct name \
233  { \
234  typedef type type_helper; /* in order to work also with type being 'const Client*' etc. */ \
235  inline name( const type_helper& compare_value ) : value( compare_value ) {}; \
236  inline bool operator()( const Client* cl ) { return check; }; \
237  const type_helper& value; \
238  }
239 
240 #define KWIN_PROCEDURE( name, action ) \
241 struct name \
242  { \
243  inline void operator()( Client* cl ) { action; }; \
244  }
245 
246 KWIN_CHECK_PREDICATE( TruePredicate, cl == cl /*true, avoid warning about 'cl' */ );
247 
248 template< typename T >
249 Client* findClientInList( const ClientList& list, T predicate )
250  {
251  for ( ClientList::ConstIterator it = list.begin(); it != list.end(); ++it)
252  {
253  if ( predicate( const_cast< const Client* >( *it)))
254  return *it;
255  }
256  return NULL;
257  }
258 
259 inline
260 int timestampCompare( Time time1, Time time2 ) // like strcmp()
261  {
262  return NET::timestampCompare( time1, time2 );
263  }
264 
265 inline
266 Time timestampDiff( Time time1, Time time2 ) // returns time2 - time1
267  {
268  return NET::timestampDiff( time1, time2 );
269  }
270 
271 bool isLocalMachine( const TQCString& host );
272 
273 void checkNonExistentClients();
274 
275 #ifndef KCMRULES
276 // Qt dialogs emit no signal when closed :(
277 class ShortcutDialog
278  : public TDEShortcutDialog
279  {
280  TQ_OBJECT
281  public:
282  ShortcutDialog( const TDEShortcut& cut );
283  virtual void accept();
284  virtual void hide();
285  signals:
286  void dialogDone( bool ok );
287  protected:
288  virtual void done( int r ) { TDEShortcutDialog::done( r ); emit dialogDone( r == Accepted ); }
289  };
290 #endif
291 
292 } // namespace
293 
294 #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.