diff options
| author | vaxerski <43317083+vaxerski@users.noreply.github.com> | 2022-03-19 14:37:40 +0100 |
|---|---|---|
| committer | vaxerski <43317083+vaxerski@users.noreply.github.com> | 2022-03-19 14:37:40 +0100 |
| commit | e664b0b6920571b864776319dd32153e104e748d (patch) | |
| tree | d7650793c620308d00ea026314628148aad6aa2b /src/render/Renderer.cpp | |
| parent | 5f71a33d9937dadac20007c2cc173e36fc51032f (diff) | |
layers should work now
Diffstat (limited to 'src/render/Renderer.cpp')
| -rw-r--r-- | src/render/Renderer.cpp | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/src/render/Renderer.cpp b/src/render/Renderer.cpp index 0ad0c1ba..b335cbe0 100644 --- a/src/render/Renderer.cpp +++ b/src/render/Renderer.cpp @@ -139,4 +139,70 @@ void CHyprRenderer::outputMgrApplyTest(wlr_output_configuration_v1* config, bool wlr_output_configuration_v1_destroy(config); Debug::log(LOG, "OutputMgr Applied/Tested."); +} + +void CHyprRenderer::arrangeLayerArray(SMonitor* pMonitor, const std::list<SLayerSurface*>& layerSurfaces) { + for (auto& ls : layerSurfaces) { + + const auto STATE = &ls->layerSurface->current; + wlr_box layerBox = { .width = STATE->desired_width, .height = STATE->desired_height }; + + if (STATE->anchor & (ZWLR_LAYER_SURFACE_V1_ANCHOR_LEFT | ZWLR_LAYER_SURFACE_V1_ANCHOR_RIGHT)) + layerBox.width = pMonitor->vecSize.x; + if (STATE->anchor & (ZWLR_LAYER_SURFACE_V1_ANCHOR_TOP | ZWLR_LAYER_SURFACE_V1_ANCHOR_BOTTOM)) + layerBox.height = pMonitor->vecSize.y; + + if (STATE->anchor & ZWLR_LAYER_SURFACE_V1_ANCHOR_TOP) { + pMonitor->vecReservedTopLeft.y += STATE->desired_height; + layerBox.x = pMonitor->vecPosition.x + STATE->margin.left; + layerBox.y = pMonitor->vecPosition.y + STATE->margin.top; + + layerBox.width -= STATE->margin.left + STATE->margin.right; + layerBox.height -= STATE->margin.top + STATE->margin.bottom; + } + if (STATE->anchor & ZWLR_LAYER_SURFACE_V1_ANCHOR_BOTTOM) { + pMonitor->vecReservedBottomRight.y += STATE->desired_height; + layerBox.x = pMonitor->vecPosition.x + STATE->margin.left; + layerBox.y = pMonitor->vecPosition.y + pMonitor->vecSize.y - layerBox.height - STATE->margin.bottom; + + layerBox.width -= STATE->margin.left + STATE->margin.right; + layerBox.height -= STATE->margin.top + STATE->margin.bottom; + } + if (STATE->anchor & ZWLR_LAYER_SURFACE_V1_ANCHOR_LEFT) { + pMonitor->vecReservedTopLeft.x += STATE->desired_width; + layerBox.x = pMonitor->vecPosition.x + STATE->margin.left; + layerBox.y = pMonitor->vecPosition.y + STATE->margin.top; + + layerBox.width -= STATE->margin.left + STATE->margin.right; + layerBox.height -= STATE->margin.top + STATE->margin.bottom; + } + if (STATE->anchor & ZWLR_LAYER_SURFACE_V1_ANCHOR_RIGHT) { + pMonitor->vecReservedBottomRight.x += STATE->desired_width; + layerBox.x = pMonitor->vecPosition.x + pMonitor->vecSize.x - layerBox.width - STATE->margin.right; + layerBox.y = pMonitor->vecPosition.y + STATE->margin.top; + + layerBox.width -= STATE->margin.left + STATE->margin.right; + layerBox.height -= STATE->margin.top + STATE->margin.bottom; + } + + ls->geometry = layerBox; + + wlr_layer_surface_v1_configure(ls->layerSurface, layerBox.width, layerBox.height); + + Debug::log(LOG, "LayerSurface %x arranged: x: %i y: %i w: %i h: %i", &ls, layerBox.x, layerBox.y, layerBox.width, layerBox.height); + } +} + +void CHyprRenderer::arrangeLayersForMonitor(const int& monitor) { + const auto PMONITOR = g_pCompositor->getMonitorFromID(monitor); + + if (!PMONITOR) + return; + + // Reset the reserved + PMONITOR->vecReservedBottomRight = Vector2D(); + PMONITOR->vecReservedTopLeft = Vector2D(); + + for (auto& la : PMONITOR->m_aLayerSurfaceLists) + arrangeLayerArray(PMONITOR, la); }
\ No newline at end of file |
