Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle wayland touch cancel message #10950

Merged
merged 1 commit into from
Sep 26, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions src/video/wayland/SDL_waylandevents.c
Original file line number Diff line number Diff line change
Expand Up @@ -932,6 +932,28 @@ static void touch_handler_frame(void *data, struct wl_touch *touch)

static void touch_handler_cancel(void *data, struct wl_touch *touch)
{
struct SDL_WaylandTouchPoint *tp;
while ((tp = touch_points.head)) {
wl_fixed_t fx = 0, fy = 0;
struct wl_surface *surface = NULL;
int id = tp->id;

touch_del(id, &fx, &fy, &surface);

if (surface) {
SDL_WindowData *window_data = (SDL_WindowData *)wl_surface_get_user_data(surface);

if (window_data) {
const double dblx = wl_fixed_to_double(fx) * window_data->pointer_scale_x;
const double dbly = wl_fixed_to_double(fy) * window_data->pointer_scale_y;
const float x = dblx / window_data->sdlwindow->w;
const float y = dbly / window_data->sdlwindow->h;

SDL_SendTouch((SDL_TouchID)(intptr_t)touch, (SDL_FingerID)id,
window_data->sdlwindow, SDL_FALSE, x, y, 1.0f);
}
}
}
}

static const struct wl_touch_listener touch_listener = {
Expand Down
Loading