Skip to content

Commit 6e1b1b1

Browse files
committed
workspace: fix emptym
Empty workspaces on other monitors should be ignored. Fixes #8416
1 parent 7ccc57e commit 6e1b1b1

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

src/helpers/MiscFunctions.cpp

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,8 @@ SWorkspaceIDName getWorkspaceIDNameFromString(const std::string& in) {
147147
} else if (in.starts_with("empty")) {
148148
const bool same_mon = in.substr(5).contains("m");
149149
const bool next = in.substr(5).contains("n");
150-
if ((same_mon || next) && !Desktop::focusState()->monitor()) {
150+
const auto monitor = Desktop::focusState()->monitor();
151+
if ((same_mon || next) && !monitor) {
151152
Debug::log(ERR, "Empty monitor workspace on monitor null!");
152153
return {WORKSPACE_INVALID};
153154
}
@@ -156,18 +157,24 @@ SWorkspaceIDName getWorkspaceIDNameFromString(const std::string& in) {
156157
if (same_mon) {
157158
for (auto const& rule : g_pConfigManager->getAllWorkspaceRules()) {
158159
const auto PMONITOR = g_pCompositor->getMonitorFromString(rule.monitor);
159-
if (PMONITOR && (PMONITOR->m_id != Desktop::focusState()->monitor()->m_id))
160+
if (PMONITOR && (PMONITOR->m_id != monitor->m_id))
160161
invalidWSes.insert(rule.workspaceId);
161162
}
162163
}
163164

164-
WORKSPACEID id = next ? Desktop::focusState()->monitor()->activeWorkspaceID() : 0;
165+
WORKSPACEID id = next ? monitor->activeWorkspaceID() : 0;
165166
while (++id < LONG_MAX) {
166167
const auto PWORKSPACE = g_pCompositor->getWorkspaceByID(id);
167-
if (!invalidWSes.contains(id) && (!PWORKSPACE || PWORKSPACE->getWindows() == 0)) {
168-
result.id = id;
169-
return result;
168+
if (invalidWSes.contains(id))
169+
continue;
170+
if (PWORKSPACE) {
171+
if (PWORKSPACE->getWindows())
172+
continue;
173+
if (same_mon && PWORKSPACE->m_monitor && PWORKSPACE->m_monitor->m_id != monitor->m_id)
174+
continue;
170175
}
176+
result.id = id;
177+
return result;
171178
}
172179
} else if (in.starts_with("prev")) {
173180
if (!Desktop::focusState()->monitor())

0 commit comments

Comments
 (0)