From 76e07a7fd201391b67988681ef3cf6a53d4f22d2 Mon Sep 17 00:00:00 2001 From: Aidan MacDonald Date: Wed, 16 Jun 2021 13:57:49 +0100 Subject: Touchscreen: adjust how bar padding is handled The old way of padding out bars was to just create a bigger touch region, the intent being to make it easier to touch the end of a bar. Unfortunately, this didn't even accomplish that, and caused an annoying offset between the bar graphics and the touch point. New method is to account for padding explicitly and clamp touches in the padding region so they are within the proper touch region. Change-Id: Id39e571fc1b033a4da94f0eb1143a2fc276bab03 --- apps/gui/skin_engine/skin_touchsupport.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'apps/gui/skin_engine/skin_touchsupport.c') diff --git a/apps/gui/skin_engine/skin_touchsupport.c b/apps/gui/skin_engine/skin_touchsupport.c index b92fd1e83e..045bc809c8 100644 --- a/apps/gui/skin_engine/skin_touchsupport.c +++ b/apps/gui/skin_engine/skin_touchsupport.c @@ -92,6 +92,18 @@ int skin_get_touchaction(struct wps_data *data, int* edge_offset, * are relative to a preceding viewport */ vx = x - wvp->vp.x; vy = y - wvp->vp.y; + + /* project touches in the padding region so they clamp to the + * edge of the region instead */ + if(r->x - r->wpad <= vx && vx < r->x) + vx = r->x; + else if(r->x + r->width <= vx && vx < r->x + r->width + r->wpad) + vx = r->x + r->width - 1; + if(r->y - r->hpad <= vy && vy < r->y) + vy = r->y; + else if(r->y + r->height <= vy && vy < r->y + r->height + r->hpad) + vy = r->y + r->height - 1; + /* now see if the point is inside this region */ if (vx >= r->x && vx < r->x+r->width && vy >= r->y && vy < r->y+r->height) -- cgit v1.2.3