summaryrefslogtreecommitdiff
path: root/src/helpers
diff options
context:
space:
mode:
authorvaxerski <vaxry@vaxry.net>2023-08-14 14:22:06 +0200
committervaxerski <vaxry@vaxry.net>2023-08-14 14:22:10 +0200
commit13886a264f7e076681f9c2c65367c643a973f390 (patch)
treece8d58854307298c7312341f90ca926e94e87db3 /src/helpers
parenta0cf89029263decba29b0f4216b38576f4418335 (diff)
internal: add a new monitor auto system
Diffstat (limited to 'src/helpers')
-rw-r--r--src/helpers/Monitor.cpp9
-rw-r--r--src/helpers/Monitor.hpp1
-rw-r--r--src/helpers/Vector2D.hpp8
3 files changed, 18 insertions, 0 deletions
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<CMonitor>* 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;