From 5baf4a79c44bf43e3c32adb56052a0683c083a4e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lubo=C5=A1=20Lu=C5=88=C3=A1k?= Date: Mon, 22 Nov 2004 11:34:09 +0000 Subject: [PATCH] Try harder to restore focus if something sets it to null. svn path=/trunk/kdebase/kwin/; revision=365079 --- activation.cpp | 22 ++++++++++++++-------- events.cpp | 7 +++++-- workspace.h | 2 +- 3 files changed, 20 insertions(+), 11 deletions(-) diff --git a/activation.cpp b/activation.cpp index 8fe89346b9..429fcb7694 100644 --- a/activation.cpp +++ b/activation.cpp @@ -384,21 +384,24 @@ void Workspace::clientHidden( Client* c ) activateNextClient( c ); } -// deactivates 'c' and activates next client -void Workspace::activateNextClient( Client* c ) +// deactivates 'c' and activates next client +bool Workspace::activateNextClient( Client* c ) { // if 'c' is not the active or the to-become active one, do nothing if( !( c == active_client || ( should_get_focus.count() > 0 && c == should_get_focus.last()))) - return; + return false; if( popup ) popup->close(); - if( c == active_client ) - setActiveClient( NULL, Allowed ); - should_get_focus.remove( c ); + if( c != NULL ) + { + if( c == active_client ) + setActiveClient( NULL, Allowed ); + should_get_focus.remove( c ); + } if( focusChangeEnabled()) { - if ( c->wantsTabFocus() && focus_chain.contains( c ) ) + if ( c != NULL && c->wantsTabFocus() && focus_chain.contains( c ) ) { focus_chain.remove( c ); focus_chain.prepend( c ); @@ -407,7 +410,7 @@ void Workspace::activateNextClient( Client* c ) { // search the focus_chain for a client to transfer focus to // if 'c' is transient, transfer focus to the first suitable mainwindow Client* get_focus = NULL; - const ClientList mainwindows = c->mainClients(); + const ClientList mainwindows = ( c != NULL ? c->mainClients() : ClientList()); for( ClientList::ConstIterator it = focus_chain.fromLast(); it != focus_chain.end(); --it ) @@ -429,11 +432,14 @@ void Workspace::activateNextClient( Client* c ) else focusToNull(); } + else + return false; } else // if blocking focus, move focus to the desktop later if needed // in order to avoid flickering focusToNull(); + return true; } diff --git a/events.cpp b/events.cpp index 8f4753176c..d9c450ab01 100644 --- a/events.cpp +++ b/events.cpp @@ -429,8 +429,11 @@ bool Workspace::workspaceEvent( XEvent * e ) if( focus == None || focus == PointerRoot ) { //kdWarning( 1212 ) << "X focus set to None/PointerRoot, reseting focus" << endl; - if( mostRecentlyActivatedClient() != NULL ) - requestFocus( mostRecentlyActivatedClient(), true ); + Client *c = mostRecentlyActivatedClient(); + if( c != NULL ) + requestFocus( c, true ); + else if( activateNextClient( NULL )) + ; // ok, activated else focusToNull(); } diff --git a/workspace.h b/workspace.h index 3aff9b4f41..8f36a46c62 100644 --- a/workspace.h +++ b/workspace.h @@ -118,7 +118,7 @@ class Workspace : public QObject, public KWinInterface, public KDecorationDefine void setShouldGetFocus( Client* ); bool fakeRequestedActivity( Client* c ); void unfakeActivity( Client* c ); - void activateNextClient( Client* c ); + bool activateNextClient( Client* c ); bool focusChangeEnabled() { return block_focus == 0; } void updateColormap();