summaryrefslogtreecommitdiff
path: root/src/managers/KeybindManager.cpp
diff options
context:
space:
mode:
authormekb <mekbgithub@icloud.com>2023-04-24 04:50:53 +1000
committerGitHub <noreply@github.com>2023-04-23 19:50:53 +0100
commitfbcbe947dacd62c93dd2e9c2f90fa827da67fd9c (patch)
tree56dfee21a82f0338b6a3ef58f8ad488b05136c2f /src/managers/KeybindManager.cpp
parent97b03687657ba141f11128d25aa345d92892bd2d (diff)
Added moveCursor dispatcher (#2100)
* Added moveCursor dispatcher * fix error message for moveCursor
Diffstat (limited to 'src/managers/KeybindManager.cpp')
-rw-r--r--src/managers/KeybindManager.cpp29
1 files changed, 29 insertions, 0 deletions
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