From d61503352637fd2153dbbbac20e0a5f9d6e3f201 Mon Sep 17 00:00:00 2001 From: vaxerski <43317083+vaxerski@users.noreply.github.com> Date: Sat, 19 Mar 2022 13:35:04 +0100 Subject: [PATCH] layers --- src/events/Events.cpp | 11 +++++------ src/helpers/Monitor.hpp | 2 +- src/render/Renderer.cpp | 20 ++++++++++++++++++++ 3 files changed, 26 insertions(+), 7 deletions(-) diff --git a/src/events/Events.cpp b/src/events/Events.cpp index 071b4c92..947e073f 100644 --- a/src/events/Events.cpp +++ b/src/events/Events.cpp @@ -121,8 +121,8 @@ void Events::listener_newLayerSurface(wl_listener* listener, void* data) { const auto WLRLAYERSURFACE = (wlr_layer_surface_v1*)data; const auto PMONITOR = (SMonitor*)WLRLAYERSURFACE->output->data; - PMONITOR->m_lLayerSurfaces.push_back(SLayerSurface()); - SLayerSurface* layerSurface = &PMONITOR->m_lLayerSurfaces.back(); + PMONITOR->m_aLayerSurfaceLists[WLRLAYERSURFACE->pending.layer].push_back(SLayerSurface()); + SLayerSurface* layerSurface = &PMONITOR->m_aLayerSurfaceLists[WLRLAYERSURFACE->pending.layer].back(); if (!WLRLAYERSURFACE->output) { WLRLAYERSURFACE->output = g_pCompositor->m_lMonitors.front().output; // TODO: current mon @@ -153,16 +153,15 @@ void Events::listener_destroyLayerSurface(wl_listener* listener, void* data) { wl_list_remove(&layersurface->listen_unmapLayerSurface.link); wl_list_remove(&layersurface->listen_commitLayerSurface.link); - free(layersurface); - const auto PMONITOR = g_pCompositor->getMonitorFromID(layersurface->monitorID); if (!PMONITOR) return; // remove the layersurface as it's not used anymore - PMONITOR->m_lLayerSurfaces.remove(*layersurface); - + PMONITOR->m_aLayerSurfaceLists[layersurface->layerSurface->pending.layer].remove(*layersurface); + free(layersurface); + Debug::log(LOG, "LayerSurface %x destroyed", layersurface); } diff --git a/src/helpers/Monitor.hpp b/src/helpers/Monitor.hpp index b6bcdec7..a121500c 100644 --- a/src/helpers/Monitor.hpp +++ b/src/helpers/Monitor.hpp @@ -22,7 +22,7 @@ struct SMonitor { wlr_output* output = nullptr; // Double-linked list because we need to have constant mem addresses for signals - std::list m_lLayerSurfaces; + std::array,4> m_aLayerSurfaceLists; DYNLISTENER(monitorFrame); DYNLISTENER(monitorDestroy); diff --git a/src/render/Renderer.cpp b/src/render/Renderer.cpp index 62e78c56..1c3d47ac 100644 --- a/src/render/Renderer.cpp +++ b/src/render/Renderer.cpp @@ -38,6 +38,16 @@ void CHyprRenderer::renderAllClientsForMonitor(const int& ID, timespec* time) { if (!PMONITOR) return; + // Render layer surfaces below windows for monitor + for (auto& ls : PMONITOR->m_aLayerSurfaceLists[ZWLR_LAYER_SHELL_V1_LAYER_BACKGROUND]) { + SRenderData renderdata = {PMONITOR->output, time, ls.geometry.x, ls.geometry.y}; + wlr_surface_for_each_surface(ls.layerSurface->surface, renderSurface, &renderdata); + } + for (auto& ls : PMONITOR->m_aLayerSurfaceLists[ZWLR_LAYER_SHELL_V1_LAYER_BOTTOM]) { + SRenderData renderdata = {PMONITOR->output, time, ls.geometry.x, ls.geometry.y}; + wlr_surface_for_each_surface(ls.layerSurface->surface, renderSurface, &renderdata); + } + for (auto& w : g_pCompositor->m_lWindows) { if (w.m_bIsX11) @@ -78,4 +88,14 @@ void CHyprRenderer::renderAllClientsForMonitor(const int& ID, timespec* time) { if (w.m_uSurface.xwayland->surface) wlr_surface_for_each_surface(g_pXWaylandManager->getWindowSurface(&w), renderSurface, &renderdata); } + + // Render surfaces above windows for monitor + for (auto& ls : PMONITOR->m_aLayerSurfaceLists[ZWLR_LAYER_SHELL_V1_LAYER_TOP]) { + SRenderData renderdata = {PMONITOR->output, time, ls.geometry.x, ls.geometry.y}; + wlr_surface_for_each_surface(ls.layerSurface->surface, renderSurface, &renderdata); + } + for (auto& ls : PMONITOR->m_aLayerSurfaceLists[ZWLR_LAYER_SHELL_V1_LAYER_OVERLAY]) { + SRenderData renderdata = {PMONITOR->output, time, ls.geometry.x, ls.geometry.y}; + wlr_surface_for_each_surface(ls.layerSurface->surface, renderSurface, &renderdata); + } }