From 15dc024a398d35957ccfb50ddade5f456a1646b5 Mon Sep 17 00:00:00 2001 From: Alexander <51529891+Truenya@users.noreply.github.com> Date: Sat, 11 Jan 2025 19:05:53 +0300 Subject: keybinds: fix previous_per_monitor logic (#9010) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Крылов Александр --- src/helpers/Monitor.cpp | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'src/helpers/Monitor.cpp') diff --git a/src/helpers/Monitor.cpp b/src/helpers/Monitor.cpp index e833e661..cf62bc54 100644 --- a/src/helpers/Monitor.cpp +++ b/src/helpers/Monitor.cpp @@ -1,5 +1,6 @@ #include "Monitor.hpp" #include "MiscFunctions.hpp" +#include "macros.hpp" #include "math/Math.hpp" #include "sync/SyncReleaser.hpp" #include "../Compositor.hpp" @@ -1169,6 +1170,29 @@ void CMonitor::moveTo(const Vector2D& pos) { vecPosition = pos; } +SWorkspaceIDName CMonitor::getPrevWorkspaceIDName(const WORKSPACEID id) { + while (!prevWorkSpaces.empty()) { + const int PREVID = prevWorkSpaces.top(); + prevWorkSpaces.pop(); + if (PREVID == id) // skip same workspace + continue; + + // recheck if previous workspace's was moved to another monitor + const auto ws = g_pCompositor->getWorkspaceByID(PREVID); + if (ws && ws->monitorID() == ID) + return {.id = PREVID, .name = ws->m_szName}; + } + + return {.id = WORKSPACE_INVALID}; +} + +void CMonitor::addPrevWorkspaceID(const WORKSPACEID id) { + if (!prevWorkSpaces.empty() && prevWorkSpaces.top() == id) + return; + + prevWorkSpaces.emplace(id); +} + Vector2D CMonitor::middle() { return vecPosition + vecSize / 2.f; } -- cgit v1.2.3