From 2887de55d6c35760dbd05656cfce0e2aa14a8f49 Mon Sep 17 00:00:00 2001
From: Frank Praznik <[EMAIL REDACTED]>
Date: Wed, 4 Feb 2026 14:26:45 -0500
Subject: [PATCH] wayland: Only use owned surface data when processing touches
Otherwise, user data set externally may be treated as SDL window data.
(cherry picked from commit bd472b43f5b0f4153ee59fbf8d556c6c8ff3ef92)
---
src/video/wayland/SDL_waylandevents.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/src/video/wayland/SDL_waylandevents.c b/src/video/wayland/SDL_waylandevents.c
index 40e3730a79c39..e213f57d0da1c 100644
--- a/src/video/wayland/SDL_waylandevents.c
+++ b/src/video/wayland/SDL_waylandevents.c
@@ -122,7 +122,7 @@ static void Wayland_SeatAddTouch(SDL_WaylandSeat *seat, SDL_TouchID id, wl_fixed
static void Wayland_SeatCancelTouch(SDL_WaylandSeat *seat, SDL_WaylandTouchPoint *tp)
{
if (tp->surface) {
- SDL_WindowData *window_data = (SDL_WindowData *)wl_surface_get_user_data(tp->surface);
+ SDL_WindowData *window_data = Wayland_GetWindowDataForOwnedSurface(tp->surface);
if (window_data) {
const float x = (float)(wl_fixed_to_double(tp->fx) / window_data->current.logical_width);
@@ -1429,7 +1429,7 @@ static void touch_handler_up(void *data, struct wl_touch *touch, uint32_t serial
Wayland_SeatRemoveTouch(seat, id, &fx, &fy, &surface);
if (surface) {
- SDL_WindowData *window_data = (SDL_WindowData *)wl_surface_get_user_data(surface);
+ SDL_WindowData *window_data = Wayland_GetWindowDataForOwnedSurface(surface);
if (window_data) {
const float x = (float)wl_fixed_to_double(fx) / window_data->current.logical_width;
@@ -1460,7 +1460,7 @@ static void touch_handler_motion(void *data, struct wl_touch *touch, uint32_t ti
Wayland_SeatUpdateTouch(seat, id, fx, fy, &surface);
if (surface) {
- SDL_WindowData *window_data = (SDL_WindowData *)wl_surface_get_user_data(surface);
+ SDL_WindowData *window_data = Wayland_GetWindowDataForOwnedSurface(surface);
if (window_data) {
const float x = (float)wl_fixed_to_double(fx) / window_data->current.logical_width;