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
92
sm.cpp
92
sm.cpp
|
@ -34,24 +34,20 @@ bool SessionManaged::saveState( QSessionManager& sm )
|
||||||
// as ksmserver assures no interaction will be done
|
// as ksmserver assures no interaction will be done
|
||||||
// before the WM finishes phase 1. Saving in phase 2 is
|
// before the WM finishes phase 1. Saving in phase 2 is
|
||||||
// too late, as possible user interaction may change some things.
|
// 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()));
|
char* sm_vendor = SmcVendor( static_cast< SmcConn >( sm.handle()));
|
||||||
bool ksmserver = qstrcmp( sm_vendor, "KDE" ) == 0;
|
bool ksmserver = qstrcmp( sm_vendor, "KDE" ) == 0;
|
||||||
free( sm_vendor );
|
free( sm_vendor );
|
||||||
if ( !sm.isPhase2() )
|
if ( !sm.isPhase2() )
|
||||||
{
|
{
|
||||||
Workspace::self()->sessionSaveStarted();
|
Workspace::self()->sessionSaveStarted();
|
||||||
if( ksmserver )
|
if( ksmserver ) // save stacking order etc. before "save file?" etc. dialogs change it
|
||||||
{
|
Workspace::self()->storeSession( kapp->sessionConfig(), SMSavePhase0 );
|
||||||
Workspace::self()->storeSession( kapp->sessionConfig() );
|
|
||||||
kapp->sessionConfig()->sync();
|
|
||||||
// we don't need phase 2 actually
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
sm.release(); // Qt doesn't automatically release in this case (bug?)
|
sm.release(); // Qt doesn't automatically release in this case (bug?)
|
||||||
sm.requestPhase2();
|
sm.requestPhase2();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
Workspace::self()->storeSession( kapp->sessionConfig() );
|
Workspace::self()->storeSession( kapp->sessionConfig(), ksmserver ? SMSavePhase2 : SMSavePhase2Full );
|
||||||
kapp->sessionConfig()->sync();
|
kapp->sessionConfig()->sync();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -71,7 +67,7 @@ bool SessionManaged::commitData( QSessionManager& sm )
|
||||||
|
|
||||||
\sa loadSessionInfo()
|
\sa loadSessionInfo()
|
||||||
*/
|
*/
|
||||||
void Workspace::storeSession( KConfig* config )
|
void Workspace::storeSession( KConfig* config, SMSavePhase phase )
|
||||||
{
|
{
|
||||||
config->setGroup("Session" );
|
config->setGroup("Session" );
|
||||||
int count = 0;
|
int count = 0;
|
||||||
|
@ -90,36 +86,56 @@ void Workspace::storeSession( KConfig* config )
|
||||||
if( c->isActive())
|
if( c->isActive())
|
||||||
active_client = count;
|
active_client = count;
|
||||||
QString n = QString::number(count);
|
QString n = QString::number(count);
|
||||||
config->writeEntry( QString("sessionId")+n, sessionId.data() );
|
if( phase == SMSavePhase2 || phase == SMSavePhase2Full )
|
||||||
config->writeEntry( QString("windowRole")+n, c->windowRole().data() );
|
{
|
||||||
config->writeEntry( QString("wmCommand")+n, wmCommand.data() );
|
config->writeEntry( QString("sessionId")+n, sessionId.data() );
|
||||||
config->writeEntry( QString("wmClientMachine")+n, c->wmClientMachine().data() );
|
config->writeEntry( QString("windowRole")+n, c->windowRole().data() );
|
||||||
config->writeEntry( QString("resourceName")+n, c->resourceName().data() );
|
config->writeEntry( QString("wmCommand")+n, wmCommand.data() );
|
||||||
config->writeEntry( QString("resourceClass")+n, c->resourceClass().data() );
|
config->writeEntry( QString("wmClientMachine")+n, c->wmClientMachine().data() );
|
||||||
config->writeEntry( QString("geometry")+n, QRect( c->calculateGravitation(TRUE), c->clientSize() ) ); // FRAME
|
config->writeEntry( QString("resourceName")+n, c->resourceName().data() );
|
||||||
config->writeEntry( QString("restore")+n, c->geometryRestore() );
|
config->writeEntry( QString("resourceClass")+n, c->resourceClass().data() );
|
||||||
config->writeEntry( QString("fsrestore")+n, c->geometryFSRestore() );
|
config->writeEntry( QString("geometry")+n, QRect( c->calculateGravitation(TRUE), c->clientSize() ) ); // FRAME
|
||||||
config->writeEntry( QString("maximize")+n, (int) c->maximizeMode() );
|
config->writeEntry( QString("restore")+n, c->geometryRestore() );
|
||||||
config->writeEntry( QString("fullscreen")+n, (int) c->fullScreenMode() );
|
config->writeEntry( QString("fsrestore")+n, c->geometryFSRestore() );
|
||||||
config->writeEntry( QString("desktop")+n, c->desktop() );
|
config->writeEntry( QString("maximize")+n, (int) c->maximizeMode() );
|
||||||
// the config entry is called "iconified" for back. comp. reasons
|
config->writeEntry( QString("fullscreen")+n, (int) c->fullScreenMode() );
|
||||||
// (kconf_update script for updating session files would be too complicated)
|
config->writeEntry( QString("desktop")+n, c->desktop() );
|
||||||
config->writeEntry( QString("iconified")+n, c->isMinimized() );
|
// the config entry is called "iconified" for back. comp. reasons
|
||||||
// the config entry is called "sticky" for back. comp. reasons
|
// (kconf_update script for updating session files would be too complicated)
|
||||||
config->writeEntry( QString("sticky")+n, c->isOnAllDesktops() );
|
config->writeEntry( QString("iconified")+n, c->isMinimized() );
|
||||||
config->writeEntry( QString("shaded")+n, c->isShade() );
|
// the config entry is called "sticky" for back. comp. reasons
|
||||||
// the config entry is called "staysOnTop" for back. comp. reasons
|
config->writeEntry( QString("sticky")+n, c->isOnAllDesktops() );
|
||||||
config->writeEntry( QString("staysOnTop")+n, c->keepAbove() );
|
config->writeEntry( QString("shaded")+n, c->isShade() );
|
||||||
config->writeEntry( QString("keepBelow")+n, c->keepBelow() );
|
// the config entry is called "staysOnTop" for back. comp. reasons
|
||||||
config->writeEntry( QString("skipTaskbar")+n, c->skipTaskbar( true ) );
|
config->writeEntry( QString("staysOnTop")+n, c->keepAbove() );
|
||||||
config->writeEntry( QString("skipPager")+n, c->skipPager() );
|
config->writeEntry( QString("keepBelow")+n, c->keepBelow() );
|
||||||
config->writeEntry( QString("userNoBorder")+n, c->isUserNoBorder() );
|
config->writeEntry( QString("skipTaskbar")+n, c->skipTaskbar( true ) );
|
||||||
config->writeEntry( QString("windowType")+n, windowTypeToTxt( c->windowType()));
|
config->writeEntry( QString("skipPager")+n, c->skipPager() );
|
||||||
|
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", session_active_client );
|
||||||
|
config->writeEntry( "desktop", session_desktop );
|
||||||
|
}
|
||||||
|
else // SMSavePhase2Full
|
||||||
|
{
|
||||||
|
config->writeEntry( "count", count );
|
||||||
|
config->writeEntry( "active", session_active_client );
|
||||||
|
config->writeEntry( "desktop", currentDesktop());
|
||||||
}
|
}
|
||||||
config->writeEntry( "count", count );
|
|
||||||
config->writeEntry( "active", active_client );
|
|
||||||
|
|
||||||
config->writeEntry( "desktop", currentDesktop());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -20,6 +20,7 @@ License. See the file "COPYING" for the exact licensing terms.
|
||||||
#include "KWinInterface.h"
|
#include "KWinInterface.h"
|
||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
#include "kdecoration.h"
|
#include "kdecoration.h"
|
||||||
|
#include "sm.h"
|
||||||
|
|
||||||
#include <X11/Xlib.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 performWindowOperation( Client* c, WindowOperation op );
|
||||||
|
|
||||||
void storeSession( KConfig* config );
|
void storeSession( KConfig* config, SMSavePhase phase );
|
||||||
|
|
||||||
SessionInfo* takeSessionInfo( Client* );
|
SessionInfo* takeSessionInfo( Client* );
|
||||||
|
|
||||||
|
@ -451,6 +452,8 @@ class Workspace : public QObject, virtual public KWinInterface, public KDecorati
|
||||||
|
|
||||||
bool was_user_interaction;
|
bool was_user_interaction;
|
||||||
bool session_saving;
|
bool session_saving;
|
||||||
|
int session_active_client;
|
||||||
|
int session_desktop;
|
||||||
|
|
||||||
bool control_grab;
|
bool control_grab;
|
||||||
bool tab_grab;
|
bool tab_grab;
|
||||||
|
|
Loading…
Reference in a new issue