summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorvaxerski <43317083+vaxerski@users.noreply.github.com>2022-03-20 14:52:23 +0100
committervaxerski <43317083+vaxerski@users.noreply.github.com>2022-03-20 14:52:23 +0100
commit45addfb31d02dac2ac7651410178e7a0cfde00f4 (patch)
tree588298df01248f6a2f558aedce8fb42ddb53a468 /src
parente7abda1b2bae15e02242e90d57efced1437fabff (diff)
arrange properly layers with no anchors
Diffstat (limited to 'src')
-rw-r--r--src/events/Events.cpp15
-rw-r--r--src/render/Renderer.cpp8
2 files changed, 23 insertions, 0 deletions
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::list<SLayer
layerBox.height -= STATE->margin.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);