From f8f8e6146604ea918e4b81a31651945e0002408e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Gr=C3=A4=C3=9Flin?= Date: Mon, 25 Apr 2016 08:51:33 +0200 Subject: [PATCH] Make integration with KScreenLocker optional in WaylandServer Summary: In order to start the WaylandServer in kwin_x11 we need to make sure that WaylandServer does not start the KScreenLocker integration. On X11 the lock screen is provided by a different application (in Plasma by ksmserver). A new init flag is added to WaylandServer to not integrate with KScreenLocker. Thus the default is still to integrate with KScreenLocker. All direct usages of KScreenLocker are guarded to not be called if the screenlocker integration is not present. Reviewers: #plasma Subscribers: plasma-devel Projects: #plasma Differential Revision: https://phabricator.kde.org/D1481 --- keyboard_input.cpp | 4 +++- pointer_input.cpp | 8 ++++++-- touch_input.cpp | 16 +++++++++------- wayland_server.cpp | 44 +++++++++++++++++++++++++++----------------- wayland_server.h | 7 ++++++- 5 files changed, 51 insertions(+), 28 deletions(-) diff --git a/keyboard_input.cpp b/keyboard_input.cpp index 436e56c1fa..26287e832c 100644 --- a/keyboard_input.cpp +++ b/keyboard_input.cpp @@ -374,7 +374,9 @@ void KeyboardInputRedirection::init() connect(workspace(), &QObject::destroyed, this, [this] { m_inited = false; }); connect(waylandServer(), &QObject::destroyed, this, [this] { m_inited = false; }); connect(workspace(), &Workspace::clientActivated, this, &KeyboardInputRedirection::update); - connect(ScreenLocker::KSldApp::self(), &ScreenLocker::KSldApp::lockStateChanged, this, &KeyboardInputRedirection::update); + if (waylandServer()->hasScreenLockerIntegration()) { + connect(ScreenLocker::KSldApp::self(), &ScreenLocker::KSldApp::lockStateChanged, this, &KeyboardInputRedirection::update); + } QAction *switchKeyboardAction = new QAction(this); switchKeyboardAction->setObjectName(QStringLiteral("Switch to Next Keyboard Layout")); diff --git a/pointer_input.cpp b/pointer_input.cpp index f4aaf8eb60..1c5b92eb37 100644 --- a/pointer_input.cpp +++ b/pointer_input.cpp @@ -126,7 +126,9 @@ void PointerInputRedirection::init() emit m_cursor->changed(); connect(workspace(), &Workspace::stackingOrderChanged, this, &PointerInputRedirection::update); connect(screens(), &Screens::changed, this, &PointerInputRedirection::updateAfterScreenChange); - connect(ScreenLocker::KSldApp::self(), &ScreenLocker::KSldApp::lockStateChanged, this, &PointerInputRedirection::update); + if (waylandServer()->hasScreenLockerIntegration()) { + connect(ScreenLocker::KSldApp::self(), &ScreenLocker::KSldApp::lockStateChanged, this, &PointerInputRedirection::update); + } connect(workspace(), &QObject::destroyed, this, [this] { m_inited = false; }); connect(waylandServer(), &QObject::destroyed, this, [this] { m_inited = false; }); connect(waylandServer()->seat(), &KWayland::Server::SeatInterface::dragEnded, this, @@ -527,7 +529,9 @@ CursorImage::CursorImage(PointerInputRedirection *parent) reevaluteSource(); } ); - connect(ScreenLocker::KSldApp::self(), &ScreenLocker::KSldApp::lockStateChanged, this, &CursorImage::reevaluteSource); + if (waylandServer()->hasScreenLockerIntegration()) { + connect(ScreenLocker::KSldApp::self(), &ScreenLocker::KSldApp::lockStateChanged, this, &CursorImage::reevaluteSource); + } connect(m_pointer, &PointerInputRedirection::decorationChanged, this, &CursorImage::updateDecoration); // connect the move resize of all window auto setupMoveResizeConnection = [this] (AbstractClient *c) { diff --git a/touch_input.cpp b/touch_input.cpp index fb01a47c98..ec4f99cb19 100644 --- a/touch_input.cpp +++ b/touch_input.cpp @@ -43,13 +43,15 @@ void TouchInputRedirection::init() Q_ASSERT(!m_inited); m_inited = true; - connect(ScreenLocker::KSldApp::self(), &ScreenLocker::KSldApp::lockStateChanged, this, - [this] { - cancel(); - // position doesn't matter - update(); - } - ); + if (waylandServer()->hasScreenLockerIntegration()) { + connect(ScreenLocker::KSldApp::self(), &ScreenLocker::KSldApp::lockStateChanged, this, + [this] { + cancel(); + // position doesn't matter + update(); + } + ); + } connect(workspace(), &QObject::destroyed, this, [this] { m_inited = false; }); connect(waylandServer(), &QObject::destroyed, this, [this] { m_inited = false; }); } diff --git a/wayland_server.cpp b/wayland_server.cpp index cac929c537..ff2e64e2a1 100644 --- a/wayland_server.cpp +++ b/wayland_server.cpp @@ -260,25 +260,27 @@ void WaylandServer::initWorkspace() ); } - ScreenLocker::KSldApp::self(); - ScreenLocker::KSldApp::self()->setWaylandDisplay(m_display); - ScreenLocker::KSldApp::self()->setGreeterEnvironment(kwinApp()->processStartupEnvironment()); - ScreenLocker::KSldApp::self()->initialize(); + if (hasScreenLockerIntegration()) { + ScreenLocker::KSldApp::self(); + ScreenLocker::KSldApp::self()->setWaylandDisplay(m_display); + ScreenLocker::KSldApp::self()->setGreeterEnvironment(kwinApp()->processStartupEnvironment()); + ScreenLocker::KSldApp::self()->initialize(); - connect(ScreenLocker::KSldApp::self(), &ScreenLocker::KSldApp::greeterClientConnectionChanged, this, - [this] () { - m_screenLockerClientConnection = ScreenLocker::KSldApp::self()->greeterClientConnection(); + connect(ScreenLocker::KSldApp::self(), &ScreenLocker::KSldApp::greeterClientConnectionChanged, this, + [this] () { + m_screenLockerClientConnection = ScreenLocker::KSldApp::self()->greeterClientConnection(); + } + ); + + connect(ScreenLocker::KSldApp::self(), &ScreenLocker::KSldApp::unlocked, this, + [this] () { + m_screenLockerClientConnection = nullptr; + } + ); + + if (m_initFlags.testFlag(InitalizationFlag::LockScreen)) { + ScreenLocker::KSldApp::self()->lock(ScreenLocker::EstablishLock::Immediate); } - ); - - connect(ScreenLocker::KSldApp::self(), &ScreenLocker::KSldApp::unlocked, this, - [this] () { - m_screenLockerClientConnection = nullptr; - } - ); - - if (m_initFlags.testFlag(InitalizationFlag::LockScreen)) { - ScreenLocker::KSldApp::self()->lock(ScreenLocker::EstablishLock::Immediate); } } @@ -511,8 +513,16 @@ quint16 WaylandServer::createClientId(ClientConnection *c) bool WaylandServer::isScreenLocked() const { + if (!hasScreenLockerIntegration()) { + return false; + } return ScreenLocker::KSldApp::self()->lockState() == ScreenLocker::KSldApp::Locked || ScreenLocker::KSldApp::self()->lockState() == ScreenLocker::KSldApp::AcquiringLock; } +bool WaylandServer::hasScreenLockerIntegration() const +{ + return !m_initFlags.testFlag(InitalizationFlag::NoLockScreenIntegration); +} + } diff --git a/wayland_server.h b/wayland_server.h index 5f19184628..a44af9a290 100644 --- a/wayland_server.h +++ b/wayland_server.h @@ -66,7 +66,8 @@ class KWIN_EXPORT WaylandServer : public QObject public: enum class InitalizationFlag { NoOptions = 0x0, - LockScreen = 0x1 + LockScreen = 0x1, + NoLockScreenIntegration = 0x2 }; Q_DECLARE_FLAGS(InitalizationFlags, InitalizationFlag) @@ -121,6 +122,10 @@ public: * @returns true if screen is locked. **/ bool isScreenLocked() const; + /** + * @returns whether integration with KScreenLocker is available. + **/ + bool hasScreenLockerIntegration() const; void createInternalConnection(); void initWorkspace();