From daf4e723ea6e66e230afae1fddd5927ba11a191d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lubo=C5=A1=20Lu=C5=88=C3=A1k?= Date: Thu, 20 Apr 2006 14:57:10 +0000 Subject: [PATCH] Save also stacking order when doing session save. svn path=/trunk/KDE/kdebase/workspace/; revision=531882 --- client.cpp | 1 + client.h | 7 +++++++ layers.cpp | 20 ++++++++++++++++++++ manage.cpp | 20 ++++++++++++-------- sm.cpp | 3 ++- sm.h | 1 + workspace.cpp | 2 +- workspace.h | 1 + 8 files changed, 45 insertions(+), 10 deletions(-) diff --git a/client.cpp b/client.cpp index 54d8e1d8a3..4f7803374f 100644 --- a/client.cpp +++ b/client.cpp @@ -89,6 +89,7 @@ Client::Client( Workspace *ws ) border_right( 0 ), border_top( 0 ), border_bottom( 0 ), + sm_stacking_order( -1 ), demandAttentionKNotifyTimer( NULL ) // SELI do all as initialization { diff --git a/client.h b/client.h index 759aef3aa5..f3db87f467 100644 --- a/client.h +++ b/client.h @@ -157,6 +157,7 @@ class Client : public QObject, public KDecorationDefines Layer layer() const; Layer belongsToLayer() const; void invalidateLayer(); + int sessionStackingOrder() const; void setModal( bool modal ); bool isModal() const; @@ -531,6 +532,7 @@ class Client : public QObject, public KDecorationDefines QRegion _mask; static bool check_active_modal; // see Client::checkActiveModal() KShortcut _shortcut; + int sm_stacking_order; friend struct FetchNameInternalPredicate; friend struct CheckIgnoreFocusStealingProcedure; friend struct ResetupRulesProcedure; @@ -790,6 +792,11 @@ inline void Client::invalidateLayer() in_layer = UnknownLayer; } +inline int Client::sessionStackingOrder() const + { + return sm_stacking_order; + } + inline bool Client::isIconicState() const { return mapping_state == IconicState; diff --git a/layers.cpp b/layers.cpp index a552624c61..b546396df5 100644 --- a/layers.cpp +++ b/layers.cpp @@ -449,6 +449,26 @@ void Workspace::restackClientUnderActive( Client* c ) updateStackingOrder(); } +void Workspace::restoreSessionStackingOrder( Client* c ) + { + if( c->sessionStackingOrder() < 0 ) + return; + StackingUpdatesBlocker blocker( this ); + unconstrained_stacking_order.remove( c ); + ClientList::Iterator best_pos = unconstrained_stacking_order.end(); + for( ClientList::Iterator it = unconstrained_stacking_order.begin(); // from bottom + it != unconstrained_stacking_order.end(); + ++it ) + { + if( (*it)->sessionStackingOrder() > c->sessionStackingOrder() ) + { + unconstrained_stacking_order.insert( it, c ); + return; + } + } + unconstrained_stacking_order.append( c ); + } + void Workspace::circulateDesktopApplications() { if ( desktops.count() > 1 ) diff --git a/manage.cpp b/manage.cpp index cebd623b22..c3e125193d 100644 --- a/manage.cpp +++ b/manage.cpp @@ -36,6 +36,8 @@ namespace KWinInternal */ bool Client::manage( Window w, bool isMapped ) { + StackingUpdatesBlocker stacking_blocker( workspace()); + XWindowAttributes attr; if( !XGetWindowAttributes(QX11Info::display(), w, &attr)) return false; @@ -424,11 +426,6 @@ bool Client::manage( Window w, bool isMapped ) updateAllowedActions( true ); - // TODO this should avoid flicker, because real restacking is done - // only after manage() finishes, but the window is shown sooner - // - keep it? - XLowerWindow( QX11Info::display(), frameId()); - // set initial user time directly user_time = readUserTimeMapTimestamp( asn_valid ? &asn_id : NULL, asn_valid ? &asn_data : NULL, session ); group()->updateUserTime( user_time ); // and do what Client::updateUserTime() does @@ -436,6 +433,15 @@ bool Client::manage( Window w, bool isMapped ) if( isTopMenu()) // they're shown in Workspace::addClient() if their mainwindow hideClient( true ); // is the active one + // this should avoid flicker, because real restacking is done + // only after manage() finishes because of blocking, but the window is shown sooner + XLowerWindow( QX11Info::display(), frameId()); + if( session && session->stackingOrder != -1 ) + { + sm_stacking_order = session->stackingOrder; + workspace()->restoreSessionStackingOrder( this ); + } + if( isShown( true ) && !doNotShow ) { if( isDialog()) @@ -466,10 +472,8 @@ bool Client::manage( Window w, bool isMapped ) if( !belongs_to_desktop && workspace()->showingDesktop()) workspace()->resetShowingDesktop( false ); - if( isOnCurrentDesktop() && !isMapped && !allow ) + if( isOnCurrentDesktop() && !isMapped && !allow && (!session || session->stackingOrder < 0 )) workspace()->restackClientUnderActive( this ); - else - workspace()->raiseClient( this ); updateVisibility(); diff --git a/sm.cpp b/sm.cpp index 6c44a63cf4..e1f205b4bd 100644 --- a/sm.cpp +++ b/sm.cpp @@ -114,9 +114,9 @@ void Workspace::storeSession( KConfig* config, SMSavePhase phase ) config->writeEntry( QString("userNoBorder")+n, c->isUserNoBorder() ); config->writeEntry( QString("windowType")+n, windowTypeToTxt( c->windowType())); config->writeEntry( QString("shortcut")+n, c->shortcut().toStringInternal()); + config->writeEntry( QString("stackingOrder")+n, unconstrained_stacking_order.findIndex( c )); } } - // TODO store also stacking order if( phase == SMSavePhase0 ) { // it would be much simpler to save these values to the config file, @@ -180,6 +180,7 @@ void Workspace::loadSessionInfo() info->windowType = txtToWindowType( config->readEntry( QString("windowType")+n, QString() ).toLatin1()); info->shortcut = config->readEntry( QString("shortcut")+n, QString() ); info->active = ( active_client == i ); + info->stackingOrder = config->readNumEntry( QString("stackingOrder")+n, -1 ); } } diff --git a/sm.h b/sm.h index 2832be90eb..efb63b49bf 100644 --- a/sm.h +++ b/sm.h @@ -48,6 +48,7 @@ struct SessionInfo NET::WindowType windowType; QString shortcut; bool active; // means 'was active in the saved session' + int stackingOrder; }; diff --git a/workspace.cpp b/workspace.cpp index 4293031124..3d4d408feb 100644 --- a/workspace.cpp +++ b/workspace.cpp @@ -521,7 +521,7 @@ void Workspace::addClient( Client* c, allowed_t ) clients.append( c ); } if( !unconstrained_stacking_order.contains( c )) - unconstrained_stacking_order.append( c ); + unconstrained_stacking_order.append( c ); // raise if it hasn't got any stacking position yet if( !stacking_order.contains( c )) // it'll be updated later, and updateToolWindows() requires stacking_order.append( c ); // c to be in stacking_order if( c->isTopMenu()) diff --git a/workspace.h b/workspace.h index bf089619cc..5361bb368a 100644 --- a/workspace.h +++ b/workspace.h @@ -145,6 +145,7 @@ class Workspace : public QObject, public KWinInterface, public KDecorationDefine void restackClientUnderActive( Client* ); void updateClientLayer( Client* c ); void raiseOrLowerClient( Client * ); + void restoreSessionStackingOrder( Client* c ); void reconfigure(); void clientHidden( Client* );