mirror of
https://github.com/brl/mutter.git
synced 2024-12-22 19:12:04 +00:00
Add tap-button-map and tap-and-drag-lock support to X11 and Wayland
https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1319
This commit is contained in:
parent
d67ba3ea65
commit
775ec67a44
@ -55,9 +55,15 @@ struct _MetaInputSettingsClass
|
||||
void (* set_tap_enabled) (MetaInputSettings *settings,
|
||||
ClutterInputDevice *device,
|
||||
gboolean enabled);
|
||||
void (* set_tap_button_map) (MetaInputSettings *settings,
|
||||
ClutterInputDevice *device,
|
||||
GDesktopTouchpadTapButtonMap mode);
|
||||
void (* set_tap_and_drag_enabled) (MetaInputSettings *settings,
|
||||
ClutterInputDevice *device,
|
||||
gboolean enabled);
|
||||
void (* set_tap_and_drag_lock_enabled) (MetaInputSettings *settings,
|
||||
ClutterInputDevice *device,
|
||||
gboolean enabled);
|
||||
void (* set_disable_while_typing) (MetaInputSettings *settings,
|
||||
ClutterInputDevice *device,
|
||||
gboolean enabled);
|
||||
|
@ -620,6 +620,36 @@ update_touchpad_tap_enabled (MetaInputSettings *input_settings,
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
update_touchpad_tap_button_map (MetaInputSettings *input_settings,
|
||||
ClutterInputDevice *device)
|
||||
{
|
||||
MetaInputSettingsClass *input_settings_class;
|
||||
GDesktopTouchpadTapButtonMap method;
|
||||
MetaInputSettingsPrivate *priv;
|
||||
|
||||
if (device &&
|
||||
clutter_input_device_get_device_type (device) != CLUTTER_TOUCHPAD_DEVICE)
|
||||
return;
|
||||
|
||||
priv = meta_input_settings_get_instance_private (input_settings);
|
||||
input_settings_class = META_INPUT_SETTINGS_GET_CLASS (input_settings);
|
||||
method = g_settings_get_enum (priv->touchpad_settings, "tap-button-map");
|
||||
|
||||
if (device)
|
||||
{
|
||||
settings_device_set_uint_setting (input_settings, device,
|
||||
input_settings_class->set_tap_button_map,
|
||||
method);
|
||||
}
|
||||
else
|
||||
{
|
||||
settings_set_uint_setting (input_settings, CLUTTER_TOUCHPAD_DEVICE,
|
||||
(ConfigUintFunc) input_settings_class->set_tap_button_map,
|
||||
method);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
update_touchpad_tap_and_drag_enabled (MetaInputSettings *input_settings,
|
||||
ClutterInputDevice *device)
|
||||
@ -652,6 +682,37 @@ update_touchpad_tap_and_drag_enabled (MetaInputSettings *input_settings,
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
update_touchpad_tap_and_drag_lock_enabled (MetaInputSettings *input_settings,
|
||||
ClutterInputDevice *device)
|
||||
{
|
||||
MetaInputSettingsClass *input_settings_class;
|
||||
MetaInputSettingsPrivate *priv;
|
||||
gboolean enabled;
|
||||
|
||||
if (device &&
|
||||
clutter_input_device_get_device_type (device) != CLUTTER_TOUCHPAD_DEVICE)
|
||||
return;
|
||||
|
||||
priv = meta_input_settings_get_instance_private (input_settings);
|
||||
input_settings_class = META_INPUT_SETTINGS_GET_CLASS (input_settings);
|
||||
enabled = g_settings_get_boolean (priv->touchpad_settings, "tap-and-drag-lock");
|
||||
|
||||
if (device)
|
||||
{
|
||||
settings_device_set_bool_setting (input_settings, device,
|
||||
input_settings_class->set_tap_and_drag_lock_enabled,
|
||||
enabled);
|
||||
}
|
||||
else
|
||||
{
|
||||
settings_set_bool_setting (input_settings, CLUTTER_TOUCHPAD_DEVICE,
|
||||
NULL,
|
||||
input_settings_class->set_tap_and_drag_lock_enabled,
|
||||
enabled);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
update_touchpad_edge_scroll (MetaInputSettings *input_settings,
|
||||
ClutterInputDevice *device)
|
||||
@ -1198,8 +1259,12 @@ meta_input_settings_changed_cb (GSettings *settings,
|
||||
update_device_natural_scroll (input_settings, NULL);
|
||||
else if (strcmp (key, "tap-to-click") == 0)
|
||||
update_touchpad_tap_enabled (input_settings, NULL);
|
||||
else if (strcmp (key, "tap-button-map") == 0)
|
||||
update_touchpad_tap_button_map (input_settings, NULL);
|
||||
else if (strcmp (key, "tap-and-drag") == 0)
|
||||
update_touchpad_tap_and_drag_enabled (input_settings, NULL);
|
||||
else if (strcmp (key, "tap-and-drag-lock") == 0)
|
||||
update_touchpad_tap_and_drag_lock_enabled (input_settings, NULL);
|
||||
else if (strcmp(key, "disable-while-typing") == 0)
|
||||
update_touchpad_disable_while_typing (input_settings, NULL);
|
||||
else if (strcmp (key, "send-events") == 0)
|
||||
@ -1700,7 +1765,9 @@ apply_device_settings (MetaInputSettings *input_settings,
|
||||
|
||||
update_touchpad_left_handed (input_settings, device);
|
||||
update_touchpad_tap_enabled (input_settings, device);
|
||||
update_touchpad_tap_button_map (input_settings, device);
|
||||
update_touchpad_tap_and_drag_enabled (input_settings, device);
|
||||
update_touchpad_tap_and_drag_lock_enabled (input_settings, device);
|
||||
update_touchpad_disable_while_typing (input_settings, device);
|
||||
update_touchpad_send_events (input_settings, device);
|
||||
update_touchpad_two_finger_scroll (input_settings, device);
|
||||
|
@ -140,6 +140,24 @@ meta_input_settings_native_set_tap_and_drag_enabled (MetaInputSettings *setting
|
||||
LIBINPUT_CONFIG_DRAG_DISABLED);
|
||||
}
|
||||
|
||||
static void
|
||||
meta_input_settings_native_set_tap_and_drag_lock_enabled (MetaInputSettings *settings,
|
||||
ClutterInputDevice *device,
|
||||
gboolean enabled)
|
||||
{
|
||||
struct libinput_device *libinput_device;
|
||||
|
||||
libinput_device = meta_input_device_native_get_libinput_device (device);
|
||||
if (!libinput_device)
|
||||
return;
|
||||
|
||||
if (libinput_device_config_tap_get_finger_count (libinput_device) > 0)
|
||||
libinput_device_config_tap_set_drag_lock_enabled (libinput_device,
|
||||
enabled ?
|
||||
LIBINPUT_CONFIG_DRAG_LOCK_ENABLED :
|
||||
LIBINPUT_CONFIG_DRAG_LOCK_DISABLED);
|
||||
}
|
||||
|
||||
static void
|
||||
meta_input_settings_native_set_disable_while_typing (MetaInputSettings *settings,
|
||||
ClutterInputDevice *device,
|
||||
@ -193,6 +211,15 @@ device_set_click_method (struct libinput_device *libinput_device,
|
||||
return status == LIBINPUT_CONFIG_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
device_set_tap_button_map (struct libinput_device *libinput_device,
|
||||
enum libinput_config_tap_button_map map)
|
||||
{
|
||||
enum libinput_config_status status =
|
||||
libinput_device_config_tap_set_button_map (libinput_device, map);
|
||||
return status == LIBINPUT_CONFIG_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
static void
|
||||
meta_input_settings_native_set_edge_scroll (MetaInputSettings *settings,
|
||||
ClutterInputDevice *device,
|
||||
@ -309,6 +336,40 @@ meta_input_settings_native_set_click_method (MetaInputSettings *settin
|
||||
device_set_click_method (libinput_device, click_method);
|
||||
}
|
||||
|
||||
static void
|
||||
meta_input_settings_native_set_tap_button_map (MetaInputSettings *settings,
|
||||
ClutterInputDevice *device,
|
||||
GDesktopTouchpadTapButtonMap mode)
|
||||
{
|
||||
enum libinput_config_tap_button_map button_map = 0;
|
||||
struct libinput_device *libinput_device;
|
||||
|
||||
libinput_device = meta_input_device_native_get_libinput_device (device);
|
||||
if (!libinput_device)
|
||||
return;
|
||||
|
||||
if (libinput_device_config_tap_get_finger_count (libinput_device) == 0)
|
||||
return;
|
||||
|
||||
switch (mode)
|
||||
{
|
||||
case G_DESKTOP_TOUCHPAD_BUTTON_TAP_MAP_DEFAULT:
|
||||
button_map = libinput_device_config_tap_get_default_button_map (libinput_device);
|
||||
break;
|
||||
case G_DESKTOP_TOUCHPAD_BUTTON_TAP_MAP_LRM:
|
||||
button_map = LIBINPUT_CONFIG_TAP_MAP_LRM;
|
||||
break;
|
||||
case G_DESKTOP_TOUCHPAD_BUTTON_TAP_MAP_LMR:
|
||||
button_map = LIBINPUT_CONFIG_TAP_MAP_LMR;
|
||||
break;
|
||||
default:
|
||||
g_assert_not_reached ();
|
||||
return;
|
||||
}
|
||||
|
||||
device_set_tap_button_map (libinput_device, button_map);
|
||||
}
|
||||
|
||||
static void
|
||||
meta_input_settings_native_set_keyboard_repeat (MetaInputSettings *settings,
|
||||
gboolean enabled,
|
||||
@ -633,7 +694,10 @@ meta_input_settings_native_class_init (MetaInputSettingsNativeClass *klass)
|
||||
input_settings_class->set_speed = meta_input_settings_native_set_speed;
|
||||
input_settings_class->set_left_handed = meta_input_settings_native_set_left_handed;
|
||||
input_settings_class->set_tap_enabled = meta_input_settings_native_set_tap_enabled;
|
||||
input_settings_class->set_tap_button_map = meta_input_settings_native_set_tap_button_map;
|
||||
input_settings_class->set_tap_and_drag_enabled = meta_input_settings_native_set_tap_and_drag_enabled;
|
||||
input_settings_class->set_tap_and_drag_lock_enabled =
|
||||
meta_input_settings_native_set_tap_and_drag_lock_enabled;
|
||||
input_settings_class->set_invert_scroll = meta_input_settings_native_set_invert_scroll;
|
||||
input_settings_class->set_edge_scroll = meta_input_settings_native_set_edge_scroll;
|
||||
input_settings_class->set_two_finger_scroll = meta_input_settings_native_set_two_finger_scroll;
|
||||
|
@ -289,6 +289,17 @@ meta_input_settings_x11_set_tap_and_drag_enabled (MetaInputSettings *settings,
|
||||
XA_INTEGER, 8, &value, 1);
|
||||
}
|
||||
|
||||
static void
|
||||
meta_input_settings_x11_set_tap_and_drag_lock_enabled (MetaInputSettings *settings,
|
||||
ClutterInputDevice *device,
|
||||
gboolean enabled)
|
||||
{
|
||||
guchar value = (enabled) ? 1 : 0;
|
||||
|
||||
change_property (device, "libinput Tapping Drag Lock Enabled",
|
||||
XA_INTEGER, 8, &value, 1);
|
||||
}
|
||||
|
||||
static void
|
||||
meta_input_settings_x11_set_invert_scroll (MetaInputSettings *settings,
|
||||
ClutterInputDevice *device,
|
||||
@ -429,6 +440,40 @@ meta_input_settings_x11_set_click_method (MetaInputSettings *settings,
|
||||
meta_XFree(available);
|
||||
}
|
||||
|
||||
static void
|
||||
meta_input_settings_x11_set_tap_button_map (MetaInputSettings *settings,
|
||||
ClutterInputDevice *device,
|
||||
GDesktopTouchpadTapButtonMap mode)
|
||||
{
|
||||
guchar values[2] = { 0 }; /* lrm, lmr */
|
||||
guchar *defaults;
|
||||
|
||||
switch (mode)
|
||||
{
|
||||
case G_DESKTOP_TOUCHPAD_BUTTON_TAP_MAP_DEFAULT:
|
||||
defaults = get_property (device, "libinput Tapping Button Mapping Default",
|
||||
XA_INTEGER, 8, 2);
|
||||
if (!defaults)
|
||||
break;
|
||||
memcpy (values, defaults, 2);
|
||||
meta_XFree (defaults);
|
||||
break;
|
||||
case G_DESKTOP_TOUCHPAD_BUTTON_TAP_MAP_LRM:
|
||||
values[0] = 1;
|
||||
break;
|
||||
case G_DESKTOP_TOUCHPAD_BUTTON_TAP_MAP_LMR:
|
||||
values[1] = 1;
|
||||
break;
|
||||
default:
|
||||
g_assert_not_reached ();
|
||||
return;
|
||||
}
|
||||
|
||||
if (values[0] || values[1])
|
||||
change_property (device, "libinput Tapping Button Mapping Enabled",
|
||||
XA_INTEGER, 8, &values, 2);
|
||||
}
|
||||
|
||||
static void
|
||||
meta_input_settings_x11_set_keyboard_repeat (MetaInputSettings *settings,
|
||||
gboolean enabled,
|
||||
@ -894,7 +939,10 @@ meta_input_settings_x11_class_init (MetaInputSettingsX11Class *klass)
|
||||
input_settings_class->set_speed = meta_input_settings_x11_set_speed;
|
||||
input_settings_class->set_left_handed = meta_input_settings_x11_set_left_handed;
|
||||
input_settings_class->set_tap_enabled = meta_input_settings_x11_set_tap_enabled;
|
||||
input_settings_class->set_tap_button_map = meta_input_settings_x11_set_tap_button_map;
|
||||
input_settings_class->set_tap_and_drag_enabled = meta_input_settings_x11_set_tap_and_drag_enabled;
|
||||
input_settings_class->set_tap_and_drag_lock_enabled =
|
||||
meta_input_settings_x11_set_tap_and_drag_lock_enabled;
|
||||
input_settings_class->set_disable_while_typing = meta_input_settings_x11_set_disable_while_typing;
|
||||
input_settings_class->set_invert_scroll = meta_input_settings_x11_set_invert_scroll;
|
||||
input_settings_class->set_edge_scroll = meta_input_settings_x11_set_edge_scroll;
|
||||
|
Loading…
Reference in New Issue
Block a user