summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorvaxerski <43317083+vaxerski@users.noreply.github.com>2022-08-28 19:47:06 +0200
committervaxerski <43317083+vaxerski@users.noreply.github.com>2022-08-28 19:47:06 +0200
commit5da114477fdb1c806f5ad6f6fbb22903481f24c1 (patch)
tree9c0cbc69899cbacb86e9443faa889c390cdcba0c /src
parentc757fa54e10bd0f486c70e32ecca366247281824 (diff)
move X11 transients to top on parent top
Diffstat (limited to 'src')
-rw-r--r--src/Compositor.cpp31
-rw-r--r--src/Window.cpp18
-rw-r--r--src/Window.hpp1
3 files changed, 45 insertions, 5 deletions
diff --git a/src/Compositor.cpp b/src/Compositor.cpp
index 790ef592..5c9451a8 100644
--- a/src/Compositor.cpp
+++ b/src/Compositor.cpp
@@ -904,11 +904,34 @@ void CCompositor::moveWindowToTop(CWindow* pWindow) {
if (!windowValidMapped(pWindow))
return;
- for (auto it = m_vWindows.begin(); it != m_vWindows.end(); ++it) {
- if (it->get() == pWindow) {
- std::rotate(it, it + 1, m_vWindows.end());
- break;
+ auto moveToTop = [&](CWindow* pw) -> void {
+ for (auto it = m_vWindows.begin(); it != m_vWindows.end(); ++it) {
+ if (it->get() == pw) {
+ std::rotate(it, it + 1, m_vWindows.end());
+ break;
+ }
}
+ };
+
+ moveToTop(pWindow);
+
+ if (!pWindow->m_bIsX11)
+ return;
+
+ // move all children
+
+ std::deque<CWindow*> toMove;
+
+ for (auto& w : m_vWindows) {
+ if (w->m_bIsMapped && w->m_bMappedX11 && !w->m_bHidden && w->m_bIsX11 && w->X11TransientFor() == pWindow) {
+ toMove.emplace_back(w.get());
+ }
+ }
+
+ for (auto& pw : toMove) {
+ moveToTop(pw);
+
+ moveWindowToTop(pw);
}
}
diff --git a/src/Window.cpp b/src/Window.cpp
index f6bdf7dc..d5b24841 100644
--- a/src/Window.cpp
+++ b/src/Window.cpp
@@ -216,4 +216,20 @@ void CWindow::moveToWorkspace(int workspaceID) {
g_pEventManager->postEvent(SHyprIPCEvent{"movewindow", getFormat("%x,%s", this, PWORKSPACE->m_szName.c_str())});
}
}
-} \ No newline at end of file
+}
+
+CWindow* CWindow::X11TransientFor() {
+ if (!m_bIsX11)
+ return nullptr;
+
+ if (!m_uSurface.xwayland->parent)
+ return nullptr;
+
+ auto PPARENT = g_pCompositor->getWindowFromSurface(m_uSurface.xwayland->parent->surface);
+
+ while (PPARENT->m_uSurface.xwayland->parent) {
+ PPARENT = g_pCompositor->getWindowFromSurface(PPARENT->m_uSurface.xwayland->parent->surface);
+ }
+
+ return PPARENT;
+}
diff --git a/src/Window.hpp b/src/Window.hpp
index b4f6e59b..6cf22204 100644
--- a/src/Window.hpp
+++ b/src/Window.hpp
@@ -159,4 +159,5 @@ public:
void updateToplevel();
void updateSurfaceOutputs();
void moveToWorkspace(int);
+ CWindow* X11TransientFor();
};