[gnome-settings-daemon] wacom: Add _get_area() helper needed by g-c-c
- From: Bastien Nocera <hadess src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-settings-daemon] wacom: Add _get_area() helper needed by g-c-c
- Date: Tue, 10 Jan 2012 19:56:57 +0000 (UTC)
commit 7675bffde2fb0e0f25d41d3f30748809353e128a
Author: Bastien Nocera <hadess hadess net>
Date: Tue Jan 10 19:56:26 2012 +0000
wacom: Add _get_area() helper needed by g-c-c
plugins/wacom/gsd-wacom-device.c | 40 ++++++++++++++++++++++++++++++++++++++
plugins/wacom/gsd-wacom-device.h | 3 +-
2 files changed, 42 insertions(+), 1 deletions(-)
---
diff --git a/plugins/wacom/gsd-wacom-device.c b/plugins/wacom/gsd-wacom-device.c
index 2f364b0..d28ac8c 100644
--- a/plugins/wacom/gsd-wacom-device.c
+++ b/plugins/wacom/gsd-wacom-device.c
@@ -734,6 +734,46 @@ gsd_wacom_device_get_device_type (GsdWacomDevice *device)
return device->priv->type;
}
+gint *
+gsd_wacom_device_get_area (GsdWacomDevice *device)
+{
+ int i, id;
+ XDevice *xdevice;
+ Atom area, realtype;
+ int rc, realformat;
+ unsigned long nitems, bytes_after;
+ unsigned char *data = NULL;
+ gint *device_area;
+
+ 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 ();
+ xdevice = XOpenDevice (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()), id);
+ if (gdk_error_trap_pop () || (device == NULL))
+ return NULL;
+
+ gdk_error_trap_push ();
+ rc = XGetDeviceProperty (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()),
+ 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 ()), xdevice);
+ return NULL;
+ }
+
+ device_area = g_new0 (int, nitems);
+ for (i = 0; i < nitems; i++)
+ device_area[i] = ((long*)data)[i];
+
+ XFree (data);
+ XCloseDevice (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()), xdevice);
+
+ return device_area;
+}
+
const char *
gsd_wacom_device_type_to_string (GsdWacomDeviceType type)
{
diff --git a/plugins/wacom/gsd-wacom-device.h b/plugins/wacom/gsd-wacom-device.h
index 235e75a..2502cb1 100644
--- a/plugins/wacom/gsd-wacom-device.h
+++ b/plugins/wacom/gsd-wacom-device.h
@@ -96,7 +96,8 @@ void gsd_wacom_device_set_current_stylus (GsdWacomDevice *device,
int stylus_id);
GsdWacomDeviceType gsd_wacom_device_get_device_type (GsdWacomDevice *device);
-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,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]