VID_SetMode: SDL2: stay on the current display when changing modes

This allows you to move the QS window to a different monitor and
then go fullscreen on that monitor. QS will still always start on
the primary monitor.

git-svn-id: svn://svn.code.sf.net/p/quakespasm/code/trunk/quakespasm@1407 af15c1b1-3010-417e-b628-4374ebc0bcbd
This commit is contained in:
Eric Wasylishen 2017-05-27 07:29:49 +00:00
parent 0a681bd7cd
commit ebe31714b2

View file

@ -542,6 +542,7 @@ static qboolean VID_SetMode (int width, int height, int bpp, qboolean fullscreen
char caption[50];
int depthbits, stencilbits;
int fsaa_obtained;
int previous_display;
// so Con_Printfs don't mess us up by forcing vid and snd updates
temp = scr_disabled_for_loading;
@ -595,6 +596,12 @@ static qboolean VID_SetMode (int width, int height, int bpp, qboolean fullscreen
}
if (!draw_context)
Sys_Error ("Couldn't create window");
previous_display = -1;
}
else
{
previous_display = SDL_GetWindowDisplayIndex(draw_context);
}
/* Ensure the window is not fullscreen */
@ -606,6 +613,9 @@ static qboolean VID_SetMode (int width, int height, int bpp, qboolean fullscreen
/* Set window size and display mode */
SDL_SetWindowSize (draw_context, width, height);
if (previous_display >= 0)
SDL_SetWindowPosition (draw_context, SDL_WINDOWPOS_CENTERED_DISPLAY(previous_display), SDL_WINDOWPOS_CENTERED_DISPLAY(previous_display));
else
SDL_SetWindowPosition(draw_context, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED);
SDL_SetWindowDisplayMode (draw_context, VID_SDL2_GetDisplayMode(width, height, bpp));
SDL_SetWindowBordered (draw_context, vid_borderless.value ? SDL_FALSE : SDL_TRUE);