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 "atoms.h"
|
||||
#include "group.h"
|
||||
#include "rules.h"
|
||||
|
||||
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
|
||||
if( time == -1U )
|
||||
time = c->userTime();
|
||||
if( session_saving
|
||||
&& options->focusStealingPreventionLevel <= 2 ) // <= normal
|
||||
int level = c->rules()->checkFSP( options->focusStealingPreventionLevel );
|
||||
if( session_saving && level <= 2 ) // <= normal
|
||||
{
|
||||
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
|
||||
return false;
|
||||
if( options->focusStealingPreventionLevel == 0 ) // none
|
||||
if( level == 0 ) // none
|
||||
return true;
|
||||
if( options->focusStealingPreventionLevel == 4 ) // extreme
|
||||
if( level == 4 ) // extreme
|
||||
return false;
|
||||
if( c->ignoreFocusStealing())
|
||||
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;
|
||||
return true;
|
||||
}
|
||||
if( options->focusStealingPreventionLevel == 3 ) // high
|
||||
if( level == 3 ) // high
|
||||
return false;
|
||||
if( time == -1U ) // no time known
|
||||
if( session_active )
|
||||
|
@ -506,14 +507,14 @@ bool Workspace::allowClientActivation( const Client* c, Time time, bool focus_in
|
|||
else
|
||||
{
|
||||
kdDebug( 1212 ) << "Activation: No timestamp at all" << endl;
|
||||
if( options->focusStealingPreventionLevel == 1 ) // low
|
||||
if( level == 1 ) // low
|
||||
return true;
|
||||
// no timestamp at all, don't activate - because there's also creation timestamp
|
||||
// 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
|
||||
return false;
|
||||
}
|
||||
// options->focusStealingPreventionLevel == 2 // normal
|
||||
// level == 2 // normal
|
||||
Time user_time = ac->userTime();
|
||||
kdDebug( 1212 ) << "Activation, compared:" << c << ":" << time << ":" << user_time
|
||||
<< ":" << ( 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
|
||||
bool Workspace::allowFullClientRaising( const Client* c, Time time )
|
||||
{
|
||||
if( session_saving
|
||||
&& options->focusStealingPreventionLevel <= 2 ) // <= normal
|
||||
int level = c->rules()->checkFSP( options->focusStealingPreventionLevel );
|
||||
if( session_saving && level <= 2 ) // <= normal
|
||||
{
|
||||
return true;
|
||||
}
|
||||
Client* ac = mostRecentlyActivatedClient();
|
||||
if( options->focusStealingPreventionLevel == 0 ) // none
|
||||
if( level == 0 ) // none
|
||||
return true;
|
||||
if( options->focusStealingPreventionLevel == 4 ) // extreme
|
||||
if( level == 4 ) // extreme
|
||||
return false;
|
||||
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;
|
||||
return true;
|
||||
}
|
||||
if( options->focusStealingPreventionLevel == 3 ) // high
|
||||
if( level == 3 ) // high
|
||||
return false;
|
||||
Time user_time = ac->userTime();
|
||||
kdDebug( 1212 ) << "Raising, compared:" << time << ":" << user_time
|
||||
|
|
16
rules.cpp
16
rules.cpp
|
@ -46,6 +46,7 @@ WindowRules::WindowRules()
|
|||
, belowrule( DontCareRule )
|
||||
, fullscreenrule( DontCareRule )
|
||||
, noborderrule( DontCareRule )
|
||||
, fspleveladjustrule( DontCareRule )
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -60,7 +61,11 @@ WindowRules::WindowRules()
|
|||
#define READ_SET_RULE_2( var, type, func, funcarg ) \
|
||||
var = func ( cfg.read##type##Entry( #var ), funcarg ); \
|
||||
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 )
|
||||
{
|
||||
wmclass = cfg.readEntry( "wmclass" ).lower().latin1();
|
||||
|
@ -95,12 +100,14 @@ WindowRules::WindowRules( KConfig& cfg )
|
|||
READ_SET_RULE( below, Bool, );
|
||||
READ_SET_RULE( fullscreen, Bool, );
|
||||
READ_SET_RULE( noborder, Bool, );
|
||||
READ_FORCE_RULE( fspleveladjust, Num, );
|
||||
kdDebug() << "READ RULE:" << wmclass << endl;
|
||||
}
|
||||
|
||||
#undef READ_MATCH_STRING
|
||||
#undef READ_SET_RULE
|
||||
#undef READ_SET_RULE_2
|
||||
#undef READ_FORCE_RULE
|
||||
|
||||
#define WRITE_MATCH_STRING( var, cast ) \
|
||||
if( !var.isEmpty()) \
|
||||
|
@ -161,6 +168,7 @@ void WindowRules::write( KConfig& cfg ) const
|
|||
WRITE_SET_RULE( below, );
|
||||
WRITE_SET_RULE( fullscreen, );
|
||||
WRITE_SET_RULE( noborder, );
|
||||
WRITE_SET_RULE( fspleveladjust, );
|
||||
}
|
||||
|
||||
#undef WRITE_MATCH_STRING
|
||||
|
@ -365,6 +373,12 @@ bool WindowRules::checkNoBorder( bool noborder, bool init ) const
|
|||
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
|
||||
|
||||
|
|
3
rules.h
3
rules.h
|
@ -62,6 +62,7 @@ class WindowRules
|
|||
bool checkKeepBelow( bool below, bool init = false ) const;
|
||||
bool checkFullScreen( bool fs, bool init = false ) const;
|
||||
bool checkNoBorder( bool noborder, bool init = false ) const;
|
||||
int checkFSP( int fsp ) const;
|
||||
private:
|
||||
static SettingRule readRule( KConfig&, const QString& key );
|
||||
static SettingRule readForceRule( KConfig&, const QString& key );
|
||||
|
@ -114,6 +115,8 @@ class WindowRules
|
|||
SettingRule fullscreenrule;
|
||||
bool noborder;
|
||||
SettingRule noborderrule;
|
||||
int fspleveladjust;
|
||||
SettingRule fspleveladjustrule;
|
||||
};
|
||||
|
||||
inline
|
||||
|
|
Loading…
Reference in a new issue