From 2ea6ceb6bb6e4f3f7a7d2c673ffde17a86a05e89 Mon Sep 17 00:00:00 2001 From: Livanh Date: Fri, 6 Oct 2023 21:09:18 +0200 Subject: [PATCH] Clear held keybinding when clicking mouse buttons with modifiers When handling a button click with one or more modifiers, or using the mouse with the floating modifier, assume that the modifiers are not intended as a standalone keybinding, and clear the held_binding from the keyboard. This way it is possible to use a single modifier (e.g. Super) as main modifier, floating modifier, and as a standalone keybinding (with --release). Fixes #4505 --- include/sway/input/seat.h | 4 ++++ sway/input/seat.c | 2 +- sway/input/seatop_default.c | 5 +++++ 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/include/sway/input/seat.h b/include/sway/input/seat.h index 428f96796..7b4e8affe 100644 --- a/include/sway/input/seat.h +++ b/include/sway/input/seat.h @@ -9,6 +9,7 @@ #include #include "sway/config.h" #include "sway/input/input-manager.h" +#include "sway/input/keyboard.h" #include "sway/input/tablet.h" #include "sway/input/text_input.h" @@ -369,4 +370,7 @@ keyboard_shortcuts_inhibitor_get_for_surface(const struct sway_seat *seat, struct sway_keyboard_shortcuts_inhibitor * keyboard_shortcuts_inhibitor_get_for_focused_surface(const struct sway_seat *seat); +struct sway_keyboard *sway_keyboard_for_wlr_keyboard(struct sway_seat *seat, + struct wlr_keyboard *wlr_keyboard); + #endif diff --git a/sway/input/seat.c b/sway/input/seat.c index 0dd26290e..91b9ddd97 100644 --- a/sway/input/seat.c +++ b/sway/input/seat.c @@ -130,7 +130,7 @@ static void seat_send_activate(struct sway_node *node, struct sway_seat *seat) { } } -static struct sway_keyboard *sway_keyboard_for_wlr_keyboard( +struct sway_keyboard *sway_keyboard_for_wlr_keyboard( struct sway_seat *seat, struct wlr_keyboard *wlr_keyboard) { struct sway_seat_device *seat_device; wl_list_for_each(seat_device, &seat->devices, link) { diff --git a/sway/input/seatop_default.c b/sway/input/seatop_default.c index 6a7dddd9a..4b8fbc7d1 100644 --- a/sway/input/seatop_default.c +++ b/sway/input/seatop_default.c @@ -368,6 +368,11 @@ static void handle_button(struct sway_seat *seat, uint32_t time_msec, return; } + // Clear pending keyboard bindings, if any + if (state == WL_POINTER_BUTTON_STATE_PRESSED && modifiers != 0) { + sway_keyboard_for_wlr_keyboard(seat, keyboard)->held_binding = NULL; + } + // Handle clicking an empty workspace if (node && node->type == N_WORKSPACE) { if (state == WL_POINTER_BUTTON_STATE_PRESSED) {