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.
This commit is contained in:
Vlad Zahorodnii 2023-03-21 10:53:21 +02:00
parent 008bdd18e4
commit 2510bf0439
2 changed files with 4 additions and 4 deletions

View file

@ -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

View file

@ -57,6 +57,7 @@ private:
QString m_captionNormal;
QString m_captionSuffix;
bool m_isHidden = false;
bool m_isScreenLocker = false;
};
} // namespace KWin