Renamed SDL_WINDOW_FOREIGN to SDL_WINDOW_EXTERNAL

This commit is contained in:
Sam Lantinga 2023-11-13 12:21:23 -08:00
parent 229b7b9d50
commit e0c45c6c98
10 changed files with 43 additions and 42 deletions

View File

@ -562,7 +562,7 @@ The following hints have been removed:
* SDL_HINT_VIDEO_FOREIGN_WINDOW_OPENGL - replaced with the "opengl" property in SDL_CreateWindowWithProperties()
* SDL_HINT_VIDEO_FOREIGN_WINDOW_VULKAN - replaced with the "vulkan" property in SDL_CreateWindowWithProperties()
* SDL_HINT_VIDEO_HIGHDPI_DISABLED - high DPI support is always enabled
* SDL_HINT_VIDEO_WINDOW_SHARE_PIXEL_FORMAT - replaced with the "native.win32.pixel_format_hwnd" in SDL_CreateWindowWithProperties()
* SDL_HINT_VIDEO_WINDOW_SHARE_PIXEL_FORMAT - replaced with the "win32.pixel_format_hwnd" in SDL_CreateWindowWithProperties()
* SDL_HINT_VIDEO_X11_FORCE_EGL - use SDL_HINT_VIDEO_FORCE_EGL instead
* SDL_HINT_VIDEO_X11_XINERAMA - Xinerama no longer supported by the X11 backend
* SDL_HINT_VIDEO_X11_XVIDMODE - Xvidmode no longer supported by the X11 backend
@ -1330,7 +1330,7 @@ The following functions have been removed:
* SDL_GetNumVideoDisplays() - replaced with SDL_GetDisplays()
* SDL_GetWindowData() - use SDL_GetWindowProperties() instead
* SDL_SetWindowData() - use SDL_GetWindowProperties() instead
* SDL_CreateWindowFrom() - use SDL_CreateWindowWithProperties() with "native.*" properties instead
* SDL_CreateWindowFrom() - use SDL_CreateWindowWithProperties() with the properties that allow you to wrap an existing window
SDL_Window id type is named SDL_WindowID

View File

@ -138,7 +138,7 @@ typedef enum
SDL_WINDOW_MOUSE_GRABBED = 0x00000100, /**< window has grabbed mouse input */
SDL_WINDOW_INPUT_FOCUS = 0x00000200, /**< window has input focus */
SDL_WINDOW_MOUSE_FOCUS = 0x00000400, /**< window has mouse focus */
SDL_WINDOW_FOREIGN = 0x00000800, /**< window not created by SDL */
SDL_WINDOW_EXTERNAL = 0x00000800, /**< window not created by SDL */
SDL_WINDOW_HIGH_PIXEL_DENSITY = 0x00002000, /**< window uses high pixel density back buffer if possible */
SDL_WINDOW_MOUSE_CAPTURE = 0x00004000, /**< window has mouse captured (unrelated to MOUSE_GRABBED) */
SDL_WINDOW_ALWAYS_ON_TOP = 0x00008000, /**< window should always be above others */
@ -827,17 +827,17 @@ extern DECLSPEC SDL_Window *SDLCALL SDL_CreatePopupWindow(SDL_Window *parent, in
*
* On macOS:
*
* - "native.cocoa.window" (pointer) - the (__unsafe_unretained) NSWindow associated with the window, if you want to wrap an existing window.
* - "native.cocoa.view" (pointer) - the (__unsafe_unretained) NSView associated with the window, defaults to [window contentView]
* - "cocoa.window" (pointer) - the (__unsafe_unretained) NSWindow associated with the window, if you want to wrap an existing window.
* - "cocoa.view" (pointer) - the (__unsafe_unretained) NSView associated with the window, defaults to [window contentView]
*
* On Windows:
*
* - "native.win32.hwnd" (pointer) - the HWND associated with the window, if you want to wrap an existing window.
* - "native.win32.pixel_format_hwnd" (pointer) - optional, another window to share pixel format with, useful for OpenGL windows
* - "win32.hwnd" (pointer) - the HWND associated with the window, if you want to wrap an existing window.
* - "win32.pixel_format_hwnd" (pointer) - optional, another window to share pixel format with, useful for OpenGL windows
*
* On X11:
*
* - "native.x11.window" (number) - the X11 Window associated with the window, if you want to wrap an existing window.
* - "x11.window" (number) - the X11 Window associated with the window, if you want to wrap an existing window.
*
* The SDL_Window is implicitly shown if the "hidden" property is not set.
*

View File

@ -783,8 +783,8 @@ static void SDLTest_PrintWindowFlag(char *text, size_t maxlen, Uint32 flag)
case SDL_WINDOW_MOUSE_FOCUS:
SDL_snprintfcat(text, maxlen, "MOUSE_FOCUS");
break;
case SDL_WINDOW_FOREIGN:
SDL_snprintfcat(text, maxlen, "FOREIGN");
case SDL_WINDOW_EXTERNAL:
SDL_snprintfcat(text, maxlen, "EXTERNAL");
break;
case SDL_WINDOW_HIGH_PIXEL_DENSITY:
SDL_snprintfcat(text, maxlen, "HIGH_PIXEL_DENSITY");
@ -835,7 +835,7 @@ static void SDLTest_PrintWindowFlags(char *text, size_t maxlen, Uint32 flags)
SDL_WINDOW_MOUSE_GRABBED,
SDL_WINDOW_INPUT_FOCUS,
SDL_WINDOW_MOUSE_FOCUS,
SDL_WINDOW_FOREIGN,
SDL_WINDOW_EXTERNAL,
SDL_WINDOW_HIGH_PIXEL_DENSITY,
SDL_WINDOW_MOUSE_CAPTURE,
SDL_WINDOW_ALWAYS_ON_TOP,

View File

@ -2170,15 +2170,15 @@ int SDL_RecreateWindow(SDL_Window *window, Uint32 flags)
return SDL_ContextNotSupported("Metal");
}
if (window->flags & SDL_WINDOW_FOREIGN) {
/* Can't destroy and re-create foreign windows, hrm */
flags |= SDL_WINDOW_FOREIGN;
if (window->flags & SDL_WINDOW_EXTERNAL) {
/* Can't destroy and re-create external windows, hrm */
flags |= SDL_WINDOW_EXTERNAL;
} else {
flags &= ~SDL_WINDOW_FOREIGN;
flags &= ~SDL_WINDOW_EXTERNAL;
}
/* Restore video mode, etc. */
if (!(window->flags & SDL_WINDOW_FOREIGN)) {
if (!(window->flags & SDL_WINDOW_EXTERNAL)) {
const SDL_bool restore_on_show = window->restore_on_show;
SDL_HideWindow(window);
window->restore_on_show = restore_on_show;
@ -2223,7 +2223,7 @@ int SDL_RecreateWindow(SDL_Window *window, Uint32 flags)
SDL_Vulkan_UnloadLibrary();
}
if (_this->DestroyWindow && !(flags & SDL_WINDOW_FOREIGN)) {
if (_this->DestroyWindow && !(flags & SDL_WINDOW_EXTERNAL)) {
_this->DestroyWindow(_this, window);
}
@ -2244,7 +2244,7 @@ int SDL_RecreateWindow(SDL_Window *window, Uint32 flags)
window->flags = ((flags & CREATE_FLAGS) | SDL_WINDOW_HIDDEN);
window->is_destroying = SDL_FALSE;
if (_this->CreateSDLWindow && !(flags & SDL_WINDOW_FOREIGN)) {
if (_this->CreateSDLWindow && !(flags & SDL_WINDOW_EXTERNAL)) {
if (_this->CreateSDLWindow(_this, window, 0) < 0) {
if (loaded_opengl) {
SDL_GL_UnloadLibrary();
@ -2258,8 +2258,8 @@ int SDL_RecreateWindow(SDL_Window *window, Uint32 flags)
}
}
if (flags & SDL_WINDOW_FOREIGN) {
window->flags |= SDL_WINDOW_FOREIGN;
if (flags & SDL_WINDOW_EXTERNAL) {
window->flags |= SDL_WINDOW_EXTERNAL;
}
if (_this->SetWindowTitle && window->title) {
@ -3556,7 +3556,7 @@ void SDL_DestroyWindow(SDL_Window *window)
/* Restore video mode, etc. */
SDL_UpdateFullscreenMode(window, SDL_FALSE);
if (!(window->flags & SDL_WINDOW_FOREIGN)) {
if (!(window->flags & SDL_WINDOW_EXTERNAL)) {
SDL_HideWindow(window);
}

View File

@ -256,7 +256,7 @@ SDL_bool Cocoa_Vulkan_CreateSurface(SDL_VideoDevice *_this,
return SDL_FALSE;
}
if (window->flags & SDL_WINDOW_FOREIGN) {
if (window->flags & SDL_WINDOW_EXTERNAL) {
@autoreleasepool {
SDL_CocoaWindowData *data = (__bridge SDL_CocoaWindowData *)window->driverdata;
if (![data.sdlContentView.layer isKindOfClass:[CAMetalLayer class]]) {

View File

@ -1861,7 +1861,7 @@ static int SetupWindowData(SDL_VideoDevice *_this, SDL_Window *window, NSWindow
*/
[nswindow setOneShot:NO];
if (window->flags & SDL_WINDOW_FOREIGN) {
if (window->flags & SDL_WINDOW_EXTERNAL) {
/* Query the title from the existing window */
NSString *title = [nswindow title];
if (title) {
@ -1883,7 +1883,7 @@ int Cocoa_CreateWindow(SDL_VideoDevice *_this, SDL_Window *window, SDL_Propertie
{
@autoreleasepool {
SDL_CocoaVideoData *videodata = (__bridge SDL_CocoaVideoData *)_this->driverdata;
const void *data = SDL_GetProperty(create_props, "native.data", NULL);
const void *data = SDL_GetProperty(create_props, "sdl2-compat.external_window", NULL);
NSWindow *nswindow = nil;
NSView *nsview = nil;
@ -1896,8 +1896,8 @@ int Cocoa_CreateWindow(SDL_VideoDevice *_this, SDL_Window *window, SDL_Propertie
SDL_assert(false);
}
} else {
nswindow = (__bridge NSWindow *)SDL_GetProperty(create_props, "native.cocoa.window", NULL);
nsview = (__bridge NSView *)SDL_GetProperty(create_props, "native.cocoa.view", NULL);
nswindow = (__bridge NSWindow *)SDL_GetProperty(create_props, "cocoa.window", NULL);
nsview = (__bridge NSView *)SDL_GetProperty(create_props, "cocoa.view", NULL);
}
if (nswindow && !nsview) {
nsview = [nswindow contentView];
@ -1906,7 +1906,7 @@ int Cocoa_CreateWindow(SDL_VideoDevice *_this, SDL_Window *window, SDL_Propertie
nswindow = [nsview window];
}
if (nswindow) {
window->flags |= SDL_WINDOW_FOREIGN;
window->flags |= SDL_WINDOW_EXTERNAL;
} else {
int x, y;
NSScreen *screen;

View File

@ -347,7 +347,7 @@ static int SetupWindowData(SDL_VideoDevice *_this, SDL_Window *window, HWND hwnd
int w = rect.right;
int h = rect.bottom;
if (window->flags & SDL_WINDOW_FOREIGN) {
if (window->flags & SDL_WINDOW_EXTERNAL) {
window->windowed.w = window->w = w;
window->windowed.h = window->h = h;
} else if ((window->windowed.w && window->windowed.w != w) || (window->windowed.h && window->windowed.h != h)) {
@ -370,7 +370,7 @@ static int SetupWindowData(SDL_VideoDevice *_this, SDL_Window *window, HWND hwnd
point.x = 0;
point.y = 0;
if (ClientToScreen(hwnd, &point)) {
if (window->flags & SDL_WINDOW_FOREIGN) {
if (window->flags & SDL_WINDOW_EXTERNAL) {
window->windowed.x = point.x;
window->windowed.y = point.y;
}
@ -443,7 +443,7 @@ static int SetupWindowData(SDL_VideoDevice *_this, SDL_Window *window, HWND hwnd
data->initializing = SDL_FALSE;
if (window->flags & SDL_WINDOW_FOREIGN) {
if (window->flags & SDL_WINDOW_EXTERNAL) {
/* Query the title from the existing window */
LPTSTR title;
int titleLen;
@ -490,7 +490,7 @@ static void CleanupWindowData(SDL_VideoDevice *_this, SDL_Window *window)
ReleaseDC(data->hwnd, data->hdc);
RemoveProp(data->hwnd, TEXT("SDL_WindowData"));
#endif
if (!(window->flags & SDL_WINDOW_FOREIGN)) {
if (!(window->flags & SDL_WINDOW_EXTERNAL)) {
DestroyWindow(data->hwnd);
if (data->destroy_parent_with_window && data->parent) {
DestroyWindow(data->parent);
@ -566,10 +566,10 @@ static void WIN_SetKeyboardFocus(SDL_Window *window)
int WIN_CreateWindow(SDL_VideoDevice *_this, SDL_Window *window, SDL_PropertiesID create_props)
{
HWND hwnd = (HWND)SDL_GetProperty(create_props, "native.win32.hwnd", SDL_GetProperty(create_props, "native.data", NULL));
HWND hwnd = (HWND)SDL_GetProperty(create_props, "win32.hwnd", SDL_GetProperty(create_props, "sdl2-compat.external_window", NULL));
HWND parent = NULL;
if (hwnd) {
window->flags |= SDL_WINDOW_FOREIGN;
window->flags |= SDL_WINDOW_EXTERNAL;
if (SetupWindowData(_this, window, hwnd, parent) < 0) {
return -1;
@ -643,7 +643,7 @@ int WIN_CreateWindow(SDL_VideoDevice *_this, SDL_Window *window, SDL_PropertiesI
}
}
HWND share_hwnd = (HWND)SDL_GetProperty(create_props, "native.win32.pixel_format_hwnd", NULL);
HWND share_hwnd = (HWND)SDL_GetProperty(create_props, "win32.pixel_format_hwnd", NULL);
if (share_hwnd) {
HDC hdc = GetDC(share_hwnd);
int pixel_format = GetPixelFormat(hdc);

View File

@ -379,7 +379,7 @@ static int SetupWindowData(SDL_VideoDevice *_this, SDL_Window *window, Window w)
}
}
if (window->flags & SDL_WINDOW_FOREIGN) {
if (window->flags & SDL_WINDOW_EXTERNAL) {
/* Query the title from the existing window */
window->title = X11_GetWindowTitle(_this, w);
}
@ -427,9 +427,10 @@ static void SetWindowBordered(Display *display, int screen, Window window, SDL_b
int X11_CreateWindow(SDL_VideoDevice *_this, SDL_Window *window, SDL_PropertiesID create_props)
{
Window w = (Window)SDL_GetNumberProperty(create_props, "native.x11.window", (Window)SDL_GetProperty(create_props, "native.data", NULL));
Window w = (Window)SDL_GetNumberProperty(create_props, "x11.window",
(Window)SDL_GetProperty(create_props, "sdl2-compat.external_window", NULL));
if (w) {
window->flags |= SDL_WINDOW_FOREIGN;
window->flags |= SDL_WINDOW_EXTERNAL;
if (SetupWindowData(_this, window, w) < 0) {
return -1;
@ -1335,7 +1336,7 @@ void X11_ShowWindow(SDL_VideoDevice *_this, SDL_Window *window)
/* Blocking wait for "MapNotify" event.
* We use X11_XIfEvent because pXWindowEvent takes a mask rather than a type,
* and XCheckTypedWindowEvent doesn't block */
if (!(window->flags & SDL_WINDOW_FOREIGN)) {
if (!(window->flags & SDL_WINDOW_EXTERNAL)) {
X11_XIfEvent(display, &event, &isMapNotify, (XPointer)&data->xwindow);
}
X11_XFlush(display);
@ -1371,7 +1372,7 @@ void X11_HideWindow(SDL_VideoDevice *_this, SDL_Window *window)
if (X11_IsWindowMapped(_this, window)) {
X11_XWithdrawWindow(display, data->xwindow, displaydata->screen);
/* Blocking wait for "UnmapNotify" event */
if (!(window->flags & SDL_WINDOW_FOREIGN)) {
if (!(window->flags & SDL_WINDOW_EXTERNAL)) {
X11_XIfEvent(display, &event, &isUnmapNotify, (XPointer)&data->xwindow);
}
X11_XFlush(display);
@ -1845,7 +1846,7 @@ void X11_DestroyWindow(SDL_VideoDevice *_this, SDL_Window *window)
X11_XDestroyIC(data->ic);
}
#endif
if (!(window->flags & SDL_WINDOW_FOREIGN)) {
if (!(window->flags & SDL_WINDOW_EXTERNAL)) {
X11_XDestroyWindow(display, data->xwindow);
X11_XFlush(display);
}

View File

@ -233,7 +233,7 @@ static int video_createWindowVariousFlags(void *arg)
flags = SDL_WINDOW_MOUSE_FOCUS;
break;
case 12:
flags = SDL_WINDOW_FOREIGN;
flags = SDL_WINDOW_EXTERNAL;
break;
case 13:
flags = SDL_WINDOW_KEYBOARD_GRABBED;

View File

@ -148,7 +148,7 @@ int main(int argc, char *argv[])
quit(3);
}
props = SDL_CreateProperties();
SDL_SetProperty(props, "native.data", native_window);
SDL_SetProperty(props, "sdl2-compat.external_window", native_window);
window = SDL_CreateWindowWithProperties(props);
SDL_DestroyProperties(props);
if (!window) {