Added SDL_CreateWindowWithPosition()

It turns out there's a race condition on X11 where the window could be placed by the window manager while being placed by the application, so we need to have the initial position available at window creation.
This commit is contained in:
Sam Lantinga
2023-03-31 17:07:38 -07:00
parent b6ae281e97
commit 2aa2fa5449
9 changed files with 88 additions and 20 deletions

View File

@@ -1312,15 +1312,12 @@ SDLTest_CommonInit(SDLTest_CommonState *state)
} else {
SDL_strlcpy(title, state->window_title, SDL_arraysize(title));
}
state->windows[i] = SDL_CreateWindow(title, r.w, r.h, state->window_flags);
state->windows[i] = SDL_CreateWindowWithPosition(title, r.x, r.y, r.w, r.h, state->window_flags);
if (!state->windows[i]) {
SDL_Log("Couldn't create window: %s\n",
SDL_GetError());
return SDL_FALSE;
}
if (r.x != SDL_WINDOWPOS_UNDEFINED || r.y != SDL_WINDOWPOS_UNDEFINED) {
SDL_SetWindowPosition(state->windows[i], r.x, r.y);
}
if (state->window_minW || state->window_minH) {
SDL_SetWindowMinimumSize(state->windows[i], state->window_minW, state->window_minH);
}