kwin Library API Documentation

utils.h

00001 /***************************************************************** 00002 KWin - the KDE window manager 00003 This file is part of the KDE project. 00004 00005 Copyright (C) 1999, 2000 Matthias Ettrich <ettrich@kde.org> 00006 Copyright (C) 2003 Lubos Lunak <l.lunak@kde.org> 00007 00008 You can Freely distribute this program under the GNU General Public 00009 License. See the file "COPYING" for the exact licensing terms. 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 | // need this, too! 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 DockLayer, 00060 AboveLayer, 00061 ActiveLayer, // active fullscreen, or active dialog 00062 NumLayers // number of layers, must be last 00063 }; 00064 00065 // yes, I know this is not 100% like standard operator++ 00066 inline void operator++( Layer& lay ) 00067 { 00068 lay = static_cast< Layer >( lay + 1 ); 00069 } 00070 00071 // for Client::takeActivity() 00072 enum ActivityFlags 00073 { 00074 ActivityFocus = 1 << 0, // focus the window 00075 ActivityFocusForce = 1 << 1, // focus even if Dock etc. 00076 ActivityRaise = 1 << 2 // raise the window 00077 }; 00078 00079 // Some KWin classes, mainly Client and Workspace, are very tighly coupled, 00080 // and some of the methods of one class may be called only from speficic places. 00081 // Those methods have additional allowed_t argument. If you pass Allowed 00082 // as an argument to any function, make sure you really know what you're doing. 00083 enum allowed_t { Allowed }; 00084 00085 // some enums to have more readable code, instead of using bools 00086 enum ForceGeometry_t { NormalGeometrySet, ForceGeometrySet }; 00087 00088 // Areas, mostly related to Xinerama 00089 enum clientAreaOption 00090 { 00091 PlacementArea, // geometry where a window will be initially placed after being mapped 00092 MovementArea, // ??? window movement snapping area? ignore struts 00093 MaximizeArea, // geometry to which a window will be maximized 00094 MaximizeFullArea, // like MaximizeArea, but ignore struts - used e.g. for topmenu 00095 FullScreenArea, // area for fullscreen windows 00096 // these below don't depend on xinerama settings 00097 WorkArea, // whole workarea (all screens together) 00098 FullArea, // whole area (all screens together), ignore struts 00099 ScreenArea // one whole screen, ignore struts 00100 }; 00101 00102 enum ShadeMode 00103 { 00104 ShadeNone, // not shaded 00105 ShadeNormal, // normally shaded - isShade() is true only here 00106 ShadeHover, // "shaded", but visible due to hover unshade 00107 ShadeActivated // "shaded", but visible due to alt+tab to the window 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 QCString getStringProperty(WId w, Atom prop, char separator=0); 00165 void updateXTime(); 00166 void grabXServer(); 00167 void ungrabXServer(); 00168 00169 // the docs say it's UrgencyHint, but it's often #defined as XUrgencyHint 00170 #ifndef UrgencyHint 00171 #define UrgencyHint XUrgencyHint 00172 #endif 00173 00174 // for STL-like algo's 00175 #define KWIN_CHECK_PREDICATE( name, check ) \ 00176 struct name \ 00177 { \ 00178 inline bool operator()( const Client* cl ) { return check; }; \ 00179 } 00180 00181 #define KWIN_COMPARE_PREDICATE( name, type, check ) \ 00182 struct name \ 00183 { \ 00184 typedef type type_helper; /* in order to work also with type being 'const Client*' etc. */ \ 00185 inline name( const type_helper& compare_value ) : value( compare_value ) {}; \ 00186 inline bool operator()( const Client* cl ) { return check; }; \ 00187 const type_helper& value; \ 00188 } 00189 00190 #define KWIN_PROCEDURE( name, action ) \ 00191 struct name \ 00192 { \ 00193 inline void operator()( Client* cl ) { action; }; \ 00194 } 00195 00196 KWIN_CHECK_PREDICATE( TruePredicate, cl == cl /*true, avoid warning about 'cl' */ ); 00197 00198 template< typename T > 00199 Client* findClientInList( const ClientList& list, T predicate ) 00200 { 00201 for ( ClientList::ConstIterator it = list.begin(); it != list.end(); ++it) 00202 { 00203 if ( predicate( const_cast< const Client* >( *it))) 00204 return *it; 00205 } 00206 return NULL; 00207 } 00208 00209 inline 00210 int timestampCompare( Time time1, Time time2 ) // like strcmp() 00211 { 00212 if( time1 == time2 ) 00213 return 0; 00214 return ( time1 - time2 ) < 1000000000 ? 1 : -1; // time1 > time2 -> 1, handle wrapping 00215 } 00216 00217 inline 00218 Time timestampDiff( Time time1, Time time2 ) // returns time2 - time1 00219 { // no need to handle wrapping? 00220 return time2 - time1; 00221 } 00222 00223 bool isLocalMachine( const QCString& host ); 00224 00225 } // namespace 00226 00227 #endif
KDE Logo
This file is part of the documentation for kwin Library Version 3.3.0.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Fri Aug 13 21:47:06 2004 by doxygen 1.3.8 written by Dimitri van Heesch, © 1997-2003