backends/native: Use helper functions to map buttons
Use the helper function for mapping a stylus tool evdev code to a clutter button code. This fixes a (theoretical) issue - if a tool were to send any button other than the one we handled those would likely be BTN_SIDE and friends and we'd likely end up with negative button numbers. The BTN_TOOL_PEN range is not predicable enough to do any sort of calculation conversion because things like BTN_TOOL_DOUBLETAP have specific meanings that aren't actually buttons. Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3649>
This commit is contained in:
parent
dfcb160321
commit
ae59acad76
1 changed files with 4 additions and 32 deletions
|
@ -812,38 +812,10 @@ meta_seat_impl_notify_button_in_impl (MetaSeatImpl *seat_impl,
|
|||
return;
|
||||
}
|
||||
|
||||
/* The evdev button numbers don't map sequentially to clutter button
|
||||
* numbers (the right and middle mouse buttons are in the opposite
|
||||
* order) so we'll map them directly with a switch statement */
|
||||
switch (button)
|
||||
{
|
||||
case BTN_LEFT:
|
||||
case BTN_TOUCH:
|
||||
button_nr = CLUTTER_BUTTON_PRIMARY;
|
||||
break;
|
||||
|
||||
case BTN_MIDDLE:
|
||||
case BTN_STYLUS:
|
||||
button_nr = CLUTTER_BUTTON_MIDDLE;
|
||||
break;
|
||||
|
||||
case BTN_RIGHT:
|
||||
case BTN_STYLUS2:
|
||||
button_nr = CLUTTER_BUTTON_SECONDARY;
|
||||
break;
|
||||
|
||||
case BTN_STYLUS3:
|
||||
button_nr = 8;
|
||||
break;
|
||||
|
||||
default:
|
||||
/* For compatibility reasons, all additional buttons go after the old 4-7 scroll ones */
|
||||
if (clutter_input_device_get_device_type (input_device) == CLUTTER_TABLET_DEVICE)
|
||||
button_nr = button - BTN_TOOL_PEN + 4;
|
||||
else
|
||||
button_nr = meta_evdev_button_to_clutter (button);
|
||||
break;
|
||||
}
|
||||
if (clutter_input_device_get_device_type (input_device) == CLUTTER_TABLET_DEVICE)
|
||||
button_nr = meta_evdev_tool_button_to_clutter (button);
|
||||
else
|
||||
button_nr = meta_evdev_button_to_clutter (button);
|
||||
|
||||
if (button_nr < 1 || button_nr > 12)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue