From 6429808cfd9e95b237f5090c52f8d7c39894e9b4 Mon Sep 17 00:00:00 2001 From: Hylke Hellinga Date: Sun, 5 Oct 2025 17:41:05 +0200 Subject: [PATCH 01/15] Testing monitor positioning fix --- src/main.cpp | 131 +++++++++++++++++++++++++++++++++++++++------------ 1 file changed, 102 insertions(+), 29 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 15de13d..915beb2 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -231,47 +231,120 @@ static SDispatchResult splitMoveToWorkspaceSilent(const std::string& workspace) return {.success = result == "ok", .error = result}; } -static SDispatchResult changeMonitor(bool quiet, const std::string& value) -{ - PHLMONITOR monitor = getCurrentMonitor(); +// Helper function to check if two coordinates are "sticking" together +// (within a small tolerance of 2 pixels) +inline bool STICKS(double a, double b) { + return std::abs(a - b) < 2; +} - PHLMONITOR nextMonitor = nullptr; +// Finds the best neighboring monitor in a given geometric direction. +static PHLMONITOR getMonitorInDirection(PHLMONITOR pSourceMonitor, const char& dir) { + if (!pSourceMonitor) + return nullptr; - uint64_t monitorCount = g_pCompositor->m_monitors.size(); + const auto POSA = pSourceMonitor->m_position; + const auto SIZEA = pSourceMonitor->m_size; - int const delta = getDelta(value); - if (delta == 0) { - Debug::log(WARN, "[split-monitor-workspaces] Invalid monitor value: {}", value.c_str()); - return {.success = false, .error = "Invalid monitor value: " + value}; - } + double longestIntersect = -1; + PHLMONITOR longestIntersectMonitor = nullptr; - // The index is used instead of the monitorID because using the monitorID won't work if monitors are removed or mirrored - // as there would be gaps in the monitorID sequence - int currentMonitorIndex = -1; - for (size_t i = 0; i < g_pCompositor->m_monitors.size(); i++) { - if (g_pCompositor->m_monitors[i] == monitor) { - currentMonitorIndex = i; - break; + for (const auto& m : g_pCompositor->m_monitors) { + if (m == pSourceMonitor || m->isMirror()) + continue; + + const auto POSB = m->m_position; + const auto SIZEB = m->m_size; + double intersectLen = -1; + + // Aliases for up/down + char realDir = dir; + if (dir == 'u') realDir = 't'; + if (dir == 'd') realDir = 'b'; + + switch (realDir) { + case 'l': + if (STICKS(POSA.x, POSB.x + SIZEB.x)) { + intersectLen = std::max(0.0, std::min(POSA.y + SIZEA.y, POSB.y + SIZEB.y) - std::max(POSA.y, POSB.y)); + } + break; + case 'r': + if (STICKS(POSA.x + SIZEA.x, POSB.x)) { + intersectLen = std::max(0.0, std::min(POSA.y + SIZEA.y, POSB.y + SIZEB.y) - std::max(POSA.y, POSB.y)); + } + break; + case 't': // top + if (STICKS(POSA.y, POSB.y + SIZEB.y)) { + intersectLen = std::max(0.0, std::min(POSA.x + SIZEA.x, POSB.x + SIZEB.x) - std::max(POSA.x, POSB.x)); + } + break; + case 'b': // bottom + if (STICKS(POSA.y + SIZEA.y, POSB.y)) { + intersectLen = std::max(0.0, std::min(POSA.x + SIZEA.x, POSB.x + SIZEB.x) - std::max(POSA.x, POSB.x)); + } + break; + } + + // The best match is the one with the longest shared edge. + if (intersectLen > longestIntersect) { + longestIntersect = intersectLen; + longestIntersectMonitor = m; } } - if (currentMonitorIndex == -1) { - Debug::log(WARN, "[split-monitor-workspaces] Monitor ID {} not found in monitor list?", monitor->m_id); - return {.success = false, .error = "Monitor ID not found in monitor list: " + std::to_string(monitor->m_id)}; + + return longestIntersectMonitor; +} + +static SDispatchResult changeMonitor(bool quiet, const std::string& value) { + PHLMONITOR monitor = getCurrentMonitor(); + if (!monitor) { + Debug::log(WARN, "[split-monitor-workspaces] Could not get current monitor."); + return {.success = false, .error = "Could not get current monitor"}; + } + + PHLMONITOR nextMonitor = nullptr; + + // First, try to handle geometric directions (l, r, u, d, t, b) + if (value.length() == 1 && std::string("lrudtb").find(value[0]) != std::string::npos) { + nextMonitor = getMonitorInDirection(monitor, value[0]); } - int nextMonitorIndex = (monitorCount + currentMonitorIndex + delta) % monitorCount; + // If it's not a geometric direction or no geometric monitor was found, fall back to index-based cycling + if (!nextMonitor) { + // This part is the original logic, used as a fallback. + long int monitorCount = g_pCompositor->m_monitors.size(); + if (monitorCount <= 1) { + return {.success = true, .error = ""}; // Nothing to do + } - nextMonitor = g_pCompositor->m_monitors[nextMonitorIndex]; + int const delta = getDelta(value); + if (delta == 0 && value != "0") { // getDelta returns 0 for invalid args and for "0" + Debug::log(WARN, "[split-monitor-workspaces] Invalid monitor value: {}", value.c_str()); + return {.success = false, .error = "Invalid monitor value: " + value}; + } - int nextWorkspaceID = nextMonitor->m_activeWorkspace->m_id; + long int currentMonitorIndex = -1; + for (size_t i = 0; i < monitorCount; i++) { + if (g_pCompositor->m_monitors[i] == monitor) { + currentMonitorIndex = i; + break; + } + } + if (currentMonitorIndex == -1) { + Debug::log(WARN, "[split-monitor-workspaces] Monitor ID {} not found in monitor list?", monitor->m_id); + return {.success = false, .error = "Monitor ID not found in monitor list: " + std::to_string(monitor->m_id)}; + } - std::string result; - if (quiet) { - result = HyprlandAPI::invokeHyprctlCommand("dispatch", "movetoworkspacesilent " + std::to_string(nextWorkspaceID)); - } - else { - result = HyprlandAPI::invokeHyprctlCommand("dispatch", "movetoworkspace " + std::to_string(nextWorkspaceID)); + // Correctly calculate the next index with wrapping for both positive and negative deltas + long int nextMonitorIndex = (currentMonitorIndex + delta % monitorCount + monitorCount) % monitorCount; + + nextMonitor = g_pCompositor->m_monitors[nextMonitorIndex]; } + + // Final dispatch logic + int nextWorkspaceID = nextMonitor->m_activeWorkspace->m_id; + std::string command = quiet ? "movetoworkspacesilent " : "movetoworkspace "; + + auto const result = HyprlandAPI::invokeHyprctlCommand("dispatch", command + std::to_string(nextWorkspaceID)); return {.success = result == "ok", .error = result}; } From 2467100c2352c066f65330ad46f1c526038c156b Mon Sep 17 00:00:00 2001 From: Hylke Hellinga Date: Sun, 5 Oct 2025 18:25:37 +0200 Subject: [PATCH 02/15] Logging to check what is not working --- src/main.cpp | 41 ++++++++++++++++++++++++++++++++++++++++- 1 file changed, 40 insertions(+), 1 deletion(-) diff --git a/src/main.cpp b/src/main.cpp index 915beb2..8b7851c 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -239,11 +239,15 @@ inline bool STICKS(double a, double b) { // Finds the best neighboring monitor in a given geometric direction. static PHLMONITOR getMonitorInDirection(PHLMONITOR pSourceMonitor, const char& dir) { - if (!pSourceMonitor) + if (!pSourceMonitor) { + Debug::log(WARN, "[split-monitor-workspaces] getMonitorInDirection called with null source monitor"); return nullptr; + } + Debug::log(INFO, "[split-monitor-workspaces] getMonitorInDirection: source='{}', dir='{}'", pSourceMonitor->m_name, dir); const auto POSA = pSourceMonitor->m_position; const auto SIZEA = pSourceMonitor->m_size; + Debug::log(INFO, "[split-monitor-workspaces] Source monitor {}: pos=({}, {}), size=({}, {})", pSourceMonitor->m_name, POSA.x, POSA.y, SIZEA.x, SIZEA.y); double longestIntersect = -1; PHLMONITOR longestIntersectMonitor = nullptr; @@ -252,8 +256,10 @@ static PHLMONITOR getMonitorInDirection(PHLMONITOR pSourceMonitor, const char& d if (m == pSourceMonitor || m->isMirror()) continue; + Debug::log(INFO, "[split-monitor-workspaces] Checking monitor '{}'", m->m_name); const auto POSB = m->m_position; const auto SIZEB = m->m_size; + Debug::log(INFO, "[split-monitor-workspaces] Target monitor {}: pos=({}, {}), size=({}, {})", m->m_name, POSB.x, POSB.y, SIZEB.x, SIZEB.y); double intersectLen = -1; // Aliases for up/down @@ -265,58 +271,81 @@ static PHLMONITOR getMonitorInDirection(PHLMONITOR pSourceMonitor, const char& d case 'l': if (STICKS(POSA.x, POSB.x + SIZEB.x)) { intersectLen = std::max(0.0, std::min(POSA.y + SIZEA.y, POSB.y + SIZEB.y) - std::max(POSA.y, POSB.y)); + Debug::log(INFO, "[split-monitor-workspaces] Monitor '{}' is to the left, intersectLen={}", m->m_name, intersectLen); } break; case 'r': if (STICKS(POSA.x + SIZEA.x, POSB.x)) { intersectLen = std::max(0.0, std::min(POSA.y + SIZEA.y, POSB.y + SIZEB.y) - std::max(POSA.y, POSB.y)); + Debug::log(INFO, "[split-monitor-workspaces] Monitor '{}' is to the right, intersectLen={}", m->m_name, intersectLen); } break; case 't': // top if (STICKS(POSA.y, POSB.y + SIZEB.y)) { intersectLen = std::max(0.0, std::min(POSA.x + SIZEA.x, POSB.x + SIZEB.x) - std::max(POSA.x, POSB.x)); + Debug::log(INFO, "[split-monitor-workspaces] Monitor '{}' is to the top, intersectLen={}", m->m_name, intersectLen); } break; case 'b': // bottom if (STICKS(POSA.y + SIZEA.y, POSB.y)) { intersectLen = std::max(0.0, std::min(POSA.x + SIZEA.x, POSB.x + SIZEB.x) - std::max(POSA.x, POSB.x)); + Debug::log(INFO, "[split-monitor-workspaces] Monitor '{}' is to the bottom, intersectLen={}", m->m_name, intersectLen); } break; } // The best match is the one with the longest shared edge. if (intersectLen > longestIntersect) { + Debug::log(INFO, "[split-monitor-workspaces] New best match: '{}' ({} > {})", m->m_name, intersectLen, longestIntersect); longestIntersect = intersectLen; longestIntersectMonitor = m; } } + if (longestIntersectMonitor) { + Debug::log(INFO, "[split-monitor-workspaces] Found best match: '{}'", longestIntersectMonitor->m_name); + } else { + Debug::log(WARN, "[split-monitor-workspaces] No matching monitor found in direction '{}'", dir); + } + return longestIntersectMonitor; } static SDispatchResult changeMonitor(bool quiet, const std::string& value) { + Debug::log(INFO, "[split-monitor-workspaces] changeMonitor called with quiet={}, value='{}'", quiet, value.c_str()); PHLMONITOR monitor = getCurrentMonitor(); if (!monitor) { Debug::log(WARN, "[split-monitor-workspaces] Could not get current monitor."); return {.success = false, .error = "Could not get current monitor"}; } + Debug::log(INFO, "[split-monitor-workspaces] Current monitor: {}", monitor->m_name); PHLMONITOR nextMonitor = nullptr; // First, try to handle geometric directions (l, r, u, d, t, b) if (value.length() == 1 && std::string("lrudtb").find(value[0]) != std::string::npos) { + Debug::log(INFO, "[split-monitor-workspaces] Attempting geometric monitor search with direction '{}'", value[0]); nextMonitor = getMonitorInDirection(monitor, value[0]); + if (nextMonitor) { + Debug::log(INFO, "[split-monitor-workspaces] Found geometric monitor: {}", nextMonitor->m_name); + } else { + Debug::log(WARN, "[split-monitor-workspaces] No geometric monitor found, falling back to index-based cycling."); + } } // If it's not a geometric direction or no geometric monitor was found, fall back to index-based cycling if (!nextMonitor) { + Debug::log(INFO, "[split-monitor-workspaces] Using index-based monitor cycling."); // This part is the original logic, used as a fallback. long int monitorCount = g_pCompositor->m_monitors.size(); + Debug::log(INFO, "[split-monitor-workspaces] Total monitors: {}", monitorCount); if (monitorCount <= 1) { + Debug::log(INFO, "[split-monitor-workspaces] Not enough monitors to cycle."); return {.success = true, .error = ""}; // Nothing to do } int const delta = getDelta(value); + Debug::log(INFO, "[split-monitor-workspaces] Cycling with delta: {}", delta); if (delta == 0 && value != "0") { // getDelta returns 0 for invalid args and for "0" Debug::log(WARN, "[split-monitor-workspaces] Invalid monitor value: {}", value.c_str()); return {.success = false, .error = "Invalid monitor value: " + value}; @@ -333,16 +362,26 @@ static SDispatchResult changeMonitor(bool quiet, const std::string& value) { Debug::log(WARN, "[split-monitor-workspaces] Monitor ID {} not found in monitor list?", monitor->m_id); return {.success = false, .error = "Monitor ID not found in monitor list: " + std::to_string(monitor->m_id)}; } + Debug::log(INFO, "[split-monitor-workspaces] Current monitor index: {}", currentMonitorIndex); // Correctly calculate the next index with wrapping for both positive and negative deltas long int nextMonitorIndex = (currentMonitorIndex + delta % monitorCount + monitorCount) % monitorCount; + Debug::log(INFO, "[split-monitor-workspaces] Next monitor index: {}", nextMonitorIndex); nextMonitor = g_pCompositor->m_monitors[nextMonitorIndex]; + Debug::log(INFO, "[split-monitor-workspaces] Next monitor is: {}", nextMonitor->m_name); + } + + if (!nextMonitor) { + Debug::log(ERR, "[split-monitor-workspaces] Failed to determine next monitor."); + return {.success = false, .error = "Failed to determine next monitor."}; } // Final dispatch logic int nextWorkspaceID = nextMonitor->m_activeWorkspace->m_id; std::string command = quiet ? "movetoworkspacesilent " : "movetoworkspace "; + Debug::log(INFO, "[split-monitor-workspaces] Next workspace ID: {}", nextWorkspaceID); + Debug::log(INFO, "[split-monitor-workspaces] Dispatching command: '{}'", command + std::to_string(nextWorkspaceID)); auto const result = HyprlandAPI::invokeHyprctlCommand("dispatch", command + std::to_string(nextWorkspaceID)); return {.success = result == "ok", .error = result}; From b27707bcac95754368171dfc268a595f17c67166 Mon Sep 17 00:00:00 2001 From: Hylke Hellinga Date: Sun, 5 Oct 2025 19:11:09 +0200 Subject: [PATCH 03/15] pin version --- hyprpm.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/hyprpm.toml b/hyprpm.toml index a116670..167f0b3 100644 --- a/hyprpm.toml +++ b/hyprpm.toml @@ -29,6 +29,7 @@ commit_pins = [ ["4e242d086e20b32951fdc0ebcbfb4d41b5be8dcc", "8f0c875a5ba9864b1267e74e6f03533d18c2bca0"], # 0.50.1 ["46174f78b374b6cea669c48880877a8bdcf7802f", "6af9cdf7d739e667c638b1ac10fec0ba7ba6b86c"], # 0.51.0 ["71a1216abcc7031776630a6d88f105605c4dc1c9", "6af9cdf7d739e667c638b1ac10fec0ba7ba6b86c"] # 0.51.1 + ["71a1216abcc7031776630a6d88f105605c4dc1c9", "2467100c2352c066f65330ad46f1c526038c156b"] # 0.51.2 ] [split-monitor-workspaces] From b78ccb06107962e1d48b3ec14323f316eff247ca Mon Sep 17 00:00:00 2001 From: Hylke Hellinga Date: Sun, 5 Oct 2025 19:15:11 +0200 Subject: [PATCH 04/15] small mistake --- hyprpm.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hyprpm.toml b/hyprpm.toml index 167f0b3..6ecee12 100644 --- a/hyprpm.toml +++ b/hyprpm.toml @@ -28,7 +28,7 @@ commit_pins = [ ["c4a4c341568944bd4fb9cd503558b2de602c0213", "8f0c875a5ba9864b1267e74e6f03533d18c2bca0"], # 0.50.0 ["4e242d086e20b32951fdc0ebcbfb4d41b5be8dcc", "8f0c875a5ba9864b1267e74e6f03533d18c2bca0"], # 0.50.1 ["46174f78b374b6cea669c48880877a8bdcf7802f", "6af9cdf7d739e667c638b1ac10fec0ba7ba6b86c"], # 0.51.0 - ["71a1216abcc7031776630a6d88f105605c4dc1c9", "6af9cdf7d739e667c638b1ac10fec0ba7ba6b86c"] # 0.51.1 + ["71a1216abcc7031776630a6d88f105605c4dc1c9", "6af9cdf7d739e667c638b1ac10fec0ba7ba6b86c"], # 0.51.1 ["71a1216abcc7031776630a6d88f105605c4dc1c9", "2467100c2352c066f65330ad46f1c526038c156b"] # 0.51.2 ] From b0ec75de562fdd8ff180466658109b68dc247fbc Mon Sep 17 00:00:00 2001 From: Hylke Hellinga Date: Sun, 5 Oct 2025 19:16:03 +0200 Subject: [PATCH 05/15] pinned wrong commit --- hyprpm.toml | 1 - 1 file changed, 1 deletion(-) diff --git a/hyprpm.toml b/hyprpm.toml index 6ecee12..55acebb 100644 --- a/hyprpm.toml +++ b/hyprpm.toml @@ -28,7 +28,6 @@ commit_pins = [ ["c4a4c341568944bd4fb9cd503558b2de602c0213", "8f0c875a5ba9864b1267e74e6f03533d18c2bca0"], # 0.50.0 ["4e242d086e20b32951fdc0ebcbfb4d41b5be8dcc", "8f0c875a5ba9864b1267e74e6f03533d18c2bca0"], # 0.50.1 ["46174f78b374b6cea669c48880877a8bdcf7802f", "6af9cdf7d739e667c638b1ac10fec0ba7ba6b86c"], # 0.51.0 - ["71a1216abcc7031776630a6d88f105605c4dc1c9", "6af9cdf7d739e667c638b1ac10fec0ba7ba6b86c"], # 0.51.1 ["71a1216abcc7031776630a6d88f105605c4dc1c9", "2467100c2352c066f65330ad46f1c526038c156b"] # 0.51.2 ] From d2b3fe093b2ba6848643a613d759312d24d566ed Mon Sep 17 00:00:00 2001 From: Hylke Hellinga Date: Sun, 5 Oct 2025 19:25:01 +0200 Subject: [PATCH 06/15] Build error fixed --- src/main.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 8b7851c..fee6bf2 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -231,9 +231,9 @@ static SDispatchResult splitMoveToWorkspaceSilent(const std::string& workspace) return {.success = result == "ok", .error = result}; } -// Helper function to check if two coordinates are "sticking" together +// Helper function to check if two coordinates are "close" to each other // (within a small tolerance of 2 pixels) -inline bool STICKS(double a, double b) { +inline bool areCoordinatesClose(double a, double b) { return std::abs(a - b) < 2; } @@ -269,25 +269,25 @@ static PHLMONITOR getMonitorInDirection(PHLMONITOR pSourceMonitor, const char& d switch (realDir) { case 'l': - if (STICKS(POSA.x, POSB.x + SIZEB.x)) { + if (areCoordinatesClose(POSA.x, POSB.x + SIZEB.x)) { intersectLen = std::max(0.0, std::min(POSA.y + SIZEA.y, POSB.y + SIZEB.y) - std::max(POSA.y, POSB.y)); Debug::log(INFO, "[split-monitor-workspaces] Monitor '{}' is to the left, intersectLen={}", m->m_name, intersectLen); } break; case 'r': - if (STICKS(POSA.x + SIZEA.x, POSB.x)) { + if (areCoordinatesClose(POSA.x + SIZEA.x, POSB.x)) { intersectLen = std::max(0.0, std::min(POSA.y + SIZEA.y, POSB.y + SIZEB.y) - std::max(POSA.y, POSB.y)); Debug::log(INFO, "[split-monitor-workspaces] Monitor '{}' is to the right, intersectLen={}", m->m_name, intersectLen); } break; case 't': // top - if (STICKS(POSA.y, POSB.y + SIZEB.y)) { + if (areCoordinatesClose(POSA.y, POSB.y + SIZEB.y)) { intersectLen = std::max(0.0, std::min(POSA.x + SIZEA.x, POSB.x + SIZEB.x) - std::max(POSA.x, POSB.x)); Debug::log(INFO, "[split-monitor-workspaces] Monitor '{}' is to the top, intersectLen={}", m->m_name, intersectLen); } break; case 'b': // bottom - if (STICKS(POSA.y + SIZEA.y, POSB.y)) { + if (areCoordinatesClose(POSA.y + SIZEA.y, POSB.y)) { intersectLen = std::max(0.0, std::min(POSA.x + SIZEA.x, POSB.x + SIZEB.x) - std::max(POSA.x, POSB.x)); Debug::log(INFO, "[split-monitor-workspaces] Monitor '{}' is to the bottom, intersectLen={}", m->m_name, intersectLen); } From d8d6ce98a5887f9bcb6b7d4728542fa986a9858e Mon Sep 17 00:00:00 2001 From: Hylke Hellinga Date: Sun, 5 Oct 2025 19:26:14 +0200 Subject: [PATCH 07/15] changed toml pin --- hyprpm.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hyprpm.toml b/hyprpm.toml index 55acebb..9acc338 100644 --- a/hyprpm.toml +++ b/hyprpm.toml @@ -28,7 +28,7 @@ commit_pins = [ ["c4a4c341568944bd4fb9cd503558b2de602c0213", "8f0c875a5ba9864b1267e74e6f03533d18c2bca0"], # 0.50.0 ["4e242d086e20b32951fdc0ebcbfb4d41b5be8dcc", "8f0c875a5ba9864b1267e74e6f03533d18c2bca0"], # 0.50.1 ["46174f78b374b6cea669c48880877a8bdcf7802f", "6af9cdf7d739e667c638b1ac10fec0ba7ba6b86c"], # 0.51.0 - ["71a1216abcc7031776630a6d88f105605c4dc1c9", "2467100c2352c066f65330ad46f1c526038c156b"] # 0.51.2 + ["71a1216abcc7031776630a6d88f105605c4dc1c9", "d2b3fe093b2ba6848643a613d759312d24d566ed"] # 0.51.2 ] [split-monitor-workspaces] From 61834e973fdf121a8b985373fb60c0b968238d13 Mon Sep 17 00:00:00 2001 From: Hylke Hellinga Date: Sun, 5 Oct 2025 19:52:58 +0200 Subject: [PATCH 08/15] Let's try something --- src/main.cpp | 210 +++++++++++++++++++-------------------------------- src/util.hpp | 11 +++ 2 files changed, 90 insertions(+), 131 deletions(-) create mode 100644 src/util.hpp diff --git a/src/main.cpp b/src/main.cpp index fee6bf2..4181e90 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -8,6 +8,7 @@ #include #include "globals.hpp" +#include "util.hpp" #include #include @@ -30,7 +31,7 @@ static bool g_enableWrapping = true; // the first time we load the plugin, we want to switch to the first workspace on the first monitor regardless of keepFocused static bool g_firstLoad = true; -static std::map> g_vMonitorWorkspaceMap; +static std::map> g_vMonitorWorkspaceMap; static std::vector g_vPersistentWorkspaces; static SP e_monitorAddedHandle = nullptr; @@ -80,14 +81,14 @@ static const std::string& getWorkspaceFromMonitor(const PHLMONITOR& monitor, con // #3 - "1", "2", "3" -> absolute workspace ID, e.g. workspace 1, 2 or 3 on the current monitor // if these formats fail to be parsed form the workspace string, we assume the user wants to switch to a workspace by name and simply pass that to hyprland - auto const curWorkspacesIt = g_vMonitorWorkspaceMap.find(monitor->m_id); + auto const curWorkspacesIt = g_vMonitorWorkspaceMap.find(getMonitorIdentifier(monitor)); if (curWorkspacesIt == g_vMonitorWorkspaceMap.end()) { - Debug::log(WARN, "[split-monitor-workspaces] Monitor ID {} not found in workspace map", monitor->m_id); + Debug::log(WARN, "[split-monitor-workspaces] Monitor ID {} not found in workspace map", getMonitorIdentifier(monitor).c_str()); return workspace; // use the original string if the monitor is not mapped } const std::vector& curWorkspaces = curWorkspacesIt->second; if (curWorkspaces.empty()) { - Debug::log(WARN, "[split-monitor-workspaces] No workspaces mapped to monitor ID {}", monitor->m_id); + Debug::log(WARN, "[split-monitor-workspaces] No workspaces mapped to monitor ID {}", getMonitorIdentifier(monitor).c_str()); return workspace; // use the original string if no workspaces are mapped } @@ -176,7 +177,7 @@ static SDispatchResult cycleWorkspaces(const std::string& value, bool nowrap = f return {.success = false, .error = "Invalid cycle value: " + value}; } PHLMONITOR const monitor = getCurrentMonitor(); - auto const workspaces = g_vMonitorWorkspaceMap[monitor->m_id]; + auto const workspaces = g_vMonitorWorkspaceMap[getMonitorIdentifier(monitor)]; int index = -1; for (int i = 0; i < g_workspaceCount; i++) { if (workspaces[i] == monitor->m_activeWorkspace->m_name) { @@ -231,84 +232,34 @@ static SDispatchResult splitMoveToWorkspaceSilent(const std::string& workspace) return {.success = result == "ok", .error = result}; } -// Helper function to check if two coordinates are "close" to each other -// (within a small tolerance of 2 pixels) -inline bool areCoordinatesClose(double a, double b) { - return std::abs(a - b) < 2; -} -// Finds the best neighboring monitor in a given geometric direction. -static PHLMONITOR getMonitorInDirection(PHLMONITOR pSourceMonitor, const char& dir) { + +static PHLMONITOR getMonitorInDirectionX(PHLMONITOR pSourceMonitor, int delta) { if (!pSourceMonitor) { - Debug::log(WARN, "[split-monitor-workspaces] getMonitorInDirection called with null source monitor"); + Debug::log(WARN, "[split-monitor-workspaces] getMonitorInDirectionX called with null source monitor"); return nullptr; } - Debug::log(INFO, "[split-monitor-workspaces] getMonitorInDirection: source='{}', dir='{}'", pSourceMonitor->m_name, dir); - - const auto POSA = pSourceMonitor->m_position; - const auto SIZEA = pSourceMonitor->m_size; - Debug::log(INFO, "[split-monitor-workspaces] Source monitor {}: pos=({}, {}), size=({}, {})", pSourceMonitor->m_name, POSA.x, POSA.y, SIZEA.x, SIZEA.y); - - double longestIntersect = -1; - PHLMONITOR longestIntersectMonitor = nullptr; + std::vector monitors; for (const auto& m : g_pCompositor->m_monitors) { - if (m == pSourceMonitor || m->isMirror()) - continue; - - Debug::log(INFO, "[split-monitor-workspaces] Checking monitor '{}'", m->m_name); - const auto POSB = m->m_position; - const auto SIZEB = m->m_size; - Debug::log(INFO, "[split-monitor-workspaces] Target monitor {}: pos=({}, {}), size=({}, {})", m->m_name, POSB.x, POSB.y, SIZEB.x, SIZEB.y); - double intersectLen = -1; - - // Aliases for up/down - char realDir = dir; - if (dir == 'u') realDir = 't'; - if (dir == 'd') realDir = 'b'; - - switch (realDir) { - case 'l': - if (areCoordinatesClose(POSA.x, POSB.x + SIZEB.x)) { - intersectLen = std::max(0.0, std::min(POSA.y + SIZEA.y, POSB.y + SIZEB.y) - std::max(POSA.y, POSB.y)); - Debug::log(INFO, "[split-monitor-workspaces] Monitor '{}' is to the left, intersectLen={}", m->m_name, intersectLen); - } - break; - case 'r': - if (areCoordinatesClose(POSA.x + SIZEA.x, POSB.x)) { - intersectLen = std::max(0.0, std::min(POSA.y + SIZEA.y, POSB.y + SIZEB.y) - std::max(POSA.y, POSB.y)); - Debug::log(INFO, "[split-monitor-workspaces] Monitor '{}' is to the right, intersectLen={}", m->m_name, intersectLen); - } - break; - case 't': // top - if (areCoordinatesClose(POSA.y, POSB.y + SIZEB.y)) { - intersectLen = std::max(0.0, std::min(POSA.x + SIZEA.x, POSB.x + SIZEB.x) - std::max(POSA.x, POSB.x)); - Debug::log(INFO, "[split-monitor-workspaces] Monitor '{}' is to the top, intersectLen={}", m->m_name, intersectLen); - } - break; - case 'b': // bottom - if (areCoordinatesClose(POSA.y + SIZEA.y, POSB.y)) { - intersectLen = std::max(0.0, std::min(POSA.x + SIZEA.x, POSB.x + SIZEB.x) - std::max(POSA.x, POSB.x)); - Debug::log(INFO, "[split-monitor-workspaces] Monitor '{}' is to the bottom, intersectLen={}", m->m_name, intersectLen); - } - break; - } - - // The best match is the one with the longest shared edge. - if (intersectLen > longestIntersect) { - Debug::log(INFO, "[split-monitor-workspaces] New best match: '{}' ({} > {})", m->m_name, intersectLen, longestIntersect); - longestIntersect = intersectLen; - longestIntersectMonitor = m; + if (!m->isMirror()) { + monitors.push_back(m); } } - if (longestIntersectMonitor) { - Debug::log(INFO, "[split-monitor-workspaces] Found best match: '{}'", longestIntersectMonitor->m_name); - } else { - Debug::log(WARN, "[split-monitor-workspaces] No matching monitor found in direction '{}'", dir); + std::sort(monitors.begin(), monitors.end(), [](const PHLMONITOR& a, const PHLMONITOR& b) { + return a->m_position.x < b->m_position.x; + }); + + auto it = std::find(monitors.begin(), monitors.end(), pSourceMonitor); + if (it == monitors.end()) { + return nullptr; } - return longestIntersectMonitor; + long int currentIndex = std::distance(monitors.begin(), it); + long int nextIndex = (currentIndex + delta + monitors.size()) % monitors.size(); + + return monitors[nextIndex]; } static SDispatchResult changeMonitor(bool quiet, const std::string& value) { @@ -321,55 +272,24 @@ static SDispatchResult changeMonitor(bool quiet, const std::string& value) { Debug::log(INFO, "[split-monitor-workspaces] Current monitor: {}", monitor->m_name); PHLMONITOR nextMonitor = nullptr; - - // First, try to handle geometric directions (l, r, u, d, t, b) - if (value.length() == 1 && std::string("lrudtb").find(value[0]) != std::string::npos) { - Debug::log(INFO, "[split-monitor-workspaces] Attempting geometric monitor search with direction '{}'", value[0]); - nextMonitor = getMonitorInDirection(monitor, value[0]); - if (nextMonitor) { - Debug::log(INFO, "[split-monitor-workspaces] Found geometric monitor: {}", nextMonitor->m_name); - } else { - Debug::log(WARN, "[split-monitor-workspaces] No geometric monitor found, falling back to index-based cycling."); - } + if (value == "next" || value == "prev" || value.starts_with('+') || value.starts_with('-')) { + int delta = getDelta(value); + nextMonitor = getMonitorInDirectionX(monitor, delta); } - - // If it's not a geometric direction or no geometric monitor was found, fall back to index-based cycling - if (!nextMonitor) { - Debug::log(INFO, "[split-monitor-workspaces] Using index-based monitor cycling."); - // This part is the original logic, used as a fallback. - long int monitorCount = g_pCompositor->m_monitors.size(); - Debug::log(INFO, "[split-monitor-workspaces] Total monitors: {}", monitorCount); - if (monitorCount <= 1) { - Debug::log(INFO, "[split-monitor-workspaces] Not enough monitors to cycle."); - return {.success = true, .error = ""}; // Nothing to do - } - - int const delta = getDelta(value); - Debug::log(INFO, "[split-monitor-workspaces] Cycling with delta: {}", delta); - if (delta == 0 && value != "0") { // getDelta returns 0 for invalid args and for "0" - Debug::log(WARN, "[split-monitor-workspaces] Invalid monitor value: {}", value.c_str()); - return {.success = false, .error = "Invalid monitor value: " + value}; - } - - long int currentMonitorIndex = -1; - for (size_t i = 0; i < monitorCount; i++) { - if (g_pCompositor->m_monitors[i] == monitor) { - currentMonitorIndex = i; - break; - } + else { + try { + int monitorId = std::stoi(value); + for (const auto& m : g_pCompositor->m_monitors) { + if (m->m_id == monitorId) { + nextMonitor = m; + break; + } + } } - if (currentMonitorIndex == -1) { - Debug::log(WARN, "[split-monitor-workspaces] Monitor ID {} not found in monitor list?", monitor->m_id); - return {.success = false, .error = "Monitor ID not found in monitor list: " + std::to_string(monitor->m_id)}; + catch (const std::invalid_argument&) { + Debug::log(WARN, "[split-monitor-workspaces] Invalid monitor value: {}", value.c_str()); + return {.success = false, .error = "Invalid monitor value: " + value}; } - Debug::log(INFO, "[split-monitor-workspaces] Current monitor index: {}", currentMonitorIndex); - - // Correctly calculate the next index with wrapping for both positive and negative deltas - long int nextMonitorIndex = (currentMonitorIndex + delta % monitorCount + monitorCount) % monitorCount; - Debug::log(INFO, "[split-monitor-workspaces] Next monitor index: {}", nextMonitorIndex); - - nextMonitor = g_pCompositor->m_monitors[nextMonitorIndex]; - Debug::log(INFO, "[split-monitor-workspaces] Next monitor is: {}", nextMonitor->m_name); } if (!nextMonitor) { @@ -418,7 +338,11 @@ static SDispatchResult grabRogueWindows(const std::string& /*unused*/) continue; auto const workspaceName = window->m_workspace->m_name; - auto const monitorID = window->m_monitor->m_id; + PHLMONITOR monitor = window->m_monitor.lock(); + if (!monitor) { + continue; + } + auto const monitorID = getMonitorIdentifier(monitor); bool isInRogueWorkspace = !g_vMonitorWorkspaceMap.contains(monitorID) || // if the monitor is not mapped, the window is rogue !std::ranges::any_of(g_vMonitorWorkspaceMap[monitorID], [&workspaceName](const auto& mappedWorkspaceName) { return workspaceName == mappedWorkspaceName; }); @@ -442,14 +366,32 @@ static void mapMonitor(const PHLMONITOR& monitor) // NOLINT(readability-convert- return; } - int workspaceIndex = (monitor->m_id * g_workspaceCount) + 1; + std::vector monitors; + for (const auto& m : g_pCompositor->m_monitors) { + if (!m->isMirror()) { + monitors.push_back(m); + } + } + + std::sort(monitors.begin(), monitors.end(), [](const PHLMONITOR& a, const PHLMONITOR& b) { + return a->m_position.x < b->m_position.x; + }); + + auto it = std::find(monitors.begin(), monitors.end(), monitor); + if (it == monitors.end()) { + Debug::log(ERR, "[split-monitor-workspaces] Could not find monitor in sorted monitor list. This should not happen."); + return; + } + + long int monitorIndex = std::distance(monitors.begin(), it); + int workspaceIndex = (monitorIndex * g_workspaceCount) + 1; Debug::log(INFO, "{}", "[split-monitor-workspaces] Mapping workspaces " + std::to_string(workspaceIndex) + "-" + std::to_string(workspaceIndex + g_workspaceCount - 1) + " to monitor " + monitor->m_name); for (int i = workspaceIndex; i < workspaceIndex + g_workspaceCount; i++) { std::string workspaceName = std::to_string(i); - g_vMonitorWorkspaceMap[monitor->m_id].push_back(workspaceName); + g_vMonitorWorkspaceMap[getMonitorIdentifier(monitor)].push_back(workspaceName); PHLWORKSPACE workspace = g_pCompositor->getWorkspaceByName(workspaceName); // when not using persistent workspaces, we still want to create the first workspace on each monitor @@ -475,15 +417,14 @@ static void mapMonitor(const PHLMONITOR& monitor) // NOLINT(readability-convert- } } + static void unmapMonitor(const PHLMONITOR& monitor) { - int workspaceIndex = (monitor->m_id * g_workspaceCount) + 1; + Debug::log(INFO, "[split-monitor-workspaces] Unmapping workspaces from monitor {}", monitor->m_name); - Debug::log(INFO, "{}", - "[split-monitor-workspaces] Unmapping workspaces " + std::to_string(workspaceIndex) + "-" + std::to_string(workspaceIndex + g_workspaceCount - 1) + " from monitor " + monitor->m_name); - - if (g_vMonitorWorkspaceMap.contains(monitor->m_id)) { - for (const auto& workspaceName : g_vMonitorWorkspaceMap[monitor->m_id]) { + auto monitorIdentifier = getMonitorIdentifier(monitor); + if (g_vMonitorWorkspaceMap.contains(monitorIdentifier)) { + for (const auto& workspaceName : g_vMonitorWorkspaceMap[monitorIdentifier]) { PHLWORKSPACE workspace = g_pCompositor->getWorkspaceByName(workspaceName); if (workspace.get() != nullptr) { @@ -492,20 +433,27 @@ static void unmapMonitor(const PHLMONITOR& monitor) std::erase(g_vPersistentWorkspaces, workspace); } } - g_vMonitorWorkspaceMap.erase(monitor->m_id); + g_vMonitorWorkspaceMap.erase(monitorIdentifier); } } static void unmapAllMonitors() { while (!g_vMonitorWorkspaceMap.empty()) { - auto [monitorID, workspaces] = *g_vMonitorWorkspaceMap.begin(); - PHLMONITOR monitor = g_pCompositor->getMonitorFromID(monitorID); + auto [monitorIdentifier, workspaces] = *g_vMonitorWorkspaceMap.begin(); + PHLMONITOR monitor = nullptr; + for (const auto& m : g_pCompositor->m_monitors) { + if (getMonitorIdentifier(m) == monitorIdentifier) { + monitor = m; + break; + } + } + if (monitor != nullptr) { unmapMonitor(monitor); // will remove the monitor from the map } else { - g_vMonitorWorkspaceMap.erase(monitorID); // remove it manually + g_vMonitorWorkspaceMap.erase(monitorIdentifier); // remove it manually } } g_vMonitorWorkspaceMap.clear(); diff --git a/src/util.hpp b/src/util.hpp new file mode 100644 index 0000000..92d2489 --- /dev/null +++ b/src/util.hpp @@ -0,0 +1,11 @@ + +#pragma once + +#include +#include + +static std::string getMonitorIdentifier(const PHLMONITOR& monitor) { + // this is a bit of a hack, but it's the best we can do to get a unique identifier for a monitor + // that is stable across reloads and monitor disconnections + return std::string(monitor->m_name) + "@" + std::to_string(monitor->m_pixelSize.x) + "x" + std::to_string(monitor->m_pixelSize.y); +} From cb818d3967d1ae1cd3b1933664584d5cbbfd114d Mon Sep 17 00:00:00 2001 From: Hylke Hellinga Date: Sun, 5 Oct 2025 19:54:32 +0200 Subject: [PATCH 09/15] change pinned commit --- hyprpm.toml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/hyprpm.toml b/hyprpm.toml index 9acc338..be61cf3 100644 --- a/hyprpm.toml +++ b/hyprpm.toml @@ -28,7 +28,8 @@ commit_pins = [ ["c4a4c341568944bd4fb9cd503558b2de602c0213", "8f0c875a5ba9864b1267e74e6f03533d18c2bca0"], # 0.50.0 ["4e242d086e20b32951fdc0ebcbfb4d41b5be8dcc", "8f0c875a5ba9864b1267e74e6f03533d18c2bca0"], # 0.50.1 ["46174f78b374b6cea669c48880877a8bdcf7802f", "6af9cdf7d739e667c638b1ac10fec0ba7ba6b86c"], # 0.51.0 - ["71a1216abcc7031776630a6d88f105605c4dc1c9", "d2b3fe093b2ba6848643a613d759312d24d566ed"] # 0.51.2 + ["71a1216abcc7031776630a6d88f105605c4dc1c9", "d2b3fe093b2ba6848643a613d759312d24d566ed"], # 0.51.2 + ["71a1216abcc7031776630a6d88f105605c4dc1c9", "61834e973fdf121a8b985373fb60c0b968238d13"] # 0.51.2 ] [split-monitor-workspaces] From 5d9d8319410138bb9bba1c26bf9b79ce849b728f Mon Sep 17 00:00:00 2001 From: Hylke Hellinga Date: Sun, 5 Oct 2025 19:57:10 +0200 Subject: [PATCH 10/15] previous pin --- hyprpm.toml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/hyprpm.toml b/hyprpm.toml index be61cf3..e9b14c9 100644 --- a/hyprpm.toml +++ b/hyprpm.toml @@ -28,8 +28,7 @@ commit_pins = [ ["c4a4c341568944bd4fb9cd503558b2de602c0213", "8f0c875a5ba9864b1267e74e6f03533d18c2bca0"], # 0.50.0 ["4e242d086e20b32951fdc0ebcbfb4d41b5be8dcc", "8f0c875a5ba9864b1267e74e6f03533d18c2bca0"], # 0.50.1 ["46174f78b374b6cea669c48880877a8bdcf7802f", "6af9cdf7d739e667c638b1ac10fec0ba7ba6b86c"], # 0.51.0 - ["71a1216abcc7031776630a6d88f105605c4dc1c9", "d2b3fe093b2ba6848643a613d759312d24d566ed"], # 0.51.2 - ["71a1216abcc7031776630a6d88f105605c4dc1c9", "61834e973fdf121a8b985373fb60c0b968238d13"] # 0.51.2 + ["71a1216abcc7031776630a6d88f105605c4dc1c9", "61834e973fdf121a8b985373fb60c0b968238d13"] # 0.51.1 ] [split-monitor-workspaces] From 6c3fa874702f10d9ea4b8717261df501f1e649ab Mon Sep 17 00:00:00 2001 From: Hylke Hellinga Date: Sun, 5 Oct 2025 20:03:31 +0200 Subject: [PATCH 11/15] testing workspace changemonitor --- src/main.cpp | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 4181e90..43d4ba8 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -297,13 +297,29 @@ static SDispatchResult changeMonitor(bool quiet, const std::string& value) { return {.success = false, .error = "Failed to determine next monitor."}; } + // find the current workspace index in the monitor's workspace list + auto const workspaces = g_vMonitorWorkspaceMap[getMonitorIdentifier(monitor)]; + auto it = std::ranges::find(workspaces, monitor->m_activeWorkspace->m_name); + if (it == workspaces.end()) { + Debug::log(ERR, "[split-monitor-workspaces] Current workspace {} not found in monitor workspaces", monitor->m_activeWorkspace->m_name.c_str()); + return {.success = false, .error = "Could not find active workspace in monitor workspaces"}; + } + long int workspaceIndex = std::distance(workspaces.begin(), it); + + // get the corresponding workspace on the next monitor + auto const nextWorkspaces = g_vMonitorWorkspaceMap[getMonitorIdentifier(nextMonitor)]; + if ((size_t)workspaceIndex >= nextWorkspaces.size()) { + Debug::log(ERR, "[split-monitor-workspaces] Workspace index {} is out of bounds for the next monitor's workspaces", workspaceIndex); + return {.success = false, .error = "Workspace index is out of bounds for the next monitor's workspaces"}; + } + const std::string& nextWorkspaceName = nextWorkspaces[workspaceIndex]; + // Final dispatch logic - int nextWorkspaceID = nextMonitor->m_activeWorkspace->m_id; std::string command = quiet ? "movetoworkspacesilent " : "movetoworkspace "; - Debug::log(INFO, "[split-monitor-workspaces] Next workspace ID: {}", nextWorkspaceID); - Debug::log(INFO, "[split-monitor-workspaces] Dispatching command: '{}'", command + std::to_string(nextWorkspaceID)); + Debug::log(INFO, "[split-monitor-workspaces] Next workspace name: {}", nextWorkspaceName); + Debug::log(INFO, "[split-monitor-workspaces] Dispatching command: '{}'", command + nextWorkspaceName); - auto const result = HyprlandAPI::invokeHyprctlCommand("dispatch", command + std::to_string(nextWorkspaceID)); + auto const result = HyprlandAPI::invokeHyprctlCommand("dispatch", command + nextWorkspaceName); return {.success = result == "ok", .error = result}; } From a96ba1b5ee655ec9d004cf46b7d3c76781dd17cb Mon Sep 17 00:00:00 2001 From: Hylke Hellinga Date: Sun, 5 Oct 2025 20:05:12 +0200 Subject: [PATCH 12/15] change pin --- hyprpm.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hyprpm.toml b/hyprpm.toml index e9b14c9..5dcfa9c 100644 --- a/hyprpm.toml +++ b/hyprpm.toml @@ -28,7 +28,7 @@ commit_pins = [ ["c4a4c341568944bd4fb9cd503558b2de602c0213", "8f0c875a5ba9864b1267e74e6f03533d18c2bca0"], # 0.50.0 ["4e242d086e20b32951fdc0ebcbfb4d41b5be8dcc", "8f0c875a5ba9864b1267e74e6f03533d18c2bca0"], # 0.50.1 ["46174f78b374b6cea669c48880877a8bdcf7802f", "6af9cdf7d739e667c638b1ac10fec0ba7ba6b86c"], # 0.51.0 - ["71a1216abcc7031776630a6d88f105605c4dc1c9", "61834e973fdf121a8b985373fb60c0b968238d13"] # 0.51.1 + ["71a1216abcc7031776630a6d88f105605c4dc1c9", "6c3fa874702f10d9ea4b8717261df501f1e649ab"] # 0.51.1 ] [split-monitor-workspaces] From 7598f95c9983afc910eb4ab27dddbc06f13c6a4b Mon Sep 17 00:00:00 2001 From: Hylke Hellinga Date: Sun, 5 Oct 2025 20:11:33 +0200 Subject: [PATCH 13/15] Fix swapping maybe? --- src/main.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/main.cpp b/src/main.cpp index 43d4ba8..474ffb0 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -319,7 +319,13 @@ static SDispatchResult changeMonitor(bool quiet, const std::string& value) { Debug::log(INFO, "[split-monitor-workspaces] Next workspace name: {}", nextWorkspaceName); Debug::log(INFO, "[split-monitor-workspaces] Dispatching command: '{}'", command + nextWorkspaceName); - auto const result = HyprlandAPI::invokeHyprctlCommand("dispatch", command + nextWorkspaceName); + auto const result = HyprlandAPI::invokeHyprctlCommand("dispatch", "workspace " + nextWorkspaceName); + if (result != "ok") { + return {.success = false, .error = result}; + } + + auto const result2 = HyprlandAPI::invokeHyprctlCommand("dispatch", command + nextWorkspaceName); + return {.success = result2 == "ok", .error = result2}; return {.success = result == "ok", .error = result}; } From 11f5cff3144563dc93800909b210454164417990 Mon Sep 17 00:00:00 2001 From: Hylke Hellinga Date: Sun, 5 Oct 2025 20:12:25 +0200 Subject: [PATCH 14/15] Fix swapping? --- hyprpm.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hyprpm.toml b/hyprpm.toml index 5dcfa9c..d7fd28c 100644 --- a/hyprpm.toml +++ b/hyprpm.toml @@ -28,7 +28,7 @@ commit_pins = [ ["c4a4c341568944bd4fb9cd503558b2de602c0213", "8f0c875a5ba9864b1267e74e6f03533d18c2bca0"], # 0.50.0 ["4e242d086e20b32951fdc0ebcbfb4d41b5be8dcc", "8f0c875a5ba9864b1267e74e6f03533d18c2bca0"], # 0.50.1 ["46174f78b374b6cea669c48880877a8bdcf7802f", "6af9cdf7d739e667c638b1ac10fec0ba7ba6b86c"], # 0.51.0 - ["71a1216abcc7031776630a6d88f105605c4dc1c9", "6c3fa874702f10d9ea4b8717261df501f1e649ab"] # 0.51.1 + ["71a1216abcc7031776630a6d88f105605c4dc1c9", "7598f95c9983afc910eb4ab27dddbc06f13c6a4b"] # 0.51.1 ] [split-monitor-workspaces] From 873f6f3e0a1582d6f936c2ba87ca7147748a2399 Mon Sep 17 00:00:00 2001 From: Hylke Hellinga Date: Sun, 5 Oct 2025 20:26:10 +0200 Subject: [PATCH 15/15] Revert 'Fix swapping' changes --- hyprpm.toml | 2 +- src/main.cpp | 8 +------- 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/hyprpm.toml b/hyprpm.toml index d7fd28c..f8b9c7d 100644 --- a/hyprpm.toml +++ b/hyprpm.toml @@ -28,7 +28,7 @@ commit_pins = [ ["c4a4c341568944bd4fb9cd503558b2de602c0213", "8f0c875a5ba9864b1267e74e6f03533d18c2bca0"], # 0.50.0 ["4e242d086e20b32951fdc0ebcbfb4d41b5be8dcc", "8f0c875a5ba9864b1267e74e6f03533d18c2bca0"], # 0.50.1 ["46174f78b374b6cea669c48880877a8bdcf7802f", "6af9cdf7d739e667c638b1ac10fec0ba7ba6b86c"], # 0.51.0 - ["71a1216abcc7031776630a6d88f105605c4dc1c9", "7598f95c9983afc910eb4ab27dddbc06f13c6a4b"] # 0.51.1 + ["71a1216abcc7031776630a6d88f105605c4dc1c9", "d0fe3628415a910f27273891649b66849a85e4eb"] # 0.51.1 ] [split-monitor-workspaces] diff --git a/src/main.cpp b/src/main.cpp index 474ffb0..43d4ba8 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -319,13 +319,7 @@ static SDispatchResult changeMonitor(bool quiet, const std::string& value) { Debug::log(INFO, "[split-monitor-workspaces] Next workspace name: {}", nextWorkspaceName); Debug::log(INFO, "[split-monitor-workspaces] Dispatching command: '{}'", command + nextWorkspaceName); - auto const result = HyprlandAPI::invokeHyprctlCommand("dispatch", "workspace " + nextWorkspaceName); - if (result != "ok") { - return {.success = false, .error = result}; - } - - auto const result2 = HyprlandAPI::invokeHyprctlCommand("dispatch", command + nextWorkspaceName); - return {.success = result2 == "ok", .error = result2}; + auto const result = HyprlandAPI::invokeHyprctlCommand("dispatch", command + nextWorkspaceName); return {.success = result == "ok", .error = result}; }