SDL_CreateWindow() has been simplified and no longer takes a window position.

main
Sam Lantinga 2023-03-05 14:44:38 -08:00
parent 7905254087
commit 698dbd8464
51 changed files with 106 additions and 326 deletions

View File

@ -2517,3 +2517,15 @@ SDL_Event *e1;
@@ @@
- e1->csensor - e1->csensor
+ e1->gsensor + 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)

View File

@ -1,12 +1,12 @@
#define SDL_MAIN_HANDLED #define SDL_MAIN_HANDLED
#include <SDL3/SDL.h> #include <SDL3/SDL.h>
#include <SDL3/SDL_main.h> #include <SDL3/SDL_main.h>
#include <stdio.h>
int main(int argc, char *argv[]) { int main(int argc, char *argv[])
{
SDL_SetMainReady(); SDL_SetMainReady();
if (SDL_Init(0) < 0) { 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 1;
} }
SDL_Delay(100); SDL_Delay(100);

View File

@ -1,22 +1,17 @@
#include <SDL3/SDL.h> #include <SDL3/SDL.h>
#include <SDL3/SDL_main.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_Window *window = NULL;
SDL_Surface *screenSurface = NULL; SDL_Surface *screenSurface = NULL;
if (SDL_Init(SDL_INIT_VIDEO) < 0) { 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; return 1;
} }
window = SDL_CreateWindow( window = SDL_CreateWindow("Hello SDL", 640, 480, 0);
"Hello SDL",
SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED,
640, 480,
0
);
if (window == NULL) { 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; return 1;
} }
screenSurface = SDL_GetWindowSurface(window); screenSurface = SDL_GetWindowSurface(window);

View File

@ -1,7 +1,6 @@
#include <SDL3/SDL.h> #include <SDL3/SDL.h>
#define SDL_MAIN_HANDLED /* don't drag in header-only SDL_main implementation */ #define SDL_MAIN_HANDLED /* don't drag in header-only SDL_main implementation */
#include <SDL3/SDL_main.h> #include <SDL3/SDL_main.h>
#include <stdio.h>
#include EXPORT_HEADER #include EXPORT_HEADER
@ -19,7 +18,7 @@ int MYLIBRARY_EXPORT mylibrary_work(void);
int mylibrary_init(void) { int mylibrary_init(void) {
SDL_SetMainReady(); SDL_SetMainReady();
if (SDL_Init(0) < 0) { 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 1;
} }
return 0; return 0;

View File

@ -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_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. 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.

View File

@ -87,7 +87,7 @@ Here's a sample SDL snippet to verify everything is setup in your IDE:
SDL_Renderer* renderer = NULL; SDL_Renderer* renderer = NULL;
SDL_Init(SDL_INIT_VIDEO); 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); renderer = SDL_CreateRenderer(window, NULL, SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC);
SDL_DestroyRenderer(renderer); SDL_DestroyRenderer(renderer);

View File

@ -44,14 +44,9 @@ extern "C" {
#define SDL_WINDOW_LACKS_SHAPE -3 #define SDL_WINDOW_LACKS_SHAPE -3
/** /**
* Create a window that can be shaped with the specified position, dimensions, * Create a window that can be shaped with the specified dimensions and flags.
* and flags.
* *
* \param title The title of the window, in UTF-8 encoding. * \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 w The width of the window.
* \param h The height of the window. * \param h The height of the window.
* \param flags The flags for the window, a mask of SDL_WINDOW_BORDERLESS with * \param flags The flags for the window, a mask of SDL_WINDOW_BORDERLESS with
@ -66,7 +61,7 @@ extern "C" {
* *
* \sa SDL_DestroyWindow * \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. * Return whether the given window is a shaped window.

View File

@ -631,10 +631,6 @@ extern DECLSPEC Uint32 SDLCALL SDL_GetWindowPixelFormat(SDL_Window *window);
* in a future version of SDL. * in a future version of SDL.
* *
* \param title the title of the window, in UTF-8 encoding * \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 w the width of the window, in screen coordinates
* \param h the height 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 * \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_CreateWindowFrom
* \sa SDL_DestroyWindow * \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. * Create an SDL window from an existing native window.

View File

@ -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_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_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_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_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_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_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_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_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_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(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_Window*,SDL_CreateWindowFrom,(const void *a),(a),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_CursorVisible,(void),(),return) SDL_DYNAPI_PROC(SDL_bool,SDL_CursorVisible,(void),(),return)

View File

@ -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) int SDL_CreateWindowAndRenderer(int width, int height, Uint32 window_flags, SDL_Window **window, SDL_Renderer **renderer)
{ {
*window = SDL_CreateWindow(NULL, SDL_WINDOWPOS_UNDEFINED, *window = SDL_CreateWindow(NULL, width, height, window_flags);
SDL_WINDOWPOS_UNDEFINED,
width, height, window_flags);
if (!*window) { if (!*window) {
*renderer = NULL; *renderer = NULL;
return -1; return -1;

View File

@ -81,7 +81,7 @@ SDLTest_CommonCreateState(char **argv, Uint32 flags)
state->argv = argv; state->argv = argv;
state->flags = flags; state->flags = flags;
state->window_title = argv[0]; state->window_title = argv[0];
state->window_flags = 0; state->window_flags = SDL_WINDOW_HIDDEN;
state->window_x = SDL_WINDOWPOS_UNDEFINED; state->window_x = SDL_WINDOWPOS_UNDEFINED;
state->window_y = SDL_WINDOWPOS_UNDEFINED; state->window_y = SDL_WINDOWPOS_UNDEFINED;
state->window_w = DEFAULT_WINDOW_WIDTH; state->window_w = DEFAULT_WINDOW_WIDTH;
@ -1278,10 +1278,6 @@ SDLTest_CommonInit(SDLTest_CommonState *state)
} }
SDL_free(displays); 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)) { if (SDL_WINDOWPOS_ISCENTERED(state->window_x)) {
state->window_x = SDL_WINDOWPOS_CENTERED_DISPLAY(state->displayID); state->window_x = SDL_WINDOWPOS_CENTERED_DISPLAY(state->displayID);
state->window_y = 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 { } else {
SDL_strlcpy(title, state->window_title, SDL_arraysize(title)); SDL_strlcpy(title, state->window_title, SDL_arraysize(title));
} }
state->windows[i] = state->windows[i] = SDL_CreateWindow(title, r.w, r.h, state->window_flags);
SDL_CreateWindow(title, r.x, r.y, r.w, r.h, state->window_flags);
if (!state->windows[i]) { if (!state->windows[i]) {
SDL_Log("Couldn't create window: %s\n", SDL_Log("Couldn't create window: %s\n",
SDL_GetError()); SDL_GetError());
return SDL_FALSE; 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) { if (state->window_minW || state->window_minH) {
SDL_SetWindowMinimumSize(state->windows[i], state->window_minW, state->window_minH); SDL_SetWindowMinimumSize(state->windows[i], state->window_minW, state->window_minH);
} }

View File

@ -24,10 +24,10 @@
#include "SDL_shape_internals.h" #include "SDL_shape_internals.h"
SDL_Window * 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; 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 (result != NULL) {
if (SDL_GetVideoDevice()->shape_driver.CreateShaper == NULL) { if (SDL_GetVideoDevice()->shape_driver.CreateShaper == NULL) {
SDL_DestroyWindow(result); 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); result->shaper = SDL_GetVideoDevice()->shape_driver.CreateShaper(result);
if (result->shaper != NULL) { if (result->shaper != NULL) {
result->shaper->userx = x;
result->shaper->usery = y;
result->shaper->mode.mode = ShapeModeDefault; result->shaper->mode.mode = ShapeModeDefault;
result->shaper->mode.parameters.binarizationCutoff = 1; result->shaper->mode.parameters.binarizationCutoff = 1;
result->shaper->hasshape = SDL_FALSE; 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; window->shaper->mode = *shape_mode;
} }
result = _this->shape_driver.SetWindowShape(window->shaper, shape, shape_mode); result = _this->shape_driver.SetWindowShape(window->shaper, shape, shape_mode);
window->shaper->hasshape = SDL_TRUE; if (result == 0) {
if (window->shaper->userx != 0 && window->shaper->usery != 0) { window->shaper->hasshape = SDL_TRUE;
SDL_SetWindowPosition(window, window->shaper->userx, window->shaper->usery); SDL_ShowWindow(window);
window->shaper->userx = 0;
window->shaper->usery = 0;
} }
return result; return result;
} }

View File

@ -42,9 +42,6 @@ struct SDL_WindowShaper
/* The window associated with the shaper */ /* The window associated with the shaper */
SDL_Window *window; 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. */ /* The parameters for shape calculation. */
SDL_WindowShapeMode mode; SDL_WindowShapeMode mode;
@ -59,7 +56,6 @@ struct SDL_ShapeDriver
{ {
SDL_WindowShaper *(*CreateShaper)(SDL_Window *window); SDL_WindowShaper *(*CreateShaper)(SDL_Window *window);
int (*SetWindowShape)(SDL_WindowShaper *shaper, SDL_Surface *shape, SDL_WindowShapeMode *shape_mode); int (*SetWindowShape)(SDL_WindowShaper *shaper, SDL_Surface *shape, SDL_WindowShapeMode *shape_mode);
int (*ResizeWindowShape)(SDL_Window *window);
}; };
typedef struct SDL_WindowUserData typedef struct SDL_WindowUserData

View File

@ -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); 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; SDL_Window *window;
Uint32 type_flags, graphics_flags; Uint32 type_flags, graphics_flags;
int x = SDL_WINDOWPOS_UNDEFINED;
int y = SDL_WINDOWPOS_UNDEFINED;
SDL_bool undefined_x = SDL_FALSE; SDL_bool undefined_x = SDL_FALSE;
SDL_bool undefined_y = SDL_FALSE; SDL_bool undefined_y = SDL_FALSE;

View File

@ -34,6 +34,5 @@
extern SDL_WindowShaper *Cocoa_CreateShaper(SDL_Window *window); 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_SetWindowShape(SDL_WindowShaper *shaper, SDL_Surface *shape, SDL_WindowShapeMode *shape_mode);
extern int Cocoa_ResizeWindowShape(SDL_Window *window);
#endif /* SDL_cocoashape_h_ */ #endif /* SDL_cocoashape_h_ */

View File

@ -44,7 +44,6 @@ Cocoa_CreateShaper(SDL_Window *window)
@autoreleasepool { @autoreleasepool {
SDL_WindowShaper *result; SDL_WindowShaper *result;
SDL_ShapeData *data; SDL_ShapeData *data;
int resized_properly;
SDL_CocoaWindowData *windata = (__bridge SDL_CocoaWindowData *)window->driverdata; SDL_CocoaWindowData *windata = (__bridge SDL_CocoaWindowData *)window->driverdata;
result = (SDL_WindowShaper *)SDL_malloc(sizeof(SDL_WindowShaper)); result = (SDL_WindowShaper *)SDL_malloc(sizeof(SDL_WindowShaper));
@ -60,7 +59,6 @@ Cocoa_CreateShaper(SDL_Window *window)
result->window = window; result->window = window;
result->mode.mode = ShapeModeDefault; result->mode.mode = ShapeModeDefault;
result->mode.parameters.binarizationCutoff = 1; result->mode.parameters.binarizationCutoff = 1;
result->userx = result->usery = 0;
window->shaper = result; window->shaper = result;
data = [[SDL_ShapeData alloc] init]; data = [[SDL_ShapeData alloc] init];
@ -71,8 +69,6 @@ Cocoa_CreateShaper(SDL_Window *window)
/* TODO: There's no place to release this... */ /* TODO: There's no place to release this... */
result->driverdata = (void *)CFBridgingRetain(data); result->driverdata = (void *)CFBridgingRetain(data);
resized_properly = Cocoa_ResizeWindowShape(window);
SDL_assert(resized_properly == 0);
return result; 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 */ #endif /* SDL_VIDEO_DRIVER_COCOA */

View File

@ -121,7 +121,6 @@ static SDL_VideoDevice *Cocoa_CreateDevice(void)
device->shape_driver.CreateShaper = Cocoa_CreateShaper; device->shape_driver.CreateShaper = Cocoa_CreateShaper;
device->shape_driver.SetWindowShape = Cocoa_SetWindowShape; device->shape_driver.SetWindowShape = Cocoa_SetWindowShape;
device->shape_driver.ResizeWindowShape = Cocoa_ResizeWindowShape;
#if SDL_VIDEO_OPENGL_CGL #if SDL_VIDEO_OPENGL_CGL
device->GL_LoadLibrary = Cocoa_GL_LoadLibrary; device->GL_LoadLibrary = Cocoa_GL_LoadLibrary;

View File

@ -816,10 +816,6 @@ static void Cocoa_UpdateClipCursor(SDL_Window *window)
w = (int)rect.size.width; w = (int)rect.size.width;
h = (int)rect.size.height; h = (int)rect.size.height;
if (SDL_IsShapedWindow(window)) {
Cocoa_ResizeWindowShape(window);
}
ScheduleContextUpdates(_data); ScheduleContextUpdates(_data);
/* The window can move during a resize event, such as when maximizing /* The window can move during a resize event, such as when maximizing

View File

@ -96,10 +96,6 @@ static SDL_VideoDevice * HAIKU_CreateDevice(void)
device->UpdateWindowFramebuffer = HAIKU_UpdateWindowFramebuffer; device->UpdateWindowFramebuffer = HAIKU_UpdateWindowFramebuffer;
device->DestroyWindowFramebuffer = HAIKU_DestroyWindowFramebuffer; device->DestroyWindowFramebuffer = HAIKU_DestroyWindowFramebuffer;
device->shape_driver.CreateShaper = NULL;
device->shape_driver.SetWindowShape = NULL;
device->shape_driver.ResizeWindowShape = NULL;
#if SDL_VIDEO_OPENGL #if SDL_VIDEO_OPENGL
device->GL_LoadLibrary = HAIKU_GL_LoadLibrary; device->GL_LoadLibrary = HAIKU_GL_LoadLibrary;
device->GL_GetProcAddress = HAIKU_GL_GetProcAddress; device->GL_GetProcAddress = HAIKU_GL_GetProcAddress;

View File

@ -1131,10 +1131,6 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
int max_w, max_h; int max_w, max_h;
BOOL constrain_max_size; BOOL constrain_max_size;
if (SDL_IsShapedWindow(data->window)) {
Win32_ResizeWindowShape(data->window);
}
/* If this is an expected size change, allow it */ /* If this is an expected size change, allow it */
if (data->expected_resize) { if (data->expected_resize) {
break; break;

View File

@ -28,7 +28,6 @@
SDL_WindowShaper * SDL_WindowShaper *
Win32_CreateShaper(SDL_Window *window) Win32_CreateShaper(SDL_Window *window)
{ {
int resized_properly;
SDL_WindowShaper *result = (SDL_WindowShaper *)SDL_malloc(sizeof(SDL_WindowShaper)); SDL_WindowShaper *result = (SDL_WindowShaper *)SDL_malloc(sizeof(SDL_WindowShaper));
if (result == NULL) { if (result == NULL) {
SDL_OutOfMemory(); SDL_OutOfMemory();
@ -37,7 +36,6 @@ Win32_CreateShaper(SDL_Window *window)
result->window = window; result->window = window;
result->mode.mode = ShapeModeDefault; result->mode.mode = ShapeModeDefault;
result->mode.parameters.binarizationCutoff = 1; result->mode.parameters.binarizationCutoff = 1;
result->userx = result->usery = 0;
result->hasshape = SDL_FALSE; result->hasshape = SDL_FALSE;
result->driverdata = (SDL_ShapeData *)SDL_calloc(1, sizeof(SDL_ShapeData)); result->driverdata = (SDL_ShapeData *)SDL_calloc(1, sizeof(SDL_ShapeData));
if (!result->driverdata) { if (!result->driverdata) {
@ -46,14 +44,6 @@ Win32_CreateShaper(SDL_Window *window)
return NULL; return NULL;
} }
window->shaper = result; 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; return result;
} }
@ -98,28 +88,4 @@ int Win32_SetWindowShape(SDL_WindowShaper *shaper, SDL_Surface *shape, SDL_Windo
return 0; 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 */ #endif /* SDL_VIDEO_DRIVER_WINDOWS */

View File

@ -34,6 +34,5 @@ typedef struct
extern SDL_WindowShaper *Win32_CreateShaper(SDL_Window *window); 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_SetWindowShape(SDL_WindowShaper *shaper, SDL_Surface *shape, SDL_WindowShapeMode *shape_mode);
extern int Win32_ResizeWindowShape(SDL_Window *window);
#endif /* SDL_windowsshape_h_ */ #endif /* SDL_windowsshape_h_ */

View File

@ -205,7 +205,6 @@ static SDL_VideoDevice *WIN_CreateDevice(void)
device->shape_driver.CreateShaper = Win32_CreateShaper; device->shape_driver.CreateShaper = Win32_CreateShaper;
device->shape_driver.SetWindowShape = Win32_SetWindowShape; device->shape_driver.SetWindowShape = Win32_SetWindowShape;
device->shape_driver.ResizeWindowShape = Win32_ResizeWindowShape;
#endif #endif
#if SDL_VIDEO_OPENGL_WGL #if SDL_VIDEO_OPENGL_WGL

View File

@ -44,7 +44,6 @@ X11_CreateShaper(SDL_Window *window)
result->window = window; result->window = window;
result->mode.mode = ShapeModeDefault; result->mode.mode = ShapeModeDefault;
result->mode.parameters.binarizationCutoff = 1; result->mode.parameters.binarizationCutoff = 1;
result->userx = result->usery = 0;
data = SDL_malloc(sizeof(SDL_ShapeData)); data = SDL_malloc(sizeof(SDL_ShapeData));
if (data == NULL) { if (data == NULL) {
SDL_free(result); SDL_free(result);
@ -55,45 +54,12 @@ X11_CreateShaper(SDL_Window *window)
data->bitmapsize = 0; data->bitmapsize = 0;
data->bitmap = NULL; data->bitmap = NULL;
window->shaper = result; window->shaper = result;
if (X11_ResizeWindowShape(window) != 0) {
SDL_free(result);
SDL_free(data);
window->shaper = NULL;
return NULL;
}
} }
#endif #endif
return result; 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) int X11_SetWindowShape(SDL_WindowShaper *shaper, SDL_Surface *shape, SDL_WindowShapeMode *shape_mode)
{ {
#if SDL_VIDEO_DRIVER_X11_XSHAPE #if SDL_VIDEO_DRIVER_X11_XSHAPE

View File

@ -32,7 +32,6 @@ typedef struct
} SDL_ShapeData; } SDL_ShapeData;
extern SDL_WindowShaper *X11_CreateShaper(SDL_Window *window); 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); extern int X11_SetWindowShape(SDL_WindowShaper *shaper, SDL_Surface *shape, SDL_WindowShapeMode *shape_mode);
#endif /* SDL_x11shape_h_ */ #endif /* SDL_x11shape_h_ */

View File

@ -260,7 +260,6 @@ static SDL_VideoDevice *X11_CreateDevice(void)
device->shape_driver.CreateShaper = X11_CreateShaper; device->shape_driver.CreateShaper = X11_CreateShaper;
device->shape_driver.SetWindowShape = X11_SetWindowShape; device->shape_driver.SetWindowShape = X11_SetWindowShape;
device->shape_driver.ResizeWindowShape = X11_ResizeWindowShape;
#if SDL_VIDEO_OPENGL_GLX #if SDL_VIDEO_OPENGL_GLX
device->GL_LoadLibrary = X11_GL_LoadLibrary; device->GL_LoadLibrary = X11_GL_LoadLibrary;

View File

@ -941,9 +941,6 @@ void X11_SetWindowSize(_THIS, SDL_Window *window)
orig_w = attrs.width; orig_w = attrs.width;
orig_h = attrs.height; orig_h = attrs.height;
if (SDL_IsShapedWindow(window)) {
X11_ResizeWindowShape(window);
}
if (!(window->flags & SDL_WINDOW_RESIZABLE)) { 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 /* 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. */ we must set the size hints to adjust the window size. */

View File

@ -265,9 +265,7 @@ int main(int argc, char *argv[])
} }
/* Set 640x480 video mode */ /* Set 640x480 video mode */
window = SDL_CreateWindow("CheckKeys Test", window = SDL_CreateWindow("CheckKeys Test", 640, 480, 0);
SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED,
640, 480, 0);
if (window == NULL) { if (window == NULL) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create 640x480 window: %s\n", SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create 640x480 window: %s\n",
SDL_GetError()); SDL_GetError());

View File

@ -251,9 +251,7 @@ int main(int argc, char *argv[])
} }
/* Set 640x480 video mode */ /* Set 640x480 video mode */
window = SDL_CreateWindow("CheckKeys Test", window = SDL_CreateWindow("CheckKeys Test", 640, 480, 0);
SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED,
640, 480, 0);
if (window == NULL) { if (window == NULL) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create 640x480 window: %s\n", SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create 640x480 window: %s\n",
SDL_GetError()); SDL_GetError());

View File

@ -746,9 +746,7 @@ int main(int argc, char *argv[])
} }
/* Create a window to display joystick axis position */ /* Create a window to display joystick axis position */
window = SDL_CreateWindow("Game Controller Map", SDL_WINDOWPOS_CENTERED, window = SDL_CreateWindow("Game Controller Map", SCREEN_WIDTH, SCREEN_HEIGHT, 0);
SDL_WINDOWPOS_CENTERED, SCREEN_WIDTH,
SCREEN_HEIGHT, 0);
if (window == NULL) { if (window == NULL) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create window: %s\n", SDL_GetError()); SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create window: %s\n", SDL_GetError());
return 2; return 2;

View File

@ -41,7 +41,7 @@ Code
SDL_Init(SDL_INIT_VIDEO); 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); SDL_SetRelativeMouseMode(SDL_TRUE);
while (1) while (1)

View File

@ -105,7 +105,7 @@ int main(int argc, char **argv)
return 1; 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); renderer = SDL_CreateRenderer(window, NULL, 0);
SDL_SetRenderDrawColor(renderer, 0, 0, 0, 255); SDL_SetRenderDrawColor(renderer, 0, 0, 0, 255);
SDL_RenderClear(renderer); SDL_RenderClear(renderer);

View File

@ -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. */ /* 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"); filename = GetResourceFilename(argc > 1 ? argv[1] : NULL, "sample.wav");

View File

@ -404,9 +404,9 @@ int mouse_getSetRelativeMouseMode(void *arg)
*/ */
static SDL_Window *createMouseSuiteTestWindow() 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; SDL_Window *window;
window = SDL_CreateWindow("mousecreateMouseSuiteTestWindow", posX, posY, width, height, 0); window = SDL_CreateWindow("mousecreateMouseSuiteTestWindow", width, height, 0);
SDLTest_AssertPass("SDL_CreateWindow()"); SDLTest_AssertPass("SDL_CreateWindow()");
SDLTest_AssertCheck(window != NULL, "Check SDL_CreateWindow result"); SDLTest_AssertCheck(window != NULL, "Check SDL_CreateWindow result");
return window; return window;

View File

@ -47,9 +47,9 @@ static int isSupported(int code);
*/ */
void InitCreateRenderer(void *arg) void InitCreateRenderer(void *arg)
{ {
int posX = 100, posY = 100, width = 320, height = 240; int width = 320, height = 240;
renderer = NULL; 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_AssertPass("SDL_CreateWindow()");
SDLTest_AssertCheck(window != NULL, "Check SDL_CreateWindow result"); SDLTest_AssertCheck(window != NULL, "Check SDL_CreateWindow result");
if (window == NULL) { if (window == NULL) {

View File

@ -16,7 +16,7 @@ int syswm_getWindowWMInfo(void *arg)
SDL_Window *window; SDL_Window *window;
SDL_SysWMinfo info; 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_AssertPass("Call to SDL_CreateWindow()");
SDLTest_AssertCheck(window != NULL, "Check that value returned from SDL_CreateWindow is not NULL"); SDLTest_AssertCheck(window != NULL, "Check that value returned from SDL_CreateWindow is not NULL");
if (window == NULL) { if (window == NULL) {

View File

@ -12,18 +12,16 @@
static SDL_Window *createVideoSuiteTestWindow(const char *title) static SDL_Window *createVideoSuiteTestWindow(const char *title)
{ {
SDL_Window *window; SDL_Window *window;
int x, y, w, h; int w, h;
SDL_WindowFlags flags; SDL_WindowFlags flags;
/* Standard window */ /* Standard window */
x = SDLTest_RandomIntegerInRange(1, 100);
y = SDLTest_RandomIntegerInRange(1, 100);
w = SDLTest_RandomIntegerInRange(320, 1024); w = SDLTest_RandomIntegerInRange(320, 1024);
h = SDLTest_RandomIntegerInRange(320, 768); h = SDLTest_RandomIntegerInRange(320, 768);
flags = SDL_WINDOW_RESIZABLE | SDL_WINDOW_BORDERLESS; flags = SDL_WINDOW_RESIZABLE | SDL_WINDOW_BORDERLESS;
window = SDL_CreateWindow(title, x, y, w, h, flags); window = SDL_CreateWindow(title, w, h, flags);
SDLTest_AssertPass("Call to SDL_CreateWindow('Title',%d,%d,%d,%d,%d)", x, y, 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"); SDLTest_AssertCheck(window != NULL, "Validate that returned window struct is not NULL");
return window; return window;
@ -94,88 +92,6 @@ int video_enableDisableScreensaver(void *arg)
return TEST_COMPLETED; 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 * \brief Tests the functionality of the SDL_CreateWindow function using different sizes
*/ */
@ -183,11 +99,9 @@ int video_createWindowVariousSizes(void *arg)
{ {
SDL_Window *window; SDL_Window *window;
const char *title = "video_createWindowVariousSizes Test Window"; const char *title = "video_createWindowVariousSizes Test Window";
int x, y, w, h; int w, h;
int wVariation, hVariation; int wVariation, hVariation;
x = SDLTest_RandomIntegerInRange(1, 100);
y = SDLTest_RandomIntegerInRange(1, 100);
for (wVariation = 0; wVariation < 3; wVariation++) { for (wVariation = 0; wVariation < 3; wVariation++) {
for (hVariation = 0; hVariation < 3; hVariation++) { for (hVariation = 0; hVariation < 3; hVariation++) {
switch (wVariation) { switch (wVariation) {
@ -220,8 +134,8 @@ int video_createWindowVariousSizes(void *arg)
break; break;
} }
window = SDL_CreateWindow(title, x, y, w, h, 0); window = SDL_CreateWindow(title, w, h, 0);
SDLTest_AssertPass("Call to SDL_CreateWindow('Title',%d,%d,%d,%d,SHOWN)", x, y, w, h); SDLTest_AssertPass("Call to SDL_CreateWindow('Title',%d,%d,SHOWN)", w, h);
SDLTest_AssertCheck(window != NULL, "Validate that returned window struct is not NULL"); SDLTest_AssertCheck(window != NULL, "Validate that returned window struct is not NULL");
/* Clean up */ /* Clean up */
@ -239,13 +153,11 @@ int video_createWindowVariousFlags(void *arg)
{ {
SDL_Window *window; SDL_Window *window;
const char *title = "video_createWindowVariousFlags Test Window"; const char *title = "video_createWindowVariousFlags Test Window";
int x, y, w, h; int w, h;
int fVariation; int fVariation;
SDL_WindowFlags flags; SDL_WindowFlags flags;
/* Standard window */ /* Standard window */
x = SDLTest_RandomIntegerInRange(1, 100);
y = SDLTest_RandomIntegerInRange(1, 100);
w = SDLTest_RandomIntegerInRange(320, 1024); w = SDLTest_RandomIntegerInRange(320, 1024);
h = SDLTest_RandomIntegerInRange(320, 768); h = SDLTest_RandomIntegerInRange(320, 768);
@ -295,8 +207,8 @@ int video_createWindowVariousFlags(void *arg)
break; break;
} }
window = SDL_CreateWindow(title, x, y, w, h, flags); window = SDL_CreateWindow(title, w, h, flags);
SDLTest_AssertPass("Call to SDL_CreateWindow('Title',%d,%d,%d,%d,%d)", x, y, 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"); SDLTest_AssertCheck(window != NULL, "Validate that returned window struct is not NULL");
/* Clean up */ /* Clean up */
@ -1678,10 +1590,14 @@ int video_setWindowCenteredOnDisplay(void *arg)
expectedX = (expectedDisplayRect.x + ((expectedDisplayRect.w - w) / 2)); expectedX = (expectedDisplayRect.x + ((expectedDisplayRect.w - w) / 2));
expectedY = (expectedDisplayRect.y + ((expectedDisplayRect.h - h) / 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_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"); 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 */ /* Check the window is centered on the requested display */
currentDisplay = SDL_GetDisplayForWindow(window); currentDisplay = SDL_GetDisplayForWindow(window);
SDL_GetWindowSize(window, &currentW, &currentH); SDL_GetWindowSize(window, &currentW, &currentH);
@ -1762,74 +1678,70 @@ static const SDLTest_TestCaseReference videoTest1 = {
}; };
static const SDLTest_TestCaseReference videoTest2 = { 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 (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 (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 (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 (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 (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 (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 (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 (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 (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 (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 (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 (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 (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 (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 (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 (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 (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, &videoTest1, &videoTest2, &videoTest3, &videoTest4, &videoTest5, &videoTest6,
&videoTest7, &videoTest8, &videoTest9, &videoTest10, &videoTest11, &videoTest12, &videoTest7, &videoTest8, &videoTest9, &videoTest10, &videoTest11, &videoTest12,
&videoTest13, &videoTest14, &videoTest15, &videoTest16, &videoTest17, &videoTest13, &videoTest14, &videoTest15, &videoTest16, &videoTest17,
&videoTest18, &videoTest19, NULL &videoTest18, NULL
}; };
/* Video test suite (global) */ /* Video test suite (global) */

View File

@ -110,7 +110,7 @@ int main(int argc, char *argv[])
} }
/* Create window and renderer for given surface */ /* 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) { if (window == NULL) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Window creation fail : %s\n", SDL_GetError()); SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Window creation fail : %s\n", SDL_GetError());
return 1; return 1;

View File

@ -897,9 +897,7 @@ int main(int argc, char *argv[])
} }
/* Create a window to display gamepad state */ /* Create a window to display gamepad state */
window = SDL_CreateWindow("Gamepad Test", SDL_WINDOWPOS_CENTERED, window = SDL_CreateWindow("Gamepad Test", SCREEN_WIDTH, SCREEN_HEIGHT, 0);
SDL_WINDOWPOS_CENTERED, SCREEN_WIDTH,
SCREEN_HEIGHT, 0);
if (window == NULL) { if (window == NULL) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create window: %s\n", SDL_GetError()); SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create window: %s\n", SDL_GetError());
return 2; return 2;

View File

@ -81,7 +81,7 @@ int main(int argc, char **argv)
/* !!! FIXME: check for errors. */ /* !!! FIXME: check for errors. */
SDL_Init(SDL_INIT_VIDEO); 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); renderer = SDL_CreateRenderer(window, NULL, 0);
if (SDL_SetWindowHitTest(window, hitTest, NULL) == -1) { if (SDL_SetWindowHitTest(window, hitTest, NULL) == -1) {

View File

@ -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)); SDL_free(SDL_GetJoysticks(&num_joysticks));

View File

@ -299,9 +299,7 @@ int main(int argc, char *argv[])
} }
/* Create a window to display joystick axis position */ /* Create a window to display joystick axis position */
window = SDL_CreateWindow("Joystick Test", SDL_WINDOWPOS_CENTERED, window = SDL_CreateWindow("Joystick Test", SCREEN_WIDTH, SCREEN_HEIGHT, 0);
SDL_WINDOWPOS_CENTERED, SCREEN_WIDTH,
SCREEN_HEIGHT, 0);
if (window == NULL) { if (window == NULL) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create window: %s\n", SDL_GetError()); SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create window: %s\n", SDL_GetError());
return SDL_FALSE; return SDL_FALSE;

View File

@ -183,7 +183,7 @@ int main(int argc, char *argv[])
/* Test showing a message box with a parent window */ /* Test showing a message box with a parent window */
{ {
SDL_Event event; 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 /* On wayland, no window will actually show until something has
actually been displayed. actually been displayed.

View File

@ -261,9 +261,7 @@ int main(int argc, char *argv[])
} }
/* Create a window to display joystick axis position */ /* Create a window to display joystick axis position */
window = SDL_CreateWindow("Mouse Test", SDL_WINDOWPOS_CENTERED, window = SDL_CreateWindow("Mouse Test", SCREEN_WIDTH, SCREEN_HEIGHT, 0);
SDL_WINDOWPOS_CENTERED, SCREEN_WIDTH,
SCREEN_HEIGHT, 0);
if (window == NULL) { if (window == NULL) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create window: %s\n", SDL_GetError()); SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create window: %s\n", SDL_GetError());
return SDL_FALSE; return SDL_FALSE;

View File

@ -77,7 +77,7 @@ test_multi_audio(int devcount)
SDL_Event event; SDL_Event event;
/* Create a Window to get fully initialized event processing for testing pause on Android. */ /* 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 #endif
if (devcount > 64) { if (devcount > 64) {

View File

@ -110,9 +110,7 @@ int main(int argc, char *argv[])
} }
/* If OPENGL fails to init it will fallback to using a framebuffer for rendering */ /* If OPENGL fails to init it will fallback to using a framebuffer for rendering */
window = SDL_CreateWindow("Offscreen Test", window = SDL_CreateWindow("Offscreen Test", width, height, 0);
SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED,
width, height, 0);
if (window == NULL) { if (window == NULL) {
SDL_Log("Couldn't create window: %s\n", SDL_Log("Couldn't create window: %s\n",

View File

@ -95,7 +95,7 @@ int main(int argc, char **argv)
SDL_bool done = SDL_FALSE; SDL_bool done = SDL_FALSE;
SDL_Event event; 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) { while (!done) {
/* Update to get the current event state */ /* Update to get the current event state */
SDL_PumpEvents(); SDL_PumpEvents();

View File

@ -456,7 +456,7 @@ int main(int argc, char **argv)
} }
/* Create a 640x480 OpenGL screen */ /* 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) { if (window == NULL) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Unable to create OpenGL window: %s\n", SDL_GetError()); SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Unable to create OpenGL window: %s\n", SDL_GetError());
SDL_Quit(); SDL_Quit();

View File

@ -14,8 +14,6 @@
#include <SDL3/SDL.h> #include <SDL3/SDL.h>
#include <SDL3/SDL_main.h> #include <SDL3/SDL_main.h>
#define SHAPED_WINDOW_X 150
#define SHAPED_WINDOW_Y 150
#define SHAPED_WINDOW_DIMENSION 640 #define SHAPED_WINDOW_DIMENSION 640
typedef struct LoadedPicture typedef struct LoadedPicture
@ -106,9 +104,7 @@ int main(int argc, char **argv)
} }
window = SDL_CreateShapedWindow("SDL_Shape test", 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) { if (window == NULL) {
for (i = 0; i < num_pictures; i++) { for (i = 0; i < num_pictures; i++) {
SDL_DestroySurface(pictures[i].surface); SDL_DestroySurface(pictures[i].surface);

View File

@ -155,11 +155,7 @@ int main(int argc, char **argv)
SDL_RWclose(handle); SDL_RWclose(handle);
/* Create the window and renderer */ /* Create the window and renderer */
window = SDL_CreateWindow("Happy Moose", window = SDL_CreateWindow("Happy Moose", MOOSEPIC_W * 4, MOOSEPIC_H * 4, SDL_WINDOW_RESIZABLE);
SDL_WINDOWPOS_UNDEFINED,
SDL_WINDOWPOS_UNDEFINED,
MOOSEPIC_W * 4, MOOSEPIC_H * 4,
SDL_WINDOW_RESIZABLE);
if (window == NULL) { if (window == NULL) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't set create window: %s\n", SDL_GetError()); SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't set create window: %s\n", SDL_GetError());
quit(3); quit(3);

View File

@ -349,11 +349,7 @@ int main(int argc, char **argv)
now = SDL_GetTicks(); 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); 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", window = SDL_CreateWindow("YUV test", original->w, original->h, 0);
SDL_WINDOWPOS_UNDEFINED,
SDL_WINDOWPOS_UNDEFINED,
original->w, original->h,
0);
if (window == NULL) { if (window == NULL) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create window: %s\n", SDL_GetError()); SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create window: %s\n", SDL_GetError());
return 4; return 4;