From c67a35580039c3e81c5b59085f3cf7a94fbbf5d4 Mon Sep 17 00:00:00 2001 From: Kevin Pouget Date: Thu, 14 May 2020 16:00:59 +0200 Subject: [PATCH] Capture and forward mouse buttons 8 and 9 Co-Authored-By: Joan Bruguera --- src/channel-inputs.c | 12 ++++++++++++ src/spice-widget.c | 12 ++++++++++++ 2 files changed, 28 insertions(+) diff --git a/src/channel-inputs.c b/src/channel-inputs.c index 5e6c7b4a..293344ed 100644 --- a/src/channel-inputs.c +++ b/src/channel-inputs.c @@ -426,6 +426,12 @@ void spice_inputs_channel_button_press(SpiceInputsChannel *channel, gint button, case SPICE_MOUSE_BUTTON_RIGHT: button_state |= SPICE_MOUSE_BUTTON_MASK_RIGHT; break; + case SPICE_MOUSE_BUTTON_SIDE: + button_state |= SPICE_MOUSE_BUTTON_MASK_SIDE; + break; + case SPICE_MOUSE_BUTTON_EXTRA: + button_state |= SPICE_MOUSE_BUTTON_MASK_EXTRA; + break; } c->bs = button_state; @@ -491,6 +497,12 @@ void spice_inputs_channel_button_release(SpiceInputsChannel *channel, gint butto case SPICE_MOUSE_BUTTON_RIGHT: button_state &= ~SPICE_MOUSE_BUTTON_MASK_RIGHT; break; + case SPICE_MOUSE_BUTTON_SIDE: + button_state &= ~SPICE_MOUSE_BUTTON_MASK_SIDE; + break; + case SPICE_MOUSE_BUTTON_EXTRA: + button_state &= ~SPICE_MOUSE_BUTTON_MASK_EXTRA; + break; } c->bs = button_state; diff --git a/src/spice-widget.c b/src/spice-widget.c index 5cef966b..85d0f4db 100644 --- a/src/spice-widget.c +++ b/src/spice-widget.c @@ -1997,6 +1997,8 @@ static int button_gdk_to_spice(guint gdk) [ 3 ] = SPICE_MOUSE_BUTTON_RIGHT, [ 4 ] = SPICE_MOUSE_BUTTON_UP, [ 5 ] = SPICE_MOUSE_BUTTON_DOWN, + [ 8 ] = SPICE_MOUSE_BUTTON_SIDE, + [ 9 ] = SPICE_MOUSE_BUTTON_EXTRA, }; if (gdk < SPICE_N_ELEMENTS(map)) { @@ -2011,6 +2015,8 @@ static int button_gdk_to_spice_mask(guint gdk) [1] = SPICE_MOUSE_BUTTON_MASK_LEFT, [2] = SPICE_MOUSE_BUTTON_MASK_MIDDLE, [3] = SPICE_MOUSE_BUTTON_MASK_RIGHT, + [8] = SPICE_MOUSE_BUTTON_MASK_SIDE, + [9] = SPICE_MOUSE_BUTTON_MASK_EXTRA, }; if (gdk < SPICE_N_ELEMENTS(map)) { @@ -2029,6 +2037,14 @@ static int button_mask_gdk_to_spice(int gdk) spice |= SPICE_MOUSE_BUTTON_MASK_MIDDLE; if (gdk & GDK_BUTTON3_MASK) spice |= SPICE_MOUSE_BUTTON_MASK_RIGHT; + /* Currently, GDK does not define any mask for buttons 8 and 9 + For X11, no mask is set at all for those buttons: + https://gitlab.gnome.org/GNOME/gtk/-/blob/4fff68355a22027791258b900f1f39ca1226b669/gdk/x11/gdkdevice-xi2.c#L639 + For Wayland, masks of (1 << 15) and (1 << 16) respectively are set: + https://gitlab.gnome.org/GNOME/gtk/-/blob/4fff68355a22027791258b900f1f39ca1226b669/gdk/wayland/gdkdevice-wayland.c#L1703 + While the situation is unclear, completely ignore the GTK mask for SIDE and EXTRA events. + Also, note that callers of this function already set/unset the mask based on the button + code, so not setting the mask here shouldn't have a noticeable impact anyway */ return spice; } -- GitLab