From 2ebe7b313efbacfcd62ec39e2fda6b4c740d0770 Mon Sep 17 00:00:00 2001 From: outfoxxed Date: Sun, 4 Feb 2024 04:00:34 -0800 Subject: [PATCH] Fix changing anchors of a shell surface --- src/qwaylandlayersurface.cpp | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/src/qwaylandlayersurface.cpp b/src/qwaylandlayersurface.cpp index 89f47ef..79475d5 100644 --- a/src/qwaylandlayersurface.cpp +++ b/src/qwaylandlayersurface.cpp @@ -41,7 +41,20 @@ QWaylandLayerSurface::QWaylandLayerSurface(QWaylandLayerShellIntegration *shell, }); set_anchor(m_interface->anchors()); - connect(m_interface, &Window::anchorsChanged, this, [this]() { + connect(m_interface, &Window::anchorsChanged, this, [this, window]() { + QSize size = window->surfaceSize(); + const Window::Anchors anchors = m_interface->anchors(); + if ((anchors & Window::AnchorLeft) && (anchors & Window::AnchorRight)) { + size.setWidth(0); + } + if ((anchors & Window::AnchorTop) && (anchors & Window::AnchorBottom)) { + size.setHeight(0); + } + if (size.isValid() && size != QSize(0, 0)) { + set_size(size.width(), size.height()); + } + + set_size(size.width(), size.height()); set_anchor(m_interface->anchors()); }); setExclusiveZone(m_interface->exclusionZone()); @@ -67,9 +80,8 @@ QWaylandLayerSurface::QWaylandLayerSurface(QWaylandLayerShellIntegration *shell, if ((anchors & Window::AnchorTop) && (anchors & Window::AnchorBottom)) { size.setHeight(0); } - if (size.isValid() && size != QSize(0, 0)) { - set_size(size.width(), size.height()); - } + + set_size(size.width(), size.height()); } QWaylandLayerSurface::~QWaylandLayerSurface()