mirror of
https://github.com/hyprwm/wlroots-hyprland.git
synced 2024-11-22 12:55:58 +01: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);
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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);
|
||||
|
@ -217,8 +217,8 @@ static void handle_touch_down(struct wl_listener *listener, void *data) {
|
|||
struct wlr_event_touch_down *event = data;
|
||||
struct touch_point *point = calloc(1, sizeof(struct touch_point));
|
||||
point->touch_id = event->touch_id;
|
||||
point->x = event->x_mm / event->width_mm;
|
||||
point->y = event->y_mm / event->height_mm;
|
||||
point->x = event->x;
|
||||
point->y = event->y;
|
||||
wl_list_insert(&sample->touch_points, &point->link);
|
||||
|
||||
warp_to_touch(sample, event->device);
|
||||
|
@ -232,8 +232,8 @@ static void handle_touch_motion(struct wl_listener *listener, void *data) {
|
|||
struct touch_point *point;
|
||||
wl_list_for_each(point, &sample->touch_points, link) {
|
||||
if (point->touch_id == event->touch_id) {
|
||||
point->x = event->x_mm / event->width_mm;
|
||||
point->y = event->y_mm / event->height_mm;
|
||||
point->x = event->x;
|
||||
point->y = event->y;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -251,8 +251,8 @@ static void handle_tablet_tool_axis(struct wl_listener *listener, void *data) {
|
|||
struct wlr_event_tablet_tool_axis *event = 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);
|
||||
wlr_cursor_warp_absolute(sample->cursor,
|
||||
event->device, event->x, event->y);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -167,8 +167,8 @@ static void touch_down_notify(struct wl_listener *listener, void *data) {
|
|||
struct wlr_event_touch_down *event = data;
|
||||
struct touch_state *tstate = wl_container_of(listener, tstate, down);
|
||||
if (tstate->compositor->touch_down_cb) {
|
||||
tstate->compositor->touch_down_cb(tstate, event->touch_id,
|
||||
event->x_mm, event->y_mm, event->width_mm, event->height_mm);
|
||||
tstate->compositor->touch_down_cb(tstate,
|
||||
event->touch_id, event->x, event->y);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -176,8 +176,8 @@ static void touch_motion_notify(struct wl_listener *listener, void *data) {
|
|||
struct wlr_event_touch_motion *event = data;
|
||||
struct touch_state *tstate = wl_container_of(listener, tstate, motion);
|
||||
if (tstate->compositor->touch_motion_cb) {
|
||||
tstate->compositor->touch_motion_cb(tstate, event->touch_id,
|
||||
event->x_mm, event->y_mm, event->width_mm, event->height_mm);
|
||||
tstate->compositor->touch_motion_cb(tstate,
|
||||
event->touch_id, event->x, event->y);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -102,10 +102,10 @@ struct compositor_state {
|
|||
enum wlr_axis_source source,
|
||||
enum wlr_axis_orientation orientation,
|
||||
double delta);
|
||||
void (*touch_down_cb)(struct touch_state *s, int32_t touch_id,
|
||||
double x, double y, double width, double height);
|
||||
void (*touch_motion_cb)(struct touch_state *s, int32_t touch_id,
|
||||
double x, double y, double width, double height);
|
||||
void (*touch_down_cb)(struct touch_state *s,
|
||||
int32_t touch_id, double x, double y);
|
||||
void (*touch_motion_cb)(struct touch_state *s,
|
||||
int32_t touch_id, double x, double y);
|
||||
void (*touch_up_cb)(struct touch_state *s, int32_t touch_id);
|
||||
void (*touch_cancel_cb)(struct touch_state *s, int32_t touch_id);
|
||||
void (*tool_axis_cb)(struct tablet_tool_state *s,
|
||||
|
|
|
@ -28,7 +28,7 @@ struct sample_state {
|
|||
bool proximity, tap, button;
|
||||
double distance;
|
||||
double pressure;
|
||||
double x_mm, y_mm;
|
||||
double x, y;
|
||||
double x_tilt, y_tilt;
|
||||
double width_mm, height_mm;
|
||||
double ring;
|
||||
|
@ -69,8 +69,8 @@ static void handle_output_frame(struct output_state *output, struct timespec *ts
|
|||
|
||||
if (sample->proximity) {
|
||||
struct wlr_box box = {
|
||||
.x = sample->x_mm * scale - 8 * (sample->pressure + 1) + left,
|
||||
.y = sample->y_mm * scale - 8 * (sample->pressure + 1) + top,
|
||||
.x = (sample->x * pad_width) - 8 * (sample->pressure + 1) + left,
|
||||
.y = (sample->y * pad_height) - 8 * (sample->pressure + 1) + top,
|
||||
.width = 16 * (sample->pressure + 1),
|
||||
.height = 16 * (sample->pressure + 1),
|
||||
};
|
||||
|
@ -94,13 +94,11 @@ static void handle_output_frame(struct output_state *output, struct timespec *ts
|
|||
static void handle_tool_axis(struct tablet_tool_state *tstate,
|
||||
struct wlr_event_tablet_tool_axis *event) {
|
||||
struct sample_state *sample = tstate->compositor->data;
|
||||
sample->width_mm = event->width_mm;
|
||||
sample->height_mm = event->height_mm;
|
||||
if ((event->updated_axes & WLR_TABLET_TOOL_AXIS_X)) {
|
||||
sample->x_mm = event->x_mm;
|
||||
sample->x = event->x;
|
||||
}
|
||||
if ((event->updated_axes & WLR_TABLET_TOOL_AXIS_Y)) {
|
||||
sample->y_mm = event->y_mm;
|
||||
sample->y = event->y;
|
||||
}
|
||||
if ((event->updated_axes & WLR_TABLET_TOOL_AXIS_DISTANCE)) {
|
||||
sample->distance = event->distance;
|
||||
|
@ -164,13 +162,24 @@ static void handle_pad_ring(struct tablet_pad_state *pstate,
|
|||
}
|
||||
}
|
||||
|
||||
static void handle_input_add(struct compositor_state *cstate,
|
||||
struct wlr_input_device *inputdev) {
|
||||
struct sample_state *sample = cstate->data;
|
||||
if (inputdev->type == WLR_INPUT_DEVICE_TABLET_TOOL) {
|
||||
sample->width_mm = inputdev->width_mm == 0 ?
|
||||
20 : inputdev->width_mm;
|
||||
sample->height_mm = inputdev->height_mm == 0 ?
|
||||
10 : inputdev->height_mm;
|
||||
}
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
wlr_log_init(L_DEBUG, NULL);
|
||||
struct sample_state state = {
|
||||
.tool_color = { 1, 1, 1, 1 },
|
||||
.pad_color = { 0.5, 0.5, 0.5, 1.0 }
|
||||
};
|
||||
struct compositor_state compositor = { 0,
|
||||
struct compositor_state compositor = {
|
||||
.data = &state,
|
||||
.output_frame_cb = handle_output_frame,
|
||||
.tool_axis_cb = handle_tool_axis,
|
||||
|
@ -178,6 +187,8 @@ int main(int argc, char *argv[]) {
|
|||
.tool_button_cb = handle_tool_button,
|
||||
.pad_button_cb = handle_pad_button,
|
||||
.pad_ring_cb = handle_pad_ring,
|
||||
.input_add_cb = handle_input_add,
|
||||
0
|
||||
};
|
||||
compositor_init(&compositor);
|
||||
|
||||
|
|
|
@ -60,13 +60,13 @@ static void handle_output_frame(struct output_state *output, struct timespec *ts
|
|||
wlr_output_swap_buffers(wlr_output, NULL, NULL);
|
||||
}
|
||||
|
||||
static void handle_touch_down(struct touch_state *tstate, int32_t touch_id,
|
||||
double x, double y, double width, double height) {
|
||||
static void handle_touch_down(struct touch_state *tstate,
|
||||
int32_t touch_id, double x, double y) {
|
||||
struct sample_state *sample = tstate->compositor->data;
|
||||
struct touch_point *point = calloc(1, sizeof(struct touch_point));
|
||||
point->touch_id = touch_id;
|
||||
point->x = x / width;
|
||||
point->y = y / height;
|
||||
point->x = x;
|
||||
point->y = y;
|
||||
wl_list_insert(&sample->touch_points, &point->link);
|
||||
}
|
||||
|
||||
|
@ -81,14 +81,14 @@ static void handle_touch_up(struct touch_state *tstate, int32_t touch_id) {
|
|||
}
|
||||
}
|
||||
|
||||
static void handle_touch_motion(struct touch_state *tstate, int32_t touch_id,
|
||||
double x, double y, double width, double height) {
|
||||
static void handle_touch_motion(struct touch_state *tstate,
|
||||
int32_t touch_id, double x, double y) {
|
||||
struct sample_state *sample = tstate->compositor->data;
|
||||
struct touch_point *point;
|
||||
wl_list_for_each(point, &sample->touch_points, link) {
|
||||
if (point->touch_id == touch_id) {
|
||||
point->x = x / width;
|
||||
point->y = y / height;
|
||||
point->x = x;
|
||||
point->y = y;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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.
|
||||
|
@ -155,7 +155,7 @@ void wlr_cursor_map_input_to_region(struct wlr_cursor *cur,
|
|||
* Convert absolute coordinates to layout coordinates for the device.
|
||||
*/
|
||||
bool wlr_cursor_absolute_to_layout_coords(struct wlr_cursor *cur,
|
||||
struct wlr_input_device *device, double x_mm, double y_mm,
|
||||
double width_mm, double height_mm, double *lx, double *ly);
|
||||
struct wlr_input_device *device, double x, double y,
|
||||
double *lx, double *ly);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -29,6 +29,8 @@ struct wlr_input_device {
|
|||
enum wlr_input_device_type type;
|
||||
int vendor, product;
|
||||
char *name;
|
||||
// Or 0 if not applicable to this device
|
||||
double width_mm, height_mm;
|
||||
|
||||
/* wlr_input_device.type determines which of these is valid */
|
||||
union {
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -36,8 +36,8 @@ struct wlr_event_tablet_tool_axis {
|
|||
struct wlr_input_device *device;
|
||||
uint32_t time_msec;
|
||||
uint32_t updated_axes;
|
||||
double x_mm, y_mm;
|
||||
double width_mm, height_mm;
|
||||
// From 0..1
|
||||
double x, y;
|
||||
double pressure;
|
||||
double distance;
|
||||
double tilt_x, tilt_y;
|
||||
|
@ -54,8 +54,8 @@ enum wlr_tablet_tool_proximity_state {
|
|||
struct wlr_event_tablet_tool_proximity {
|
||||
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;
|
||||
enum wlr_tablet_tool_proximity_state state;
|
||||
};
|
||||
|
||||
|
@ -67,8 +67,8 @@ enum wlr_tablet_tool_tip_state {
|
|||
struct wlr_event_tablet_tool_tip {
|
||||
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;
|
||||
enum wlr_tablet_tool_tip_state state;
|
||||
};
|
||||
|
||||
|
|
|
@ -23,8 +23,8 @@ struct wlr_event_touch_down {
|
|||
struct wlr_input_device *device;
|
||||
uint32_t time_msec;
|
||||
int32_t touch_id;
|
||||
double x_mm, y_mm;
|
||||
double width_mm, height_mm;
|
||||
// From 0..1
|
||||
double x, y;
|
||||
};
|
||||
|
||||
struct wlr_event_touch_up {
|
||||
|
@ -37,8 +37,8 @@ struct wlr_event_touch_motion {
|
|||
struct wlr_input_device *device;
|
||||
uint32_t time_msec;
|
||||
int32_t touch_id;
|
||||
double x_mm, y_mm;
|
||||
double width_mm, height_mm;
|
||||
// From 0..1
|
||||
double x, y;
|
||||
};
|
||||
|
||||
struct wlr_event_touch_cancel {
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
@ -310,10 +310,8 @@ void roots_cursor_handle_touch_down(struct roots_cursor *cursor,
|
|||
struct roots_desktop *desktop = cursor->seat->input->server->desktop;
|
||||
struct wlr_surface *surface = NULL;
|
||||
double lx, ly;
|
||||
bool result =
|
||||
wlr_cursor_absolute_to_layout_coords(cursor->cursor,
|
||||
event->device, event->x_mm, event->y_mm, event->width_mm,
|
||||
event->height_mm, &lx, &ly);
|
||||
bool result = wlr_cursor_absolute_to_layout_coords(cursor->cursor,
|
||||
event->device, event->x, event->y, &lx, &ly);
|
||||
if (!result) {
|
||||
return;
|
||||
}
|
||||
|
@ -365,8 +363,7 @@ void roots_cursor_handle_touch_motion(struct roots_cursor *cursor,
|
|||
double lx, ly;
|
||||
bool result =
|
||||
wlr_cursor_absolute_to_layout_coords(cursor->cursor,
|
||||
event->device, event->x_mm, event->y_mm, event->width_mm,
|
||||
event->height_mm, &lx, &ly);
|
||||
event->device, event->x, event->y, &lx, &ly);
|
||||
if (!result) {
|
||||
return;
|
||||
}
|
||||
|
@ -395,15 +392,13 @@ void roots_cursor_handle_tool_axis(struct roots_cursor *cursor,
|
|||
if ((event->updated_axes & WLR_TABLET_TOOL_AXIS_X) &&
|
||||
(event->updated_axes & WLR_TABLET_TOOL_AXIS_Y)) {
|
||||
wlr_cursor_warp_absolute(cursor->cursor, event->device,
|
||||
event->x_mm / event->width_mm, event->y_mm / event->height_mm);
|
||||
event->x, event->y);
|
||||
roots_cursor_update_position(cursor, event->time_msec);
|
||||
} else if ((event->updated_axes & WLR_TABLET_TOOL_AXIS_X)) {
|
||||
wlr_cursor_warp_absolute(cursor->cursor, event->device,
|
||||
event->x_mm / event->width_mm, -1);
|
||||
wlr_cursor_warp_absolute(cursor->cursor, event->device, event->x, -1);
|
||||
roots_cursor_update_position(cursor, event->time_msec);
|
||||
} else if ((event->updated_axes & WLR_TABLET_TOOL_AXIS_Y)) {
|
||||
wlr_cursor_warp_absolute(cursor->cursor, event->device,
|
||||
-1, event->y_mm / event->height_mm);
|
||||
wlr_cursor_warp_absolute(cursor->cursor, event->device, -1, event->y);
|
||||
roots_cursor_update_position(cursor, event->time_msec);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
@ -640,19 +640,15 @@ void wlr_cursor_map_input_to_region(struct wlr_cursor *cur,
|
|||
}
|
||||
|
||||
bool wlr_cursor_absolute_to_layout_coords(struct wlr_cursor *cur,
|
||||
struct wlr_input_device *device, double x_mm, double y_mm,
|
||||
double width_mm, double height_mm, double *lx, double *ly) {
|
||||
if (width_mm <= 0 || height_mm <= 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
struct wlr_input_device *device, double x, double y,
|
||||
double *lx, double *ly) {
|
||||
struct wlr_box *mapping = get_mapping(cur, device);
|
||||
if (!mapping) {
|
||||
mapping = wlr_output_layout_get_box(cur->state->layout, NULL);
|
||||
}
|
||||
|
||||
*lx = x_mm > 0 ? mapping->width * (x_mm / width_mm) + mapping->x : cur->x;
|
||||
*ly = y_mm > 0 ? mapping->height * (y_mm / height_mm) + mapping->y : cur->y;
|
||||
*lx = x > 0 ? mapping->width * x + mapping->x : cur->x;
|
||||
*ly = y > 0 ? mapping->height * y + mapping->y : cur->y;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue