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