summaryrefslogtreecommitdiff
path: root/tools/libinput-debug-gui.c
diff options
context:
space:
mode:
authorPeter Hutterer <peter.hutterer@who-t.net>2018-08-07 12:42:40 +1000
committerPeter Hutterer <peter.hutterer@who-t.net>2018-08-08 10:07:43 +1000
commitf78d6669e57a717689ff40854788676b8a5c90fd (patch)
tree4e6d5a05945e2530e1bf86017639a6988e8f2c6b /tools/libinput-debug-gui.c
parent28fc00b5f754c8679f12317bf5593227f6ead831 (diff)
downloadlibinput-f78d6669e57a717689ff40854788676b8a5c90fd.tar.gz
tools: debug-*: show unaccelerated deltas for pointer events
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Diffstat (limited to 'tools/libinput-debug-gui.c')
-rw-r--r--tools/libinput-debug-gui.c36
1 files changed, 36 insertions, 0 deletions
diff --git a/tools/libinput-debug-gui.c b/tools/libinput-debug-gui.c
index 6ed6c4a7..1cf81117 100644
--- a/tools/libinput-debug-gui.c
+++ b/tools/libinput-debug-gui.c
@@ -64,6 +64,11 @@ struct window {
/* sprite position */
double x, y;
+ /* these are for the delta coordinates, but they're not
+ * deltas, they are converted into abs positions */
+ size_t ndeltas;
+ struct point deltas[64];
+
/* abs position */
int absx, absy;
@@ -268,6 +273,26 @@ draw_tablet(struct window *w, cairo_t *cr)
cairo_fill(cr);
cairo_restore(cr);
+ /* pointer deltas */
+ mask = ARRAY_LENGTH(w->deltas);
+ first = max(w->ndeltas + 1, mask) - mask;
+ last = w->ndeltas;
+
+ cairo_save(cr);
+ cairo_set_source_rgb(cr, .8, .5, .2);
+
+ x = w->deltas[first % mask].x;
+ y = w->deltas[first % mask].y;
+ cairo_move_to(cr, x, y);
+
+ for (i = first + 1; i < last; i++) {
+ x = w->deltas[i % mask].x;
+ y = w->deltas[i % mask].y;
+ cairo_line_to(cr, x, y);
+ }
+
+ cairo_stroke(cr);
+
/* tablet deltas */
mask = ARRAY_LENGTH(w->tool.deltas);
first = max(w->tool.ndeltas + 1, mask) - mask;
@@ -541,11 +566,22 @@ handle_event_motion(struct libinput_event *ev, struct window *w)
struct libinput_event_pointer *p = libinput_event_get_pointer_event(ev);
double dx = libinput_event_pointer_get_dx(p),
dy = libinput_event_pointer_get_dy(p);
+ struct point point;
+ const int mask = ARRAY_LENGTH(w->deltas);
+ size_t idx;
w->x += dx;
w->y += dy;
w->x = clip(w->x, 0.0, w->width);
w->y = clip(w->y, 0.0, w->height);
+
+ idx = w->ndeltas % mask;
+ point = w->deltas[idx];
+ idx = (w->ndeltas + 1) % mask;
+ point.x += libinput_event_pointer_get_dx_unaccelerated(p);
+ point.y += libinput_event_pointer_get_dy_unaccelerated(p);
+ w->deltas[idx] = point;
+ w->ndeltas++;
}
static void