From f0e163bab562cce5c605c9adf3fde14d77969918 Mon Sep 17 00:00:00 2001 From: nanahi <130121847+na-na-hi@users.noreply.github.com> Date: Sat, 27 Apr 2024 02:52:31 -0400 Subject: [PATCH] wayland_common: support multitouch Use the multitouch API. No need to emulate mouse input as it's already done by the input system. --- video/out/wayland_common.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/video/out/wayland_common.c b/video/out/wayland_common.c index 697b69d84f..21eca3c5fc 100644 --- a/video/out/wayland_common.c +++ b/video/out/wayland_common.c @@ -440,19 +440,17 @@ static void touch_handle_down(void *data, struct wl_touch *wl_touch, { struct vo_wayland_seat *s = data; struct vo_wayland_state *wl = s->wl; + // Note: the position should still be saved here for VO dragging handling. wl->mouse_x = wl_fixed_to_int(x_w) * wl->scaling; wl->mouse_y = wl_fixed_to_int(y_w) * wl->scaling; - mp_input_set_mouse_pos(wl->vo->input_ctx, wl->mouse_x, wl->mouse_y); - mp_input_put_key(wl->vo->input_ctx, MP_MBTN_LEFT | MP_KEY_STATE_DOWN); + mp_input_add_touch_point(wl->vo->input_ctx, id, wl->mouse_x, wl->mouse_y); enum xdg_toplevel_resize_edge edge; if (!mp_input_test_dragging(wl->vo->input_ctx, wl->mouse_x, wl->mouse_y) && !wl->locked_size && check_for_resize(wl, wl->opts->edge_pixels_touch, &edge)) { xdg_toplevel_resize(wl->xdg_toplevel, s->seat, serial, edge); - // Explicitly send an UP event after the client finishes a resize - mp_input_put_key(wl->vo->input_ctx, MP_MBTN_LEFT | MP_KEY_STATE_UP); } else { // Save the serial and seat for voctrl-initialized dragging requests. s->pointer_button_serial = serial; @@ -465,7 +463,7 @@ static void touch_handle_up(void *data, struct wl_touch *wl_touch, { struct vo_wayland_seat *s = data; struct vo_wayland_state *wl = s->wl; - mp_input_put_key(wl->vo->input_ctx, MP_MBTN_LEFT | MP_KEY_STATE_UP); + mp_input_remove_touch_point(wl->vo->input_ctx, id); wl->last_button_seat = NULL; } @@ -478,7 +476,7 @@ static void touch_handle_motion(void *data, struct wl_touch *wl_touch, wl->mouse_x = wl_fixed_to_int(x_w) * wl->scaling; wl->mouse_y = wl_fixed_to_int(y_w) * wl->scaling; - mp_input_set_mouse_pos(wl->vo->input_ctx, wl->mouse_x, wl->mouse_y); + mp_input_update_touch_point(wl->vo->input_ctx, id, wl->mouse_x, wl->mouse_y); } static void touch_handle_frame(void *data, struct wl_touch *wl_touch) @@ -487,6 +485,9 @@ static void touch_handle_frame(void *data, struct wl_touch *wl_touch) static void touch_handle_cancel(void *data, struct wl_touch *wl_touch) { + struct vo_wayland_seat *s = data; + struct vo_wayland_state *wl = s->wl; + mp_input_put_key(wl->vo->input_ctx, MP_TOUCH_RELEASE_ALL); } static void touch_handle_shape(void *data, struct wl_touch *wl_touch,