diff --git a/cmake/test/main_gui.c b/cmake/test/main_gui.c index a1aa410d3..2e1aa0f15 100644 --- a/cmake/test/main_gui.c +++ b/cmake/test/main_gui.c @@ -13,7 +13,7 @@ int main(int argc, char *argv[]) { "Hello SDL", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, 640, 480, - SDL_WINDOW_SHOWN + 0 ); if (window == NULL) { fprintf(stderr, "could not create window: %s\n", SDL_GetError()); diff --git a/docs/README-visualc.md b/docs/README-visualc.md index 44e74d79d..43f426f42 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, SDL_WINDOW_SHOWN); + window = SDL_CreateWindow("Hello SDL", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, WIDTH, HEIGHT, 0); renderer = SDL_CreateRenderer(window, NULL, SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC); SDL_DestroyRenderer(renderer); diff --git a/include/SDL3/SDL_video.h b/include/SDL3/SDL_video.h index 387ca7db2..8fdd06d31 100644 --- a/include/SDL3/SDL_video.h +++ b/include/SDL3/SDL_video.h @@ -103,7 +103,6 @@ typedef enum { SDL_WINDOW_FULLSCREEN = 0x00000001, /**< fullscreen window */ SDL_WINDOW_OPENGL = 0x00000002, /**< window usable with OpenGL context */ - SDL_WINDOW_SHOWN = 0x00000004, /**< window is visible */ SDL_WINDOW_HIDDEN = 0x00000008, /**< window is not visible */ SDL_WINDOW_BORDERLESS = 0x00000010, /**< no window decoration */ SDL_WINDOW_RESIZABLE = 0x00000020, /**< window can be resized */ @@ -379,10 +378,10 @@ extern DECLSPEC int SDLCALL SDL_GetDisplayUsableBounds(int displayIndex, SDL_Rec * **WARNING**: This reports the DPI that the hardware reports, and it is not * always reliable! It is almost always better to use SDL_GetWindowSize() to * find the window size, which might be in logical points instead of pixels, - * and then SDL_GetWindowSizeInPixels(), SDL_GL_GetDrawableSize(), - * SDL_Vulkan_GetDrawableSize(), SDL_Metal_GetDrawableSize(), or + * and then SDL_GetWindowSizeInPixels(), SDL_GL_GetDrawableSize(), + * SDL_Vulkan_GetDrawableSize(), SDL_Metal_GetDrawableSize(), or * SDL_GetRendererOutputSize(), and compare the two values to get an actual - * scaling value between the two. We will be rethinking how high-dpi details + * scaling value between the two. We will be rethinking how high-dpi details * should be managed in SDL3 to make things more consistent, reliable, and clear. * * \param displayIndex the index of the display from which DPI information @@ -656,9 +655,7 @@ extern DECLSPEC Uint32 SDLCALL SDL_GetWindowPixelFormat(SDL_Window * window); * - `SDL_WINDOW_ALLOW_HIGHDPI`: window should be created in high-DPI mode if * supported (>= SDL 2.0.1) * - * `SDL_WINDOW_SHOWN` is ignored by SDL_CreateWindow(). The SDL_Window is - * implicitly shown if SDL_WINDOW_HIDDEN is not set. `SDL_WINDOW_SHOWN` may be - * queried later using SDL_GetWindowFlags(). + * The SDL_Window is implicitly shown if SDL_WINDOW_HIDDEN is not set. * * On Apple's macOS, you **must** set the NSHighResolutionCapable Info.plist * property to YES, otherwise you will not receive a High-DPI OpenGL canvas. @@ -923,7 +920,7 @@ extern DECLSPEC void SDLCALL SDL_SetWindowSize(SDL_Window * window, int w, * The window size in screen coordinates may differ from the size in pixels, * if the window was created with `SDL_WINDOW_ALLOW_HIGHDPI` on a platform * with high-dpi support (e.g. iOS or macOS). Use SDL_GetWindowSizeInPixels(), - * SDL_GL_GetDrawableSize(), SDL_Vulkan_GetDrawableSize(), or + * SDL_GL_GetDrawableSize(), SDL_Vulkan_GetDrawableSize(), or * SDL_GetRendererOutputSize() to get the real client area size in pixels. * * \param window the window to query the width and height from diff --git a/src/events/SDL_windowevents.c b/src/events/SDL_windowevents.c index 524caa97f..f3e417ed1 100644 --- a/src/events/SDL_windowevents.c +++ b/src/events/SDL_windowevents.c @@ -84,18 +84,16 @@ int SDL_SendWindowEvent(SDL_Window *window, SDL_EventType windowevent, } switch (windowevent) { case SDL_WINDOWEVENT_SHOWN: - if (window->flags & SDL_WINDOW_SHOWN) { + if (!(window->flags & SDL_WINDOW_HIDDEN)) { return 0; } window->flags &= ~(SDL_WINDOW_HIDDEN | SDL_WINDOW_MINIMIZED); - window->flags |= SDL_WINDOW_SHOWN; SDL_OnWindowShown(window); break; case SDL_WINDOWEVENT_HIDDEN: - if (!(window->flags & SDL_WINDOW_SHOWN)) { + if (window->flags & SDL_WINDOW_HIDDEN) { return 0; } - window->flags &= ~SDL_WINDOW_SHOWN; window->flags |= SDL_WINDOW_HIDDEN; SDL_OnWindowHidden(window); break; diff --git a/src/test/SDL_test_common.c b/src/test/SDL_test_common.c index 64ccb4b23..f91fe2355 100644 --- a/src/test/SDL_test_common.c +++ b/src/test/SDL_test_common.c @@ -32,7 +32,7 @@ static const char *video_usage[] = { "[--min-geometry WxH]", "[--max-geometry WxH]", "[--logical WxH]", "[--scale N]", "[--depth N]", "[--refresh R]", "[--vsync]", "[--noframe]", "[--resizable]", "[--minimize]", "[--maximize]", "[--grab]", "[--keyboard-grab]", - "[--shown]", "[--hidden]", "[--input-focus]", "[--mouse-focus]", + "[--hidden]", "[--input-focus]", "[--mouse-focus]", "[--flash-on-focus-loss]", "[--allow-highdpi]", "[--confine-cursor X,Y,W,H]", "[--usable-bounds]" }; @@ -453,10 +453,6 @@ int SDLTest_CommonArg(SDLTest_CommonState *state, int index) state->window_flags |= SDL_WINDOW_MAXIMIZED; return 1; } - if (SDL_strcasecmp(argv[index], "--shown") == 0) { - state->window_flags |= SDL_WINDOW_SHOWN; - return 1; - } if (SDL_strcasecmp(argv[index], "--hidden") == 0) { state->window_flags |= SDL_WINDOW_HIDDEN; return 1; @@ -690,9 +686,6 @@ static void SDLTest_PrintWindowFlag(char *text, size_t maxlen, Uint32 flag) case SDL_WINDOW_OPENGL: SDL_snprintfcat(text, maxlen, "OPENGL"); break; - case SDL_WINDOW_SHOWN: - SDL_snprintfcat(text, maxlen, "SHOWN"); - break; case SDL_WINDOW_HIDDEN: SDL_snprintfcat(text, maxlen, "HIDDEN"); break; @@ -764,7 +757,6 @@ static void SDLTest_PrintWindowFlags(char *text, size_t maxlen, Uint32 flags) const Uint32 window_flags[] = { SDL_WINDOW_FULLSCREEN, SDL_WINDOW_OPENGL, - SDL_WINDOW_SHOWN, SDL_WINDOW_HIDDEN, SDL_WINDOW_BORDERLESS, SDL_WINDOW_RESIZABLE, diff --git a/src/video/SDL_shape.c b/src/video/SDL_shape.c index 7d8aabdef..03db0125f 100644 --- a/src/video/SDL_shape.c +++ b/src/video/SDL_shape.c @@ -27,7 +27,7 @@ SDL_Window * SDL_CreateShapedWindow(const char *title, unsigned int x, unsigned int y, unsigned int w, unsigned 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) /* & (~SDL_WINDOW_SHOWN) */); + result = SDL_CreateWindow(title, -1000, -1000, w, h, (flags | SDL_WINDOW_BORDERLESS) & (~SDL_WINDOW_FULLSCREEN) & (~SDL_WINDOW_RESIZABLE)); if (result != NULL) { if (SDL_GetVideoDevice()->shape_driver.CreateShaper == NULL) { SDL_DestroyWindow(result); diff --git a/src/video/SDL_sysvideo.h b/src/video/SDL_sysvideo.h index 469cddaa2..dc96350f4 100644 --- a/src/video/SDL_sysvideo.h +++ b/src/video/SDL_sysvideo.h @@ -110,7 +110,7 @@ struct SDL_Window }; #define FULLSCREEN_VISIBLE(W) \ (((W)->flags & SDL_WINDOW_FULLSCREEN) && \ - ((W)->flags & SDL_WINDOW_SHOWN) && \ + !((W)->flags & SDL_WINDOW_HIDDEN) && \ !((W)->flags & SDL_WINDOW_MINIMIZED)) /* diff --git a/src/video/SDL_video.c b/src/video/SDL_video.c index 4d8be6123..5f046c72c 100644 --- a/src/video/SDL_video.c +++ b/src/video/SDL_video.c @@ -2453,7 +2453,7 @@ void SDL_ShowWindow(SDL_Window *window) { CHECK_WINDOW_MAGIC(window, ); - if (window->flags & SDL_WINDOW_SHOWN) { + if (!(window->flags & SDL_WINDOW_HIDDEN)) { return; } @@ -2467,7 +2467,7 @@ void SDL_HideWindow(SDL_Window *window) { CHECK_WINDOW_MAGIC(window, ); - if (!(window->flags & SDL_WINDOW_SHOWN)) { + if (window->flags & SDL_WINDOW_HIDDEN) { return; } @@ -2485,7 +2485,7 @@ void SDL_RaiseWindow(SDL_Window *window) { CHECK_WINDOW_MAGIC(window, ); - if (!(window->flags & SDL_WINDOW_SHOWN)) { + if (window->flags & SDL_WINDOW_HIDDEN) { return; } if (_this->RaiseWindow) { diff --git a/src/video/android/SDL_androidwindow.c b/src/video/android/SDL_androidwindow.c index 1697a378c..0798c22c4 100644 --- a/src/video/android/SDL_androidwindow.c +++ b/src/video/android/SDL_androidwindow.c @@ -59,7 +59,6 @@ int Android_CreateWindow(_THIS, SDL_Window *window) window->h = Android_SurfaceHeight; window->flags &= ~SDL_WINDOW_HIDDEN; - window->flags |= SDL_WINDOW_SHOWN; /* only one window on Android */ /* One window, it always has focus */ SDL_SetMouseFocus(window); diff --git a/src/video/cocoa/SDL_cocoawindow.m b/src/video/cocoa/SDL_cocoawindow.m index f10dc468a..bb2b0cad0 100644 --- a/src/video/cocoa/SDL_cocoawindow.m +++ b/src/video/cocoa/SDL_cocoawindow.m @@ -1082,7 +1082,7 @@ static void Cocoa_UpdateClipCursor(SDL_Window *window) [self windowDidResize:aNotification]; /* FIXME: Why does the window get hidden? */ - if (window->flags & SDL_WINDOW_SHOWN) { + if (!(window->flags & SDL_WINDOW_HIDDEN)) { Cocoa_ShowWindow(SDL_GetVideoDevice(), window); } } @@ -1645,9 +1645,9 @@ static int SetupWindowData(_THIS, SDL_Window *window, NSWindow *nswindow, NSView [data.listener listen:data]; if ([nswindow isVisible]) { - window->flags |= SDL_WINDOW_SHOWN; + window->flags &= ~SDL_WINDOW_HIDDEN; } else { - window->flags &= ~SDL_WINDOW_SHOWN; + window->flags |= SDL_WINDOW_HIDDEN; } { diff --git a/src/video/windows/SDL_windowswindow.c b/src/video/windows/SDL_windowswindow.c index 47455c5a6..57bd0534d 100644 --- a/src/video/windows/SDL_windowswindow.c +++ b/src/video/windows/SDL_windowswindow.c @@ -378,9 +378,9 @@ static int SetupWindowData(_THIS, SDL_Window *window, HWND hwnd, HWND parent, SD { DWORD style = GetWindowLong(hwnd, GWL_STYLE); if (style & WS_VISIBLE) { - window->flags |= SDL_WINDOW_SHOWN; + window->flags &= ~SDL_WINDOW_HIDDEN; } else { - window->flags &= ~SDL_WINDOW_SHOWN; + window->flags |= SDL_WINDOW_HIDDEN; } if (style & WS_POPUP) { window->flags |= SDL_WINDOW_BORDERLESS; diff --git a/src/video/winrt/SDL_winrtvideo.cpp b/src/video/winrt/SDL_winrtvideo.cpp index 16aede756..5f345c58a 100644 --- a/src/video/winrt/SDL_winrtvideo.cpp +++ b/src/video/winrt/SDL_winrtvideo.cpp @@ -489,7 +489,7 @@ void WINRT_VideoQuit(_THIS) WINRT_QuitMouse(_this); } -static const Uint32 WINRT_DetectableFlags = SDL_WINDOW_MAXIMIZED | SDL_WINDOW_FULLSCREEN_DESKTOP | SDL_WINDOW_SHOWN | SDL_WINDOW_HIDDEN | SDL_WINDOW_MOUSE_FOCUS; +static const Uint32 WINRT_DetectableFlags = SDL_WINDOW_MAXIMIZED | SDL_WINDOW_FULLSCREEN_DESKTOP | SDL_WINDOW_HIDDEN | SDL_WINDOW_MOUSE_FOCUS; extern "C" Uint32 WINRT_DetectWindowFlags(SDL_Window *window) @@ -541,7 +541,7 @@ WINRT_DetectWindowFlags(SDL_Window *window) } if (data->coreWindow->Visible) { - latestFlags |= SDL_WINDOW_SHOWN; + latestFlags &= ~SDL_WINDOW_HIDDEN; } else { latestFlags |= SDL_WINDOW_HIDDEN; } @@ -693,7 +693,7 @@ int WINRT_CreateWindow(_THIS, SDL_Window *window) /* TODO, WinRT: set SDL_Window size, maybe position too, from XAML control */ window->x = 0; window->y = 0; - window->flags |= SDL_WINDOW_SHOWN; + window->flags &= ~SDL_WINDOW_HIDDEN; SDL_SetMouseFocus(NULL); // TODO: detect this SDL_SetKeyboardFocus(NULL); // TODO: detect this } else { diff --git a/src/video/x11/SDL_x11window.c b/src/video/x11/SDL_x11window.c index fea82d479..dc1dbb82a 100644 --- a/src/video/x11/SDL_x11window.c +++ b/src/video/x11/SDL_x11window.c @@ -306,9 +306,9 @@ static int SetupWindowData(_THIS, SDL_Window *window, Window w, BOOL created) window->w = attrib.width; window->h = attrib.height; if (attrib.map_state != IsUnmapped) { - window->flags |= SDL_WINDOW_SHOWN; + window->flags &= SDL_WINDOW_HIDDEN; } else { - window->flags &= ~SDL_WINDOW_SHOWN; + window->flags |= SDL_WINDOW_HIDDEN; } data->visual = attrib.visual; data->colormap = attrib.colormap; diff --git a/test/testautomation_video.c b/test/testautomation_video.c index 6b5ac14da..e3cab4932 100644 --- a/test/testautomation_video.c +++ b/test/testautomation_video.c @@ -20,7 +20,7 @@ SDL_Window *_createVideoSuiteTestWindow(const char *title) y = SDLTest_RandomIntegerInRange(1, 100); w = SDLTest_RandomIntegerInRange(320, 1024); h = SDLTest_RandomIntegerInRange(320, 768); - flags = SDL_WINDOW_SHOWN | SDL_WINDOW_RESIZABLE | SDL_WINDOW_BORDERLESS; + 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); @@ -164,7 +164,7 @@ int video_createWindowVariousPositions(void *arg) w = SDLTest_RandomIntegerInRange(32, 96); h = SDLTest_RandomIntegerInRange(32, 96); - window = SDL_CreateWindow(title, x, y, w, h, SDL_WINDOW_SHOWN); + 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"); @@ -220,7 +220,7 @@ int video_createWindowVariousSizes(void *arg) break; } - window = SDL_CreateWindow(title, x, y, w, h, SDL_WINDOW_SHOWN); + 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"); @@ -266,7 +266,7 @@ int video_createWindowVariousFlags(void *arg) flags = SDL_WINDOW_OPENGL; break; case 3: - flags = SDL_WINDOW_SHOWN; + flags = 0; break; case 4: flags = SDL_WINDOW_HIDDEN; @@ -322,7 +322,7 @@ int video_getWindowFlags(void *arg) Uint32 actualFlags; /* Reliable flag set always set in test window */ - flags = SDL_WINDOW_SHOWN; + flags = 0; /* Call against new test window */ window = _createVideoSuiteTestWindow(title); @@ -1753,7 +1753,7 @@ 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, SDL_WINDOW_SHOWN | SDL_WINDOW_ALLOW_HIGHDPI); + window = SDL_CreateWindow(title, x, y, w, h, SDL_WINDOW_ALLOW_HIGHDPI); 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");