From 04c98abd1fe7f3d63c6060ea175e0a5cd9cd9947 Mon Sep 17 00:00:00 2001 From: Vaxry <43317083+vaxerski@users.noreply.github.com> Date: Thu, 8 May 2025 21:00:28 +0200 Subject: layout: properly assign workspace and monitor when moving a child to the parent (#10338) --- src/desktop/Window.cpp | 21 +++++++++++++++++++++ src/desktop/Window.hpp | 1 + 2 files changed, 22 insertions(+) (limited to 'src/desktop') diff --git a/src/desktop/Window.cpp b/src/desktop/Window.cpp index c712e5eb..c2b92094 100644 --- a/src/desktop/Window.cpp +++ b/src/desktop/Window.cpp @@ -1822,3 +1822,24 @@ std::optional CWindow::xdgDescription() { return m_xdgSurface->m_toplevel->m_toplevelDescription; } + +PHLWINDOW CWindow::parent() { + if (m_isX11) { + auto t = x11TransientFor(); + + // don't return a parent that's not mapped + if (!validMapped(t)) + return nullptr; + + return t; + } + + if (!m_xdgSurface || !m_xdgSurface->m_toplevel || !m_xdgSurface->m_toplevel->m_parent) + return nullptr; + + // don't return a parent that's not mapped + if (!m_xdgSurface->m_toplevel->m_parent->m_window || !validMapped(m_xdgSurface->m_toplevel->m_parent->m_window)) + return nullptr; + + return m_xdgSurface->m_toplevel->m_parent->m_window.lock(); +} diff --git a/src/desktop/Window.hpp b/src/desktop/Window.hpp index 449c9c60..abc2747f 100644 --- a/src/desktop/Window.hpp +++ b/src/desktop/Window.hpp @@ -409,6 +409,7 @@ class CWindow { bool isNotResponding(); std::optional xdgTag(); std::optional xdgDescription(); + PHLWINDOW parent(); CBox getWindowMainSurfaceBox() const { return {m_realPosition->value().x, m_realPosition->value().y, m_realSize->value().x, m_realSize->value().y}; -- cgit v1.2.3