KWin rules setting maximizevert, maximizehoriz, minimize, shade, skiptaskbar,
skippager, fullscreen, noborder. svn path=/trunk/kdebase/kwin/; revision=317377
This commit is contained in:
parent
05c003dd28
commit
03bdeb94b0
5 changed files with 154 additions and 32 deletions
|
@ -400,6 +400,7 @@ void Client::setUserNoBorder( bool set )
|
||||||
{
|
{
|
||||||
if( !userCanSetNoBorder())
|
if( !userCanSetNoBorder())
|
||||||
return;
|
return;
|
||||||
|
set = rules()->checkNoBorder( set );
|
||||||
if( user_noborder == set )
|
if( user_noborder == set )
|
||||||
return;
|
return;
|
||||||
user_noborder = set;
|
user_noborder = set;
|
||||||
|
@ -687,6 +688,7 @@ void Client::setShade( ShadeMode mode )
|
||||||
{
|
{
|
||||||
if( !isShadeable())
|
if( !isShadeable())
|
||||||
return;
|
return;
|
||||||
|
mode = rules()->checkShade( mode );
|
||||||
if( shade_mode == mode )
|
if( shade_mode == mode )
|
||||||
return;
|
return;
|
||||||
bool was_shade = isShade();
|
bool was_shade = isShade();
|
||||||
|
@ -1053,7 +1055,10 @@ void Client::processKillerExited()
|
||||||
void Client::setSkipTaskbar( bool b, bool from_outside )
|
void Client::setSkipTaskbar( bool b, bool from_outside )
|
||||||
{
|
{
|
||||||
if( from_outside )
|
if( from_outside )
|
||||||
|
{
|
||||||
|
b = rules()->checkSkipTaskbar( b );
|
||||||
original_skip_taskbar = b;
|
original_skip_taskbar = b;
|
||||||
|
}
|
||||||
if ( b == skipTaskbar() )
|
if ( b == skipTaskbar() )
|
||||||
return;
|
return;
|
||||||
skip_taskbar = b;
|
skip_taskbar = b;
|
||||||
|
@ -1062,6 +1067,7 @@ void Client::setSkipTaskbar( bool b, bool from_outside )
|
||||||
|
|
||||||
void Client::setSkipPager( bool b )
|
void Client::setSkipPager( bool b )
|
||||||
{
|
{
|
||||||
|
b = rules()->checkSkipPager( b );
|
||||||
if ( b == skipPager() )
|
if ( b == skipPager() )
|
||||||
return;
|
return;
|
||||||
skip_pager = b;
|
skip_pager = b;
|
||||||
|
|
|
@ -1665,8 +1665,6 @@ void Client::changeMaximize( bool vertical, bool horizontal, bool adjust )
|
||||||
if( !isMaximizable())
|
if( !isMaximizable())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
++block_geometry; // TODO GeometryBlocker class?
|
|
||||||
|
|
||||||
if( isShade()) // SELI SHADE
|
if( isShade()) // SELI SHADE
|
||||||
setShade( ShadeNone );
|
setShade( ShadeNone );
|
||||||
|
|
||||||
|
@ -1679,6 +1677,12 @@ void Client::changeMaximize( bool vertical, bool horizontal, bool adjust )
|
||||||
if( horizontal )
|
if( horizontal )
|
||||||
max_mode = MaximizeMode( max_mode ^ MaximizeHorizontal );
|
max_mode = MaximizeMode( max_mode ^ MaximizeHorizontal );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
max_mode = rules()->checkMaximize( max_mode );
|
||||||
|
if( !adjust && max_mode == old_mode )
|
||||||
|
return;
|
||||||
|
|
||||||
|
++block_geometry; // TODO GeometryBlocker class?
|
||||||
|
|
||||||
// maximing one way and unmaximizing the other way shouldn't happen
|
// maximing one way and unmaximizing the other way shouldn't happen
|
||||||
Q_ASSERT( !( vertical && horizontal )
|
Q_ASSERT( !( vertical && horizontal )
|
||||||
|
@ -1846,6 +1850,7 @@ void Client::setFullScreen( bool set, bool user )
|
||||||
return;
|
return;
|
||||||
if( user && !userCanSetFullScreen())
|
if( user && !userCanSetFullScreen())
|
||||||
return;
|
return;
|
||||||
|
set = rules()->checkFullScreen( set );
|
||||||
setShade( ShadeNone );
|
setShade( ShadeNone );
|
||||||
bool was_fs = isFullScreen();
|
bool was_fs = isFullScreen();
|
||||||
if( !was_fs )
|
if( !was_fs )
|
||||||
|
|
38
manage.cpp
38
manage.cpp
|
@ -145,6 +145,10 @@ bool Client::manage( Window w, bool isMapped )
|
||||||
setUserNoBorder( true );
|
setUserNoBorder( true );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
init_minimize = rules()->checkMinimize( init_minimize, !isMapped );
|
||||||
|
if( rules()->checkNoBorder( false, !isMapped ))
|
||||||
|
setUserNoBorder( true );
|
||||||
|
|
||||||
// initial desktop placement
|
// initial desktop placement
|
||||||
if ( info->desktop() )
|
if ( info->desktop() )
|
||||||
desk = info->desktop(); // window had the initial desktop property!
|
desk = info->desktop(); // window had the initial desktop property!
|
||||||
|
@ -269,9 +273,9 @@ bool Client::manage( Window w, bool isMapped )
|
||||||
|
|
||||||
updateDecoration( false ); // also gravitates
|
updateDecoration( false ); // also gravitates
|
||||||
// TODO is CentralGravity right here, when resizing is done after gravitating?
|
// TODO is CentralGravity right here, when resizing is done after gravitating?
|
||||||
plainResize( rules()->checkSize( sizeForClientSize( geom.size()), true ));
|
plainResize( rules()->checkSize( sizeForClientSize( geom.size()), !isMapped ));
|
||||||
|
|
||||||
QPoint forced_pos = rules()->checkPosition( invalidPoint, true );
|
QPoint forced_pos = rules()->checkPosition( invalidPoint, !isMapped );
|
||||||
if( forced_pos != invalidPoint )
|
if( forced_pos != invalidPoint )
|
||||||
{
|
{
|
||||||
move( forced_pos );
|
move( forced_pos );
|
||||||
|
@ -370,31 +374,27 @@ bool Client::manage( Window w, bool isMapped )
|
||||||
// done after checking that the window isn't larger than the workarea, so that
|
// done after checking that the window isn't larger than the workarea, so that
|
||||||
// the restore geometry from the checks above takes precedence, and window
|
// the restore geometry from the checks above takes precedence, and window
|
||||||
// isn't restored larger than the workarea
|
// isn't restored larger than the workarea
|
||||||
if ( (info->state() & NET::Max) == NET::Max )
|
MaximizeMode maxmode = static_cast< MaximizeMode >
|
||||||
maximize( Client::MaximizeFull );
|
((( info->state() & NET::MaxVert ) ? MaximizeVertical : 0 )
|
||||||
else if ( info->state() & NET::MaxVert )
|
| (( info->state() & NET::MaxHoriz ) ? MaximizeHorizontal : 0 ));
|
||||||
maximize( Client::MaximizeVertical );
|
MaximizeMode forced_maxmode = rules()->checkMaximize( maxmode, !isMapped );
|
||||||
else if ( info->state() & NET::MaxHoriz )
|
// either hints were set to maximize, or is forced to maximize,
|
||||||
maximize( Client::MaximizeHorizontal );
|
// or is forced to non-maximize and hints were set to maximize
|
||||||
|
if( forced_maxmode != MaximizeRestore || maxmode != MaximizeRestore )
|
||||||
|
maximize( forced_maxmode );
|
||||||
|
|
||||||
// read other initial states
|
// read other initial states
|
||||||
if( info->state() & NET::Shaded )
|
setShade( rules()->checkShade( info->state() & NET::Shaded ? ShadeNormal : ShadeNone, !isMapped ));
|
||||||
setShade( ShadeNormal );
|
|
||||||
setKeepAbove( rules()->checkKeepAbove( info->state() & NET::KeepAbove, !isMapped ));
|
setKeepAbove( rules()->checkKeepAbove( info->state() & NET::KeepAbove, !isMapped ));
|
||||||
setKeepBelow( rules()->checkKeepBelow( info->state() & NET::KeepBelow, !isMapped ));
|
setKeepBelow( rules()->checkKeepBelow( info->state() & NET::KeepBelow, !isMapped ));
|
||||||
if( info->state() & NET::SkipTaskbar )
|
setSkipTaskbar( rules()->checkSkipTaskbar( info->state() & NET::SkipTaskbar, !isMapped ), true );
|
||||||
setSkipTaskbar( true, true );
|
setSkipPager( rules()->checkSkipPager( info->state() & NET::SkipPager, !isMapped ));
|
||||||
if( info->state() & NET::SkipPager )
|
|
||||||
setSkipPager( true );
|
|
||||||
if( info->state() & NET::DemandsAttention )
|
if( info->state() & NET::DemandsAttention )
|
||||||
demandAttention();
|
demandAttention();
|
||||||
if( info->state() & NET::Modal )
|
if( info->state() & NET::Modal )
|
||||||
setModal( true );
|
setModal( true );
|
||||||
if( fullscreen_mode != FullScreenHack )
|
if( fullscreen_mode != FullScreenHack && isFullScreenable())
|
||||||
{
|
setFullScreen( rules()->checkFullScreen( info->state() & NET::FullScreen, !isMapped ), false );
|
||||||
if(( info->state() & NET::FullScreen ) != 0 && isFullScreenable())
|
|
||||||
setFullScreen( true, false );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
updateAllowedActions( true );
|
updateAllowedActions( true );
|
||||||
|
|
105
rules.cpp
105
rules.cpp
|
@ -36,8 +36,16 @@ WindowRules::WindowRules()
|
||||||
, maxsizerule( DontCareRule )
|
, maxsizerule( DontCareRule )
|
||||||
, desktoprule( DontCareRule )
|
, desktoprule( DontCareRule )
|
||||||
, typerule( DontCareRule )
|
, typerule( DontCareRule )
|
||||||
|
, maximizevertrule( DontCareRule )
|
||||||
|
, maximizehorizrule( DontCareRule )
|
||||||
|
, minimizerule( DontCareRule )
|
||||||
|
, shaderule( DontCareRule )
|
||||||
|
, skiptaskbarrule( DontCareRule )
|
||||||
|
, skippagerrule( DontCareRule )
|
||||||
, aboverule( DontCareRule )
|
, aboverule( DontCareRule )
|
||||||
, belowrule( DontCareRule )
|
, belowrule( DontCareRule )
|
||||||
|
, fullscreenrule( DontCareRule )
|
||||||
|
, noborderrule( DontCareRule )
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -77,8 +85,16 @@ WindowRules::WindowRules( KConfig& cfg )
|
||||||
READ_SET_RULE( desktop, Num, );
|
READ_SET_RULE( desktop, Num, );
|
||||||
type = readType( cfg, "type" );
|
type = readType( cfg, "type" );
|
||||||
typerule = type != NET::Unknown ? readForceRule( cfg, "typerule" ) : DontCareRule;
|
typerule = type != NET::Unknown ? readForceRule( cfg, "typerule" ) : DontCareRule;
|
||||||
|
READ_SET_RULE( maximizevert, Bool, );
|
||||||
|
READ_SET_RULE( maximizehoriz, Bool, );
|
||||||
|
READ_SET_RULE( minimize, Bool, );
|
||||||
|
READ_SET_RULE( shade, Bool, );
|
||||||
|
READ_SET_RULE( skiptaskbar, Bool, );
|
||||||
|
READ_SET_RULE( skippager, Bool, );
|
||||||
READ_SET_RULE( above, Bool, );
|
READ_SET_RULE( above, Bool, );
|
||||||
READ_SET_RULE( below, Bool, );
|
READ_SET_RULE( below, Bool, );
|
||||||
|
READ_SET_RULE( fullscreen, Bool, );
|
||||||
|
READ_SET_RULE( noborder, Bool, );
|
||||||
kdDebug() << "READ RULE:" << wmclass << endl;
|
kdDebug() << "READ RULE:" << wmclass << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -135,8 +151,16 @@ void WindowRules::write( KConfig& cfg ) const
|
||||||
WRITE_SET_RULE( maxsize, );
|
WRITE_SET_RULE( maxsize, );
|
||||||
WRITE_SET_RULE( desktop, );
|
WRITE_SET_RULE( desktop, );
|
||||||
WRITE_SET_RULE( type, );
|
WRITE_SET_RULE( type, );
|
||||||
|
WRITE_SET_RULE( maximizevert, );
|
||||||
|
WRITE_SET_RULE( maximizehoriz, );
|
||||||
|
WRITE_SET_RULE( minimize, );
|
||||||
|
WRITE_SET_RULE( shade, );
|
||||||
|
WRITE_SET_RULE( skiptaskbar, );
|
||||||
|
WRITE_SET_RULE( skippager, );
|
||||||
WRITE_SET_RULE( above, );
|
WRITE_SET_RULE( above, );
|
||||||
WRITE_SET_RULE( below, );
|
WRITE_SET_RULE( below, );
|
||||||
|
WRITE_SET_RULE( fullscreen, );
|
||||||
|
WRITE_SET_RULE( noborder, );
|
||||||
}
|
}
|
||||||
|
|
||||||
#undef WRITE_MATCH_STRING
|
#undef WRITE_MATCH_STRING
|
||||||
|
@ -222,10 +246,26 @@ void WindowRules::update( Client* c )
|
||||||
size = c->size();
|
size = c->size();
|
||||||
if( desktoprule == RememberRule )
|
if( desktoprule == RememberRule )
|
||||||
desktop = c->desktop();
|
desktop = c->desktop();
|
||||||
|
if( maximizevertrule == RememberRule )
|
||||||
|
maximizevert = c->maximizeMode() & MaximizeVertical;
|
||||||
|
if( maximizehorizrule == RememberRule )
|
||||||
|
maximizehoriz = c->maximizeMode() & MaximizeHorizontal;
|
||||||
|
if( minimizerule == RememberRule )
|
||||||
|
minimize = c->isMinimized();
|
||||||
|
if( shaderule == RememberRule )
|
||||||
|
shade = c->shadeMode() != Client::ShadeNone;
|
||||||
|
if( skiptaskbarrule == RememberRule )
|
||||||
|
skiptaskbar = c->skipTaskbar();
|
||||||
|
if( skippagerrule == RememberRule )
|
||||||
|
skippager = c->skipPager();
|
||||||
if( aboverule == RememberRule )
|
if( aboverule == RememberRule )
|
||||||
above = c->keepAbove();
|
above = c->keepAbove();
|
||||||
if( belowrule == RememberRule )
|
if( belowrule == RememberRule )
|
||||||
below = c->keepBelow();
|
below = c->keepBelow();
|
||||||
|
if( fullscreenrule == RememberRule )
|
||||||
|
fullscreen = c->isFullScreen();
|
||||||
|
if( noborderrule == RememberRule )
|
||||||
|
noborder = c->isUserNoBorder();
|
||||||
}
|
}
|
||||||
|
|
||||||
Placement::Policy WindowRules::checkPlacement( Placement::Policy placement ) const
|
Placement::Policy WindowRules::checkPlacement( Placement::Policy placement ) const
|
||||||
|
@ -266,21 +306,66 @@ int WindowRules::checkDesktop( int req_desktop, bool init ) const
|
||||||
return checkRule( desktoprule, init ) ? this->desktop : req_desktop;
|
return checkRule( desktoprule, init ) ? this->desktop : req_desktop;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool WindowRules::checkKeepAbove( bool req_above, bool init ) const
|
|
||||||
{
|
|
||||||
return checkRule( aboverule, init ) ? this->above : req_above;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool WindowRules::checkKeepBelow( bool req_below, bool init ) const
|
|
||||||
{
|
|
||||||
return checkRule( belowrule, init ) ? this->below : req_below;
|
|
||||||
}
|
|
||||||
|
|
||||||
NET::WindowType WindowRules::checkType( NET::WindowType req_type ) const
|
NET::WindowType WindowRules::checkType( NET::WindowType req_type ) const
|
||||||
{
|
{
|
||||||
return checkForceRule( typerule ) ? this->type : req_type;
|
return checkForceRule( typerule ) ? this->type : req_type;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
KDecorationDefines::MaximizeMode WindowRules::checkMaximize( MaximizeMode mode, bool init ) const
|
||||||
|
{
|
||||||
|
bool vert = checkRule( maximizevertrule, init ) ? this->maximizevert : bool( mode & MaximizeVertical );
|
||||||
|
bool horiz = checkRule( maximizehorizrule, init ) ? this->maximizehoriz : bool( mode & MaximizeHorizontal );
|
||||||
|
return static_cast< MaximizeMode >(( vert ? MaximizeVertical : 0 ) | ( horiz ? MaximizeHorizontal : 0 ));
|
||||||
|
}
|
||||||
|
|
||||||
|
bool WindowRules::checkMinimize( bool minimize, bool init ) const
|
||||||
|
{
|
||||||
|
return checkRule( minimizerule, init ) ? this->minimize : minimize;
|
||||||
|
}
|
||||||
|
|
||||||
|
Client::ShadeMode WindowRules::checkShade( Client::ShadeMode shade, bool init ) const
|
||||||
|
{
|
||||||
|
if( checkRule( shaderule, init ))
|
||||||
|
{
|
||||||
|
if( !this->shade )
|
||||||
|
return Client::ShadeNone;
|
||||||
|
if( this->shade && shade == Client::ShadeNone )
|
||||||
|
return Client::ShadeNormal;
|
||||||
|
}
|
||||||
|
return shade;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool WindowRules::checkSkipTaskbar( bool skip, bool init ) const
|
||||||
|
{
|
||||||
|
return checkRule( skiptaskbarrule, init ) ? this->skiptaskbar : skip;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool WindowRules::checkSkipPager( bool skip, bool init ) const
|
||||||
|
{
|
||||||
|
return checkRule( skippagerrule, init ) ? this->skippager : skip;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool WindowRules::checkKeepAbove( bool above, bool init ) const
|
||||||
|
{
|
||||||
|
return checkRule( aboverule, init ) ? this->above : above;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool WindowRules::checkKeepBelow( bool below, bool init ) const
|
||||||
|
{
|
||||||
|
return checkRule( belowrule, init ) ? this->below : below;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool WindowRules::checkFullScreen( bool fs, bool init ) const
|
||||||
|
{
|
||||||
|
return checkRule( fullscreenrule, init ) ? this->fullscreen : fs;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool WindowRules::checkNoBorder( bool noborder, bool init ) const
|
||||||
|
{
|
||||||
|
return checkRule( noborderrule, init ) ? this->noborder : noborder;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// Client
|
// Client
|
||||||
|
|
||||||
void Client::setupWindowRules()
|
void Client::setupWindowRules()
|
||||||
|
|
28
rules.h
28
rules.h
|
@ -16,6 +16,8 @@ License. See the file "COPYING" for the exact licensing terms.
|
||||||
#include <qrect.h>
|
#include <qrect.h>
|
||||||
|
|
||||||
#include "placement.h"
|
#include "placement.h"
|
||||||
|
#include "lib/kdecoration.h"
|
||||||
|
#include "client.h"
|
||||||
|
|
||||||
class KConfig;
|
class KConfig;
|
||||||
|
|
||||||
|
@ -34,6 +36,7 @@ enum SettingRule
|
||||||
};
|
};
|
||||||
|
|
||||||
class WindowRules
|
class WindowRules
|
||||||
|
: public KDecorationDefines
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
WindowRules();
|
WindowRules();
|
||||||
|
@ -50,8 +53,15 @@ class WindowRules
|
||||||
QSize checkMaxSize( const QSize& s ) const;
|
QSize checkMaxSize( const QSize& s ) const;
|
||||||
int checkDesktop( int desktop, bool init = false ) const;
|
int checkDesktop( int desktop, bool init = false ) const;
|
||||||
NET::WindowType checkType( NET::WindowType type ) const;
|
NET::WindowType checkType( NET::WindowType type ) const;
|
||||||
|
MaximizeMode checkMaximize( MaximizeMode mode, bool init = false ) const;
|
||||||
|
bool checkMinimize( bool minimized, bool init = false ) const;
|
||||||
|
Client::ShadeMode checkShade( Client::ShadeMode shade, bool init = false ) const;
|
||||||
|
bool checkSkipTaskbar( bool skip, bool init = false ) const;
|
||||||
|
bool checkSkipPager( bool skip, bool init = false ) const;
|
||||||
bool checkKeepAbove( bool above, bool init = false ) const;
|
bool checkKeepAbove( bool above, bool init = false ) const;
|
||||||
bool checkKeepBelow( bool above, bool init = false ) const;
|
bool checkKeepBelow( bool below, bool init = false ) const;
|
||||||
|
bool checkFullScreen( bool fs, bool init = false ) const;
|
||||||
|
bool checkNoBorder( bool noborder, bool init = false ) const;
|
||||||
private:
|
private:
|
||||||
static SettingRule readRule( KConfig&, const QString& key );
|
static SettingRule readRule( KConfig&, const QString& key );
|
||||||
static SettingRule readForceRule( KConfig&, const QString& key );
|
static SettingRule readForceRule( KConfig&, const QString& key );
|
||||||
|
@ -84,10 +94,26 @@ class WindowRules
|
||||||
SettingRule desktoprule;
|
SettingRule desktoprule;
|
||||||
NET::WindowType type; // type for setting
|
NET::WindowType type; // type for setting
|
||||||
SettingRule typerule;
|
SettingRule typerule;
|
||||||
|
bool maximizevert;
|
||||||
|
SettingRule maximizevertrule;
|
||||||
|
bool maximizehoriz;
|
||||||
|
SettingRule maximizehorizrule;
|
||||||
|
bool minimize;
|
||||||
|
SettingRule minimizerule;
|
||||||
|
bool shade;
|
||||||
|
SettingRule shaderule;
|
||||||
|
bool skiptaskbar;
|
||||||
|
SettingRule skiptaskbarrule;
|
||||||
|
bool skippager;
|
||||||
|
SettingRule skippagerrule;
|
||||||
bool above;
|
bool above;
|
||||||
SettingRule aboverule;
|
SettingRule aboverule;
|
||||||
bool below;
|
bool below;
|
||||||
SettingRule belowrule;
|
SettingRule belowrule;
|
||||||
|
bool fullscreen;
|
||||||
|
SettingRule fullscreenrule;
|
||||||
|
bool noborder;
|
||||||
|
SettingRule noborderrule;
|
||||||
};
|
};
|
||||||
|
|
||||||
inline
|
inline
|
||||||
|
|
Loading…
Reference in a new issue