[gnome-settings-daemon/wip/carlosg/remove-device-mapper: 83/84] common: Drop unused input helper API
- From: Carlos Garnacho <carlosg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-settings-daemon/wip/carlosg/remove-device-mapper: 83/84] common: Drop unused input helper API
- Date: Thu, 6 Dec 2018 15:57:04 +0000 (UTC)
commit 50de828e14177579ff43ce650b9370d6a98bc1f0
Author: Carlos Garnacho <carlosg gnome org>
Date: Fri Apr 20 20:04:00 2018 +0200
common: Drop unused input helper API
plugins/common/gsd-input-helper.c | 310 --------------------------------------
plugins/common/gsd-input-helper.h | 33 ----
2 files changed, 343 deletions(-)
---
diff --git a/plugins/common/gsd-input-helper.c b/plugins/common/gsd-input-helper.c
index 58e136a0..186dee02 100644
--- a/plugins/common/gsd-input-helper.c
+++ b/plugins/common/gsd-input-helper.c
@@ -30,89 +30,6 @@
#include "gsd-input-helper.h"
-#define ABS_MT_X "Abs MT Position X"
-#define ABS_MT_Y "Abs MT Position Y"
-#define ABS_X "Abs X"
-#define ABS_Y "Abs Y"
-
-typedef gboolean (* InfoIdentifyFunc) (XDeviceInfo *device_info);
-typedef gboolean (* DeviceIdentifyFunc) (XDevice *xdevice);
-
-gboolean
-device_set_property (XDevice *xdevice,
- const char *device_name,
- PropertyHelper *property)
-{
- int rc, i;
- Atom prop;
- Atom realtype;
- int realformat;
- unsigned long nitems, bytes_after;
- unsigned char *data;
-
- prop = XInternAtom (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()),
- property->name, False);
- if (!prop)
- return FALSE;
-
- gdk_error_trap_push ();
-
- rc = XGetDeviceProperty (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()),
- xdevice, prop, 0, property->nitems, False,
- AnyPropertyType, &realtype, &realformat, &nitems,
- &bytes_after, &data);
-
- if (rc != Success ||
- realtype != property->type ||
- realformat != property->format ||
- nitems < property->nitems) {
- gdk_error_trap_pop_ignored ();
- g_warning ("Error reading property \"%s\" for \"%s\"", property->name, device_name);
- return FALSE;
- }
-
- for (i = 0; i < nitems; i++) {
- switch (property->format) {
- case 8:
- data[i] = property->data.c[i];
- break;
- case 32:
- ((long*)data)[i] = property->data.i[i];
- break;
- }
- }
-
- XChangeDeviceProperty (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()),
- 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;
- }
-
- return TRUE;
-}
-
-static gboolean
-supports_xinput_devices_with_opcode (int *opcode)
-{
- gint op_code, event, error;
- gboolean retval;
-
- retval = XQueryExtension (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()),
- "XInputExtension",
- &op_code,
- &event,
- &error);
- if (opcode)
- *opcode = op_code;
-
- return retval;
-}
-
gboolean
supports_xtest (void)
{
@@ -128,31 +45,6 @@ supports_xtest (void)
return retval;
}
-gboolean
-supports_xinput2_devices (int *opcode)
-{
- int major, minor;
-
- if (supports_xinput_devices_with_opcode (opcode) == FALSE)
- return FALSE;
-
- gdk_error_trap_push ();
-
- major = 2;
- minor = 3;
-
- if (XIQueryVersion (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()), &major, &minor) != Success) {
- gdk_error_trap_pop_ignored ();
- return FALSE;
- }
- gdk_error_trap_pop_ignored ();
-
- if ((major * 1000 + minor) < (2000))
- return FALSE;
-
- return TRUE;
-}
-
char *
xdevice_get_device_node (int deviceid)
{
@@ -200,205 +92,3 @@ out:
XFree (data);
return NULL;
}
-
-#define TOOL_ID_FORMAT_SIZE 32
-static int
-get_id_for_index (guchar *data,
- guint idx)
-{
- guchar *ptr;
- int id;
-
- ptr = data;
- ptr += TOOL_ID_FORMAT_SIZE / 8 * idx;
-
- id = *((int32_t*)ptr);
- id = id & 0xfffff;
-
- return id;
-}
-
-
-#define STYLUS_DEVICE_ID 0x02
-#define ERASER_DEVICE_ID 0x0A
-
-int
-xdevice_get_last_tool_id (int deviceid)
-{
- Atom prop;
- Atom act_type;
- int act_format;
- unsigned long nitems, bytes_after;
- unsigned char *data;
- int id;
-
- id = -1;
-
- gdk_display_sync (gdk_display_get_default ());
-
- prop = XInternAtom (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()), WACOM_SERIAL_IDS_PROP, False);
- if (!prop)
- return -1;
-
- data = NULL;
-
- gdk_error_trap_push ();
-
- if (XIGetProperty (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()),
- deviceid, prop, 0, 1000, False,
- AnyPropertyType, &act_type, &act_format,
- &nitems, &bytes_after, &data) != Success) {
- gdk_error_trap_pop_ignored ();
- goto out;
- }
-
- if (gdk_error_trap_pop ())
- goto out;
-
- if (nitems != 4 && nitems != 5)
- goto out;
-
- if (act_type != XA_INTEGER)
- goto out;
-
- if (act_format != TOOL_ID_FORMAT_SIZE)
- goto out;
-
- /* item 0 = tablet ID
- * item 1 = old device serial number (== last tool in proximity)
- * item 2 = old hardware serial number (including tool ID)
- * item 3 = current serial number (0 if no tool in proximity)
- * item 4 = current tool ID (since Feb 2012)
- *
- * Get the current tool ID first, if available, then the old one */
- id = 0x0;
- if (nitems == 5)
- id = get_id_for_index (data, 4);
- if (id == 0x0)
- id = get_id_for_index (data, 2);
-
- /* That means that no tool was set down yet */
- if (id == STYLUS_DEVICE_ID ||
- id == ERASER_DEVICE_ID)
- id = 0x0;
-
-out:
- if (data != NULL)
- XFree (data);
- return id;
-}
-
-gboolean
-set_device_enabled (int device_id,
- gboolean enabled)
-{
- Atom prop;
- guchar value;
-
- prop = XInternAtom (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()), "Device Enabled", False);
- if (!prop)
- return FALSE;
-
- gdk_error_trap_push ();
-
- value = enabled ? 1 : 0;
- XIChangeProperty (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()),
- device_id, prop, XA_INTEGER, 8, PropModeReplace, &value, 1);
-
- if (gdk_error_trap_pop ())
- return FALSE;
-
- return TRUE;
-}
-
-const char *
-xdevice_get_wacom_tool_type (int deviceid)
-{
- unsigned long nitems, bytes_after;
- unsigned char *data = NULL;
- Atom prop, realtype, tool;
- GdkDisplay *display;
- int realformat, rc;
- const gchar *ret = NULL;
-
- gdk_error_trap_push ();
-
- display = gdk_display_get_default ();
- prop = gdk_x11_get_xatom_by_name ("Wacom Tool Type");
-
- rc = XIGetProperty (GDK_DISPLAY_XDISPLAY (display),
- deviceid, prop, 0, 1, False,
- XA_ATOM, &realtype, &realformat, &nitems,
- &bytes_after, &data);
-
- gdk_error_trap_pop_ignored ();
-
- if (rc != Success || nitems == 0)
- return NULL;
-
- if (realtype == XA_ATOM) {
- tool = *((Atom*) data);
- ret = gdk_x11_get_xatom_name (tool);
- }
-
- XFree (data);
-
- return ret;
-}
-
-void
-xdevice_close (XDevice *xdevice)
-{
- gdk_error_trap_push ();
- XCloseDevice (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()), xdevice);
- gdk_error_trap_pop_ignored();
-}
-
-gboolean
-xdevice_get_dimensions (int deviceid,
- guint *width,
- guint *height)
-{
- GdkDisplay *display = gdk_display_get_default ();
- XIDeviceInfo *info;
- guint *value, w, h;
- int i, n_info;
-
- gdk_error_trap_push ();
-
- info = XIQueryDevice (GDK_DISPLAY_XDISPLAY (display), deviceid, &n_info);
- *width = *height = w = h = 0;
-
- if (gdk_error_trap_pop ())
- return FALSE;
-
- if (!info)
- return FALSE;
-
- for (i = 0; i < info->num_classes; i++) {
- XIValuatorClassInfo *valuator_info;
-
- if (info->classes[i]->type != XIValuatorClass)
- continue;
-
- valuator_info = (XIValuatorClassInfo *) info->classes[i];
-
- if (valuator_info->label == gdk_x11_get_xatom_by_name_for_display (display, ABS_X) ||
- valuator_info->label == gdk_x11_get_xatom_by_name_for_display (display, ABS_MT_X))
- value = &w;
- else if (valuator_info->label == gdk_x11_get_xatom_by_name_for_display (display, ABS_Y) ||
- valuator_info->label == gdk_x11_get_xatom_by_name_for_display (display, ABS_MT_Y))
- value = &h;
- else
- continue;
-
- *value = (valuator_info->max - valuator_info->min) * 1000 / valuator_info->resolution;
- }
-
- *width = w;
- *height = h;
-
- XIFreeDeviceInfo (info);
-
- return (w != 0 && h != 0);
-}
diff --git a/plugins/common/gsd-input-helper.h b/plugins/common/gsd-input-helper.h
index 25a96289..b99fae4e 100644
--- a/plugins/common/gsd-input-helper.h
+++ b/plugins/common/gsd-input-helper.h
@@ -26,42 +26,9 @@ G_BEGIN_DECLS
#include <X11/extensions/XInput.h>
#include <X11/extensions/XIproto.h>
-#define WACOM_SERIAL_IDS_PROP "Wacom Serial IDs"
-
-/* Generic property setting code. Fill up the struct property with the property
- * data and pass it into device_set_property together with the device to be
- * changed. Note: doesn't cater for non-zero offsets yet, but we don't have
- * any settings that require that.
- */
-typedef struct {
- const char *name; /* property name */
- gint nitems; /* number of items in data */
- gint format; /* CARD8 or CARD32 sized-items */
- gint type; /* Atom representing data type */
- union {
- const gchar *c; /* 8 bit data */
- const gint *i; /* 32 bit data */
- } data;
-} PropertyHelper;
-
-gboolean supports_xinput2_devices (int *opcode);
gboolean supports_xtest (void);
-gboolean set_device_enabled (int device_id,
- gboolean enabled);
-
-gboolean device_set_property (XDevice *xdevice,
- const char *device_name,
- PropertyHelper *property);
-
char * xdevice_get_device_node (int deviceid);
-int xdevice_get_last_tool_id (int deviceid);
-gboolean xdevice_get_dimensions (int deviceid,
- guint *width,
- guint *height);
-void xdevice_close (XDevice *xdevice);
-
-const char * xdevice_get_wacom_tool_type (int deviceid);
G_END_DECLS
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]