From e568e3ff0e77c844434a29d92a9270b1d2a28c09 Mon Sep 17 00:00:00 2001 From: Denis Pauk Date: Fri, 22 Mar 2019 23:29:17 +0200 Subject: [PATCH] Save original window position before recreate --- src/client/menu/menu.c | 2 -- src/client/vid/glimp_sdl.c | 42 ++++++++++++++++++++++++++------------ 2 files changed, 29 insertions(+), 15 deletions(-) diff --git a/src/client/menu/menu.c b/src/client/menu/menu.c index 8e6743a6..141d5919 100644 --- a/src/client/menu/menu.c +++ b/src/client/menu/menu.c @@ -1560,8 +1560,6 @@ static const char *idcredits[] = { "Henk Hartong", "", "+PATCHES AUTHORS", - "PGM", - "PMM", "eliasm", "", "+YAMAGI QUAKE II BY", diff --git a/src/client/vid/glimp_sdl.c b/src/client/vid/glimp_sdl.c index 8853b4c4..aaaca4c8 100644 --- a/src/client/vid/glimp_sdl.c +++ b/src/client/vid/glimp_sdl.c @@ -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",