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 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, // active fullscreen, or active dialog
00060     NumLayers // number of layers, must be last
00061     };
00062 
00063 // yes, I know this is not 100% like standard operator++
00064 inline void operator++( Layer& lay )
00065     {
00066     lay = static_cast< Layer >( lay + 1 );
00067     }
00068 
00069 // Some KWin classes, mainly Client and Workspace, are very tighly coupled,
00070 // and some of the methods of one class may be called only from speficic places.
00071 // Those methods have additional allowed_t argument. If you pass Allowed
00072 // as an argument to any function, make sure you really know what you're doing.
00073 enum allowed_t { Allowed };
00074 
00075 // some enums to have more readable code, instead of using bools
00076 enum ForceGeometry_t { NormalGeometrySet, ForceGeometrySet };
00077 
00078 // Areas, mostly related to Xinerama
00079 enum clientAreaOption
00080     {
00081     PlacementArea,         // geometry where a window will be initially placed after being mapped
00082     MovementArea,          // ???  window movement snapping area?  ignore struts
00083     MaximizeArea,          // geometry to which a window will be maximized
00084     MaximizeFullArea,      // like MaximizeArea, but ignore struts - used e.g. for fullscreening
00085     WorkArea,              // whole workarea (all screens together)
00086     FullArea,              // whole area (all screens together), ignore struts
00087     ScreenArea             // one whole screen, ignore struts
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 // the docs say it's UrgencyHint, but it's often #defined as XUrgencyHint
00150 #ifndef UrgencyHint
00151 #define UrgencyHint XUrgencyHint
00152 #endif
00153 
00154 // for STL-like algo's
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; /* in order to work also with type being 'const Client*' etc. */ \
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 /*true, avoid warning about '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 ) // like strcmp()
00191     {
00192     if( time1 == time2 )
00193         return 0;
00194     return ( time1 - time2 ) < 1000000000 ? 1 : -1; // time1 > time2 -> 1, handle wrapping
00195     }
00196 
00197 inline
00198 Time timestampDiff( Time time1, Time time2 ) // returns time2 - time1
00199     { // no need to handle wrapping?
00200     return time2 - time1;
00201     }
00202     
00203 } // namespace
00204 
00205 #endif
KDE Logo
This file is part of the documentation for kwin Library Version 3.2.2.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Thu Apr 29 21:20:54 2004 by doxygen 1.2.15 written by Dimitri van Heesch, © 1997-2003