[gnome-settings-daemon] mouse: Don't apply any settings if XInput isn't present



commit 4d6ecb300358fcef4310a7f696a032d8a0afb80e
Author: Bastien Nocera <hadess hadess net>
Date:   Mon Mar 21 10:18:32 2011 +0000

    mouse: Don't apply any settings if XInput isn't present
    
    We pretty much rely on XInput being present on a modern
    desktop, and so do the graphical front-ends.

 plugins/common/gsd-input-helper.c |    2 +-
 plugins/common/gsd-input-helper.h |    9 +++--
 plugins/mouse/gsd-mouse-manager.c |   71 ++++--------------------------------
 3 files changed, 14 insertions(+), 68 deletions(-)
---
diff --git a/plugins/common/gsd-input-helper.c b/plugins/common/gsd-input-helper.c
index d8bae69..2742a9f 100644
--- a/plugins/common/gsd-input-helper.c
+++ b/plugins/common/gsd-input-helper.c
@@ -31,7 +31,7 @@
 #define INPUT_DEVICES_SCHEMA "org.gnome.settings-daemon.peripherals.input-devices"
 #define KEY_HOTPLUG_COMMAND  "hotplug-command"
 
-static gboolean
+gboolean
 supports_xinput_devices (void)
 {
         gint op_code, event, error;
diff --git a/plugins/common/gsd-input-helper.h b/plugins/common/gsd-input-helper.h
index eb3cd8a..6498dd2 100644
--- a/plugins/common/gsd-input-helper.h
+++ b/plugins/common/gsd-input-helper.h
@@ -33,11 +33,12 @@ typedef enum {
 	COMMAND_DEVICE_PRESENT
 } CustomCommand;
 
-XDevice * device_is_touchpad  (XDeviceInfo deviceinfo);
-gboolean  touchpad_is_present (void);
+gboolean  supports_xinput_devices (void);
+XDevice  *device_is_touchpad      (XDeviceInfo deviceinfo);
+gboolean  touchpad_is_present     (void);
 
-gboolean  run_custom_command  (GdkDevice              *device,
-			       CustomCommand           command);
+gboolean  run_custom_command      (GdkDevice              *device,
+			           CustomCommand           command);
 
 G_END_DECLS
 
diff --git a/plugins/mouse/gsd-mouse-manager.c b/plugins/mouse/gsd-mouse-manager.c
index 376d9e2..70d03ae 100644
--- a/plugins/mouse/gsd-mouse-manager.c
+++ b/plugins/mouse/gsd-mouse-manager.c
@@ -158,19 +158,6 @@ gsd_mouse_manager_class_init (GsdMouseManagerClass *klass)
         g_type_class_add_private (klass, sizeof (GsdMouseManagerPrivate));
 }
 
-
-static gboolean
-supports_xinput_devices (void)
-{
-        gint op_code, event, error;
-
-        return XQueryExtension (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()),
-                                "XInputExtension",
-                                &op_code,
-                                &event,
-                                &error);
-}
-
 static void
 configure_button_layout (guchar   *buttons,
                          gint      n_buttons,
@@ -281,9 +268,9 @@ touchpad_has_single_button (XDevice *device)
 
 
 static void
-set_xinput_devices_left_handed (GsdMouseManager *manager,
-                                gboolean mouse_left_handed,
-                                gboolean touchpad_left_handed)
+set_left_handed (GsdMouseManager *manager,
+                 gboolean mouse_left_handed,
+                 gboolean touchpad_left_handed)
 {
         XDeviceInfo *device_info;
         gint n_devices;
@@ -384,53 +371,6 @@ set_devicepresence_handler (GsdMouseManager *manager)
         manager->priv->device_manager = device_manager;
 }
 
-static void
-set_left_handed (GsdMouseManager *manager,
-                 gboolean         mouse_left_handed,
-                 gboolean         touchpad_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,
-                                                mouse_left_handed,
-                                                touchpad_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, mouse_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 XDevice *
 device_open (XDeviceInfo deviceinfo)
 {
@@ -1073,6 +1013,11 @@ gsd_mouse_manager_start (GsdMouseManager *manager,
 {
         gnome_settings_profile_start (NULL);
 
+        if (!supports_xinput_devices ()) {
+                g_debug ("XInput is not supported, not applying any settings");
+                return TRUE;
+        }
+
         manager->priv->start_idle_id = g_idle_add ((GSourceFunc) gsd_mouse_manager_idle_cb, manager);
 
         gnome_settings_profile_end (NULL);



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]