00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012 #ifndef KWIN_UTILS_H
00013 #define KWIN_UTILS_H
00014
00015 #include <qvaluelist.h>
00016 #include <qwidget.h>
00017 #include <kmanagerselection.h>
00018 #include <netwm_def.h>
00019 #include <kshortcutdialog.h>
00020
00021 namespace KWinInternal
00022 {
00023
00024 const int SUPPORTED_WINDOW_TYPES_MASK = NET::NormalMask | NET::DesktopMask | NET::DockMask
00025 | NET::ToolbarMask | NET::MenuMask | NET::DialogMask | NET::OverrideMask | NET::TopMenuMask
00026 | NET::UtilityMask | NET::SplashMask;
00027
00028 const long ClientWinMask = KeyPressMask | KeyReleaseMask |
00029 ButtonPressMask | ButtonReleaseMask |
00030 KeymapStateMask |
00031 ButtonMotionMask |
00032 PointerMotionMask |
00033 EnterWindowMask | LeaveWindowMask |
00034 FocusChangeMask |
00035 ExposureMask |
00036 StructureNotifyMask |
00037 SubstructureRedirectMask;
00038
00039 const QPoint invalidPoint( INT_MIN, INT_MIN );
00040
00041 class Client;
00042 class Group;
00043 class Options;
00044
00045 typedef QValueList< Client* > ClientList;
00046 typedef QValueList< const Client* > ConstClientList;
00047
00048 typedef QValueList< Group* > GroupList;
00049 typedef QValueList< const Group* > ConstGroupList;
00050
00051 extern Options* options;
00052
00053 enum Layer
00054 {
00055 UnknownLayer = -1,
00056 FirstLayer = 0,
00057 DesktopLayer = FirstLayer,
00058 BelowLayer,
00059 NormalLayer,
00060 AboveLayer,
00061 DockLayer,
00062 ActiveLayer,
00063 NumLayers
00064 };
00065
00066
00067 inline void operator++( Layer& lay )
00068 {
00069 lay = static_cast< Layer >( lay + 1 );
00070 }
00071
00072
00073 enum ActivityFlags
00074 {
00075 ActivityFocus = 1 << 0,
00076 ActivityFocusForce = 1 << 1,
00077 ActivityRaise = 1 << 2
00078 };
00079
00080
00081
00082
00083
00084 enum allowed_t { Allowed };
00085
00086
00087 enum ForceGeometry_t { NormalGeometrySet, ForceGeometrySet };
00088
00089
00090 enum clientAreaOption
00091 {
00092 PlacementArea,
00093 MovementArea,
00094 MaximizeArea,
00095 MaximizeFullArea,
00096 FullScreenArea,
00097
00098 WorkArea,
00099 FullArea,
00100 ScreenArea
00101 };
00102
00103 enum ShadeMode
00104 {
00105 ShadeNone,
00106 ShadeNormal,
00107 ShadeHover,
00108 ShadeActivated
00109 };
00110
00111 class Shape
00112 {
00113 public:
00114 static bool available() { return kwin_has_shape; }
00115 static bool hasShape( WId w);
00116 static int shapeEvent();
00117 static void init();
00118 private:
00119 static int kwin_has_shape;
00120 static int kwin_shape_event;
00121 };
00122
00123 class Motif
00124 {
00125 public:
00126 static void readFlags( WId w, bool& noborder, bool& resize, bool& move,
00127 bool& minimize, bool& maximize, bool& close );
00128 struct MwmHints
00129 {
00130 ulong flags;
00131 ulong functions;
00132 ulong decorations;
00133 long input_mode;
00134 ulong status;
00135 };
00136 enum {
00137 MWM_HINTS_FUNCTIONS = (1L << 0),
00138 MWM_HINTS_DECORATIONS = (1L << 1),
00139
00140 MWM_FUNC_ALL = (1L << 0),
00141 MWM_FUNC_RESIZE = (1L << 1),
00142 MWM_FUNC_MOVE = (1L << 2),
00143 MWM_FUNC_MINIMIZE = (1L << 3),
00144 MWM_FUNC_MAXIMIZE = (1L << 4),
00145 MWM_FUNC_CLOSE = (1L << 5)
00146 };
00147 };
00148
00149 class KWinSelectionOwner
00150 : public KSelectionOwner
00151 {
00152 Q_OBJECT
00153 public:
00154 KWinSelectionOwner( int screen );
00155 protected:
00156 virtual bool genericReply( Atom target, Atom property, Window requestor );
00157 virtual void replyTargets( Atom property, Window requestor );
00158 virtual void getAtoms();
00159 private:
00160 Atom make_selection_atom( int screen );
00161 static Atom xa_version;
00162 };
00163
00164
00165
00166
00167
00168 template< typename T >
00169 class TemporaryAssign
00170 {
00171 public:
00172 TemporaryAssign( const T& var, const T& value )
00173 : variable( var ), orig( var )
00174 {
00175 const_cast< T& >( variable ) = value;
00176 }
00177 ~TemporaryAssign()
00178 {
00179 const_cast< T& >( variable ) = orig;
00180 }
00181 private:
00182 const T& variable;
00183 T orig;
00184 };
00185
00186 QCString getStringProperty(WId w, Atom prop, char separator=0);
00187 void updateXTime();
00188 void grabXServer();
00189 void ungrabXServer();
00190
00191
00192 #ifndef UrgencyHint
00193 #define UrgencyHint XUrgencyHint
00194 #endif
00195
00196
00197 #define KWIN_CHECK_PREDICATE( name, check ) \
00198 struct name \
00199 { \
00200 inline bool operator()( const Client* cl ) { return check; }; \
00201 }
00202
00203 #define KWIN_COMPARE_PREDICATE( name, type, check ) \
00204 struct name \
00205 { \
00206 typedef type type_helper; \
00207 inline name( const type_helper& compare_value ) : value( compare_value ) {}; \
00208 inline bool operator()( const Client* cl ) { return check; }; \
00209 const type_helper& value; \
00210 }
00211
00212 #define KWIN_PROCEDURE( name, action ) \
00213 struct name \
00214 { \
00215 inline void operator()( Client* cl ) { action; }; \
00216 }
00217
00218 KWIN_CHECK_PREDICATE( TruePredicate, cl == cl );
00219
00220 template< typename T >
00221 Client* findClientInList( const ClientList& list, T predicate )
00222 {
00223 for ( ClientList::ConstIterator it = list.begin(); it != list.end(); ++it)
00224 {
00225 if ( predicate( const_cast< const Client* >( *it)))
00226 return *it;
00227 }
00228 return NULL;
00229 }
00230
00231 inline
00232 int timestampCompare( Time time1, Time time2 )
00233 {
00234 if( time1 == time2 )
00235 return 0;
00236 return ( time1 - time2 ) < 1000000000 ? 1 : -1;
00237 }
00238
00239 inline
00240 Time timestampDiff( Time time1, Time time2 )
00241 {
00242 return time2 - time1;
00243 }
00244
00245 bool isLocalMachine( const QCString& host );
00246
00247 #ifndef KCMRULES
00248
00249 class ShortcutDialog
00250 : public KShortcutDialog
00251 {
00252 Q_OBJECT
00253 public:
00254 ShortcutDialog( const KShortcut& cut );
00255 virtual void accept();
00256 signals:
00257 void dialogDone( bool ok );
00258 protected:
00259 virtual void done( int r ) { KShortcutDialog::done( r ); emit dialogDone( r == Accepted ); }
00260 };
00261 #endif
00262
00263 }
00264
00265 #endif