diff options
| author | Aditya Singh <1adityasingh@proton.me> | 2025-12-28 01:57:59 +0530 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-12-27 21:27:59 +0100 |
| commit | e5d20b56bcad78df42c9060a5d330274b0a6e510 (patch) | |
| tree | 8c7829bbe0130a0cb03674b286e21fb09aa8d8e5 /hyprtester/plugin/src/main.cpp | |
| parent | 5faa66d297752ab0d919bb5719fa0949292fe720 (diff) | |
keybinds: simulate mouse movement after bringing active window to top (#12703)
Fixes https://github.com/hyprwm/Hyprland/discussions/12702
Diffstat (limited to 'hyprtester/plugin/src/main.cpp')
| -rw-r--r-- | hyprtester/plugin/src/main.cpp | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/hyprtester/plugin/src/main.cpp b/hyprtester/plugin/src/main.cpp index d8588752..d8f3c971 100644 --- a/hyprtester/plugin/src/main.cpp +++ b/hyprtester/plugin/src/main.cpp @@ -224,6 +224,28 @@ static SDispatchResult scroll(std::string in) { return {}; } +static SDispatchResult click(std::string in) { + CVarList2 data(std::move(in)); + + uint32_t button; + bool pressed; + try { + button = std::stoul(std::string{data[0]}); + pressed = std::stoul(std::string{data[1]}) == 1; + } catch (...) { return {.success = false, .error = "invalid input"}; } + + Log::logger->log(Log::DEBUG, "tester: mouse button {} state {}", button, pressed); + + g_mouse->m_pointerEvents.button.emit(IPointer::SButtonEvent{ + .timeMs = sc<uint32_t>(Time::millis(Time::steadyNow())), + .button = button, + .state = pressed ? WL_POINTER_BUTTON_STATE_PRESSED : WL_POINTER_BUTTON_STATE_RELEASED, + .mouse = true, + }); + + return {}; +} + static SDispatchResult keybind(std::string in) { CVarList2 data(std::move(in)); // 0 = release, 1 = press @@ -283,6 +305,7 @@ APICALL EXPORT PLUGIN_DESCRIPTION_INFO PLUGIN_INIT(HANDLE handle) { HyprlandAPI::addDispatcherV2(PHANDLE, "plugin:test:alt", ::pressAlt); HyprlandAPI::addDispatcherV2(PHANDLE, "plugin:test:gesture", ::simulateGesture); HyprlandAPI::addDispatcherV2(PHANDLE, "plugin:test:scroll", ::scroll); + HyprlandAPI::addDispatcherV2(PHANDLE, "plugin:test:click", ::click); HyprlandAPI::addDispatcherV2(PHANDLE, "plugin:test:keybind", ::keybind); HyprlandAPI::addDispatcherV2(PHANDLE, "plugin:test:add_rule", ::addRule); HyprlandAPI::addDispatcherV2(PHANDLE, "plugin:test:check_rule", ::checkRule); |
