utils.h
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 class Client;
00039 class Group;
00040 class Options;
00041
00042 typedef QValueList< Client* > ClientList;
00043 typedef QValueList< const Client* > ConstClientList;
00044
00045 typedef QValueList< Group* > GroupList;
00046 typedef QValueList< const Group* > ConstGroupList;
00047
00048 extern Options* options;
00049
00050 enum Layer
00051 {
00052 UnknownLayer = -1,
00053 FirstLayer = 0,
00054 DesktopLayer = FirstLayer,
00055 BelowLayer,
00056 NormalLayer,
00057 DockLayer,
00058 AboveLayer,
00059 ActiveLayer,
00060 NumLayers
00061 };
00062
00063
00064 inline void operator++( Layer& lay )
00065 {
00066 lay = static_cast< Layer >( lay + 1 );
00067 }
00068
00069
00070
00071
00072
00073 enum allowed_t { Allowed };
00074
00075
00076 enum ForceGeometry_t { NormalGeometrySet, ForceGeometrySet };
00077
00078
00079 enum clientAreaOption
00080 {
00081 PlacementArea,
00082 MovementArea,
00083 MaximizeArea,
00084 MaximizeFullArea,
00085 WorkArea,
00086 FullArea,
00087 ScreenArea
00088 };
00089
00090 class Shape
00091 {
00092 public:
00093 static bool available() { return kwin_has_shape; }
00094 static bool hasShape( WId w);
00095 static int shapeEvent();
00096 static void init();
00097 private:
00098 static int kwin_has_shape;
00099 static int kwin_shape_event;
00100 };
00101
00102 class Motif
00103 {
00104 public:
00105 static bool noBorder( WId w );
00106 static bool funcFlags( WId w, bool& resize, bool& move, bool& minimize,
00107 bool& maximize, bool& close );
00108 struct MwmHints
00109 {
00110 ulong flags;
00111 ulong functions;
00112 ulong decorations;
00113 long input_mode;
00114 ulong status;
00115 };
00116 enum { MWM_HINTS_FUNCTIONS = (1L << 0),
00117 MWM_HINTS_DECORATIONS = (1L << 1),
00118
00119 MWM_FUNC_ALL = (1L << 0),
00120 MWM_FUNC_RESIZE = (1L << 1),
00121 MWM_FUNC_MOVE = (1L << 2),
00122 MWM_FUNC_MINIMIZE = (1L << 3),
00123 MWM_FUNC_MAXIMIZE = (1L << 4),
00124 MWM_FUNC_CLOSE = (1L << 5)
00125 };
00126 };
00127
00128 class KWinSelectionOwner
00129 : public KSelectionOwner
00130 {
00131 Q_OBJECT
00132 public:
00133 KWinSelectionOwner( int screen );
00134 protected:
00135 virtual bool genericReply( Atom target, Atom property, Window requestor );
00136 virtual void replyTargets( Atom property, Window requestor );
00137 virtual void getAtoms();
00138 private:
00139 Atom make_selection_atom( int screen );
00140 static Atom xa_version;
00141 };
00142
00143
00144 QCString getStringProperty(WId w, Atom prop, char separator=0);
00145 void updateXTime();
00146 void grabXServer();
00147 void ungrabXServer();
00148
00149
00150 #ifndef UrgencyHint
00151 #define UrgencyHint XUrgencyHint
00152 #endif
00153
00154
00155 #define KWIN_CHECK_PREDICATE( name, check ) \
00156 struct name \
00157 { \
00158 inline bool operator()( const Client* cl ) { return check; }; \
00159 }
00160
00161 #define KWIN_COMPARE_PREDICATE( name, type, check ) \
00162 struct name \
00163 { \
00164 typedef type type_helper; \
00165 inline name( const type_helper& compare_value ) : value( compare_value ) {}; \
00166 inline bool operator()( const Client* cl ) { return check; }; \
00167 const type_helper& value; \
00168 }
00169
00170 #define KWIN_PROCEDURE( name, action ) \
00171 struct name \
00172 { \
00173 inline void operator()( Client* cl ) { action; }; \
00174 }
00175
00176 KWIN_CHECK_PREDICATE( TruePredicate, cl == cl );
00177
00178 template< typename T >
00179 Client* findClientInList( const ClientList& list, T predicate )
00180 {
00181 for ( ClientList::ConstIterator it = list.begin(); it != list.end(); ++it)
00182 {
00183 if ( predicate( const_cast< const Client* >( *it)))
00184 return *it;
00185 }
00186 return NULL;
00187 }
00188
00189 inline
00190 int timestampCompare( Time time1, Time time2 )
00191 {
00192 if( time1 == time2 )
00193 return 0;
00194 return ( time1 - time2 ) < 1000000000 ? 1 : -1;
00195 }
00196
00197 inline
00198 Time timestampDiff( Time time1, Time time2 )
00199 {
00200 return time2 - time1;
00201 }
00202
00203 }
00204
00205 #endif
This file is part of the documentation for kwin Library Version 3.2.1.