wayland_common: support multitouch

Use the multitouch API. No need to emulate mouse input as it's already
done by the input system.
This commit is contained in:
nanahi 2024-04-27 02:52:31 -04:00 committed by Kacper Michajłow
parent 89aa10de24
commit f0e163bab5
1 changed files with 7 additions and 6 deletions

View File

@ -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,