mirror of
https://github.com/hyprwm/Hyprland
synced 2024-11-23 00:25:57 +01:00
keybinds: fix empty on monitor for new workspaces (#6089)
This commit is contained in:
parent
b9c58b6e75
commit
a8522db683
1 changed files with 13 additions and 5 deletions
|
@ -284,16 +284,24 @@ int getWorkspaceIDFromString(const std::string& in, std::string& outName) {
|
||||||
} else if (in.starts_with("empty")) {
|
} else if (in.starts_with("empty")) {
|
||||||
const bool same_mon = in.substr(5).contains("m");
|
const bool same_mon = in.substr(5).contains("m");
|
||||||
const bool next = in.substr(5).contains("n");
|
const bool next = in.substr(5).contains("n");
|
||||||
if (same_mon || next) {
|
if ((same_mon || next) && !g_pCompositor->m_pLastMonitor) {
|
||||||
if (!g_pCompositor->m_pLastMonitor) {
|
Debug::log(ERR, "Empty monitor workspace on monitor null!");
|
||||||
Debug::log(ERR, "Empty monitor workspace on monitor null!");
|
return WORKSPACE_INVALID;
|
||||||
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;
|
int id = next ? g_pCompositor->m_pLastMonitor->activeWorkspaceID() : 0;
|
||||||
while (++id < INT_MAX) {
|
while (++id < INT_MAX) {
|
||||||
const auto PWORKSPACE = g_pCompositor->getWorkspaceByID(id);
|
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;
|
return id;
|
||||||
}
|
}
|
||||||
} else if (in.starts_with("prev")) {
|
} else if (in.starts_with("prev")) {
|
||||||
|
|
Loading…
Reference in a new issue