From a35a5786b0e40cb1ffa87344d3cb21dff9fd99f4 Mon Sep 17 00:00:00 2001 From: Drew DeVault Date: Wed, 28 Mar 2018 10:46:50 -0400 Subject: [PATCH] Remove width_mm from wlr_pointer events --- backend/libinput/pointer.c | 5 ++--- backend/wayland/wl_seat.c | 6 ++---- backend/x11/backend.c | 12 ++++-------- examples/multi-pointer.c | 3 +-- examples/pointer.c | 6 +++--- examples/support/shared.c | 4 ++-- include/wlr/types/wlr_cursor.h | 2 +- include/wlr/types/wlr_pointer.h | 4 ++-- rootston/cursor.c | 4 ++-- types/wlr_cursor.c | 6 +++--- 10 files changed, 22 insertions(+), 30 deletions(-) diff --git a/backend/libinput/pointer.c b/backend/libinput/pointer.c index 8a31d312..9ccda634 100644 --- a/backend/libinput/pointer.c +++ b/backend/libinput/pointer.c @@ -53,9 +53,8 @@ void handle_pointer_motion_abs(struct libinput_event *event, wlr_event.device = wlr_dev; wlr_event.time_msec = usec_to_msec(libinput_event_pointer_get_time_usec(pevent)); - wlr_event.x_mm = libinput_event_pointer_get_absolute_x(pevent); - wlr_event.y_mm = libinput_event_pointer_get_absolute_y(pevent); - libinput_device_get_size(libinput_dev, &wlr_event.width_mm, &wlr_event.height_mm); + wlr_event.x = libinput_event_pointer_get_absolute_x_transformed(pevent, 1); + wlr_event.y = libinput_event_pointer_get_absolute_y_transformed(pevent, 1); wlr_signal_emit_safe(&wlr_dev->pointer->events.motion_absolute, &wlr_event); } diff --git a/backend/wayland/wl_seat.c b/backend/wayland/wl_seat.c index 6ca59130..2d4f76de 100644 --- a/backend/wayland/wl_seat.c +++ b/backend/wayland/wl_seat.c @@ -80,10 +80,8 @@ static void pointer_handle_motion(void *data, struct wl_pointer *wl_pointer, struct wlr_event_pointer_motion_absolute wlr_event; wlr_event.device = dev; wlr_event.time_msec = time; - wlr_event.width_mm = layout_box.width; - wlr_event.height_mm = layout_box.height; - wlr_event.x_mm = transformed.x + wlr_output->lx - layout_box.x; - wlr_event.y_mm = transformed.y + wlr_output->ly - layout_box.y; + wlr_event.x = transformed.x / layout_box.width; + wlr_event.y = transformed.y / layout_box.height; wlr_signal_emit_safe(&dev->pointer->events.motion_absolute, &wlr_event); } diff --git a/backend/x11/backend.c b/backend/x11/backend.c index 36d72d9e..f534676d 100644 --- a/backend/x11/backend.c +++ b/backend/x11/backend.c @@ -108,10 +108,8 @@ static bool handle_x11_event(struct wlr_x11_backend *x11, xcb_generic_event_t *e struct wlr_event_pointer_motion_absolute abs = { .device = &x11->pointer_dev, .time_msec = ev->time, - .x_mm = ev->event_x, - .y_mm = ev->event_y, - .width_mm = output->wlr_output.width, - .height_mm = output->wlr_output.height, + .x = (double)ev->event_x / output->wlr_output.width, + .y = (double)ev->event_y / output->wlr_output.height, }; wlr_signal_emit_safe(&x11->pointer.events.motion_absolute, &abs); @@ -136,10 +134,8 @@ static bool handle_x11_event(struct wlr_x11_backend *x11, xcb_generic_event_t *e struct wlr_event_pointer_motion_absolute abs = { .device = &x11->pointer_dev, .time_msec = x11->time, - .x_mm = pointer->root_x, - .y_mm = pointer->root_y, - .width_mm = output->wlr_output.width, - .height_mm = output->wlr_output.height, + .x = (double)pointer->root_x / output->wlr_output.width, + .y = (double)pointer->root_y / output->wlr_output.height, }; wlr_signal_emit_safe(&x11->pointer.events.motion_absolute, &abs); diff --git a/examples/multi-pointer.c b/examples/multi-pointer.c index 1f869f50..46f0e78f 100644 --- a/examples/multi-pointer.c +++ b/examples/multi-pointer.c @@ -118,8 +118,7 @@ static void handle_cursor_motion_absolute(struct wl_listener *listener, struct sample_cursor *cursor = wl_container_of(listener, cursor, cursor_motion_absolute); struct wlr_event_pointer_motion_absolute *event = data; - wlr_cursor_warp_absolute(cursor->cursor, event->device, - event->x_mm / event->width_mm, event->y_mm / event->height_mm); + wlr_cursor_warp_absolute(cursor->cursor, event->device, event->x, event->y); } static void handle_input_add(struct compositor_state *state, diff --git a/examples/pointer.c b/examples/pointer.c index 9794e6e5..12312092 100644 --- a/examples/pointer.c +++ b/examples/pointer.c @@ -154,8 +154,8 @@ static void handle_cursor_motion_absolute(struct wl_listener *listener, wl_container_of(listener, sample, cursor_motion_absolute); struct wlr_event_pointer_motion_absolute *event = data; - sample->cur_x = event->x_mm; - sample->cur_y = event->y_mm; + sample->cur_x = event->x; + sample->cur_y = event->y; wlr_cursor_warp_absolute(sample->cursor, event->device, sample->cur_x, sample->cur_y); @@ -252,7 +252,7 @@ static void handle_tablet_tool_axis(struct wl_listener *listener, void *data) { if ((event->updated_axes & WLR_TABLET_TOOL_AXIS_X) && (event->updated_axes & WLR_TABLET_TOOL_AXIS_Y)) { wlr_cursor_warp_absolute(sample->cursor, event->device, - event->x_mm / event->width_mm, event->y_mm / event->height_mm); + event->x_mm / event->width_mm, event->y_mm / event->height_mm); } } diff --git a/examples/support/shared.c b/examples/support/shared.c index e6233206..c6460374 100644 --- a/examples/support/shared.c +++ b/examples/support/shared.c @@ -108,8 +108,8 @@ static void pointer_motion_absolute_notify(struct wl_listener *listener, void *d struct wlr_event_pointer_motion_absolute *event = data; struct pointer_state *pstate = wl_container_of(listener, pstate, motion_absolute); if (pstate->compositor->pointer_motion_absolute_cb) { - pstate->compositor->pointer_motion_absolute_cb(pstate, - event->x_mm, event->y_mm); + pstate->compositor->pointer_motion_absolute_cb( + pstate, event->x, event->y); } } diff --git a/include/wlr/types/wlr_cursor.h b/include/wlr/types/wlr_cursor.h index 70dca9f7..ffe149c9 100644 --- a/include/wlr/types/wlr_cursor.h +++ b/include/wlr/types/wlr_cursor.h @@ -73,7 +73,7 @@ bool wlr_cursor_warp(struct wlr_cursor *cur, struct wlr_input_device *dev, double x, double y); void wlr_cursor_warp_absolute(struct wlr_cursor *cur, - struct wlr_input_device *dev, double x_mm, double y_mm); + struct wlr_input_device *dev, double x, double y); /** * Move the cursor in the direction of the given x and y coordinates. diff --git a/include/wlr/types/wlr_pointer.h b/include/wlr/types/wlr_pointer.h index e7ac9b46..a8969b9e 100644 --- a/include/wlr/types/wlr_pointer.h +++ b/include/wlr/types/wlr_pointer.h @@ -29,8 +29,8 @@ struct wlr_event_pointer_motion { struct wlr_event_pointer_motion_absolute { struct wlr_input_device *device; uint32_t time_msec; - double x_mm, y_mm; - double width_mm, height_mm; + // From 0..1 + double x, y; }; struct wlr_event_pointer_button { diff --git a/rootston/cursor.c b/rootston/cursor.c index 52439dff..c1fd7d31 100644 --- a/rootston/cursor.c +++ b/rootston/cursor.c @@ -288,8 +288,8 @@ void roots_cursor_handle_motion(struct roots_cursor *cursor, void roots_cursor_handle_motion_absolute(struct roots_cursor *cursor, struct wlr_event_pointer_motion_absolute *event) { - wlr_cursor_warp_absolute(cursor->cursor, event->device, - event->x_mm / event->width_mm, event->y_mm / event->height_mm); + wlr_cursor_warp_absolute(cursor->cursor, + event->device, event->x, event->y); roots_cursor_update_position(cursor, event->time_msec); } diff --git a/types/wlr_cursor.c b/types/wlr_cursor.c index 20acebf1..ed1a67da 100644 --- a/types/wlr_cursor.c +++ b/types/wlr_cursor.c @@ -254,7 +254,7 @@ bool wlr_cursor_warp(struct wlr_cursor *cur, struct wlr_input_device *dev, } void wlr_cursor_warp_absolute(struct wlr_cursor *cur, - struct wlr_input_device *dev, double x_mm, double y_mm) { + struct wlr_input_device *dev, double x, double y) { assert(cur->state->layout); struct wlr_box *mapping = get_mapping(cur, dev); @@ -262,8 +262,8 @@ void wlr_cursor_warp_absolute(struct wlr_cursor *cur, mapping = wlr_output_layout_get_box(cur->state->layout, NULL); } - double x = x_mm > 0 ? mapping->width * x_mm + mapping->x : cur->x; - double y = y_mm > 0 ? mapping->height * y_mm + mapping->y : cur->y; + x = x > 0 ? mapping->width * x + mapping->x : cur->x; + y = y > 0 ? mapping->height * y + mapping->y : cur->y; wlr_cursor_warp_unchecked(cur, x, y); }