SDL: wayland: Destroy the seats before stopping the cursor surface event thread

From acaf53926c2b376b44616b4798687d4100c1708c Mon Sep 17 00:00:00 2001
From: Frank Praznik <[EMAIL REDACTED]>
Date: Sat, 25 Oct 2025 12:54:20 -0400
Subject: [PATCH] wayland: Destroy the seats before stopping the cursor surface
 event thread

Stopping the thread also destroys the queue used by pointer surfaces, and if any seats still have a surface associated with the queue at that time, it will cause a libwayland warning. Destroying the seats first ensures that all surfaces associated with the thread queue are destroyed before the queue is destroyed.
---
 src/video/wayland/SDL_waylandvideo.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/src/video/wayland/SDL_waylandvideo.c b/src/video/wayland/SDL_waylandvideo.c
index e266c5f2fd06d..bddf90320c0e9 100644
--- a/src/video/wayland/SDL_waylandvideo.c
+++ b/src/video/wayland/SDL_waylandvideo.c
@@ -1512,11 +1512,8 @@ static void Wayland_VideoCleanup(SDL_VideoDevice *_this)
 {
     SDL_VideoData *data = _this->internal;
     SDL_WaylandSeat *seat, *tmp;
-    int i;
-
-    Wayland_FiniMouse(data);
 
-    for (i = _this->num_displays - 1; i >= 0; --i) {
+    for (int i = _this->num_displays - 1; i >= 0; --i) {
         SDL_VideoDisplay *display = _this->displays[i];
         Wayland_free_display(display, false);
     }
@@ -1526,6 +1523,8 @@ static void Wayland_VideoCleanup(SDL_VideoDevice *_this)
         Wayland_SeatDestroy(seat, false);
     }
 
+    Wayland_FiniMouse(data);
+
     if (data->pointer_constraints) {
         zwp_pointer_constraints_v1_destroy(data->pointer_constraints);
         data->pointer_constraints = NULL;