aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorvaxerski <[email protected]>2022-07-26 14:50:21 +0200
committervaxerski <[email protected]>2022-07-26 14:50:21 +0200
commit66eac124e263073d3f6f7afdd3a5bfc35eb15353 (patch)
treec7a3d2a7f1ecde8a3e1d0ba12f32de54bb4711ac
parentd04f36c57d231e4736de750b1a86d6e971350224 (diff)
downloadHyprland-66eac124e263073d3f6f7afdd3a5bfc35eb15353.tar.gz
Hyprland-66eac124e263073d3f6f7afdd3a5bfc35eb15353.zip
add binding to mouse buttons
-rw-r--r--src/config/ConfigManager.cpp2
-rw-r--r--src/managers/KeybindManager.cpp22
-rw-r--r--src/managers/KeybindManager.hpp1
-rw-r--r--src/managers/input/InputManager.cpp7
4 files changed, 32 insertions, 0 deletions
diff --git a/src/config/ConfigManager.cpp b/src/config/ConfigManager.cpp
index 86929918..fedcbc14 100644
--- a/src/config/ConfigManager.cpp
+++ b/src/config/ConfigManager.cpp
@@ -126,6 +126,8 @@ void CConfigManager::setDefaultVars() {
configValues["input:touchpad:tap-to-click"].intValue = 1;
configValues["input:touchpad:drag_lock"].intValue = 0;
+ configValues["binds:pass_mouse_when_bound"].intValue = 1;
+
configValues["gestures:workspace_swipe"].intValue = 0;
configValues["gestures:workspace_swipe_fingers"].intValue = 3;
configValues["gestures:workspace_swipe_distance"].intValue = 300;
diff --git a/src/managers/KeybindManager.cpp b/src/managers/KeybindManager.cpp
index 45a35b22..61769c38 100644
--- a/src/managers/KeybindManager.cpp
+++ b/src/managers/KeybindManager.cpp
@@ -143,6 +143,28 @@ bool CKeybindManager::onAxisEvent(wlr_pointer_axis_event* e) {
} else {
found = g_pKeybindManager->handleKeybinds(MODS, "mouse_up", 0, 0, true, 0);
}
+
+ if (found)
+ shadowKeybinds();
+ }
+
+ return !found;
+}
+
+bool CKeybindManager::onMouseEvent(wlr_pointer_button_event* e) {
+ const auto MODS = g_pInputManager->accumulateModsFromAllKBs();
+
+ bool found = false;
+
+ if (e->state == WLR_BUTTON_PRESSED) {
+ found = g_pKeybindManager->handleKeybinds(MODS, "mouse:" + std::to_string(e->button), 0, 0, true, 0);
+
+ if (found)
+ shadowKeybinds();
+ } else {
+ found = g_pKeybindManager->handleKeybinds(MODS, "mouse:" + std::to_string(e->button), 0, 0, false, 0);
+
+ shadowKeybinds();
}
return !found;
diff --git a/src/managers/KeybindManager.hpp b/src/managers/KeybindManager.hpp
index 2ae9b77b..30d3e859 100644
--- a/src/managers/KeybindManager.hpp
+++ b/src/managers/KeybindManager.hpp
@@ -27,6 +27,7 @@ public:
bool onKeyEvent(wlr_keyboard_key_event*, SKeyboard*);
bool onAxisEvent(wlr_pointer_axis_event*);
+ bool onMouseEvent(wlr_pointer_button_event*);
void addKeybind(SKeybind);
void removeKeybind(uint32_t, const std::string&);
diff --git a/src/managers/input/InputManager.cpp b/src/managers/input/InputManager.cpp
index e1f2e98f..fae0d03b 100644
--- a/src/managers/input/InputManager.cpp
+++ b/src/managers/input/InputManager.cpp
@@ -323,6 +323,13 @@ void CInputManager::processMouseDownNormal(wlr_pointer_button_event* e) {
return;
}
+ // notify the keybind manager
+ static auto *const PPASSMOUSE = &g_pConfigManager->getConfigValuePtr("binds:pass_mouse_when_bound")->intValue;
+ const auto PASS = g_pKeybindManager->onMouseEvent(e);
+
+ if (!PASS && !*PPASSMOUSE)
+ return;
+
switch (e->state) {
case WLR_BUTTON_PRESSED:
if (!g_pCompositor->m_sSeat.mouse->currentConstraint)