diff --git a/client.cpp b/client.cpp index 7211d49808..d5d9afc411 100644 --- a/client.cpp +++ b/client.cpp @@ -480,7 +480,7 @@ Client::~Client() Manages the clients. This means handling the very first maprequest: reparenting, initial geometry, initial state, placement, etc. */ -void Client::manage( bool isMapped ) +bool Client::manage( bool isMapped, bool isReset ) { if (layout()) @@ -564,15 +564,22 @@ void Client::manage( bool isMapped ) } info->setDesktop( desk ); - + setMappingState( state ); - if ( state == NormalState && isOnDesktop( workspace()->currentDesktop() ) ) { + + bool showMe = state == NormalState && isOnDesktop( workspace()->currentDesktop() ); + + if ( showMe && !isReset ) { Events::raise( isTransient() ? Events::TransNew : Events::New ); - workspace()->raiseClient( this ); // ensure constrains - show(); - if ( options->focusPolicyIsReasonable() && wantsTabFocus() ) - workspace()->requestFocus( this ); + if ( isMapped ) { + show(); + } else { + workspace()->raiseClient( this ); // ensure constrains + show(); + if ( options->focusPolicyIsReasonable() && wantsTabFocus() ) + workspace()->requestFocus( this ); + } } // other settings from the previous session @@ -581,8 +588,11 @@ void Client::manage( bool isMapped ) } delete session; - - workspace()->updateClientArea(); + + if ( !isReset ) + workspace()->updateClientArea(); + + return showMe; } diff --git a/client.h b/client.h index 3632f1f342..b8451f5a50 100644 --- a/client.h +++ b/client.h @@ -74,7 +74,7 @@ public: virtual bool windowEvent( XEvent * ); - void manage( bool isMapped = FALSE ); + bool manage( bool isMapped = FALSE, bool isReset = FALSE ); void setMappingState( int s ); int mappingState() const; diff --git a/workspace.cpp b/workspace.cpp index 0a04183c39..4501a2fbe5 100644 --- a/workspace.cpp +++ b/workspace.cpp @@ -1559,6 +1559,7 @@ void Workspace::raiseClient( Client* c ) if ( !c ) return; + qDebug("raise client %s", c->caption().latin1() ); if ( tab_box->isVisible() ) return; @@ -2499,21 +2500,42 @@ bool Workspace::keyPressMouseEmulation( XKeyEvent key ) */ void Workspace::slotResetAllClients() { - for (ClientList::Iterator it = clients.begin(); it != clients.end(); ++it) { - Client *oldClient = (*it); - WId w = oldClient->window(); - oldClient->hide(); - oldClient->releaseWindow(); - // Replace oldClient with newClient in all lists - Client *newClient = clientFactory (w); - (*it) = newClient; - ClientList::Iterator jt = stacking_order.find (oldClient); - (*jt) = newClient; - jt = focus_chain.find (oldClient); - (*jt) = newClient; - delete oldClient; - newClient->manage( TRUE ); + + ClientList stack = stacking_order; + Client* active = activeClient(); + block_focus = TRUE; + Client* prev = 0; + for (ClientList::Iterator it = stack.fromLast(); it != stack.end(); --it) { + Client *oldClient = (*it); + oldClient->hide(); + WId w = oldClient->window(); + XUnmapWindow( qt_xdisplay(), w ); + oldClient->releaseWindow(); + // Replace oldClient with newClient in all lists + Client *newClient = clientFactory (w); + if ( oldClient == active ) + active = newClient; + ClientList::Iterator jt = clients.find (oldClient); + (*jt) = newClient; + jt = stacking_order.find (oldClient); + (*jt) = newClient; + jt = focus_chain.find (oldClient); + (*jt) = newClient; + delete oldClient; + bool showIt = newClient->manage( TRUE, TRUE ); + if ( prev ) { + Window stack[2]; + stack[0] = prev->winId();; + stack[1] = newClient->winId(); + XRestackWindows( qt_xdisplay(), stack, 2 ); + } + if ( showIt ) + newClient->show(); + prev = newClient; } + block_focus = FALSE; + if ( active ) + requestFocus( active ); } /*!