From 35abacabc41dabb4d5680c18c5c59c8ca9179cc5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Gr=C3=A4=C3=9Flin?= Date: Wed, 3 Jun 2015 21:19:00 +0200 Subject: [PATCH] [wayland] Handle unmap in ShellClient Do not destroy the ShellClient when the Surface gets unmapped. Instead just hide the ShellClient and show it again on the next damage. --- scene.cpp | 4 ++-- shell_client.cpp | 14 ++++++++++++-- shell_client.h | 2 ++ 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/scene.cpp b/scene.cpp index 208a2403ba..6a6714272f 100644 --- a/scene.cpp +++ b/scene.cpp @@ -760,8 +760,8 @@ bool Scene::Window::isVisible() const return false; if (!toplevel->isOnCurrentActivity()) return false; - if (toplevel->isClient()) - return (static_cast< Client *>(toplevel))->isShown(true); + if (AbstractClient *c = dynamic_cast(toplevel)) + return c->isShown(true); return true; // Unmanaged is always visible } diff --git a/shell_client.cpp b/shell_client.cpp index c9b3c94645..3eeab316a9 100644 --- a/shell_client.cpp +++ b/shell_client.cpp @@ -48,6 +48,7 @@ ShellClient::ShellClient(ShellSurfaceInterface *surface) setupCompositing(); if (surface->surface()->buffer()) { setReadyForPainting(); + m_unmapped = false; m_clientSize = surface->surface()->buffer()->size(); } else { ready_for_painting = false; @@ -68,7 +69,7 @@ ShellClient::ShellClient(ShellSurfaceInterface *surface) } ); connect(surface, &ShellSurfaceInterface::destroyed, this, &ShellClient::destroyClient); - connect(surface->surface(), &SurfaceInterface::unmapped, this, &ShellClient::destroyClient); + connect(surface->surface(), &SurfaceInterface::unmapped, this, &ShellClient::unmap); connect(surface, &ShellSurfaceInterface::titleChanged, this, &ShellClient::captionChanged); connect(surface, &ShellSurfaceInterface::fullscreenChanged, this, &ShellClient::clientFullScreenChanged); @@ -167,6 +168,7 @@ void ShellClient::addDamage(const QRegion &damage) } setDepth(m_shellSurface->surface()->buffer()->hasAlphaChannel() ? 32 : 24); setReadyForPainting(); + m_unmapped = false; Toplevel::addDamage(damage); } @@ -266,7 +268,7 @@ bool ShellClient::isResizable() const bool ShellClient::isShown(bool shaded_is_shown) const { Q_UNUSED(shaded_is_shown) - return !m_closing; + return !m_closing && !m_unmapped; } void ShellClient::maximize(MaximizeMode) @@ -470,4 +472,12 @@ void ShellClient::resizeWithChecks(int w, int h, ForceGeometry_t force) m_shellSurface->requestSize(QSize(w, h)); } +void ShellClient::unmap() +{ + m_unmapped = true; + ready_for_painting = false; + addWorkspaceRepaint(visibleRect()); + workspace()->clientHidden(this); +} + } diff --git a/shell_client.h b/shell_client.h index 1a47578fcd..d751f75cb9 100644 --- a/shell_client.h +++ b/shell_client.h @@ -109,6 +109,7 @@ private: void requestGeometry(const QRect &rect); void setGeometry(const QRect &rect); void destroyClient(); + void unmap(); void createWindowId(); void findInternalWindow(); void updateInternalWindowGeometry(); @@ -122,6 +123,7 @@ private: bool m_closing = false; quint32 m_windowId = 0; QWindow *m_internalWindow = nullptr; + bool m_unmapped = true; }; }