From b6a3cc7f178123d7b094c3036de32548cdeeaeb7 Mon Sep 17 00:00:00 2001 From: Jason Ekstrand Date: Sun, 27 Oct 2013 22:25:00 -0500 Subject: [PATCH] Make weston_output_transform_coordinate more sane The output is renamed "output" from "x11_output" and the input coordinates are changed to wl_fixed_t from int. This way it is useable in compositor-wayland as well as compositor-x11 and evdev. Signed-off-by: Jason Ekstrand --- src/compositor-x11.c | 9 +++++---- src/compositor.c | 34 +++++++++++++++++----------------- src/compositor.h | 4 ++-- src/evdev.c | 16 ++++++++++------ 4 files changed, 34 insertions(+), 29 deletions(-) diff --git a/src/compositor-x11.c b/src/compositor-x11.c index 73e71edf..be082084 100644 --- a/src/compositor-x11.c +++ b/src/compositor-x11.c @@ -1097,8 +1097,9 @@ x11_compositor_deliver_motion_event(struct x11_compositor *c, update_xkb_state_from_core(c, motion_notify->state); output = x11_compositor_find_output(c, motion_notify->event); weston_output_transform_coordinate(&output->base, - motion_notify->event_x, - motion_notify->event_y, &x, &y); + wl_fixed_from_int(motion_notify->event_x), + wl_fixed_from_int(motion_notify->event_y), + &x, &y); notify_motion(&c->core_seat, weston_compositor_get_time(), x - c->prev_x, y - c->prev_y); @@ -1122,8 +1123,8 @@ x11_compositor_deliver_enter_event(struct x11_compositor *c, update_xkb_state_from_core(c, enter_notify->state); output = x11_compositor_find_output(c, enter_notify->event); weston_output_transform_coordinate(&output->base, - enter_notify->event_x, - enter_notify->event_y, &x, &y); + wl_fixed_from_int(enter_notify->event_x), + wl_fixed_from_int(enter_notify->event_y), &x, &y); notify_pointer_focus(&c->core_seat, &output->base, x, y); diff --git a/src/compositor.c b/src/compositor.c index adc219ac..7b87a9ff 100644 --- a/src/compositor.c +++ b/src/compositor.c @@ -3098,7 +3098,7 @@ weston_output_init(struct weston_output *output, struct weston_compositor *c, WL_EXPORT void weston_output_transform_coordinate(struct weston_output *output, - int device_x, int device_y, + wl_fixed_t device_x, wl_fixed_t device_y, wl_fixed_t *x, wl_fixed_t *y) { wl_fixed_t tx, ty; @@ -3110,36 +3110,36 @@ weston_output_transform_coordinate(struct weston_output *output, switch(output->transform) { case WL_OUTPUT_TRANSFORM_NORMAL: default: - tx = wl_fixed_from_int(device_x); - ty = wl_fixed_from_int(device_y); + tx = device_x; + ty = device_y; break; case WL_OUTPUT_TRANSFORM_90: - tx = wl_fixed_from_int(device_y); - ty = height - wl_fixed_from_int(device_x); + tx = device_y; + ty = height - device_x; break; case WL_OUTPUT_TRANSFORM_180: - tx = width - wl_fixed_from_int(device_x); - ty = height - wl_fixed_from_int(device_y); + tx = width - device_x; + ty = height - device_y; break; case WL_OUTPUT_TRANSFORM_270: - tx = width - wl_fixed_from_int(device_y); - ty = wl_fixed_from_int(device_x); + tx = width - device_y; + ty = device_x; break; case WL_OUTPUT_TRANSFORM_FLIPPED: - tx = width - wl_fixed_from_int(device_x); - ty = wl_fixed_from_int(device_y); + tx = width - device_x; + ty = device_y; break; case WL_OUTPUT_TRANSFORM_FLIPPED_90: - tx = width - wl_fixed_from_int(device_y); - ty = height - wl_fixed_from_int(device_x); + tx = width - device_y; + ty = height - device_x; break; case WL_OUTPUT_TRANSFORM_FLIPPED_180: - tx = wl_fixed_from_int(device_x); - ty = height - wl_fixed_from_int(device_y); + tx = device_x; + ty = height - device_y; break; case WL_OUTPUT_TRANSFORM_FLIPPED_270: - tx = wl_fixed_from_int(device_y); - ty = wl_fixed_from_int(device_x); + tx = device_y; + ty = device_x; break; } diff --git a/src/compositor.h b/src/compositor.h index 2487577d..eb105a5b 100644 --- a/src/compositor.h +++ b/src/compositor.h @@ -1156,8 +1156,8 @@ weston_output_init(struct weston_output *output, struct weston_compositor *c, void weston_output_destroy(struct weston_output *output); void -weston_output_transform_coordinate(struct weston_output *x11_output, - int device_x, int device_y, +weston_output_transform_coordinate(struct weston_output *output, + wl_fixed_t device_x, wl_fixed_t device_y, wl_fixed_t *x, wl_fixed_t *y); void diff --git a/src/evdev.c b/src/evdev.c index ad7a3f6b..b3609d5c 100644 --- a/src/evdev.c +++ b/src/evdev.c @@ -104,16 +104,16 @@ evdev_flush_pending_event(struct evdev_device *device, uint32_t time) goto handled; case EVDEV_ABSOLUTE_MT_DOWN: weston_output_transform_coordinate(device->output, - device->mt.slots[slot].x, - device->mt.slots[slot].y, + wl_fixed_from_int(device->mt.slots[slot].x), + wl_fixed_from_int(device->mt.slots[slot].y), &x, &y); notify_touch(master, time, slot, x, y, WL_TOUCH_DOWN); goto handled; case EVDEV_ABSOLUTE_MT_MOTION: weston_output_transform_coordinate(device->output, - device->mt.slots[slot].x, - device->mt.slots[slot].y, + wl_fixed_from_int(device->mt.slots[slot].x), + wl_fixed_from_int(device->mt.slots[slot].y), &x, &y); notify_touch(master, time, slot, x, y, WL_TOUCH_MOTION); @@ -125,13 +125,17 @@ evdev_flush_pending_event(struct evdev_device *device, uint32_t time) case EVDEV_ABSOLUTE_TOUCH_DOWN: transform_absolute(device, &cx, &cy); weston_output_transform_coordinate(device->output, - cx, cy, &x, &y); + wl_fixed_from_int(cx), + wl_fixed_from_int(cy), + &x, &y); notify_touch(master, time, 0, x, y, WL_TOUCH_DOWN); goto handled; case EVDEV_ABSOLUTE_MOTION: transform_absolute(device, &cx, &cy); weston_output_transform_coordinate(device->output, - cx, cy, &x, &y); + wl_fixed_from_int(cx), + wl_fixed_from_int(cy), + &x, &y); if (device->caps & EVDEV_TOUCH) notify_touch(master, time, 0, x, y, WL_TOUCH_MOTION);