diff --git a/src/events/Events.cpp b/src/events/Events.cpp index df2e65fd..8f4dd105 100644 --- a/src/events/Events.cpp +++ b/src/events/Events.cpp @@ -204,6 +204,20 @@ void Events::listener_mapLayerSurface(wl_listener* listener, void* data) { wlr_surface_send_enter(layersurface->layerSurface->surface, layersurface->layerSurface->output); + // fix if it changed its mon + const auto PMONITOR = g_pCompositor->getMonitorFromOutput(layersurface->layerSurface->output); + + if ((uint64_t)layersurface->monitorID != PMONITOR->ID) { + const auto POLDMON = g_pCompositor->getMonitorFromID(layersurface->monitorID); + POLDMON->m_aLayerSurfaceLists[layersurface->layer].remove(layersurface); + PMONITOR->m_aLayerSurfaceLists[layersurface->layer].push_back(layersurface); + layersurface->monitorID = PMONITOR->ID; + g_pLayoutManager->getCurrentLayout()->recalculateMonitor(POLDMON->ID); + g_pHyprRenderer->arrangeLayersForMonitor(POLDMON->ID); + } + + g_pHyprRenderer->arrangeLayersForMonitor(PMONITOR->ID); + if (layersurface->layer == ZWLR_LAYER_SHELL_V1_LAYER_TOP || layersurface->layer == ZWLR_LAYER_SHELL_V1_LAYER_OVERLAY) g_pCompositor->focusSurface(layersurface->layerSurface->surface); @@ -240,6 +254,7 @@ void Events::listener_commitLayerSurface(wl_listener* listener, void* data) { PMONITOR->m_aLayerSurfaceLists[layersurface->layer].push_back(layersurface); layersurface->monitorID = PMONITOR->ID; g_pLayoutManager->getCurrentLayout()->recalculateMonitor(POLDMON->ID); + g_pHyprRenderer->arrangeLayersForMonitor(POLDMON->ID); } g_pHyprRenderer->arrangeLayersForMonitor(PMONITOR->ID); diff --git a/src/render/Renderer.cpp b/src/render/Renderer.cpp index 2f772e71..74ebb122 100644 --- a/src/render/Renderer.cpp +++ b/src/render/Renderer.cpp @@ -189,6 +189,14 @@ void CHyprRenderer::arrangeLayerArray(SMonitor* pMonitor, const std::listmargin.top + STATE->margin.bottom; } + if (!(STATE->anchor & (ZWLR_LAYER_SURFACE_V1_ANCHOR_RIGHT | ZWLR_LAYER_SURFACE_V1_ANCHOR_LEFT | ZWLR_LAYER_SURFACE_V1_ANCHOR_TOP | ZWLR_LAYER_SURFACE_V1_ANCHOR_BOTTOM))) { + // no anchors. center + layerBox.x = pMonitor->vecPosition.x + (pMonitor->vecSize.x - layerBox.width) / 2.f; + layerBox.y = pMonitor->vecPosition.y + (pMonitor->vecSize.y - layerBox.height) / 2.f; + + // TODO: maybe allow the app to choose for itself its x and y? + } + ls->geometry = layerBox; wlr_layer_surface_v1_configure(ls->layerSurface, layerBox.width, layerBox.height);