wacom: Update from gnome-settings-daemon

This commit is contained in:
Bastien Nocera 2012-05-25 14:04:53 +01:00
parent 5c78387b59
commit 487c11c0d9
2 changed files with 34 additions and 11 deletions

View file

@ -83,6 +83,8 @@ device_set_property (XDevice *xdevice,
xdevice, prop, realtype, realformat, xdevice, prop, realtype, realformat,
PropModeReplace, data, nitems); PropModeReplace, data, nitems);
XFree (data);
if (gdk_error_trap_pop ()) { if (gdk_error_trap_pop ()) {
g_warning ("Error in setting \"%s\" for \"%s\"", property->name, device_name); g_warning ("Error in setting \"%s\" for \"%s\"", property->name, device_name);
return FALSE; return FALSE;
@ -335,14 +337,16 @@ xdevice_get_last_tool_id (int deviceid)
if (!prop) if (!prop)
return -1; return -1;
data = NULL;
gdk_error_trap_push (); 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, deviceid, prop, 0, 1000, False,
AnyPropertyType, &act_type, &act_format, AnyPropertyType, &act_type, &act_format,
&nitems, &bytes_after, &data) == Success) { &nitems, &bytes_after, &data) != Success) {
gdk_error_trap_pop_ignored (); gdk_error_trap_pop_ignored ();
return -1; goto out;
} }
if (gdk_error_trap_pop ()) if (gdk_error_trap_pop ())
@ -373,10 +377,11 @@ xdevice_get_last_tool_id (int deviceid)
/* That means that no tool was set down yet */ /* That means that no tool was set down yet */
if (id == STYLUS_DEVICE_ID || if (id == STYLUS_DEVICE_ID ||
id == ERASER_DEVICE_ID) id == ERASER_DEVICE_ID)
return 0x0; id = 0x0;
out: out:
XFree (data); if (data != NULL)
XFree (data);
return id; return id;
} }

View file

@ -374,6 +374,8 @@ filter_events (XEvent *xevent,
name = XGetAtomName (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()), pev->property); name = XGetAtomName (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()), pev->property);
if (name == NULL || if (name == NULL ||
g_strcmp0 (name, WACOM_SERIAL_IDS_PROP) != 0) { g_strcmp0 (name, WACOM_SERIAL_IDS_PROP) != 0) {
if (name)
XFree (name);
return GDK_FILTER_CONTINUE; return GDK_FILTER_CONTINUE;
} }
XFree (name); XFree (name);
@ -478,10 +480,10 @@ get_device_type (XDeviceInfo *dev)
device, prop, 0, 1, False, device, prop, 0, 1, False,
XA_ATOM, &realtype, &realformat, &nitems, XA_ATOM, &realtype, &realformat, &nitems,
&bytes_after, &data); &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; ret = WACOM_TYPE_INVALID;
}
XFree (data); XFree (data);
@ -573,23 +575,31 @@ find_output_by_display (GsdWacomDevice *device)
GSettings *tablet; GSettings *tablet;
GVariant *display; GVariant *display;
const gchar **edid; const gchar **edid;
GnomeRROutputInfo *ret;
if (device == NULL) if (device == NULL)
return NULL; return NULL;
ret = NULL;
tablet = device->priv->wacom_settings; tablet = device->priv->wacom_settings;
display = g_settings_get_value (tablet, "display"); display = g_settings_get_value (tablet, "display");
edid = g_variant_get_strv (display, &n); edid = g_variant_get_strv (display, &n);
if (n != 3) { if (n != 3) {
g_critical ("Expected 'display' key to store %d values; got %"G_GSIZE_FORMAT".", 3, n); 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) 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* static GnomeRROutputInfo*
@ -910,6 +920,8 @@ gsd_wacom_device_add_ring_modes (WacomDevice *wacom_device,
name = g_strdup_printf (_("Left Ring Mode #%d"), i); name = g_strdup_printf (_("Left Ring Mode #%d"), i);
id = 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)); 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)) { } else if ((direction & WACOM_BUTTON_POSITION_RIGHT) && libwacom_has_ring2 (wacom_device)) {
num_modes = libwacom_get_ring2_num_modes (wacom_device); num_modes = libwacom_get_ring2_num_modes (wacom_device);
@ -917,6 +929,8 @@ gsd_wacom_device_add_ring_modes (WacomDevice *wacom_device,
name = g_strdup_printf (_("Right Ring Mode #%d"), i); name = g_strdup_printf (_("Right Ring Mode #%d"), i);
id = 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)); 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);
} }
} }
@ -945,6 +959,8 @@ gsd_wacom_device_add_strip_modes (WacomDevice *wacom_device,
name = g_strdup_printf (_("Left Touchstrip Mode #%d"), i); name = g_strdup_printf (_("Left Touchstrip Mode #%d"), i);
id = g_strdup_printf ("left-strip-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)); 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) { } else if ((direction & WACOM_BUTTON_POSITION_RIGHT) && num_strips >= 2) {
num_modes = libwacom_get_strips_num_modes (wacom_device); num_modes = libwacom_get_strips_num_modes (wacom_device);
@ -952,6 +968,8 @@ gsd_wacom_device_add_strip_modes (WacomDevice *wacom_device,
name = g_strdup_printf (_("Right Touchstrip Mode #%d"), i); name = g_strdup_printf (_("Right Touchstrip Mode #%d"), i);
id = g_strdup_printf ("right-strip-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)); 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);
} }
} }