mirror of
https://github.com/yquake2/yquake2remaster.git
synced 2024-11-30 00:10:53 +00:00
Save original window position before recreate
This commit is contained in:
parent
f0dc7bd6f9
commit
e568e3ff0e
2 changed files with 29 additions and 15 deletions
|
@ -1560,8 +1560,6 @@ static const char *idcredits[] = {
|
|||
"Henk Hartong",
|
||||
"",
|
||||
"+PATCHES AUTHORS",
|
||||
"PGM",
|
||||
"PMM",
|
||||
"eliasm",
|
||||
"",
|
||||
"+YAMAGI QUAKE II BY",
|
||||
|
|
|
@ -37,6 +37,9 @@ cvar_t *vid_displayrefreshrate;
|
|||
int glimp_refreshRate = -1;
|
||||
|
||||
static int last_flags = 0;
|
||||
static int last_display = 0;
|
||||
static int last_position_x = SDL_WINDOWPOS_UNDEFINED;
|
||||
static int last_position_y = SDL_WINDOWPOS_UNDEFINED;
|
||||
static SDL_Window* window = NULL;
|
||||
static qboolean initSuccessful = false;
|
||||
|
||||
|
@ -45,9 +48,16 @@ static qboolean initSuccessful = false;
|
|||
static qboolean
|
||||
CreateSDLWindow(int flags, int w, int h)
|
||||
{
|
||||
int windowPos = SDL_WINDOWPOS_UNDEFINED;
|
||||
|
||||
window = SDL_CreateWindow("Yamagi Quake II", windowPos, windowPos, w, h, flags);
|
||||
window = SDL_CreateWindow("Yamagi Quake II",
|
||||
last_position_x, last_position_y,
|
||||
w, h, flags);
|
||||
if (window)
|
||||
{
|
||||
/* save current display as default */
|
||||
last_display = SDL_GetWindowDisplayIndex(window);
|
||||
SDL_GetWindowPosition(window,
|
||||
&last_position_x, &last_position_y);
|
||||
}
|
||||
|
||||
return window != NULL;
|
||||
}
|
||||
|
@ -136,6 +146,10 @@ ShutdownGraphics(void)
|
|||
{
|
||||
if (window)
|
||||
{
|
||||
/* save current display as default */
|
||||
last_display = SDL_GetWindowDisplayIndex(window);
|
||||
SDL_GetWindowPosition(window,
|
||||
&last_position_x, &last_position_y);
|
||||
/* cleanly ungrab input (needs window) */
|
||||
GLimp_GrabInput(false);
|
||||
SDL_DestroyWindow(window);
|
||||
|
@ -424,22 +438,24 @@ GLimp_GetDesktopMode(int *pwidth, int *pheight)
|
|||
{
|
||||
// Declare display mode structure to be filled in.
|
||||
SDL_DisplayMode mode;
|
||||
int display_id = 0;
|
||||
|
||||
if (window)
|
||||
{
|
||||
display_id = SDL_GetWindowDisplayIndex(window);
|
||||
if (display_id < 0)
|
||||
{
|
||||
// In case of error...
|
||||
Com_Printf("Can't detect current desktop: %s\n",
|
||||
SDL_GetError());
|
||||
display_id = 0;
|
||||
}
|
||||
/* save current display as default */
|
||||
last_display = SDL_GetWindowDisplayIndex(window);
|
||||
SDL_GetWindowPosition(window,
|
||||
&last_position_x, &last_position_y);
|
||||
}
|
||||
|
||||
if (last_display < 0)
|
||||
{
|
||||
// In case of error...
|
||||
Com_Printf("Can't detect current desktop.\n");
|
||||
last_display = 0;
|
||||
}
|
||||
|
||||
// We can't get desktop where we start, so use first desktop
|
||||
if(SDL_GetDesktopDisplayMode(0, &mode) != 0)
|
||||
if(SDL_GetDesktopDisplayMode(last_display, &mode) != 0)
|
||||
{
|
||||
// In case of error...
|
||||
Com_Printf("Can't detect default desktop mode: %s\n",
|
||||
|
|
Loading…
Reference in a new issue