kwin Library API Documentation

rules.h

00001 /*****************************************************************
00002  KWin - the KDE window manager
00003  This file is part of the KDE project.
00004 
00005 Copyright (C) 2004 Lubos Lunak <l.lunak@kde.org>
00006 
00007 You can Freely distribute this program under the GNU General Public
00008 License. See the file "COPYING" for the exact licensing terms.
00009 ******************************************************************/
00010 
00011 #ifndef KWIN_RULES_H
00012 #define KWIN_RULES_H
00013 
00014 #include <qstring.h>
00015 #include <netwm_def.h>
00016 #include <qrect.h>
00017 #include <qvaluevector.h>
00018 #include <kdebug.h>
00019 
00020 #include "placement.h"
00021 #include "lib/kdecoration.h"
00022 #include "options.h"
00023 #include "utils.h"
00024 
00025 class KConfig;
00026 
00027 namespace KWinInternal
00028 {
00029 
00030 class Client;
00031 class Rules;
00032 
00033 #ifndef KCMRULES // only for kwin core
00034 
00035 class WindowRules
00036     : public KDecorationDefines
00037     {
00038     public:
00039         WindowRules( const QValueVector< Rules* >& rules );
00040         WindowRules();
00041         void update( Client* );
00042         void discardTemporary();
00043         Placement::Policy checkPlacement( Placement::Policy placement ) const;
00044         QRect checkGeometry( QRect rect, bool init = false ) const;
00045         // use 'invalidPoint' with checkPosition, unlike QSize() and QRect(), QPoint() is a valid point
00046         QPoint checkPosition( QPoint pos, bool init = false ) const;
00047         QSize checkSize( QSize s, bool init = false ) const;
00048         QSize checkMinSize( QSize s ) const;
00049         QSize checkMaxSize( QSize s ) const;
00050         int checkOpacityActive(int s) const;
00051         int checkOpacityInactive(int s) const;
00052         bool checkIgnorePosition( bool ignore ) const;
00053         int checkDesktop( int desktop, bool init = false ) const;
00054         NET::WindowType checkType( NET::WindowType type ) const;
00055         MaximizeMode checkMaximize( MaximizeMode mode, bool init = false ) const;
00056         bool checkMinimize( bool minimized, bool init = false ) const;
00057         ShadeMode checkShade( ShadeMode shade, bool init = false ) const;
00058         bool checkSkipTaskbar( bool skip, bool init = false ) const;
00059         bool checkSkipPager( bool skip, bool init = false ) const;
00060         bool checkKeepAbove( bool above, bool init = false ) const;
00061         bool checkKeepBelow( bool below, bool init = false ) const;
00062         bool checkFullScreen( bool fs, bool init = false ) const;
00063         bool checkNoBorder( bool noborder, bool init = false ) const;
00064         int checkFSP( int fsp ) const;
00065         bool checkAcceptFocus( bool focus ) const;
00066         Options::MoveResizeMode checkMoveResizeMode( Options::MoveResizeMode mode ) const;
00067         bool checkCloseable( bool closeable ) const;
00068         bool checkStrictGeometry( bool strict ) const;
00069         QString checkShortcut( QString s, bool init = false ) const;
00070     private:
00071         MaximizeMode checkMaximizeVert( MaximizeMode mode, bool init ) const;
00072         MaximizeMode checkMaximizeHoriz( MaximizeMode mode, bool init ) const;
00073         QValueVector< Rules* > rules;
00074     };
00075 #endif
00076 
00077 class Rules
00078     : public KDecorationDefines
00079     {
00080     public:
00081         Rules();
00082         Rules( KConfig& );
00083         Rules( const QString&, bool temporary );
00084         void write( KConfig& ) const;
00085         bool isEmpty() const;
00086 #ifndef KCMRULES
00087         bool match( const Client* c ) const;
00088         bool update( Client* );
00089         bool isTemporary() const;
00090         bool discardTemporary( bool force ); // removes if temporary and forced or too old
00091         bool applyPlacement( Placement::Policy& placement ) const;
00092         bool applyGeometry( QRect& rect, bool init ) const;
00093         // use 'invalidPoint' with applyPosition, unlike QSize() and QRect(), QPoint() is a valid point
00094         bool applyPosition( QPoint& pos, bool init ) const;
00095         bool applySize( QSize& s, bool init ) const;
00096         bool applyMinSize( QSize& s ) const;
00097         bool applyMaxSize( QSize& s ) const;
00098         bool applyOpacityActive(int& s) const;
00099         bool applyOpacityInactive(int& s) const;
00100         bool applyIgnorePosition( bool& ignore ) const;
00101         bool applyDesktop( int& desktop, bool init ) const;
00102         bool applyType( NET::WindowType& type ) const;
00103         bool applyMaximizeVert( MaximizeMode& mode, bool init ) const;
00104         bool applyMaximizeHoriz( MaximizeMode& mode, bool init ) const;
00105         bool applyMinimize( bool& minimized, bool init ) const;
00106         bool applyShade( ShadeMode& shade, bool init ) const;
00107         bool applySkipTaskbar( bool& skip, bool init ) const;
00108         bool applySkipPager( bool& skip, bool init ) const;
00109         bool applyKeepAbove( bool& above, bool init ) const;
00110         bool applyKeepBelow( bool& below, bool init ) const;
00111         bool applyFullScreen( bool& fs, bool init ) const;
00112         bool applyNoBorder( bool& noborder, bool init ) const;
00113         bool applyFSP( int& fsp ) const;
00114         bool applyAcceptFocus( bool& focus ) const;
00115         bool applyMoveResizeMode( Options::MoveResizeMode& mode ) const;
00116         bool applyCloseable( bool& closeable ) const;
00117         bool applyStrictGeometry( bool& strict ) const;
00118         bool applyShortcut( QString& shortcut, bool init ) const;
00119     private:
00120 #endif
00121         bool matchType( NET::WindowType match_type ) const;
00122         bool matchWMClass( const QCString& match_class, const QCString& match_name ) const;
00123         bool matchRole( const QCString& match_role ) const;
00124         bool matchTitle( const QString& match_title ) const;
00125         bool matchClientMachine( const QCString& match_machine ) const;
00126         // All these values are saved to the cfg file, and are also used in kstart!
00127         enum
00128             {
00129             Unused = 0,
00130             DontAffect, // use the default value
00131             Force,      // force the given value
00132             Apply,      // apply only after initial mapping
00133             Remember   // like apply, and remember the value when the window is withdrawn
00134             };
00135         enum SetRule
00136             {
00137             UnusedSetRule = Unused,
00138             SetRuleDummy = 256   // so that it's at least short int
00139             };
00140         enum ForceRule
00141             {
00142             UnusedForceRule = Unused,
00143             ForceRuleDummy = 256   // so that it's at least short int
00144             };
00145         enum StringMatch
00146             {
00147             FirstStringMatch,
00148             UnimportantMatch = FirstStringMatch,
00149             ExactMatch,
00150             SubstringMatch,
00151             RegExpMatch,
00152             LastStringMatch = RegExpMatch
00153             };
00154         void readFromCfg( KConfig& cfg );
00155         static SetRule readSetRule( KConfig&, const QString& key );
00156         static ForceRule readForceRule( KConfig&, const QString& key );
00157         static NET::WindowType readType( KConfig&, const QString& key );
00158 #ifndef KCMRULES
00159         static bool checkSetRule( SetRule rule, bool init );
00160         static bool checkForceRule( ForceRule rule );
00161         static bool checkSetStop( SetRule rule );
00162         static bool checkForceStop( ForceRule rule );
00163 #endif
00164         int temporary_state; // e.g. for kstart
00165         QString description;
00166         QCString wmclass;
00167         StringMatch wmclassmatch;
00168         bool wmclasscomplete;
00169         QCString windowrole;
00170         StringMatch windowrolematch;
00171         QString title; // TODO "caption" ?
00172         StringMatch titlematch;
00173         QCString extrarole;
00174         StringMatch extrarolematch;
00175         QCString clientmachine;
00176         StringMatch clientmachinematch;
00177         unsigned long types; // types for matching
00178         Placement::Policy placement;
00179         ForceRule placementrule;
00180         QPoint position;
00181         SetRule positionrule;
00182         QSize size;
00183         SetRule sizerule;
00184         QSize minsize;
00185         ForceRule minsizerule;
00186         QSize maxsize;
00187         ForceRule maxsizerule;
00188         int opacityactive;
00189         ForceRule opacityactiverule;
00190         int opacityinactive;
00191         ForceRule opacityinactiverule;
00192         bool ignoreposition;
00193         ForceRule ignorepositionrule;
00194         int desktop;
00195         SetRule desktoprule;
00196         NET::WindowType type; // type for setting
00197         ForceRule typerule;
00198         bool maximizevert;
00199         SetRule maximizevertrule;
00200         bool maximizehoriz;
00201         SetRule maximizehorizrule;
00202         bool minimize;
00203         SetRule minimizerule;
00204         bool shade;
00205         SetRule shaderule;
00206         bool skiptaskbar;
00207         SetRule skiptaskbarrule;
00208         bool skippager;
00209         SetRule skippagerrule;
00210         bool above;
00211         SetRule aboverule;
00212         bool below;
00213         SetRule belowrule;
00214         bool fullscreen;
00215         SetRule fullscreenrule;
00216         bool noborder;
00217         SetRule noborderrule;
00218         int fsplevel;
00219         ForceRule fsplevelrule;
00220         bool acceptfocus;
00221         ForceRule acceptfocusrule;
00222         Options::MoveResizeMode moveresizemode;
00223         ForceRule moveresizemoderule;
00224         bool closeable;
00225         ForceRule closeablerule;
00226         bool strictgeometry;
00227         ForceRule strictgeometryrule;
00228         QString shortcut;
00229         SetRule shortcutrule;
00230         friend kdbgstream& operator<<( kdbgstream& stream, const Rules* );
00231     };
00232 
00233 #ifndef KCMRULES
00234 inline
00235 bool Rules::checkSetRule( SetRule rule, bool init )
00236     {
00237     if( rule > ( SetRule )DontAffect) // Unused or DontAffect
00238         {
00239         if( rule == ( SetRule )Force || init )
00240             return true;
00241         }
00242     return false;
00243     }
00244 
00245 inline
00246 bool Rules::checkForceRule( ForceRule rule )
00247     {
00248     return rule == ( ForceRule )Force;
00249     }
00250 
00251 inline
00252 bool Rules::checkSetStop( SetRule rule )
00253     {
00254     return rule != UnusedSetRule;
00255     }
00256     
00257 inline
00258 bool Rules::checkForceStop( ForceRule rule )
00259     {
00260     return rule != UnusedForceRule;
00261     }
00262 
00263 inline
00264 WindowRules::WindowRules( const QValueVector< Rules* >& r )
00265     : rules( r )
00266     {
00267     }
00268 
00269 inline
00270 WindowRules::WindowRules()
00271     {
00272     }
00273 #endif
00274 
00275 #ifdef NDEBUG
00276 inline
00277 kndbgstream& operator<<( kndbgstream& stream, const Rules* ) { return stream; }
00278 #else
00279 kdbgstream& operator<<( kdbgstream& stream, const Rules* );
00280 #endif
00281 
00282 } // namespace
00283 
00284 #endif
KDE Logo
This file is part of the documentation for kwin Library Version 3.4.1.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Fri Sep 30 18:40:43 2005 by doxygen 1.4.3 written by Dimitri van Heesch, © 1997-2003