SDL_CreateWindowWithPosition() and SDL_CreateWindowFrom() have been replaced with SDL_CreateWindowWithProperties()
This is a more general interface that can be extended in the future as needed.
This commit is contained in:
@@ -69,8 +69,7 @@ SDL3_0.0.0 {
|
||||
SDL_CreateThreadWithStackSize;
|
||||
SDL_CreateWindow;
|
||||
SDL_CreateWindowAndRenderer;
|
||||
SDL_CreateWindowFrom;
|
||||
SDL_CreateWindowWithPosition;
|
||||
SDL_CreateWindowWithProperties;
|
||||
SDL_CursorVisible;
|
||||
SDL_DXGIGetOutputInfo;
|
||||
SDL_DelEventWatch;
|
||||
|
||||
@@ -93,8 +93,7 @@
|
||||
#define SDL_CreateThreadWithStackSize SDL_CreateThreadWithStackSize_REAL
|
||||
#define SDL_CreateWindow SDL_CreateWindow_REAL
|
||||
#define SDL_CreateWindowAndRenderer SDL_CreateWindowAndRenderer_REAL
|
||||
#define SDL_CreateWindowFrom SDL_CreateWindowFrom_REAL
|
||||
#define SDL_CreateWindowWithPosition SDL_CreateWindowWithPosition_REAL
|
||||
#define SDL_CreateWindowWithProperties SDL_CreateWindowWithProperties_REAL
|
||||
#define SDL_CursorVisible SDL_CursorVisible_REAL
|
||||
#define SDL_DXGIGetOutputInfo SDL_DXGIGetOutputInfo_REAL
|
||||
#define SDL_DelEventWatch SDL_DelEventWatch_REAL
|
||||
|
||||
@@ -157,8 +157,7 @@ SDL_DYNAPI_PROC(SDL_Texture*,SDL_CreateTexture,(SDL_Renderer *a, Uint32 b, int c
|
||||
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, 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,(SDL_PropertiesID a),(a),return)
|
||||
SDL_DYNAPI_PROC(SDL_Window*,SDL_CreateWindowWithPosition,(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_CreateWindowWithProperties,(SDL_PropertiesID a),(a),return)
|
||||
SDL_DYNAPI_PROC(SDL_bool,SDL_CursorVisible,(void),(),return)
|
||||
SDL_DYNAPI_PROC(void,SDL_DelEventWatch,(SDL_EventFilter a, void *b),(a,b),)
|
||||
SDL_DYNAPI_PROC(void,SDL_DelHintCallback,(const char *a, SDL_HintCallback b, void *c),(a,b,c),)
|
||||
|
||||
@@ -1347,6 +1347,7 @@ SDL_bool SDLTest_CommonInit(SDLTest_CommonState *state)
|
||||
for (i = 0; i < state->num_windows; ++i) {
|
||||
char title[1024];
|
||||
SDL_Rect r;
|
||||
SDL_PropertiesID props;
|
||||
|
||||
r.x = state->window_x;
|
||||
r.y = state->window_y;
|
||||
@@ -1369,7 +1370,15 @@ SDL_bool SDLTest_CommonInit(SDLTest_CommonState *state)
|
||||
} else {
|
||||
SDL_strlcpy(title, state->window_title, SDL_arraysize(title));
|
||||
}
|
||||
state->windows[i] = SDL_CreateWindowWithPosition(title, r.x, r.y, r.w, r.h, state->window_flags);
|
||||
props = SDL_CreateProperties();
|
||||
SDL_SetStringProperty(props, "title", title);
|
||||
SDL_SetNumberProperty(props, "x", r.x);
|
||||
SDL_SetNumberProperty(props, "y", r.y);
|
||||
SDL_SetNumberProperty(props, "width", r.w);
|
||||
SDL_SetNumberProperty(props, "height", r.h);
|
||||
SDL_SetNumberProperty(props, "flags", state->window_flags);
|
||||
state->windows[i] = SDL_CreateWindowWithProperties(props);
|
||||
SDL_DestroyProperties(props);
|
||||
if (!state->windows[i]) {
|
||||
SDL_Log("Couldn't create window: %s\n",
|
||||
SDL_GetError());
|
||||
|
||||
@@ -222,8 +222,7 @@ struct SDL_VideoDevice
|
||||
/*
|
||||
* Window functions
|
||||
*/
|
||||
int (*CreateSDLWindow)(SDL_VideoDevice *_this, SDL_Window *window);
|
||||
int (*CreateSDLWindowFrom)(SDL_VideoDevice *_this, SDL_Window *window, SDL_PropertiesID props);
|
||||
int (*CreateSDLWindow)(SDL_VideoDevice *_this, SDL_Window *window, SDL_PropertiesID create_props);
|
||||
void (*SetWindowTitle)(SDL_VideoDevice *_this, SDL_Window *window);
|
||||
int (*SetWindowIcon)(SDL_VideoDevice *_this, SDL_Window *window, SDL_Surface *icon);
|
||||
int (*SetWindowPosition)(SDL_VideoDevice *_this, SDL_Window *window);
|
||||
|
||||
@@ -1844,9 +1844,59 @@ static int SDL_DllNotSupported(const char *name)
|
||||
return SDL_SetError("No dynamic %s support in current SDL video driver (%s)", name, _this->name);
|
||||
}
|
||||
|
||||
static SDL_Window *SDL_CreateWindowInternal(const char *title, int x, int y, int w, int h, SDL_Window *parent, Uint32 flags)
|
||||
static struct {
|
||||
const char *property_name;
|
||||
Uint32 flag;
|
||||
SDL_bool invert_value;
|
||||
} SDL_WindowFlagProperties[] = {
|
||||
{ "always-on-top", SDL_WINDOW_ALWAYS_ON_TOP, SDL_FALSE },
|
||||
{ "borderless", SDL_WINDOW_BORDERLESS, SDL_FALSE },
|
||||
{ "focusable", SDL_WINDOW_NOT_FOCUSABLE, SDL_TRUE },
|
||||
{ "fullscreen", SDL_WINDOW_FULLSCREEN, SDL_FALSE },
|
||||
{ "hidden", SDL_WINDOW_HIDDEN, SDL_FALSE },
|
||||
{ "high-pixel-density", SDL_WINDOW_HIGH_PIXEL_DENSITY, SDL_FALSE },
|
||||
{ "maximized", SDL_WINDOW_MAXIMIZED, SDL_FALSE },
|
||||
{ "menu", SDL_WINDOW_POPUP_MENU, SDL_FALSE },
|
||||
{ "metal", SDL_WINDOW_METAL, SDL_FALSE },
|
||||
{ "minimized", SDL_WINDOW_MINIMIZED, SDL_FALSE },
|
||||
{ "mouse-grabbed", SDL_WINDOW_MOUSE_GRABBED, SDL_FALSE },
|
||||
{ "opengl", SDL_WINDOW_OPENGL, SDL_FALSE },
|
||||
{ "resizable", SDL_WINDOW_RESIZABLE, SDL_FALSE },
|
||||
{ "transparent", SDL_WINDOW_TRANSPARENT, SDL_FALSE },
|
||||
{ "tooltip", SDL_WINDOW_TOOLTIP, SDL_FALSE },
|
||||
{ "utility", SDL_WINDOW_UTILITY, SDL_FALSE },
|
||||
{ "vulkan", SDL_WINDOW_VULKAN, SDL_FALSE }
|
||||
};
|
||||
|
||||
static Uint32 SDL_GetWindowFlagProperties(SDL_PropertiesID props)
|
||||
{
|
||||
unsigned i;
|
||||
Uint32 flags = (Uint32)SDL_GetNumberProperty(props, "flags", 0);
|
||||
|
||||
for (i = 0; i < SDL_arraysize(SDL_WindowFlagProperties); ++i) {
|
||||
if (SDL_WindowFlagProperties[i].invert_value) {
|
||||
if (!SDL_GetBooleanProperty(props, SDL_WindowFlagProperties[i].property_name, SDL_TRUE)) {
|
||||
flags |= SDL_WindowFlagProperties[i].flag;
|
||||
}
|
||||
} else {
|
||||
if (SDL_GetBooleanProperty(props, SDL_WindowFlagProperties[i].property_name, SDL_FALSE)) {
|
||||
flags |= SDL_WindowFlagProperties[i].flag;
|
||||
}
|
||||
}
|
||||
}
|
||||
return flags;
|
||||
}
|
||||
|
||||
SDL_Window *SDL_CreateWindowWithProperties(SDL_PropertiesID props)
|
||||
{
|
||||
SDL_Window *window;
|
||||
const char *title = SDL_GetStringProperty(props, "title", NULL);
|
||||
int x = (int)SDL_GetNumberProperty(props, "x", SDL_WINDOWPOS_UNDEFINED);
|
||||
int y = (int)SDL_GetNumberProperty(props, "y", SDL_WINDOWPOS_UNDEFINED);
|
||||
int w = (int)SDL_GetNumberProperty(props, "width", 0);
|
||||
int h = (int)SDL_GetNumberProperty(props, "height", 0);
|
||||
SDL_Window *parent = SDL_GetProperty(props, "parent", NULL);
|
||||
Uint32 flags = SDL_GetWindowFlagProperties(props);
|
||||
Uint32 type_flags, graphics_flags;
|
||||
SDL_bool undefined_x = SDL_FALSE;
|
||||
SDL_bool undefined_y = SDL_FALSE;
|
||||
@@ -1863,22 +1913,32 @@ static SDL_Window *SDL_CreateWindowInternal(const char *title, int x, int y, int
|
||||
}
|
||||
}
|
||||
|
||||
/* Make sure the display list is up to date for window placement */
|
||||
if (_this->RefreshDisplays) {
|
||||
_this->RefreshDisplays(_this);
|
||||
if ((flags & (SDL_WINDOW_TOOLTIP | SDL_WINDOW_POPUP_MENU)) != 0) {
|
||||
if (!(_this->quirk_flags & VIDEO_DEVICE_QUIRK_HAS_POPUP_WINDOW_SUPPORT)) {
|
||||
SDL_Unsupported();
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* Tooltip and popup menu window must specify a parent window */
|
||||
if (!parent || parent->magic != &_this->window_magic) {
|
||||
SDL_SetError("Tooltip and popup menu windows must specify a parent window");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* Remove invalid flags */
|
||||
flags &= ~(SDL_WINDOW_MINIMIZED | SDL_WINDOW_MAXIMIZED | SDL_WINDOW_FULLSCREEN | SDL_WINDOW_BORDERLESS);
|
||||
}
|
||||
|
||||
/* ensure no more than one of these flags is set */
|
||||
/* Ensure no more than one of these flags is set */
|
||||
type_flags = flags & (SDL_WINDOW_UTILITY | SDL_WINDOW_TOOLTIP | SDL_WINDOW_POPUP_MENU);
|
||||
if (type_flags & (type_flags - 1)) {
|
||||
SDL_SetError("Conflicting window type flags specified: 0x%.8x", (unsigned int)type_flags);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* Tooltip and popup menu window must specify a parent window */
|
||||
if (!parent && ((type_flags & SDL_WINDOW_TOOLTIP) || (type_flags & SDL_WINDOW_POPUP_MENU))) {
|
||||
SDL_SetError("Tooltip and popup menu windows must specify a parent window");
|
||||
return NULL;
|
||||
/* Make sure the display list is up to date for window placement */
|
||||
if (_this->RefreshDisplays) {
|
||||
_this->RefreshDisplays(_this);
|
||||
}
|
||||
|
||||
/* Some platforms can't create zero-sized windows */
|
||||
@@ -1889,14 +1949,6 @@ static SDL_Window *SDL_CreateWindowInternal(const char *title, int x, int y, int
|
||||
h = 1;
|
||||
}
|
||||
|
||||
/* Some platforms blow up if the windows are too large. Raise it later? */
|
||||
if (w > 16384) {
|
||||
w = 16384;
|
||||
}
|
||||
if (h > 16384) {
|
||||
h = 16384;
|
||||
}
|
||||
|
||||
if (SDL_WINDOWPOS_ISUNDEFINED(x) || SDL_WINDOWPOS_ISUNDEFINED(y) ||
|
||||
SDL_WINDOWPOS_ISCENTERED(x) || SDL_WINDOWPOS_ISCENTERED(y)) {
|
||||
SDL_DisplayID displayID = 0;
|
||||
@@ -2013,7 +2065,7 @@ static SDL_Window *SDL_CreateWindowInternal(const char *title, int x, int y, int
|
||||
parent->first_child = window;
|
||||
}
|
||||
|
||||
if (_this->CreateSDLWindow && _this->CreateSDLWindow(_this, window) < 0) {
|
||||
if (_this->CreateSDLWindow && _this->CreateSDLWindow(_this, window, props) < 0) {
|
||||
SDL_DestroyWindow(window);
|
||||
return NULL;
|
||||
}
|
||||
@@ -2057,28 +2109,23 @@ static SDL_Window *SDL_CreateWindowInternal(const char *title, int x, int y, int
|
||||
|
||||
SDL_Window *SDL_CreateWindow(const char *title, int w, int h, Uint32 flags)
|
||||
{
|
||||
return SDL_CreateWindowInternal(title, SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, w , h, NULL, flags);
|
||||
}
|
||||
|
||||
SDL_Window *SDL_CreateWindowWithPosition(const char *title, int x, int y, int w, int h, Uint32 flags)
|
||||
{
|
||||
return SDL_CreateWindowInternal(title, x, y, w , h, NULL, flags);
|
||||
SDL_Window *window;
|
||||
SDL_PropertiesID props = SDL_CreateProperties();
|
||||
if (title && *title) {
|
||||
SDL_SetStringProperty(props, "title", title);
|
||||
}
|
||||
SDL_SetNumberProperty(props, "width", w);
|
||||
SDL_SetNumberProperty(props, "height", h);
|
||||
SDL_SetNumberProperty(props, "flags", flags);
|
||||
window = SDL_CreateWindowWithProperties(props);
|
||||
SDL_DestroyProperties(props);
|
||||
return window;
|
||||
}
|
||||
|
||||
SDL_Window *SDL_CreatePopupWindow(SDL_Window *parent, int offset_x, int offset_y, int w, int h, Uint32 flags)
|
||||
{
|
||||
if (!_this) {
|
||||
SDL_UninitializedVideo();
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (!(_this->quirk_flags & VIDEO_DEVICE_QUIRK_HAS_POPUP_WINDOW_SUPPORT)) {
|
||||
SDL_Unsupported();
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* Parent must be a valid window */
|
||||
CHECK_WINDOW_MAGIC(parent, NULL);
|
||||
SDL_Window *window;
|
||||
SDL_PropertiesID props = SDL_CreateProperties();
|
||||
|
||||
/* Popups must specify either the tooltip or popup menu window flags */
|
||||
if (!(flags & (SDL_WINDOW_TOOLTIP | SDL_WINDOW_POPUP_MENU))) {
|
||||
@@ -2086,81 +2133,14 @@ SDL_Window *SDL_CreatePopupWindow(SDL_Window *parent, int offset_x, int offset_y
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* Remove invalid flags */
|
||||
flags &= ~(SDL_WINDOW_MINIMIZED | SDL_WINDOW_MAXIMIZED | SDL_WINDOW_FULLSCREEN | SDL_WINDOW_BORDERLESS);
|
||||
|
||||
return SDL_CreateWindowInternal(NULL, offset_x, offset_y, w, h, parent, flags);
|
||||
}
|
||||
|
||||
SDL_Window *SDL_CreateWindowFrom(SDL_PropertiesID props)
|
||||
{
|
||||
SDL_Window *window;
|
||||
Uint32 flags = SDL_WINDOW_FOREIGN;
|
||||
|
||||
if (!props) {
|
||||
SDL_InvalidParamError("props");
|
||||
return NULL;
|
||||
}
|
||||
if (!_this) {
|
||||
SDL_UninitializedVideo();
|
||||
return NULL;
|
||||
}
|
||||
if (!_this->CreateSDLWindowFrom) {
|
||||
SDL_Unsupported();
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (SDL_GetBooleanProperty(props, "opengl", SDL_FALSE)) {
|
||||
if (!_this->GL_CreateContext) {
|
||||
SDL_ContextNotSupported("OpenGL");
|
||||
return NULL;
|
||||
}
|
||||
if (SDL_GL_LoadLibrary(NULL) < 0) {
|
||||
return NULL;
|
||||
}
|
||||
flags |= SDL_WINDOW_OPENGL;
|
||||
}
|
||||
|
||||
if (SDL_GetBooleanProperty(props, "vulkan", SDL_FALSE)) {
|
||||
if (!_this->Vulkan_CreateSurface) {
|
||||
SDL_ContextNotSupported("Vulkan");
|
||||
return NULL;
|
||||
}
|
||||
if (flags & SDL_WINDOW_OPENGL) {
|
||||
SDL_SetError("Vulkan and OpenGL not supported on same window");
|
||||
return NULL;
|
||||
}
|
||||
if (SDL_Vulkan_LoadLibrary(NULL) < 0) {
|
||||
return NULL;
|
||||
}
|
||||
flags |= SDL_WINDOW_VULKAN;
|
||||
}
|
||||
|
||||
window = (SDL_Window *)SDL_calloc(1, sizeof(*window));
|
||||
if (!window) {
|
||||
SDL_OutOfMemory();
|
||||
return NULL;
|
||||
}
|
||||
window->magic = &_this->window_magic;
|
||||
window->id = SDL_GetNextObjectID();
|
||||
window->flags = flags;
|
||||
window->is_destroying = SDL_FALSE;
|
||||
window->display_scale = 1.0f;
|
||||
window->opacity = 1.0f;
|
||||
window->next = _this->windows;
|
||||
if (_this->windows) {
|
||||
_this->windows->prev = window;
|
||||
}
|
||||
_this->windows = window;
|
||||
|
||||
if (_this->CreateSDLWindowFrom(_this, window, props) < 0) {
|
||||
SDL_DestroyWindow(window);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
window->last_displayID = SDL_GetDisplayForWindow(window);
|
||||
PrepareDragAndDropSupport(window);
|
||||
|
||||
SDL_SetProperty(props, "parent", parent);
|
||||
SDL_SetNumberProperty(props, "x", offset_x);
|
||||
SDL_SetNumberProperty(props, "y", offset_y);
|
||||
SDL_SetNumberProperty(props, "width", w);
|
||||
SDL_SetNumberProperty(props, "height", h);
|
||||
SDL_SetNumberProperty(props, "flags", flags);
|
||||
window = SDL_CreateWindowWithProperties(props);
|
||||
SDL_DestroyProperties(props);
|
||||
return window;
|
||||
}
|
||||
|
||||
@@ -2265,7 +2245,7 @@ int SDL_RecreateWindow(SDL_Window *window, Uint32 flags)
|
||||
window->is_destroying = SDL_FALSE;
|
||||
|
||||
if (_this->CreateSDLWindow && !(flags & SDL_WINDOW_FOREIGN)) {
|
||||
if (_this->CreateSDLWindow(_this, window) < 0) {
|
||||
if (_this->CreateSDLWindow(_this, window, 0) < 0) {
|
||||
if (loaded_opengl) {
|
||||
SDL_GL_UnloadLibrary();
|
||||
window->flags &= ~SDL_WINDOW_OPENGL;
|
||||
|
||||
@@ -35,7 +35,7 @@
|
||||
/* Currently only one window */
|
||||
SDL_Window *Android_Window = NULL;
|
||||
|
||||
int Android_CreateWindow(SDL_VideoDevice *_this, SDL_Window *window)
|
||||
int Android_CreateWindow(SDL_VideoDevice *_this, SDL_Window *window, SDL_PropertiesID create_props)
|
||||
{
|
||||
SDL_WindowData *data;
|
||||
int retval = 0;
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
#include "../../core/android/SDL_android.h"
|
||||
#include "../SDL_egl_c.h"
|
||||
|
||||
extern int Android_CreateWindow(SDL_VideoDevice *_this, SDL_Window *window);
|
||||
extern int Android_CreateWindow(SDL_VideoDevice *_this, SDL_Window *window, SDL_PropertiesID create_props);
|
||||
extern void Android_SetWindowTitle(SDL_VideoDevice *_this, SDL_Window *window);
|
||||
extern void Android_SetWindowFullscreen(SDL_VideoDevice *_this, SDL_Window *window, SDL_VideoDisplay *display, SDL_bool fullscreen);
|
||||
extern void Android_MinimizeWindow(SDL_VideoDevice *_this, SDL_Window *window);
|
||||
|
||||
@@ -90,7 +90,6 @@ static SDL_VideoDevice *Cocoa_CreateDevice(void)
|
||||
device->SuspendScreenSaver = Cocoa_SuspendScreenSaver;
|
||||
|
||||
device->CreateSDLWindow = Cocoa_CreateWindow;
|
||||
device->CreateSDLWindowFrom = Cocoa_CreateWindowFrom;
|
||||
device->SetWindowTitle = Cocoa_SetWindowTitle;
|
||||
device->SetWindowIcon = Cocoa_SetWindowIcon;
|
||||
device->SetWindowPosition = Cocoa_SetWindowPosition;
|
||||
|
||||
@@ -141,8 +141,7 @@ typedef enum
|
||||
#endif
|
||||
@end
|
||||
|
||||
extern int Cocoa_CreateWindow(SDL_VideoDevice *_this, SDL_Window *window);
|
||||
extern int Cocoa_CreateWindowFrom(SDL_VideoDevice *_this, SDL_Window *window, SDL_PropertiesID props);
|
||||
extern int Cocoa_CreateWindow(SDL_VideoDevice *_this, SDL_Window *window, SDL_PropertiesID create_props);
|
||||
extern void Cocoa_SetWindowTitle(SDL_VideoDevice *_this, SDL_Window *window);
|
||||
extern int Cocoa_SetWindowIcon(SDL_VideoDevice *_this, SDL_Window *window, SDL_Surface *icon);
|
||||
extern int Cocoa_SetWindowPosition(SDL_VideoDevice *_this, SDL_Window *window);
|
||||
|
||||
@@ -1752,7 +1752,7 @@ static int Cocoa_SendMouseButtonClicks(SDL_Mouse *mouse, NSEvent *theEvent, SDL_
|
||||
|
||||
@end
|
||||
|
||||
static int SetupWindowData(SDL_VideoDevice *_this, SDL_Window *window, NSWindow *nswindow, NSView *nsview, SDL_bool created)
|
||||
static int SetupWindowData(SDL_VideoDevice *_this, SDL_Window *window, NSWindow *nswindow, NSView *nsview)
|
||||
{
|
||||
@autoreleasepool {
|
||||
SDL_CocoaVideoData *videodata = (__bridge SDL_CocoaVideoData *)_this->driverdata;
|
||||
@@ -1765,7 +1765,6 @@ static int SetupWindowData(SDL_VideoDevice *_this, SDL_Window *window, NSWindow
|
||||
}
|
||||
data.window = window;
|
||||
data.nswindow = nswindow;
|
||||
data.created = created;
|
||||
data.videodata = videodata;
|
||||
data.window_number = nswindow.windowNumber;
|
||||
data.nscontexts = [[NSMutableArray alloc] init];
|
||||
@@ -1862,6 +1861,14 @@ static int SetupWindowData(SDL_VideoDevice *_this, SDL_Window *window, NSWindow
|
||||
*/
|
||||
[nswindow setOneShot:NO];
|
||||
|
||||
if (window->flags & SDL_WINDOW_FOREIGN) {
|
||||
/* Query the title from the existing window */
|
||||
NSString *title = [nswindow title];
|
||||
if (title) {
|
||||
window->title = SDL_strdup([title UTF8String]);
|
||||
}
|
||||
}
|
||||
|
||||
SDL_PropertiesID props = SDL_GetWindowProperties(window);
|
||||
SDL_SetProperty(props, "SDL.window.cocoa.window", (__bridge void *)data.nswindow);
|
||||
SDL_SetNumberProperty(props, "SDL.window.cocoa.metal_view_tag", SDL_METALVIEW_TAG);
|
||||
@@ -1872,69 +1879,99 @@ static int SetupWindowData(SDL_VideoDevice *_this, SDL_Window *window, NSWindow
|
||||
}
|
||||
}
|
||||
|
||||
int Cocoa_CreateWindow(SDL_VideoDevice *_this, SDL_Window *window)
|
||||
int Cocoa_CreateWindow(SDL_VideoDevice *_this, SDL_Window *window, SDL_PropertiesID create_props)
|
||||
{
|
||||
@autoreleasepool {
|
||||
SDL_CocoaVideoData *videodata = (__bridge SDL_CocoaVideoData *)_this->driverdata;
|
||||
NSWindow *nswindow;
|
||||
int x, y;
|
||||
NSScreen *screen;
|
||||
NSRect rect, screenRect;
|
||||
BOOL fullscreen;
|
||||
NSUInteger style;
|
||||
SDLView *contentView;
|
||||
BOOL highdpi;
|
||||
const void *data = SDL_GetProperty(create_props, "native.data", NULL);
|
||||
NSWindow *nswindow = nil;
|
||||
NSView *nsview = nil;
|
||||
|
||||
SDL_RelativeToGlobalForWindow(window, window->x, window->y, &x, &y);
|
||||
rect.origin.x = x;
|
||||
rect.origin.y = y;
|
||||
rect.size.width = window->w;
|
||||
rect.size.height = window->h;
|
||||
fullscreen = (window->flags & SDL_WINDOW_FULLSCREEN) ? YES : NO;
|
||||
ConvertNSRect(fullscreen, &rect);
|
||||
|
||||
style = GetWindowStyle(window);
|
||||
|
||||
/* Figure out which screen to place this window */
|
||||
screen = ScreenForRect(&rect);
|
||||
screenRect = [screen frame];
|
||||
rect.origin.x -= screenRect.origin.x;
|
||||
rect.origin.y -= screenRect.origin.y;
|
||||
|
||||
/* Constrain the popup */
|
||||
if (SDL_WINDOW_IS_POPUP(window)) {
|
||||
if (rect.origin.x + rect.size.width > screenRect.origin.x + screenRect.size.width) {
|
||||
rect.origin.x -= (rect.origin.x + rect.size.width) - (screenRect.origin.x + screenRect.size.width);
|
||||
if (data) {
|
||||
if ([(__bridge id)data isKindOfClass:[NSWindow class]]) {
|
||||
nswindow = (__bridge NSWindow *)data;
|
||||
} else if ([(__bridge id)data isKindOfClass:[NSView class]]) {
|
||||
nsview = (__bridge NSView *)data;
|
||||
} else {
|
||||
SDL_assert(false);
|
||||
}
|
||||
if (rect.origin.y + rect.size.height > screenRect.origin.y + screenRect.size.height) {
|
||||
rect.origin.y -= (rect.origin.y + rect.size.height) - (screenRect.origin.y + screenRect.size.height);
|
||||
} else {
|
||||
nswindow = (__bridge NSWindow *)SDL_GetProperty(create_props, "native.cocoa.window", NULL);
|
||||
nsview = (__bridge NSView *)SDL_GetProperty(create_props, "native.cocoa.view", NULL);
|
||||
}
|
||||
if (nswindow && !nsview) {
|
||||
nsview = [nswindow contentView];
|
||||
}
|
||||
if (nsview && !nswindow) {
|
||||
nswindow = [nsview window];
|
||||
}
|
||||
if (nswindow) {
|
||||
window->flags |= SDL_WINDOW_FOREIGN;
|
||||
} else {
|
||||
int x, y;
|
||||
NSScreen *screen;
|
||||
NSRect rect, screenRect;
|
||||
BOOL fullscreen;
|
||||
NSUInteger style;
|
||||
SDLView *contentView;
|
||||
|
||||
SDL_RelativeToGlobalForWindow(window, window->x, window->y, &x, &y);
|
||||
rect.origin.x = x;
|
||||
rect.origin.y = y;
|
||||
rect.size.width = window->w;
|
||||
rect.size.height = window->h;
|
||||
fullscreen = (window->flags & SDL_WINDOW_FULLSCREEN) ? YES : NO;
|
||||
ConvertNSRect(fullscreen, &rect);
|
||||
|
||||
style = GetWindowStyle(window);
|
||||
|
||||
/* Figure out which screen to place this window */
|
||||
screen = ScreenForRect(&rect);
|
||||
screenRect = [screen frame];
|
||||
rect.origin.x -= screenRect.origin.x;
|
||||
rect.origin.y -= screenRect.origin.y;
|
||||
|
||||
/* Constrain the popup */
|
||||
if (SDL_WINDOW_IS_POPUP(window)) {
|
||||
if (rect.origin.x + rect.size.width > screenRect.origin.x + screenRect.size.width) {
|
||||
rect.origin.x -= (rect.origin.x + rect.size.width) - (screenRect.origin.x + screenRect.size.width);
|
||||
}
|
||||
if (rect.origin.y + rect.size.height > screenRect.origin.y + screenRect.size.height) {
|
||||
rect.origin.y -= (rect.origin.y + rect.size.height) - (screenRect.origin.y + screenRect.size.height);
|
||||
}
|
||||
rect.origin.x = SDL_max(rect.origin.x, screenRect.origin.x);
|
||||
rect.origin.y = SDL_max(rect.origin.y, screenRect.origin.y);
|
||||
}
|
||||
rect.origin.x = SDL_max(rect.origin.x, screenRect.origin.x);
|
||||
rect.origin.y = SDL_max(rect.origin.y, screenRect.origin.y);
|
||||
}
|
||||
|
||||
@try {
|
||||
nswindow = [[SDLWindow alloc] initWithContentRect:rect styleMask:style backing:NSBackingStoreBuffered defer:NO screen:screen];
|
||||
}
|
||||
@catch (NSException *e) {
|
||||
return SDL_SetError("%s", [[e reason] UTF8String]);
|
||||
}
|
||||
@try {
|
||||
nswindow = [[SDLWindow alloc] initWithContentRect:rect styleMask:style backing:NSBackingStoreBuffered defer:NO screen:screen];
|
||||
}
|
||||
@catch (NSException *e) {
|
||||
return SDL_SetError("%s", [[e reason] UTF8String]);
|
||||
}
|
||||
|
||||
[nswindow setColorSpace:[NSColorSpace sRGBColorSpace]];
|
||||
[nswindow setColorSpace:[NSColorSpace sRGBColorSpace]];
|
||||
|
||||
#if MAC_OS_X_VERSION_MAX_ALLOWED >= 101200 /* Added in the 10.12.0 SDK. */
|
||||
/* By default, don't allow users to make our window tabbed in 10.12 or later */
|
||||
if ([nswindow respondsToSelector:@selector(setTabbingMode:)]) {
|
||||
[nswindow setTabbingMode:NSWindowTabbingModeDisallowed];
|
||||
}
|
||||
/* By default, don't allow users to make our window tabbed in 10.12 or later */
|
||||
if ([nswindow respondsToSelector:@selector(setTabbingMode:)]) {
|
||||
[nswindow setTabbingMode:NSWindowTabbingModeDisallowed];
|
||||
}
|
||||
#endif
|
||||
|
||||
if (videodata.allow_spaces) {
|
||||
/* we put fullscreen desktop windows in their own Space, without a toggle button or menubar, later */
|
||||
if (window->flags & SDL_WINDOW_RESIZABLE) {
|
||||
/* resizable windows are Spaces-friendly: they get the "go fullscreen" toggle button on their titlebar. */
|
||||
[nswindow setCollectionBehavior:NSWindowCollectionBehaviorFullScreenPrimary];
|
||||
if (videodata.allow_spaces) {
|
||||
/* we put fullscreen desktop windows in their own Space, without a toggle button or menubar, later */
|
||||
if (window->flags & SDL_WINDOW_RESIZABLE) {
|
||||
/* resizable windows are Spaces-friendly: they get the "go fullscreen" toggle button on their titlebar. */
|
||||
[nswindow setCollectionBehavior:NSWindowCollectionBehaviorFullScreenPrimary];
|
||||
}
|
||||
}
|
||||
|
||||
/* Create a default view for this window */
|
||||
rect = [nswindow contentRectForFrameRect:[nswindow frame]];
|
||||
contentView = [[SDLView alloc] initWithFrame:rect];
|
||||
[contentView setSDLWindow:window];
|
||||
nsview = contentView;
|
||||
}
|
||||
|
||||
if (window->flags & SDL_WINDOW_ALWAYS_ON_TOP) {
|
||||
@@ -1947,11 +1984,6 @@ int Cocoa_CreateWindow(SDL_VideoDevice *_this, SDL_Window *window)
|
||||
nswindow.backgroundColor = [NSColor clearColor];
|
||||
}
|
||||
|
||||
/* Create a default view for this window */
|
||||
rect = [nswindow contentRectForFrameRect:[nswindow frame]];
|
||||
contentView = [[SDLView alloc] initWithFrame:rect];
|
||||
[contentView setSDLWindow:window];
|
||||
|
||||
/* We still support OpenGL as long as Apple offers it, deprecated or not, so disable deprecation warnings about it. */
|
||||
#ifdef __clang__
|
||||
#pragma clang diagnostic push
|
||||
@@ -1959,8 +1991,8 @@ int Cocoa_CreateWindow(SDL_VideoDevice *_this, SDL_Window *window)
|
||||
#endif
|
||||
/* Note: as of the macOS 10.15 SDK, this defaults to YES instead of NO when
|
||||
* the NSHighResolutionCapable boolean is set in Info.plist. */
|
||||
highdpi = (window->flags & SDL_WINDOW_HIGH_PIXEL_DENSITY) ? YES : NO;
|
||||
[contentView setWantsBestResolutionOpenGLSurface:highdpi];
|
||||
BOOL highdpi = (window->flags & SDL_WINDOW_HIGH_PIXEL_DENSITY) ? YES : NO;
|
||||
[nsview setWantsBestResolutionOpenGLSurface:highdpi];
|
||||
#ifdef __clang__
|
||||
#pragma clang diagnostic pop
|
||||
#endif
|
||||
@@ -1969,19 +2001,19 @@ int Cocoa_CreateWindow(SDL_VideoDevice *_this, SDL_Window *window)
|
||||
#ifdef SDL_VIDEO_OPENGL_EGL
|
||||
if ((window->flags & SDL_WINDOW_OPENGL) &&
|
||||
_this->gl_config.profile_mask == SDL_GL_CONTEXT_PROFILE_ES) {
|
||||
[contentView setWantsLayer:TRUE];
|
||||
[nsview setWantsLayer:TRUE];
|
||||
if ((window->flags & SDL_WINDOW_HIGH_PIXEL_DENSITY) &&
|
||||
[nswindow.screen respondsToSelector:@selector(backingScaleFactor)]) {
|
||||
contentView.layer.contentsScale = nswindow.screen.backingScaleFactor;
|
||||
nsview.layer.contentsScale = nswindow.screen.backingScaleFactor;
|
||||
} else {
|
||||
contentView.layer.contentsScale = 1;
|
||||
nsview.layer.contentsScale = 1;
|
||||
}
|
||||
}
|
||||
#endif /* SDL_VIDEO_OPENGL_EGL */
|
||||
#endif /* SDL_VIDEO_OPENGL_ES2 */
|
||||
[nswindow setContentView:contentView];
|
||||
[nswindow setContentView:nsview];
|
||||
|
||||
if (SetupWindowData(_this, window, nswindow, contentView, SDL_TRUE) < 0) {
|
||||
if (SetupWindowData(_this, window, nswindow, nsview) < 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -2007,60 +2039,6 @@ int Cocoa_CreateWindow(SDL_VideoDevice *_this, SDL_Window *window)
|
||||
}
|
||||
}
|
||||
|
||||
int Cocoa_CreateWindowFrom(SDL_VideoDevice *_this, SDL_Window *window, SDL_PropertiesID props)
|
||||
{
|
||||
@autoreleasepool {
|
||||
const void *data = SDL_GetProperty(props, "data", NULL);
|
||||
NSWindow *nswindow = nil;
|
||||
NSView *nsview = nil;
|
||||
NSString *title;
|
||||
BOOL highdpi;
|
||||
|
||||
if (data) {
|
||||
if ([(__bridge id)data isKindOfClass:[NSWindow class]]) {
|
||||
nswindow = (__bridge NSWindow *)data;
|
||||
} else if ([(__bridge id)data isKindOfClass:[NSView class]]) {
|
||||
nsview = (__bridge NSView *)data;
|
||||
} else {
|
||||
SDL_assert(false);
|
||||
}
|
||||
} else {
|
||||
nswindow = (__bridge NSWindow *)SDL_GetProperty(props, "cocoa.window", NULL);
|
||||
nsview = (__bridge NSView *)SDL_GetProperty(props, "cocoa.view", NULL);
|
||||
}
|
||||
if (nswindow && !nsview) {
|
||||
nsview = [nswindow contentView];
|
||||
}
|
||||
if (nsview && !nswindow) {
|
||||
nswindow = [nsview window];
|
||||
}
|
||||
if (!nswindow) {
|
||||
return SDL_SetError("Couldn't find property cocoa.window");
|
||||
}
|
||||
|
||||
/* Query the title from the existing window */
|
||||
title = [nswindow title];
|
||||
if (title) {
|
||||
window->title = SDL_strdup([title UTF8String]);
|
||||
}
|
||||
|
||||
/* We still support OpenGL as long as Apple offers it, deprecated or not, so disable deprecation warnings about it. */
|
||||
#ifdef __clang__
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
|
||||
#endif
|
||||
/* Note: as of the macOS 10.15 SDK, this defaults to YES instead of NO when
|
||||
* the NSHighResolutionCapable boolean is set in Info.plist. */
|
||||
highdpi = (window->flags & SDL_WINDOW_HIGH_PIXEL_DENSITY) ? YES : NO;
|
||||
[nsview setWantsBestResolutionOpenGLSurface:highdpi];
|
||||
#ifdef __clang__
|
||||
#pragma clang diagnostic pop
|
||||
#endif
|
||||
|
||||
return SetupWindowData(_this, window, nswindow, nsview, SDL_FALSE);
|
||||
}
|
||||
}
|
||||
|
||||
void Cocoa_SetWindowTitle(SDL_VideoDevice *_this, SDL_Window *window)
|
||||
{
|
||||
@autoreleasepool {
|
||||
|
||||
@@ -40,7 +40,7 @@ static int Emscripten_SetDisplayMode(SDL_VideoDevice *_this, SDL_VideoDisplay *d
|
||||
static void Emscripten_VideoQuit(SDL_VideoDevice *_this);
|
||||
static int Emscripten_GetDisplayUsableBounds(SDL_VideoDevice *_this, SDL_VideoDisplay *display, SDL_Rect *rect);
|
||||
|
||||
static int Emscripten_CreateWindow(SDL_VideoDevice *_this, SDL_Window *window);
|
||||
static int Emscripten_CreateWindow(SDL_VideoDevice *_this, SDL_Window *window, SDL_PropertiesID create_props);
|
||||
static void Emscripten_SetWindowSize(SDL_VideoDevice *_this, SDL_Window *window);
|
||||
static void Emscripten_GetWindowSizeInPixels(SDL_VideoDevice *_this, SDL_Window *window, int *w, int *h);
|
||||
static void Emscripten_DestroyWindow(SDL_VideoDevice *_this, SDL_Window *window);
|
||||
@@ -171,7 +171,7 @@ static void Emscripten_PumpEvents(SDL_VideoDevice *_this)
|
||||
/* do nothing. */
|
||||
}
|
||||
|
||||
static int Emscripten_CreateWindow(SDL_VideoDevice *_this, SDL_Window *window)
|
||||
static int Emscripten_CreateWindow(SDL_VideoDevice *_this, SDL_Window *window, SDL_PropertiesID props)
|
||||
{
|
||||
SDL_WindowData *wdata;
|
||||
double scaled_w, scaled_h;
|
||||
|
||||
@@ -76,7 +76,7 @@ static int _InitWindow(SDL_VideoDevice *_this, SDL_Window *window) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int HAIKU_CreateWindow(SDL_VideoDevice *_this, SDL_Window *window) {
|
||||
int HAIKU_CreateWindow(SDL_VideoDevice *_this, SDL_Window *window, SDL_PropertiesID create_props) {
|
||||
if (_InitWindow(_this, window) < 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
|
||||
#include "../SDL_sysvideo.h"
|
||||
|
||||
extern int HAIKU_CreateWindow(SDL_VideoDevice *_this, SDL_Window *window);
|
||||
extern int HAIKU_CreateWindow(SDL_VideoDevice *_this, SDL_Window *window, SDL_PropertiesID create_props);
|
||||
extern void HAIKU_SetWindowTitle(SDL_VideoDevice *_this, SDL_Window *window);
|
||||
extern int HAIKU_SetWindowPosition(SDL_VideoDevice *_this, SDL_Window *window);
|
||||
extern void HAIKU_SetWindowSize(SDL_VideoDevice *_this, SDL_Window *window);
|
||||
|
||||
@@ -1443,7 +1443,7 @@ void KMSDRM_DestroyWindow(SDL_VideoDevice *_this, SDL_Window *window)
|
||||
/* reflect it: if it's fullscreen, KMSDRM_SetWindwoFullscreen() will */
|
||||
/* be called by SDL later, and we can manage it there. */
|
||||
/**********************************************************************/
|
||||
int KMSDRM_CreateWindow(SDL_VideoDevice *_this, SDL_Window *window)
|
||||
int KMSDRM_CreateWindow(SDL_VideoDevice *_this, SDL_Window *window, SDL_PropertiesID create_props)
|
||||
{
|
||||
SDL_WindowData *windata = NULL;
|
||||
SDL_VideoData *viddata = _this->driverdata;
|
||||
|
||||
@@ -121,7 +121,7 @@ int KMSDRM_VideoInit(SDL_VideoDevice *_this);
|
||||
void KMSDRM_VideoQuit(SDL_VideoDevice *_this);
|
||||
int KMSDRM_GetDisplayModes(SDL_VideoDevice *_this, SDL_VideoDisplay *display);
|
||||
int KMSDRM_SetDisplayMode(SDL_VideoDevice *_this, SDL_VideoDisplay *display, SDL_DisplayMode *mode);
|
||||
int KMSDRM_CreateWindow(SDL_VideoDevice *_this, SDL_Window *window);
|
||||
int KMSDRM_CreateWindow(SDL_VideoDevice *_this, SDL_Window *window, SDL_PropertiesID create_props);
|
||||
void KMSDRM_SetWindowTitle(SDL_VideoDevice *_this, SDL_Window *window);
|
||||
int KMSDRM_SetWindowPosition(SDL_VideoDevice *_this, SDL_Window *window);
|
||||
void KMSDRM_SetWindowSize(SDL_VideoDevice *_this, SDL_Window *window);
|
||||
|
||||
@@ -36,7 +36,7 @@ static int AddN3DSDisplay(gfxScreen_t screen);
|
||||
static int N3DS_VideoInit(SDL_VideoDevice *_this);
|
||||
static void N3DS_VideoQuit(SDL_VideoDevice *_this);
|
||||
static int N3DS_GetDisplayBounds(SDL_VideoDevice *_this, SDL_VideoDisplay *display, SDL_Rect *rect);
|
||||
static int N3DS_CreateWindow(SDL_VideoDevice *_this, SDL_Window *window);
|
||||
static int N3DS_CreateWindow(SDL_VideoDevice *_this, SDL_Window *window, SDL_PropertiesID create_props);
|
||||
static void N3DS_DestroyWindow(SDL_VideoDevice *_this, SDL_Window *window);
|
||||
|
||||
struct SDL_DisplayData
|
||||
@@ -150,7 +150,7 @@ static int N3DS_GetDisplayBounds(SDL_VideoDevice *_this, SDL_VideoDisplay *displ
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int N3DS_CreateWindow(SDL_VideoDevice *_this, SDL_Window *window)
|
||||
static int N3DS_CreateWindow(SDL_VideoDevice *_this, SDL_Window *window, SDL_PropertiesID create_props)
|
||||
{
|
||||
SDL_DisplayData *display_data;
|
||||
SDL_WindowData *window_data = (SDL_WindowData *)SDL_calloc(1, sizeof(SDL_WindowData));
|
||||
|
||||
@@ -32,7 +32,7 @@ const TUint32 WindowClientHandle = 9210;
|
||||
void DisableKeyBlocking(SDL_VideoDevice *_this);
|
||||
void ConstructWindowL(SDL_VideoDevice *_this);
|
||||
|
||||
int NGAGE_CreateWindow(SDL_VideoDevice *_this, SDL_Window *window)
|
||||
int NGAGE_CreateWindow(SDL_VideoDevice *_this, SDL_Window *window, SDL_PropertiesID create_props)
|
||||
{
|
||||
NGAGE_Window *ngage_window = (NGAGE_Window *)SDL_calloc(1, sizeof(NGAGE_Window));
|
||||
|
||||
|
||||
@@ -32,7 +32,7 @@ typedef struct
|
||||
|
||||
} NGAGE_Window;
|
||||
|
||||
extern int NGAGE_CreateWindow(SDL_VideoDevice *_this, SDL_Window *window);
|
||||
extern int NGAGE_CreateWindow(SDL_VideoDevice *_this, SDL_Window *window, SDL_PropertiesID create_props);
|
||||
extern void NGAGE_DestroyWindow(SDL_VideoDevice *_this, SDL_Window *window);
|
||||
|
||||
#endif /* SDL_ngagewindow */
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
|
||||
#include "SDL_offscreenwindow.h"
|
||||
|
||||
int OFFSCREEN_CreateWindow(SDL_VideoDevice *_this, SDL_Window *window)
|
||||
int OFFSCREEN_CreateWindow(SDL_VideoDevice *_this, SDL_Window *window, SDL_PropertiesID create_props)
|
||||
{
|
||||
SDL_WindowData *offscreen_window = (SDL_WindowData *)SDL_calloc(1, sizeof(SDL_WindowData));
|
||||
|
||||
|
||||
@@ -33,7 +33,7 @@ struct SDL_WindowData
|
||||
#endif
|
||||
};
|
||||
|
||||
extern int OFFSCREEN_CreateWindow(SDL_VideoDevice *_this, SDL_Window *window);
|
||||
extern int OFFSCREEN_CreateWindow(SDL_VideoDevice *_this, SDL_Window *window, SDL_PropertiesID create_props);
|
||||
extern void OFFSCREEN_DestroyWindow(SDL_VideoDevice *_this, SDL_Window *window);
|
||||
|
||||
#endif /* SDL_offscreenwindow_h */
|
||||
|
||||
@@ -55,7 +55,7 @@ static void PS2_DeleteDevice(SDL_VideoDevice *device)
|
||||
SDL_free(device);
|
||||
}
|
||||
|
||||
static int PS2_CreateWindow(SDL_VideoDevice *_this, SDL_Window *window)
|
||||
static int PS2_CreateWindow(SDL_VideoDevice *_this, SDL_Window *window, SDL_PropertiesID create_props)
|
||||
{
|
||||
SDL_SetKeyboardFocus(window);
|
||||
|
||||
|
||||
@@ -185,7 +185,7 @@ int PSP_SetDisplayMode(SDL_VideoDevice *_this, SDL_VideoDisplay *display, SDL_Di
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
int PSP_CreateWindow(SDL_VideoDevice *_this, SDL_Window *window)
|
||||
int PSP_CreateWindow(SDL_VideoDevice *_this, SDL_Window *window, SDL_PropertiesID create_props)
|
||||
{
|
||||
SDL_WindowData *wdata;
|
||||
|
||||
|
||||
@@ -49,7 +49,7 @@ int PSP_VideoInit(SDL_VideoDevice *_this);
|
||||
void PSP_VideoQuit(SDL_VideoDevice *_this);
|
||||
int PSP_GetDisplayModes(SDL_VideoDevice *_this, SDL_VideoDisplay *display);
|
||||
int PSP_SetDisplayMode(SDL_VideoDevice *_this, SDL_VideoDisplay *display, SDL_DisplayMode *mode);
|
||||
int PSP_CreateWindow(SDL_VideoDevice *_this, SDL_Window *window);
|
||||
int PSP_CreateWindow(SDL_VideoDevice *_this, SDL_Window *window, SDL_PropertiesID create_props);
|
||||
void PSP_SetWindowTitle(SDL_VideoDevice *_this, SDL_Window *window);
|
||||
int PSP_SetWindowPosition(SDL_VideoDevice *_this, SDL_Window *window);
|
||||
void PSP_SetWindowSize(SDL_VideoDevice *_this, SDL_Window *window);
|
||||
|
||||
@@ -216,7 +216,7 @@ static void RPI_vsync_callback(DISPMANX_UPDATE_HANDLE_T u, void *data)
|
||||
SDL_UnlockMutex(wdata->vsync_cond_mutex);
|
||||
}
|
||||
|
||||
int RPI_CreateWindow(SDL_VideoDevice *_this, SDL_Window *window)
|
||||
int RPI_CreateWindow(SDL_VideoDevice *_this, SDL_Window *window, SDL_PropertiesID create_props)
|
||||
{
|
||||
SDL_WindowData *wdata;
|
||||
SDL_VideoDisplay *display;
|
||||
|
||||
@@ -63,7 +63,7 @@ int RPI_VideoInit(SDL_VideoDevice *_this);
|
||||
void RPI_VideoQuit(SDL_VideoDevice *_this);
|
||||
int RPI_GetDisplayModes(SDL_VideoDevice *_this, SDL_VideoDisplay *display);
|
||||
int RPI_SetDisplayMode(SDL_VideoDevice *_this, SDL_VideoDisplay *display, SDL_DisplayMode *mode);
|
||||
int RPI_CreateWindow(SDL_VideoDevice *_this, SDL_Window *window);
|
||||
int RPI_CreateWindow(SDL_VideoDevice *_this, SDL_Window *window, SDL_PropertiesID create_props);
|
||||
void RPI_SetWindowTitle(SDL_VideoDevice *_this, SDL_Window *window);
|
||||
int RPI_SetWindowPosition(SDL_VideoDevice *_this, SDL_Window *window);
|
||||
void RPI_SetWindowSize(SDL_VideoDevice *_this, SDL_Window *window);
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
#include "SDL_riscosvideo.h"
|
||||
#include "SDL_riscoswindow.h"
|
||||
|
||||
int RISCOS_CreateWindow(SDL_VideoDevice *_this, SDL_Window *window)
|
||||
int RISCOS_CreateWindow(SDL_VideoDevice *_this, SDL_Window *window, SDL_PropertiesID create_props)
|
||||
{
|
||||
SDL_WindowData *driverdata;
|
||||
|
||||
|
||||
@@ -32,7 +32,7 @@ struct SDL_WindowData
|
||||
sprite_header *fb_sprite;
|
||||
};
|
||||
|
||||
extern int RISCOS_CreateWindow(SDL_VideoDevice *_this, SDL_Window *window);
|
||||
extern int RISCOS_CreateWindow(SDL_VideoDevice *_this, SDL_Window *window, SDL_PropertiesID create_props);
|
||||
extern void RISCOS_DestroyWindow(SDL_VideoDevice *_this, SDL_Window *window);
|
||||
|
||||
#endif /* SDL_riscoswindow_h_ */
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
#import "SDL_uikitview.h"
|
||||
#import "SDL_uikitviewcontroller.h"
|
||||
|
||||
extern int UIKit_CreateWindow(SDL_VideoDevice *_this, SDL_Window *window);
|
||||
extern int UIKit_CreateWindow(SDL_VideoDevice *_this, SDL_Window *window, SDL_PropertiesID create_props);
|
||||
extern void UIKit_SetWindowTitle(SDL_VideoDevice *_this, SDL_Window *window);
|
||||
extern void UIKit_ShowWindow(SDL_VideoDevice *_this, SDL_Window *window);
|
||||
extern void UIKit_HideWindow(SDL_VideoDevice *_this, SDL_Window *window);
|
||||
|
||||
@@ -160,7 +160,7 @@ static int SetupWindowData(SDL_VideoDevice *_this, SDL_Window *window, UIWindow
|
||||
return 0;
|
||||
}
|
||||
|
||||
int UIKit_CreateWindow(SDL_VideoDevice *_this, SDL_Window *window)
|
||||
int UIKit_CreateWindow(SDL_VideoDevice *_this, SDL_Window *window, SDL_PropertiesID create_props)
|
||||
{
|
||||
@autoreleasepool {
|
||||
SDL_VideoDisplay *display = SDL_GetVideoDisplayForWindow(window);
|
||||
|
||||
@@ -218,7 +218,7 @@ void VITA_VideoQuit(SDL_VideoDevice *_this)
|
||||
VITA_QuitTouch();
|
||||
}
|
||||
|
||||
int VITA_CreateWindow(SDL_VideoDevice *_this, SDL_Window *window)
|
||||
int VITA_CreateWindow(SDL_VideoDevice *_this, SDL_Window *window, SDL_PropertiesID create_props)
|
||||
{
|
||||
SDL_WindowData *wdata;
|
||||
#ifdef SDL_VIDEO_VITA_PVR
|
||||
|
||||
@@ -62,7 +62,7 @@ int VITA_VideoInit(SDL_VideoDevice *_this);
|
||||
void VITA_VideoQuit(SDL_VideoDevice *_this);
|
||||
int VITA_GetDisplayModes(SDL_VideoDevice *_this, SDL_VideoDisplay *display);
|
||||
int VITA_SetDisplayMode(SDL_VideoDevice *_this, SDL_VideoDisplay *display, SDL_DisplayMode *mode);
|
||||
int VITA_CreateWindow(SDL_VideoDevice *_this, SDL_Window *window);
|
||||
int VITA_CreateWindow(SDL_VideoDevice *_this, SDL_Window *window, SDL_PropertiesID create_props);
|
||||
void VITA_SetWindowTitle(SDL_VideoDevice *_this, SDL_Window *window);
|
||||
int VITA_SetWindowPosition(SDL_VideoDevice *_this, SDL_Window *window);
|
||||
void VITA_SetWindowSize(SDL_VideoDevice *_this, SDL_Window *window);
|
||||
|
||||
@@ -238,7 +238,7 @@ void VIVANTE_VideoQuit(SDL_VideoDevice *_this)
|
||||
#endif
|
||||
}
|
||||
|
||||
int VIVANTE_CreateWindow(SDL_VideoDevice *_this, SDL_Window *window)
|
||||
int VIVANTE_CreateWindow(SDL_VideoDevice *_this, SDL_Window *window, SDL_PropertiesID create_props)
|
||||
{
|
||||
SDL_VideoData *videodata = _this->driverdata;
|
||||
SDL_DisplayData *displaydata;
|
||||
|
||||
@@ -72,7 +72,7 @@ int VIVANTE_VideoInit(SDL_VideoDevice *_this);
|
||||
void VIVANTE_VideoQuit(SDL_VideoDevice *_this);
|
||||
int VIVANTE_GetDisplayModes(SDL_VideoDevice *_this, SDL_VideoDisplay *display);
|
||||
int VIVANTE_SetDisplayMode(SDL_VideoDevice *_this, SDL_VideoDisplay *display, SDL_DisplayMode *mode);
|
||||
int VIVANTE_CreateWindow(SDL_VideoDevice *_this, SDL_Window *window);
|
||||
int VIVANTE_CreateWindow(SDL_VideoDevice *_this, SDL_Window *window, SDL_PropertiesID create_props);
|
||||
void VIVANTE_SetWindowTitle(SDL_VideoDevice *_this, SDL_Window *window);
|
||||
int VIVANTE_SetWindowPosition(SDL_VideoDevice *_this, SDL_Window *window);
|
||||
void VIVANTE_SetWindowSize(SDL_VideoDevice *_this, SDL_Window *window);
|
||||
|
||||
@@ -1981,7 +1981,7 @@ void Wayland_SetWindowKeyboardGrab(SDL_VideoDevice *_this, SDL_Window *window, S
|
||||
}
|
||||
}
|
||||
|
||||
int Wayland_CreateWindow(SDL_VideoDevice *_this, SDL_Window *window)
|
||||
int Wayland_CreateWindow(SDL_VideoDevice *_this, SDL_Window *window, SDL_PropertiesID create_props)
|
||||
{
|
||||
SDL_WindowData *data;
|
||||
SDL_VideoData *c;
|
||||
|
||||
@@ -137,7 +137,7 @@ extern void Wayland_SetWindowKeyboardGrab(SDL_VideoDevice *_this, SDL_Window *wi
|
||||
extern void Wayland_RestoreWindow(SDL_VideoDevice *_this, SDL_Window *window);
|
||||
extern void Wayland_SetWindowBordered(SDL_VideoDevice *_this, SDL_Window *window, SDL_bool bordered);
|
||||
extern void Wayland_SetWindowResizable(SDL_VideoDevice *_this, SDL_Window *window, SDL_bool resizable);
|
||||
extern int Wayland_CreateWindow(SDL_VideoDevice *_this, SDL_Window *window);
|
||||
extern int Wayland_CreateWindow(SDL_VideoDevice *_this, SDL_Window *window, SDL_PropertiesID create_props);
|
||||
extern int Wayland_SetWindowPosition(SDL_VideoDevice *_this, SDL_Window *window);
|
||||
extern void Wayland_SetWindowSize(SDL_VideoDevice *_this, SDL_Window *window);
|
||||
extern void Wayland_SetWindowMinimumSize(SDL_VideoDevice *_this, SDL_Window *window);
|
||||
|
||||
@@ -176,7 +176,6 @@ static SDL_VideoDevice *WIN_CreateDevice(void)
|
||||
#endif
|
||||
|
||||
device->CreateSDLWindow = WIN_CreateWindow;
|
||||
device->CreateSDLWindowFrom = WIN_CreateWindowFrom;
|
||||
device->SetWindowTitle = WIN_SetWindowTitle;
|
||||
device->SetWindowIcon = WIN_SetWindowIcon;
|
||||
device->SetWindowPosition = WIN_SetWindowPosition;
|
||||
|
||||
@@ -276,7 +276,7 @@ static void SDLCALL WIN_MouseRelativeModeCenterChanged(void *userdata, const cha
|
||||
data->mouse_relative_mode_center = SDL_GetStringBoolean(hint, SDL_TRUE);
|
||||
}
|
||||
|
||||
static int SetupWindowData(SDL_VideoDevice *_this, SDL_Window *window, HWND hwnd, HWND parent, SDL_bool created)
|
||||
static int SetupWindowData(SDL_VideoDevice *_this, SDL_Window *window, HWND hwnd, HWND parent)
|
||||
{
|
||||
SDL_VideoData *videodata = _this->driverdata;
|
||||
SDL_WindowData *data;
|
||||
@@ -295,8 +295,6 @@ static int SetupWindowData(SDL_VideoDevice *_this, SDL_Window *window, HWND hwnd
|
||||
data->hdc = GetDC(hwnd);
|
||||
#endif
|
||||
data->hinstance = (HINSTANCE)GetWindowLongPtr(hwnd, GWLP_HINSTANCE);
|
||||
data->created = created;
|
||||
data->high_surrogate = 0;
|
||||
data->mouse_button_flags = (WPARAM)-1;
|
||||
data->last_pointer_update = (LPARAM)-1;
|
||||
data->videodata = videodata;
|
||||
@@ -349,7 +347,10 @@ static int SetupWindowData(SDL_VideoDevice *_this, SDL_Window *window, HWND hwnd
|
||||
int w = rect.right;
|
||||
int h = rect.bottom;
|
||||
|
||||
if ((window->windowed.w && window->windowed.w != w) || (window->windowed.h && window->windowed.h != h)) {
|
||||
if (window->flags & SDL_WINDOW_FOREIGN) {
|
||||
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)) {
|
||||
/* We tried to create a window larger than the desktop and Windows didn't allow it. Override! */
|
||||
int x, y;
|
||||
/* Figure out what the window area will be */
|
||||
@@ -369,6 +370,10 @@ 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) {
|
||||
window->windowed.x = point.x;
|
||||
window->windowed.y = point.y;
|
||||
}
|
||||
window->x = point.x;
|
||||
window->y = point.y;
|
||||
}
|
||||
@@ -438,6 +443,27 @@ static int SetupWindowData(SDL_VideoDevice *_this, SDL_Window *window, HWND hwnd
|
||||
|
||||
data->initializing = SDL_FALSE;
|
||||
|
||||
if (window->flags & SDL_WINDOW_FOREIGN) {
|
||||
/* Query the title from the existing window */
|
||||
LPTSTR title;
|
||||
int titleLen;
|
||||
SDL_bool isstack;
|
||||
|
||||
titleLen = GetWindowTextLength(hwnd);
|
||||
title = SDL_small_alloc(TCHAR, titleLen + 1, &isstack);
|
||||
if (title) {
|
||||
titleLen = GetWindowText(hwnd, title, titleLen + 1);
|
||||
} else {
|
||||
titleLen = 0;
|
||||
}
|
||||
if (titleLen > 0) {
|
||||
window->title = WIN_StringToUTF8(title);
|
||||
}
|
||||
if (title) {
|
||||
SDL_small_free(title, isstack);
|
||||
}
|
||||
}
|
||||
|
||||
SDL_PropertiesID props = SDL_GetWindowProperties(window);
|
||||
SDL_SetProperty(props, "SDL.window.win32.hwnd", data->hwnd);
|
||||
SDL_SetProperty(props, "SDL.window.win32.hdc", data->hdc);
|
||||
@@ -464,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 (data->created) {
|
||||
if (!(window->flags & SDL_WINDOW_FOREIGN)) {
|
||||
DestroyWindow(data->hwnd);
|
||||
if (data->destroy_parent_with_window && data->parent) {
|
||||
DestroyWindow(data->parent);
|
||||
@@ -538,55 +564,64 @@ static void WIN_SetKeyboardFocus(SDL_Window *window)
|
||||
SDL_SetKeyboardFocus(window);
|
||||
}
|
||||
|
||||
int WIN_CreateWindow(SDL_VideoDevice *_this, SDL_Window *window)
|
||||
int WIN_CreateWindow(SDL_VideoDevice *_this, SDL_Window *window, SDL_PropertiesID create_props)
|
||||
{
|
||||
HWND hwnd, parent = NULL;
|
||||
DWORD style = STYLE_BASIC;
|
||||
DWORD styleEx = 0;
|
||||
int x, y;
|
||||
int w, h;
|
||||
HWND hwnd = (HWND)SDL_GetProperty(create_props, "native.win32.hwnd", SDL_GetProperty(create_props, "native.data", NULL));
|
||||
HWND parent = NULL;
|
||||
if (hwnd) {
|
||||
window->flags |= SDL_WINDOW_FOREIGN;
|
||||
|
||||
if (SDL_WINDOW_IS_POPUP(window)) {
|
||||
parent = window->parent->driverdata->hwnd;
|
||||
} else if (window->flags & SDL_WINDOW_UTILITY) {
|
||||
parent = CreateWindow(SDL_Appname, TEXT(""), STYLE_BASIC, 0, 0, 32, 32, NULL, NULL, SDL_Instance, NULL);
|
||||
}
|
||||
|
||||
style |= GetWindowStyle(window);
|
||||
styleEx |= GetWindowStyleEx(window);
|
||||
|
||||
/* Figure out what the window area will be */
|
||||
WIN_ConstrainPopup(window);
|
||||
WIN_AdjustWindowRectWithStyle(window, style, FALSE, &x, &y, &w, &h, SDL_FALSE);
|
||||
|
||||
hwnd = CreateWindowEx(styleEx, SDL_Appname, TEXT(""), style,
|
||||
x, y, w, h, parent, NULL, SDL_Instance, NULL);
|
||||
if (!hwnd) {
|
||||
return WIN_SetError("Couldn't create window");
|
||||
}
|
||||
|
||||
WIN_UpdateDarkModeForHWND(hwnd);
|
||||
|
||||
WIN_PumpEvents(_this);
|
||||
|
||||
if (SetupWindowData(_this, window, hwnd, parent, SDL_TRUE) < 0) {
|
||||
DestroyWindow(hwnd);
|
||||
if (parent) {
|
||||
DestroyWindow(parent);
|
||||
if (SetupWindowData(_this, window, hwnd, parent) < 0) {
|
||||
return -1;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
} else {
|
||||
DWORD style = STYLE_BASIC;
|
||||
DWORD styleEx = 0;
|
||||
int x, y;
|
||||
int w, h;
|
||||
|
||||
/* Inform Windows of the frame change so we can respond to WM_NCCALCSIZE */
|
||||
SetWindowPos(hwnd, NULL, 0, 0, 0, 0, SWP_FRAMECHANGED | SWP_NOSIZE | SWP_NOMOVE | SWP_NOZORDER | SWP_NOOWNERZORDER | SWP_NOACTIVATE);
|
||||
if (SDL_WINDOW_IS_POPUP(window)) {
|
||||
parent = window->parent->driverdata->hwnd;
|
||||
} else if (window->flags & SDL_WINDOW_UTILITY) {
|
||||
parent = CreateWindow(SDL_Appname, TEXT(""), STYLE_BASIC, 0, 0, 32, 32, NULL, NULL, SDL_Instance, NULL);
|
||||
}
|
||||
|
||||
if (window->flags & SDL_WINDOW_MINIMIZED) {
|
||||
/* TODO: We have to clear SDL_WINDOW_HIDDEN here to ensure the window flags match the window state. The
|
||||
window is already shown after this and windows with WS_MINIMIZE do not generate a WM_SHOWWINDOW. This
|
||||
means you can't currently create a window that is initially hidden and is minimized when shown.
|
||||
*/
|
||||
window->flags &= ~SDL_WINDOW_HIDDEN;
|
||||
ShowWindow(hwnd, SW_SHOWMINNOACTIVE);
|
||||
style |= GetWindowStyle(window);
|
||||
styleEx |= GetWindowStyleEx(window);
|
||||
|
||||
/* Figure out what the window area will be */
|
||||
WIN_ConstrainPopup(window);
|
||||
WIN_AdjustWindowRectWithStyle(window, style, FALSE, &x, &y, &w, &h, SDL_FALSE);
|
||||
|
||||
hwnd = CreateWindowEx(styleEx, SDL_Appname, TEXT(""), style,
|
||||
x, y, w, h, parent, NULL, SDL_Instance, NULL);
|
||||
if (!hwnd) {
|
||||
return WIN_SetError("Couldn't create window");
|
||||
}
|
||||
|
||||
WIN_UpdateDarkModeForHWND(hwnd);
|
||||
|
||||
WIN_PumpEvents(_this);
|
||||
|
||||
if (SetupWindowData(_this, window, hwnd, parent) < 0) {
|
||||
DestroyWindow(hwnd);
|
||||
if (parent) {
|
||||
DestroyWindow(parent);
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Inform Windows of the frame change so we can respond to WM_NCCALCSIZE */
|
||||
SetWindowPos(hwnd, NULL, 0, 0, 0, 0, SWP_FRAMECHANGED | SWP_NOSIZE | SWP_NOMOVE | SWP_NOZORDER | SWP_NOOWNERZORDER | SWP_NOACTIVATE);
|
||||
|
||||
if (window->flags & SDL_WINDOW_MINIMIZED) {
|
||||
/* TODO: We have to clear SDL_WINDOW_HIDDEN here to ensure the window flags match the window state. The
|
||||
window is already shown after this and windows with WS_MINIMIZE do not generate a WM_SHOWWINDOW. This
|
||||
means you can't currently create a window that is initially hidden and is minimized when shown.
|
||||
*/
|
||||
window->flags &= ~SDL_WINDOW_HIDDEN;
|
||||
ShowWindow(hwnd, SW_SHOWMINNOACTIVE);
|
||||
}
|
||||
}
|
||||
|
||||
/* FIXME: does not work on all hardware configurations with different renders (i.e. hybrid GPUs) */
|
||||
@@ -608,98 +643,56 @@ int WIN_CreateWindow(SDL_VideoDevice *_this, SDL_Window *window)
|
||||
}
|
||||
}
|
||||
|
||||
if (!(window->flags & SDL_WINDOW_OPENGL)) {
|
||||
return 0;
|
||||
}
|
||||
HWND share_hwnd = (HWND)SDL_GetProperty(create_props, "native.win32.pixel_format_hwnd", NULL);
|
||||
if (share_hwnd) {
|
||||
HDC hdc = GetDC(share_hwnd);
|
||||
int pixel_format = GetPixelFormat(hdc);
|
||||
PIXELFORMATDESCRIPTOR pfd;
|
||||
|
||||
/* The rest of this macro mess is for OpenGL or OpenGL ES windows */
|
||||
#ifdef SDL_VIDEO_OPENGL_ES2
|
||||
if ((_this->gl_config.profile_mask == SDL_GL_CONTEXT_PROFILE_ES ||
|
||||
SDL_GetHintBoolean(SDL_HINT_VIDEO_FORCE_EGL, SDL_FALSE)) &&
|
||||
#ifdef SDL_VIDEO_OPENGL_WGL
|
||||
(!_this->gl_data || WIN_GL_UseEGL(_this))
|
||||
#endif /* SDL_VIDEO_OPENGL_WGL */
|
||||
) {
|
||||
#ifdef SDL_VIDEO_OPENGL_EGL
|
||||
if (WIN_GLES_SetupWindow(_this, window) < 0) {
|
||||
SDL_zero(pfd);
|
||||
DescribePixelFormat(hdc, pixel_format, sizeof(pfd), &pfd);
|
||||
ReleaseDC(share_hwnd, hdc);
|
||||
|
||||
if (!SetPixelFormat(window->driverdata->hdc, pixel_format, &pfd)) {
|
||||
WIN_DestroyWindow(_this, window);
|
||||
return -1;
|
||||
return WIN_SetError("SetPixelFormat()");
|
||||
}
|
||||
return 0;
|
||||
} else {
|
||||
if (!(window->flags & SDL_WINDOW_OPENGL)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* The rest of this macro mess is for OpenGL or OpenGL ES windows */
|
||||
#ifdef SDL_VIDEO_OPENGL_ES2
|
||||
if ((_this->gl_config.profile_mask == SDL_GL_CONTEXT_PROFILE_ES ||
|
||||
SDL_GetHintBoolean(SDL_HINT_VIDEO_FORCE_EGL, SDL_FALSE)) &&
|
||||
#ifdef SDL_VIDEO_OPENGL_WGL
|
||||
(!_this->gl_data || WIN_GL_UseEGL(_this))
|
||||
#endif /* SDL_VIDEO_OPENGL_WGL */
|
||||
) {
|
||||
#ifdef SDL_VIDEO_OPENGL_EGL
|
||||
if (WIN_GLES_SetupWindow(_this, window) < 0) {
|
||||
WIN_DestroyWindow(_this, window);
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
#else
|
||||
return SDL_SetError("Could not create GLES window surface (EGL support not configured)");
|
||||
return SDL_SetError("Could not create GLES window surface (EGL support not configured)");
|
||||
#endif /* SDL_VIDEO_OPENGL_EGL */
|
||||
}
|
||||
}
|
||||
#endif /* SDL_VIDEO_OPENGL_ES2 */
|
||||
|
||||
#ifdef SDL_VIDEO_OPENGL_WGL
|
||||
if (WIN_GL_SetupWindow(_this, window) < 0) {
|
||||
WIN_DestroyWindow(_this, window);
|
||||
return -1;
|
||||
}
|
||||
#else
|
||||
return SDL_SetError("Could not create GL window (WGL support not configured)");
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int WIN_CreateWindowFrom(SDL_VideoDevice *_this, SDL_Window *window, SDL_PropertiesID props)
|
||||
{
|
||||
#if defined(__XBOXONE__) || defined(__XBOXSERIES__)
|
||||
return -1;
|
||||
#else
|
||||
HWND hwnd = (HWND)SDL_GetProperty(props, "win32.hwnd", SDL_GetProperty(props, "data", NULL));
|
||||
LPTSTR title;
|
||||
int titleLen;
|
||||
SDL_bool isstack;
|
||||
|
||||
if (!hwnd) {
|
||||
return SDL_SetError("Couldn't find property win32.hwnd");
|
||||
}
|
||||
|
||||
/* Query the title from the existing window */
|
||||
titleLen = GetWindowTextLength(hwnd);
|
||||
title = SDL_small_alloc(TCHAR, titleLen + 1, &isstack);
|
||||
if (title) {
|
||||
titleLen = GetWindowText(hwnd, title, titleLen + 1);
|
||||
} else {
|
||||
titleLen = 0;
|
||||
}
|
||||
if (titleLen > 0) {
|
||||
window->title = WIN_StringToUTF8(title);
|
||||
}
|
||||
if (title) {
|
||||
SDL_small_free(title, isstack);
|
||||
}
|
||||
|
||||
if (SetupWindowData(_this, window, hwnd, GetParent(hwnd), SDL_FALSE) < 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
#ifdef SDL_VIDEO_OPENGL_WGL
|
||||
{
|
||||
HWND share_hwnd = (HWND)SDL_GetProperty(props, "win32.pixel_format_hwnd", NULL);
|
||||
if (share_hwnd) {
|
||||
HDC hdc = GetDC(share_hwnd);
|
||||
int pixel_format = GetPixelFormat(hdc);
|
||||
PIXELFORMATDESCRIPTOR pfd;
|
||||
|
||||
SDL_zero(pfd);
|
||||
DescribePixelFormat(hdc, pixel_format, sizeof(pfd), &pfd);
|
||||
ReleaseDC(share_hwnd, hdc);
|
||||
|
||||
if (!SetPixelFormat(window->driverdata->hdc, pixel_format, &pfd)) {
|
||||
return WIN_SetError("SetPixelFormat()");
|
||||
}
|
||||
} else if (window->flags & SDL_WINDOW_OPENGL) {
|
||||
/* Try to set up the pixel format, if it hasn't been set by the application */
|
||||
WIN_GL_SetupWindow(_this, window);
|
||||
if (WIN_GL_SetupWindow(_this, window) < 0) {
|
||||
WIN_DestroyWindow(_this, window);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
#else
|
||||
return SDL_SetError("Could not create GL window (WGL support not configured)");
|
||||
#endif
|
||||
}
|
||||
|
||||
return 0;
|
||||
#endif /*!defined(__XBOXONE__) && !defined(__XBOXSERIES__)*/
|
||||
}
|
||||
|
||||
void WIN_SetWindowTitle(SDL_VideoDevice *_this, SDL_Window *window)
|
||||
|
||||
@@ -45,7 +45,6 @@ struct SDL_WindowData
|
||||
HBITMAP hbm;
|
||||
WNDPROC wndproc;
|
||||
HHOOK keyboard_hook;
|
||||
SDL_bool created;
|
||||
WPARAM mouse_button_flags;
|
||||
LPARAM last_pointer_update;
|
||||
WCHAR high_surrogate;
|
||||
@@ -75,8 +74,7 @@ struct SDL_WindowData
|
||||
UINT copybits_flag;
|
||||
};
|
||||
|
||||
extern int WIN_CreateWindow(SDL_VideoDevice *_this, SDL_Window *window);
|
||||
extern int WIN_CreateWindowFrom(SDL_VideoDevice *_this, SDL_Window *window, SDL_PropertiesID props);
|
||||
extern int WIN_CreateWindow(SDL_VideoDevice *_this, SDL_Window *window, SDL_PropertiesID create_props);
|
||||
extern void WIN_SetWindowTitle(SDL_VideoDevice *_this, SDL_Window *window);
|
||||
extern int WIN_SetWindowIcon(SDL_VideoDevice *_this, SDL_Window *window, SDL_Surface *icon);
|
||||
extern int WIN_SetWindowPosition(SDL_VideoDevice *_this, SDL_Window *window);
|
||||
|
||||
@@ -74,7 +74,7 @@ static int WINRT_SetDisplayMode(SDL_VideoDevice *_this, SDL_VideoDisplay *displa
|
||||
static void WINRT_VideoQuit(SDL_VideoDevice *_this);
|
||||
|
||||
/* Window functions */
|
||||
static int WINRT_CreateWindow(SDL_VideoDevice *_this, SDL_Window *window);
|
||||
static int WINRT_CreateWindow(SDL_VideoDevice *_this, SDL_Window *window, SDL_PropertiesID create_props);
|
||||
static void WINRT_SetWindowSize(SDL_VideoDevice *_this, SDL_Window *window);
|
||||
static void WINRT_SetWindowFullscreen(SDL_VideoDevice *_this, SDL_Window *window, SDL_VideoDisplay *display, SDL_bool fullscreen);
|
||||
static void WINRT_DestroyWindow(SDL_VideoDevice *_this, SDL_Window *window);
|
||||
@@ -581,7 +581,7 @@ static bool WINRT_IsCoreWindowActive(CoreWindow ^ coreWindow)
|
||||
return true;
|
||||
}
|
||||
|
||||
int WINRT_CreateWindow(SDL_VideoDevice *_this, SDL_Window *window)
|
||||
int WINRT_CreateWindow(SDL_VideoDevice *_this, SDL_Window *window, SDL_PropertiesID create_props)
|
||||
{
|
||||
// Make sure that only one window gets created, at least until multimonitor
|
||||
// support is added.
|
||||
|
||||
@@ -181,7 +181,6 @@ static SDL_VideoDevice *X11_CreateDevice(void)
|
||||
device->SendWakeupEvent = X11_SendWakeupEvent;
|
||||
|
||||
device->CreateSDLWindow = X11_CreateWindow;
|
||||
device->CreateSDLWindowFrom = X11_CreateWindowFrom;
|
||||
device->SetWindowTitle = X11_SetWindowTitle;
|
||||
device->SetWindowIcon = X11_SetWindowIcon;
|
||||
device->SetWindowPosition = X11_SetWindowPosition;
|
||||
|
||||
@@ -295,7 +295,7 @@ Uint32 X11_GetNetWMState(SDL_VideoDevice *_this, SDL_Window *window, Window xwin
|
||||
return flags;
|
||||
}
|
||||
|
||||
static int SetupWindowData(SDL_VideoDevice *_this, SDL_Window *window, Window w, BOOL created)
|
||||
static int SetupWindowData(SDL_VideoDevice *_this, SDL_Window *window, Window w)
|
||||
{
|
||||
SDL_VideoData *videodata = _this->driverdata;
|
||||
SDL_DisplayData *displaydata = SDL_GetDisplayDriverDataForWindow(window);
|
||||
@@ -320,7 +320,6 @@ static int SetupWindowData(SDL_VideoDevice *_this, SDL_Window *window, Window w,
|
||||
NULL);
|
||||
}
|
||||
#endif
|
||||
data->created = created;
|
||||
data->videodata = videodata;
|
||||
|
||||
/* Associate the data with the window */
|
||||
@@ -380,8 +379,10 @@ static int SetupWindowData(SDL_VideoDevice *_this, SDL_Window *window, Window w,
|
||||
}
|
||||
}
|
||||
|
||||
/* All done! */
|
||||
window->driverdata = data;
|
||||
if (window->flags & SDL_WINDOW_FOREIGN) {
|
||||
/* Query the title from the existing window */
|
||||
window->title = X11_GetWindowTitle(_this, w);
|
||||
}
|
||||
|
||||
SDL_PropertiesID props = SDL_GetWindowProperties(window);
|
||||
int screen = (displaydata ? displaydata->screen : 0);
|
||||
@@ -389,6 +390,8 @@ static int SetupWindowData(SDL_VideoDevice *_this, SDL_Window *window, Window w,
|
||||
SDL_SetNumberProperty(props, "SDL.window.x11.screen", screen);
|
||||
SDL_SetNumberProperty(props, "SDL.window.x11.window", data->xwindow);
|
||||
|
||||
/* All done! */
|
||||
window->driverdata = data;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -422,8 +425,18 @@ static void SetWindowBordered(Display *display, int screen, Window window, SDL_b
|
||||
}
|
||||
}
|
||||
|
||||
int X11_CreateWindow(SDL_VideoDevice *_this, SDL_Window *window)
|
||||
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));
|
||||
if (w) {
|
||||
window->flags |= SDL_WINDOW_FOREIGN;
|
||||
|
||||
if (SetupWindowData(_this, window, w) < 0) {
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
SDL_VideoData *data = _this->driverdata;
|
||||
SDL_DisplayData *displaydata = SDL_GetDisplayDriverDataForWindow(window);
|
||||
const SDL_bool force_override_redirect = SDL_GetHintBoolean(SDL_HINT_X11_FORCE_OVERRIDE_REDIRECT, SDL_FALSE);
|
||||
@@ -433,7 +446,6 @@ int X11_CreateWindow(SDL_VideoDevice *_this, SDL_Window *window)
|
||||
Visual *visual;
|
||||
int depth;
|
||||
XSetWindowAttributes xattr;
|
||||
Window w;
|
||||
XSizeHints *sizehints;
|
||||
XWMHints *wmhints;
|
||||
XClassHint *classhints;
|
||||
@@ -706,7 +718,7 @@ int X11_CreateWindow(SDL_VideoDevice *_this, SDL_Window *window)
|
||||
X11_XSetWMProtocols(display, w, protocols, proto_count);
|
||||
}
|
||||
|
||||
if (SetupWindowData(_this, window, w, SDL_TRUE) < 0) {
|
||||
if (SetupWindowData(_this, window, w) < 0) {
|
||||
X11_XDestroyWindow(display, w);
|
||||
return -1;
|
||||
}
|
||||
@@ -777,21 +789,6 @@ int X11_CreateWindow(SDL_VideoDevice *_this, SDL_Window *window)
|
||||
return 0;
|
||||
}
|
||||
|
||||
int X11_CreateWindowFrom(SDL_VideoDevice *_this, SDL_Window *window, SDL_PropertiesID props)
|
||||
{
|
||||
Window w = (Window)SDL_GetNumberProperty(props, "x11.window", (Window)SDL_GetProperty(props, "data", NULL));
|
||||
if (!w) {
|
||||
return SDL_SetError("Couldn't find property x11.window");
|
||||
}
|
||||
|
||||
window->title = X11_GetWindowTitle(_this, w);
|
||||
|
||||
if (SetupWindowData(_this, window, w, SDL_FALSE) < 0) {
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
char *X11_GetWindowTitle(SDL_VideoDevice *_this, Window xwindow)
|
||||
{
|
||||
SDL_VideoData *data = _this->driverdata;
|
||||
@@ -1848,7 +1845,7 @@ void X11_DestroyWindow(SDL_VideoDevice *_this, SDL_Window *window)
|
||||
X11_XDestroyIC(data->ic);
|
||||
}
|
||||
#endif
|
||||
if (data->created) {
|
||||
if (!(window->flags & SDL_WINDOW_FOREIGN)) {
|
||||
X11_XDestroyWindow(display, data->xwindow);
|
||||
X11_XFlush(display);
|
||||
}
|
||||
|
||||
@@ -84,8 +84,7 @@ struct SDL_WindowData
|
||||
extern void X11_SetNetWMState(SDL_VideoDevice *_this, Window xwindow, Uint32 flags);
|
||||
extern Uint32 X11_GetNetWMState(SDL_VideoDevice *_this, SDL_Window *window, Window xwindow);
|
||||
|
||||
extern int X11_CreateWindow(SDL_VideoDevice *_this, SDL_Window *window);
|
||||
extern int X11_CreateWindowFrom(SDL_VideoDevice *_this, SDL_Window *window, SDL_PropertiesID props);
|
||||
extern int X11_CreateWindow(SDL_VideoDevice *_this, SDL_Window *window, SDL_PropertiesID create_props);
|
||||
extern char *X11_GetWindowTitle(SDL_VideoDevice *_this, Window xwindow);
|
||||
extern void X11_SetWindowTitle(SDL_VideoDevice *_this, SDL_Window *window);
|
||||
extern int X11_SetWindowIcon(SDL_VideoDevice *_this, SDL_Window *window, SDL_Surface *icon);
|
||||
|
||||
Reference in New Issue
Block a user