SDL: wayland: Send a display removed event when a display is disconnected

From 458f616c535fad628a6e2b10c88826e8f761905d Mon Sep 17 00:00:00 2001
From: Frank Praznik <[EMAIL REDACTED]>
Date: Sun, 3 Nov 2024 12:39:41 -0500
Subject: [PATCH] wayland: Send a display removed event when a display is
 disconnected

An event would be dispatched if a display was dynamically added after initialization, but not if one was removed.
---
 src/video/wayland/SDL_waylandvideo.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/src/video/wayland/SDL_waylandvideo.c b/src/video/wayland/SDL_waylandvideo.c
index 02952a162ae00..64bc39f522076 100644
--- a/src/video/wayland/SDL_waylandvideo.c
+++ b/src/video/wayland/SDL_waylandvideo.c
@@ -1130,7 +1130,7 @@ static bool Wayland_add_display(SDL_VideoData *d, uint32_t id, uint32_t version)
     return true;
 }
 
-static void Wayland_free_display(SDL_VideoDisplay *display)
+static void Wayland_free_display(SDL_VideoDisplay *display, bool send_event)
 {
     if (display) {
         SDL_DisplayData *display_data = display->internal;
@@ -1154,7 +1154,7 @@ static void Wayland_free_display(SDL_VideoDisplay *display)
             wl_output_destroy(display_data->output);
         }
 
-        SDL_DelVideoDisplay(display->id, false);
+        SDL_DelVideoDisplay(display->id, send_event);
     }
 }
 
@@ -1282,7 +1282,7 @@ static void display_remove_global(void *data, struct wl_registry *registry, uint
     for (int i = 0; i < d->output_count; ++i) {
         SDL_DisplayData *disp = d->output_list[i];
         if (disp->registry_id == id) {
-            Wayland_free_display(SDL_GetVideoDisplay(disp->display));
+            Wayland_free_display(SDL_GetVideoDisplay(disp->display), true);
 
             if (i < d->output_count) {
                 SDL_memmove(&d->output_list[i], &d->output_list[i + 1], sizeof(SDL_DisplayData *) * (d->output_count - i - 1));
@@ -1429,7 +1429,7 @@ static void Wayland_VideoCleanup(SDL_VideoDevice *_this)
 
     for (i = _this->num_displays - 1; i >= 0; --i) {
         SDL_VideoDisplay *display = _this->displays[i];
-        Wayland_free_display(display);
+        Wayland_free_display(display, false);
     }
     SDL_free(data->output_list);