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 <jason@jlekstrand.net>
diff --git a/src/compositor-x11.c b/src/compositor-x11.c
index 73e71ed..be08208 100644
--- a/src/compositor-x11.c
+++ b/src/compositor-x11.c
@@ -1097,8 +1097,9 @@
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 @@
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 adc219a..7b87a9f 100644
--- a/src/compositor.c
+++ b/src/compositor.c
@@ -3098,7 +3098,7 @@
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 @@
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 2487577..eb105a5 100644
--- a/src/compositor.h
+++ b/src/compositor.h
@@ -1156,8 +1156,8 @@
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 ad7a3f6..b3609d5 100644
--- a/src/evdev.c
+++ b/src/evdev.c
@@ -104,16 +104,16 @@
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 @@
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);