Remove width_mm from wlr_touch events
This commit is contained in:
parent
a35a5786b0
commit
324b9d910d
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -156,6 +156,6 @@ 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);
|
||||
double *lx, double *ly);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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 New Issue