Added moveCursor dispatcher (#2100)

* Added moveCursor dispatcher

* fix error message for moveCursor
This commit is contained in:
mekb 2023-04-24 04:50:53 +10:00 committed by GitHub
parent 97b0368765
commit fbcbe947da
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 30 additions and 0 deletions

View file

@ -36,6 +36,7 @@ CKeybindManager::CKeybindManager() {
m_mDispatchers["splitratio"] = alterSplitRatio; m_mDispatchers["splitratio"] = alterSplitRatio;
m_mDispatchers["focusmonitor"] = focusMonitor; m_mDispatchers["focusmonitor"] = focusMonitor;
m_mDispatchers["movecursortocorner"] = moveCursorToCorner; m_mDispatchers["movecursortocorner"] = moveCursorToCorner;
m_mDispatchers["movecursor"] = moveCursor;
m_mDispatchers["workspaceopt"] = workspaceOpt; m_mDispatchers["workspaceopt"] = workspaceOpt;
m_mDispatchers["exit"] = exitHyprland; m_mDispatchers["exit"] = exitHyprland;
m_mDispatchers["movecurrentworkspacetomonitor"] = moveCurrentWorkspaceToMonitor; 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) { void CKeybindManager::workspaceOpt(std::string args) {
// current workspace // current workspace

View file

@ -115,6 +115,7 @@ class CKeybindManager {
static void focusMonitor(std::string); static void focusMonitor(std::string);
static void toggleSplit(std::string); static void toggleSplit(std::string);
static void moveCursorToCorner(std::string); static void moveCursorToCorner(std::string);
static void moveCursor(std::string);
static void workspaceOpt(std::string); static void workspaceOpt(std::string);
static void renameWorkspace(std::string); static void renameWorkspace(std::string);
static void exitHyprland(std::string); static void exitHyprland(std::string);