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