This commit requires the libwayland commit "make wl_fixed_t a safe
type".

Track the type changes, making sure the types match. Only the trivial
cases are fixed, where the existing code already did the right thing.

Signed-off-by: Pekka Paalanen <[email protected]>
---
 src/compositor-wayland.c |    7 +++--
 src/compositor-x11.c     |    4 ++-
 src/evdev.c              |   57 +++++++++++++++++++++++++++++-----------------
 src/shell.c              |   26 +++++++++++---------
 4 files changed, 57 insertions(+), 37 deletions(-)

diff --git a/src/compositor-wayland.c b/src/compositor-wayland.c
index 9e1f8a3..d3ba965 100644
--- a/src/compositor-wayland.c
+++ b/src/compositor-wayland.c
@@ -531,7 +531,8 @@ input_handle_pointer_leave(void *data, struct wl_pointer 
*pointer,
        struct wayland_input *input = data;
        struct wayland_compositor *c = input->compositor;
 
-       notify_pointer_focus(&c->base.seat->seat, NULL, 0, 0);
+       notify_pointer_focus(&c->base.seat->seat, NULL,
+                            wl_fixed_from_int(0), wl_fixed_from_int(0));
 }
 
 static void
@@ -542,8 +543,8 @@ input_handle_motion(void *data, struct wl_pointer *pointer,
        struct wayland_compositor *c = input->compositor;
 
        notify_motion(&c->base.seat->seat, time,
-                     x - wl_fixed_from_int(c->border.left),
-                     y - wl_fixed_from_int(c->border.top));
+                     wl_fixed_sub(x, wl_fixed_from_int(c->border.left)),
+                     wl_fixed_sub(y, wl_fixed_from_int(c->border.top)));
 }
 
 static void
diff --git a/src/compositor-x11.c b/src/compositor-x11.c
index d23553e..38999dd 100644
--- a/src/compositor-x11.c
+++ b/src/compositor-x11.c
@@ -726,7 +726,9 @@ x11_compositor_handle_event(int fd, uint32_t mask, void 
*data)
                        if (enter_notify->state >= Button1Mask)
                                break;
                        output = x11_compositor_find_output(c, 
enter_notify->event);
-                       notify_pointer_focus(&c->base.seat->seat, NULL, 0, 0);
+                       notify_pointer_focus(&c->base.seat->seat, NULL,
+                                            wl_fixed_from_int(0),
+                                            wl_fixed_from_int(0));
                        break;
 
                case XCB_CLIENT_MESSAGE:
diff --git a/src/evdev.c b/src/evdev.c
index 23d22d7..d141542 100644
--- a/src/evdev.c
+++ b/src/evdev.c
@@ -158,11 +158,11 @@ evdev_process_relative(struct evdev_input_device *device,
 {
        switch (e->code) {
        case REL_X:
-               device->rel.dx += wl_fixed_from_int(e->value);
+               device->rel.dx.raw += wl_fixed_from_int(e->value).raw;
                device->pending_events |= EVDEV_RELATIVE_MOTION;
                break;
        case REL_Y:
-               device->rel.dy += wl_fixed_from_int(e->value);
+               device->rel.dy.raw += wl_fixed_from_int(e->value).raw;
                device->pending_events |= EVDEV_RELATIVE_MOTION;
                break;
        case REL_WHEEL:
@@ -218,45 +218,60 @@ static void
 evdev_flush_motion(struct evdev_input_device *device, uint32_t time)
 {
        struct weston_seat *master = &device->master->base;
+       wl_fixed_t x, y;
 
        if (!device->pending_events)
                return;
 
        if (device->pending_events & EVDEV_RELATIVE_MOTION) {
-               notify_motion(&master->seat, time,
-                             master->seat.pointer->x + device->rel.dx,
-                             master->seat.pointer->y + device->rel.dy);
+               x = wl_fixed_add(master->seat.pointer->x, device->rel.dx);
+               y = wl_fixed_add(master->seat.pointer->y, device->rel.dy);
+
+               notify_motion(&master->seat, time, x, y);
+
                device->pending_events &= ~EVDEV_RELATIVE_MOTION;
-               device->rel.dx = 0;
-               device->rel.dy = 0;
+               device->rel.dx = wl_fixed_from_int(0);
+               device->rel.dy = wl_fixed_from_int(0);
        }
+
        if (device->pending_events & EVDEV_ABSOLUTE_MT_DOWN) {
-               notify_touch(&master->seat, time,
-                            device->mt.slot,
-                            wl_fixed_from_int(device->mt.x[device->mt.slot]),
-                            wl_fixed_from_int(device->mt.y[device->mt.slot]),
+               x = wl_fixed_from_int(device->mt.x[device->mt.slot]);
+               y = wl_fixed_from_int(device->mt.y[device->mt.slot]);
+
+               notify_touch(&master->seat, time, device->mt.slot, x, y,
                             WL_TOUCH_DOWN);
+
                device->pending_events &= ~EVDEV_ABSOLUTE_MT_DOWN;
                device->pending_events &= ~EVDEV_ABSOLUTE_MT_MOTION;
        }
+
        if (device->pending_events & EVDEV_ABSOLUTE_MT_MOTION) {
-               notify_touch(&master->seat, time,
-                            device->mt.slot,
-                            wl_fixed_from_int(device->mt.x[device->mt.slot]),
-                            wl_fixed_from_int(device->mt.y[device->mt.slot]),
+               x = wl_fixed_from_int(device->mt.x[device->mt.slot]);
+               y = wl_fixed_from_int(device->mt.y[device->mt.slot]);
+
+               notify_touch(&master->seat, time, device->mt.slot, x, y,
                             WL_TOUCH_MOTION);
+
                device->pending_events &= ~EVDEV_ABSOLUTE_MT_DOWN;
                device->pending_events &= ~EVDEV_ABSOLUTE_MT_MOTION;
        }
+
        if (device->pending_events & EVDEV_ABSOLUTE_MT_UP) {
-               notify_touch(&master->seat, time, device->mt.slot, 0, 0,
+               x = wl_fixed_from_int(0);
+               y = wl_fixed_from_int(0);
+
+               notify_touch(&master->seat, time, device->mt.slot, x, y,
                             WL_TOUCH_UP);
+
                device->pending_events &= ~EVDEV_ABSOLUTE_MT_UP;
        }
+
        if (device->pending_events & EVDEV_ABSOLUTE_MOTION) {
-               notify_motion(&master->seat, time,
-                             wl_fixed_from_int(device->abs.x),
-                             wl_fixed_from_int(device->abs.y));
+               x = wl_fixed_from_int(device->abs.x);
+               y = wl_fixed_from_int(device->abs.x);
+
+               notify_motion(&master->seat, time, x, y);
+
                device->pending_events &= ~EVDEV_ABSOLUTE_MOTION;
        }
 }
@@ -474,8 +489,8 @@ evdev_input_device_create(struct evdev_seat *master,
        device->mtdev = NULL;
        device->devnode = strdup(path);
        device->mt.slot = -1;
-       device->rel.dx = 0;
-       device->rel.dy = 0;
+       device->rel.dx = wl_fixed_from_int(0);
+       device->rel.dy = wl_fixed_from_int(0);
        device->dispatch = NULL;
 
        /* Use non-blocking mode so that we can loop on read on
diff --git a/src/shell.c b/src/shell.c
index 40e84b6..1ba0cfc 100644
--- a/src/shell.c
+++ b/src/shell.c
@@ -321,15 +321,15 @@ move_grab_motion(struct wl_pointer_grab *grab,
        struct wl_pointer *pointer = grab->pointer;
        struct shell_surface *shsurf = move->base.shsurf;
        struct weston_surface *es;
-       int dx = wl_fixed_to_int(pointer->x + move->dx);
-       int dy = wl_fixed_to_int(pointer->y + move->dy);
+       wl_fixed_t dx = wl_fixed_add(pointer->x, move->dx);
+       wl_fixed_t dy = wl_fixed_add(pointer->y, move->dy);
 
        if (!shsurf)
                return;
 
        es = shsurf->surface;
 
-       weston_surface_configure(es, dx, dy,
+       weston_surface_configure(es, wl_fixed_to_int(dx), wl_fixed_to_int(dy),
                                 es->geometry.width, es->geometry.height);
 }
 
@@ -510,6 +510,7 @@ static int
 surface_move(struct shell_surface *shsurf, struct weston_seat *ws)
 {
        struct weston_move_grab *move;
+       wl_fixed_t pos_x, pos_y;
 
        if (!shsurf)
                return -1;
@@ -520,10 +521,11 @@ surface_move(struct shell_surface *shsurf, struct 
weston_seat *ws)
 
        shell_grab_init(&move->base, &move_grab_interface, shsurf);
 
-       move->dx = wl_fixed_from_double(shsurf->surface->geometry.x) -
-                       ws->seat.pointer->grab_x;
-       move->dy = wl_fixed_from_double(shsurf->surface->geometry.y) -
-                       ws->seat.pointer->grab_y;
+       pos_x = wl_fixed_from_double(shsurf->surface->geometry.x);
+       pos_y = wl_fixed_from_double(shsurf->surface->geometry.y);
+
+       move->dx = wl_fixed_sub(pos_x, ws->seat.pointer->grab_x);
+       move->dy = wl_fixed_sub(pos_y, ws->seat.pointer->grab_y);
 
        wl_pointer_start_grab(ws->seat.pointer, &move->base.grab);
 
@@ -578,16 +580,16 @@ resize_grab_motion(struct wl_pointer_grab *grab,
 
        width = resize->width;
        if (resize->edges & WL_SHELL_SURFACE_RESIZE_LEFT) {
-               width += wl_fixed_to_int(from_x - to_x);
+               width += wl_fixed_to_int(wl_fixed_sub(from_x, to_x));
        } else if (resize->edges & WL_SHELL_SURFACE_RESIZE_RIGHT) {
-               width += wl_fixed_to_int(to_x - from_x);
+               width += wl_fixed_to_int(wl_fixed_sub(to_x, from_x));
        }
 
        height = resize->height;
        if (resize->edges & WL_SHELL_SURFACE_RESIZE_TOP) {
-               height += wl_fixed_to_int(from_y - to_y);
+               height += wl_fixed_to_int(wl_fixed_sub(from_y, to_y));
        } else if (resize->edges & WL_SHELL_SURFACE_RESIZE_BOTTOM) {
-               height += wl_fixed_to_int(to_y - from_y);
+               height += wl_fixed_to_int(wl_fixed_sub(to_y, from_y));
        }
 
        shsurf->client->send_configure(shsurf->surface,
@@ -1706,7 +1708,7 @@ static void
 zoom_key_binding(struct wl_seat *seat, uint32_t time, uint32_t key,
                 void *data)
 {
-       do_zoom(seat, time, key, 0, 0);
+       do_zoom(seat, time, key, 0, wl_fixed_from_int(0));
 }
 
 static void
-- 
1.7.3.4

_______________________________________________
wayland-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/wayland-devel

Reply via email to