}
static void
-x11_output_transform_coordinate(struct x11_output *x11_output,
- wl_fixed_t *x, wl_fixed_t *y)
-{
- struct weston_output *output = &x11_output->base;
- wl_fixed_t tx, ty;
- wl_fixed_t width = wl_fixed_from_int(output->width * output->scale - 1);
- wl_fixed_t height = wl_fixed_from_int(output->height * output->scale - 1);
-
- switch(output->transform) {
- case WL_OUTPUT_TRANSFORM_NORMAL:
- default:
- tx = *x;
- ty = *y;
- break;
- case WL_OUTPUT_TRANSFORM_90:
- tx = *y;
- ty = height - *x;
- break;
- case WL_OUTPUT_TRANSFORM_180:
- tx = width - *x;
- ty = height - *y;
- break;
- case WL_OUTPUT_TRANSFORM_270:
- tx = width - *y;
- ty = *x;
- break;
- case WL_OUTPUT_TRANSFORM_FLIPPED:
- tx = width - *x;
- ty = *y;
- break;
- case WL_OUTPUT_TRANSFORM_FLIPPED_90:
- tx = width - *y;
- ty = height - *x;
- break;
- case WL_OUTPUT_TRANSFORM_FLIPPED_180:
- tx = *x;
- ty = height - *y;
- break;
- case WL_OUTPUT_TRANSFORM_FLIPPED_270:
- tx = *y;
- ty = *x;
- break;
- }
-
- tx /= output->scale;
- ty /= output->scale;
-
- tx += wl_fixed_from_int(output->x);
- ty += wl_fixed_from_int(output->y);
-
- *x = tx;
- *y = ty;
-}
-
-static void
x11_compositor_deliver_motion_event(struct x11_compositor *c,
xcb_generic_event_t *event)
{
if (!c->has_xkb)
update_xkb_state_from_core(c, motion_notify->state);
output = x11_compositor_find_output(c, motion_notify->event);
- x = wl_fixed_from_int(motion_notify->event_x);
- y = wl_fixed_from_int(motion_notify->event_y);
- x11_output_transform_coordinate(output, &x, &y);
+ weston_output_transform_coordinate(&output->base,
+ motion_notify->event_x,
+ motion_notify->event_y, &x, &y);
notify_motion(&c->core_seat, weston_compositor_get_time(),
x - c->prev_x, y - c->prev_y);
if (!c->has_xkb)
update_xkb_state_from_core(c, enter_notify->state);
output = x11_compositor_find_output(c, enter_notify->event);
- x = wl_fixed_from_int(enter_notify->event_x);
- y = wl_fixed_from_int(enter_notify->event_y);
- x11_output_transform_coordinate(output, &x, &y);
+ weston_output_transform_coordinate(&output->base,
+ enter_notify->event_x,
+ enter_notify->event_y, &x, &y);
notify_pointer_focus(&c->core_seat, &output->base, x, y);
wl_signal_emit(&c->output_created_signal, output);
}
+WL_EXPORT void
+weston_output_transform_coordinate(struct weston_output *output,
+ int device_x, int device_y,
+ wl_fixed_t *x, wl_fixed_t *y)
+{
+ wl_fixed_t tx, ty;
+ wl_fixed_t width, height;
+
+ width = wl_fixed_from_int(output->width * output->scale - 1);
+ height = wl_fixed_from_int(output->height * output->scale - 1);
+
+ switch(output->transform) {
+ case WL_OUTPUT_TRANSFORM_NORMAL:
+ default:
+ tx = wl_fixed_from_int(device_x);
+ ty = wl_fixed_from_int(device_y);
+ break;
+ case WL_OUTPUT_TRANSFORM_90:
+ tx = wl_fixed_from_int(device_y);
+ ty = height - wl_fixed_from_int(device_x);
+ break;
+ case WL_OUTPUT_TRANSFORM_180:
+ tx = width - wl_fixed_from_int(device_x);
+ ty = height - wl_fixed_from_int(device_y);
+ break;
+ case WL_OUTPUT_TRANSFORM_270:
+ tx = width - wl_fixed_from_int(device_y);
+ ty = wl_fixed_from_int(device_x);
+ break;
+ case WL_OUTPUT_TRANSFORM_FLIPPED:
+ tx = width - wl_fixed_from_int(device_x);
+ ty = wl_fixed_from_int(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);
+ break;
+ case WL_OUTPUT_TRANSFORM_FLIPPED_180:
+ tx = wl_fixed_from_int(device_x);
+ ty = height - wl_fixed_from_int(device_y);
+ break;
+ case WL_OUTPUT_TRANSFORM_FLIPPED_270:
+ tx = wl_fixed_from_int(device_y);
+ ty = wl_fixed_from_int(device_x);
+ break;
+ }
+
+ *x = tx / output->scale + wl_fixed_from_int(output->x);
+ *y = ty / output->scale + wl_fixed_from_int(output->y);
+}
+
static void
compositor_bind(struct wl_client *client,
void *data, uint32_t version, uint32_t id)
int x, int y, int width, int height, uint32_t transform, int32_t scale);
void
weston_output_destroy(struct weston_output *output);
+void
+weston_output_transform_coordinate(struct weston_output *x11_output,
+ int device_x, int device_y,
+ wl_fixed_t *x, wl_fixed_t *y);
void
weston_seat_init(struct weston_seat *seat, struct weston_compositor *ec,