From 450bbaafdc6eb70d1934c2c54c0e38daf8271add Mon Sep 17 00:00:00 2001 From: Bhushan Shah Date: Mon, 16 Nov 2015 15:49:38 +0530 Subject: [PATCH] [wayland] Introduce property to identify lockscreen and inputmethods This introduces Toplevel::isLockScreen() and Toplevel::isInputMethod(), this can be used to allow only lockscreen/inputmethods to get input events and shown when screen is locked. --- shell_client.h | 4 ++-- toplevel.h | 13 +++++++++++++ wayland_server.cpp | 8 ++++++++ wayland_server.h | 5 +++++ 4 files changed, 28 insertions(+), 2 deletions(-) diff --git a/shell_client.h b/shell_client.h index 35ae084fdf..64fb53ebea 100644 --- a/shell_client.h +++ b/shell_client.h @@ -101,8 +101,8 @@ public: return m_windowId; } bool isInternal() const; - bool isLockScreen() const; - bool isInputMethod() const; + bool isLockScreen() const override; + bool isInputMethod() const override; QWindow *internalWindow() const { return m_internalWindow; } diff --git a/toplevel.h b/toplevel.h index 1af3274445..4f12bec558 100644 --- a/toplevel.h +++ b/toplevel.h @@ -252,6 +252,9 @@ public: bool isComboBox() const; bool isDNDIcon() const; + virtual bool isLockScreen() const; + virtual bool isInputMethod() const; + virtual int desktop() const = 0; virtual QStringList activities() const = 0; bool isOnDesktop(int d) const; @@ -650,6 +653,16 @@ inline bool Toplevel::isDNDIcon() const return windowType() == NET::DNDIcon; } +inline bool Toplevel::isLockScreen() const +{ + return false; +} + +inline bool Toplevel::isInputMethod() const +{ + return false; +} + inline QRegion Toplevel::damage() const { return damage_region; diff --git a/wayland_server.cpp b/wayland_server.cpp index 3bc4de3ffd..4036a317ae 100644 --- a/wayland_server.cpp +++ b/wayland_server.cpp @@ -133,6 +133,9 @@ void WaylandServer::init(const QByteArray &socketName, InitalizationFlags flags) // skip Xwayland clients, those are created using standard X11 way return; } + if (surface->client() == m_screenLockerClientConnection && !isScreenLocked()) { + ScreenLocker::KSldApp::self()->lockScreenShown(); + } auto client = new ShellClient(surface); if (auto c = Compositor::self()) { connect(client, &Toplevel::needsRepaint, c, &Compositor::scheduleRepaint); @@ -480,4 +483,9 @@ quint16 WaylandServer::createClientId(ClientConnection *c) return id; } +bool WaylandServer::isScreenLocked() const +{ + return ScreenLocker::KSldApp::self()->lockState() == ScreenLocker::KSldApp::Locked; +} + } diff --git a/wayland_server.h b/wayland_server.h index 64193d07d0..b6514b6fe8 100644 --- a/wayland_server.h +++ b/wayland_server.h @@ -117,6 +117,11 @@ public: int createInputMethodConnection(); void destroyInputMethodConnection(); + /** + * @returns true if screen is locked. + **/ + bool isScreenLocked() const; + void createInternalConnection(); void destroyInternalConnection(); void initWorkspace();