mirror of
https://github.com/libsdl-org/SDL.git
synced 2025-06-03 02:17:39 +00:00
video: Drop size and position requests for windows in a fixed size/position state
It is not uncommon for clients to redundantly set the window size and position, either as a holdover from an SDL 1 port, when this was required, due to any window state change triggering a universal update function that sets all window state, even if unnecessary (e.g. always calling SDL_SetWindowSize(), even if the window is fullscreen), or due to the use of compatability layers. Historically, these clients expect that their behavior won't override the base window state, which is an assumption that the windowing changes in SDL 3 broke by caching size and position changes that can't be applied immediately. This change drops size and position requests when the window is in the maximized and fullscreen states (fullscreen-desktop windows will be repositioned, but the non-fullscreen floating position will not be overwritten), which is behavior more in line with existing client assumptions, and should ease the porting process, as well as prevent annoying bugs when older software is run via sdl2-compat. In the process of making these changes, pending window state has been moved to separate variables in the SDL_Window struct, as this fixes bugs regarding fullscreen display selection and centering windows immediately after resize on asynchronous platforms, which had issues due to pending state possibly being overwritten.
This commit is contained in:
parent
6fa6297441
commit
eda0261c4e
21 changed files with 359 additions and 283 deletions
|
@ -2133,7 +2133,54 @@ static int SDLCALL video_getSetWindowState(void *arg)
|
|||
SDLTest_AssertCheck(windowedW == currentW, "Verify returned width; expected: %d, got: %d", windowedW, currentW);
|
||||
SDLTest_AssertCheck(windowedH == currentH, "Verify returned height; expected: %d, got: %d", windowedH, currentH);
|
||||
|
||||
/* Maximize, change size, and restore */
|
||||
/* Maximize, restore, and change size */
|
||||
result = SDL_MaximizeWindow(window);
|
||||
SDLTest_AssertPass("SDL_MaximizeWindow()");
|
||||
SDLTest_AssertCheck(result == true, "Verify return value; expected: true, got: %d", result);
|
||||
|
||||
result = SDL_RestoreWindow(window);
|
||||
SDLTest_AssertPass("SDL_RestoreWindow()");
|
||||
SDLTest_AssertCheck(result == true, "Verify return value; expected: true, got: %d", result);
|
||||
|
||||
desiredW = windowedW + 10;
|
||||
desiredH = windowedH + 10;
|
||||
result = SDL_SetWindowSize(window, desiredW, desiredH);
|
||||
SDLTest_AssertPass("SDL_SetWindowSize()");
|
||||
SDLTest_AssertCheck(result == true, "Verify return value; expected: true, got: %d", result);
|
||||
|
||||
if (!skipPos) {
|
||||
desiredX = windowedX + 10;
|
||||
desiredY = windowedY + 10;
|
||||
result = SDL_SetWindowPosition(window, desiredX, desiredY);
|
||||
SDLTest_AssertPass("SDL_SetWindowPosition()");
|
||||
SDLTest_AssertCheck(result == true, "Verify return value; expected: true, got: %d", result);
|
||||
}
|
||||
|
||||
result = SDL_SyncWindow(window);
|
||||
SDLTest_AssertPass("SDL_SyncWindow()");
|
||||
SDLTest_AssertCheck(result == true, "Verify return value; expected: true, got: %d", result);
|
||||
|
||||
flags = SDL_GetWindowFlags(window);
|
||||
SDLTest_AssertPass("SDL_GetWindowFlags()");
|
||||
SDLTest_AssertCheck(!(flags & SDL_WINDOW_MAXIMIZED), "Verify that the `SDL_WINDOW_MAXIMIZED` flag is cleared: %s", !(flags & SDL_WINDOW_MAXIMIZED) ? "true" : "false");
|
||||
|
||||
if (!skipPos) {
|
||||
currentX = desiredX + 1;
|
||||
currentY = desiredY + 1;
|
||||
SDL_GetWindowPosition(window, ¤tX, ¤tY);
|
||||
SDLTest_AssertPass("Call to SDL_GetWindowPosition()");
|
||||
SDLTest_AssertCheck(desiredX == currentX, "Verify returned X coordinate; expected: %d, got: %d", desiredX, currentX);
|
||||
SDLTest_AssertCheck(desiredY == currentY, "Verify returned Y coordinate; expected: %d, got: %d", desiredY, currentY);
|
||||
}
|
||||
|
||||
currentW = desiredW + 1;
|
||||
currentH = desiredH + 1;
|
||||
SDL_GetWindowSize(window, ¤tW, ¤tH);
|
||||
SDLTest_AssertPass("Call to SDL_GetWindowSize()");
|
||||
SDLTest_AssertCheck(desiredW == currentW, "Verify returned width; expected: %d, got: %d", desiredW, currentW);
|
||||
SDLTest_AssertCheck(desiredH == currentH, "Verify returned height; expected: %d, got: %d", desiredH, currentH);
|
||||
|
||||
/* Maximize, change size/position (should be ignored), and restore. */
|
||||
result = SDL_MaximizeWindow(window);
|
||||
SDLTest_AssertPass("SDL_MaximizeWindow()");
|
||||
SDLTest_AssertCheck(result == true, "Verify return value; expected: true, got: %d", result);
|
||||
|
@ -2165,20 +2212,20 @@ static int SDLCALL video_getSetWindowState(void *arg)
|
|||
SDLTest_AssertCheck(!(flags & SDL_WINDOW_MAXIMIZED), "Verify that the `SDL_WINDOW_MAXIMIZED` flag is cleared: %s", !(flags & SDL_WINDOW_MAXIMIZED) ? "true" : "false");
|
||||
|
||||
if (!skipPos) {
|
||||
currentX = desiredX + 1;
|
||||
currentY = desiredY + 1;
|
||||
SDL_GetWindowPosition(window, ¤tX, ¤tY);
|
||||
int previousX = desiredX + 1;
|
||||
int previousY = desiredY + 1;
|
||||
SDL_GetWindowPosition(window, &previousX, &previousY);
|
||||
SDLTest_AssertPass("Call to SDL_GetWindowPosition()");
|
||||
SDLTest_AssertCheck(desiredX == currentX, "Verify returned X coordinate; expected: %d, got: %d", desiredX, currentX);
|
||||
SDLTest_AssertCheck(desiredY == currentY, "Verify returned Y coordinate; expected: %d, got: %d", desiredY, currentY);
|
||||
SDLTest_AssertCheck(desiredX == currentX, "Verify returned X coordinate; expected: %d, got: %d", previousX, currentX);
|
||||
SDLTest_AssertCheck(desiredY == currentY, "Verify returned Y coordinate; expected: %d, got: %d", previousY, currentY);
|
||||
}
|
||||
|
||||
currentW = desiredW + 1;
|
||||
currentH = desiredH + 1;
|
||||
SDL_GetWindowSize(window, ¤tW, ¤tH);
|
||||
int previousW = desiredW + 1;
|
||||
int previousH = desiredH + 1;
|
||||
SDL_GetWindowSize(window, &previousW, &previousH);
|
||||
SDLTest_AssertPass("Call to SDL_GetWindowSize()");
|
||||
SDLTest_AssertCheck(desiredW == currentW, "Verify returned width; expected: %d, got: %d", desiredW, currentW);
|
||||
SDLTest_AssertCheck(desiredH == currentH, "Verify returned height; expected: %d, got: %d", desiredH, currentH);
|
||||
SDLTest_AssertCheck(desiredW == currentW, "Verify returned width; expected: %d, got: %d", previousW, currentW);
|
||||
SDLTest_AssertCheck(desiredH == currentH, "Verify returned height; expected: %d, got: %d", previousH, currentH);
|
||||
|
||||
/* Change size and position, maximize and restore */
|
||||
desiredW = windowedW - 5;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue