From de8d2fd13645d12c8d05ebff1053d09b768a1939 Mon Sep 17 00:00:00 2001 From: vaxerski <43317083+vaxerski@users.noreply.github.com> Date: Sun, 27 Mar 2022 21:46:27 +0200 Subject: [PATCH] handle window subsurface trees --- src/Window.hpp | 3 +++ src/events/Windows.cpp | 16 ++++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/src/Window.hpp b/src/Window.hpp index 9626bbc6..1e964860 100644 --- a/src/Window.hpp +++ b/src/Window.hpp @@ -2,6 +2,7 @@ #include "defines.hpp" #include "events/Events.hpp" +#include "helpers/SubsurfaceTree.hpp" class CWindow { @@ -54,6 +55,8 @@ public: DYNLISTENER(configureX11); // + SSurfaceTreeNode* m_pSurfaceTree = nullptr; + // For the list lookup bool operator==(const CWindow& rhs) { diff --git a/src/events/Windows.cpp b/src/events/Windows.cpp index 217fdf57..68adf1dd 100644 --- a/src/events/Windows.cpp +++ b/src/events/Windows.cpp @@ -15,6 +15,12 @@ // // // ------------------------------------------------------------ // +void addViewCoords(void* pWindow, int* x, int* y) { + const auto PWINDOW = (CWindow*)pWindow; + *x += PWINDOW->m_vEffectivePosition.x; + *y += PWINDOW->m_vEffectivePosition.y; +} + void Events::listener_mapWindow(wl_listener* listener, void* data) { CWindow* PWINDOW = wl_container_of(listener, PWINDOW, listen_mapWindow); @@ -106,6 +112,8 @@ void Events::listener_mapWindow(wl_listener* listener, void* data) { if (!PWINDOW->m_bIsModal) g_pCompositor->focusWindow(PWINDOW); + PWINDOW->m_pSurfaceTree = SubsurfaceTree::createTreeRoot(g_pXWaylandManager->getWindowSurface(PWINDOW), addViewCoords, PWINDOW); + Debug::log(LOG, "Map request dispatched, monitor %s, xywh: %f %f %f %f", PMONITOR->szName.c_str(), PWINDOW->m_vEffectivePosition.x, PWINDOW->m_vEffectivePosition.y, PWINDOW->m_vEffectiveSize.x, PWINDOW->m_vEffectiveSize.y); } @@ -132,6 +140,9 @@ void Events::listener_unmapWindow(wl_listener* listener, void* data) { // refocus on a new window g_pInputManager->refocus(); + + SubsurfaceTree::destroySurfaceTree(PWINDOW->m_pSurfaceTree); + PWINDOW->m_pSurfaceTree = nullptr; } void Events::listener_commitWindow(wl_listener* listener, void* data) { @@ -150,6 +161,11 @@ void Events::listener_destroyWindow(wl_listener* listener, void* data) { g_pLayoutManager->getCurrentLayout()->onWindowRemoved(PWINDOW); + if (PWINDOW->m_pSurfaceTree) { + SubsurfaceTree::destroySurfaceTree(PWINDOW->m_pSurfaceTree); + PWINDOW->m_pSurfaceTree = nullptr; + } + g_pCompositor->removeWindowFromVectorSafe(PWINDOW); }