backends/native: Store the stylus actions as actions
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3649>
This commit is contained in:

committed by
Marge Bot

parent
5fdf1fa892
commit
829adfcfaa
@ -146,7 +146,7 @@ meta_input_device_tool_native_set_pressure_curve_in_impl (ClutterInputDeviceTool
|
||||
void
|
||||
meta_input_device_tool_native_set_button_code_in_impl (ClutterInputDeviceTool *tool,
|
||||
uint32_t button,
|
||||
uint32_t evcode)
|
||||
GDesktopStylusButtonAction action)
|
||||
{
|
||||
MetaInputDeviceToolNative *evdev_tool;
|
||||
|
||||
@ -154,14 +154,14 @@ meta_input_device_tool_native_set_button_code_in_impl (ClutterInputDeviceTool *t
|
||||
|
||||
evdev_tool = META_INPUT_DEVICE_TOOL_NATIVE (tool);
|
||||
|
||||
if (evcode == 0)
|
||||
if (action == G_DESKTOP_STYLUS_BUTTON_ACTION_DEFAULT)
|
||||
{
|
||||
g_hash_table_remove (evdev_tool->button_map, GUINT_TO_POINTER (button));
|
||||
}
|
||||
else
|
||||
{
|
||||
g_hash_table_insert (evdev_tool->button_map, GUINT_TO_POINTER (button),
|
||||
GUINT_TO_POINTER (evcode));
|
||||
GUINT_TO_POINTER (action));
|
||||
}
|
||||
}
|
||||
|
||||
@ -182,7 +182,7 @@ meta_input_device_tool_native_translate_pressure_in_impl (ClutterInputDeviceTool
|
||||
return pressure * factor;
|
||||
}
|
||||
|
||||
uint32_t
|
||||
GDesktopStylusButtonAction
|
||||
meta_input_device_tool_native_get_button_code_in_impl (ClutterInputDeviceTool *tool,
|
||||
uint32_t button)
|
||||
{
|
||||
|
@ -49,13 +49,13 @@ ClutterInputDeviceTool * meta_input_device_tool_native_new (struct libinput
|
||||
|
||||
gdouble meta_input_device_tool_native_translate_pressure_in_impl (ClutterInputDeviceTool *tool,
|
||||
double pressure);
|
||||
uint32_t meta_input_device_tool_native_get_button_code_in_impl (ClutterInputDeviceTool *tool,
|
||||
GDesktopStylusButtonAction meta_input_device_tool_native_get_button_code_in_impl (ClutterInputDeviceTool *tool,
|
||||
uint32_t button);
|
||||
|
||||
void meta_input_device_tool_native_set_pressure_curve_in_impl (ClutterInputDeviceTool *tool,
|
||||
double curve[4]);
|
||||
void meta_input_device_tool_native_set_button_code_in_impl (ClutterInputDeviceTool *tool,
|
||||
uint32_t button,
|
||||
uint32_t evcode);
|
||||
GDesktopStylusButtonAction evcode);
|
||||
|
||||
G_END_DECLS
|
||||
|
@ -708,25 +708,6 @@ meta_input_settings_native_set_stylus_pressure (MetaInputSettings *settings
|
||||
meta_input_device_tool_native_set_pressure_curve_in_impl (tool, pressure_curve);
|
||||
}
|
||||
|
||||
static guint
|
||||
action_to_evcode (GDesktopStylusButtonAction action)
|
||||
{
|
||||
switch (action)
|
||||
{
|
||||
case G_DESKTOP_STYLUS_BUTTON_ACTION_MIDDLE:
|
||||
return BTN_STYLUS;
|
||||
case G_DESKTOP_STYLUS_BUTTON_ACTION_RIGHT:
|
||||
return BTN_STYLUS2;
|
||||
case G_DESKTOP_STYLUS_BUTTON_ACTION_BACK:
|
||||
return BTN_BACK;
|
||||
case G_DESKTOP_STYLUS_BUTTON_ACTION_FORWARD:
|
||||
return BTN_FORWARD;
|
||||
case G_DESKTOP_STYLUS_BUTTON_ACTION_DEFAULT:
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
meta_input_settings_native_set_stylus_button_map (MetaInputSettings *settings,
|
||||
ClutterInputDevice *device,
|
||||
@ -735,12 +716,9 @@ meta_input_settings_native_set_stylus_button_map (MetaInputSettings *se
|
||||
GDesktopStylusButtonAction secondary,
|
||||
GDesktopStylusButtonAction tertiary)
|
||||
{
|
||||
meta_input_device_tool_native_set_button_code_in_impl (tool, CLUTTER_BUTTON_MIDDLE,
|
||||
action_to_evcode (primary));
|
||||
meta_input_device_tool_native_set_button_code_in_impl (tool, CLUTTER_BUTTON_SECONDARY,
|
||||
action_to_evcode (secondary));
|
||||
meta_input_device_tool_native_set_button_code_in_impl (tool, 8, /* Back */
|
||||
action_to_evcode (tertiary));
|
||||
meta_input_device_tool_native_set_button_code_in_impl (tool, CLUTTER_BUTTON_MIDDLE, primary);
|
||||
meta_input_device_tool_native_set_button_code_in_impl (tool, CLUTTER_BUTTON_SECONDARY, secondary);
|
||||
meta_input_device_tool_native_set_button_code_in_impl (tool, 8, tertiary);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -814,13 +814,31 @@ meta_seat_impl_notify_button_in_impl (MetaSeatImpl *seat_impl,
|
||||
|
||||
if (device_native->last_tool)
|
||||
{
|
||||
uint32_t mapped_button;
|
||||
GDesktopStylusButtonAction action;
|
||||
int tool_button_nr = meta_evdev_tool_button_to_clutter (button);
|
||||
|
||||
/* Apply the button event code as per the tool mapping */
|
||||
mapped_button = meta_input_device_tool_native_get_button_code_in_impl (device_native->last_tool, tool_button_nr);
|
||||
if (mapped_button != 0)
|
||||
button = mapped_button;
|
||||
action = meta_input_device_tool_native_get_button_code_in_impl (device_native->last_tool, tool_button_nr);
|
||||
switch (action)
|
||||
{
|
||||
case G_DESKTOP_STYLUS_BUTTON_ACTION_DEFAULT:
|
||||
button = meta_clutter_tool_button_to_evdev (CLUTTER_BUTTON_PRIMARY);
|
||||
break;
|
||||
case G_DESKTOP_STYLUS_BUTTON_ACTION_MIDDLE:
|
||||
button = meta_clutter_tool_button_to_evdev (CLUTTER_BUTTON_MIDDLE);
|
||||
break;
|
||||
case G_DESKTOP_STYLUS_BUTTON_ACTION_RIGHT:
|
||||
button = meta_clutter_tool_button_to_evdev (CLUTTER_BUTTON_SECONDARY);
|
||||
break;
|
||||
case G_DESKTOP_STYLUS_BUTTON_ACTION_BACK:
|
||||
button = BTN_BACK;
|
||||
break;
|
||||
case G_DESKTOP_STYLUS_BUTTON_ACTION_FORWARD:
|
||||
button = BTN_FORWARD;
|
||||
break;
|
||||
default:
|
||||
g_warn_if_reached ();
|
||||
}
|
||||
}
|
||||
|
||||
if (clutter_input_device_get_device_type (input_device) == CLUTTER_TABLET_DEVICE)
|
||||
|
Reference in New Issue
Block a user