From 4d8462f5790ea800109bd97e30ad5e19dbaa45ee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lubo=C5=A1=20Lu=C5=88=C3=A1k?= Date: Tue, 11 Apr 2006 14:52:27 +0000 Subject: [PATCH] Move minimized windows to the right place in focus chain. (#124807) svn path=/trunk/KDE/kdebase/workspace/; revision=528632 --- activation.cpp | 2 +- client.cpp | 7 ++++--- events.cpp | 2 +- workspace.cpp | 28 +++++++++++++++++++++------- workspace.h | 3 ++- 5 files changed, 29 insertions(+), 13 deletions(-) diff --git a/activation.cpp b/activation.cpp index fdfc5f6b5e..5bfa0c6f94 100644 --- a/activation.cpp +++ b/activation.cpp @@ -229,7 +229,7 @@ void Workspace::setActiveClient( Client* c, allowed_t ) last_active_client = active_client; if ( active_client ) { - updateFocusChains( active_client, true ); // make it first in focus chain + updateFocusChains( active_client, FocusChainMakeFirst ); active_client->demandAttention( false ); } pending_take_activity = NULL; diff --git a/client.cpp b/client.cpp index f742c38868..b632115870 100644 --- a/client.cpp +++ b/client.cpp @@ -574,7 +574,7 @@ void Client::minimize( bool avoid_animation ) updateAllowedActions(); workspace()->updateMinimizedOfTransients( this ); updateWindowRules(); - workspace()->updateFocusChains( this, false ); // make it last in the focus chain + workspace()->updateFocusChains( this, Workspace::FocusChainMakeLast ); } void Client::unminimize( bool avoid_animation ) @@ -1154,7 +1154,8 @@ void Client::setSkipTaskbar( bool b, bool from_outside ) info->setState( b?NET::SkipTaskbar:0, NET::SkipTaskbar ); updateWindowRules(); if( was_wants_tab_focus != wantsTabFocus()) - workspace()->updateFocusChains( this, isActive()); + workspace()->updateFocusChains( this, + isActive() ? Workspace::FocusChainMakeFirst : Workspace::FocusChainUpdate ); } void Client::setSkipPager( bool b ) @@ -1196,7 +1197,7 @@ void Client::setDesktop( int desktop ) } if( decoration != NULL ) decoration->desktopChange(); - workspace()->updateFocusChains( this, true ); + workspace()->updateFocusChains( this, Workspace::FocusChainMakeFirst ); updateVisibility(); updateWindowRules(); } diff --git a/events.cpp b/events.cpp index caa28d3984..5ba372e2e9 100644 --- a/events.cpp +++ b/events.cpp @@ -370,7 +370,7 @@ bool Workspace::workspaceEvent( XEvent * e ) if( c ) { c->windowEvent( e ); - updateFocusChains( c, true ); + updateFocusChains( c, FocusChainUpdate ); return true; } break; diff --git a/workspace.cpp b/workspace.cpp index c146ebf856..98faf72f07 100644 --- a/workspace.cpp +++ b/workspace.cpp @@ -516,7 +516,7 @@ void Workspace::addClient( Client* c, allowed_t ) } else { - updateFocusChains( c, false ); // add to focus chain if not already there + updateFocusChains( c, FocusChainUpdate ); // add to focus chain if not already there clients.append( c ); } if( !unconstrained_stacking_order.contains( c )) @@ -595,7 +595,7 @@ void Workspace::removeClient( Client* c, allowed_t ) updateClientArea(); } -void Workspace::updateFocusChains( Client* c, bool make_first ) +void Workspace::updateFocusChains( Client* c, FocusChainChange change ) { if( !c->wantsTabFocus()) // doesn't want tab focus, remove { @@ -609,11 +609,15 @@ void Workspace::updateFocusChains( Client* c, bool make_first ) if(c->desktop() == NET::OnAllDesktops) { //now on all desktops, add it to focus_chains it is not already in for( int i=1; i<= numberOfDesktops(); i++) - { // make_first works only on current desktop, don't affect all desktops - if( make_first && i == currentDesktop()) + { // making first/last works only on current desktop, don't affect all desktops + if( i == currentDesktop() + && ( change == FocusChainMakeFirst || change == FocusChainMakeLast )) { focus_chain[ i ].remove( c ); - focus_chain[ i ].append( c ); + if( change == FocusChainMakeFirst ) + focus_chain[ i ].append( c ); + else + focus_chain[ i ].prepend( c ); } else if( !focus_chain[ i ].contains( c )) focus_chain[ i ].prepend( c ); // otherwise add as the last one @@ -625,11 +629,16 @@ void Workspace::updateFocusChains( Client* c, bool make_first ) { if( i == c->desktop()) { - if( make_first ) + if( change == FocusChainMakeFirst ) { focus_chain[ i ].remove( c ); focus_chain[ i ].append( c ); } + else if( change == FocusChainMakeLast ) + { + focus_chain[ i ].remove( c ); + focus_chain[ i ].prepend( c ); + } else if( !focus_chain[ i ].contains( c )) focus_chain[ i ].prepend( c ); } @@ -637,11 +646,16 @@ void Workspace::updateFocusChains( Client* c, bool make_first ) focus_chain[ i ].remove( c ); } } - if( make_first ) + if( change == FocusChainMakeFirst ) { global_focus_chain.remove( c ); global_focus_chain.append( c ); } + else if( change == FocusChainMakeLast ) + { + global_focus_chain.remove( c ); + global_focus_chain.prepend( c ); + } else if( !global_focus_chain.contains( c )) global_focus_chain.prepend( c ); } diff --git a/workspace.h b/workspace.h index d5cae85b6c..a9ecc3684e 100644 --- a/workspace.h +++ b/workspace.h @@ -251,7 +251,8 @@ class Workspace : public QObject, public KWinInterface, public KDecorationDefine bool checkStartupNotification( Window w, KStartupInfoId& id, KStartupInfoData& data ); void focusToNull(); // SELI public? - void updateFocusChains( Client* c, bool make_first ); + enum FocusChainChange { FocusChainMakeFirst, FocusChainMakeLast, FocusChainUpdate }; + void updateFocusChains( Client* c, FocusChainChange change ); bool forcedGlobalMouseGrab() const; void clientShortcutUpdated( Client* c );