aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorvaxerski <[email protected]>2023-03-16 16:30:22 +0000
committervaxerski <[email protected]>2023-03-16 16:30:22 +0000
commit162f23597272a472d4a70f3069f60fd77ea9734b (patch)
tree82373b74c843a075642c2f9218b3733a91d6934c
parente8adae65feb26a16693490a3a1bc10d953e031d8 (diff)
downloadHyprland-162f23597272a472d4a70f3069f60fd77ea9734b.tar.gz
Hyprland-162f23597272a472d4a70f3069f60fd77ea9734b.zip
switches: do not fire on no change in toggle
-rw-r--r--src/helpers/WLClasses.hpp2
-rw-r--r--src/managers/input/InputManager.cpp9
2 files changed, 9 insertions, 2 deletions
diff --git a/src/helpers/WLClasses.hpp b/src/helpers/WLClasses.hpp
index 8a96c6ff..55524ad1 100644
--- a/src/helpers/WLClasses.hpp
+++ b/src/helpers/WLClasses.hpp
@@ -358,6 +358,8 @@ struct STouchDevice {
struct SSwitchDevice {
wlr_input_device* pWlrDevice = nullptr;
+ int status = -1; // uninitialized
+
DYNLISTENER(destroy);
DYNLISTENER(toggle);
diff --git a/src/managers/input/InputManager.cpp b/src/managers/input/InputManager.cpp
index 99b41392..738e1011 100644
--- a/src/managers/input/InputManager.cpp
+++ b/src/managers/input/InputManager.cpp
@@ -1307,13 +1307,16 @@ void CInputManager::newSwitch(wlr_input_device* pDevice) {
[&](void* owner, void* data) {
const auto PDEVICE = (SSwitchDevice*)owner;
const auto NAME = std::string(PDEVICE->pWlrDevice->name);
+ const auto E = (wlr_switch_toggle_event*)data;
+
+ if (PDEVICE->status != -1 && PDEVICE->status == E->switch_state)
+ return;
Debug::log(LOG, "Switch %s fired, triggering binds.", NAME.c_str());
g_pKeybindManager->onSwitchEvent(NAME);
- const auto event_data = (wlr_switch_toggle_event*)data;
- switch (event_data->switch_state) {
+ switch (E->switch_state) {
case WLR_SWITCH_STATE_ON:
Debug::log(LOG, "Switch %s turn on, triggering binds.", NAME.c_str());
g_pKeybindManager->onSwitchOnEvent(NAME);
@@ -1323,6 +1326,8 @@ void CInputManager::newSwitch(wlr_input_device* pDevice) {
g_pKeybindManager->onSwitchOffEvent(NAME);
break;
}
+
+ PDEVICE->status = E->switch_state;
},
PNEWDEV, "SwitchDevice");
}