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
This commit is contained in:
Livanh 2023-10-06 21:09:18 +02:00
parent 4326a26ad6
commit 51ab2e1797
3 changed files with 10 additions and 1 deletions

View File

@ -8,6 +8,7 @@
#include <wlr/util/edges.h>
#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"
@ -381,4 +382,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

View File

@ -124,7 +124,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) {

View File

@ -357,6 +357,11 @@ static void handle_button(struct sway_seat *seat, uint32_t time_msec,
return;
}
// Clear pending keyboard bindings, if any
if (state == WLR_BUTTON_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 == WLR_BUTTON_PRESSED) {