Skip to content

Commit c5d5967

Browse files
Kontrabantslouken
authored andcommitted
video: Store the preferred fullscreen display in a property for sdl2-compat
sdl2-compat will call SDL_GetDisplayForWindow() when querying the display to use for fullscreen, which won't always be correct if the backend can't actually reposition the window. When calling this function, get the ideal fullscreen display and store it in a property for retrieval by sdl2-compat.
1 parent 11e1d4a commit c5d5967

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

src/video/SDL_video.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1731,12 +1731,25 @@ SDL_VideoDisplay *SDL_GetVideoDisplayForFullscreenWindow(SDL_Window *window)
17311731
return SDL_GetVideoDisplay(displayID);
17321732
}
17331733

1734+
#define SDL_PROP_SDL2_COMPAT_WINDOW_PREFERRED_FULLSCREEN_DISPLAY "sdl2-compat.window.preferred_fullscreen_display"
1735+
17341736
SDL_DisplayID SDL_GetDisplayForWindow(SDL_Window *window)
17351737
{
17361738
SDL_DisplayID displayID = 0;
17371739

17381740
CHECK_WINDOW_MAGIC(window, 0);
17391741

1742+
/* sdl2-compat calls this function to get a display on which to make the window fullscreen,
1743+
* so pass it the preferred fullscreen display ID in a property.
1744+
*/
1745+
SDL_PropertiesID window_props = SDL_GetWindowProperties(window);
1746+
SDL_VideoDisplay *fs_display = SDL_GetVideoDisplayForFullscreenWindow(window);
1747+
if (fs_display) {
1748+
SDL_SetNumberProperty(window_props, SDL_PROP_SDL2_COMPAT_WINDOW_PREFERRED_FULLSCREEN_DISPLAY, fs_display->id);
1749+
} else {
1750+
SDL_ClearProperty(window_props, SDL_PROP_SDL2_COMPAT_WINDOW_PREFERRED_FULLSCREEN_DISPLAY);
1751+
}
1752+
17401753
// An explicit fullscreen display overrides all
17411754
if (window->flags & SDL_WINDOW_FULLSCREEN) {
17421755
displayID = window->current_fullscreen_mode.displayID;

0 commit comments

Comments
 (0)