From 698dbd84640eacfb555e1accbeb53980164f2205 Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Sun, 5 Mar 2023 14:44:38 -0800 Subject: [PATCH] SDL_CreateWindow() has been simplified and no longer takes a window position. --- build-scripts/SDL_migration.cocci | 12 +++ cmake/test/main_cli.c | 6 +- cmake/test/main_gui.c | 15 +-- cmake/test/main_lib.c | 3 +- docs/README-migration.md | 9 ++ docs/README-visualc.md | 2 +- include/SDL3/SDL_shape.h | 9 +- include/SDL3/SDL_video.h | 6 +- src/dynapi/SDL_dynapi_procs.h | 4 +- src/render/SDL_render.c | 4 +- src/test/SDL_test_common.c | 12 +-- src/video/SDL_shape.c | 14 +-- src/video/SDL_sysvideo.h | 4 - src/video/SDL_video.c | 4 +- src/video/cocoa/SDL_cocoashape.h | 1 - src/video/cocoa/SDL_cocoashape.m | 13 --- src/video/cocoa/SDL_cocoavideo.m | 1 - src/video/cocoa/SDL_cocoawindow.m | 4 - src/video/haiku/SDL_bvideo.cc | 4 - src/video/windows/SDL_windowsevents.c | 4 - src/video/windows/SDL_windowsshape.c | 34 ------ src/video/windows/SDL_windowsshape.h | 1 - src/video/windows/SDL_windowsvideo.c | 1 - src/video/x11/SDL_x11shape.c | 34 ------ src/video/x11/SDL_x11shape.h | 1 - src/video/x11/SDL_x11video.c | 1 - src/video/x11/SDL_x11window.c | 3 - test/checkkeys.c | 4 +- test/checkkeysthreads.c | 4 +- test/gamepadmap.c | 4 +- test/relative_mode.markdown | 2 +- test/testaudiocapture.c | 2 +- test/testaudiohotplug.c | 2 +- test/testautomation_mouse.c | 4 +- test/testautomation_render.c | 4 +- test/testautomation_syswm.c | 2 +- test/testautomation_video.c | 150 ++++++-------------------- test/testdrawchessboard.c | 2 +- test/testgamepad.c | 4 +- test/testhittesting.c | 2 +- test/testhotplug.c | 2 +- test/testjoystick.c | 4 +- test/testmessage.c | 2 +- test/testmouse.c | 4 +- test/testmultiaudio.c | 2 +- test/testoffscreen.c | 4 +- test/testsensor.c | 2 +- test/testshader.c | 2 +- test/testshape.c | 6 +- test/teststreaming.c | 6 +- test/testyuv.c | 6 +- 51 files changed, 106 insertions(+), 326 deletions(-) diff --git a/build-scripts/SDL_migration.cocci b/build-scripts/SDL_migration.cocci index 9551bf920..cfbdf9bd6 100644 --- a/build-scripts/SDL_migration.cocci +++ b/build-scripts/SDL_migration.cocci @@ -2517,3 +2517,15 @@ SDL_Event *e1; @@ - e1->csensor + e1->gsensor +@@ +expression e1, e2, e3, e4; +constant c1, c2; +@@ +- SDL_CreateWindow(e1, c1, c2, e2, e3, e4) ++ SDL_CreateWindow(e1, e2, e3, e4) +@@ +expression e1, e2, e3, e4; +constant c1, c2; +@@ +- SDL_CreateShapedWindow(e1, c1, c2, e2, e3, e4) ++ SDL_CreateShapedWindow(e1, e2, e3, e4) diff --git a/cmake/test/main_cli.c b/cmake/test/main_cli.c index 0449709c0..25bb28aed 100644 --- a/cmake/test/main_cli.c +++ b/cmake/test/main_cli.c @@ -1,12 +1,12 @@ #define SDL_MAIN_HANDLED #include #include -#include -int main(int argc, char *argv[]) { +int main(int argc, char *argv[]) +{ SDL_SetMainReady(); if (SDL_Init(0) < 0) { - fprintf(stderr, "Could not initialize SDL: %s\n", SDL_GetError()); + SDL_Log("Could not initialize SDL: %s\n", SDL_GetError()); return 1; } SDL_Delay(100); diff --git a/cmake/test/main_gui.c b/cmake/test/main_gui.c index 2e1aa0f15..715c4306f 100644 --- a/cmake/test/main_gui.c +++ b/cmake/test/main_gui.c @@ -1,22 +1,17 @@ #include #include -#include -int main(int argc, char *argv[]) { +int main(int argc, char *argv[]) +{ SDL_Window *window = NULL; SDL_Surface *screenSurface = NULL; if (SDL_Init(SDL_INIT_VIDEO) < 0) { - fprintf(stderr, "Could not initialize SDL: %s\n", SDL_GetError()); + SDL_Log("Could not initialize SDL: %s\n", SDL_GetError()); return 1; } - window = SDL_CreateWindow( - "Hello SDL", - SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, - 640, 480, - 0 - ); + window = SDL_CreateWindow("Hello SDL", 640, 480, 0); if (window == NULL) { - fprintf(stderr, "could not create window: %s\n", SDL_GetError()); + SDL_Log("could not create window: %s\n", SDL_GetError()); return 1; } screenSurface = SDL_GetWindowSurface(window); diff --git a/cmake/test/main_lib.c b/cmake/test/main_lib.c index 78d7c60dd..9468d71f1 100644 --- a/cmake/test/main_lib.c +++ b/cmake/test/main_lib.c @@ -1,7 +1,6 @@ #include #define SDL_MAIN_HANDLED /* don't drag in header-only SDL_main implementation */ #include -#include #include EXPORT_HEADER @@ -19,7 +18,7 @@ int MYLIBRARY_EXPORT mylibrary_work(void); int mylibrary_init(void) { SDL_SetMainReady(); if (SDL_Init(0) < 0) { - fprintf(stderr, "Could not initialize SDL: %s\n", SDL_GetError()); + SDL_Log("Could not initialize SDL: %s\n", SDL_GetError()); return 1; } return 0; diff --git a/docs/README-migration.md b/docs/README-migration.md index 557a1038f..b6f51e996 100644 --- a/docs/README-migration.md +++ b/docs/README-migration.md @@ -1031,6 +1031,15 @@ Rather than iterating over displays using display index, there is a new function } ``` +SDL_CreateWindow() has been simplified and no longer takes a window position. You can set a position for your window during window creation by creating it hidden and setting the position before showing it: +```c +{ + SDL_Window *window = SDL_CreateWindow("Test", 640, 480, SDL_WINDOW_HIDDEN); + SDL_SetWindowPosition(window, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED); + SDL_ShowWindow(window); +} +``` + The SDL_WINDOWPOS_UNDEFINED_DISPLAY() and SDL_WINDOWPOS_CENTERED_DISPLAY() macros take a display ID instead of display index. The display ID 0 has a special meaning in this case, and is used to indicate the primary display. The SDL_WINDOW_SHOWN flag has been removed. Windows are shown by default and can be created hidden by using the SDL_WINDOW_HIDDEN flag. diff --git a/docs/README-visualc.md b/docs/README-visualc.md index 4864548a7..276c83bce 100644 --- a/docs/README-visualc.md +++ b/docs/README-visualc.md @@ -87,7 +87,7 @@ Here's a sample SDL snippet to verify everything is setup in your IDE: SDL_Renderer* renderer = NULL; SDL_Init(SDL_INIT_VIDEO); - window = SDL_CreateWindow("Hello SDL", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, WIDTH, HEIGHT, 0); + window = SDL_CreateWindow("Hello SDL", WIDTH, HEIGHT, 0); renderer = SDL_CreateRenderer(window, NULL, SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC); SDL_DestroyRenderer(renderer); diff --git a/include/SDL3/SDL_shape.h b/include/SDL3/SDL_shape.h index 964556ad9..4b7fb661f 100644 --- a/include/SDL3/SDL_shape.h +++ b/include/SDL3/SDL_shape.h @@ -44,14 +44,9 @@ extern "C" { #define SDL_WINDOW_LACKS_SHAPE -3 /** - * Create a window that can be shaped with the specified position, dimensions, - * and flags. + * Create a window that can be shaped with the specified dimensions and flags. * * \param title The title of the window, in UTF-8 encoding. - * \param x The x position of the window, ::SDL_WINDOWPOS_CENTERED, or - * ::SDL_WINDOWPOS_UNDEFINED. - * \param y The y position of the window, ::SDL_WINDOWPOS_CENTERED, or - * ::SDL_WINDOWPOS_UNDEFINED. * \param w The width of the window. * \param h The height of the window. * \param flags The flags for the window, a mask of SDL_WINDOW_BORDERLESS with @@ -66,7 +61,7 @@ extern "C" { * * \sa SDL_DestroyWindow */ -extern DECLSPEC SDL_Window * SDLCALL SDL_CreateShapedWindow(const char *title,unsigned int x,unsigned int y,unsigned int w,unsigned int h,Uint32 flags); +extern DECLSPEC SDL_Window *SDLCALL SDL_CreateShapedWindow(const char *title, int w, int h, Uint32 flags); /** * Return whether the given window is a shaped window. diff --git a/include/SDL3/SDL_video.h b/include/SDL3/SDL_video.h index f64e92ae9..ebdc8a779 100644 --- a/include/SDL3/SDL_video.h +++ b/include/SDL3/SDL_video.h @@ -631,10 +631,6 @@ extern DECLSPEC Uint32 SDLCALL SDL_GetWindowPixelFormat(SDL_Window *window); * in a future version of SDL. * * \param title the title of the window, in UTF-8 encoding - * \param x the x position of the window, `SDL_WINDOWPOS_CENTERED`, or - * `SDL_WINDOWPOS_UNDEFINED` - * \param y the y position of the window, `SDL_WINDOWPOS_CENTERED`, or - * `SDL_WINDOWPOS_UNDEFINED` * \param w the width of the window, in screen coordinates * \param h the height of the window, in screen coordinates * \param flags 0, or one or more SDL_WindowFlags OR'd together @@ -646,7 +642,7 @@ extern DECLSPEC Uint32 SDLCALL SDL_GetWindowPixelFormat(SDL_Window *window); * \sa SDL_CreateWindowFrom * \sa SDL_DestroyWindow */ -extern DECLSPEC SDL_Window *SDLCALL SDL_CreateWindow(const char *title, int x, int y, int w, int h, Uint32 flags); +extern DECLSPEC SDL_Window *SDLCALL SDL_CreateWindow(const char *title, int w, int h, Uint32 flags); /** * Create an SDL window from an existing native window. diff --git a/src/dynapi/SDL_dynapi_procs.h b/src/dynapi/SDL_dynapi_procs.h index e253666ff..fab380c95 100644 --- a/src/dynapi/SDL_dynapi_procs.h +++ b/src/dynapi/SDL_dynapi_procs.h @@ -165,14 +165,14 @@ SDL_DYNAPI_PROC(SDL_Palette*,SDL_CreatePalette,(int a),(a),return) SDL_DYNAPI_PROC(SDL_PixelFormat*,SDL_CreatePixelFormat,(Uint32 a),(a),return) SDL_DYNAPI_PROC(SDL_Renderer*,SDL_CreateRenderer,(SDL_Window *a, const char *b, Uint32 c),(a,b,c),return) SDL_DYNAPI_PROC(SDL_sem*,SDL_CreateSemaphore,(Uint32 a),(a),return) -SDL_DYNAPI_PROC(SDL_Window*,SDL_CreateShapedWindow,(const char *a, unsigned int b, unsigned int c, unsigned int d, unsigned int e, Uint32 f),(a,b,c,d,e,f),return) +SDL_DYNAPI_PROC(SDL_Window*,SDL_CreateShapedWindow,(const char *a, int b, int c, Uint32 d),(a,b,c,d),return) SDL_DYNAPI_PROC(SDL_Renderer*,SDL_CreateSoftwareRenderer,(SDL_Surface *a),(a),return) SDL_DYNAPI_PROC(SDL_Surface*,SDL_CreateSurface,(int a, int b, Uint32 c),(a,b,c),return) SDL_DYNAPI_PROC(SDL_Surface*,SDL_CreateSurfaceFrom,(void *a, int b, int c, int d, Uint32 e),(a,b,c,d,e),return) SDL_DYNAPI_PROC(SDL_Cursor*,SDL_CreateSystemCursor,(SDL_SystemCursor a),(a),return) SDL_DYNAPI_PROC(SDL_Texture*,SDL_CreateTexture,(SDL_Renderer *a, Uint32 b, int c, int d, int e),(a,b,c,d,e),return) SDL_DYNAPI_PROC(SDL_Texture*,SDL_CreateTextureFromSurface,(SDL_Renderer *a, SDL_Surface *b),(a,b),return) -SDL_DYNAPI_PROC(SDL_Window*,SDL_CreateWindow,(const char *a, int b, int c, int d, int e, Uint32 f),(a,b,c,d,e,f),return) +SDL_DYNAPI_PROC(SDL_Window*,SDL_CreateWindow,(const char *a, int b, int c, Uint32 d),(a,b,c,d),return) SDL_DYNAPI_PROC(int,SDL_CreateWindowAndRenderer,(int a, int b, Uint32 c, SDL_Window **d, SDL_Renderer **e),(a,b,c,d,e),return) SDL_DYNAPI_PROC(SDL_Window*,SDL_CreateWindowFrom,(const void *a),(a),return) SDL_DYNAPI_PROC(SDL_bool,SDL_CursorVisible,(void),(),return) diff --git a/src/render/SDL_render.c b/src/render/SDL_render.c index d6e415761..166ab0dbc 100644 --- a/src/render/SDL_render.c +++ b/src/render/SDL_render.c @@ -727,9 +727,7 @@ static int SDLCALL SDL_RendererEventWatch(void *userdata, SDL_Event *event) int SDL_CreateWindowAndRenderer(int width, int height, Uint32 window_flags, SDL_Window **window, SDL_Renderer **renderer) { - *window = SDL_CreateWindow(NULL, SDL_WINDOWPOS_UNDEFINED, - SDL_WINDOWPOS_UNDEFINED, - width, height, window_flags); + *window = SDL_CreateWindow(NULL, width, height, window_flags); if (!*window) { *renderer = NULL; return -1; diff --git a/src/test/SDL_test_common.c b/src/test/SDL_test_common.c index 47cc0bbb7..0aecf4d72 100644 --- a/src/test/SDL_test_common.c +++ b/src/test/SDL_test_common.c @@ -81,7 +81,7 @@ SDLTest_CommonCreateState(char **argv, Uint32 flags) state->argv = argv; state->flags = flags; state->window_title = argv[0]; - state->window_flags = 0; + state->window_flags = SDL_WINDOW_HIDDEN; state->window_x = SDL_WINDOWPOS_UNDEFINED; state->window_y = SDL_WINDOWPOS_UNDEFINED; state->window_w = DEFAULT_WINDOW_WIDTH; @@ -1278,10 +1278,6 @@ SDLTest_CommonInit(SDLTest_CommonState *state) } SDL_free(displays); - if (SDL_WINDOWPOS_ISUNDEFINED(state->window_x)) { - state->window_x = SDL_WINDOWPOS_UNDEFINED_DISPLAY(state->displayID); - state->window_y = SDL_WINDOWPOS_UNDEFINED_DISPLAY(state->displayID); - } if (SDL_WINDOWPOS_ISCENTERED(state->window_x)) { state->window_x = SDL_WINDOWPOS_CENTERED_DISPLAY(state->displayID); state->window_y = SDL_WINDOWPOS_CENTERED_DISPLAY(state->displayID); @@ -1326,13 +1322,15 @@ SDLTest_CommonInit(SDLTest_CommonState *state) } else { SDL_strlcpy(title, state->window_title, SDL_arraysize(title)); } - state->windows[i] = - SDL_CreateWindow(title, r.x, r.y, r.w, r.h, state->window_flags); + state->windows[i] = SDL_CreateWindow(title, 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); } diff --git a/src/video/SDL_shape.c b/src/video/SDL_shape.c index f00bbc2d3..709959046 100644 --- a/src/video/SDL_shape.c +++ b/src/video/SDL_shape.c @@ -24,10 +24,10 @@ #include "SDL_shape_internals.h" SDL_Window * -SDL_CreateShapedWindow(const char *title, unsigned int x, unsigned int y, unsigned int w, unsigned int h, Uint32 flags) +SDL_CreateShapedWindow(const char *title, int w, int h, Uint32 flags) { SDL_Window *result = NULL; - result = SDL_CreateWindow(title, -1000, -1000, w, h, (flags | SDL_WINDOW_BORDERLESS) & (~SDL_WINDOW_FULLSCREEN) & (~SDL_WINDOW_RESIZABLE)); + result = SDL_CreateWindow(title, w, h, (flags | SDL_WINDOW_BORDERLESS | SDL_WINDOW_HIDDEN) & (~SDL_WINDOW_FULLSCREEN) & (~SDL_WINDOW_RESIZABLE)); if (result != NULL) { if (SDL_GetVideoDevice()->shape_driver.CreateShaper == NULL) { SDL_DestroyWindow(result); @@ -35,8 +35,6 @@ SDL_CreateShapedWindow(const char *title, unsigned int x, unsigned int y, unsign } result->shaper = SDL_GetVideoDevice()->shape_driver.CreateShaper(result); if (result->shaper != NULL) { - result->shaper->userx = x; - result->shaper->usery = y; result->shaper->mode.mode = ShapeModeDefault; result->shaper->mode.parameters.binarizationCutoff = 1; result->shaper->hasshape = SDL_FALSE; @@ -271,11 +269,9 @@ int SDL_SetWindowShape(SDL_Window *window, SDL_Surface *shape, SDL_WindowShapeMo window->shaper->mode = *shape_mode; } result = _this->shape_driver.SetWindowShape(window->shaper, shape, shape_mode); - window->shaper->hasshape = SDL_TRUE; - if (window->shaper->userx != 0 && window->shaper->usery != 0) { - SDL_SetWindowPosition(window, window->shaper->userx, window->shaper->usery); - window->shaper->userx = 0; - window->shaper->usery = 0; + if (result == 0) { + window->shaper->hasshape = SDL_TRUE; + SDL_ShowWindow(window); } return result; } diff --git a/src/video/SDL_sysvideo.h b/src/video/SDL_sysvideo.h index 0fb800288..2c690cf81 100644 --- a/src/video/SDL_sysvideo.h +++ b/src/video/SDL_sysvideo.h @@ -42,9 +42,6 @@ struct SDL_WindowShaper /* The window associated with the shaper */ SDL_Window *window; - /* The user's specified coordinates for the window, for once we give it a shape. */ - Uint32 userx, usery; - /* The parameters for shape calculation. */ SDL_WindowShapeMode mode; @@ -59,7 +56,6 @@ struct SDL_ShapeDriver { SDL_WindowShaper *(*CreateShaper)(SDL_Window *window); int (*SetWindowShape)(SDL_WindowShaper *shaper, SDL_Surface *shape, SDL_WindowShapeMode *shape_mode); - int (*ResizeWindowShape)(SDL_Window *window); }; typedef struct SDL_WindowUserData diff --git a/src/video/SDL_video.c b/src/video/SDL_video.c index ad1f58d2b..c5d048fc9 100644 --- a/src/video/SDL_video.c +++ b/src/video/SDL_video.c @@ -1651,10 +1651,12 @@ static int SDL_DllNotSupported(const char *name) return SDL_SetError("No dynamic %s support in current SDL video driver (%s)", name, _this->name); } -SDL_Window *SDL_CreateWindow(const char *title, int x, int y, int w, int h, Uint32 flags) +SDL_Window *SDL_CreateWindow(const char *title, int w, int h, Uint32 flags) { SDL_Window *window; Uint32 type_flags, graphics_flags; + int x = SDL_WINDOWPOS_UNDEFINED; + int y = SDL_WINDOWPOS_UNDEFINED; SDL_bool undefined_x = SDL_FALSE; SDL_bool undefined_y = SDL_FALSE; diff --git a/src/video/cocoa/SDL_cocoashape.h b/src/video/cocoa/SDL_cocoashape.h index f824cf410..a7c6d14a5 100644 --- a/src/video/cocoa/SDL_cocoashape.h +++ b/src/video/cocoa/SDL_cocoashape.h @@ -34,6 +34,5 @@ extern SDL_WindowShaper *Cocoa_CreateShaper(SDL_Window *window); extern int Cocoa_SetWindowShape(SDL_WindowShaper *shaper, SDL_Surface *shape, SDL_WindowShapeMode *shape_mode); -extern int Cocoa_ResizeWindowShape(SDL_Window *window); #endif /* SDL_cocoashape_h_ */ diff --git a/src/video/cocoa/SDL_cocoashape.m b/src/video/cocoa/SDL_cocoashape.m index c77ef8661..803bb8a29 100644 --- a/src/video/cocoa/SDL_cocoashape.m +++ b/src/video/cocoa/SDL_cocoashape.m @@ -44,7 +44,6 @@ Cocoa_CreateShaper(SDL_Window *window) @autoreleasepool { SDL_WindowShaper *result; SDL_ShapeData *data; - int resized_properly; SDL_CocoaWindowData *windata = (__bridge SDL_CocoaWindowData *)window->driverdata; result = (SDL_WindowShaper *)SDL_malloc(sizeof(SDL_WindowShaper)); @@ -60,7 +59,6 @@ Cocoa_CreateShaper(SDL_Window *window) result->window = window; result->mode.mode = ShapeModeDefault; result->mode.parameters.binarizationCutoff = 1; - result->userx = result->usery = 0; window->shaper = result; data = [[SDL_ShapeData alloc] init]; @@ -71,8 +69,6 @@ Cocoa_CreateShaper(SDL_Window *window) /* TODO: There's no place to release this... */ result->driverdata = (void *)CFBridgingRetain(data); - resized_properly = Cocoa_ResizeWindowShape(window); - SDL_assert(resized_properly == 0); return result; } } @@ -117,13 +113,4 @@ int Cocoa_SetWindowShape(SDL_WindowShaper *shaper, SDL_Surface *shape, SDL_Windo } } -int Cocoa_ResizeWindowShape(SDL_Window *window) -{ - @autoreleasepool { - SDL_ShapeData *data = (__bridge SDL_ShapeData *)window->shaper->driverdata; - SDL_assert(data != NULL); - return 0; - } -} - #endif /* SDL_VIDEO_DRIVER_COCOA */ diff --git a/src/video/cocoa/SDL_cocoavideo.m b/src/video/cocoa/SDL_cocoavideo.m index fa9f48320..1d46bc8bb 100644 --- a/src/video/cocoa/SDL_cocoavideo.m +++ b/src/video/cocoa/SDL_cocoavideo.m @@ -121,7 +121,6 @@ static SDL_VideoDevice *Cocoa_CreateDevice(void) device->shape_driver.CreateShaper = Cocoa_CreateShaper; device->shape_driver.SetWindowShape = Cocoa_SetWindowShape; - device->shape_driver.ResizeWindowShape = Cocoa_ResizeWindowShape; #if SDL_VIDEO_OPENGL_CGL device->GL_LoadLibrary = Cocoa_GL_LoadLibrary; diff --git a/src/video/cocoa/SDL_cocoawindow.m b/src/video/cocoa/SDL_cocoawindow.m index fb0f00d6c..5d105f5ba 100644 --- a/src/video/cocoa/SDL_cocoawindow.m +++ b/src/video/cocoa/SDL_cocoawindow.m @@ -816,10 +816,6 @@ static void Cocoa_UpdateClipCursor(SDL_Window *window) w = (int)rect.size.width; h = (int)rect.size.height; - if (SDL_IsShapedWindow(window)) { - Cocoa_ResizeWindowShape(window); - } - ScheduleContextUpdates(_data); /* The window can move during a resize event, such as when maximizing diff --git a/src/video/haiku/SDL_bvideo.cc b/src/video/haiku/SDL_bvideo.cc index a5a16fe9d..2a44241fa 100644 --- a/src/video/haiku/SDL_bvideo.cc +++ b/src/video/haiku/SDL_bvideo.cc @@ -96,10 +96,6 @@ static SDL_VideoDevice * HAIKU_CreateDevice(void) device->UpdateWindowFramebuffer = HAIKU_UpdateWindowFramebuffer; device->DestroyWindowFramebuffer = HAIKU_DestroyWindowFramebuffer; - device->shape_driver.CreateShaper = NULL; - device->shape_driver.SetWindowShape = NULL; - device->shape_driver.ResizeWindowShape = NULL; - #if SDL_VIDEO_OPENGL device->GL_LoadLibrary = HAIKU_GL_LoadLibrary; device->GL_GetProcAddress = HAIKU_GL_GetProcAddress; diff --git a/src/video/windows/SDL_windowsevents.c b/src/video/windows/SDL_windowsevents.c index 487ce3c30..a7444fbae 100644 --- a/src/video/windows/SDL_windowsevents.c +++ b/src/video/windows/SDL_windowsevents.c @@ -1131,10 +1131,6 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) int max_w, max_h; BOOL constrain_max_size; - if (SDL_IsShapedWindow(data->window)) { - Win32_ResizeWindowShape(data->window); - } - /* If this is an expected size change, allow it */ if (data->expected_resize) { break; diff --git a/src/video/windows/SDL_windowsshape.c b/src/video/windows/SDL_windowsshape.c index 702c97585..cec1e83a1 100644 --- a/src/video/windows/SDL_windowsshape.c +++ b/src/video/windows/SDL_windowsshape.c @@ -28,7 +28,6 @@ SDL_WindowShaper * Win32_CreateShaper(SDL_Window *window) { - int resized_properly; SDL_WindowShaper *result = (SDL_WindowShaper *)SDL_malloc(sizeof(SDL_WindowShaper)); if (result == NULL) { SDL_OutOfMemory(); @@ -37,7 +36,6 @@ Win32_CreateShaper(SDL_Window *window) result->window = window; result->mode.mode = ShapeModeDefault; result->mode.parameters.binarizationCutoff = 1; - result->userx = result->usery = 0; result->hasshape = SDL_FALSE; result->driverdata = (SDL_ShapeData *)SDL_calloc(1, sizeof(SDL_ShapeData)); if (!result->driverdata) { @@ -46,14 +44,6 @@ Win32_CreateShaper(SDL_Window *window) return NULL; } window->shaper = result; - /* Put some driver-data here. */ - resized_properly = Win32_ResizeWindowShape(window); - if (resized_properly != 0) { - SDL_free(result->driverdata); - SDL_free(result); - window->shaper = NULL; - return NULL; - } return result; } @@ -98,28 +88,4 @@ int Win32_SetWindowShape(SDL_WindowShaper *shaper, SDL_Surface *shape, SDL_Windo return 0; } -int Win32_ResizeWindowShape(SDL_Window *window) -{ - SDL_ShapeData *data; - - if (window == NULL) { - return -1; - } - data = (SDL_ShapeData *)window->shaper->driverdata; - if (data == NULL) { - return -1; - } - - if (data->mask_tree != NULL) { - SDL_FreeShapeTree(&data->mask_tree); - } - if (window->shaper->hasshape == SDL_TRUE) { - window->shaper->userx = window->x; - window->shaper->usery = window->y; - SDL_SetWindowPosition(window, -1000, -1000); - } - - return 0; -} - #endif /* SDL_VIDEO_DRIVER_WINDOWS */ diff --git a/src/video/windows/SDL_windowsshape.h b/src/video/windows/SDL_windowsshape.h index 1e869fe94..074f7edf4 100644 --- a/src/video/windows/SDL_windowsshape.h +++ b/src/video/windows/SDL_windowsshape.h @@ -34,6 +34,5 @@ typedef struct extern SDL_WindowShaper *Win32_CreateShaper(SDL_Window *window); extern int Win32_SetWindowShape(SDL_WindowShaper *shaper, SDL_Surface *shape, SDL_WindowShapeMode *shape_mode); -extern int Win32_ResizeWindowShape(SDL_Window *window); #endif /* SDL_windowsshape_h_ */ diff --git a/src/video/windows/SDL_windowsvideo.c b/src/video/windows/SDL_windowsvideo.c index 9cb30d820..7afe97f1d 100644 --- a/src/video/windows/SDL_windowsvideo.c +++ b/src/video/windows/SDL_windowsvideo.c @@ -205,7 +205,6 @@ static SDL_VideoDevice *WIN_CreateDevice(void) device->shape_driver.CreateShaper = Win32_CreateShaper; device->shape_driver.SetWindowShape = Win32_SetWindowShape; - device->shape_driver.ResizeWindowShape = Win32_ResizeWindowShape; #endif #if SDL_VIDEO_OPENGL_WGL diff --git a/src/video/x11/SDL_x11shape.c b/src/video/x11/SDL_x11shape.c index f726dd2e3..9d5b29953 100644 --- a/src/video/x11/SDL_x11shape.c +++ b/src/video/x11/SDL_x11shape.c @@ -44,7 +44,6 @@ X11_CreateShaper(SDL_Window *window) result->window = window; result->mode.mode = ShapeModeDefault; result->mode.parameters.binarizationCutoff = 1; - result->userx = result->usery = 0; data = SDL_malloc(sizeof(SDL_ShapeData)); if (data == NULL) { SDL_free(result); @@ -55,45 +54,12 @@ X11_CreateShaper(SDL_Window *window) data->bitmapsize = 0; data->bitmap = NULL; window->shaper = result; - if (X11_ResizeWindowShape(window) != 0) { - SDL_free(result); - SDL_free(data); - window->shaper = NULL; - return NULL; - } } #endif return result; } -int X11_ResizeWindowShape(SDL_Window *window) -{ - SDL_ShapeData *data = window->shaper->driverdata; - unsigned int bitmapsize = window->w / 8; - SDL_assert(data != NULL); - - if (window->w % 8 > 0) { - bitmapsize += 1; - } - bitmapsize *= window->h; - if (data->bitmapsize != bitmapsize || data->bitmap == NULL) { - data->bitmapsize = bitmapsize; - SDL_free(data->bitmap); - data->bitmap = SDL_malloc(data->bitmapsize); - if (data->bitmap == NULL) { - return SDL_OutOfMemory(); - } - } - SDL_memset(data->bitmap, 0, data->bitmapsize); - - window->shaper->userx = window->x; - window->shaper->usery = window->y; - SDL_SetWindowPosition(window, -1000, -1000); - - return 0; -} - int X11_SetWindowShape(SDL_WindowShaper *shaper, SDL_Surface *shape, SDL_WindowShapeMode *shape_mode) { #if SDL_VIDEO_DRIVER_X11_XSHAPE diff --git a/src/video/x11/SDL_x11shape.h b/src/video/x11/SDL_x11shape.h index 06e57d7cd..96ec12184 100644 --- a/src/video/x11/SDL_x11shape.h +++ b/src/video/x11/SDL_x11shape.h @@ -32,7 +32,6 @@ typedef struct } SDL_ShapeData; extern SDL_WindowShaper *X11_CreateShaper(SDL_Window *window); -extern int X11_ResizeWindowShape(SDL_Window *window); extern int X11_SetWindowShape(SDL_WindowShaper *shaper, SDL_Surface *shape, SDL_WindowShapeMode *shape_mode); #endif /* SDL_x11shape_h_ */ diff --git a/src/video/x11/SDL_x11video.c b/src/video/x11/SDL_x11video.c index e43ad2388..f789857ed 100644 --- a/src/video/x11/SDL_x11video.c +++ b/src/video/x11/SDL_x11video.c @@ -260,7 +260,6 @@ static SDL_VideoDevice *X11_CreateDevice(void) device->shape_driver.CreateShaper = X11_CreateShaper; device->shape_driver.SetWindowShape = X11_SetWindowShape; - device->shape_driver.ResizeWindowShape = X11_ResizeWindowShape; #if SDL_VIDEO_OPENGL_GLX device->GL_LoadLibrary = X11_GL_LoadLibrary; diff --git a/src/video/x11/SDL_x11window.c b/src/video/x11/SDL_x11window.c index 5ed302dac..5812bd9c4 100644 --- a/src/video/x11/SDL_x11window.c +++ b/src/video/x11/SDL_x11window.c @@ -941,9 +941,6 @@ void X11_SetWindowSize(_THIS, SDL_Window *window) orig_w = attrs.width; orig_h = attrs.height; - if (SDL_IsShapedWindow(window)) { - X11_ResizeWindowShape(window); - } if (!(window->flags & SDL_WINDOW_RESIZABLE)) { /* Apparently, if the X11 Window is set to a 'non-resizable' window, you cannot resize it using the X11_XResizeWindow, thus we must set the size hints to adjust the window size. */ diff --git a/test/checkkeys.c b/test/checkkeys.c index 735c5d7a5..fc2767388 100644 --- a/test/checkkeys.c +++ b/test/checkkeys.c @@ -265,9 +265,7 @@ int main(int argc, char *argv[]) } /* Set 640x480 video mode */ - window = SDL_CreateWindow("CheckKeys Test", - SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, - 640, 480, 0); + window = SDL_CreateWindow("CheckKeys Test", 640, 480, 0); if (window == NULL) { SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create 640x480 window: %s\n", SDL_GetError()); diff --git a/test/checkkeysthreads.c b/test/checkkeysthreads.c index 6cc060f90..ca11ece8c 100644 --- a/test/checkkeysthreads.c +++ b/test/checkkeysthreads.c @@ -251,9 +251,7 @@ int main(int argc, char *argv[]) } /* Set 640x480 video mode */ - window = SDL_CreateWindow("CheckKeys Test", - SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, - 640, 480, 0); + window = SDL_CreateWindow("CheckKeys Test", 640, 480, 0); if (window == NULL) { SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create 640x480 window: %s\n", SDL_GetError()); diff --git a/test/gamepadmap.c b/test/gamepadmap.c index 7f4f622fe..568fbcdfe 100644 --- a/test/gamepadmap.c +++ b/test/gamepadmap.c @@ -746,9 +746,7 @@ int main(int argc, char *argv[]) } /* Create a window to display joystick axis position */ - window = SDL_CreateWindow("Game Controller Map", SDL_WINDOWPOS_CENTERED, - SDL_WINDOWPOS_CENTERED, SCREEN_WIDTH, - SCREEN_HEIGHT, 0); + window = SDL_CreateWindow("Game Controller Map", SCREEN_WIDTH, SCREEN_HEIGHT, 0); if (window == NULL) { SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create window: %s\n", SDL_GetError()); return 2; diff --git a/test/relative_mode.markdown b/test/relative_mode.markdown index 4fc2995aa..23f04f5fe 100644 --- a/test/relative_mode.markdown +++ b/test/relative_mode.markdown @@ -41,7 +41,7 @@ Code SDL_Init(SDL_INIT_VIDEO); - win = SDL_CreateWindow("Test", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, 800, 600, 0); + win = SDL_CreateWindow("Test", 800, 600, 0); SDL_SetRelativeMouseMode(SDL_TRUE); while (1) diff --git a/test/testaudiocapture.c b/test/testaudiocapture.c index 82898153b..9d6136448 100644 --- a/test/testaudiocapture.c +++ b/test/testaudiocapture.c @@ -105,7 +105,7 @@ int main(int argc, char **argv) return 1; } - window = SDL_CreateWindow("testaudiocapture", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, 320, 240, 0); + window = SDL_CreateWindow("testaudiocapture", 320, 240, 0); renderer = SDL_CreateRenderer(window, NULL, 0); SDL_SetRenderDrawColor(renderer, 0, 0, 0, 255); SDL_RenderClear(renderer); diff --git a/test/testaudiohotplug.c b/test/testaudiohotplug.c index 4418bdb51..7e1fb5cf2 100644 --- a/test/testaudiohotplug.c +++ b/test/testaudiohotplug.c @@ -146,7 +146,7 @@ int main(int argc, char *argv[]) } /* Some targets (Mac CoreAudio) need an event queue for audio hotplug, so make and immediately hide a window. */ - SDL_MinimizeWindow(SDL_CreateWindow("testaudiohotplug", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, 640, 480, 0)); + SDL_MinimizeWindow(SDL_CreateWindow("testaudiohotplug", 640, 480, 0)); filename = GetResourceFilename(argc > 1 ? argv[1] : NULL, "sample.wav"); diff --git a/test/testautomation_mouse.c b/test/testautomation_mouse.c index e25bf40d4..cd3ffa598 100644 --- a/test/testautomation_mouse.c +++ b/test/testautomation_mouse.c @@ -404,9 +404,9 @@ int mouse_getSetRelativeMouseMode(void *arg) */ static SDL_Window *createMouseSuiteTestWindow() { - int posX = 100, posY = 100, width = MOUSE_TESTWINDOW_WIDTH, height = MOUSE_TESTWINDOW_HEIGHT; + int width = MOUSE_TESTWINDOW_WIDTH, height = MOUSE_TESTWINDOW_HEIGHT; SDL_Window *window; - window = SDL_CreateWindow("mousecreateMouseSuiteTestWindow", posX, posY, width, height, 0); + window = SDL_CreateWindow("mousecreateMouseSuiteTestWindow", width, height, 0); SDLTest_AssertPass("SDL_CreateWindow()"); SDLTest_AssertCheck(window != NULL, "Check SDL_CreateWindow result"); return window; diff --git a/test/testautomation_render.c b/test/testautomation_render.c index 3f7653f25..396067c81 100644 --- a/test/testautomation_render.c +++ b/test/testautomation_render.c @@ -47,9 +47,9 @@ static int isSupported(int code); */ void InitCreateRenderer(void *arg) { - int posX = 100, posY = 100, width = 320, height = 240; + int width = 320, height = 240; renderer = NULL; - window = SDL_CreateWindow("render_testCreateRenderer", posX, posY, width, height, 0); + window = SDL_CreateWindow("render_testCreateRenderer", width, height, 0); SDLTest_AssertPass("SDL_CreateWindow()"); SDLTest_AssertCheck(window != NULL, "Check SDL_CreateWindow result"); if (window == NULL) { diff --git a/test/testautomation_syswm.c b/test/testautomation_syswm.c index 8e73269c2..d6a7854db 100644 --- a/test/testautomation_syswm.c +++ b/test/testautomation_syswm.c @@ -16,7 +16,7 @@ int syswm_getWindowWMInfo(void *arg) SDL_Window *window; SDL_SysWMinfo info; - window = SDL_CreateWindow("", 0, 0, 0, 0, SDL_WINDOW_HIDDEN); + window = SDL_CreateWindow("", 0, 0, SDL_WINDOW_HIDDEN); SDLTest_AssertPass("Call to SDL_CreateWindow()"); SDLTest_AssertCheck(window != NULL, "Check that value returned from SDL_CreateWindow is not NULL"); if (window == NULL) { diff --git a/test/testautomation_video.c b/test/testautomation_video.c index d93270aa4..100c41bc4 100644 --- a/test/testautomation_video.c +++ b/test/testautomation_video.c @@ -12,18 +12,16 @@ static SDL_Window *createVideoSuiteTestWindow(const char *title) { SDL_Window *window; - int x, y, w, h; + int w, h; SDL_WindowFlags flags; /* Standard window */ - x = SDLTest_RandomIntegerInRange(1, 100); - y = SDLTest_RandomIntegerInRange(1, 100); w = SDLTest_RandomIntegerInRange(320, 1024); h = SDLTest_RandomIntegerInRange(320, 768); flags = SDL_WINDOW_RESIZABLE | SDL_WINDOW_BORDERLESS; - window = SDL_CreateWindow(title, x, y, w, h, flags); - SDLTest_AssertPass("Call to SDL_CreateWindow('Title',%d,%d,%d,%d,%d)", x, y, w, h, flags); + window = SDL_CreateWindow(title, w, h, flags); + SDLTest_AssertPass("Call to SDL_CreateWindow('Title',%d,%d,%d)", w, h, flags); SDLTest_AssertCheck(window != NULL, "Validate that returned window struct is not NULL"); return window; @@ -94,88 +92,6 @@ int video_enableDisableScreensaver(void *arg) return TEST_COMPLETED; } -/** - * \brief Tests the functionality of the SDL_CreateWindow function using different positions - */ -int video_createWindowVariousPositions(void *arg) -{ - SDL_Window *window; - const char *title = "video_createWindowVariousPositions Test Window"; - int x, y, w, h; - int xVariation, yVariation; - - for (xVariation = 0; xVariation < 6; xVariation++) { - for (yVariation = 0; yVariation < 6; yVariation++) { - switch (xVariation) { - default: - case 0: - /* Zero X Position */ - x = 0; - break; - case 1: - /* Random X position inside screen */ - x = SDLTest_RandomIntegerInRange(1, 100); - break; - case 2: - /* Random X position outside screen (positive) */ - x = SDLTest_RandomIntegerInRange(10000, 11000); - break; - case 3: - /* Random X position outside screen (negative) */ - x = SDLTest_RandomIntegerInRange(-1000, -100); - break; - case 4: - /* Centered X position */ - x = SDL_WINDOWPOS_CENTERED; - break; - case 5: - /* Undefined X position */ - x = SDL_WINDOWPOS_UNDEFINED; - break; - } - - switch (yVariation) { - default: - case 0: - /* Zero X Position */ - y = 0; - break; - case 1: - /* Random X position inside screen */ - y = SDLTest_RandomIntegerInRange(1, 100); - break; - case 2: - /* Random X position outside screen (positive) */ - y = SDLTest_RandomIntegerInRange(10000, 11000); - break; - case 3: - /* Random Y position outside screen (negative) */ - y = SDLTest_RandomIntegerInRange(-1000, -100); - break; - case 4: - /* Centered Y position */ - y = SDL_WINDOWPOS_CENTERED; - break; - case 5: - /* Undefined Y position */ - y = SDL_WINDOWPOS_UNDEFINED; - break; - } - - w = SDLTest_RandomIntegerInRange(32, 96); - h = SDLTest_RandomIntegerInRange(32, 96); - window = SDL_CreateWindow(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"); - - /* Clean up */ - destroyVideoSuiteTestWindow(window); - } - } - - return TEST_COMPLETED; -} - /** * \brief Tests the functionality of the SDL_CreateWindow function using different sizes */ @@ -183,11 +99,9 @@ int video_createWindowVariousSizes(void *arg) { SDL_Window *window; const char *title = "video_createWindowVariousSizes Test Window"; - int x, y, w, h; + int w, h; int wVariation, hVariation; - x = SDLTest_RandomIntegerInRange(1, 100); - y = SDLTest_RandomIntegerInRange(1, 100); for (wVariation = 0; wVariation < 3; wVariation++) { for (hVariation = 0; hVariation < 3; hVariation++) { switch (wVariation) { @@ -220,8 +134,8 @@ int video_createWindowVariousSizes(void *arg) break; } - window = SDL_CreateWindow(title, x, y, w, h, 0); - SDLTest_AssertPass("Call to SDL_CreateWindow('Title',%d,%d,%d,%d,SHOWN)", x, y, w, h); + window = SDL_CreateWindow(title, w, h, 0); + SDLTest_AssertPass("Call to SDL_CreateWindow('Title',%d,%d,SHOWN)", w, h); SDLTest_AssertCheck(window != NULL, "Validate that returned window struct is not NULL"); /* Clean up */ @@ -239,13 +153,11 @@ int video_createWindowVariousFlags(void *arg) { SDL_Window *window; const char *title = "video_createWindowVariousFlags Test Window"; - int x, y, w, h; + int w, h; int fVariation; SDL_WindowFlags flags; /* Standard window */ - x = SDLTest_RandomIntegerInRange(1, 100); - y = SDLTest_RandomIntegerInRange(1, 100); w = SDLTest_RandomIntegerInRange(320, 1024); h = SDLTest_RandomIntegerInRange(320, 768); @@ -295,8 +207,8 @@ int video_createWindowVariousFlags(void *arg) break; } - window = SDL_CreateWindow(title, x, y, w, h, flags); - SDLTest_AssertPass("Call to SDL_CreateWindow('Title',%d,%d,%d,%d,%d)", x, y, w, h, flags); + window = SDL_CreateWindow(title, w, h, flags); + SDLTest_AssertPass("Call to SDL_CreateWindow('Title',%d,%d,%d)", w, h, flags); SDLTest_AssertCheck(window != NULL, "Validate that returned window struct is not NULL"); /* Clean up */ @@ -1678,10 +1590,14 @@ int video_setWindowCenteredOnDisplay(void *arg) expectedX = (expectedDisplayRect.x + ((expectedDisplayRect.w - w) / 2)); expectedY = (expectedDisplayRect.y + ((expectedDisplayRect.h - h) / 2)); - window = SDL_CreateWindow(title, x, y, w, h, 0); + window = SDL_CreateWindow(title, w, h, SDL_WINDOW_HIDDEN); 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); @@ -1762,74 +1678,70 @@ static const SDLTest_TestCaseReference videoTest1 = { }; static const SDLTest_TestCaseReference videoTest2 = { - (SDLTest_TestCaseFp)video_createWindowVariousPositions, "video_createWindowVariousPositions", "Create windows at various locations", TEST_ENABLED -}; - -static const SDLTest_TestCaseReference videoTest3 = { (SDLTest_TestCaseFp)video_createWindowVariousSizes, "video_createWindowVariousSizes", "Create windows with various sizes", TEST_ENABLED }; -static const SDLTest_TestCaseReference videoTest4 = { +static const SDLTest_TestCaseReference videoTest3 = { (SDLTest_TestCaseFp)video_createWindowVariousFlags, "video_createWindowVariousFlags", "Create windows using various flags", TEST_ENABLED }; -static const SDLTest_TestCaseReference videoTest5 = { +static const SDLTest_TestCaseReference videoTest4 = { (SDLTest_TestCaseFp)video_getWindowFlags, "video_getWindowFlags", "Get window flags set during SDL_CreateWindow", TEST_ENABLED }; -static const SDLTest_TestCaseReference videoTest6 = { +static const SDLTest_TestCaseReference videoTest5 = { (SDLTest_TestCaseFp)video_getFullscreenDisplayModes, "video_getFullscreenDisplayModes", "Use SDL_GetFullscreenDisplayModes function to get number of display modes", TEST_ENABLED }; -static const SDLTest_TestCaseReference videoTest7 = { +static const SDLTest_TestCaseReference videoTest6 = { (SDLTest_TestCaseFp)video_getClosestDisplayModeCurrentResolution, "video_getClosestDisplayModeCurrentResolution", "Use function to get closes match to requested display mode for current resolution", TEST_ENABLED }; -static const SDLTest_TestCaseReference videoTest8 = { +static const SDLTest_TestCaseReference videoTest7 = { (SDLTest_TestCaseFp)video_getClosestDisplayModeRandomResolution, "video_getClosestDisplayModeRandomResolution", "Use function to get closes match to requested display mode for random resolution", TEST_ENABLED }; -static const SDLTest_TestCaseReference videoTest9 = { +static const SDLTest_TestCaseReference videoTest8 = { (SDLTest_TestCaseFp)video_getWindowDisplayMode, "video_getWindowDisplayMode", "Get window display mode", TEST_ENABLED }; -static const SDLTest_TestCaseReference videoTest10 = { +static const SDLTest_TestCaseReference videoTest9 = { (SDLTest_TestCaseFp)video_getWindowDisplayModeNegative, "video_getWindowDisplayModeNegative", "Get window display mode with invalid input", TEST_ENABLED }; -static const SDLTest_TestCaseReference videoTest11 = { +static const SDLTest_TestCaseReference videoTest10 = { (SDLTest_TestCaseFp)video_getSetWindowGrab, "video_getSetWindowGrab", "Checks SDL_GetWindowGrab and SDL_SetWindowGrab positive and negative cases", TEST_ENABLED }; -static const SDLTest_TestCaseReference videoTest12 = { +static const SDLTest_TestCaseReference videoTest11 = { (SDLTest_TestCaseFp)video_getWindowId, "video_getWindowId", "Checks SDL_GetWindowID and SDL_GetWindowFromID", TEST_ENABLED }; -static const SDLTest_TestCaseReference videoTest13 = { +static const SDLTest_TestCaseReference videoTest12 = { (SDLTest_TestCaseFp)video_getWindowPixelFormat, "video_getWindowPixelFormat", "Checks SDL_GetWindowPixelFormat", TEST_ENABLED }; -static const SDLTest_TestCaseReference videoTest14 = { +static const SDLTest_TestCaseReference videoTest13 = { (SDLTest_TestCaseFp)video_getSetWindowPosition, "video_getSetWindowPosition", "Checks SDL_GetWindowPosition and SDL_SetWindowPosition positive and negative cases", TEST_ENABLED }; -static const SDLTest_TestCaseReference videoTest15 = { +static const SDLTest_TestCaseReference videoTest14 = { (SDLTest_TestCaseFp)video_getSetWindowSize, "video_getSetWindowSize", "Checks SDL_GetWindowSize and SDL_SetWindowSize positive and negative cases", TEST_ENABLED }; -static const SDLTest_TestCaseReference videoTest16 = { +static const SDLTest_TestCaseReference videoTest15 = { (SDLTest_TestCaseFp)video_getSetWindowMinimumSize, "video_getSetWindowMinimumSize", "Checks SDL_GetWindowMinimumSize and SDL_SetWindowMinimumSize positive and negative cases", TEST_ENABLED }; -static const SDLTest_TestCaseReference videoTest17 = { +static const SDLTest_TestCaseReference videoTest16 = { (SDLTest_TestCaseFp)video_getSetWindowMaximumSize, "video_getSetWindowMaximumSize", "Checks SDL_GetWindowMaximumSize and SDL_SetWindowMaximumSize positive and negative cases", TEST_ENABLED }; -static const SDLTest_TestCaseReference videoTest18 = { +static const SDLTest_TestCaseReference videoTest17 = { (SDLTest_TestCaseFp)video_getSetWindowData, "video_getSetWindowData", "Checks SDL_SetWindowData and SDL_GetWindowData positive and negative cases", TEST_ENABLED }; -static const SDLTest_TestCaseReference videoTest19 = { +static const SDLTest_TestCaseReference videoTest18 = { (SDLTest_TestCaseFp)video_setWindowCenteredOnDisplay, "video_setWindowCenteredOnDisplay", "Checks using SDL_WINDOWPOS_CENTERED_DISPLAY centers the window on a display", TEST_ENABLED }; @@ -1838,7 +1750,7 @@ static const SDLTest_TestCaseReference *videoTests[] = { &videoTest1, &videoTest2, &videoTest3, &videoTest4, &videoTest5, &videoTest6, &videoTest7, &videoTest8, &videoTest9, &videoTest10, &videoTest11, &videoTest12, &videoTest13, &videoTest14, &videoTest15, &videoTest16, &videoTest17, - &videoTest18, &videoTest19, NULL + &videoTest18, NULL }; /* Video test suite (global) */ diff --git a/test/testdrawchessboard.c b/test/testdrawchessboard.c index 609a87aba..4bac05606 100644 --- a/test/testdrawchessboard.c +++ b/test/testdrawchessboard.c @@ -110,7 +110,7 @@ int main(int argc, char *argv[]) } /* Create window and renderer for given surface */ - window = SDL_CreateWindow("Chess Board", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, 640, 480, SDL_WINDOW_RESIZABLE); + window = SDL_CreateWindow("Chess Board", 640, 480, SDL_WINDOW_RESIZABLE); if (window == NULL) { SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Window creation fail : %s\n", SDL_GetError()); return 1; diff --git a/test/testgamepad.c b/test/testgamepad.c index 8825b6840..7a3a6a852 100644 --- a/test/testgamepad.c +++ b/test/testgamepad.c @@ -897,9 +897,7 @@ int main(int argc, char *argv[]) } /* Create a window to display gamepad state */ - window = SDL_CreateWindow("Gamepad Test", SDL_WINDOWPOS_CENTERED, - SDL_WINDOWPOS_CENTERED, SCREEN_WIDTH, - SCREEN_HEIGHT, 0); + window = SDL_CreateWindow("Gamepad Test", SCREEN_WIDTH, SCREEN_HEIGHT, 0); if (window == NULL) { SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create window: %s\n", SDL_GetError()); return 2; diff --git a/test/testhittesting.c b/test/testhittesting.c index 2974024a0..259990a6a 100644 --- a/test/testhittesting.c +++ b/test/testhittesting.c @@ -81,7 +81,7 @@ int main(int argc, char **argv) /* !!! FIXME: check for errors. */ SDL_Init(SDL_INIT_VIDEO); - window = SDL_CreateWindow("Drag the red boxes", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, 640, 480, SDL_WINDOW_BORDERLESS | SDL_WINDOW_RESIZABLE); + window = SDL_CreateWindow("Drag the red boxes", 640, 480, SDL_WINDOW_BORDERLESS | SDL_WINDOW_RESIZABLE); renderer = SDL_CreateRenderer(window, NULL, 0); if (SDL_SetWindowHitTest(window, hitTest, NULL) == -1) { diff --git a/test/testhotplug.c b/test/testhotplug.c index a44b28647..f94538fcd 100644 --- a/test/testhotplug.c +++ b/test/testhotplug.c @@ -50,7 +50,7 @@ int main(int argc, char *argv[]) } /* - //SDL_CreateWindow("Dummy", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, 128, 128, 0); + //SDL_CreateWindow("Dummy", 128, 128, 0); */ SDL_free(SDL_GetJoysticks(&num_joysticks)); diff --git a/test/testjoystick.c b/test/testjoystick.c index a12265dec..057a6606c 100644 --- a/test/testjoystick.c +++ b/test/testjoystick.c @@ -299,9 +299,7 @@ int main(int argc, char *argv[]) } /* Create a window to display joystick axis position */ - window = SDL_CreateWindow("Joystick Test", SDL_WINDOWPOS_CENTERED, - SDL_WINDOWPOS_CENTERED, SCREEN_WIDTH, - SCREEN_HEIGHT, 0); + window = SDL_CreateWindow("Joystick Test", SCREEN_WIDTH, SCREEN_HEIGHT, 0); if (window == NULL) { SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create window: %s\n", SDL_GetError()); return SDL_FALSE; diff --git a/test/testmessage.c b/test/testmessage.c index 7af3b2f3d..f94e2a63c 100644 --- a/test/testmessage.c +++ b/test/testmessage.c @@ -183,7 +183,7 @@ int main(int argc, char *argv[]) /* Test showing a message box with a parent window */ { SDL_Event event; - SDL_Window *window = SDL_CreateWindow("Test", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, 640, 480, 0); + SDL_Window *window = SDL_CreateWindow("Test", 640, 480, 0); /* On wayland, no window will actually show until something has actually been displayed. diff --git a/test/testmouse.c b/test/testmouse.c index a7f921716..c6dc9c711 100644 --- a/test/testmouse.c +++ b/test/testmouse.c @@ -261,9 +261,7 @@ int main(int argc, char *argv[]) } /* Create a window to display joystick axis position */ - window = SDL_CreateWindow("Mouse Test", SDL_WINDOWPOS_CENTERED, - SDL_WINDOWPOS_CENTERED, SCREEN_WIDTH, - SCREEN_HEIGHT, 0); + window = SDL_CreateWindow("Mouse Test", SCREEN_WIDTH, SCREEN_HEIGHT, 0); if (window == NULL) { SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create window: %s\n", SDL_GetError()); return SDL_FALSE; diff --git a/test/testmultiaudio.c b/test/testmultiaudio.c index d0130e47f..45a5fec1b 100644 --- a/test/testmultiaudio.c +++ b/test/testmultiaudio.c @@ -77,7 +77,7 @@ test_multi_audio(int devcount) SDL_Event event; /* Create a Window to get fully initialized event processing for testing pause on Android. */ - SDL_CreateWindow("testmultiaudio", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, 320, 240, 0); + SDL_CreateWindow("testmultiaudio", 320, 240, 0); #endif if (devcount > 64) { diff --git a/test/testoffscreen.c b/test/testoffscreen.c index eaa9d3093..f2ac3babd 100644 --- a/test/testoffscreen.c +++ b/test/testoffscreen.c @@ -110,9 +110,7 @@ int main(int argc, char *argv[]) } /* If OPENGL fails to init it will fallback to using a framebuffer for rendering */ - window = SDL_CreateWindow("Offscreen Test", - SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, - width, height, 0); + window = SDL_CreateWindow("Offscreen Test", width, height, 0); if (window == NULL) { SDL_Log("Couldn't create window: %s\n", diff --git a/test/testsensor.c b/test/testsensor.c index 3e7aaa28e..fb731e378 100644 --- a/test/testsensor.c +++ b/test/testsensor.c @@ -95,7 +95,7 @@ int main(int argc, char **argv) SDL_bool done = SDL_FALSE; SDL_Event event; - SDL_CreateWindow("Sensor Test", 0, 0, 0, 0, SDL_WINDOW_FULLSCREEN); + SDL_CreateWindow("Sensor Test", 0, 0, SDL_WINDOW_FULLSCREEN); while (!done) { /* Update to get the current event state */ SDL_PumpEvents(); diff --git a/test/testshader.c b/test/testshader.c index 6350c684e..d61ddefe6 100644 --- a/test/testshader.c +++ b/test/testshader.c @@ -456,7 +456,7 @@ int main(int argc, char **argv) } /* Create a 640x480 OpenGL screen */ - window = SDL_CreateWindow("Shader Demo", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, 640, 480, SDL_WINDOW_OPENGL); + window = SDL_CreateWindow("Shader Demo", 640, 480, SDL_WINDOW_OPENGL); if (window == NULL) { SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Unable to create OpenGL window: %s\n", SDL_GetError()); SDL_Quit(); diff --git a/test/testshape.c b/test/testshape.c index e846e1b14..802648e08 100644 --- a/test/testshape.c +++ b/test/testshape.c @@ -14,8 +14,6 @@ #include #include -#define SHAPED_WINDOW_X 150 -#define SHAPED_WINDOW_Y 150 #define SHAPED_WINDOW_DIMENSION 640 typedef struct LoadedPicture @@ -106,9 +104,7 @@ int main(int argc, char **argv) } window = SDL_CreateShapedWindow("SDL_Shape test", - SHAPED_WINDOW_X, SHAPED_WINDOW_Y, - SHAPED_WINDOW_DIMENSION, SHAPED_WINDOW_DIMENSION, - 0); + SHAPED_WINDOW_DIMENSION, SHAPED_WINDOW_DIMENSION, 0); if (window == NULL) { for (i = 0; i < num_pictures; i++) { SDL_DestroySurface(pictures[i].surface); diff --git a/test/teststreaming.c b/test/teststreaming.c index a79a63c4c..72d0881d2 100644 --- a/test/teststreaming.c +++ b/test/teststreaming.c @@ -155,11 +155,7 @@ int main(int argc, char **argv) SDL_RWclose(handle); /* Create the window and renderer */ - window = SDL_CreateWindow("Happy Moose", - SDL_WINDOWPOS_UNDEFINED, - SDL_WINDOWPOS_UNDEFINED, - MOOSEPIC_W * 4, MOOSEPIC_H * 4, - SDL_WINDOW_RESIZABLE); + window = SDL_CreateWindow("Happy Moose", MOOSEPIC_W * 4, MOOSEPIC_H * 4, SDL_WINDOW_RESIZABLE); if (window == NULL) { SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't set create window: %s\n", SDL_GetError()); quit(3); diff --git a/test/testyuv.c b/test/testyuv.c index f9622d74a..2d8284360 100644 --- a/test/testyuv.c +++ b/test/testyuv.c @@ -349,11 +349,7 @@ int main(int argc, char **argv) now = SDL_GetTicks(); SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION, "%" SDL_PRIu32 " iterations in %" SDL_PRIu64 " ms, %.2fms each\n", iterations, (now - then), (float)(now - then) / iterations); - window = SDL_CreateWindow("YUV test", - SDL_WINDOWPOS_UNDEFINED, - SDL_WINDOWPOS_UNDEFINED, - original->w, original->h, - 0); + window = SDL_CreateWindow("YUV test", original->w, original->h, 0); if (window == NULL) { SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create window: %s\n", SDL_GetError()); return 4;