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
This commit is contained in:
parent
191525cdb4
commit
90923903ae
@ -117,6 +117,9 @@ struct _MetaInputSettingsClass
|
|||||||
ClutterInputDeviceTool *tool,
|
ClutterInputDeviceTool *tool,
|
||||||
GDesktopStylusButtonAction primary,
|
GDesktopStylusButtonAction primary,
|
||||||
GDesktopStylusButtonAction secondary);
|
GDesktopStylusButtonAction secondary);
|
||||||
|
|
||||||
|
gboolean (* has_two_finger_scroll) (MetaInputSettings *settings,
|
||||||
|
ClutterInputDevice *device);
|
||||||
};
|
};
|
||||||
|
|
||||||
GType meta_input_settings_get_type (void) G_GNUC_CONST;
|
GType meta_input_settings_get_type (void) G_GNUC_CONST;
|
||||||
|
@ -74,6 +74,8 @@ struct _MetaInputSettingsPrivate
|
|||||||
#ifdef HAVE_LIBWACOM
|
#ifdef HAVE_LIBWACOM
|
||||||
WacomDeviceDatabase *wacom_db;
|
WacomDeviceDatabase *wacom_db;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
GHashTable *two_finger_devices;
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef void (*ConfigBoolFunc) (MetaInputSettings *input_settings,
|
typedef void (*ConfigBoolFunc) (MetaInputSettings *input_settings,
|
||||||
@ -141,6 +143,8 @@ meta_input_settings_dispose (GObject *object)
|
|||||||
libwacom_database_destroy (priv->wacom_db);
|
libwacom_database_destroy (priv->wacom_db);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
g_clear_pointer (&priv->two_finger_devices, g_hash_table_destroy);
|
||||||
|
|
||||||
G_OBJECT_CLASS (meta_input_settings_parent_class)->dispose (object);
|
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;
|
MetaInputSettingsClass *input_settings_class;
|
||||||
gboolean edge_scroll_enabled;
|
gboolean edge_scroll_enabled;
|
||||||
gboolean two_finger_scroll_enabled;
|
gboolean two_finger_scroll_enabled;
|
||||||
|
gboolean two_finger_scroll_available;
|
||||||
MetaInputSettingsPrivate *priv;
|
MetaInputSettingsPrivate *priv;
|
||||||
|
|
||||||
if (device &&
|
if (device &&
|
||||||
@ -487,9 +492,10 @@ update_touchpad_edge_scroll (MetaInputSettings *input_settings,
|
|||||||
input_settings_class = META_INPUT_SETTINGS_GET_CLASS (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");
|
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_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 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;
|
edge_scroll_enabled = FALSE;
|
||||||
|
|
||||||
if (device)
|
if (device)
|
||||||
@ -1268,6 +1274,23 @@ apply_stylus_settings (MetaInputSettings *input_settings,
|
|||||||
update_stylus_buttonmap (input_settings, device, tool);
|
update_stylus_buttonmap (input_settings, device, tool);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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
|
static void
|
||||||
meta_input_settings_device_added (ClutterDeviceManager *device_manager,
|
meta_input_settings_device_added (ClutterDeviceManager *device_manager,
|
||||||
ClutterInputDevice *device,
|
ClutterInputDevice *device,
|
||||||
@ -1276,6 +1299,8 @@ meta_input_settings_device_added (ClutterDeviceManager *device_manager,
|
|||||||
if (clutter_input_device_get_device_mode (device) == CLUTTER_INPUT_MODE_MASTER)
|
if (clutter_input_device_get_device_mode (device) == CLUTTER_INPUT_MODE_MASTER)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
evaluate_two_finger_scrolling (input_settings, device);
|
||||||
|
|
||||||
apply_device_settings (input_settings, device);
|
apply_device_settings (input_settings, device);
|
||||||
check_add_mappable_device (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);
|
priv = meta_input_settings_get_instance_private (input_settings);
|
||||||
g_hash_table_remove (priv->mappable_devices, device);
|
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
|
static void
|
||||||
@ -1327,6 +1356,13 @@ static void
|
|||||||
meta_input_settings_constructed (GObject *object)
|
meta_input_settings_constructed (GObject *object)
|
||||||
{
|
{
|
||||||
MetaInputSettings *input_settings = META_INPUT_SETTINGS (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);
|
apply_device_settings (input_settings, NULL);
|
||||||
update_keyboard_repeat (input_settings);
|
update_keyboard_repeat (input_settings);
|
||||||
@ -1390,6 +1426,8 @@ meta_input_settings_init (MetaInputSettings *settings)
|
|||||||
"expect tablets to misbehave");
|
"expect tablets to misbehave");
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
priv->two_finger_devices = g_hash_table_new (NULL, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
MetaInputSettings *
|
MetaInputSettings *
|
||||||
|
@ -188,6 +188,19 @@ meta_input_settings_native_set_two_finger_scroll (MetaInputSettings *
|
|||||||
device_set_scroll_method (libinput_device, current | method);
|
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
|
static void
|
||||||
meta_input_settings_native_set_scroll_button (MetaInputSettings *settings,
|
meta_input_settings_native_set_scroll_button (MetaInputSettings *settings,
|
||||||
ClutterInputDevice *device,
|
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_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->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
|
static void
|
||||||
|
@ -284,6 +284,22 @@ meta_input_settings_x11_set_two_finger_scroll (MetaInputSettings *set
|
|||||||
meta_XFree (available);
|
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
|
static void
|
||||||
meta_input_settings_x11_set_scroll_button (MetaInputSettings *settings,
|
meta_input_settings_x11_set_scroll_button (MetaInputSettings *settings,
|
||||||
ClutterInputDevice *device,
|
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_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->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
|
static void
|
||||||
|
Loading…
Reference in New Issue
Block a user