[gnome-control-center/gnome-3-4] wacom: Update from gnome-settings-daemon



commit 89498b55c2a5acc7d6ad8701d5f9a9f7d514733d
Author: Bastien Nocera <hadess hadess net>
Date:   Fri May 25 14:03:31 2012 +0100

    wacom: Update from gnome-settings-daemon

 panels/wacom/gsd-input-helper.c |   40 ++++++++++++++++++++++++++------------
 panels/wacom/gsd-wacom-device.c |   33 ++++++++++++++++++++++++++-----
 2 files changed, 54 insertions(+), 19 deletions(-)
---
diff --git a/panels/wacom/gsd-input-helper.c b/panels/wacom/gsd-input-helper.c
index 95b1b38..78f1873 100644
--- a/panels/wacom/gsd-input-helper.c
+++ b/panels/wacom/gsd-input-helper.c
@@ -83,6 +83,8 @@ device_set_property (XDevice        *xdevice,
                                xdevice, prop, realtype, realformat,
                                PropModeReplace, data, nitems);
 
+        XFree (data);
+
         if (gdk_error_trap_pop ()) {
                 g_warning ("Error in setting \"%s\" for \"%s\"", property->name, device_name);
                 return FALSE;
@@ -129,7 +131,14 @@ supports_xinput2_devices (int *opcode)
 
         if (XIQueryVersion (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()), &major, &minor) != Success) {
                 gdk_error_trap_pop_ignored ();
-                return FALSE;
+                /* try for 2.2, maybe gtk has already announced 2.2 support */
+                gdk_error_trap_push ();
+                major = 2;
+                minor = 2;
+                if (XIQueryVersion (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()), &major, &minor) != Success) {
+                    gdk_error_trap_pop_ignored ();
+                    return FALSE;
+                }
         }
         gdk_error_trap_pop_ignored ();
 
@@ -328,14 +337,16 @@ xdevice_get_last_tool_id (int  deviceid)
         if (!prop)
                 return -1;
 
+        data = NULL;
+
         gdk_error_trap_push ();
 
-        if (!XIGetProperty (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()),
+        if (XIGetProperty (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()),
                             deviceid, prop, 0, 1000, False,
                             AnyPropertyType, &act_type, &act_format,
-                            &nitems, &bytes_after, &data) == Success) {
+                            &nitems, &bytes_after, &data) != Success) {
                 gdk_error_trap_pop_ignored ();
-                return -1;
+                goto out;
         }
 
         if (gdk_error_trap_pop ())
@@ -366,10 +377,11 @@ xdevice_get_last_tool_id (int  deviceid)
 	/* That means that no tool was set down yet */
 	if (id == STYLUS_DEVICE_ID ||
 	    id == ERASER_DEVICE_ID)
-		return 0x0;
+		id = 0x0;
 
 out:
-        XFree (data);
+        if (data != NULL)
+                XFree (data);
         return id;
 }
 
@@ -433,7 +445,7 @@ run_custom_command (GdkDevice              *device,
 {
         GSettings *settings;
         char *cmd;
-        char *argv[5];
+        char *argv[7];
         int exit_status;
         gboolean rc;
         int id;
@@ -451,10 +463,12 @@ run_custom_command (GdkDevice              *device,
         g_object_get (device, "device-id", &id, NULL);
 
         argv[0] = cmd;
-        argv[1] = g_strdup_printf ("-t %s", custom_command_to_string (command));
-        argv[2] = g_strdup_printf ("-i %d", id);
-        argv[3] = g_strdup_printf ("%s", gdk_device_get_name (device));
-        argv[4] = NULL;
+        argv[1] = "-t";
+        argv[2] = (char *) custom_command_to_string (command);
+        argv[3] = "-i";
+        argv[4] = g_strdup_printf ("%d", id);
+        argv[5] = g_strdup_printf ("%s", gdk_device_get_name (device));
+        argv[6] = NULL;
 
         rc = g_spawn_sync (g_get_home_dir (), argv, NULL, G_SPAWN_SEARCH_PATH,
                            NULL, NULL, NULL, NULL, &exit_status, NULL);
@@ -463,8 +477,8 @@ run_custom_command (GdkDevice              *device,
                 g_warning ("Couldn't execute command '%s', verify that this is a valid command.", cmd);
 
         g_free (argv[0]);
-        g_free (argv[1]);
-        g_free (argv[2]);
+        g_free (argv[4]);
+        g_free (argv[5]);
 
         return (exit_status == 0);
 }
diff --git a/panels/wacom/gsd-wacom-device.c b/panels/wacom/gsd-wacom-device.c
index f995546..be23a66 100644
--- a/panels/wacom/gsd-wacom-device.c
+++ b/panels/wacom/gsd-wacom-device.c
@@ -373,6 +373,8 @@ filter_events (XEvent         *xevent,
 	name = XGetAtomName (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()), pev->property);
 	if (name == NULL ||
 	    g_strcmp0 (name, WACOM_SERIAL_IDS_PROP) != 0) {
+		if (name)
+			XFree (name);
 		return GDK_FILTER_CONTINUE;
 	}
 	XFree (name);
@@ -477,10 +479,10 @@ get_device_type (XDeviceInfo *dev)
                                  device, prop, 0, 1, False,
                                  XA_ATOM, &realtype, &realformat, &nitems,
                                  &bytes_after, &data);
-        if (gdk_error_trap_pop () || rc != Success || realtype == None) {
-                XCloseDevice (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()), device);
+        XCloseDevice (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()), device);
+
+        if (gdk_error_trap_pop () || rc != Success || realtype == None)
                 ret = WACOM_TYPE_INVALID;
-        }
 
         XFree (data);
 
@@ -572,23 +574,31 @@ find_output_by_display (GsdWacomDevice *device)
 	GSettings *tablet;
 	GVariant *display;
 	const gchar **edid;
+	GnomeRROutputInfo *ret;
 
 	if (device == NULL)
 		return NULL;
 
+	ret      = NULL;
 	tablet   = device->priv->wacom_settings;
 	display  = g_settings_get_value (tablet, "display");
 	edid     = g_variant_get_strv (display, &n);
 
 	if (n != 3) {
 		g_critical ("Expected 'display' key to store %d values; got %"G_GSIZE_FORMAT".", 3, n);
-		return NULL;
+		goto out;
 	}
 
 	if (strlen(edid[0]) == 0 || strlen(edid[1]) == 0 || strlen(edid[2]) == 0)
-		return NULL;
+		goto out;
 
-	return find_output_by_edid (edid[0], edid[1], edid[2]);
+	ret = find_output_by_edid (edid[0], edid[1], edid[2]);
+
+out:
+	g_free (edid);
+	g_variant_unref (display);
+
+	return ret;
 }
 
 static GnomeRROutputInfo*
@@ -909,6 +919,8 @@ gsd_wacom_device_add_ring_modes (WacomDevice      *wacom_device,
 			name = g_strdup_printf (_("Left Ring Mode #%d"), i);
 			id = g_strdup_printf ("left-ring-mode-%d", i);
 			l = g_list_append (l, gsd_wacom_tablet_button_new (name, id, settings_path, WACOM_TABLET_BUTTON_TYPE_ELEVATOR, flags_to_group (WACOM_BUTTON_RING_MODESWITCH), i - 1));
+			g_free (name);
+			g_free (id);
 		}
 	} else if ((direction & WACOM_BUTTON_POSITION_RIGHT) && libwacom_has_ring2 (wacom_device)) {
 		num_modes = libwacom_get_ring2_num_modes (wacom_device);
@@ -916,6 +928,8 @@ gsd_wacom_device_add_ring_modes (WacomDevice      *wacom_device,
 			name = g_strdup_printf (_("Right Ring Mode #%d"), i);
 			id = g_strdup_printf ("right-ring-mode-%d", i);
 			l = g_list_append (l, gsd_wacom_tablet_button_new (name, id, settings_path, WACOM_TABLET_BUTTON_TYPE_ELEVATOR, flags_to_group (WACOM_BUTTON_RING2_MODESWITCH), i - 1));
+			g_free (name);
+			g_free (id);
 		}
 	}
 
@@ -944,6 +958,8 @@ gsd_wacom_device_add_strip_modes (WacomDevice      *wacom_device,
 			name = g_strdup_printf (_("Left Touchstrip Mode #%d"), i);
 			id = g_strdup_printf ("left-strip-mode-%d", i);
 			l = g_list_append (l, gsd_wacom_tablet_button_new (name, id, settings_path, WACOM_TABLET_BUTTON_TYPE_ELEVATOR, flags_to_group (WACOM_BUTTON_TOUCHSTRIP_MODESWITCH), i - 1));
+			g_free (name);
+			g_free (id);
 		}
 	} else if ((direction & WACOM_BUTTON_POSITION_RIGHT) && num_strips >= 2) {
 		num_modes = libwacom_get_strips_num_modes (wacom_device);
@@ -951,6 +967,8 @@ gsd_wacom_device_add_strip_modes (WacomDevice      *wacom_device,
 			name = g_strdup_printf (_("Right Touchstrip Mode #%d"), i);
 			id = g_strdup_printf ("right-strip-mode-%d", i);
 			l = g_list_append (l, gsd_wacom_tablet_button_new (name, id, settings_path, WACOM_TABLET_BUTTON_TYPE_ELEVATOR, flags_to_group (WACOM_BUTTON_TOUCHSTRIP2_MODESWITCH), i - 1));
+			g_free (name);
+			g_free (id);
 		}
 	}
 
@@ -1322,6 +1340,9 @@ gsd_wacom_device_finalize (GObject *object)
                 p->wacom_settings = NULL;
         }
 
+        g_list_foreach (p->styli, (GFunc) g_object_unref, NULL);
+        g_list_free (p->styli);
+
         g_list_foreach (p->buttons, (GFunc) gsd_wacom_tablet_button_free, NULL);
         g_list_free (p->buttons);
 



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