Commit 09cad25f authored by David Edmundson's avatar David Edmundson
Browse files

[ksmserver] Signal session management state to kwin directly

Summary:
Kwin had to have two ICE connections in order to track state
indepdendently of it's session saving.

This replaces that with a more direct DBus protocol allowing for both
simplification on the kwin side as well as comunicating the logout state
better for effects.

Whilst this code temporarily complicates things, now we have this
interface the next step is drop all the isWM() stuff and do kwin
specific session management also over this interface. See T11882

Test Plan:
Added qdebug into kwin
started logging out with an unsaved file, cancelled shutdown
started logging out with, discarded file

Reviewers: #kwin, apol

Reviewed By: apol

Subscribers: broulik, apol, plasma-devel

Tags: #plasma

Differential Revision: https://phabricator.kde.org/D24945
parent e477d80b
......@@ -23,6 +23,8 @@ ecm_qt_declare_logging_category(ksmserver_KDEINIT_SRCS HEADER ksmserver_debug.h
qt5_add_dbus_adaptor( ksmserver_KDEINIT_SRCS org.kde.KSMServerInterface.xml server.h KSMServer )
qt5_add_dbus_interface( ksmserver_KDEINIT_SRCS ${KSCREENLOCKER_DBUS_INTERFACES_DIR}/org.kde.screensaver.xml kscreenlocker_interface )
qt5_add_dbus_interface( ksmserver_KDEINIT_SRCS org.kde.LogoutPrompt.xml logoutprompt_interface)
qt5_add_dbus_interface( ksmserver_KDEINIT_SRCS org.kde.KWin.Session.xml kwinsession_interface)
set(klauncher_xml ${KINIT_DBUS_INTERFACES_DIR}/kf5_org.kde.KLauncher.xml)
qt5_add_dbus_interface( ksmserver_KDEINIT_SRCS ${klauncher_xml} klauncher_interface )
......
......@@ -77,6 +77,13 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#include "logoutprompt_interface.h"
#include "shutdown_interface.h"
#include "kwinsession_interface.h"
enum KWinSessionState {
Normal = 0,
Saving = 1,
Quitting = 2
};
void KSMServer::logout( int confirm, int sdtype, int sdmode )
{
......@@ -183,6 +190,11 @@ void KSMServer::performLogout()
if (state != Idle) {
QTimer::singleShot(1000, this, &KSMServer::performLogout);
}
auto reply = m_kwinInterface->setState(KWinSessionState::Saving);
// we don't need to block as we wait for kwin to handle it's session 1
// before messaging the clients
state = Shutdown;
// shall we save the session on logout?
......@@ -251,6 +263,7 @@ void KSMServer::saveCurrentSession()
sessionGroup = QLatin1String("Session: ") + QString::fromLocal8Bit( SESSION_BY_USER );
state = Checkpoint;
wmPhase1WaitingCount = 0;
saveType = SmSaveLocal;
saveSession = true;
......@@ -405,6 +418,9 @@ void KSMServer::cancelShutdown( KSMClient* c )
}
}
state = Idle;
m_kwinInterface->setState(KWinSessionState::Normal);
if (m_performLogoutCall.type() == QDBusMessage::MethodCallMessage) {
auto reply = m_performLogoutCall.createReply(false);
QDBusConnection::sessionBus().send(reply);
......@@ -519,6 +535,9 @@ void KSMServer::startKilling()
}
// kill all clients
state = Killing;
m_kwinInterface->setState(KWinSessionState::Quitting);
foreach( KSMClient* c, clients ) {
if( isWM( c )) // kill the WM as the last one in order to reduce flicker
continue;
......
<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN"
"http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd">
<node>
<interface name="org.kde.KWin.Session">
<method name="setState">
<!-- Sets state of the session should be one of:
0 = normal
1 = saving
2= quitting
-->
<arg name="state" type="u" direction="in"/>
</method>
</interface>
</node>
......@@ -93,6 +93,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#include <qstandardpaths.h>
#include "kscreenlocker_interface.h"
#include "kwinsession_interface.h"
KSMServer* the_server = nullptr;
......@@ -599,6 +600,7 @@ extern "C" int _IceTransNoListen(const char * protocol);
KSMServer::KSMServer( const QString& windowManager, InitFlags flags )
: wmProcess( nullptr )
, sessionGroup( QStringLiteral( "" ) )
, m_kwinInterface(new OrgKdeKWinSessionInterface(QStringLiteral("org.kde.KWin"), QStringLiteral("/Session"), QDBusConnection::sessionBus(), this))
, sockets{ -1, -1 }
{
if (!flags.testFlag(InitFlag::NoLockScreen)) {
......
......@@ -62,6 +62,7 @@ class KSMListener;
class KSMConnection;
class KSMClient;
class OrgKdeKWinSessionInterface;
enum SMType { SM_ERROR, SM_WMCOMMAND, SM_WMSAVEYOURSELF };
struct SMData
......@@ -83,6 +84,7 @@ public:
ImmediateLockScreen = 1 << 1,
NoLockScreen = 1 << 2
};
Q_DECLARE_FLAGS(InitFlags, InitFlag)
KSMServer( const QString& windowManager, InitFlags flags );
~KSMServer() override;
......@@ -255,6 +257,8 @@ private:
QList<KSMClient*> clientsToKill;
QList<KSMClient*> clientsToSave;
OrgKdeKWinSessionInterface *m_kwinInterface;
int sockets[2];
friend bool readFromPipe(int pipe);
};
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment