From 2d336eb6acbb36319da10d188a2db06cd9eb6812 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lubo=C5=A1=20Lu=C5=88=C3=A1k?= Date: Wed, 9 Jun 2004 08:30:06 +0000 Subject: [PATCH] KWin rule for accepting/not accepting input focus. svn path=/trunk/kdebase/kwin/; revision=318992 --- client.cpp | 6 +++--- rules.cpp | 8 ++++++++ rules.h | 3 +++ 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/client.cpp b/client.cpp index de1bc5c6fc..2da1973903 100644 --- a/client.cpp +++ b/client.cpp @@ -1162,7 +1162,7 @@ void Client::takeFocus( allowed_t ) previous_focus_timestamp = qt_x_time; previous_client = this; #endif - if ( input ) + if ( rules()->checkAcceptFocus( input )) { XSetInputFocus( qt_xdisplay(), window(), RevertToPointerRoot, qt_x_time ); } @@ -1496,13 +1496,13 @@ Window Client::wmClientLeader() const bool Client::wantsTabFocus() const { return ( isNormalWindow() || isDialog() || isOverride()) - && ( input || Ptakefocus ) && !skip_taskbar; + && wantsInput() && !skip_taskbar; } bool Client::wantsInput() const { - return input || Ptakefocus; + return rules()->checkAcceptFocus( input || Ptakefocus ); } bool Client::isDesktop() const diff --git a/rules.cpp b/rules.cpp index c68845a977..388a817dc3 100644 --- a/rules.cpp +++ b/rules.cpp @@ -47,6 +47,7 @@ WindowRules::WindowRules() , fullscreenrule( DontCareRule ) , noborderrule( DontCareRule ) , fspleveladjustrule( DontCareRule ) + , acceptfocusrule( DontCareRule ) { } @@ -101,6 +102,7 @@ WindowRules::WindowRules( KConfig& cfg ) READ_SET_RULE( fullscreen, Bool, ); READ_SET_RULE( noborder, Bool, ); READ_FORCE_RULE( fspleveladjust, Num, ); + READ_FORCE_RULE( acceptfocus, Bool, ); kdDebug() << "READ RULE:" << wmclass << endl; } @@ -169,6 +171,7 @@ void WindowRules::write( KConfig& cfg ) const WRITE_SET_RULE( fullscreen, ); WRITE_SET_RULE( noborder, ); WRITE_SET_RULE( fspleveladjust, ); + WRITE_SET_RULE( acceptfocus, ); } #undef WRITE_MATCH_STRING @@ -380,6 +383,11 @@ int WindowRules::checkFSP( int fsp ) const return QMIN( 4, QMAX( 0, fsp + fspleveladjust )); } +bool WindowRules::checkAcceptFocus( bool focus ) const + { + return checkForceRule( acceptfocusrule ) ? this->acceptfocus : focus; + } + // Client void Client::setupWindowRules() diff --git a/rules.h b/rules.h index c444826e0a..1744e5af00 100644 --- a/rules.h +++ b/rules.h @@ -63,6 +63,7 @@ class WindowRules bool checkFullScreen( bool fs, bool init = false ) const; bool checkNoBorder( bool noborder, bool init = false ) const; int checkFSP( int fsp ) const; + bool checkAcceptFocus( bool focus ) const; private: static SettingRule readRule( KConfig&, const QString& key ); static SettingRule readForceRule( KConfig&, const QString& key ); @@ -117,6 +118,8 @@ class WindowRules SettingRule noborderrule; int fspleveladjust; SettingRule fspleveladjustrule; + bool acceptfocus; + SettingRule acceptfocusrule; }; inline