KWin rule for adjusting focus stealing prevention level.
svn path=/trunk/kdebase/kwin/; revision=318991
This commit is contained in:
parent
83657d963d
commit
76f21da02b
3 changed files with 31 additions and 13 deletions
|
@ -26,6 +26,7 @@ License. See the file "COPYING" for the exact licensing terms.
|
||||||
#include "notifications.h"
|
#include "notifications.h"
|
||||||
#include "atoms.h"
|
#include "atoms.h"
|
||||||
#include "group.h"
|
#include "group.h"
|
||||||
|
#include "rules.h"
|
||||||
|
|
||||||
extern Time qt_x_time;
|
extern Time qt_x_time;
|
||||||
|
|
||||||
|
@ -465,8 +466,8 @@ bool Workspace::allowClientActivation( const Client* c, Time time, bool focus_in
|
||||||
// 4 - extreme - no window gets focus without user intervention
|
// 4 - extreme - no window gets focus without user intervention
|
||||||
if( time == -1U )
|
if( time == -1U )
|
||||||
time = c->userTime();
|
time = c->userTime();
|
||||||
if( session_saving
|
int level = c->rules()->checkFSP( options->focusStealingPreventionLevel );
|
||||||
&& options->focusStealingPreventionLevel <= 2 ) // <= normal
|
if( session_saving && level <= 2 ) // <= normal
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -481,9 +482,9 @@ bool Workspace::allowClientActivation( const Client* c, Time time, bool focus_in
|
||||||
}
|
}
|
||||||
if( time == 0 ) // explicitly asked not to get focus
|
if( time == 0 ) // explicitly asked not to get focus
|
||||||
return false;
|
return false;
|
||||||
if( options->focusStealingPreventionLevel == 0 ) // none
|
if( level == 0 ) // none
|
||||||
return true;
|
return true;
|
||||||
if( options->focusStealingPreventionLevel == 4 ) // extreme
|
if( level == 4 ) // extreme
|
||||||
return false;
|
return false;
|
||||||
if( c->ignoreFocusStealing())
|
if( c->ignoreFocusStealing())
|
||||||
return true;
|
return true;
|
||||||
|
@ -498,7 +499,7 @@ bool Workspace::allowClientActivation( const Client* c, Time time, bool focus_in
|
||||||
kdDebug( 1212 ) << "Activation: Belongs to active application" << endl;
|
kdDebug( 1212 ) << "Activation: Belongs to active application" << endl;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if( options->focusStealingPreventionLevel == 3 ) // high
|
if( level == 3 ) // high
|
||||||
return false;
|
return false;
|
||||||
if( time == -1U ) // no time known
|
if( time == -1U ) // no time known
|
||||||
if( session_active )
|
if( session_active )
|
||||||
|
@ -506,14 +507,14 @@ bool Workspace::allowClientActivation( const Client* c, Time time, bool focus_in
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
kdDebug( 1212 ) << "Activation: No timestamp at all" << endl;
|
kdDebug( 1212 ) << "Activation: No timestamp at all" << endl;
|
||||||
if( options->focusStealingPreventionLevel == 1 ) // low
|
if( level == 1 ) // low
|
||||||
return true;
|
return true;
|
||||||
// no timestamp at all, don't activate - because there's also creation timestamp
|
// no timestamp at all, don't activate - because there's also creation timestamp
|
||||||
// done on CreateNotify, this case should happen only in case application
|
// done on CreateNotify, this case should happen only in case application
|
||||||
// maps again already used window, i.e. this won't happen after app startup
|
// maps again already used window, i.e. this won't happen after app startup
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
// options->focusStealingPreventionLevel == 2 // normal
|
// level == 2 // normal
|
||||||
Time user_time = ac->userTime();
|
Time user_time = ac->userTime();
|
||||||
kdDebug( 1212 ) << "Activation, compared:" << c << ":" << time << ":" << user_time
|
kdDebug( 1212 ) << "Activation, compared:" << c << ":" << time << ":" << user_time
|
||||||
<< ":" << ( timestampCompare( time, user_time ) >= 0 ) << endl;
|
<< ":" << ( timestampCompare( time, user_time ) >= 0 ) << endl;
|
||||||
|
@ -526,15 +527,15 @@ bool Workspace::allowClientActivation( const Client* c, Time time, bool focus_in
|
||||||
// to the same application
|
// to the same application
|
||||||
bool Workspace::allowFullClientRaising( const Client* c, Time time )
|
bool Workspace::allowFullClientRaising( const Client* c, Time time )
|
||||||
{
|
{
|
||||||
if( session_saving
|
int level = c->rules()->checkFSP( options->focusStealingPreventionLevel );
|
||||||
&& options->focusStealingPreventionLevel <= 2 ) // <= normal
|
if( session_saving && level <= 2 ) // <= normal
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
Client* ac = mostRecentlyActivatedClient();
|
Client* ac = mostRecentlyActivatedClient();
|
||||||
if( options->focusStealingPreventionLevel == 0 ) // none
|
if( level == 0 ) // none
|
||||||
return true;
|
return true;
|
||||||
if( options->focusStealingPreventionLevel == 4 ) // extreme
|
if( level == 4 ) // extreme
|
||||||
return false;
|
return false;
|
||||||
if( ac == NULL || ac->isDesktop())
|
if( ac == NULL || ac->isDesktop())
|
||||||
{
|
{
|
||||||
|
@ -549,7 +550,7 @@ bool Workspace::allowFullClientRaising( const Client* c, Time time )
|
||||||
kdDebug( 1212 ) << "Raising: Belongs to active application" << endl;
|
kdDebug( 1212 ) << "Raising: Belongs to active application" << endl;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if( options->focusStealingPreventionLevel == 3 ) // high
|
if( level == 3 ) // high
|
||||||
return false;
|
return false;
|
||||||
Time user_time = ac->userTime();
|
Time user_time = ac->userTime();
|
||||||
kdDebug( 1212 ) << "Raising, compared:" << time << ":" << user_time
|
kdDebug( 1212 ) << "Raising, compared:" << time << ":" << user_time
|
||||||
|
|
14
rules.cpp
14
rules.cpp
|
@ -46,6 +46,7 @@ WindowRules::WindowRules()
|
||||||
, belowrule( DontCareRule )
|
, belowrule( DontCareRule )
|
||||||
, fullscreenrule( DontCareRule )
|
, fullscreenrule( DontCareRule )
|
||||||
, noborderrule( DontCareRule )
|
, noborderrule( DontCareRule )
|
||||||
|
, fspleveladjustrule( DontCareRule )
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -61,6 +62,10 @@ WindowRules::WindowRules()
|
||||||
var = func ( cfg.read##type##Entry( #var ), funcarg ); \
|
var = func ( cfg.read##type##Entry( #var ), funcarg ); \
|
||||||
var##rule = readRule( cfg, #var "rule" );
|
var##rule = readRule( cfg, #var "rule" );
|
||||||
|
|
||||||
|
#define READ_FORCE_RULE( var, type, func ) \
|
||||||
|
var = func ( cfg.read##type##Entry( #var )); \
|
||||||
|
var##rule = readForceRule( cfg, #var "rule" );
|
||||||
|
|
||||||
WindowRules::WindowRules( KConfig& cfg )
|
WindowRules::WindowRules( KConfig& cfg )
|
||||||
{
|
{
|
||||||
wmclass = cfg.readEntry( "wmclass" ).lower().latin1();
|
wmclass = cfg.readEntry( "wmclass" ).lower().latin1();
|
||||||
|
@ -95,12 +100,14 @@ WindowRules::WindowRules( KConfig& cfg )
|
||||||
READ_SET_RULE( below, Bool, );
|
READ_SET_RULE( below, Bool, );
|
||||||
READ_SET_RULE( fullscreen, Bool, );
|
READ_SET_RULE( fullscreen, Bool, );
|
||||||
READ_SET_RULE( noborder, Bool, );
|
READ_SET_RULE( noborder, Bool, );
|
||||||
|
READ_FORCE_RULE( fspleveladjust, Num, );
|
||||||
kdDebug() << "READ RULE:" << wmclass << endl;
|
kdDebug() << "READ RULE:" << wmclass << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
#undef READ_MATCH_STRING
|
#undef READ_MATCH_STRING
|
||||||
#undef READ_SET_RULE
|
#undef READ_SET_RULE
|
||||||
#undef READ_SET_RULE_2
|
#undef READ_SET_RULE_2
|
||||||
|
#undef READ_FORCE_RULE
|
||||||
|
|
||||||
#define WRITE_MATCH_STRING( var, cast ) \
|
#define WRITE_MATCH_STRING( var, cast ) \
|
||||||
if( !var.isEmpty()) \
|
if( !var.isEmpty()) \
|
||||||
|
@ -161,6 +168,7 @@ void WindowRules::write( KConfig& cfg ) const
|
||||||
WRITE_SET_RULE( below, );
|
WRITE_SET_RULE( below, );
|
||||||
WRITE_SET_RULE( fullscreen, );
|
WRITE_SET_RULE( fullscreen, );
|
||||||
WRITE_SET_RULE( noborder, );
|
WRITE_SET_RULE( noborder, );
|
||||||
|
WRITE_SET_RULE( fspleveladjust, );
|
||||||
}
|
}
|
||||||
|
|
||||||
#undef WRITE_MATCH_STRING
|
#undef WRITE_MATCH_STRING
|
||||||
|
@ -365,6 +373,12 @@ bool WindowRules::checkNoBorder( bool noborder, bool init ) const
|
||||||
return checkRule( noborderrule, init ) ? this->noborder : noborder;
|
return checkRule( noborderrule, init ) ? this->noborder : noborder;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int WindowRules::checkFSP( int fsp ) const
|
||||||
|
{
|
||||||
|
if( !checkForceRule( fspleveladjustrule ))
|
||||||
|
return fsp;
|
||||||
|
return QMIN( 4, QMAX( 0, fsp + fspleveladjust ));
|
||||||
|
}
|
||||||
|
|
||||||
// Client
|
// Client
|
||||||
|
|
||||||
|
|
3
rules.h
3
rules.h
|
@ -62,6 +62,7 @@ class WindowRules
|
||||||
bool checkKeepBelow( bool below, bool init = false ) const;
|
bool checkKeepBelow( bool below, bool init = false ) const;
|
||||||
bool checkFullScreen( bool fs, bool init = false ) const;
|
bool checkFullScreen( bool fs, bool init = false ) const;
|
||||||
bool checkNoBorder( bool noborder, bool init = false ) const;
|
bool checkNoBorder( bool noborder, bool init = false ) const;
|
||||||
|
int checkFSP( int fsp ) 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 );
|
||||||
|
@ -114,6 +115,8 @@ class WindowRules
|
||||||
SettingRule fullscreenrule;
|
SettingRule fullscreenrule;
|
||||||
bool noborder;
|
bool noborder;
|
||||||
SettingRule noborderrule;
|
SettingRule noborderrule;
|
||||||
|
int fspleveladjust;
|
||||||
|
SettingRule fspleveladjustrule;
|
||||||
};
|
};
|
||||||
|
|
||||||
inline
|
inline
|
||||||
|
|
Loading…
Reference in a new issue