[gnome-control-center] common: Update from gnome-settings-daemon



commit d98d42880de420b8a1ee1f5a3cf7102f42de435b
Author: Bastien Nocera <hadess hadess net>
Date:   Thu Dec 17 15:41:46 2015 +0100

    common: Update from gnome-settings-daemon

 panels/common/gsd-device-manager-x11.c |    6 +-
 panels/common/gsd-device-manager.c     |   10 +
 panels/common/gsd-device-manager.h     |    2 +
 panels/common/gsd-input-helper.c       |  282 --------------------------------
 panels/common/gsd-input-helper.h       |   21 ---
 5 files changed, 17 insertions(+), 304 deletions(-)
---
diff --git a/panels/common/gsd-device-manager-x11.c b/panels/common/gsd-device-manager-x11.c
index cee7b2f..14f6e72 100644
--- a/panels/common/gsd-device-manager-x11.c
+++ b/panels/common/gsd-device-manager-x11.c
@@ -112,7 +112,11 @@ add_device (GsdX11DeviceManager *manager,
        /* Takes ownership of device_file */
        g_hash_table_insert (manager->gdk_devices, gdk_device, device_file);
 
-       if (!g_hash_table_lookup (manager->devices, device_file)) {
+       device = g_hash_table_lookup (manager->devices, device_file);
+
+       if (device) {
+               g_signal_emit_by_name (manager, "device-changed", device);
+       } else {
                device = create_device (gdk_device, device_file);
                g_hash_table_insert (manager->devices, g_strdup (device_file), device);
                g_signal_emit_by_name (manager, "device-added", device);
diff --git a/panels/common/gsd-device-manager.c b/panels/common/gsd-device-manager.c
index aaf70bf..1737bf3 100644
--- a/panels/common/gsd-device-manager.c
+++ b/panels/common/gsd-device-manager.c
@@ -55,6 +55,7 @@ enum {
 enum {
        DEVICE_ADDED,
        DEVICE_REMOVED,
+       DEVICE_CHANGED,
        N_SIGNALS
 };
 
@@ -246,6 +247,15 @@ gsd_device_manager_class_init (GsdDeviceManagerClass *klass)
                              NULL, NULL, NULL,
                              G_TYPE_NONE, 1,
                              GSD_TYPE_DEVICE | G_SIGNAL_TYPE_STATIC_SCOPE);
+
+       signals[DEVICE_CHANGED] =
+               g_signal_new ("device-changed",
+                             GSD_TYPE_DEVICE_MANAGER,
+                             G_SIGNAL_RUN_LAST,
+                             G_STRUCT_OFFSET (GsdDeviceManagerClass, device_changed),
+                             NULL, NULL, NULL,
+                             G_TYPE_NONE, 1,
+                             GSD_TYPE_DEVICE | G_SIGNAL_TYPE_STATIC_SCOPE);
 }
 
 static void
diff --git a/panels/common/gsd-device-manager.h b/panels/common/gsd-device-manager.h
index 61e5727..baf46a8 100644
--- a/panels/common/gsd-device-manager.h
+++ b/panels/common/gsd-device-manager.h
@@ -76,6 +76,8 @@ struct _GsdDeviceManagerClass
                                 GsdDevice        *device);
        void (* device_removed) (GsdDeviceManager *manager,
                                 GsdDevice        *device);
+       void (* device_changed) (GsdDeviceManager *manager,
+                                GsdDevice        *device);
 };
 
 GType             gsd_device_get_type                (void) G_GNUC_CONST;
diff --git a/panels/common/gsd-input-helper.c b/panels/common/gsd-input-helper.c
index 7396d38..077ff1c 100644
--- a/panels/common/gsd-input-helper.c
+++ b/panels/common/gsd-input-helper.c
@@ -31,9 +31,6 @@
 #include "gsd-input-helper.h"
 #include "gsd-device-manager.h"
 
-#define INPUT_DEVICES_SCHEMA "org.gnome.settings-daemon.peripherals.input-devices"
-#define KEY_HOTPLUG_COMMAND  "hotplug-command"
-
 #define ABS_MT_X "Abs MT Position X"
 #define ABS_MT_Y "Abs MT Position Y"
 #define ABS_X "Abs X"
@@ -118,12 +115,6 @@ supports_xinput_devices_with_opcode (int *opcode)
 }
 
 gboolean
-supports_xinput_devices (void)
-{
-       return supports_xinput_devices_with_opcode (NULL);
-}
-
-gboolean
 supports_xtest (void)
 {
         gint op_code, event, error;
@@ -163,66 +154,6 @@ supports_xinput2_devices (int *opcode)
         return TRUE;
 }
 
-gboolean
-xdevice_is_synaptics (XDevice *xdevice)
-{
-        Atom realtype, prop;
-        int realformat;
-        unsigned long nitems, bytes_after;
-        unsigned char *data;
-
-        /* we don't check on the type being XI_TOUCHPAD here,
-         * but having a "Synaptics Off" property should be enough */
-
-        prop = XInternAtom (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()), "Synaptics Off", False);
-        if (!prop)
-                return FALSE;
-
-        gdk_error_trap_push ();
-        if ((XGetDeviceProperty (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()), xdevice, prop, 0, 1, 
False,
-                                XA_INTEGER, &realtype, &realformat, &nitems,
-                                &bytes_after, &data) == Success) && (realtype != None)) {
-                gdk_error_trap_pop_ignored ();
-                XFree (data);
-                return TRUE;
-        }
-        gdk_error_trap_pop_ignored ();
-
-        return FALSE;
-}
-
-gboolean
-synaptics_is_present (void)
-{
-        XDeviceInfo *device_info;
-        gint n_devices;
-        guint i;
-        gboolean retval;
-
-        retval = FALSE;
-
-        device_info = XListInputDevices (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()), &n_devices);
-        if (device_info == NULL)
-                return FALSE;
-
-        for (i = 0; i < n_devices; i++) {
-                XDevice *device;
-
-                gdk_error_trap_push ();
-                device = XOpenDevice (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()), device_info[i].id);
-                if (gdk_error_trap_pop () || (device == NULL))
-                        continue;
-
-                retval = xdevice_is_synaptics (device);
-                xdevice_close (device);
-                if (retval)
-                        break;
-        }
-        XFreeDeviceList (device_info);
-
-        return retval;
-}
-
 static gboolean
 device_type_is_present (GsdDeviceType type)
 {
@@ -250,29 +181,6 @@ mouse_is_present (void)
         return device_type_is_present (GSD_DEVICE_TYPE_MOUSE);
 }
 
-gboolean
-trackball_is_present (void)
-{
-        gboolean retval;
-        GList *l, *mice = gsd_device_manager_list_devices (gsd_device_manager_get (),
-                                                           GSD_DEVICE_TYPE_MOUSE);
-        if (mice == NULL)
-                return FALSE;
-
-        for (l = mice; l != NULL; l = l->next) {
-                gchar *lowercase;
-                const gchar *name = gsd_device_get_name (l->data);
-                if (!name)
-                        continue;
-                lowercase = g_ascii_strdown (name, -1);
-                retval = strstr (lowercase, "trackball") != NULL;
-                g_free (lowercase);
-        }
-
-        g_list_free (mice);
-        return retval;
-}
-
 char *
 xdevice_get_device_node (int deviceid)
 {
@@ -431,172 +339,6 @@ set_device_enabled (int device_id,
         return TRUE;
 }
 
-gboolean
-set_synaptics_device_enabled (int device_id,
-                              gboolean enabled)
-{
-        Atom prop;
-        guchar value;
-
-        prop = XInternAtom (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()), "Synaptics Off", False);
-        if (!prop)
-                return FALSE;
-
-        gdk_error_trap_push ();
-
-        value = enabled ? 0 : 1;
-        XIChangeProperty (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()),
-                          device_id, prop, XA_INTEGER, 8, PropModeReplace, &value, 1);
-
-        if (gdk_error_trap_pop ())
-                return FALSE;
-
-        return TRUE;
-}
-
-static const char *
-custom_command_to_string (CustomCommand command)
-{
-        switch (command) {
-        case COMMAND_DEVICE_ADDED:
-                return "added";
-        case COMMAND_DEVICE_REMOVED:
-                return "removed";
-        case COMMAND_DEVICE_PRESENT:
-                return "present";
-        default:
-                g_assert_not_reached ();
-        }
-}
-
-/* Run a custom command on device presence events. Parameters passed into
- * the custom command are:
- * command -t [added|removed|present] -i <device ID> <device name>
- * Type 'added' and 'removed' signal 'device added' and 'device removed',
- * respectively. Type 'present' signals 'device present at
- * gnome-settings-daemon init'.
- *
- * The script is expected to run synchronously, and an exit value
- * of "1" means that no other settings will be applied to this
- * particular device.
- *
- * More options may be added in the future.
- *
- * This function returns TRUE if we should not apply any more settings
- * to the device.
- */
-gboolean
-run_custom_command (GdkDevice              *device,
-                    CustomCommand           command)
-{
-        GSettings *settings;
-        GError *error = NULL;
-        char *cmd;
-        char *argv[7];
-        int exit_status;
-        gboolean rc;
-        int id;
-        char *out;
-
-        settings = g_settings_new (INPUT_DEVICES_SCHEMA);
-        cmd = g_settings_get_string (settings, KEY_HOTPLUG_COMMAND);
-        g_object_unref (settings);
-
-        if (!cmd || cmd[0] == '\0') {
-                g_free (cmd);
-                return FALSE;
-        }
-
-        /* Easter egg! */
-        g_object_get (device, "device-id", &id, NULL);
-
-        argv[0] = cmd;
-        argv[1] = "-t";
-        argv[2] = (char *) custom_command_to_string (command);
-        argv[3] = "-i";
-        argv[4] = g_strdup_printf ("%d", id);
-        argv[5] = (char*) gdk_device_get_name (device);
-        argv[6] = NULL;
-
-        out = g_strjoinv (" ", argv);
-        g_debug ("About to launch command: %s", out);
-        g_free (out);
-
-        rc = g_spawn_sync (g_get_home_dir (), argv, NULL, G_SPAWN_SEARCH_PATH,
-                           NULL, NULL, NULL, NULL, &exit_status, &error);
-
-        if (rc == FALSE) {
-                g_warning ("Couldn't execute command '%s', verify that this is a valid command: %s", cmd, 
error->message);
-                g_clear_error (&error);
-        }
-
-        g_free (argv[0]);
-        g_free (argv[4]);
-
-        if (!g_spawn_check_exit_status (exit_status, &error)) {
-                if (g_error_matches (error, G_SPAWN_EXIT_ERROR, 1)) {
-                        g_clear_error (&error);
-                        return TRUE;
-                }
-                g_clear_error (&error);
-        }
-
-        return FALSE;
-}
-
-GList *
-get_disabled_synaptics (void)
-{
-        GdkDisplay *display;
-        XDeviceInfo *device_info;
-        gint n_devices, act_format, rc;
-        guint i;
-        GList *ret;
-        Atom prop, act_type;
-        unsigned long  nitems, bytes_after;
-        unsigned char *data;
-
-        ret = NULL;
-
-        display = gdk_display_get_default ();
-        prop = gdk_x11_get_xatom_by_name ("Synaptics Off");
-
-        gdk_error_trap_push ();
-
-        device_info = XListInputDevices (GDK_DISPLAY_XDISPLAY (display), &n_devices);
-        if (device_info == NULL) {
-                gdk_error_trap_pop_ignored ();
-
-                return ret;
-        }
-
-        for (i = 0; i < n_devices; i++) {
-                rc = XIGetProperty (GDK_DISPLAY_XDISPLAY (display),
-                                    device_info[i].id, prop, 0, 1, False,
-                                    XA_INTEGER, &act_type, &act_format,
-                                    &nitems, &bytes_after, &data);
-
-                if (rc != Success || act_type != XA_INTEGER ||
-                    act_format != 8 || nitems < 1)
-                        continue;
-
-                if (!(data[0])) {
-                        XFree (data);
-                        continue;
-                }
-
-                XFree (data);
-
-                ret = g_list_prepend (ret, GINT_TO_POINTER (device_info[i].id));
-        }
-
-        gdk_error_trap_pop_ignored ();
-
-        XFreeDeviceList (device_info);
-
-        return ret;
-}
-
 const char *
 xdevice_get_wacom_tool_type (int deviceid)
 {
@@ -683,27 +425,3 @@ xdevice_get_dimensions (int    deviceid,
 
         return (w != 0 && h != 0);
 }
-
-gboolean
-xdevice_is_libinput (gint deviceid)
-{
-        GdkDisplay *display = gdk_display_get_default ();
-        gulong nitems, bytes_after;
-        gint rc, format;
-        guchar *data;
-        Atom type;
-
-        gdk_error_trap_push ();
-
-        /* Lookup a libinput driver specific property */
-        rc = XIGetProperty (GDK_DISPLAY_XDISPLAY (display), deviceid,
-                            gdk_x11_get_xatom_by_name ("libinput Send Events Mode Enabled"),
-                            0, 1, False, XA_INTEGER, &type, &format, &nitems, &bytes_after, &data);
-
-        if (rc == Success)
-                XFree (data);
-
-        gdk_error_trap_pop_ignored ();
-
-        return rc == Success && nitems > 0;
-}
diff --git a/panels/common/gsd-input-helper.h b/panels/common/gsd-input-helper.h
index aadd790..31e2e47 100644
--- a/panels/common/gsd-input-helper.h
+++ b/panels/common/gsd-input-helper.h
@@ -28,12 +28,6 @@ G_BEGIN_DECLS
 
 #define WACOM_SERIAL_IDS_PROP "Wacom Serial IDs"
 
-typedef enum {
-        COMMAND_DEVICE_ADDED,
-        COMMAND_DEVICE_REMOVED,
-        COMMAND_DEVICE_PRESENT
-} CustomCommand;
-
 /* Generic property setting code. Fill up the struct property with the property
  * data and pass it into device_set_property together with the device to be
  * changed.  Note: doesn't cater for non-zero offsets yet, but we don't have
@@ -50,32 +44,20 @@ typedef struct {
         } data;
 } PropertyHelper;
 
-gboolean  supports_xinput_devices  (void);
 gboolean  supports_xinput2_devices (int *opcode);
 gboolean  supports_xtest           (void);
 
 gboolean set_device_enabled       (int device_id,
                                    gboolean enabled);
 
-gboolean  set_synaptics_device_enabled (int device_id,
-                                        gboolean enabled);
-
-gboolean  xdevice_is_synaptics       (XDevice                *xdevice);
-
-gboolean  synaptics_is_present    (void);
 gboolean  touchpad_is_present     (void);
 gboolean  touchscreen_is_present  (void);
 gboolean  mouse_is_present        (void);
-gboolean  trackball_is_present    (void);
 
 gboolean  device_set_property     (XDevice                *xdevice,
                                    const char             *device_name,
                                    PropertyHelper         *property);
 
-gboolean  run_custom_command      (GdkDevice              *device,
-                                   CustomCommand           command);
-
-GList *   get_disabled_synaptics     (void);
 char *    xdevice_get_device_node  (int                     deviceid);
 int       xdevice_get_last_tool_id (int                     deviceid);
 gboolean  xdevice_get_dimensions   (int                     deviceid,
@@ -85,9 +67,6 @@ void      xdevice_close      (XDevice                *xdevice);
 
 const char * xdevice_get_wacom_tool_type (int               deviceid);
 
-gboolean  xdevice_is_libinput (gint deviceid);
-
-
 G_END_DECLS
 
 #endif /* __GSD_INPUT_HELPER_H */


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