GtkGestureDrag only works with primary mouse button
Steps to reproduce
- Change the drawingarea demo to use the secondary of middle mouse button (see amolenaar/gtk@0b10e1cc).
- Compile GTK.
- Run the drawingarea demo:
./demos/gtk-demo/gtk4-demo --run drawingarea
- Try draw something, you'll notice only one dot (on `drag-begin') is being drawn.
Current behavior
When any but the primary button is pressed, the drag gesture ends immediately. There's no drag-update events being emitted.
Expected outcome
I would expect GtkGestureDrag
to work for any mouse button.
If GtkGestureDrag
is not intended to work with any but the primary mouse button, I would expect find that in the documentation.
Version information
Used GTK main
on Fedora 37 (Wayland), compiled from source.
Additional info
When I use my right mouse button (GDK_BUTTON_SECONDARY
), my button id is 3, but the modifier state is 512
(GDK_BUTTON2_MASK
). This gives a mismatch on the mask, and as a result the gesture is ended.
It may be the issue is related to buttons and button masks in GtkGestureSingle
.
It may just as well be an issue with the mapping from Wayland to GTK. On macOS the drawingarea demo works as expected with the secondary mouse button.
Wayland:
#define BTN_LEFT 0x110
#define BTN_RIGHT 0x111
#define BTN_MIDDLE 0x112
GTK:
GDK_BUTTON1_MASK = 1 << 8,
GDK_BUTTON2_MASK = 1 << 9,
GDK_BUTTON3_MASK = 1 << 10,
For Wayland, the modifier is calculated as:
modifier = (GDK_BUTTON1_MASK << (button - BUTTON_BASE - 1)) & ALL_BUTTONS_MASK;
But it's not a 1:1 mapping: button 2 and 3 need to be swapped.