summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorCarlos Garnacho <mrgarnacho@gmail.com>2018-03-20 17:03:15 +0000
committerCarlos Garnacho <mrgarnacho@gmail.com>2018-03-20 17:03:15 +0000
commit28c27f37ee5fe3a1a9d6a4c35bd9b979f228cf9e (patch)
treec3806a27c99698c2c69c38e064c38e333c0abdcf /tests
parentdcc61242094d1a9fc532a80ecc22b47a4243f986 (diff)
parent0ad27cc5985664437c022d42e433734742454f05 (diff)
downloadgtk+-28c27f37ee5fe3a1a9d6a4c35bd9b979f228cf9e.tar.gz
Merge branch 'detect-synaptics-touchpads-v2' into 'master'
x11/xi2: Report touchpads as TOUCHPAD, not MOUSE See merge request GNOME/gtk!65
Diffstat (limited to 'tests')
-rw-r--r--tests/testinput.c52
1 files changed, 41 insertions, 11 deletions
diff --git a/tests/testinput.c b/tests/testinput.c
index 101e3e59c5..616f769153 100644
--- a/tests/testinput.c
+++ b/tests/testinput.c
@@ -121,14 +121,50 @@ draw_brush (GtkWidget *widget, GdkInputSource source,
static guint32 motion_time;
+static const char *
+device_source_name (GdkDevice *device)
+{
+ static const struct {GdkInputSource source; const char *name;} sources[] =
+ {
+ {GDK_SOURCE_MOUSE, "mouse"},
+ {GDK_SOURCE_PEN, "pen"},
+ {GDK_SOURCE_ERASER, "eraser"},
+ {GDK_SOURCE_CURSOR, "cursor"},
+ {GDK_SOURCE_KEYBOARD, "keyboard"},
+ {GDK_SOURCE_TOUCHSCREEN, "touchscreen"},
+ {GDK_SOURCE_TOUCHPAD, "touchpad"},
+ {GDK_SOURCE_TRACKPOINT, "trackpoint"},
+ {GDK_SOURCE_TABLET_PAD, "tablet pad"},
+ };
+ GdkInputSource source = gdk_device_get_source (device);
+ int s;
+
+ for (s = 0; s < G_N_ELEMENTS (sources); ++s)
+ if (sources[s].source == source)
+ return sources[s].name;
+
+ return "unknown";
+}
+
static void
-print_axes (GdkDevice *device, gdouble *axes)
+print_axes (GdkEvent *event)
{
- int i;
+ gdouble *axes;
+ guint n_axes;
+
+ gdk_event_get_axes (event, &axes, &n_axes);
if (axes)
{
- g_print ("%s ", gdk_device_get_name (device));
+ GdkDevice *device = gdk_event_get_device (event);
+ GdkDevice *source = gdk_event_get_source_device (event);
+ int i;
+
+ g_print ("%s (%s) via %s (%s): ",
+ gdk_device_get_name (device),
+ device_source_name (device),
+ gdk_device_get_name (source),
+ device_source_name (source));
for (i = 0; i < gdk_device_get_n_axes (device); i++)
g_print ("%g ", axes[i]);
@@ -147,17 +183,14 @@ drag_begin (GtkGesture *gesture,
{
gdouble pressure = 0.5;
GdkDevice *device;
- gdouble *axes;
- guint n_axes;
gdouble x, y;
GdkEvent *event;
event = gtk_get_current_event ();
device = gdk_event_get_device (event);
- gdk_event_get_axes (event, &axes, &n_axes);
gdk_event_get_coords (event, &x, &y);
- print_axes (device, axes);
+ print_axes (event);
gdk_event_get_axis (event, GDK_AXIS_PRESSURE, &pressure);
draw_brush (widget, gdk_device_get_source (device), x, y, pressure);
@@ -188,9 +221,7 @@ drag_update (GtkGesture *gesture,
{
GdkModifierType state;
GdkDevice *device;
- gdouble *axes;
GdkEvent *event;
- guint n_axes;
double start_x, start_y;
event = gtk_get_current_event ();
@@ -210,8 +241,7 @@ drag_update (GtkGesture *gesture,
motion_time = gdk_event_get_time (event);
}
- gdk_event_get_axes (event, &axes, &n_axes);
- print_axes (device, axes);
+ print_axes (event);
}
void