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/helpers/Monitor.cpp | 9 +++++++++ src/helpers/Monitor.hpp | 1 + src/helpers/Vector2D.hpp | 8 ++++++++ 3 files changed, 18 insertions(+) (limited to 'src/helpers') diff --git a/src/helpers/Monitor.cpp b/src/helpers/Monitor.cpp index a860585d..3839115a 100644 --- a/src/helpers/Monitor.cpp +++ b/src/helpers/Monitor.cpp @@ -489,6 +489,8 @@ void CMonitor::setMirror(const std::string& mirrorOf) { // remove from mvmonitors std::erase_if(g_pCompositor->m_vMonitors, [&](const auto& other) { return other.get() == this; }); + g_pCompositor->arrangeMonitors(); + g_pCompositor->setActiveMonitor(g_pCompositor->m_vMonitors.front().get()); g_pCompositor->sanityCheckWorkspaces(); @@ -622,3 +624,10 @@ void CMonitor::setSpecialWorkspace(CWorkspace* const pWorkspace) { void CMonitor::setSpecialWorkspace(const int& id) { setSpecialWorkspace(g_pCompositor->getWorkspaceByID(id)); } + +void CMonitor::moveTo(const Vector2D& pos) { + vecPosition = pos; + + if (!isMirror()) + wlr_output_layout_add(g_pCompositor->m_sWLROutputLayout, output, (int)vecPosition.x, (int)vecPosition.y); +} diff --git a/src/helpers/Monitor.hpp b/src/helpers/Monitor.hpp index e4bf6251..067caaa6 100644 --- a/src/helpers/Monitor.hpp +++ b/src/helpers/Monitor.hpp @@ -109,6 +109,7 @@ class CMonitor { void changeWorkspace(const int& id, bool internal = false); void setSpecialWorkspace(CWorkspace* const pWorkspace); void setSpecialWorkspace(const int& id); + void moveTo(const Vector2D& pos); std::shared_ptr* m_pThisWrap = nullptr; bool m_bEnabled = false; diff --git a/src/helpers/Vector2D.hpp b/src/helpers/Vector2D.hpp index d23b3fbe..a5fcc72a 100644 --- a/src/helpers/Vector2D.hpp +++ b/src/helpers/Vector2D.hpp @@ -43,6 +43,14 @@ class Vector2D { return Vector2D(this->x / a.x, this->y / a.y); } + bool operator>(const Vector2D& a) const { + return this->x > a.x && this->y > a.y; + } + + bool operator<(const Vector2D& a) const { + return this->x < a.x && this->y < a.y; + } + double distance(const Vector2D& other) const; Vector2D clamp(const Vector2D& min, const Vector2D& max = Vector2D()) const; -- cgit v1.2.3