SDL: Always Use Next Display Index

From bee8874629409aad58d334ea0fcfd03921626166 Mon Sep 17 00:00:00 2001
From: jimtahu <[EMAIL REDACTED]>
Date: Fri, 15 Nov 2024 14:48:53 -0600
Subject: [PATCH] Always Use Next Display Index

WIN_AddDisplay asserted that the returned index is the expected next
one in the list. This can be an unexpected number when displays are
add and removed in a batch (eg, Remote Desktop disconnect and reconnect).
Instead always just make use of the next index, even if it is not the
expected next index value. This fixes issue #9105
---
 src/video/windows/SDL_windowsmodes.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/src/video/windows/SDL_windowsmodes.c b/src/video/windows/SDL_windowsmodes.c
index 9a37a11ac0637..b29c9e174d566 100644
--- a/src/video/windows/SDL_windowsmodes.c
+++ b/src/video/windows/SDL_windowsmodes.c
@@ -377,11 +377,10 @@ static void WIN_AddDisplay(_THIS, HMONITOR hMonitor, const MONITORINFOEXW *info,
     display.driverdata = displaydata;
     WIN_GetDisplayBounds(_this, &display, &displaydata->bounds);
     index = SDL_AddVideoDisplay(&display, send_event);
-    SDL_assert(index == *display_index);
     SDL_free(display.name);
 
 done:
-    *display_index += 1;
+    *display_index = index + 1;
 }
 
 typedef struct _WIN_AddDisplaysData