diff --git a/src/input.c b/src/input.c index f8c192f7..50e155e6 100644 --- a/src/input.c +++ b/src/input.c @@ -1608,6 +1608,18 @@ int Get_input(int sleep_time) break; case SDL_WINDOWEVENT_MOVED: GFX2_Log(GFX2_DEBUG, "SDL_WINDOWEVENT_MOVED %d (%d, %d)\n", event.window.windowID, event.window.data1, event.window.data2); + Config.Window_pos_x = event.window.data1; + Config.Window_pos_y = event.window.data2; +#if SDL_VERSION_ATLEAST(2, 0, 5) + { + // correct position by taking window decoration into account + int offset_x, offset_y; + if (SDL_GetWindowBordersSize(SDL_GetWindowFromID(event.window.windowID), &offset_y, &offset_x, NULL, NULL) == 0) { + Config.Window_pos_x -= offset_x; + Config.Window_pos_y -= offset_y; + } + } +#endif break; case SDL_WINDOWEVENT_ENTER: GFX2_Log(GFX2_DEBUG, "SDL_WINDOWEVENT_ENTER %d\n", event.window.windowID); diff --git a/src/main.c b/src/main.c index c3e27abf..e4300116 100644 --- a/src/main.c +++ b/src/main.c @@ -1251,7 +1251,7 @@ void Program_shutdown(void) Config.Window_pos_y = windowplacement.rcNormalPosition.top; } } - #elif !defined(USE_X11) + #elif !defined(USE_X11) && !defined(USE_SDL2) // All other targets: irrelevant dimensions. // Do not attempt to force them back on next program run. Config.Window_pos_x = 9999; diff --git a/src/sdlscreen.c b/src/sdlscreen.c index bf1b50fc..7ccb5ea5 100644 --- a/src/sdlscreen.c +++ b/src/sdlscreen.c @@ -153,7 +153,9 @@ void GFX2_Set_mode(int *width, int *height, int fullscreen) // SDL2 if (Window_SDL == NULL) { - Window_SDL = SDL_CreateWindow("GrafX2", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, + Window_SDL = SDL_CreateWindow("GrafX2", + Config.Window_pos_x != 9999 ? Config.Window_pos_x : (int)SDL_WINDOWPOS_UNDEFINED, + Config.Window_pos_y != 9999 ? Config.Window_pos_y : (int)SDL_WINDOWPOS_UNDEFINED, *width, *height, (fullscreen?SDL_WINDOW_FULLSCREEN:SDL_WINDOW_RESIZABLE)); SDL_SetWindowIcon(Window_SDL, icon); Renderer_SDL = SDL_CreateRenderer(Window_SDL, -1, SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC);