mirror of
https://github.com/libsdl-org/SDL.git
synced 2026-05-02 03:54:41 +00:00
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:
@@ -1672,14 +1672,10 @@ static int video_setWindowCenteredOnDisplay(void *arg)
|
||||
expectedX = (expectedDisplayRect.x + ((expectedDisplayRect.w - w) / 2));
|
||||
expectedY = (expectedDisplayRect.y + ((expectedDisplayRect.h - h) / 2));
|
||||
|
||||
window = SDL_CreateWindow(title, w, h, SDL_WINDOW_HIDDEN);
|
||||
window = SDL_CreateWindowWithPosition(title, x, y, w, h, 0);
|
||||
SDLTest_AssertPass("Call to SDL_CreateWindow('Title',%d,%d,%d,%d,SHOWN)", x, y, w, h);
|
||||
SDLTest_AssertCheck(window != NULL, "Validate that returned window struct is not NULL");
|
||||
|
||||
/* Set the desired position */
|
||||
SDL_SetWindowPosition(window, x, y);
|
||||
SDL_ShowWindow(window);
|
||||
|
||||
/* Check the window is centered on the requested display */
|
||||
currentDisplay = SDL_GetDisplayForWindow(window);
|
||||
SDL_GetWindowSize(window, ¤tW, ¤tH);
|
||||
|
||||
Reference in New Issue
Block a user