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;
|
return device->priv->type;
|
||||||
}
|
}
|
||||||
|
|
||||||
gboolean
|
gint *
|
||||||
gsd_wacom_device_get_area (GsdWacomDevice *dev, gint *device_area)
|
gsd_wacom_device_get_area (GsdWacomDevice *device)
|
||||||
{
|
{
|
||||||
int i, id;
|
int i, id;
|
||||||
XDevice *device;
|
XDevice *xdevice;
|
||||||
Atom area, realtype;
|
Atom area, realtype;
|
||||||
int rc, realformat;
|
int rc, realformat;
|
||||||
unsigned long nitems, bytes_after;
|
unsigned long nitems, bytes_after;
|
||||||
unsigned char *data = NULL;
|
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);
|
area = XInternAtom (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()), "Wacom Tablet Area", False);
|
||||||
|
|
||||||
gdk_error_trap_push ();
|
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))
|
if (gdk_error_trap_pop () || (device == NULL))
|
||||||
return FALSE;
|
return NULL;
|
||||||
|
|
||||||
gdk_error_trap_push ();
|
gdk_error_trap_push ();
|
||||||
rc = XGetDeviceProperty (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()),
|
rc = XGetDeviceProperty (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()),
|
||||||
device, area, 0, 4, False,
|
xdevice, area, 0, 4, False,
|
||||||
XA_INTEGER, &realtype, &realformat, &nitems,
|
XA_INTEGER, &realtype, &realformat, &nitems,
|
||||||
&bytes_after, &data);
|
&bytes_after, &data);
|
||||||
if (gdk_error_trap_pop () || rc != Success || realtype == None || bytes_after != 0 || nitems != 4) {
|
if (gdk_error_trap_pop () || rc != Success || realtype == None || bytes_after != 0 || nitems != 4) {
|
||||||
XCloseDevice (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()), device);
|
XCloseDevice (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()), xdevice);
|
||||||
return FALSE;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
device_area = g_new0 (int, nitems);
|
||||||
for (i = 0; i < nitems; i++)
|
for (i = 0; i < nitems; i++)
|
||||||
device_area[i] = ((long*)data)[i];
|
device_area[i] = ((long*)data)[i];
|
||||||
|
|
||||||
XFree (data);
|
XFree (data);
|
||||||
return TRUE;
|
XCloseDevice (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()), xdevice);
|
||||||
|
|
||||||
|
return device_area;
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *
|
const char *
|
||||||
|
|
|
@ -96,9 +96,8 @@ void gsd_wacom_device_set_current_stylus (GsdWacomDevice *device,
|
||||||
int stylus_id);
|
int stylus_id);
|
||||||
|
|
||||||
GsdWacomDeviceType gsd_wacom_device_get_device_type (GsdWacomDevice *device);
|
GsdWacomDeviceType gsd_wacom_device_get_device_type (GsdWacomDevice *device);
|
||||||
gboolean gsd_wacom_device_get_area (GsdWacomDevice *dev,
|
gint * gsd_wacom_device_get_area (GsdWacomDevice *device);
|
||||||
int *device_area);
|
const char * gsd_wacom_device_type_to_string (GsdWacomDeviceType type);
|
||||||
const char * gsd_wacom_device_type_to_string (GsdWacomDeviceType type);
|
|
||||||
|
|
||||||
/* Helper and debug functions */
|
/* Helper and debug functions */
|
||||||
GsdWacomDevice * gsd_wacom_device_create_fake (GsdWacomDeviceType type,
|
GsdWacomDevice * gsd_wacom_device_create_fake (GsdWacomDeviceType type,
|
||||||
|
|
Loading…
Add table
Reference in a new issue