diff options
| author | William Gray <wagyourtail@wagyourtail.xyz> | 2024-05-08 07:30:20 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-05-08 13:30:20 +0100 |
| commit | 36d32973ddc1bd1d4096ec36f3b8cb507009eba4 (patch) | |
| tree | 1bf82e0b85cfab3f55b300fc61c05e8b87f0161b /src/helpers/MiscFunctions.cpp | |
| parent | 70b5e6df70a7eac180e2c8e9c2bce70ff43b45ad (diff) | |
keybinds: add empty on monitor and next empty flags (#5936)
* empty on monitor
* add flag for next empty
* clang-format changes
* next also uses m_pLastMonitor
Diffstat (limited to 'src/helpers/MiscFunctions.cpp')
| -rw-r--r-- | src/helpers/MiscFunctions.cpp | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/src/helpers/MiscFunctions.cpp b/src/helpers/MiscFunctions.cpp index f9bb5b46..4855553a 100644 --- a/src/helpers/MiscFunctions.cpp +++ b/src/helpers/MiscFunctions.cpp @@ -282,10 +282,18 @@ int getWorkspaceIDFromString(const std::string& in, std::string& outName) { } outName = WORKSPACENAME; } else if (in.starts_with("empty")) { - int id = 0; + 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; + } + } + 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)) + if (!PWORKSPACE || (g_pCompositor->getWindowsOnWorkspace(id) == 0 && (!same_mon || PWORKSPACE->m_iMonitorID == g_pCompositor->m_pLastMonitor->ID))) return id; } } else if (in.starts_with("prev")) { |
