From 2510bf04394f0f95bc75851ff7969c789fa4f1e5 Mon Sep 17 00:00:00 2001 From: Vlad Zahorodnii Date: Tue, 21 Mar 2023 10:53:21 +0200 Subject: [PATCH] wayland: Cache WaylandWindow::isScreenLocker() This is needed to ensure that Window::isScreenLocker() returns a good value for closed windows. Also, it's needed to get rid of ClientConnection::aboutToBeDestroyed() connection, which can cause problems with window teardown. --- src/waylandwindow.cpp | 7 +++---- src/waylandwindow.h | 1 + 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/waylandwindow.cpp b/src/waylandwindow.cpp index b27b86d21d..31c389a2ac 100644 --- a/src/waylandwindow.cpp +++ b/src/waylandwindow.cpp @@ -35,6 +35,7 @@ enum WaylandGeometryType { Q_DECLARE_FLAGS(WaylandGeometryTypes, WaylandGeometryType) WaylandWindow::WaylandWindow(SurfaceInterface *surface) + : m_isScreenLocker(surface->client() == waylandServer()->screenLockerClientConnection()) { setSurface(surface); setDepth(32); @@ -46,8 +47,6 @@ WaylandWindow::WaylandWindow(SurfaceInterface *surface) connect(this, &WaylandWindow::desktopFileNameChanged, this, &WaylandWindow::updateIcon); connect(workspace(), &Workspace::outputsChanged, this, &WaylandWindow::updateClientOutputs); - connect(surface->client(), &ClientConnection::aboutToBeDestroyed, - this, &WaylandWindow::destroyWindow); updateResourceName(); updateIcon(); @@ -70,7 +69,7 @@ QString WaylandWindow::captionSuffix() const pid_t WaylandWindow::pid() const { - return surface()->client()->processId(); + return surface() ? surface()->client()->processId() : -1; } bool WaylandWindow::isClient() const @@ -80,7 +79,7 @@ bool WaylandWindow::isClient() const bool WaylandWindow::isLockScreen() const { - return surface()->client() == waylandServer()->screenLockerClientConnection(); + return m_isScreenLocker; } bool WaylandWindow::isLocalhost() const diff --git a/src/waylandwindow.h b/src/waylandwindow.h index 2be051eed5..2c7b5c8186 100644 --- a/src/waylandwindow.h +++ b/src/waylandwindow.h @@ -57,6 +57,7 @@ private: QString m_captionNormal; QString m_captionSuffix; bool m_isHidden = false; + bool m_isScreenLocker = false; }; } // namespace KWin