Save also stacking order when doing session save.

svn path=/trunk/KDE/kdebase/workspace/; revision=531882
icc-effect-5.14.5
Luboš Luňák 2006-04-20 14:57:10 +00:00
parent 82dff6627f
commit daf4e723ea
8 changed files with 45 additions and 10 deletions

View File

@ -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
{

View File

@ -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;

View File

@ -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 )

View File

@ -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();

3
sm.cpp
View File

@ -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 );
}
}

1
sm.h
View File

@ -48,6 +48,7 @@ struct SessionInfo
NET::WindowType windowType;
QString shortcut;
bool active; // means 'was active in the saved session'
int stackingOrder;
};

View File

@ -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())

View File

@ -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* );