Simplified driver window creation code.
Implemented several Cocoa window functions --HG-- extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%402002
This commit is contained in:
parent
7f0d36082f
commit
c8d7322dc6
8 changed files with 127 additions and 175 deletions
|
@ -148,7 +148,6 @@ struct SDL_SysWMinfo
|
|||
{
|
||||
SDL_version version;
|
||||
HWND window; /* The Win32 display window */
|
||||
HGLRC hglrc; /* The OpenGL context, if any */
|
||||
};
|
||||
|
||||
#elif defined(SDL_VIDEO_DRIVER_RISCOS)
|
||||
|
|
|
@ -574,17 +574,15 @@ extern DECLSPEC int SDLCALL SDL_GetGammaRamp(Uint16 * red, Uint16 * green,
|
|||
*
|
||||
* \brief Create a window with the specified position, dimensions, and flags.
|
||||
*
|
||||
* \param title The title of the window
|
||||
* \param x The x position of the window
|
||||
* \param y The y position of the window
|
||||
* \param title The title of the window, in UTF-8 encoding
|
||||
* \param x The x position of the window, SDL_WINDOWPOS_CENTERED, or SDL_WINDOWPOS_UNDEFINED
|
||||
* \param y The y position of the window, SDL_WINDOWPOS_CENTERED, or SDL_WINDOWPOS_UNDEFINED
|
||||
* \param w The width of the window
|
||||
* \param h The height of the window
|
||||
* \param flags The flags for the window, a mask of any of the following: SDL_WINDOW_FULLSCREEN, SDL_WINDOW_OPENGL, SDL_WINDOW_SHOWN, SDL_WINDOW_BORDERLESS, SDL_WINDOW_RESIZABLE, SDL_WINDOW_MAXIMIZED, SDL_WINDOW_MINIMIZED, SDL_WINDOW_INPUT_GRABBED
|
||||
*
|
||||
* \return The id of the window created, or zero if window creation failed.
|
||||
*
|
||||
* \note Setting the position to -1, -1, indicates any position is fine.
|
||||
*
|
||||
* \sa SDL_DestroyWindow()
|
||||
*/
|
||||
extern DECLSPEC SDL_WindowID SDLCALL SDL_CreateWindow(const char *title,
|
||||
|
|
|
@ -614,9 +614,8 @@ SDL_SetDisplayMode(const SDL_DisplayMode * mode)
|
|||
for (i = 0; i < display->num_windows; ++i) {
|
||||
SDL_Window *window = &display->windows[i];
|
||||
if (FULLSCREEN_VISIBLE(window)) {
|
||||
SDL_SetWindowPosition(window->id,
|
||||
((display_mode.w - window->w) / 2),
|
||||
((display_mode.h - window->h) / 2));
|
||||
SDL_SetWindowPosition(window->id, SDL_WINDOWPOS_CENTERED,
|
||||
SDL_WINDOWPOS_CENTERED);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -718,12 +717,8 @@ SDL_CreateWindow(const char *title, int x, int y, int w, int h, Uint32 flags)
|
|||
{
|
||||
const Uint32 allowed_flags = (SDL_WINDOW_FULLSCREEN |
|
||||
SDL_WINDOW_OPENGL |
|
||||
SDL_WINDOW_SHOWN |
|
||||
SDL_WINDOW_BORDERLESS |
|
||||
SDL_WINDOW_RESIZABLE |
|
||||
SDL_WINDOW_MAXIMIZED |
|
||||
SDL_WINDOW_MINIMIZED |
|
||||
SDL_WINDOW_INPUT_GRABBED);
|
||||
SDL_WINDOW_RESIZABLE);
|
||||
SDL_VideoDisplay *display;
|
||||
SDL_Window window;
|
||||
int num_windows;
|
||||
|
@ -739,9 +734,14 @@ SDL_CreateWindow(const char *title, int x, int y, int w, int h, Uint32 flags)
|
|||
return 0;
|
||||
}
|
||||
|
||||
/* Fullscreen windows don't have any window decorations */
|
||||
if (flags & SDL_WINDOW_FULLSCREEN) {
|
||||
flags |= SDL_WINDOW_BORDERLESS;
|
||||
flags &= ~SDL_WINDOW_RESIZABLE;
|
||||
}
|
||||
|
||||
SDL_zero(window);
|
||||
window.id = _this->next_object_id++;
|
||||
window.title = title ? SDL_strdup(title) : NULL;
|
||||
window.x = x;
|
||||
window.y = y;
|
||||
window.w = w;
|
||||
|
@ -750,9 +750,6 @@ SDL_CreateWindow(const char *title, int x, int y, int w, int h, Uint32 flags)
|
|||
window.display = _this->current_display;
|
||||
|
||||
if (_this->CreateWindow && _this->CreateWindow(_this, &window) < 0) {
|
||||
if (window.title) {
|
||||
SDL_free(window.title);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -764,27 +761,27 @@ SDL_CreateWindow(const char *title, int x, int y, int w, int h, Uint32 flags)
|
|||
if (_this->DestroyWindow) {
|
||||
_this->DestroyWindow(_this, &window);
|
||||
}
|
||||
if (window.title) {
|
||||
SDL_free(window.title);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
windows[num_windows] = window;
|
||||
display->windows = windows;
|
||||
display->num_windows++;
|
||||
|
||||
if (FULLSCREEN_VISIBLE(&window)) {
|
||||
/* Hide any other fullscreen windows */
|
||||
int i;
|
||||
for (i = 0; i < display->num_windows; ++i) {
|
||||
SDL_Window *other = &display->windows[i];
|
||||
if (other->id != window.id && FULLSCREEN_VISIBLE(other)) {
|
||||
SDL_MinimizeWindow(other->id);
|
||||
}
|
||||
}
|
||||
SDL_SetDisplayMode(display->fullscreen_mode);
|
||||
if (title) {
|
||||
SDL_SetWindowTitle(window.id, title);
|
||||
}
|
||||
if (flags & SDL_WINDOW_MAXIMIZED) {
|
||||
SDL_MaximizeWindow(window.id);
|
||||
}
|
||||
if (flags & SDL_WINDOW_MINIMIZED) {
|
||||
SDL_MinimizeWindow(window.id);
|
||||
}
|
||||
if (flags & SDL_WINDOW_SHOWN) {
|
||||
SDL_ShowWindow(window.id);
|
||||
}
|
||||
if (flags & SDL_WINDOW_INPUT_GRABBED) {
|
||||
SDL_SetWindowGrab(window.id, 1);
|
||||
}
|
||||
|
||||
return window.id;
|
||||
}
|
||||
|
||||
|
@ -833,15 +830,44 @@ SDL_CreateWindowFrom(const void *data)
|
|||
int
|
||||
SDL_RecreateWindow(SDL_Window * window, Uint32 flags)
|
||||
{
|
||||
char *title = window->title;
|
||||
|
||||
if ((flags & SDL_WINDOW_OPENGL) && !_this->GL_CreateContext) {
|
||||
SDL_SetError("No OpenGL support in video driver");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (_this->DestroyWindow) {
|
||||
_this->DestroyWindow(_this, window);
|
||||
}
|
||||
window->flags = flags;
|
||||
return _this->CreateWindow(_this, window);
|
||||
|
||||
window->title = NULL;
|
||||
window->flags =
|
||||
(flags &
|
||||
~(SDL_WINDOW_MAXIMIZED | SDL_WINDOW_MINIMIZED | SDL_WINDOW_SHOWN |
|
||||
SDL_WINDOW_INPUT_GRABBED));
|
||||
|
||||
if (_this->CreateWindow && _this->CreateWindow(_this, window) < 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (title) {
|
||||
SDL_SetWindowTitle(window->id, title);
|
||||
SDL_free(title);
|
||||
}
|
||||
if (flags & SDL_WINDOW_MAXIMIZED) {
|
||||
SDL_MaximizeWindow(window->id);
|
||||
}
|
||||
if (flags & SDL_WINDOW_MINIMIZED) {
|
||||
SDL_MinimizeWindow(window->id);
|
||||
}
|
||||
if (flags & SDL_WINDOW_SHOWN) {
|
||||
SDL_ShowWindow(window->id);
|
||||
}
|
||||
if (flags & SDL_WINDOW_INPUT_GRABBED) {
|
||||
SDL_SetWindowGrab(window->id, 1);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
SDL_Window *
|
||||
|
@ -873,6 +899,9 @@ SDL_GetDisplayFromWindow(SDL_Window * window)
|
|||
SDL_UninitializedVideo();
|
||||
return NULL;
|
||||
}
|
||||
if (!window) {
|
||||
return NULL;
|
||||
}
|
||||
return &_this->displays[window->display];
|
||||
}
|
||||
|
||||
|
@ -891,14 +920,20 @@ void
|
|||
SDL_SetWindowTitle(SDL_WindowID windowID, const char *title)
|
||||
{
|
||||
SDL_Window *window = SDL_GetWindowFromID(windowID);
|
||||
const char *last_title;
|
||||
|
||||
if (!window) {
|
||||
if (!window || title == window->title) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (window->title) {
|
||||
SDL_free(window->title);
|
||||
}
|
||||
window->title = SDL_strdup(title);
|
||||
if (title) {
|
||||
window->title = SDL_strdup(title);
|
||||
} else {
|
||||
window->title = NULL;
|
||||
}
|
||||
|
||||
if (_this->SetWindowTitle) {
|
||||
_this->SetWindowTitle(_this, window);
|
||||
|
@ -942,15 +977,20 @@ void
|
|||
SDL_SetWindowPosition(SDL_WindowID windowID, int x, int y)
|
||||
{
|
||||
SDL_Window *window = SDL_GetWindowFromID(windowID);
|
||||
SDL_VideoDisplay *display = SDL_GetDisplayFromWindow(window);
|
||||
|
||||
if (!window) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (x != SDL_WINDOWPOS_UNDEFINED) {
|
||||
if (x == SDL_WINDOWPOS_CENTERED) {
|
||||
window->x = (display->current_mode.w - window->w) / 2;
|
||||
} else if (x != SDL_WINDOWPOS_UNDEFINED) {
|
||||
window->x = x;
|
||||
}
|
||||
if (y != SDL_WINDOWPOS_UNDEFINED) {
|
||||
if (y == SDL_WINDOWPOS_CENTERED) {
|
||||
window->y = (display->current_mode.h - window->h) / 2;
|
||||
} else if (y != SDL_WINDOWPOS_UNDEFINED) {
|
||||
window->y = y;
|
||||
}
|
||||
|
||||
|
@ -1045,7 +1085,7 @@ SDL_RaiseWindow(SDL_WindowID windowID)
|
|||
{
|
||||
SDL_Window *window = SDL_GetWindowFromID(windowID);
|
||||
|
||||
if (!window) {
|
||||
if (!window || !(window->flags & SDL_WINDOW_SHOWN)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -55,8 +55,6 @@ typedef struct SDL_WindowData SDL_WindowData;
|
|||
-(void) otherMouseUp:(NSEvent *) theEvent;
|
||||
-(void) mouseMoved:(NSEvent *) theEvent;
|
||||
-(void) scrollWheel:(NSEvent *) theEvent;
|
||||
-(void) mouseEntered:(NSEvent *) theEvent;
|
||||
-(void) mouseExited:(NSEvent *) theEvent;
|
||||
-(void) keyDown:(NSEvent *) theEvent;
|
||||
-(void) keyUp:(NSEvent *) theEvent;
|
||||
@end
|
||||
|
|
|
@ -195,6 +195,7 @@ static __inline__ void ConvertNSRect(NSRect *r)
|
|||
|
||||
- (void)mouseMoved:(NSEvent *)theEvent
|
||||
{
|
||||
SDL_Window *window = SDL_GetWindowFromID(_data->windowID);
|
||||
int index;
|
||||
SDL_Mouse *mouse;
|
||||
NSPoint point;
|
||||
|
@ -207,6 +208,18 @@ static __inline__ void ConvertNSRect(NSRect *r)
|
|||
}
|
||||
|
||||
point = [NSEvent mouseLocation];
|
||||
if (point.x < rect.origin.x ||
|
||||
point.x > (rect.origin.x + rect.size.width) ||
|
||||
point.y < rect.origin.y ||
|
||||
point.y > (rect.origin.y + rect.size.height)) {
|
||||
if (window->flags & SDL_WINDOW_MOUSE_FOCUS) {
|
||||
SDL_SendWindowEvent(_data->windowID, SDL_WINDOWEVENT_LEAVE, 0, 0);
|
||||
}
|
||||
} else {
|
||||
if (!(window->flags & SDL_WINDOW_MOUSE_FOCUS)) {
|
||||
SDL_SendWindowEvent(_data->windowID, SDL_WINDOWEVENT_ENTER, 0, 0);
|
||||
}
|
||||
}
|
||||
point.x = point.x - rect.origin.x;
|
||||
point.y = rect.size.height - (point.y - rect.origin.y);
|
||||
SDL_SendMouseMotion(index, 0, (int)point.x, (int)point.y);
|
||||
|
@ -217,18 +230,6 @@ static __inline__ void ConvertNSRect(NSRect *r)
|
|||
fprintf(stderr, "scrollWheel\n");
|
||||
}
|
||||
|
||||
- (void)mouseEntered:(NSEvent *)theEvent
|
||||
{
|
||||
fprintf(stderr, "mouseEntered\n");
|
||||
SDL_SendWindowEvent(_data->windowID, SDL_WINDOWEVENT_ENTER, 0, 0);
|
||||
}
|
||||
|
||||
- (void)mouseExited:(NSEvent *)theEvent
|
||||
{
|
||||
fprintf(stderr, "mouseExited\n");
|
||||
SDL_SendWindowEvent(_data->windowID, SDL_WINDOWEVENT_LEAVE, 0, 0);
|
||||
}
|
||||
|
||||
- (void)keyDown:(NSEvent *)theEvent
|
||||
{
|
||||
fprintf(stderr, "keyDown\n");
|
||||
|
@ -282,7 +283,7 @@ SetupWindowData(_THIS, SDL_Window * window, NSWindow *nswindow, SDL_bool created
|
|||
{
|
||||
unsigned int style = [nswindow styleMask];
|
||||
|
||||
if (style == NSBorderlessWindowMask) {
|
||||
if ((style & ~NSResizableWindowMask) == NSBorderlessWindowMask) {
|
||||
window->flags |= SDL_WINDOW_BORDERLESS;
|
||||
} else {
|
||||
window->flags &= ~SDL_WINDOW_BORDERLESS;
|
||||
|
@ -331,16 +332,14 @@ Cocoa_CreateWindow(_THIS, SDL_Window * window)
|
|||
|
||||
pool = [[NSAutoreleasePool alloc] init];
|
||||
|
||||
if ((window->flags & SDL_WINDOW_FULLSCREEN) ||
|
||||
window->x == SDL_WINDOWPOS_CENTERED) {
|
||||
if (window->x == SDL_WINDOWPOS_CENTERED) {
|
||||
rect.origin.x = (CGDisplayPixelsWide(kCGDirectMainDisplay) - window->w) / 2;
|
||||
} else if (window->x == SDL_WINDOWPOS_UNDEFINED) {
|
||||
rect.origin.x = 0;
|
||||
} else {
|
||||
rect.origin.x = window->x;
|
||||
}
|
||||
if ((window->flags & SDL_WINDOW_FULLSCREEN) ||
|
||||
window->y == SDL_WINDOWPOS_CENTERED) {
|
||||
if (window->y == SDL_WINDOWPOS_CENTERED) {
|
||||
rect.origin.y = (CGDisplayPixelsHigh(kCGDirectMainDisplay) - window->h) / 2;
|
||||
} else if (window->y == SDL_WINDOWPOS_UNDEFINED) {
|
||||
rect.origin.y = 0;
|
||||
|
@ -362,23 +361,6 @@ Cocoa_CreateWindow(_THIS, SDL_Window * window)
|
|||
|
||||
nswindow = [[NSWindow alloc] initWithContentRect:rect styleMask:style backing:NSBackingStoreBuffered defer:FALSE];
|
||||
|
||||
if (window->flags & SDL_WINDOW_SHOWN) {
|
||||
[nswindow makeKeyAndOrderFront:nil];
|
||||
}
|
||||
if (window->flags & SDL_WINDOW_MAXIMIZED) {
|
||||
[nswindow performZoom:nil];
|
||||
}
|
||||
if (window->flags & SDL_WINDOW_MINIMIZED) {
|
||||
[nswindow performMiniaturize:nil];
|
||||
}
|
||||
|
||||
if (window->title) {
|
||||
title = [[NSString alloc] initWithUTF8String:window->title];
|
||||
[nswindow setTitle:title];
|
||||
[nswindow setMiniwindowTitle:title];
|
||||
[title release];
|
||||
}
|
||||
|
||||
[pool release];
|
||||
|
||||
if (SetupWindowData(_this, window, nswindow, SDL_TRUE) < 0) {
|
||||
|
@ -424,10 +406,14 @@ Cocoa_SetWindowTitle(_THIS, SDL_Window * window)
|
|||
NSWindow *nswindow = ((SDL_WindowData *) window->driverdata)->window;
|
||||
NSString *string;
|
||||
|
||||
string = [[NSString alloc] initWithUTF8String:window->title];
|
||||
if(window->title) {
|
||||
string = [[NSString alloc] initWithUTF8String:window->title];
|
||||
} else {
|
||||
string = [[NSString alloc] init];
|
||||
}
|
||||
[nswindow setTitle:string];
|
||||
[nswindow setMiniwindowTitle:string];
|
||||
[string release];
|
||||
|
||||
[pool release];
|
||||
}
|
||||
|
||||
|
@ -467,16 +453,20 @@ Cocoa_ShowWindow(_THIS, SDL_Window * window)
|
|||
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
|
||||
NSWindow *nswindow = ((SDL_WindowData *) window->driverdata)->window;
|
||||
|
||||
[nswindow makeKeyAndOrderFront:nil];
|
||||
if (![nswindow isMiniaturized]) {
|
||||
[nswindow makeKeyAndOrderFront:nil];
|
||||
}
|
||||
[pool release];
|
||||
}
|
||||
|
||||
void
|
||||
Cocoa_HideWindow(_THIS, SDL_Window * window)
|
||||
{
|
||||
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
|
||||
NSWindow *nswindow = ((SDL_WindowData *) window->driverdata)->window;
|
||||
|
||||
/* FIXME */
|
||||
[nswindow orderOut:nil];
|
||||
[pool release];
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -495,7 +485,7 @@ Cocoa_MaximizeWindow(_THIS, SDL_Window * window)
|
|||
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
|
||||
NSWindow *nswindow = ((SDL_WindowData *) window->driverdata)->window;
|
||||
|
||||
[nswindow performZoom:nil];
|
||||
[nswindow zoom:nil];
|
||||
[pool release];
|
||||
}
|
||||
|
||||
|
@ -505,16 +495,22 @@ Cocoa_MinimizeWindow(_THIS, SDL_Window * window)
|
|||
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
|
||||
NSWindow *nswindow = ((SDL_WindowData *) window->driverdata)->window;
|
||||
|
||||
[nswindow performMiniaturize:nil];
|
||||
[nswindow miniaturize:nil];
|
||||
[pool release];
|
||||
}
|
||||
|
||||
void
|
||||
Cocoa_RestoreWindow(_THIS, SDL_Window * window)
|
||||
{
|
||||
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
|
||||
NSWindow *nswindow = ((SDL_WindowData *) window->driverdata)->window;
|
||||
|
||||
/* FIXME */
|
||||
if ([nswindow isMiniaturized]) {
|
||||
[nswindow deminiaturize:nil];
|
||||
} else if ([nswindow isZoomed]) {
|
||||
[nswindow zoom:nil];
|
||||
}
|
||||
[pool release];
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -133,23 +133,13 @@ int
|
|||
WIN_CreateWindow(_THIS, SDL_Window * window)
|
||||
{
|
||||
HWND hwnd;
|
||||
LPTSTR title = NULL;
|
||||
HWND top;
|
||||
RECT rect;
|
||||
DWORD style = (WS_CLIPSIBLINGS | WS_CLIPCHILDREN);
|
||||
int x, y;
|
||||
int w, h;
|
||||
|
||||
if (window->title) {
|
||||
title = WIN_UTF8ToString(window->title);
|
||||
} else {
|
||||
title = NULL;
|
||||
}
|
||||
|
||||
if (window->flags & SDL_WINDOW_SHOWN) {
|
||||
style |= WS_VISIBLE;
|
||||
}
|
||||
if ((window->flags & (SDL_WINDOW_FULLSCREEN | SDL_WINDOW_BORDERLESS))) {
|
||||
if (window->flags & SDL_WINDOW_BORDERLESS) {
|
||||
style |= WS_POPUP;
|
||||
} else {
|
||||
style |= (WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX);
|
||||
|
@ -157,12 +147,6 @@ WIN_CreateWindow(_THIS, SDL_Window * window)
|
|||
if (window->flags & SDL_WINDOW_RESIZABLE) {
|
||||
style |= (WS_THICKFRAME | WS_MAXIMIZEBOX);
|
||||
}
|
||||
if (window->flags & SDL_WINDOW_MAXIMIZED) {
|
||||
style |= WS_MAXIMIZE;
|
||||
}
|
||||
if (window->flags & SDL_WINDOW_MINIMIZED) {
|
||||
style |= WS_MINIMIZE;
|
||||
}
|
||||
|
||||
/* Figure out what the window area will be */
|
||||
if (window->flags & SDL_WINDOW_FULLSCREEN) {
|
||||
|
@ -178,16 +162,14 @@ WIN_CreateWindow(_THIS, SDL_Window * window)
|
|||
w = (rect.right - rect.left);
|
||||
h = (rect.bottom - rect.top);
|
||||
|
||||
if ((window->flags & SDL_WINDOW_FULLSCREEN) ||
|
||||
window->x == SDL_WINDOWPOS_CENTERED) {
|
||||
if (window->x == SDL_WINDOWPOS_CENTERED) {
|
||||
x = (GetSystemMetrics(SM_CXSCREEN) - w) / 2;
|
||||
} else if (window->x == SDL_WINDOWPOS_UNDEFINED) {
|
||||
x = CW_USEDEFAULT;
|
||||
} else {
|
||||
x = window->x + rect.left;
|
||||
}
|
||||
if ((window->flags & SDL_WINDOW_FULLSCREEN) ||
|
||||
window->y == SDL_WINDOWPOS_CENTERED) {
|
||||
if (window->y == SDL_WINDOWPOS_CENTERED) {
|
||||
y = (GetSystemMetrics(SM_CYSCREEN) - h) / 2;
|
||||
} else if (window->y == SDL_WINDOWPOS_UNDEFINED) {
|
||||
y = CW_USEDEFAULT;
|
||||
|
@ -195,15 +177,11 @@ WIN_CreateWindow(_THIS, SDL_Window * window)
|
|||
y = window->y + rect.top;
|
||||
}
|
||||
|
||||
hwnd = CreateWindow(SDL_Appname,
|
||||
title ? title : TEXT(""),
|
||||
style, x, y, w, h, NULL, NULL, SDL_Instance, NULL);
|
||||
hwnd =
|
||||
CreateWindow(SDL_Appname, TEXT(""), style, x, y, w, h, NULL, NULL,
|
||||
SDL_Instance, NULL);
|
||||
WIN_PumpEvents(_this);
|
||||
|
||||
if (title) {
|
||||
SDL_free(title);
|
||||
}
|
||||
|
||||
if (!hwnd) {
|
||||
WIN_SetError("Couldn't create window");
|
||||
return -1;
|
||||
|
@ -277,7 +255,6 @@ WIN_SetWindowPosition(_THIS, SDL_Window * window)
|
|||
DWORD style;
|
||||
HWND top;
|
||||
int x, y;
|
||||
int w, h;
|
||||
|
||||
/* Figure out what the window area will be */
|
||||
if (window->flags & SDL_WINDOW_FULLSCREEN) {
|
||||
|
@ -293,24 +270,10 @@ WIN_SetWindowPosition(_THIS, SDL_Window * window)
|
|||
AdjustWindowRectEx(&rect, style,
|
||||
(style & WS_CHILDWINDOW) ? FALSE : (GetMenu(hwnd) !=
|
||||
NULL), 0);
|
||||
w = (rect.right - rect.left);
|
||||
h = (rect.bottom - rect.top);
|
||||
x = window->x + rect.left;
|
||||
y = window->y + rect.top;
|
||||
|
||||
if ((window->flags & SDL_WINDOW_FULLSCREEN) ||
|
||||
window->x == SDL_WINDOWPOS_CENTERED) {
|
||||
x = (GetSystemMetrics(SM_CXSCREEN) - w) / 2;
|
||||
window->x = x - rect.left;
|
||||
} else {
|
||||
x = window->x + rect.left;
|
||||
}
|
||||
if ((window->flags & SDL_WINDOW_FULLSCREEN) ||
|
||||
window->y == SDL_WINDOWPOS_CENTERED) {
|
||||
y = (GetSystemMetrics(SM_CYSCREEN) - h) / 2;
|
||||
window->y = y - rect.top;
|
||||
} else {
|
||||
y = window->y + rect.top;
|
||||
}
|
||||
SetWindowPos(hwnd, top, x, y, h, w, (SWP_NOCOPYBITS | SWP_NOSIZE));
|
||||
SetWindowPos(hwnd, top, x, y, 0, 0, (SWP_NOCOPYBITS | SWP_NOSIZE));
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -438,8 +401,6 @@ WIN_GetWindowWMInfo(_THIS, SDL_Window * window, SDL_SysWMinfo * info)
|
|||
HWND hwnd = ((SDL_WindowData *) window->driverdata)->hwnd;
|
||||
if (info->version.major <= SDL_MAJOR_VERSION) {
|
||||
info->window = hwnd;
|
||||
/* FIXME! */
|
||||
info->hglrc = NULL;
|
||||
return SDL_TRUE;
|
||||
} else {
|
||||
SDL_SetError("Application not compiled with SDL %d.%d\n",
|
||||
|
|
|
@ -113,8 +113,7 @@ X11_GL_LoadLibrary(_THIS, const char *path)
|
|||
if (!_this->gl_data->glXChooseVisual ||
|
||||
!_this->gl_data->glXCreateContext ||
|
||||
!_this->gl_data->glXDestroyContext ||
|
||||
!_this->gl_data->glXMakeCurrent ||
|
||||
!_this->gl_data->glXSwapBuffers) {
|
||||
!_this->gl_data->glXMakeCurrent || !_this->gl_data->glXSwapBuffers) {
|
||||
SDL_SetError("Could not retrieve OpenGL functions");
|
||||
return -1;
|
||||
}
|
||||
|
|
|
@ -193,8 +193,7 @@ X11_CreateWindow(_THIS, SDL_Window * window)
|
|||
visual, AllocNone);
|
||||
}
|
||||
|
||||
if ((window->flags & SDL_WINDOW_FULLSCREEN) ||
|
||||
window->x == SDL_WINDOWPOS_CENTERED) {
|
||||
if (window->x == SDL_WINDOWPOS_CENTERED) {
|
||||
x = (DisplayWidth(data->display, displaydata->screen) -
|
||||
window->w) / 2;
|
||||
} else if (window->x == SDL_WINDOWPOS_UNDEFINED) {
|
||||
|
@ -202,8 +201,7 @@ X11_CreateWindow(_THIS, SDL_Window * window)
|
|||
} else {
|
||||
x = window->x;
|
||||
}
|
||||
if ((window->flags & SDL_WINDOW_FULLSCREEN) ||
|
||||
window->y == SDL_WINDOWPOS_CENTERED) {
|
||||
if (window->y == SDL_WINDOWPOS_CENTERED) {
|
||||
y = (DisplayHeight(data->display, displaydata->screen) -
|
||||
window->h) / 2;
|
||||
} else if (window->y == SDL_WINDOWPOS_UNDEFINED) {
|
||||
|
@ -360,14 +358,7 @@ X11_CreateWindow(_THIS, SDL_Window * window)
|
|||
wmhints = XAllocWMHints();
|
||||
if (wmhints) {
|
||||
wmhints->input = True;
|
||||
if (window->flags & SDL_WINDOW_MINIMIZED) {
|
||||
wmhints->initial_state = IconicState;
|
||||
} else if (window->flags & SDL_WINDOW_SHOWN) {
|
||||
wmhints->initial_state = NormalState;
|
||||
} else {
|
||||
wmhints->initial_state = WithdrawnState;
|
||||
}
|
||||
wmhints->flags = InputHint | StateHint;
|
||||
wmhints->flags = InputHint;
|
||||
XSetWMHints(data->display, w, wmhints);
|
||||
XFree(wmhints);
|
||||
}
|
||||
|
@ -391,16 +382,6 @@ X11_CreateWindow(_THIS, SDL_Window * window)
|
|||
/* Allow the window to be deleted by the window manager */
|
||||
XSetWMProtocols(data->display, w, &data->WM_DELETE_WINDOW, 1);
|
||||
|
||||
/* Finally, show the window */
|
||||
if (window->flags & SDL_WINDOW_SHOWN) {
|
||||
XEvent event;
|
||||
|
||||
XMapRaised(data->display, w);
|
||||
do {
|
||||
XCheckWindowEvent(data->display, w, StructureNotifyMask, &event);
|
||||
} while (event.type != MapNotify);
|
||||
}
|
||||
|
||||
if (SetupWindowData(_this, window, w, SDL_TRUE) < 0) {
|
||||
#ifdef SDL_VIDEO_OPENGL_GLX
|
||||
if (window->flags & SDL_WINDOW_OPENGL) {
|
||||
|
@ -410,9 +391,6 @@ X11_CreateWindow(_THIS, SDL_Window * window)
|
|||
XDestroyWindow(data->display, w);
|
||||
return -1;
|
||||
}
|
||||
|
||||
X11_SetWindowTitle(_this, window);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -510,25 +488,8 @@ X11_SetWindowPosition(_THIS, SDL_Window * window)
|
|||
SDL_DisplayData *displaydata =
|
||||
(SDL_DisplayData *) SDL_GetDisplayFromWindow(window)->driverdata;
|
||||
Display *display = data->videodata->display;
|
||||
int x, y;
|
||||
|
||||
if ((window->flags & SDL_WINDOW_FULLSCREEN) ||
|
||||
window->x == SDL_WINDOWPOS_CENTERED) {
|
||||
x = (DisplayWidth(display, displaydata->screen) - window->w) / 2;
|
||||
} else if (window->x == SDL_WINDOWPOS_UNDEFINED) {
|
||||
x = 0;
|
||||
} else {
|
||||
x = window->x;
|
||||
}
|
||||
if ((window->flags & SDL_WINDOW_FULLSCREEN) ||
|
||||
window->y == SDL_WINDOWPOS_CENTERED) {
|
||||
y = (DisplayHeight(display, displaydata->screen) - window->h) / 2;
|
||||
} else if (window->y == SDL_WINDOWPOS_UNDEFINED) {
|
||||
y = 0;
|
||||
} else {
|
||||
y = window->y;
|
||||
}
|
||||
XMoveWindow(display, data->window, x, y);
|
||||
XMoveWindow(display, data->window, window->x, window->y);
|
||||
}
|
||||
|
||||
void
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue