From 698dbd84640eacfb555e1accbeb53980164f2205 Mon Sep 17 00:00:00 2001
From: Sam Lantinga <[EMAIL REDACTED]>
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 9551bf92063f..cfbdf9bd6ff5 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 0449709c025d..25bb28aed860 100644
--- a/cmake/test/main_cli.c
+++ b/cmake/test/main_cli.c
@@ -1,12 +1,12 @@
#define SDL_MAIN_HANDLED
#include <SDL3/SDL.h>
#include <SDL3/SDL_main.h>
-#include <stdio.h>
-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 2e1aa0f1500e..715c4306f5ca 100644
--- a/cmake/test/main_gui.c
+++ b/cmake/test/main_gui.c
@@ -1,22 +1,17 @@
#include <SDL3/SDL.h>
#include <SDL3/SDL_main.h>
-#include <stdio.h>
-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 78d7c60dd918..9468d71f1cdc 100644
--- a/cmake/test/main_lib.c
+++ b/cmake/test/main_lib.c
@@ -1,7 +1,6 @@
#include <SDL3/SDL.h>
#define SDL_MAIN_HANDLED /* don't drag in header-only SDL_main implementation */
#include <SDL3/SDL_main.h>
-#include <stdio.h>
#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 557a1038f6c1..b6f51e99616c 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 4864548a7086…276c83bce77e 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 964556ad96aa…4b7fb661f437 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 f64e92ae9254…ebdc8a779a6d 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
- \param x the x position of the window,
-
-
`SDL_WINDOWPOS_UNDEFINED`
-
-
- \param y the y position of the window,
SDL_WINDOWPOS_CENTERED
, or
- \param y the y position of the window,
-
-
`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 e253666ff152…fab380c95903 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 d6e415761483…166ab0dbc94a 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 47cc0bbb731e…0aecf4d72ac1 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 f00bbc2d379d…709959046738 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 0fb800288a58…2c690cf81259 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 ad1f58d2bf4b…c5d048fc93e7 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 f824cf410494…a7c6d14a5a8a 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 c77ef8661f30…803bb8a29b2d 100644
— a/src/video/cocoa/SDL_cocoashape.m
+++ b/src/video/cocoa/SDL_cocoashape.m
@@ -44,7 +44,6 @@ @implementation SDL_CocoaClosure
@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 @@ @implementation SDL_CocoaClosure
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 @@ @implementation SDL_CocoaClosure
/* 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 fa9f48320c93…1d46bc8bbc71 100644
— a/src/video/cocoa/SDL_cocoavideo.m
+++ b/src/video/cocoa/SDL_cocoavideo.m
@@ -121,7 +121,6 @@ static void Cocoa_DeleteDevice(SDL_VideoDevice *device)
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 fb0f00d6c236…5d105f5baedd 100644
— a/src/video/cocoa/SDL_cocoawindow.m
+++ b/src/video/cocoa/SDL_cocoawindow.m
@@ -816,10 +816,6 @@ - (void)windowDidResize:(NSNotification *)aNotification
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 a5a16fe9d42f…2a44241fa3e9 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 487ce3c30ec1…a7444fbae585 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 702c97585a91…cec1e83a129d 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 1e869fe9490c…074f7edf4fb6 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 9cb30d820b8f…7afe97f1d1cd 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 f726dd2e358b…9d5b29953ca2 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;
-
}
}
#endifreturn 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 06e57d7cda0e…96ec12184fc0 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 e43ad2388d66…f789857ed880 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 5ed302dac836…5812bd9c4b8e 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 735c5d7a59bd…fc2767388976 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 6cc060f90423…ca11ece8cbda 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 7f4f622fe7e9…568fbcdfe1c9 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 4fc2995aabe6…23f04f5fe0a3 100644
— a/test/relative_mode.markdown
+++ b/test/relative_mode.markdown
@@ -41,7 +41,7 @@ CodeSDL_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 82898153b4e9…9d613644842c 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”,
(Patch may be truncated, please check the link at the top of this post.)