Clear the undefined position state when the window is placed

This allows the window to be recreated in the same location if needed, for example if recreated because of switching to OpenGL rendering.
This commit is contained in:
Sam Lantinga 2023-02-24 18:04:54 -08:00
parent 4d9d343662
commit 2897de9efc
3 changed files with 2 additions and 18 deletions

View File

@ -63,10 +63,8 @@ int SDL_SendWindowEvent(SDL_Window *window, SDL_EventType windowevent,
window->flags |= SDL_WINDOW_HIDDEN; window->flags |= SDL_WINDOW_HIDDEN;
break; break;
case SDL_EVENT_WINDOW_MOVED: case SDL_EVENT_WINDOW_MOVED:
if (SDL_WINDOWPOS_ISUNDEFINED(data1) || window->undefined_x = SDL_FALSE;
SDL_WINDOWPOS_ISUNDEFINED(data2)) { window->undefined_y = SDL_FALSE;
return 0;
}
if (!(window->flags & SDL_WINDOW_FULLSCREEN)) { if (!(window->flags & SDL_WINDOW_FULLSCREEN)) {
window->windowed.x = data1; window->windowed.x = data1;
window->windowed.y = data2; window->windowed.y = data2;

View File

@ -490,7 +490,6 @@ int WIN_CreateWindow(_THIS, SDL_Window *window)
DWORD style = STYLE_BASIC; DWORD style = STYLE_BASIC;
int x, y; int x, y;
int w, h; int w, h;
SDL_bool undefined_position = SDL_FALSE;
if (window->flags & SDL_WINDOW_SKIP_TASKBAR) { if (window->flags & SDL_WINDOW_SKIP_TASKBAR) {
parent = CreateWindow(SDL_Appname, TEXT(""), STYLE_BASIC, 0, 0, 32, 32, NULL, NULL, SDL_Instance, NULL); parent = CreateWindow(SDL_Appname, TEXT(""), STYLE_BASIC, 0, 0, 32, 32, NULL, NULL, SDL_Instance, NULL);
@ -503,7 +502,6 @@ int WIN_CreateWindow(_THIS, SDL_Window *window)
if (window->undefined_x && window->undefined_y && if (window->undefined_x && window->undefined_y &&
window->last_displayID == SDL_GetPrimaryDisplay()) { window->last_displayID == SDL_GetPrimaryDisplay()) {
undefined_position = SDL_TRUE;
x = CW_USEDEFAULT; x = CW_USEDEFAULT;
y = CW_USEDEFAULT; /* Not actually used */ y = CW_USEDEFAULT; /* Not actually used */
} }
@ -523,12 +521,6 @@ int WIN_CreateWindow(_THIS, SDL_Window *window)
return -1; return -1;
} }
if (undefined_position) {
/* Record where the window ended up */
window->windowed.x = window->x;
window->windowed.y = window->y;
}
/* Inform Windows of the frame change so we can respond to WM_NCCALCSIZE */ /* Inform Windows of the frame change so we can respond to WM_NCCALCSIZE */
SetWindowPos(hwnd, NULL, 0, 0, 0, 0, SWP_FRAMECHANGED | SWP_NOSIZE | SWP_NOZORDER | SWP_NOMOVE | SWP_NOACTIVATE); SetWindowPos(hwnd, NULL, 0, 0, 0, 0, SWP_FRAMECHANGED | SWP_NOSIZE | SWP_NOZORDER | SWP_NOMOVE | SWP_NOACTIVATE);

View File

@ -644,12 +644,6 @@ int X11_CreateWindow(_THIS, SDL_Window *window)
} }
windowdata = window->driverdata; windowdata = window->driverdata;
if (undefined_position) {
/* Record where the window ended up */
window->windowed.x = window->x;
window->windowed.y = window->y;
}
#if SDL_VIDEO_OPENGL_ES || SDL_VIDEO_OPENGL_ES2 || SDL_VIDEO_OPENGL_EGL #if SDL_VIDEO_OPENGL_ES || SDL_VIDEO_OPENGL_ES2 || SDL_VIDEO_OPENGL_EGL
if ((window->flags & SDL_WINDOW_OPENGL) && if ((window->flags & SDL_WINDOW_OPENGL) &&
((_this->gl_config.profile_mask == SDL_GL_CONTEXT_PROFILE_ES) || ((_this->gl_config.profile_mask == SDL_GL_CONTEXT_PROFILE_ES) ||