wacom: _get_area() helper stylistic changes
Including fixing a leak XDevice.
This commit is contained in:
parent
41d73eb43c
commit
82d6b9e809
2 changed files with 16 additions and 13 deletions
|
@ -734,40 +734,44 @@ gsd_wacom_device_get_device_type (GsdWacomDevice *device)
|
|||
return device->priv->type;
|
||||
}
|
||||
|
||||
gboolean
|
||||
gsd_wacom_device_get_area (GsdWacomDevice *dev, gint *device_area)
|
||||
gint *
|
||||
gsd_wacom_device_get_area (GsdWacomDevice *device)
|
||||
{
|
||||
int i, id;
|
||||
XDevice *device;
|
||||
XDevice *xdevice;
|
||||
Atom area, realtype;
|
||||
int rc, realformat;
|
||||
unsigned long nitems, bytes_after;
|
||||
unsigned char *data = NULL;
|
||||
gint *device_area;
|
||||
|
||||
g_object_get (dev->priv->gdk_device, "device-id", &id, NULL);
|
||||
g_object_get (device->priv->gdk_device, "device-id", &id, NULL);
|
||||
|
||||
area = XInternAtom (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()), "Wacom Tablet Area", False);
|
||||
|
||||
gdk_error_trap_push ();
|
||||
device = XOpenDevice (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()), id);
|
||||
xdevice = XOpenDevice (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()), id);
|
||||
if (gdk_error_trap_pop () || (device == NULL))
|
||||
return FALSE;
|
||||
return NULL;
|
||||
|
||||
gdk_error_trap_push ();
|
||||
rc = XGetDeviceProperty (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()),
|
||||
device, area, 0, 4, False,
|
||||
xdevice, area, 0, 4, False,
|
||||
XA_INTEGER, &realtype, &realformat, &nitems,
|
||||
&bytes_after, &data);
|
||||
if (gdk_error_trap_pop () || rc != Success || realtype == None || bytes_after != 0 || nitems != 4) {
|
||||
XCloseDevice (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()), device);
|
||||
return FALSE;
|
||||
XCloseDevice (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()), xdevice);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
device_area = g_new0 (int, nitems);
|
||||
for (i = 0; i < nitems; i++)
|
||||
device_area[i] = ((long*)data)[i];
|
||||
|
||||
XFree (data);
|
||||
return TRUE;
|
||||
XCloseDevice (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()), xdevice);
|
||||
|
||||
return device_area;
|
||||
}
|
||||
|
||||
const char *
|
||||
|
|
|
@ -96,9 +96,8 @@ void gsd_wacom_device_set_current_stylus (GsdWacomDevice *device,
|
|||
int stylus_id);
|
||||
|
||||
GsdWacomDeviceType gsd_wacom_device_get_device_type (GsdWacomDevice *device);
|
||||
gboolean gsd_wacom_device_get_area (GsdWacomDevice *dev,
|
||||
int *device_area);
|
||||
const char * gsd_wacom_device_type_to_string (GsdWacomDeviceType type);
|
||||
gint * gsd_wacom_device_get_area (GsdWacomDevice *device);
|
||||
const char * gsd_wacom_device_type_to_string (GsdWacomDeviceType type);
|
||||
|
||||
/* Helper and debug functions */
|
||||
GsdWacomDevice * gsd_wacom_device_create_fake (GsdWacomDeviceType type,
|
||||
|
|
Loading…
Add table
Reference in a new issue