1
0
Fork 0

backends/native: Handle new stylus actions as zero button events

Stylus actions that don't map into LMR or back/forward are now created
as a clutter button event with a button number of zero. Nothing is
actually done with those events for now, they're just discarded later.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3649>
This commit is contained in:
Peter Hutterer 2024-03-06 15:44:22 +10:00 committed by Marge Bot
parent 829adfcfaa
commit 7ab5a8cf95
2 changed files with 24 additions and 10 deletions

View file

@ -792,7 +792,7 @@ meta_seat_impl_notify_button_in_impl (MetaSeatImpl *seat_impl,
MetaInputDeviceNative *device_native = META_INPUT_DEVICE_NATIVE (input_device);
ClutterEvent *event = NULL;
ClutterModifierType modifiers;
int button_nr;
int button_nr = 0;
float x, y;
static int maskmap[8] =
{
@ -823,36 +823,44 @@ meta_seat_impl_notify_button_in_impl (MetaSeatImpl *seat_impl,
{
case G_DESKTOP_STYLUS_BUTTON_ACTION_DEFAULT:
button = meta_clutter_tool_button_to_evdev (CLUTTER_BUTTON_PRIMARY);
button_nr = meta_evdev_tool_button_to_clutter (button);
break;
case G_DESKTOP_STYLUS_BUTTON_ACTION_MIDDLE:
button = meta_clutter_tool_button_to_evdev (CLUTTER_BUTTON_MIDDLE);
button_nr = meta_evdev_tool_button_to_clutter (button);
break;
case G_DESKTOP_STYLUS_BUTTON_ACTION_RIGHT:
button = meta_clutter_tool_button_to_evdev (CLUTTER_BUTTON_SECONDARY);
button_nr = meta_evdev_tool_button_to_clutter (button);
break;
case G_DESKTOP_STYLUS_BUTTON_ACTION_BACK:
button = BTN_BACK;
button_nr = meta_evdev_tool_button_to_clutter (button);
break;
case G_DESKTOP_STYLUS_BUTTON_ACTION_FORWARD:
button = BTN_FORWARD;
button_nr = meta_evdev_tool_button_to_clutter (button);
break;
case G_DESKTOP_STYLUS_BUTTON_ACTION_SWITCH_MONITOR:
case G_DESKTOP_STYLUS_BUTTON_ACTION_KEYBINDING:
// button evdev code left as-is, i.e. BTN_STYLUS or whatever
button_nr = 0;
break;
default:
g_warn_if_reached ();
}
}
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)
{
g_warning ("Unhandled button event 0x%x", button);
return;
button_nr = meta_evdev_button_to_clutter (button);
if (button_nr < 1 || button_nr > 12)
{
g_warning ("Unhandled button event 0x%x", button);
return;
}
}
if (button_nr < G_N_ELEMENTS (maskmap))
if (button_nr > 0 && button_nr < G_N_ELEMENTS (maskmap))
{
/* Update the modifiers */
if (state)

View file

@ -325,6 +325,12 @@ meta_display_handle_event (MetaDisplay *display,
meta_tablet_action_mapper_handle_event (mapper, event))
return CLUTTER_EVENT_STOP;
}
else if (event_type == CLUTTER_BUTTON_PRESS ||
event_type == CLUTTER_BUTTON_RELEASE)
{
if (clutter_event_get_button (event) == 0)
return CLUTTER_EVENT_STOP;
}
if (event_type != CLUTTER_DEVICE_ADDED &&
event_type != CLUTTER_DEVICE_REMOVED)