diff options
author | Rui Matos <tiagomatos@gmail.com> | 2017-02-13 14:06:35 +0100 |
---|---|---|
committer | Rui Matos <tiagomatos@gmail.com> | 2017-02-16 16:49:44 +0100 |
commit | 90923903ae8be5ba66143bc17036884a3825050a (patch) | |
tree | b70427046304e1fe56721b6364016719c1fbb6bd /src/backends | |
parent | 191525cdb4a148217aad77f60438fe1096213186 (diff) | |
download | mutter-90923903ae8be5ba66143bc17036884a3825050a.tar.gz |
MetaInputSettings: allow edge scrolling without 2fg capable devices
We should only force edge scrolling off if two finger is enabled *and*
we actually have two finger capable devices.
https://bugzilla.gnome.org/show_bug.cgi?id=778554
Diffstat (limited to 'src/backends')
-rw-r--r-- | src/backends/meta-input-settings-private.h | 3 | ||||
-rw-r--r-- | src/backends/meta-input-settings.c | 40 | ||||
-rw-r--r-- | src/backends/native/meta-input-settings-native.c | 15 | ||||
-rw-r--r-- | src/backends/x11/meta-input-settings-x11.c | 18 |
4 files changed, 75 insertions, 1 deletions
diff --git a/src/backends/meta-input-settings-private.h b/src/backends/meta-input-settings-private.h index 18eeb3a51..84c2a13bc 100644 --- a/src/backends/meta-input-settings-private.h +++ b/src/backends/meta-input-settings-private.h @@ -117,6 +117,9 @@ struct _MetaInputSettingsClass ClutterInputDeviceTool *tool, GDesktopStylusButtonAction primary, GDesktopStylusButtonAction secondary); + + gboolean (* has_two_finger_scroll) (MetaInputSettings *settings, + ClutterInputDevice *device); }; GType meta_input_settings_get_type (void) G_GNUC_CONST; diff --git a/src/backends/meta-input-settings.c b/src/backends/meta-input-settings.c index bd3d84848..e0c892603 100644 --- a/src/backends/meta-input-settings.c +++ b/src/backends/meta-input-settings.c @@ -74,6 +74,8 @@ struct _MetaInputSettingsPrivate #ifdef HAVE_LIBWACOM WacomDeviceDatabase *wacom_db; #endif + + GHashTable *two_finger_devices; }; typedef void (*ConfigBoolFunc) (MetaInputSettings *input_settings, @@ -141,6 +143,8 @@ meta_input_settings_dispose (GObject *object) libwacom_database_destroy (priv->wacom_db); #endif + g_clear_pointer (&priv->two_finger_devices, g_hash_table_destroy); + G_OBJECT_CLASS (meta_input_settings_parent_class)->dispose (object); } @@ -477,6 +481,7 @@ update_touchpad_edge_scroll (MetaInputSettings *input_settings, MetaInputSettingsClass *input_settings_class; gboolean edge_scroll_enabled; gboolean two_finger_scroll_enabled; + gboolean two_finger_scroll_available; MetaInputSettingsPrivate *priv; if (device && @@ -487,9 +492,10 @@ update_touchpad_edge_scroll (MetaInputSettings *input_settings, input_settings_class = META_INPUT_SETTINGS_GET_CLASS (input_settings); edge_scroll_enabled = g_settings_get_boolean (priv->touchpad_settings, "edge-scrolling-enabled"); two_finger_scroll_enabled = g_settings_get_boolean (priv->touchpad_settings, "two-finger-scrolling-enabled"); + two_finger_scroll_available = g_hash_table_size (priv->two_finger_devices) > 0; /* If both are enabled we prefer two finger. */ - if (edge_scroll_enabled && two_finger_scroll_enabled) + if (edge_scroll_enabled && two_finger_scroll_enabled && two_finger_scroll_available) edge_scroll_enabled = FALSE; if (device) @@ -1269,6 +1275,23 @@ apply_stylus_settings (MetaInputSettings *input_settings, } static void +evaluate_two_finger_scrolling (MetaInputSettings *input_settings, + ClutterInputDevice *device) +{ + MetaInputSettingsClass *klass; + MetaInputSettingsPrivate *priv; + + if (clutter_input_device_get_device_type (device) != CLUTTER_TOUCHPAD_DEVICE) + return; + + klass = META_INPUT_SETTINGS_GET_CLASS (input_settings); + priv = meta_input_settings_get_instance_private (input_settings); + + if (klass->has_two_finger_scroll (input_settings, device)) + g_hash_table_add (priv->two_finger_devices, device); +} + +static void meta_input_settings_device_added (ClutterDeviceManager *device_manager, ClutterInputDevice *device, MetaInputSettings *input_settings) @@ -1276,6 +1299,8 @@ meta_input_settings_device_added (ClutterDeviceManager *device_manager, if (clutter_input_device_get_device_mode (device) == CLUTTER_INPUT_MODE_MASTER) return; + evaluate_two_finger_scrolling (input_settings, device); + apply_device_settings (input_settings, device); check_add_mappable_device (input_settings, device); } @@ -1289,6 +1314,10 @@ meta_input_settings_device_removed (ClutterDeviceManager *device_manager, priv = meta_input_settings_get_instance_private (input_settings); g_hash_table_remove (priv->mappable_devices, device); + + if (g_hash_table_remove (priv->two_finger_devices, device) && + g_hash_table_size (priv->two_finger_devices) == 0) + apply_device_settings (input_settings, NULL); } static void @@ -1327,6 +1356,13 @@ static void meta_input_settings_constructed (GObject *object) { MetaInputSettings *input_settings = META_INPUT_SETTINGS (object); + GSList *devices, *d; + + devices = meta_input_settings_get_devices (input_settings, CLUTTER_TOUCHPAD_DEVICE); + for (d = devices; d; d = d->next) + evaluate_two_finger_scrolling (input_settings, d->data); + + g_slist_free (devices); apply_device_settings (input_settings, NULL); update_keyboard_repeat (input_settings); @@ -1390,6 +1426,8 @@ meta_input_settings_init (MetaInputSettings *settings) "expect tablets to misbehave"); } #endif + + priv->two_finger_devices = g_hash_table_new (NULL, NULL); } MetaInputSettings * diff --git a/src/backends/native/meta-input-settings-native.c b/src/backends/native/meta-input-settings-native.c index d26d01d6a..98a86bd8e 100644 --- a/src/backends/native/meta-input-settings-native.c +++ b/src/backends/native/meta-input-settings-native.c @@ -188,6 +188,19 @@ meta_input_settings_native_set_two_finger_scroll (MetaInputSettings * device_set_scroll_method (libinput_device, current | method); } +static gboolean +meta_input_settings_native_has_two_finger_scroll (MetaInputSettings *settings, + ClutterInputDevice *device) +{ + struct libinput_device *libinput_device; + + libinput_device = clutter_evdev_input_device_get_libinput_device (device); + if (!libinput_device) + return FALSE; + + return libinput_device_config_scroll_get_methods (libinput_device) & LIBINPUT_CONFIG_SCROLL_2FG; +} + static void meta_input_settings_native_set_scroll_button (MetaInputSettings *settings, ClutterInputDevice *device, @@ -503,6 +516,8 @@ meta_input_settings_native_class_init (MetaInputSettingsNativeClass *klass) input_settings_class->set_stylus_pressure = meta_input_settings_native_set_stylus_pressure; input_settings_class->set_stylus_button_map = meta_input_settings_native_set_stylus_button_map; + + input_settings_class->has_two_finger_scroll = meta_input_settings_native_has_two_finger_scroll; } static void diff --git a/src/backends/x11/meta-input-settings-x11.c b/src/backends/x11/meta-input-settings-x11.c index 3fc0d2c0e..a2c173193 100644 --- a/src/backends/x11/meta-input-settings-x11.c +++ b/src/backends/x11/meta-input-settings-x11.c @@ -284,6 +284,22 @@ meta_input_settings_x11_set_two_finger_scroll (MetaInputSettings *set meta_XFree (available); } +static gboolean +meta_input_settings_x11_has_two_finger_scroll (MetaInputSettings *settings, + ClutterInputDevice *device) +{ + guchar *available = NULL; + gboolean has_two_finger = TRUE; + + available = get_property (device, "libinput Scroll Methods Available", + XA_INTEGER, 8, SCROLL_METHOD_NUM_FIELDS); + if (!available || !available[SCROLL_METHOD_FIELD_2FG]) + has_two_finger = FALSE; + + meta_XFree (available); + return has_two_finger; +} + static void meta_input_settings_x11_set_scroll_button (MetaInputSettings *settings, ClutterInputDevice *device, @@ -743,6 +759,8 @@ meta_input_settings_x11_class_init (MetaInputSettingsX11Class *klass) input_settings_class->set_stylus_pressure = meta_input_settings_x11_set_stylus_pressure; input_settings_class->set_stylus_button_map = meta_input_settings_x11_set_stylus_button_map; + + input_settings_class->has_two_finger_scroll = meta_input_settings_x11_has_two_finger_scroll; } static void |