]> git.mdlowis.com Git - proto/labwc.git/commitdiff
touch.c: fix coding style (sx,sy) vs (nx,ny)
authorJohan Malm <jgm323@gmail.com>
Mon, 28 Mar 2022 20:35:59 +0000 (21:35 +0100)
committerJohan Malm <jgm323@gmail.com>
Mon, 28 Mar 2022 20:35:59 +0000 (21:35 +0100)
Prefer surface to node naming convention for coordinates

CONTRIBUTING.md
src/touch.c

index af1c4bb3f532f649bdb88f96de94be3622880148..a9fb946c62ed55f37154a0036aed79b09c442785 100644 (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
index 5b02b8e262cde2fde8cb135acf05a6d4fc06db9f..a6296acd8028717f8f3d333d17c47ed51f981d5c 100644 (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);
        }
 }