diff options
| author | vaxerski <43317083+vaxerski@users.noreply.github.com> | 2022-07-04 16:51:42 +0200 |
|---|---|---|
| committer | vaxerski <43317083+vaxerski@users.noreply.github.com> | 2022-07-04 16:51:42 +0200 |
| commit | c40ef59a3570e2d80a0b15131e6964c3c5e14408 (patch) | |
| tree | 5a725e17fde3b3f15e0f233dbafe78dfc8871a33 /src/managers/KeybindManager.cpp | |
| parent | c71b76a9e04df40f57b3d44fbcab2ed65eacb1ee (diff) | |
support monitor names in moving workspaces
Diffstat (limited to 'src/managers/KeybindManager.cpp')
| -rw-r--r-- | src/managers/KeybindManager.cpp | 32 |
1 files changed, 20 insertions, 12 deletions
diff --git a/src/managers/KeybindManager.cpp b/src/managers/KeybindManager.cpp index cb091c9f..d26b0e92 100644 --- a/src/managers/KeybindManager.cpp +++ b/src/managers/KeybindManager.cpp @@ -793,15 +793,16 @@ void CKeybindManager::exitHyprland(std::string argz) { } void CKeybindManager::moveCurrentWorkspaceToMonitor(std::string args) { - if (!isNumber(args) && !isDirection(args)) { - Debug::log(ERR, "moveCurrentWorkspaceToMonitor arg not a number or direction!"); - return; - } - - const auto PMONITOR = isDirection(args) ? g_pCompositor->getMonitorInDirection(args[0]) : g_pCompositor->getMonitorFromID(std::stoi(args)); + SMonitor* PMONITOR = nullptr; - if (!PMONITOR) { - Debug::log(ERR, "Ignoring moveCurrentWorkspaceToMonitor: monitor doesnt exist"); + try { + if (!isNumber(args) && !isDirection(args)) { + PMONITOR = g_pCompositor->getMonitorFromName(args); + } else { + PMONITOR = isDirection(args) ? g_pCompositor->getMonitorInDirection(args[0]) : g_pCompositor->getMonitorFromID(std::stoi(args)); + } + } catch (std::exception& e) { + Debug::log(LOG, "moveCurrentWorkspaceToMonitor: caught exception in monitor", e.what()); return; } @@ -821,12 +822,19 @@ void CKeybindManager::moveWorkspaceToMonitor(std::string args) { std::string workspace = args.substr(0, args.find_first_of(' ')); std::string monitor = args.substr(args.find_first_of(' ') + 1); - if (!isNumber(monitor) && !isDirection(monitor)) { - Debug::log(ERR, "moveWorkspaceToMonitor monitor arg not a number or direction!"); + SMonitor* PMONITOR = nullptr; + + try { + if (!isNumber(monitor) && !isDirection(monitor)) { + PMONITOR = g_pCompositor->getMonitorFromName(monitor); + } else { + PMONITOR = isDirection(monitor) ? g_pCompositor->getMonitorInDirection(monitor[0]) : g_pCompositor->getMonitorFromID(std::stoi(monitor)); + } + } catch (std::exception& e) { + Debug::log(LOG, "moveWorkspaceToMonitor: caught exception in monitor", e.what()); return; } - - const auto PMONITOR = isDirection(monitor) ? g_pCompositor->getMonitorInDirection(monitor[0]) : g_pCompositor->getMonitorFromID(std::stoi(monitor)); + if (!PMONITOR){ Debug::log(ERR, "Ignoring moveWorkspaceToMonitor: monitor doesnt exist"); |
