update SDL3 from 3.2.20 to 3.4.2
This commit is contained in:
@@ -7,6 +7,52 @@
|
||||
|
||||
/* Private helpers */
|
||||
|
||||
static bool VideoSupportsWindowPositioning(void)
|
||||
{
|
||||
const char *video_driver = SDL_GetCurrentVideoDriver();
|
||||
|
||||
if (SDL_strcmp(video_driver, "android") == 0) {
|
||||
return false;
|
||||
}
|
||||
if (SDL_strcmp(video_driver, "emscripten") == 0) {
|
||||
return false;
|
||||
}
|
||||
if (SDL_strcmp(video_driver, "uikit") == 0) {
|
||||
return false;
|
||||
}
|
||||
if (SDL_strcmp(video_driver, "wayland") == 0) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool VideoSupportsWindowResizing(void)
|
||||
{
|
||||
const char *video_driver = SDL_GetCurrentVideoDriver();
|
||||
|
||||
if (SDL_strcmp(video_driver, "android") == 0) {
|
||||
return false;
|
||||
}
|
||||
if (SDL_strcmp(video_driver, "emscripten") == 0) {
|
||||
return false;
|
||||
}
|
||||
if (SDL_strcmp(video_driver, "uikit") == 0) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool VideoSupportsWindowMinimizing(void)
|
||||
{
|
||||
const char *video_driver = SDL_GetCurrentVideoDriver();
|
||||
|
||||
if (SDL_strcmp(video_driver, "android") == 0) {
|
||||
// Technically it's supported, but minimizing backgrounds the application and stops processing
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a test window
|
||||
*/
|
||||
@@ -358,7 +404,7 @@ static int SDLCALL video_getClosestDisplayModeCurrentResolution(void *arg)
|
||||
SDL_memcpy(¤t, modes[0], sizeof(current));
|
||||
|
||||
/* Make call */
|
||||
result = SDL_GetClosestFullscreenDisplayMode(displays[i], current.w, current.h, current.refresh_rate, false, &closest);
|
||||
result = SDL_GetClosestFullscreenDisplayMode(displays[i], current.w, current.h, current.refresh_rate, (current.pixel_density > 1.0f), &closest);
|
||||
SDLTest_AssertPass("Call to SDL_GetClosestFullscreenDisplayMode(target=current)");
|
||||
SDLTest_AssertCheck(result == true, "Verify return value; expected: true, got: %d", result);
|
||||
|
||||
@@ -1677,8 +1723,8 @@ static int SDLCALL video_setWindowCenteredOnDisplay(void *arg)
|
||||
int result;
|
||||
SDL_Rect display0, display1;
|
||||
const char *video_driver = SDL_GetCurrentVideoDriver();
|
||||
bool video_driver_is_wayland = SDL_strcmp(video_driver, "wayland") == 0;
|
||||
bool video_driver_is_emscripten = SDL_strcmp(video_driver, "emscripten") == 0;
|
||||
const bool video_driver_is_wayland = SDL_strcmp(video_driver, "wayland") == 0;
|
||||
const bool video_driver_is_emscripten = SDL_strcmp(video_driver, "emscripten") == 0;
|
||||
|
||||
displays = SDL_GetDisplays(&displayNum);
|
||||
if (displays) {
|
||||
@@ -1758,89 +1804,94 @@ static int SDLCALL video_setWindowCenteredOnDisplay(void *arg)
|
||||
} else {
|
||||
SDLTest_AssertCheck(currentDisplay == expectedDisplay, "Validate display ID (current: %d, expected: %d)", currentDisplay, expectedDisplay);
|
||||
}
|
||||
if (video_driver_is_emscripten) {
|
||||
if (VideoSupportsWindowResizing()) {
|
||||
SDLTest_AssertCheck(currentW == w, "Validate width (current: %d, expected: %d)", currentW, w);
|
||||
SDLTest_AssertCheck(currentH == h, "Validate height (current: %d, expected: %d)", currentH, h);
|
||||
} else {
|
||||
SDLTest_Log("Skipping window size validation: %s driver does not support window resizing", video_driver);
|
||||
} else {
|
||||
SDLTest_AssertCheck(currentW == w, "Validate width (current: %d, expected: %d)", currentW, w);
|
||||
SDLTest_AssertCheck(currentH == h, "Validate height (current: %d, expected: %d)", currentH, h);
|
||||
}
|
||||
if (video_driver_is_emscripten || video_driver_is_wayland) {
|
||||
SDLTest_Log("Skipping window position validation: %s driver does not support window positioning", video_driver);
|
||||
} else {
|
||||
if (VideoSupportsWindowPositioning()) {
|
||||
SDLTest_AssertCheck(currentX == expectedX, "Validate x (current: %d, expected: %d)", currentX, expectedX);
|
||||
SDLTest_AssertCheck(currentY == expectedY, "Validate y (current: %d, expected: %d)", currentY, expectedY);
|
||||
}
|
||||
|
||||
/* Enter fullscreen desktop */
|
||||
SDL_SetWindowPosition(window, x, y);
|
||||
result = SDL_SetWindowFullscreen(window, true);
|
||||
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);
|
||||
|
||||
/* Check we are filling the full display */
|
||||
currentDisplay = SDL_GetDisplayForWindow(window);
|
||||
SDL_GetWindowSize(window, ¤tW, ¤tH);
|
||||
SDL_GetWindowPosition(window, ¤tX, ¤tY);
|
||||
|
||||
/* Get the expected fullscreen rect.
|
||||
* This needs to be queried after window creation and positioning as some drivers can alter the
|
||||
* usable bounds based on the window scaling mode.
|
||||
*/
|
||||
result = SDL_GetDisplayBounds(expectedDisplay, &expectedFullscreenRect);
|
||||
SDLTest_AssertPass("SDL_GetDisplayBounds()");
|
||||
SDLTest_AssertCheck(result == true, "Verify return value; expected: true, got: %d", result);
|
||||
|
||||
if (video_driver_is_wayland) {
|
||||
SDLTest_Log("Skipping display ID validation: Wayland driver does not support window positioning");
|
||||
} else {
|
||||
SDLTest_AssertCheck(currentDisplay == expectedDisplay, "Validate display ID (current: %d, expected: %d)", currentDisplay, expectedDisplay);
|
||||
SDLTest_Log("Skipping window position validation: %s driver does not support window positioning", video_driver);
|
||||
}
|
||||
|
||||
if (video_driver_is_emscripten) {
|
||||
SDLTest_Log("Skipping window position validation: %s driver does not support window resizing", video_driver);
|
||||
SDLTest_Log("Skipping fullscreen checks on Emscripten: can't toggle fullscreen without returning to mainloop.");
|
||||
} else {
|
||||
SDLTest_AssertCheck(currentW == expectedFullscreenRect.w, "Validate width (current: %d, expected: %d)", currentW, expectedFullscreenRect.w);
|
||||
SDLTest_AssertCheck(currentH == expectedFullscreenRect.h, "Validate height (current: %d, expected: %d)", currentH, expectedFullscreenRect.h);
|
||||
}
|
||||
if (video_driver_is_emscripten || video_driver_is_wayland) {
|
||||
SDLTest_Log("Skipping window position validation: %s driver does not support window positioning", video_driver);
|
||||
} else {
|
||||
SDLTest_AssertCheck(currentX == expectedFullscreenRect.x, "Validate x (current: %d, expected: %d)", currentX, expectedFullscreenRect.x);
|
||||
SDLTest_AssertCheck(currentY == expectedFullscreenRect.y, "Validate y (current: %d, expected: %d)", currentY, expectedFullscreenRect.y);
|
||||
}
|
||||
/* Enter fullscreen desktop */
|
||||
SDL_SetWindowPosition(window, x, y);
|
||||
result = SDL_SetWindowFullscreen(window, true);
|
||||
SDLTest_AssertCheck(result == true, "Verify return value; expected: true, got: %d", result);
|
||||
|
||||
/* Leave fullscreen desktop */
|
||||
result = SDL_SetWindowFullscreen(window, false);
|
||||
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);
|
||||
|
||||
result = SDL_SyncWindow(window);
|
||||
SDLTest_AssertPass("SDL_SyncWindow()");
|
||||
SDLTest_AssertCheck(result == true, "Verify return value; expected: true, got: %d", result);
|
||||
/* Check we are filling the full display */
|
||||
currentDisplay = SDL_GetDisplayForWindow(window);
|
||||
SDL_GetWindowSize(window, ¤tW, ¤tH);
|
||||
SDL_GetWindowPosition(window, ¤tX, ¤tY);
|
||||
|
||||
/* Check window was restored correctly */
|
||||
currentDisplay = SDL_GetDisplayForWindow(window);
|
||||
SDL_GetWindowSize(window, ¤tW, ¤tH);
|
||||
SDL_GetWindowPosition(window, ¤tX, ¤tY);
|
||||
/* Get the expected fullscreen rect.
|
||||
* This needs to be queried after window creation and positioning as some drivers can alter the
|
||||
* usable bounds based on the window scaling mode.
|
||||
*/
|
||||
result = SDL_GetDisplayBounds(expectedDisplay, &expectedFullscreenRect);
|
||||
SDLTest_AssertPass("SDL_GetDisplayBounds()");
|
||||
SDLTest_AssertCheck(result == true, "Verify return value; expected: true, got: %d", result);
|
||||
|
||||
if (video_driver_is_wayland) {
|
||||
SDLTest_Log("Skipping display ID validation: %s driver does not support window positioning", video_driver);
|
||||
} else {
|
||||
SDLTest_AssertCheck(currentDisplay == expectedDisplay, "Validate display index (current: %d, expected: %d)", currentDisplay, expectedDisplay);
|
||||
}
|
||||
if (video_driver_is_emscripten) {
|
||||
SDLTest_Log("Skipping window position validation: %s driver does not support window resizing", video_driver);
|
||||
} else {
|
||||
SDLTest_AssertCheck(currentW == w, "Validate width (current: %d, expected: %d)", currentW, w);
|
||||
SDLTest_AssertCheck(currentH == h, "Validate height (current: %d, expected: %d)", currentH, h);
|
||||
}
|
||||
if (video_driver_is_emscripten || video_driver_is_wayland) {
|
||||
SDLTest_Log("Skipping window position validation: %s driver does not support window positioning", video_driver);
|
||||
} else {
|
||||
SDLTest_AssertCheck(currentX == expectedX, "Validate x (current: %d, expected: %d)", currentX, expectedX);
|
||||
SDLTest_AssertCheck(currentY == expectedY, "Validate y (current: %d, expected: %d)", currentY, expectedY);
|
||||
if (video_driver_is_wayland) {
|
||||
SDLTest_Log("Skipping display ID validation: Wayland driver does not support window positioning");
|
||||
} else {
|
||||
SDLTest_AssertCheck(currentDisplay == expectedDisplay, "Validate display ID (current: %d, expected: %d)", currentDisplay, expectedDisplay);
|
||||
}
|
||||
|
||||
if (VideoSupportsWindowResizing()) {
|
||||
SDLTest_AssertCheck(currentW == expectedFullscreenRect.w, "Validate width (current: %d, expected: %d)", currentW, expectedFullscreenRect.w);
|
||||
SDLTest_AssertCheck(currentH == expectedFullscreenRect.h, "Validate height (current: %d, expected: %d)", currentH, expectedFullscreenRect.h);
|
||||
} else {
|
||||
SDLTest_Log("Skipping window size validation: %s driver does not support window resizing", video_driver);
|
||||
}
|
||||
if (VideoSupportsWindowPositioning()) {
|
||||
SDLTest_AssertCheck(currentX == expectedFullscreenRect.x, "Validate x (current: %d, expected: %d)", currentX, expectedFullscreenRect.x);
|
||||
SDLTest_AssertCheck(currentY == expectedFullscreenRect.y, "Validate y (current: %d, expected: %d)", currentY, expectedFullscreenRect.y);
|
||||
} else {
|
||||
SDLTest_Log("Skipping window position validation: %s driver does not support window positioning", video_driver);
|
||||
}
|
||||
|
||||
/* Leave fullscreen desktop */
|
||||
|
||||
result = SDL_SetWindowFullscreen(window, false);
|
||||
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);
|
||||
|
||||
/* Check window was restored correctly */
|
||||
currentDisplay = SDL_GetDisplayForWindow(window);
|
||||
SDL_GetWindowSize(window, ¤tW, ¤tH);
|
||||
SDL_GetWindowPosition(window, ¤tX, ¤tY);
|
||||
|
||||
if (video_driver_is_wayland) {
|
||||
SDLTest_Log("Skipping display ID validation: %s driver does not support window positioning", video_driver);
|
||||
} else {
|
||||
SDLTest_AssertCheck(currentDisplay == expectedDisplay, "Validate display index (current: %d, expected: %d)", currentDisplay, expectedDisplay);
|
||||
}
|
||||
if (VideoSupportsWindowResizing()) {
|
||||
SDLTest_AssertCheck(currentW == w, "Validate width (current: %d, expected: %d)", currentW, w);
|
||||
SDLTest_AssertCheck(currentH == h, "Validate height (current: %d, expected: %d)", currentH, h);
|
||||
} else {
|
||||
SDLTest_Log("Skipping window size validation: %s driver does not support window resizing", video_driver);
|
||||
}
|
||||
if (VideoSupportsWindowPositioning()) {
|
||||
SDLTest_AssertCheck(currentX == expectedX, "Validate x (current: %d, expected: %d)", currentX, expectedX);
|
||||
SDLTest_AssertCheck(currentY == expectedY, "Validate y (current: %d, expected: %d)", currentY, expectedY);
|
||||
} else {
|
||||
SDLTest_Log("Skipping window position validation: %s driver does not support window positioning", video_driver);
|
||||
}
|
||||
}
|
||||
|
||||
/* Center on display yVariation, and check window properties */
|
||||
@@ -1866,17 +1917,17 @@ static int SDLCALL video_setWindowCenteredOnDisplay(void *arg)
|
||||
} else {
|
||||
SDLTest_AssertCheck(currentDisplay == expectedDisplay, "Validate display ID (current: %d, expected: %d)", currentDisplay, expectedDisplay);
|
||||
}
|
||||
if (video_driver_is_emscripten) {
|
||||
SDLTest_Log("Skipping window position validation: %s driver does not support window resizing", video_driver);
|
||||
} else {
|
||||
if (VideoSupportsWindowResizing()) {
|
||||
SDLTest_AssertCheck(currentW == w, "Validate width (current: %d, expected: %d)", currentW, w);
|
||||
SDLTest_AssertCheck(currentH == h, "Validate height (current: %d, expected: %d)", currentH, h);
|
||||
}
|
||||
if (video_driver_is_emscripten || video_driver_is_wayland) {
|
||||
SDLTest_Log("Skipping window position validation: %s driver does not support window positioning", video_driver);
|
||||
} else {
|
||||
SDLTest_Log("Skipping window size validation: %s driver does not support window resizing", video_driver);
|
||||
}
|
||||
if (VideoSupportsWindowPositioning()) {
|
||||
SDLTest_AssertCheck(currentX == expectedX, "Validate x (current: %d, expected: %d)", currentX, expectedX);
|
||||
SDLTest_AssertCheck(currentY == expectedY, "Validate y (current: %d, expected: %d)", currentY, expectedY);
|
||||
} else {
|
||||
SDLTest_Log("Skipping window position validation: %s driver does not support window positioning", video_driver);
|
||||
}
|
||||
|
||||
/* Clean up */
|
||||
@@ -2270,8 +2321,7 @@ static int SDLCALL video_getSetWindowState(void *arg)
|
||||
minimize_test:
|
||||
|
||||
/* Minimize */
|
||||
result = SDL_MinimizeWindow(window);
|
||||
if (result) {
|
||||
if (VideoSupportsWindowMinimizing() && SDL_MinimizeWindow(window)) {
|
||||
SDLTest_AssertPass("SDL_MinimizeWindow()");
|
||||
SDLTest_AssertCheck(result == true, "Verify return value; expected: true, got: %d", result);
|
||||
|
||||
@@ -2304,6 +2354,11 @@ static int SDLCALL video_createMinimized(void *arg)
|
||||
int windowedX, windowedY;
|
||||
int windowedW, windowedH;
|
||||
|
||||
if (!VideoSupportsWindowMinimizing()) {
|
||||
SDLTest_Log("Skipping creating mimized window, %s reports window minimizing as unsupported", SDL_GetCurrentVideoDriver());
|
||||
return TEST_SKIPPED;
|
||||
}
|
||||
|
||||
/* Call against new test window */
|
||||
window = SDL_CreateWindow(title, 320, 200, SDL_WINDOW_MINIMIZED);
|
||||
if (!window) {
|
||||
@@ -2444,6 +2499,33 @@ static int SDLCALL video_getWindowSurface(void *arg)
|
||||
return TEST_COMPLETED;
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests SDL_RaiseWindow
|
||||
*/
|
||||
static int SDLCALL video_raiseWindow(void *arg)
|
||||
{
|
||||
bool result;
|
||||
SDL_Window *window;
|
||||
|
||||
SDLTest_AssertPass("SDL_SetWindowInputFocus is not supported on dummy and SDL2 wayland driver");
|
||||
if (SDL_strcmp(SDL_GetCurrentVideoDriver(), "dummy") == 0 || SDL_strcmp(SDL_GetCurrentVideoDriver(), "wayland") == 0) {
|
||||
return TEST_SKIPPED;
|
||||
}
|
||||
|
||||
window = createVideoSuiteTestWindow("video_raiseWindow");
|
||||
if (!window) {
|
||||
return TEST_ABORTED;
|
||||
}
|
||||
|
||||
SDLTest_AssertPass("About to call SDL_RaiseWindow(window)");
|
||||
result = SDL_RaiseWindow(window);
|
||||
SDLTest_AssertCheck(result, "Result is %d, expected 1 (%s)", result, SDL_GetError());
|
||||
|
||||
destroyVideoSuiteTestWindow(window);
|
||||
|
||||
return TEST_COMPLETED;
|
||||
}
|
||||
|
||||
/* ================= Test References ================== */
|
||||
|
||||
/* Video test cases */
|
||||
@@ -2534,6 +2616,9 @@ static const SDLTest_TestCaseReference videoTestCreateMaximized = {
|
||||
static const SDLTest_TestCaseReference videoTestGetWindowSurface = {
|
||||
video_getWindowSurface, "video_getWindowSurface", "Checks window surface functionality", TEST_ENABLED
|
||||
};
|
||||
static const SDLTest_TestCaseReference videoTestRaiseWindow = {
|
||||
video_raiseWindow, "video_raiseWindow", "Checks window focus", TEST_ENABLED
|
||||
};
|
||||
|
||||
/* Sequence of Video test cases */
|
||||
static const SDLTest_TestCaseReference *videoTests[] = {
|
||||
@@ -2559,6 +2644,7 @@ static const SDLTest_TestCaseReference *videoTests[] = {
|
||||
&videoTestCreateMinimized,
|
||||
&videoTestCreateMaximized,
|
||||
&videoTestGetWindowSurface,
|
||||
&videoTestRaiseWindow,
|
||||
NULL
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user