Browse Source

Make sure the display list is up to date for window placement

(cherry picked from commit ab479b49611e8f34573509cfece7e159faa922d6)
Sam Lantinga 2 years ago
parent
commit
7d1bf0a9fe
3 changed files with 11 additions and 0 deletions
  1. 5 0
      src/video/SDL_sysvideo.h
  2. 5 0
      src/video/SDL_video.c
  3. 1 0
      src/video/windows/SDL_windowsvideo.c

+ 5 - 0
src/video/SDL_sysvideo.h

@@ -178,6 +178,11 @@ struct SDL_VideoDevice
      * Display functions
      */
 
+    /*
+     * Refresh the display list
+     */
+    void (*RefreshDisplays)(_THIS);
+
     /*
      * Get the bounds of a display
      */

+ 5 - 0
src/video/SDL_video.c

@@ -1567,6 +1567,11 @@ SDL_CreateWindow(const char *title, int x, int y, int w, int h, Uint32 flags)
         }
     }
 
+    /* Make sure the display list is up to date for window placement */
+    if (_this->RefreshDisplays) {
+        _this->RefreshDisplays(_this);
+    }
+
     /* ensure no more than one of these flags is set */
     type_flags = flags & (SDL_WINDOW_UTILITY | SDL_WINDOW_TOOLTIP | SDL_WINDOW_POPUP_MENU);
     if ((type_flags & (type_flags - 1)) != 0) {

+ 1 - 0
src/video/windows/SDL_windowsvideo.c

@@ -154,6 +154,7 @@ static SDL_VideoDevice *WIN_CreateDevice(void)
     device->VideoInit = WIN_VideoInit;
     device->VideoQuit = WIN_VideoQuit;
 #if !defined(__XBOXONE__) && !defined(__XBOXSERIES__)
+    device->RefreshDisplays = WIN_RefreshDisplays;
     device->GetDisplayBounds = WIN_GetDisplayBounds;
     device->GetDisplayUsableBounds = WIN_GetDisplayUsableBounds;
     device->GetDisplayDPI = WIN_GetDisplayDPI;