From 0742170062b99f64de6cfaf04700ddecf4d49f36 Mon Sep 17 00:00:00 2001 From: Evan Goode Date: Tue, 6 Sep 2022 13:15:42 -0400 Subject: [PATCH] Support selecting an acceleration profile for touchpad devices Signed-off-by: Evan Goode Part-of: --- src/backends/meta-input-settings-dummy.c | 9 +++++++++ src/backends/meta-input-settings-private.h | 3 +++ src/backends/meta-input-settings.c | 6 ++++++ src/backends/native/meta-input-settings-native.c | 15 +++++++++++++++ src/backends/x11/meta-input-settings-x11.c | 15 +++++++++++++++ 5 files changed, 48 insertions(+) diff --git a/src/backends/meta-input-settings-dummy.c b/src/backends/meta-input-settings-dummy.c index 4da354668..eecd3cc37 100644 --- a/src/backends/meta-input-settings-dummy.c +++ b/src/backends/meta-input-settings-dummy.c @@ -167,6 +167,13 @@ meta_input_settings_dummy_set_mouse_accel_profile (MetaInputSettings * { } +static void +meta_input_settings_dummy_set_touchpad_accel_profile (MetaInputSettings *settings, + ClutterInputDevice *device, + GDesktopPointerAccelProfile profile) +{ +} + static void meta_input_settings_dummy_set_trackball_accel_profile (MetaInputSettings *settings, ClutterInputDevice *device, @@ -270,6 +277,8 @@ meta_input_settings_dummy_class_init (MetaInputSettingsDummyClass *klass) meta_input_settings_dummy_set_tablet_area; input_settings_class->set_mouse_accel_profile = meta_input_settings_dummy_set_mouse_accel_profile; + input_settings_class->set_touchpad_accel_profile = + meta_input_settings_dummy_set_touchpad_accel_profile; input_settings_class->set_trackball_accel_profile = meta_input_settings_dummy_set_trackball_accel_profile; input_settings_class->set_stylus_pressure = diff --git a/src/backends/meta-input-settings-private.h b/src/backends/meta-input-settings-private.h index d67f7f298..423744fb3 100644 --- a/src/backends/meta-input-settings-private.h +++ b/src/backends/meta-input-settings-private.h @@ -124,6 +124,9 @@ struct _MetaInputSettingsClass void (* set_mouse_accel_profile) (MetaInputSettings *settings, ClutterInputDevice *device, GDesktopPointerAccelProfile profile); + void (* set_touchpad_accel_profile) (MetaInputSettings *settings, + ClutterInputDevice *device, + GDesktopPointerAccelProfile profile); void (* set_trackball_accel_profile) (MetaInputSettings *settings, ClutterInputDevice *device, GDesktopPointerAccelProfile profile); diff --git a/src/backends/meta-input-settings.c b/src/backends/meta-input-settings.c index e763433f7..b606006eb 100644 --- a/src/backends/meta-input-settings.c +++ b/src/backends/meta-input-settings.c @@ -388,6 +388,10 @@ do_update_pointer_accel_profile (MetaInputSettings *input_settings, input_settings_class->set_mouse_accel_profile (input_settings, device, profile); + else if (settings == priv->touchpad_settings) + input_settings_class->set_touchpad_accel_profile (input_settings, + device, + profile); else if (settings == priv->trackball_settings) input_settings_class->set_trackball_accel_profile (input_settings, device, @@ -1184,6 +1188,8 @@ meta_input_settings_changed_cb (GSettings *settings, update_device_speed (input_settings, NULL); else if (strcmp (key, "natural-scroll") == 0) update_device_natural_scroll (input_settings, NULL); + else if (strcmp (key, "accel-profile") == 0) + update_pointer_accel_profile (input_settings, 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) diff --git a/src/backends/native/meta-input-settings-native.c b/src/backends/native/meta-input-settings-native.c index 7fbe49f88..0c3719e0f 100644 --- a/src/backends/native/meta-input-settings-native.c +++ b/src/backends/native/meta-input-settings-native.c @@ -554,12 +554,26 @@ meta_input_settings_native_set_mouse_accel_profile (MetaInputSettings * return; if ((caps & (CLUTTER_INPUT_CAPABILITY_TRACKBALL | + CLUTTER_INPUT_CAPABILITY_TOUCHPAD | CLUTTER_INPUT_CAPABILITY_TRACKPOINT)) != 0) return; set_device_accel_profile (device, profile); } +static void +meta_input_settings_native_set_touchpad_accel_profile (MetaInputSettings *settings, + ClutterInputDevice *device, + GDesktopPointerAccelProfile profile) +{ + ClutterInputCapabilities caps = clutter_input_device_get_capabilities (device); + + if ((caps & CLUTTER_INPUT_CAPABILITY_TOUCHPAD) == 0) + return; + + set_device_accel_profile (device, profile); +} + static void meta_input_settings_native_set_trackball_accel_profile (MetaInputSettings *settings, ClutterInputDevice *device, @@ -800,6 +814,7 @@ meta_input_settings_native_class_init (MetaInputSettingsNativeClass *klass) input_settings_class->set_tablet_area = meta_input_settings_native_set_tablet_area; input_settings_class->set_mouse_accel_profile = meta_input_settings_native_set_mouse_accel_profile; + input_settings_class->set_touchpad_accel_profile = meta_input_settings_native_set_touchpad_accel_profile; input_settings_class->set_trackball_accel_profile = meta_input_settings_native_set_trackball_accel_profile; input_settings_class->set_stylus_pressure = meta_input_settings_native_set_stylus_pressure; diff --git a/src/backends/x11/meta-input-settings-x11.c b/src/backends/x11/meta-input-settings-x11.c index d9338f8ad..402235159 100644 --- a/src/backends/x11/meta-input-settings-x11.c +++ b/src/backends/x11/meta-input-settings-x11.c @@ -569,12 +569,26 @@ meta_input_settings_x11_set_mouse_accel_profile (MetaInputSettings *set return; if ((caps & (CLUTTER_INPUT_CAPABILITY_TRACKBALL | + CLUTTER_INPUT_CAPABILITY_TOUCHPAD | CLUTTER_INPUT_CAPABILITY_TRACKPOINT)) != 0) return; set_device_accel_profile (settings, device, profile); } +static void +meta_input_settings_x11_set_touchpad_accel_profile (MetaInputSettings *settings, + ClutterInputDevice *device, + GDesktopPointerAccelProfile profile) +{ + ClutterInputCapabilities caps = clutter_input_device_get_capabilities (device); + + if ((caps & CLUTTER_INPUT_CAPABILITY_TOUCHPAD) == 0) + return; + + set_device_accel_profile (settings, device, profile); +} + static void meta_input_settings_x11_set_trackball_accel_profile (MetaInputSettings *settings, ClutterInputDevice *device, @@ -873,6 +887,7 @@ meta_input_settings_x11_class_init (MetaInputSettingsX11Class *klass) input_settings_class->set_tablet_area = meta_input_settings_x11_set_tablet_area; input_settings_class->set_mouse_accel_profile = meta_input_settings_x11_set_mouse_accel_profile; + input_settings_class->set_touchpad_accel_profile = meta_input_settings_x11_set_touchpad_accel_profile; input_settings_class->set_trackball_accel_profile = meta_input_settings_x11_set_trackball_accel_profile; input_settings_class->set_stylus_pressure = meta_input_settings_x11_set_stylus_pressure;