touch.c: fix coding style (sx,sy) vs (nx,ny)

Prefer surface to node naming convention for coordinates
This commit is contained in:
Johan Malm 2022-03-28 21:35:59 +01:00
parent 57a937bdf2
commit a188526859
2 changed files with 17 additions and 8 deletions

View file

@ -12,6 +12,15 @@ cursor: add special feature
And please wrap the main commit message at max 74 characters, otherwise `git log` and similar look so weird.
## Naming Convention
There are three types of coordinate systems: surface, output and layout - for
which the variables (sx, sy), (ox, oy) and (lx, ly) are used respectively in
line with wlroots.
With the introduction of the scene-graph API, some wlroots functions also use
node coordinates (nx, ny) but we prefer (sx, sy) where possible.
[coding style]: https://git.sr.ht/~sircmpwn/cstyle
[commit messages]: https://gitlab.freedesktop.org/wlroots/wlroots/-/blob/master/CONTRIBUTING.md#commit-messages
[checkpatch.pl]: https://github.com/johanmalm/checkpatch.pl

View file

@ -4,7 +4,7 @@
static struct wlr_surface*
touch_get_coords(struct seat *seat, struct wlr_touch *touch, double x, double y,
double *nx, double *ny)
double *sx, double *sy)
{
/* Convert coordinates: first [0, 1] => layout, then layout => surface */
double lx, ly;
@ -12,7 +12,7 @@ touch_get_coords(struct seat *seat, struct wlr_touch *touch, double x, double y,
x, y, &lx, &ly);
struct wlr_scene_node *node =
wlr_scene_node_at(&seat->server->scene->node, lx, ly, nx, ny);
wlr_scene_node_at(&seat->server->scene->node, lx, ly, sx, sy);
/* Find the surface and return it if it accepts touch events. */
struct wlr_surface *surface = NULL;
@ -36,10 +36,10 @@ touch_motion(struct wl_listener *listener, void *data)
struct wlr_touch_motion_event *event = data;
wlr_idle_notify_activity(seat->wlr_idle, seat->seat);
double nx, ny;
if (touch_get_coords(seat, event->touch, event->x, event->y, &nx, &ny)) {
double sx, sy;
if (touch_get_coords(seat, event->touch, event->x, event->y, &sx, &sy)) {
wlr_seat_touch_notify_motion(seat->seat, event->time_msec,
event->touch_id, nx, ny);
event->touch_id, sx, sy);
}
}
@ -57,12 +57,12 @@ touch_down(struct wl_listener *listener, void *data)
struct seat *seat = wl_container_of(listener, seat, touch_down);
struct wlr_touch_down_event *event = data;
double nx, ny;
double sx, sy;
struct wlr_surface *surface = touch_get_coords(seat, event->touch,
event->x, event->y, &nx, &ny);
event->x, event->y, &sx, &sy);
if (surface) {
wlr_seat_touch_notify_down(seat->seat, surface,
event->time_msec, event->touch_id, nx, ny);
event->time_msec, event->touch_id, sx, sy);
}
}