aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorvaxerski <[email protected]>2022-05-22 11:52:39 +0200
committervaxerski <[email protected]>2022-05-22 11:52:39 +0200
commite924cd95fde26bf776951800a595662bba0b9326 (patch)
tree97e0bd24018b3c15831fbcae4a3a26b60960d5b2
parent9af95492f8bd6d3ab58d0d445eed36acc84a6670 (diff)
downloadHyprland-e924cd95fde26bf776951800a595662bba0b9326.tar.gz
Hyprland-e924cd95fde26bf776951800a595662bba0b9326.zip
Added movecursortocorner
-rw-r--r--src/managers/KeybindManager.cpp39
-rw-r--r--src/managers/KeybindManager.hpp1
2 files changed, 40 insertions, 0 deletions
diff --git a/src/managers/KeybindManager.cpp b/src/managers/KeybindManager.cpp
index acc027f3..72daf5ce 100644
--- a/src/managers/KeybindManager.cpp
+++ b/src/managers/KeybindManager.cpp
@@ -18,6 +18,7 @@ CKeybindManager::CKeybindManager() {
m_mDispatchers["togglesplit"] = toggleSplit;
m_mDispatchers["splitratio"] = alterSplitRatio;
m_mDispatchers["focusmonitor"] = focusMonitor;
+ m_mDispatchers["movecursortocorner"] = moveCursorToCorner;
}
void CKeybindManager::addKeybind(SKeybind kb) {
@@ -556,3 +557,41 @@ void CKeybindManager::focusMonitor(std::string arg) {
Debug::log(ERR, "Error in focusMonitor: no such monitor");
}
}
+
+void CKeybindManager::moveCursorToCorner(std::string arg) {
+ if (!isNumber(arg)) {
+ Debug::log(ERR, "moveCursorToCorner, arg has to be a number.");
+ return;
+ }
+
+ const auto CORNER = std::stoi(arg);
+
+ if (CORNER < 0 || CORNER > 3) {
+ Debug::log(ERR, "moveCursorToCorner, corner not 0 - 3.");
+ return;
+ }
+
+ const auto PWINDOW = g_pCompositor->m_pLastWindow;
+
+ if (!g_pCompositor->windowValidMapped(PWINDOW))
+ return;
+
+ switch (CORNER) {
+ case 0:
+ // bottom left
+ wlr_cursor_warp(g_pCompositor->m_sWLRCursor, g_pCompositor->m_sSeat.mouse->mouse, PWINDOW->m_vRealPosition.vec().x, PWINDOW->m_vRealPosition.vec().y + PWINDOW->m_vRealSize.vec().y);
+ break;
+ case 1:
+ // bottom right
+ wlr_cursor_warp(g_pCompositor->m_sWLRCursor, g_pCompositor->m_sSeat.mouse->mouse, PWINDOW->m_vRealPosition.vec().x + PWINDOW->m_vRealSize.vec().x, PWINDOW->m_vRealPosition.vec().y + PWINDOW->m_vRealSize.vec().y);
+ break;
+ case 2:
+ // top right
+ wlr_cursor_warp(g_pCompositor->m_sWLRCursor, g_pCompositor->m_sSeat.mouse->mouse, PWINDOW->m_vRealPosition.vec().x + PWINDOW->m_vRealSize.vec().x, PWINDOW->m_vRealPosition.vec().y);
+ break;
+ case 3:
+ // top left
+ wlr_cursor_warp(g_pCompositor->m_sWLRCursor, g_pCompositor->m_sSeat.mouse->mouse, PWINDOW->m_vRealPosition.vec().x, PWINDOW->m_vRealPosition.vec().y);
+ break;
+ }
+} \ No newline at end of file
diff --git a/src/managers/KeybindManager.hpp b/src/managers/KeybindManager.hpp
index 014f2cdd..4317d7f6 100644
--- a/src/managers/KeybindManager.hpp
+++ b/src/managers/KeybindManager.hpp
@@ -46,6 +46,7 @@ private:
static void alterSplitRatio(std::string);
static void focusMonitor(std::string);
static void toggleSplit(std::string);
+ static void moveCursorToCorner(std::string);
};
inline std::unique_ptr<CKeybindManager> g_pKeybindManager; \ No newline at end of file