From 3a1371989e290d3df08cf0abd4d5eb298d329fa4 Mon Sep 17 00:00:00 2001 From: Bhushan Shah Date: Fri, 6 Nov 2015 19:38:13 +0530 Subject: [PATCH] [wayland] Introduce ShellClient::isLockScreen method MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This allows to check if specific ShellClient is from LockScreen or not, as well as this adds method to verify if ShellClient is from input method like maliit. Now that KWin knows about which window is from Screenlocker it can apply various security restrictions like no other window then greeter is on top of it. Reviewed-By: Martin Gräßlin --- shell_client.cpp | 10 ++++++++++ shell_client.h | 2 ++ wayland_server.cpp | 13 +++++++++++++ wayland_server.h | 4 ++++ 4 files changed, 29 insertions(+) diff --git a/shell_client.cpp b/shell_client.cpp index 6868dfc5a7..929ceed50e 100644 --- a/shell_client.cpp +++ b/shell_client.cpp @@ -626,6 +626,16 @@ bool ShellClient::isInternal() const return m_shellSurface->client() == waylandServer()->internalConnection(); } +bool ShellClient::isLockScreen() const +{ + return m_shellSurface->client() == waylandServer()->greeterClientConnection(); +} + +bool ShellClient::isInputMethod() const +{ + return m_shellSurface->client() == waylandServer()->inputMethodConnection(); +} + xcb_window_t ShellClient::window() const { return windowId(); diff --git a/shell_client.h b/shell_client.h index 2cf24a3573..35ae084fdf 100644 --- a/shell_client.h +++ b/shell_client.h @@ -101,6 +101,8 @@ public: return m_windowId; } bool isInternal() const; + bool isLockScreen() const; + bool isInputMethod() const; QWindow *internalWindow() const { return m_internalWindow; } diff --git a/wayland_server.cpp b/wayland_server.cpp index aeb819ca42..6cb222c30f 100644 --- a/wayland_server.cpp +++ b/wayland_server.cpp @@ -214,6 +214,19 @@ void WaylandServer::initWorkspace() ScreenLocker::KSldApp::self(); ScreenLocker::KSldApp::self()->setWaylandDisplay(m_display); ScreenLocker::KSldApp::self()->initialize(); + + connect(ScreenLocker::KSldApp::self(), &ScreenLocker::KSldApp::locked, 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); } diff --git a/wayland_server.h b/wayland_server.h index b9bda4df83..e54e39bff0 100644 --- a/wayland_server.h +++ b/wayland_server.h @@ -127,6 +127,9 @@ public: KWayland::Server::ClientConnection *internalConnection() const { return m_internalConnection.server; } + KWayland::Server::ClientConnection *screenLockerClientConnection() const { + return m_screenLockerClientConnection; + } KWayland::Client::ShmPool *internalShmPool() { return m_internalConnection.shm; } @@ -154,6 +157,7 @@ private: KWayland::Server::QtSurfaceExtensionInterface *m_qtExtendedSurface = nullptr; KWayland::Server::ClientConnection *m_xwaylandConnection = nullptr; KWayland::Server::ClientConnection *m_inputMethodServerConnection = nullptr; + KWayland::Server::ClientConnection *m_screenLockerClientConnection = nullptr; struct { KWayland::Server::ClientConnection *server = nullptr; KWayland::Client::ConnectionThread *client = nullptr;