mirror of
https://github.com/brl/mutter.git
synced 2024-11-27 18:40:40 -05:00
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
1d24f612cc
commit
443250a9f7
@ -107,6 +107,9 @@ struct _MetaInputSettingsClass
|
||||
void (* set_trackball_accel_profile) (MetaInputSettings *settings,
|
||||
ClutterInputDevice *device,
|
||||
GDesktopPointerAccelProfile profile);
|
||||
|
||||
gboolean (* has_two_finger_scroll) (MetaInputSettings *settings,
|
||||
ClutterInputDevice *device);
|
||||
};
|
||||
|
||||
GType meta_input_settings_get_type (void) G_GNUC_CONST;
|
||||
|
@ -83,6 +83,8 @@ struct _MetaInputSettingsPrivate
|
||||
#ifdef HAVE_LIBWACOM
|
||||
WacomDeviceDatabase *wacom_db;
|
||||
#endif
|
||||
|
||||
GHashTable *two_finger_devices;
|
||||
};
|
||||
|
||||
typedef void (*ConfigBoolFunc) (MetaInputSettings *input_settings,
|
||||
@ -148,6 +150,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);
|
||||
}
|
||||
|
||||
@ -484,6 +488,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 &&
|
||||
@ -494,9 +499,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)
|
||||
@ -1409,6 +1415,23 @@ apply_device_settings (MetaInputSettings *input_settings,
|
||||
device);
|
||||
}
|
||||
|
||||
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,
|
||||
@ -1417,6 +1440,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);
|
||||
}
|
||||
@ -1430,6 +1455,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
|
||||
@ -1456,6 +1485,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);
|
||||
@ -1517,6 +1553,8 @@ meta_input_settings_init (MetaInputSettings *settings)
|
||||
"expect tablets to misbehave");
|
||||
}
|
||||
#endif
|
||||
|
||||
priv->two_finger_devices = g_hash_table_new (NULL, NULL);
|
||||
}
|
||||
|
||||
MetaInputSettings *
|
||||
|
@ -189,6 +189,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,
|
||||
@ -418,6 +431,8 @@ meta_input_settings_native_class_init (MetaInputSettingsNativeClass *klass)
|
||||
|
||||
input_settings_class->set_mouse_accel_profile = meta_input_settings_native_set_mouse_accel_profile;
|
||||
input_settings_class->set_trackball_accel_profile = meta_input_settings_native_set_trackball_accel_profile;
|
||||
|
||||
input_settings_class->has_two_finger_scroll = meta_input_settings_native_has_two_finger_scroll;
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -274,6 +274,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,
|
||||
@ -543,6 +559,8 @@ meta_input_settings_x11_class_init (MetaInputSettingsX11Class *klass)
|
||||
|
||||
input_settings_class->set_mouse_accel_profile = meta_input_settings_x11_set_mouse_accel_profile;
|
||||
input_settings_class->set_trackball_accel_profile = meta_input_settings_x11_set_trackball_accel_profile;
|
||||
|
||||
input_settings_class->has_two_finger_scroll = meta_input_settings_x11_has_two_finger_scroll;
|
||||
}
|
||||
|
||||
static void
|
||||
|
Loading…
Reference in New Issue
Block a user