mirror of
https://gitlab.freedesktop.org/wlroots/wlroots.git
synced 2025-12-16 08:56:26 -05:00
Merge pull request #765 from swaywm/transformed-events
Use libinput transformed events instead of width_mm/height_mm
This commit is contained in:
commit
5dd022da13
20 changed files with 105 additions and 100 deletions
|
|
@ -47,7 +47,7 @@ bool legacy_crtc_set_cursor(struct wlr_drm_backend *drm,
|
|||
|
||||
if (drmModeSetCursor(drm->fd, crtc->id, gbm_bo_get_handle(bo).u32,
|
||||
plane->surf.width, plane->surf.height)) {
|
||||
wlr_log_errno(L_ERROR, "Failed to set hardware cursor");
|
||||
wlr_log_errno(L_DEBUG, "Failed to set hardware cursor");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -46,6 +46,8 @@ static struct wlr_input_device *allocate_device(
|
|||
return NULL;
|
||||
}
|
||||
struct wlr_input_device *wlr_dev = &wlr_libinput_dev->wlr_input_device;
|
||||
libinput_device_get_size(libinput_dev,
|
||||
&wlr_dev->width_mm, &wlr_dev->height_mm);
|
||||
wl_list_insert(wlr_devices, &wlr_dev->link);
|
||||
wlr_libinput_dev->handle = libinput_dev;
|
||||
libinput_device_ref(libinput_dev);
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -34,14 +34,13 @@ void handle_tablet_tool_axis(struct libinput_event *event,
|
|||
wlr_event.device = wlr_dev;
|
||||
wlr_event.time_msec =
|
||||
usec_to_msec(libinput_event_tablet_tool_get_time_usec(tevent));
|
||||
libinput_device_get_size(libinput_dev, &wlr_event.width_mm, &wlr_event.height_mm);
|
||||
if (libinput_event_tablet_tool_x_has_changed(tevent)) {
|
||||
wlr_event.updated_axes |= WLR_TABLET_TOOL_AXIS_X;
|
||||
wlr_event.x_mm = libinput_event_tablet_tool_get_x(tevent);
|
||||
wlr_event.x = libinput_event_tablet_tool_get_x_transformed(tevent, 1);
|
||||
}
|
||||
if (libinput_event_tablet_tool_y_has_changed(tevent)) {
|
||||
wlr_event.updated_axes |= WLR_TABLET_TOOL_AXIS_Y;
|
||||
wlr_event.y_mm = libinput_event_tablet_tool_get_y(tevent);
|
||||
wlr_event.y = libinput_event_tablet_tool_get_y_transformed(tevent, 1);
|
||||
}
|
||||
if (libinput_event_tablet_tool_pressure_has_changed(tevent)) {
|
||||
wlr_event.updated_axes |= WLR_TABLET_TOOL_AXIS_PRESSURE;
|
||||
|
|
|
|||
|
|
@ -35,9 +35,8 @@ void handle_touch_down(struct libinput_event *event,
|
|||
wlr_event.time_msec =
|
||||
usec_to_msec(libinput_event_touch_get_time_usec(tevent));
|
||||
wlr_event.touch_id = libinput_event_touch_get_slot(tevent);
|
||||
wlr_event.x_mm = libinput_event_touch_get_x(tevent);
|
||||
wlr_event.y_mm = libinput_event_touch_get_y(tevent);
|
||||
libinput_device_get_size(libinput_dev, &wlr_event.width_mm, &wlr_event.height_mm);
|
||||
wlr_event.x = libinput_event_touch_get_x_transformed(tevent, 1);
|
||||
wlr_event.y = libinput_event_touch_get_y_transformed(tevent, 1);
|
||||
wlr_signal_emit_safe(&wlr_dev->touch->events.down, &wlr_event);
|
||||
}
|
||||
|
||||
|
|
@ -74,9 +73,8 @@ void handle_touch_motion(struct libinput_event *event,
|
|||
wlr_event.time_msec =
|
||||
usec_to_msec(libinput_event_touch_get_time_usec(tevent));
|
||||
wlr_event.touch_id = libinput_event_touch_get_slot(tevent);
|
||||
wlr_event.x_mm = libinput_event_touch_get_x(tevent);
|
||||
wlr_event.y_mm = libinput_event_touch_get_y(tevent);
|
||||
libinput_device_get_size(libinput_dev, &wlr_event.width_mm, &wlr_event.height_mm);
|
||||
wlr_event.x = libinput_event_touch_get_x_transformed(tevent, 1);
|
||||
wlr_event.y = libinput_event_touch_get_y_transformed(tevent, 1);
|
||||
wlr_signal_emit_safe(&wlr_dev->touch->events.motion, &wlr_event);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -64,6 +64,9 @@ static void pointer_handle_motion(void *data, struct wl_pointer *wl_pointer,
|
|||
wl_egl_window_get_attached_size(wlr_wl_pointer->current_output->egl_window,
|
||||
&width, &height);
|
||||
|
||||
int owidth, oheight;
|
||||
wlr_output_effective_resolution(wlr_output, &owidth, &oheight);
|
||||
|
||||
struct wlr_box box = {
|
||||
.x = wl_fixed_to_int(surface_x),
|
||||
.y = wl_fixed_to_int(surface_y),
|
||||
|
|
@ -80,10 +83,15 @@ 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;
|
||||
|
||||
double tx = transformed.x / (double)owidth;
|
||||
double ty = transformed.y / (double)oheight;
|
||||
double ox = wlr_output->lx / (double)layout_box.width;
|
||||
double oy = wlr_output->ly / (double)layout_box.height;
|
||||
|
||||
wlr_event.x = tx * ((double)owidth / layout_box.width) + ox;
|
||||
wlr_event.y = ty * ((double)oheight / layout_box.height) + oy;
|
||||
|
||||
wlr_signal_emit_safe(&dev->pointer->events.motion_absolute, &wlr_event);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -112,10 +112,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);
|
||||
|
|
@ -140,10 +138,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);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue