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