more reasonable focus handling when switching desktops
svn path=/trunk/kdebase/kwin/; revision=34472
This commit is contained in:
parent
52d957df8e
commit
4bc6ce23fb
1 changed files with 52 additions and 31 deletions
|
@ -1225,9 +1225,8 @@ void Workspace::setCurrentDesktop( int new_desktop ){
|
|||
}
|
||||
|
||||
for ( ClientList::ConstIterator it = stacking_order.begin(); it != stacking_order.end(); ++it) {
|
||||
if ( (*it)->isOnDesktop( new_desktop ) ) {
|
||||
if ( (*it)->isOnDesktop( new_desktop ) && !(*it)->isIconified() ) {
|
||||
(*it)->show();
|
||||
//XMapWindow( qt_xdisplay(), (*it)->winId() );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1237,6 +1236,28 @@ void Workspace::setCurrentDesktop( int new_desktop ){
|
|||
atoms->net_current_desktop, XA_CARDINAL, 32,
|
||||
PropModeReplace, (unsigned char *)¤t_desktop, 1);
|
||||
|
||||
|
||||
// try to restore the focus on this desktop
|
||||
Client* c = active_client?active_client:previousClient(0);
|
||||
Client* stop = c;
|
||||
while ( c && !c->isVisible() ) {
|
||||
c = previousClient( c );
|
||||
if ( c == stop )
|
||||
break;
|
||||
}
|
||||
|
||||
if ( !c || !c->isVisible() ) {
|
||||
// there's no suitable client in the focus chain. Try to find any other client then.
|
||||
for ( ClientList::ConstIterator it = stacking_order.begin(); it != stacking_order.end(); ++it) {
|
||||
if ( (*it)->isVisible() ) {
|
||||
c = *it;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if ( c && c->isVisible() )
|
||||
requestFocus( c );
|
||||
|
||||
QApplication::syncX();
|
||||
KWM::switchToDesktop( current_desktop ); // ### compatibility
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue