From 13886a264f7e076681f9c2c65367c643a973f390 Mon Sep 17 00:00:00 2001 From: vaxerski Date: Mon, 14 Aug 2023 14:22:06 +0200 Subject: internal: add a new monitor auto system --- src/Compositor.cpp | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) (limited to 'src/Compositor.cpp') diff --git a/src/Compositor.cpp b/src/Compositor.cpp index ab38bd09..fb038e5f 100644 --- a/src/Compositor.cpp +++ b/src/Compositor.cpp @@ -2485,3 +2485,37 @@ void CCompositor::setIdleActivityInhibit(bool enabled) { wlr_idle_set_enabled(g_pCompositor->m_sWLRIdle, g_pCompositor->m_sSeat.seat, enabled); wlr_idle_notifier_v1_set_inhibited(g_pCompositor->m_sWLRIdleNotifier, !enabled); } + +void CCompositor::arrangeMonitors() { + std::vector toArrange; + std::vector arranged; + + for (auto& m : m_vMonitors) + toArrange.push_back(m.get()); + + for (auto it = toArrange.begin(); it != toArrange.end(); ++it) { + auto m = *it; + + if (m->activeMonitorRule.offset > Vector2D{-1, -1}) { + // explicit. + m->moveTo(m->activeMonitorRule.offset); + arranged.push_back(m); + it = toArrange.erase(it); + + if (it == toArrange.end()) + break; + } + } + + // auto left + int maxOffset = 0; + for (auto& m : arranged) { + if (m->vecPosition.x + m->vecSize.x > maxOffset) + maxOffset = m->vecPosition.x + m->vecSize.x; + } + + for (auto& m : toArrange) { + m->moveTo({maxOffset, 0}); + maxOffset += m->vecPosition.x; + } +} -- cgit v1.2.3