From 84864453c8e16565e6774d924589671a367ed4f9 Mon Sep 17 00:00:00 2001 From: WhySoBad <49595640+WhySoBad@users.noreply.github.com> Date: Mon, 25 Nov 2024 10:23:23 +0100 Subject: [PATCH 1/2] fix: fix removal of getWindowsOnWorkspace --- src/VirtualDesk.cpp | 2 +- src/main.cpp | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/VirtualDesk.cpp b/src/VirtualDesk.cpp index 4e13ca0..8716d13 100644 --- a/src/VirtualDesk.cpp +++ b/src/VirtualDesk.cpp @@ -121,7 +121,7 @@ CSharedPointer VirtualDesk::firstAvailableMonitor(const std::vector newMonitor; for (const auto& mon : currentlyEnabledMonitors()) { - auto n_on_mon = g_pCompositor->getWindowsOnWorkspace(mon->activeWorkspaceID()); + auto n_on_mon = g_pCompositor->getWorkspaceByID(mon->activeWorkspaceID())->getWindows(); if (n_on_mon < n) { n = n_on_mon; newMonitor = mon; diff --git a/src/main.cpp b/src/main.cpp index c7d21c8..9e02160 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -184,7 +184,7 @@ std::string printStateDispatch(eHyprCtlOutputFormat format, std::string arg) { std::string workspaces; bool first = true; for (auto const& [monitor, workspaceId] : desk->activeLayout(manager->conf)) { - windows += g_pCompositor->getWindowsOnWorkspace(workspaceId); + windows += g_pCompositor->getWorkspaceByID(workspaceId)->getWindows(); if (!first) workspaces += ", "; else @@ -204,7 +204,7 @@ std::string printStateDispatch(eHyprCtlOutputFormat format, std::string arg) { std::string workspaces; bool first = true; for (auto const& [monitor, workspaceId] : desk->activeLayout(manager->conf)) { - windows += g_pCompositor->getWindowsOnWorkspace(workspaceId); + windows += g_pCompositor->getWorkspaceByID(workspaceId)->getWindows(); if (!first) workspaces += ", "; else From 525670f62e919d85aa5042d1dcf1ceb709938f9b Mon Sep 17 00:00:00 2001 From: WhySoBad <49595640+WhySoBad@users.noreply.github.com> Date: Mon, 25 Nov 2024 10:33:47 +0100 Subject: [PATCH 2/2] fix: handle inexistent workspaces --- src/VirtualDesk.cpp | 12 ++++++++---- src/main.cpp | 10 ++++++++-- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/src/VirtualDesk.cpp b/src/VirtualDesk.cpp index 8716d13..4002cad 100644 --- a/src/VirtualDesk.cpp +++ b/src/VirtualDesk.cpp @@ -1,4 +1,5 @@ #include "VirtualDesk.hpp" +#include "src/Compositor.hpp" #include #include #include @@ -121,10 +122,13 @@ CSharedPointer VirtualDesk::firstAvailableMonitor(const std::vector newMonitor; for (const auto& mon : currentlyEnabledMonitors()) { - auto n_on_mon = g_pCompositor->getWorkspaceByID(mon->activeWorkspaceID())->getWindows(); - if (n_on_mon < n) { - n = n_on_mon; - newMonitor = mon; + auto workspace = g_pCompositor->getWorkspaceByID(mon->activeWorkspaceID()); + if (workspace) { + auto n_on_mon = workspace->getWindows(); + if (n_on_mon < n) { + n = n_on_mon; + newMonitor = mon; + } } } return newMonitor; diff --git a/src/main.cpp b/src/main.cpp index 9e02160..385c0da 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -184,7 +184,10 @@ std::string printStateDispatch(eHyprCtlOutputFormat format, std::string arg) { std::string workspaces; bool first = true; for (auto const& [monitor, workspaceId] : desk->activeLayout(manager->conf)) { - windows += g_pCompositor->getWorkspaceByID(workspaceId)->getWindows(); + auto workspace = g_pCompositor->getWorkspaceByID(workspaceId); + if (workspace) { + windows += workspace->getWindows(); + } if (!first) workspaces += ", "; else @@ -204,7 +207,10 @@ std::string printStateDispatch(eHyprCtlOutputFormat format, std::string arg) { std::string workspaces; bool first = true; for (auto const& [monitor, workspaceId] : desk->activeLayout(manager->conf)) { - windows += g_pCompositor->getWorkspaceByID(workspaceId)->getWindows(); + auto workspace = g_pCompositor->getWorkspaceByID(workspaceId); + if (workspace) { + windows += workspace->getWindows(); + } if (!first) workspaces += ", "; else