diff options
| author | vaxerski <vaxry@vaxry.net> | 2023-08-14 14:22:06 +0200 |
|---|---|---|
| committer | vaxerski <vaxry@vaxry.net> | 2023-08-14 14:22:10 +0200 |
| commit | 13886a264f7e076681f9c2c65367c643a973f390 (patch) | |
| tree | ce8d58854307298c7312341f90ca926e94e87db3 /src/Compositor.cpp | |
| parent | a0cf89029263decba29b0f4216b38576f4418335 (diff) | |
internal: add a new monitor auto system
Diffstat (limited to 'src/Compositor.cpp')
| -rw-r--r-- | src/Compositor.cpp | 34 |
1 files changed, 34 insertions, 0 deletions
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<CMonitor*> toArrange; + std::vector<CMonitor*> 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; + } +} |
