Remove width_mm from wlr_pointer events

This commit is contained in:
Drew DeVault 2018-03-28 10:46:50 -04:00
parent 330ee08126
commit a35a5786b0
10 changed files with 22 additions and 30 deletions

View File

@ -53,9 +53,8 @@ void handle_pointer_motion_abs(struct libinput_event *event,
wlr_event.device = wlr_dev; wlr_event.device = wlr_dev;
wlr_event.time_msec = wlr_event.time_msec =
usec_to_msec(libinput_event_pointer_get_time_usec(pevent)); usec_to_msec(libinput_event_pointer_get_time_usec(pevent));
wlr_event.x_mm = libinput_event_pointer_get_absolute_x(pevent); wlr_event.x = libinput_event_pointer_get_absolute_x_transformed(pevent, 1);
wlr_event.y_mm = libinput_event_pointer_get_absolute_y(pevent); wlr_event.y = libinput_event_pointer_get_absolute_y_transformed(pevent, 1);
libinput_device_get_size(libinput_dev, &wlr_event.width_mm, &wlr_event.height_mm);
wlr_signal_emit_safe(&wlr_dev->pointer->events.motion_absolute, &wlr_event); wlr_signal_emit_safe(&wlr_dev->pointer->events.motion_absolute, &wlr_event);
} }

View File

@ -80,10 +80,8 @@ static void pointer_handle_motion(void *data, struct wl_pointer *wl_pointer,
struct wlr_event_pointer_motion_absolute wlr_event; struct wlr_event_pointer_motion_absolute wlr_event;
wlr_event.device = dev; wlr_event.device = dev;
wlr_event.time_msec = time; wlr_event.time_msec = time;
wlr_event.width_mm = layout_box.width; wlr_event.x = transformed.x / layout_box.width;
wlr_event.height_mm = layout_box.height; wlr_event.y = transformed.y / 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_signal_emit_safe(&dev->pointer->events.motion_absolute, &wlr_event); wlr_signal_emit_safe(&dev->pointer->events.motion_absolute, &wlr_event);
} }

View File

@ -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 = { struct wlr_event_pointer_motion_absolute abs = {
.device = &x11->pointer_dev, .device = &x11->pointer_dev,
.time_msec = ev->time, .time_msec = ev->time,
.x_mm = ev->event_x, .x = (double)ev->event_x / output->wlr_output.width,
.y_mm = ev->event_y, .y = (double)ev->event_y / output->wlr_output.height,
.width_mm = output->wlr_output.width,
.height_mm = output->wlr_output.height,
}; };
wlr_signal_emit_safe(&x11->pointer.events.motion_absolute, &abs); 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 = { struct wlr_event_pointer_motion_absolute abs = {
.device = &x11->pointer_dev, .device = &x11->pointer_dev,
.time_msec = x11->time, .time_msec = x11->time,
.x_mm = pointer->root_x, .x = (double)pointer->root_x / output->wlr_output.width,
.y_mm = pointer->root_y, .y = (double)pointer->root_y / output->wlr_output.height,
.width_mm = output->wlr_output.width,
.height_mm = output->wlr_output.height,
}; };
wlr_signal_emit_safe(&x11->pointer.events.motion_absolute, &abs); wlr_signal_emit_safe(&x11->pointer.events.motion_absolute, &abs);

View File

@ -118,8 +118,7 @@ static void handle_cursor_motion_absolute(struct wl_listener *listener,
struct sample_cursor *cursor = struct sample_cursor *cursor =
wl_container_of(listener, cursor, cursor_motion_absolute); wl_container_of(listener, cursor, cursor_motion_absolute);
struct wlr_event_pointer_motion_absolute *event = data; struct wlr_event_pointer_motion_absolute *event = data;
wlr_cursor_warp_absolute(cursor->cursor, event->device, wlr_cursor_warp_absolute(cursor->cursor, event->device, event->x, event->y);
event->x_mm / event->width_mm, event->y_mm / event->height_mm);
} }
static void handle_input_add(struct compositor_state *state, static void handle_input_add(struct compositor_state *state,

View File

@ -154,8 +154,8 @@ static void handle_cursor_motion_absolute(struct wl_listener *listener,
wl_container_of(listener, sample, cursor_motion_absolute); wl_container_of(listener, sample, cursor_motion_absolute);
struct wlr_event_pointer_motion_absolute *event = data; struct wlr_event_pointer_motion_absolute *event = data;
sample->cur_x = event->x_mm; sample->cur_x = event->x;
sample->cur_y = event->y_mm; sample->cur_y = event->y;
wlr_cursor_warp_absolute(sample->cursor, event->device, sample->cur_x, wlr_cursor_warp_absolute(sample->cursor, event->device, sample->cur_x,
sample->cur_y); 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) && if ((event->updated_axes & WLR_TABLET_TOOL_AXIS_X) &&
(event->updated_axes & WLR_TABLET_TOOL_AXIS_Y)) { (event->updated_axes & WLR_TABLET_TOOL_AXIS_Y)) {
wlr_cursor_warp_absolute(sample->cursor, event->device, 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);
} }
} }

View File

@ -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 wlr_event_pointer_motion_absolute *event = data;
struct pointer_state *pstate = wl_container_of(listener, pstate, motion_absolute); struct pointer_state *pstate = wl_container_of(listener, pstate, motion_absolute);
if (pstate->compositor->pointer_motion_absolute_cb) { if (pstate->compositor->pointer_motion_absolute_cb) {
pstate->compositor->pointer_motion_absolute_cb(pstate, pstate->compositor->pointer_motion_absolute_cb(
event->x_mm, event->y_mm); pstate, event->x, event->y);
} }
} }

View File

@ -73,7 +73,7 @@ bool wlr_cursor_warp(struct wlr_cursor *cur, struct wlr_input_device *dev,
double x, double y); double x, double y);
void wlr_cursor_warp_absolute(struct wlr_cursor *cur, 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. * Move the cursor in the direction of the given x and y coordinates.

View File

@ -29,8 +29,8 @@ struct wlr_event_pointer_motion {
struct wlr_event_pointer_motion_absolute { struct wlr_event_pointer_motion_absolute {
struct wlr_input_device *device; struct wlr_input_device *device;
uint32_t time_msec; uint32_t time_msec;
double x_mm, y_mm; // From 0..1
double width_mm, height_mm; double x, y;
}; };
struct wlr_event_pointer_button { struct wlr_event_pointer_button {

View File

@ -288,8 +288,8 @@ void roots_cursor_handle_motion(struct roots_cursor *cursor,
void roots_cursor_handle_motion_absolute(struct roots_cursor *cursor, void roots_cursor_handle_motion_absolute(struct roots_cursor *cursor,
struct wlr_event_pointer_motion_absolute *event) { struct wlr_event_pointer_motion_absolute *event) {
wlr_cursor_warp_absolute(cursor->cursor, event->device, wlr_cursor_warp_absolute(cursor->cursor,
event->x_mm / event->width_mm, event->y_mm / event->height_mm); event->device, event->x, event->y);
roots_cursor_update_position(cursor, event->time_msec); roots_cursor_update_position(cursor, event->time_msec);
} }

View File

@ -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, 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); assert(cur->state->layout);
struct wlr_box *mapping = get_mapping(cur, dev); 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); mapping = wlr_output_layout_get_box(cur->state->layout, NULL);
} }
double x = x_mm > 0 ? mapping->width * x_mm + mapping->x : cur->x; x = x > 0 ? mapping->width * x + mapping->x : cur->x;
double y = y_mm > 0 ? mapping->height * y_mm + mapping->y : cur->y; y = y > 0 ? mapping->height * y + mapping->y : cur->y;
wlr_cursor_warp_unchecked(cur, x, y); wlr_cursor_warp_unchecked(cur, x, y);
} }