From ef230c73fb5133ca37c60b185268ab4ddfa2635c Mon Sep 17 00:00:00 2001 From: monsta Date: Wed, 26 Oct 2016 16:47:59 +0300 Subject: mouse: don't apply any settings if XInput isn't present and drop some fallback code as well adapted from: https://git.gnome.org/browse/gnome-settings-daemon/commit/?id=4d6ecb300358fcef4310a7f696a032d8a0afb80e https://git.gnome.org/browse/gnome-settings-daemon/commit/?id=3a244a490df4453c41469d8eeb789d96412f80b1 --- plugins/mouse/msd-mouse-manager.c | 55 +++++---------------------------------- 1 file changed, 6 insertions(+), 49 deletions(-) (limited to 'plugins/mouse') diff --git a/plugins/mouse/msd-mouse-manager.c b/plugins/mouse/msd-mouse-manager.c index 4399a51..f91623a 100644 --- a/plugins/mouse/msd-mouse-manager.c +++ b/plugins/mouse/msd-mouse-manager.c @@ -227,9 +227,8 @@ touchpad_has_single_button (XDevice *device) return is_single_button; } - static void -set_xinput_devices_left_handed (MsdMouseManager * manager, gboolean left_handed) +set_left_handed (MsdMouseManager * manager, gboolean left_handed) { XDeviceInfo *device_info; gint n_devices; @@ -331,9 +330,6 @@ set_devicepresence_handler (MsdMouseManager *manager) XEventClass class_presence; int xi_presence; - if (!supports_xinput_devices ()) - return; - display = gdk_x11_get_default_xdisplay (); gdk_error_trap_push (); @@ -347,50 +343,6 @@ set_devicepresence_handler (MsdMouseManager *manager) gdk_window_add_filter (NULL, devicepresence_filter, manager); } -static void -set_left_handed (MsdMouseManager *manager, - gboolean left_handed) -{ - guchar *buttons ; - gsize buttons_capacity = 16; - gint n_buttons, i; - - if (supports_xinput_devices ()) { - /* When XInput support is available, never set the - * button ordering on the core pointer as that would - * revert the changes we make on the devices themselves */ - set_xinput_devices_left_handed (manager, left_handed); - return; - } - - buttons = g_new (guchar, buttons_capacity); - n_buttons = XGetPointerMapping (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()), - buttons, - (gint) buttons_capacity); - while (n_buttons > buttons_capacity) { - buttons_capacity = n_buttons; - buttons = (guchar *) g_realloc (buttons, - buttons_capacity * sizeof (guchar)); - - n_buttons = XGetPointerMapping (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()), - buttons, - (gint) buttons_capacity); - } - - configure_button_layout (buttons, n_buttons, left_handed); - - /* X refuses to change the mapping while buttons are engaged, - * so if this is the case we'll retry a few times - */ - for (i = 0; - i < 20 && XSetPointerMapping (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()), buttons, n_buttons) == MappingBusy; - ++i) { - g_usleep (300); - } - - g_free (buttons); -} - static void set_motion_acceleration (MsdMouseManager *manager, gfloat motion_acceleration) @@ -1025,6 +977,11 @@ msd_mouse_manager_start (MsdMouseManager *manager, { mate_settings_profile_start (NULL); + if (!supports_xinput_devices ()) { + g_debug ("XInput is not supported, not applying any settings"); + return TRUE; + } + g_idle_add ((GSourceFunc) msd_mouse_manager_idle_cb, manager); mate_settings_profile_end (NULL); -- cgit v1.2.1