diff options
author | Carlos Garnacho <carlosg@gnome.org> | 2022-11-02 17:11:10 +0100 |
---|---|---|
committer | Mat <mail@mathias.is> | 2022-11-12 03:37:34 +0200 |
commit | 9b74027deaa4995ef582fdaf970ad881c3263cc1 (patch) | |
tree | 58eef2281d0213e38ea0060a032394518fa926d1 | |
parent | 5b98e171b25c3cf818a1eee26445fa0370449898 (diff) | |
download | gtk+-9b74027deaa4995ef582fdaf970ad881c3263cc1.tar.gz |
gdk/wayland: Fix button mask calculation on button events
There's 2 things broken here:
- The mask was calculated on top of the GDK button (i.e. skipping
4-7 buttons), so GDK_BUTTON4_MASK and GDK_BUTTON5_MASK were not
assigned. This is now calculated on the (continuous) BTN_ evcodes
so it is guaranteed that the next 2 physical buttons (i.e.
back/forward) get these two places in the mask assigned.
- Furthermore, these buttons would be pushed to places in the
modifier mask that they didn't belong to. It is now checked hard
that only the first 5 buttons enable a modifier flag.
Overall, this ensures that no event masks with bonkers values are
forwarded, and that no stale implicit grabs are left after additional
buttons are pressed.
Closes: https://gitlab.gnome.org/GNOME/gtk/-/issues/5301
-rw-r--r-- | gdk/wayland/gdkdevice-wayland.c | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/gdk/wayland/gdkdevice-wayland.c b/gdk/wayland/gdkdevice-wayland.c index 98e08ecb5f..f00580fa76 100644 --- a/gdk/wayland/gdkdevice-wayland.c +++ b/gdk/wayland/gdkdevice-wayland.c @@ -83,6 +83,10 @@ #define BTN_STYLUS3 0x149 /* Linux 4.15 */ #endif +#define ALL_BUTTONS_MASK (GDK_BUTTON1_MASK | GDK_BUTTON2_MASK | \ + GDK_BUTTON3_MASK | GDK_BUTTON4_MASK | \ + GDK_BUTTON5_MASK) + #define GDK_SEAT_DEBUG(seat,type,...) GDK_DISPLAY_DEBUG(gdk_seat_get_display (GDK_SEAT (seat)),type,__VA_ARGS__) typedef struct _GdkWaylandDevicePad GdkWaylandDevicePad; @@ -1716,7 +1720,8 @@ pointer_handle_button (void *data, gdk_wayland_seat_set_frame_event (seat, event); - modifier = 1 << (8 + gdk_button - 1); + modifier = (GDK_BUTTON1_MASK << (button - BUTTON_BASE - 1)) & ALL_BUTTONS_MASK; + if (state) seat->pointer_info.button_modifiers |= modifier; else |