summaryrefslogtreecommitdiff
path: root/src/helpers/MiscFunctions.cpp
diff options
context:
space:
mode:
authorJManch <61563764+JManch@users.noreply.github.com>2024-05-15 21:03:51 +0100
committerGitHub <noreply@github.com>2024-05-15 21:03:51 +0100
commita8522db683ae260f16f8e7778561d8a54906beb1 (patch)
treeb182a2ddd1b42a4c0cbe83fe5b6a68356b0b3d5a /src/helpers/MiscFunctions.cpp
parentb9c58b6e75f7d0141d8ba88fb3f6f022fed0877a (diff)
keybinds: fix empty on monitor for new workspaces (#6089)
Diffstat (limited to 'src/helpers/MiscFunctions.cpp')
-rw-r--r--src/helpers/MiscFunctions.cpp18
1 files changed, 13 insertions, 5 deletions
diff --git a/src/helpers/MiscFunctions.cpp b/src/helpers/MiscFunctions.cpp
index 4855553a..7382d24c 100644
--- a/src/helpers/MiscFunctions.cpp
+++ b/src/helpers/MiscFunctions.cpp
@@ -284,16 +284,24 @@ int getWorkspaceIDFromString(const std::string& in, std::string& outName) {
} else if (in.starts_with("empty")) {
const bool same_mon = in.substr(5).contains("m");
const bool next = in.substr(5).contains("n");
- if (same_mon || next) {
- if (!g_pCompositor->m_pLastMonitor) {
- Debug::log(ERR, "Empty monitor workspace on monitor null!");
- return WORKSPACE_INVALID;
+ if ((same_mon || next) && !g_pCompositor->m_pLastMonitor) {
+ Debug::log(ERR, "Empty monitor workspace on monitor null!");
+ return WORKSPACE_INVALID;
+ }
+
+ std::set<int> invalidWSes;
+ if (same_mon) {
+ for (auto& rule : g_pConfigManager->getAllWorkspaceRules()) {
+ const auto PMONITOR = g_pCompositor->getMonitorFromName(rule.monitor);
+ if (PMONITOR && (PMONITOR->ID != g_pCompositor->m_pLastMonitor->ID))
+ invalidWSes.insert(rule.workspaceId);
}
}
+
int id = next ? g_pCompositor->m_pLastMonitor->activeWorkspaceID() : 0;
while (++id < INT_MAX) {
const auto PWORKSPACE = g_pCompositor->getWorkspaceByID(id);
- if (!PWORKSPACE || (g_pCompositor->getWindowsOnWorkspace(id) == 0 && (!same_mon || PWORKSPACE->m_iMonitorID == g_pCompositor->m_pLastMonitor->ID)))
+ if (!invalidWSes.contains(id) && (!PWORKSPACE || g_pCompositor->getWindowsOnWorkspace(id) == 0))
return id;
}
} else if (in.starts_with("prev")) {