Save windows state in phase2. The XSMP spec allows apps to change
their state in phase1 :(. svn path=/trunk/kdebase/kwin/; revision=252344
This commit is contained in:
parent
0391b7bfaf
commit
9db6939eca
2 changed files with 58 additions and 39 deletions
38
sm.cpp
38
sm.cpp
|
@ -34,24 +34,20 @@ bool SessionManaged::saveState( QSessionManager& sm )
|
|||
// as ksmserver assures no interaction will be done
|
||||
// before the WM finishes phase 1. Saving in phase 2 is
|
||||
// too late, as possible user interaction may change some things.
|
||||
// Phase2 is still needed though (ICCCM 5.2)
|
||||
char* sm_vendor = SmcVendor( static_cast< SmcConn >( sm.handle()));
|
||||
bool ksmserver = qstrcmp( sm_vendor, "KDE" ) == 0;
|
||||
free( sm_vendor );
|
||||
if ( !sm.isPhase2() )
|
||||
{
|
||||
Workspace::self()->sessionSaveStarted();
|
||||
if( ksmserver )
|
||||
{
|
||||
Workspace::self()->storeSession( kapp->sessionConfig() );
|
||||
kapp->sessionConfig()->sync();
|
||||
// we don't need phase 2 actually
|
||||
return true;
|
||||
}
|
||||
if( ksmserver ) // save stacking order etc. before "save file?" etc. dialogs change it
|
||||
Workspace::self()->storeSession( kapp->sessionConfig(), SMSavePhase0 );
|
||||
sm.release(); // Qt doesn't automatically release in this case (bug?)
|
||||
sm.requestPhase2();
|
||||
return true;
|
||||
}
|
||||
Workspace::self()->storeSession( kapp->sessionConfig() );
|
||||
Workspace::self()->storeSession( kapp->sessionConfig(), ksmserver ? SMSavePhase2 : SMSavePhase2Full );
|
||||
kapp->sessionConfig()->sync();
|
||||
return true;
|
||||
}
|
||||
|
@ -71,7 +67,7 @@ bool SessionManaged::commitData( QSessionManager& sm )
|
|||
|
||||
\sa loadSessionInfo()
|
||||
*/
|
||||
void Workspace::storeSession( KConfig* config )
|
||||
void Workspace::storeSession( KConfig* config, SMSavePhase phase )
|
||||
{
|
||||
config->setGroup("Session" );
|
||||
int count = 0;
|
||||
|
@ -90,6 +86,8 @@ void Workspace::storeSession( KConfig* config )
|
|||
if( c->isActive())
|
||||
active_client = count;
|
||||
QString n = QString::number(count);
|
||||
if( phase == SMSavePhase2 || phase == SMSavePhase2Full )
|
||||
{
|
||||
config->writeEntry( QString("sessionId")+n, sessionId.data() );
|
||||
config->writeEntry( QString("windowRole")+n, c->windowRole().data() );
|
||||
config->writeEntry( QString("wmCommand")+n, wmCommand.data() );
|
||||
|
@ -116,11 +114,29 @@ void Workspace::storeSession( KConfig* config )
|
|||
config->writeEntry( QString("userNoBorder")+n, c->isUserNoBorder() );
|
||||
config->writeEntry( QString("windowType")+n, windowTypeToTxt( c->windowType()));
|
||||
}
|
||||
}
|
||||
// TODO store also stacking order
|
||||
if( phase == SMSavePhase0 )
|
||||
{
|
||||
// it would be much simpler to save these values to the config file,
|
||||
// but both Qt and KDE treat phase1 and phase2 separately,
|
||||
// which results in different sessionkey and different config file :(
|
||||
session_active_client = active_client;
|
||||
session_desktop = currentDesktop();
|
||||
}
|
||||
else if( phase == SMSavePhase2 )
|
||||
{
|
||||
config->writeEntry( "count", count );
|
||||
config->writeEntry( "active", active_client );
|
||||
|
||||
config->writeEntry( "active", session_active_client );
|
||||
config->writeEntry( "desktop", session_desktop );
|
||||
}
|
||||
else // SMSavePhase2Full
|
||||
{
|
||||
config->writeEntry( "count", count );
|
||||
config->writeEntry( "active", session_active_client );
|
||||
config->writeEntry( "desktop", currentDesktop());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*!
|
||||
|
|
|
@ -20,6 +20,7 @@ License. See the file "COPYING" for the exact licensing terms.
|
|||
#include "KWinInterface.h"
|
||||
#include "utils.h"
|
||||
#include "kdecoration.h"
|
||||
#include "sm.h"
|
||||
|
||||
#include <X11/Xlib.h>
|
||||
|
||||
|
@ -225,7 +226,7 @@ class Workspace : public QObject, virtual public KWinInterface, public KDecorati
|
|||
|
||||
void performWindowOperation( Client* c, WindowOperation op );
|
||||
|
||||
void storeSession( KConfig* config );
|
||||
void storeSession( KConfig* config, SMSavePhase phase );
|
||||
|
||||
SessionInfo* takeSessionInfo( Client* );
|
||||
|
||||
|
@ -451,6 +452,8 @@ class Workspace : public QObject, virtual public KWinInterface, public KDecorati
|
|||
|
||||
bool was_user_interaction;
|
||||
bool session_saving;
|
||||
int session_active_client;
|
||||
int session_desktop;
|
||||
|
||||
bool control_grab;
|
||||
bool tab_grab;
|
||||
|
|
Loading…
Reference in a new issue