more reasonable focus handling when switching desktops

svn path=/trunk/kdebase/kwin/; revision=34472
This commit is contained in:
Matthias Ettrich 1999-11-20 13:51:29 +00:00
parent 52d957df8e
commit 4bc6ce23fb

View file

@ -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 *)&current_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
}