diff --git a/src/managers/KeybindManager.cpp b/src/managers/KeybindManager.cpp index 39b0292a..345c2c03 100644 --- a/src/managers/KeybindManager.cpp +++ b/src/managers/KeybindManager.cpp @@ -36,6 +36,7 @@ CKeybindManager::CKeybindManager() { m_mDispatchers["splitratio"] = alterSplitRatio; m_mDispatchers["focusmonitor"] = focusMonitor; m_mDispatchers["movecursortocorner"] = moveCursorToCorner; + m_mDispatchers["movecursor"] = moveCursor; m_mDispatchers["workspaceopt"] = workspaceOpt; m_mDispatchers["exit"] = exitHyprland; m_mDispatchers["movecurrentworkspacetomonitor"] = moveCurrentWorkspaceToMonitor; @@ -1304,6 +1305,34 @@ void CKeybindManager::moveCursorToCorner(std::string arg) { } } +void CKeybindManager::moveCursor(std::string args) { + std::string x_str, y_str; + int x, y, i; + + i = args.find_first_of(' '); + if (i == std::string::npos) { + Debug::log(ERR, "moveCursor, takes 2 arguments."); + return; + } + + x_str = args.substr(0, i); + y_str = args.substr(i + 1); + + if (!isNumber(x_str)) { + Debug::log(ERR, "moveCursor, x argument has to be a number."); + return; + } + if (!isNumber(y_str)) { + Debug::log(ERR, "moveCursor, y argument has to be a number."); + return; + } + + x = std::stoi(x_str); + y = std::stoi(y_str); + + wlr_cursor_warp(g_pCompositor->m_sWLRCursor, g_pCompositor->m_sSeat.mouse->mouse, x, y); +} + void CKeybindManager::workspaceOpt(std::string args) { // current workspace diff --git a/src/managers/KeybindManager.hpp b/src/managers/KeybindManager.hpp index cccdc696..5b7e6186 100644 --- a/src/managers/KeybindManager.hpp +++ b/src/managers/KeybindManager.hpp @@ -115,6 +115,7 @@ class CKeybindManager { static void focusMonitor(std::string); static void toggleSplit(std::string); static void moveCursorToCorner(std::string); + static void moveCursor(std::string); static void workspaceOpt(std::string); static void renameWorkspace(std::string); static void exitHyprland(std::string);