2004-05-28 13:51:11 +00:00
|
|
|
/*****************************************************************
|
|
|
|
KWin - the KDE window manager
|
|
|
|
This file is part of the KDE project.
|
|
|
|
|
|
|
|
Copyright (C) 2004 Lubos Lunak <l.lunak@kde.org>
|
|
|
|
|
|
|
|
You can Freely distribute this program under the GNU General Public
|
|
|
|
License. See the file "COPYING" for the exact licensing terms.
|
|
|
|
******************************************************************/
|
|
|
|
|
|
|
|
#ifndef KWIN_RULES_H
|
|
|
|
#define KWIN_RULES_H
|
|
|
|
|
|
|
|
#include <qstring.h>
|
2004-05-28 15:04:01 +00:00
|
|
|
#include <netwm_def.h>
|
2004-05-31 14:15:33 +00:00
|
|
|
#include <qrect.h>
|
2004-06-18 08:57:42 +00:00
|
|
|
#include <qvaluevector.h>
|
|
|
|
#include <kdebug.h>
|
2004-05-28 13:51:11 +00:00
|
|
|
|
2004-05-31 14:14:10 +00:00
|
|
|
#include "placement.h"
|
2004-06-03 14:09:45 +00:00
|
|
|
#include "lib/kdecoration.h"
|
2004-06-09 08:33:53 +00:00
|
|
|
#include "options.h"
|
2004-06-18 08:57:42 +00:00
|
|
|
#include "utils.h"
|
2004-05-31 14:14:10 +00:00
|
|
|
|
2004-05-28 13:51:11 +00:00
|
|
|
class KConfig;
|
|
|
|
|
|
|
|
namespace KWinInternal
|
|
|
|
{
|
|
|
|
|
|
|
|
class Client;
|
2004-06-18 08:57:42 +00:00
|
|
|
class Rules;
|
2004-05-28 13:51:11 +00:00
|
|
|
|
2004-06-21 16:25:24 +00:00
|
|
|
#ifndef KCMRULES // only for kwin core
|
|
|
|
|
2004-05-28 13:51:11 +00:00
|
|
|
class WindowRules
|
2004-06-03 14:09:45 +00:00
|
|
|
: public KDecorationDefines
|
2004-05-28 13:51:11 +00:00
|
|
|
{
|
|
|
|
public:
|
2004-06-18 08:57:42 +00:00
|
|
|
WindowRules( const QValueVector< Rules* >& rules );
|
2004-05-28 13:51:11 +00:00
|
|
|
WindowRules();
|
|
|
|
void update( Client* );
|
2004-06-18 08:57:42 +00:00
|
|
|
void discardTemporary();
|
2004-05-31 14:14:10 +00:00
|
|
|
Placement::Policy checkPlacement( Placement::Policy placement ) const;
|
2004-06-18 08:57:42 +00:00
|
|
|
QRect checkGeometry( QRect rect, bool init = false ) const;
|
2004-05-31 14:25:25 +00:00
|
|
|
// use 'invalidPoint' with checkPosition, unlike QSize() and QRect(), QPoint() is a valid point
|
2004-06-18 08:57:42 +00:00
|
|
|
QPoint checkPosition( QPoint pos, bool init = false ) const;
|
|
|
|
QSize checkSize( QSize s, bool init = false ) const;
|
|
|
|
QSize checkMinSize( QSize s ) const;
|
|
|
|
QSize checkMaxSize( QSize s ) const;
|
2005-01-15 17:07:48 +00:00
|
|
|
int checkOpacityActive(int s) const;
|
|
|
|
int checkOpacityInactive(int s) const;
|
2004-06-21 12:38:40 +00:00
|
|
|
bool checkIgnorePosition( bool ignore ) const;
|
2004-05-28 13:51:11 +00:00
|
|
|
int checkDesktop( int desktop, bool init = false ) const;
|
2004-05-31 14:14:10 +00:00
|
|
|
NET::WindowType checkType( NET::WindowType type ) const;
|
2004-06-03 14:09:45 +00:00
|
|
|
MaximizeMode checkMaximize( MaximizeMode mode, bool init = false ) const;
|
|
|
|
bool checkMinimize( bool minimized, bool init = false ) const;
|
2004-06-18 08:57:42 +00:00
|
|
|
ShadeMode checkShade( ShadeMode shade, bool init = false ) const;
|
2004-06-03 14:09:45 +00:00
|
|
|
bool checkSkipTaskbar( bool skip, bool init = false ) const;
|
|
|
|
bool checkSkipPager( bool skip, bool init = false ) const;
|
2004-05-28 13:51:11 +00:00
|
|
|
bool checkKeepAbove( bool above, bool init = false ) const;
|
2004-06-03 14:09:45 +00:00
|
|
|
bool checkKeepBelow( bool below, bool init = false ) const;
|
|
|
|
bool checkFullScreen( bool fs, bool init = false ) const;
|
|
|
|
bool checkNoBorder( bool noborder, bool init = false ) const;
|
2004-06-09 08:29:35 +00:00
|
|
|
int checkFSP( int fsp ) const;
|
2004-06-09 08:30:06 +00:00
|
|
|
bool checkAcceptFocus( bool focus ) const;
|
2004-06-09 08:33:53 +00:00
|
|
|
Options::MoveResizeMode checkMoveResizeMode( Options::MoveResizeMode mode ) const;
|
|
|
|
bool checkCloseable( bool closeable ) const;
|
2005-01-17 13:35:48 +00:00
|
|
|
bool checkStrictGeometry( bool strict ) const;
|
2005-01-17 15:53:14 +00:00
|
|
|
QString checkShortcut( QString s, bool init = false ) const;
|
2004-05-28 13:51:11 +00:00
|
|
|
private:
|
2004-06-18 08:57:42 +00:00
|
|
|
MaximizeMode checkMaximizeVert( MaximizeMode mode, bool init ) const;
|
|
|
|
MaximizeMode checkMaximizeHoriz( MaximizeMode mode, bool init ) const;
|
|
|
|
QValueVector< Rules* > rules;
|
|
|
|
};
|
2004-06-21 16:25:24 +00:00
|
|
|
#endif
|
2004-06-18 08:57:42 +00:00
|
|
|
|
|
|
|
class Rules
|
|
|
|
: public KDecorationDefines
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
Rules();
|
|
|
|
Rules( KConfig& );
|
|
|
|
Rules( const QString&, bool temporary );
|
|
|
|
void write( KConfig& ) const;
|
2004-07-29 17:08:25 +00:00
|
|
|
bool isEmpty() const;
|
2004-06-21 16:25:24 +00:00
|
|
|
#ifndef KCMRULES
|
2004-07-29 17:08:25 +00:00
|
|
|
bool match( const Client* c ) const;
|
2004-06-18 08:57:42 +00:00
|
|
|
bool update( Client* );
|
|
|
|
bool isTemporary() const;
|
|
|
|
bool discardTemporary( bool force ); // removes if temporary and forced or too old
|
|
|
|
bool applyPlacement( Placement::Policy& placement ) const;
|
|
|
|
bool applyGeometry( QRect& rect, bool init ) const;
|
|
|
|
// use 'invalidPoint' with applyPosition, unlike QSize() and QRect(), QPoint() is a valid point
|
|
|
|
bool applyPosition( QPoint& pos, bool init ) const;
|
|
|
|
bool applySize( QSize& s, bool init ) const;
|
|
|
|
bool applyMinSize( QSize& s ) const;
|
|
|
|
bool applyMaxSize( QSize& s ) const;
|
2005-01-15 17:07:48 +00:00
|
|
|
bool applyOpacityActive(int& s) const;
|
|
|
|
bool applyOpacityInactive(int& s) const;
|
2004-06-21 12:38:40 +00:00
|
|
|
bool applyIgnorePosition( bool& ignore ) const;
|
2004-06-18 08:57:42 +00:00
|
|
|
bool applyDesktop( int& desktop, bool init ) const;
|
|
|
|
bool applyType( NET::WindowType& type ) const;
|
|
|
|
bool applyMaximizeVert( MaximizeMode& mode, bool init ) const;
|
|
|
|
bool applyMaximizeHoriz( MaximizeMode& mode, bool init ) const;
|
|
|
|
bool applyMinimize( bool& minimized, bool init ) const;
|
|
|
|
bool applyShade( ShadeMode& shade, bool init ) const;
|
|
|
|
bool applySkipTaskbar( bool& skip, bool init ) const;
|
|
|
|
bool applySkipPager( bool& skip, bool init ) const;
|
|
|
|
bool applyKeepAbove( bool& above, bool init ) const;
|
|
|
|
bool applyKeepBelow( bool& below, bool init ) const;
|
|
|
|
bool applyFullScreen( bool& fs, bool init ) const;
|
|
|
|
bool applyNoBorder( bool& noborder, bool init ) const;
|
|
|
|
bool applyFSP( int& fsp ) const;
|
|
|
|
bool applyAcceptFocus( bool& focus ) const;
|
|
|
|
bool applyMoveResizeMode( Options::MoveResizeMode& mode ) const;
|
|
|
|
bool applyCloseable( bool& closeable ) const;
|
2005-01-17 13:35:48 +00:00
|
|
|
bool applyStrictGeometry( bool& strict ) const;
|
2005-01-17 15:53:14 +00:00
|
|
|
bool applyShortcut( QString& shortcut, bool init ) const;
|
2004-06-18 08:57:42 +00:00
|
|
|
private:
|
2004-06-21 16:25:24 +00:00
|
|
|
#endif
|
2004-07-29 17:08:25 +00:00
|
|
|
bool matchType( NET::WindowType match_type ) const;
|
|
|
|
bool matchWMClass( const QCString& match_class, const QCString& match_name ) const;
|
|
|
|
bool matchRole( const QCString& match_role ) const;
|
|
|
|
bool matchTitle( const QString& match_title ) const;
|
|
|
|
bool matchClientMachine( const QCString& match_machine ) const;
|
2004-10-01 12:58:50 +00:00
|
|
|
// All these values are saved to the cfg file, and are also used in kstart!
|
|
|
|
enum
|
2004-06-18 08:57:42 +00:00
|
|
|
{
|
|
|
|
Unused = 0,
|
|
|
|
DontAffect, // use the default value
|
|
|
|
Force, // force the given value
|
|
|
|
Apply, // apply only after initial mapping
|
|
|
|
Remember // like apply, and remember the value when the window is withdrawn
|
|
|
|
};
|
|
|
|
enum SetRule
|
|
|
|
{
|
|
|
|
UnusedSetRule = Unused,
|
|
|
|
SetRuleDummy = 256 // so that it's at least short int
|
|
|
|
};
|
|
|
|
enum ForceRule
|
|
|
|
{
|
|
|
|
UnusedForceRule = Unused,
|
|
|
|
ForceRuleDummy = 256 // so that it's at least short int
|
|
|
|
};
|
2004-06-25 11:28:17 +00:00
|
|
|
enum StringMatch
|
|
|
|
{
|
|
|
|
FirstStringMatch,
|
|
|
|
UnimportantMatch = FirstStringMatch,
|
|
|
|
ExactMatch,
|
|
|
|
SubstringMatch,
|
|
|
|
RegExpMatch,
|
|
|
|
LastStringMatch = RegExpMatch
|
|
|
|
};
|
2004-06-11 15:10:09 +00:00
|
|
|
void readFromCfg( KConfig& cfg );
|
2004-06-18 08:57:42 +00:00
|
|
|
static SetRule readSetRule( KConfig&, const QString& key );
|
|
|
|
static ForceRule readForceRule( KConfig&, const QString& key );
|
2004-05-28 15:04:01 +00:00
|
|
|
static NET::WindowType readType( KConfig&, const QString& key );
|
2004-06-21 16:25:24 +00:00
|
|
|
#ifndef KCMRULES
|
2004-06-18 08:57:42 +00:00
|
|
|
static bool checkSetRule( SetRule rule, bool init );
|
|
|
|
static bool checkForceRule( ForceRule rule );
|
|
|
|
static bool checkSetStop( SetRule rule );
|
|
|
|
static bool checkForceStop( ForceRule rule );
|
2004-06-21 16:25:24 +00:00
|
|
|
#endif
|
2004-06-11 15:10:09 +00:00
|
|
|
int temporary_state; // e.g. for kstart
|
2004-06-21 16:25:24 +00:00
|
|
|
QString description;
|
2004-05-28 13:51:11 +00:00
|
|
|
QCString wmclass;
|
2004-06-25 11:28:17 +00:00
|
|
|
StringMatch wmclassmatch;
|
2004-05-28 13:54:20 +00:00
|
|
|
bool wmclasscomplete;
|
2004-05-28 13:51:11 +00:00
|
|
|
QCString windowrole;
|
2004-06-25 11:28:17 +00:00
|
|
|
StringMatch windowrolematch;
|
2004-05-28 13:51:11 +00:00
|
|
|
QString title; // TODO "caption" ?
|
2004-06-25 11:28:17 +00:00
|
|
|
StringMatch titlematch;
|
2004-05-28 13:51:11 +00:00
|
|
|
QCString extrarole;
|
2004-06-25 11:28:17 +00:00
|
|
|
StringMatch extrarolematch;
|
2004-05-28 13:54:20 +00:00
|
|
|
QCString clientmachine;
|
2004-06-25 11:28:17 +00:00
|
|
|
StringMatch clientmachinematch;
|
2004-05-31 14:04:49 +00:00
|
|
|
unsigned long types; // types for matching
|
2004-05-31 14:14:10 +00:00
|
|
|
Placement::Policy placement;
|
2004-06-18 08:57:42 +00:00
|
|
|
ForceRule placementrule;
|
2004-05-31 14:25:25 +00:00
|
|
|
QPoint position;
|
2004-06-18 08:57:42 +00:00
|
|
|
SetRule positionrule;
|
2004-05-31 14:25:25 +00:00
|
|
|
QSize size;
|
2004-06-18 08:57:42 +00:00
|
|
|
SetRule sizerule;
|
2004-05-31 14:15:33 +00:00
|
|
|
QSize minsize;
|
2004-06-18 08:57:42 +00:00
|
|
|
ForceRule minsizerule;
|
2004-05-31 14:15:33 +00:00
|
|
|
QSize maxsize;
|
2004-06-18 08:57:42 +00:00
|
|
|
ForceRule maxsizerule;
|
2005-01-15 17:07:48 +00:00
|
|
|
int opacityactive;
|
|
|
|
ForceRule opacityactiverule;
|
|
|
|
int opacityinactive;
|
|
|
|
ForceRule opacityinactiverule;
|
2004-06-21 12:38:40 +00:00
|
|
|
bool ignoreposition;
|
|
|
|
ForceRule ignorepositionrule;
|
2004-05-28 13:51:11 +00:00
|
|
|
int desktop;
|
2004-06-18 08:57:42 +00:00
|
|
|
SetRule desktoprule;
|
2004-05-31 14:04:49 +00:00
|
|
|
NET::WindowType type; // type for setting
|
2004-06-18 08:57:42 +00:00
|
|
|
ForceRule typerule;
|
2004-06-03 14:09:45 +00:00
|
|
|
bool maximizevert;
|
2004-06-18 08:57:42 +00:00
|
|
|
SetRule maximizevertrule;
|
2004-06-03 14:09:45 +00:00
|
|
|
bool maximizehoriz;
|
2004-06-18 08:57:42 +00:00
|
|
|
SetRule maximizehorizrule;
|
2004-06-03 14:09:45 +00:00
|
|
|
bool minimize;
|
2004-06-18 08:57:42 +00:00
|
|
|
SetRule minimizerule;
|
2004-06-03 14:09:45 +00:00
|
|
|
bool shade;
|
2004-06-18 08:57:42 +00:00
|
|
|
SetRule shaderule;
|
2004-06-03 14:09:45 +00:00
|
|
|
bool skiptaskbar;
|
2004-06-18 08:57:42 +00:00
|
|
|
SetRule skiptaskbarrule;
|
2004-06-03 14:09:45 +00:00
|
|
|
bool skippager;
|
2004-06-18 08:57:42 +00:00
|
|
|
SetRule skippagerrule;
|
2004-05-28 13:51:11 +00:00
|
|
|
bool above;
|
2004-06-18 08:57:42 +00:00
|
|
|
SetRule aboverule;
|
2004-05-28 13:51:11 +00:00
|
|
|
bool below;
|
2004-06-18 08:57:42 +00:00
|
|
|
SetRule belowrule;
|
2004-06-03 14:09:45 +00:00
|
|
|
bool fullscreen;
|
2004-06-18 08:57:42 +00:00
|
|
|
SetRule fullscreenrule;
|
2004-06-03 14:09:45 +00:00
|
|
|
bool noborder;
|
2004-06-18 08:57:42 +00:00
|
|
|
SetRule noborderrule;
|
2004-06-11 15:12:07 +00:00
|
|
|
int fsplevel;
|
2004-06-18 08:57:42 +00:00
|
|
|
ForceRule fsplevelrule;
|
2004-06-09 08:30:06 +00:00
|
|
|
bool acceptfocus;
|
2004-06-18 08:57:42 +00:00
|
|
|
ForceRule acceptfocusrule;
|
2004-06-09 08:33:53 +00:00
|
|
|
Options::MoveResizeMode moveresizemode;
|
2004-06-18 08:57:42 +00:00
|
|
|
ForceRule moveresizemoderule;
|
2004-06-09 08:33:53 +00:00
|
|
|
bool closeable;
|
2004-06-18 08:57:42 +00:00
|
|
|
ForceRule closeablerule;
|
2005-01-17 13:35:48 +00:00
|
|
|
bool strictgeometry;
|
|
|
|
ForceRule strictgeometryrule;
|
2005-01-17 15:53:14 +00:00
|
|
|
QString shortcut;
|
|
|
|
SetRule shortcutrule;
|
2004-06-18 08:57:42 +00:00
|
|
|
friend kdbgstream& operator<<( kdbgstream& stream, const Rules* );
|
2004-05-28 13:51:11 +00:00
|
|
|
};
|
|
|
|
|
2004-06-21 16:25:24 +00:00
|
|
|
#ifndef KCMRULES
|
2004-05-28 13:51:11 +00:00
|
|
|
inline
|
2004-06-18 08:57:42 +00:00
|
|
|
bool Rules::checkSetRule( SetRule rule, bool init )
|
2004-05-28 13:51:11 +00:00
|
|
|
{
|
2004-06-18 22:06:04 +00:00
|
|
|
if( rule > ( SetRule )DontAffect) // Unused or DontAffect
|
2004-05-28 13:51:11 +00:00
|
|
|
{
|
2004-06-18 22:06:04 +00:00
|
|
|
if( rule == ( SetRule )Force || init )
|
2004-05-28 13:51:11 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2004-05-28 15:04:01 +00:00
|
|
|
inline
|
2004-06-18 08:57:42 +00:00
|
|
|
bool Rules::checkForceRule( ForceRule rule )
|
2004-05-28 15:04:01 +00:00
|
|
|
{
|
2004-06-18 22:06:04 +00:00
|
|
|
return rule == ( ForceRule )Force;
|
2004-05-28 15:04:01 +00:00
|
|
|
}
|
|
|
|
|
2004-06-18 08:57:42 +00:00
|
|
|
inline
|
|
|
|
bool Rules::checkSetStop( SetRule rule )
|
|
|
|
{
|
|
|
|
return rule != UnusedSetRule;
|
|
|
|
}
|
|
|
|
|
|
|
|
inline
|
|
|
|
bool Rules::checkForceStop( ForceRule rule )
|
|
|
|
{
|
|
|
|
return rule != UnusedForceRule;
|
|
|
|
}
|
|
|
|
|
|
|
|
inline
|
|
|
|
WindowRules::WindowRules( const QValueVector< Rules* >& r )
|
|
|
|
: rules( r )
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
inline
|
|
|
|
WindowRules::WindowRules()
|
|
|
|
{
|
|
|
|
}
|
2004-06-21 16:25:24 +00:00
|
|
|
#endif
|
2004-06-18 08:57:42 +00:00
|
|
|
|
|
|
|
#ifdef NDEBUG
|
|
|
|
inline
|
|
|
|
kndbgstream& operator<<( kndbgstream& stream, const Rules* ) { return stream; }
|
|
|
|
#else
|
|
|
|
kdbgstream& operator<<( kdbgstream& stream, const Rules* );
|
|
|
|
#endif
|
|
|
|
|
2004-05-28 13:51:11 +00:00
|
|
|
} // namespace
|
|
|
|
|
|
|
|
#endif
|