Window coordinates are in the global space and windows are not tied to a particular display.
Also added Ctrl-Enter keybinding to the test code to toggle fullscreen mode for testing.
This commit is contained in:
parent
2c021d9b34
commit
018af55e16
21 changed files with 300 additions and 190 deletions
|
@ -113,12 +113,20 @@ typedef enum
|
|||
/**
|
||||
* \brief Used to indicate that you don't care what the window position is.
|
||||
*/
|
||||
#define SDL_WINDOWPOS_UNDEFINED 0x7FFFFFF
|
||||
#define SDL_WINDOWPOS_UNDEFINED_MASK 0x1FFF0000
|
||||
#define SDL_WINDOWPOS_UNDEFINED_DISPLAY(X) (SDL_WINDOWPOS_UNDEFINED_MASK|(X))
|
||||
#define SDL_WINDOWPOS_UNDEFINED SDL_WINDOWPOS_UNDEFINED_DISPLAY(0)
|
||||
#define SDL_WINDOWPOS_ISUNDEFINED(X) \
|
||||
(((X)&0xFFFF0000) == SDL_WINDOWPOS_UNDEFINED_MASK)
|
||||
|
||||
/**
|
||||
* \brief Used to indicate that the window position should be centered.
|
||||
*/
|
||||
#define SDL_WINDOWPOS_CENTERED 0x7FFFFFE
|
||||
#define SDL_WINDOWPOS_CENTERED_MASK 0x2FFF0000
|
||||
#define SDL_WINDOWPOS_CENTERED_DISPLAY(X) (SDL_WINDOWPOS_CENTERED_MASK|(X))
|
||||
#define SDL_WINDOWPOS_CENTERED SDL_WINDOWPOS_CENTERED_DISPLAY(0)
|
||||
#define SDL_WINDOWPOS_ISCENTERED(X) \
|
||||
(((X)&0xFFFF0000) == SDL_WINDOWPOS_CENTERED_MASK)
|
||||
|
||||
/**
|
||||
* \brief Event subtype for window events
|
||||
|
@ -303,6 +311,14 @@ extern DECLSPEC int SDLCALL SDL_GetCurrentDisplayMode(int displayIndex, SDL_Disp
|
|||
*/
|
||||
extern DECLSPEC SDL_DisplayMode * SDLCALL SDL_GetClosestDisplayMode(int displayIndex, const SDL_DisplayMode * mode, SDL_DisplayMode * closest);
|
||||
|
||||
/**
|
||||
* \brief Get the display index associated with a window.
|
||||
*
|
||||
* \return the display index of the display containing the center of the
|
||||
* window, or -1 on error.
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_GetWindowDisplay(SDL_Window * window);
|
||||
|
||||
/**
|
||||
* \brief Set the display mode used when a fullscreen window is visible.
|
||||
*
|
||||
|
@ -531,7 +547,7 @@ extern DECLSPEC void SDLCALL SDL_RestoreWindow(SDL_Window * window);
|
|||
* \sa SDL_GetWindowDisplayMode()
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_SetWindowFullscreen(SDL_Window * window,
|
||||
int fullscreen);
|
||||
SDL_bool fullscreen);
|
||||
|
||||
/**
|
||||
* \brief Get an SDL surface associated with the window.
|
||||
|
|
|
@ -35,7 +35,7 @@ SDL_CreateShapedWindow(const char *title,unsigned int x,unsigned int y,unsigned
|
|||
SDL_Window *result = NULL;
|
||||
result = SDL_CreateWindow(title,-1000,-1000,w,h,(flags | SDL_WINDOW_BORDERLESS) & (~SDL_WINDOW_FULLSCREEN) & (~SDL_WINDOW_RESIZABLE) /*& (~SDL_WINDOW_SHOWN)*/);
|
||||
if(result != NULL) {
|
||||
result->shaper = result->display->device->shape_driver.CreateShaper(result);
|
||||
result->shaper = SDL_GetVideoDevice()->shape_driver.CreateShaper(result);
|
||||
if(result->shaper != NULL) {
|
||||
result->shaper->userx = x;
|
||||
result->shaper->usery = y;
|
||||
|
@ -240,7 +240,7 @@ SDL_SetWindowShape(SDL_Window *window,SDL_Surface *shape,SDL_WindowShapeMode *sh
|
|||
|
||||
if(shape_mode != NULL)
|
||||
window->shaper->mode = *shape_mode;
|
||||
result = window->display->device->shape_driver.SetWindowShape(window->shaper,shape,shape_mode);
|
||||
result = SDL_GetVideoDevice()->shape_driver.SetWindowShape(window->shaper,shape,shape_mode);
|
||||
window->shaper->hasshape = SDL_TRUE;
|
||||
if(window->shaper->userx != 0 && window->shaper->usery != 0) {
|
||||
SDL_SetWindowPosition(window,window->shaper->userx,window->shaper->usery);
|
||||
|
|
|
@ -76,8 +76,6 @@ struct SDL_Window
|
|||
int w, h;
|
||||
Uint32 flags;
|
||||
|
||||
SDL_VideoDisplay *display;
|
||||
|
||||
SDL_DisplayMode fullscreen_mode;
|
||||
|
||||
SDL_Surface *surface;
|
||||
|
@ -110,7 +108,6 @@ struct SDL_VideoDisplay
|
|||
SDL_DisplayMode current_mode;
|
||||
SDL_bool updating_fullscreen;
|
||||
|
||||
SDL_Window *windows;
|
||||
SDL_Window *fullscreen_window;
|
||||
|
||||
SDL_VideoDevice *device;
|
||||
|
@ -153,8 +150,7 @@ struct SDL_VideoDevice
|
|||
int (*GetDisplayBounds) (_THIS, SDL_VideoDisplay * display, SDL_Rect * rect);
|
||||
|
||||
/*
|
||||
* Get a list of the available display modes. e.g.
|
||||
* SDL_AddDisplayMode(_this->current_display, mode)
|
||||
* Get a list of the available display modes for a display.
|
||||
*/
|
||||
void (*GetDisplayModes) (_THIS, SDL_VideoDisplay * display);
|
||||
|
||||
|
@ -236,7 +232,7 @@ struct SDL_VideoDevice
|
|||
SDL_bool suspend_screensaver;
|
||||
int num_displays;
|
||||
SDL_VideoDisplay *displays;
|
||||
int current_display;
|
||||
SDL_Window *windows;
|
||||
Uint8 window_magic;
|
||||
Uint32 next_object_id;
|
||||
char * clipboard_text;
|
||||
|
@ -326,6 +322,7 @@ extern SDL_VideoDevice *SDL_GetVideoDevice(void);
|
|||
extern int SDL_AddBasicVideoDisplay(const SDL_DisplayMode * desktop_mode);
|
||||
extern int SDL_AddVideoDisplay(const SDL_VideoDisplay * display);
|
||||
extern SDL_bool SDL_AddDisplayMode(SDL_VideoDisplay *display, const SDL_DisplayMode * mode);
|
||||
extern SDL_VideoDisplay *SDL_GetDisplayForWindow(SDL_Window *window);
|
||||
|
||||
extern int SDL_RecreateWindow(SDL_Window * window, Uint32 flags);
|
||||
|
||||
|
|
|
@ -655,6 +655,12 @@ SDL_AddDisplayMode(SDL_VideoDisplay * display, const SDL_DisplayMode * mode)
|
|||
return SDL_TRUE;
|
||||
}
|
||||
|
||||
SDL_VideoDisplay *
|
||||
SDL_GetFirstDisplay(void)
|
||||
{
|
||||
return &_this->displays[0];
|
||||
}
|
||||
|
||||
static int
|
||||
SDL_GetNumDisplayModesForDisplay(SDL_VideoDisplay * display)
|
||||
{
|
||||
|
@ -892,6 +898,67 @@ SDL_SetDisplayModeForDisplay(SDL_VideoDisplay * display, const SDL_DisplayMode *
|
|||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
SDLCALL SDL_GetWindowDisplay(SDL_Window * window)
|
||||
{
|
||||
int displayIndex;
|
||||
int i, dist;
|
||||
int closest = -1;
|
||||
int closest_dist = 0x7FFFFFFF;
|
||||
SDL_Point center;
|
||||
SDL_Point delta;
|
||||
SDL_Rect rect;
|
||||
|
||||
CHECK_WINDOW_MAGIC(window, -1);
|
||||
|
||||
if (SDL_WINDOWPOS_ISUNDEFINED(window->x) ||
|
||||
SDL_WINDOWPOS_ISCENTERED(window->x)) {
|
||||
displayIndex = (window->x & 0xFFFF);
|
||||
if (displayIndex >= _this->num_displays) {
|
||||
displayIndex = 0;
|
||||
}
|
||||
return displayIndex;
|
||||
}
|
||||
if (SDL_WINDOWPOS_ISUNDEFINED(window->y) ||
|
||||
SDL_WINDOWPOS_ISCENTERED(window->y)) {
|
||||
displayIndex = (window->y & 0xFFFF);
|
||||
if (displayIndex >= _this->num_displays) {
|
||||
displayIndex = 0;
|
||||
}
|
||||
return displayIndex;
|
||||
}
|
||||
|
||||
/* Find the display containing the window */
|
||||
center.x = window->x + window->w / 2;
|
||||
center.y = window->y + window->h / 2;
|
||||
for (i = 0; i < _this->num_displays; ++i) {
|
||||
SDL_VideoDisplay *display = &_this->displays[i];
|
||||
|
||||
SDL_GetDisplayBounds(i, &rect);
|
||||
if (display->fullscreen_window == window || SDL_EnclosePoints(¢er, 1, &rect, NULL)) {
|
||||
return i;
|
||||
}
|
||||
|
||||
delta.x = center.x - (rect.x + rect.w / 2);
|
||||
delta.y = center.y - (rect.y + rect.h / 2);
|
||||
dist = (delta.x*delta.x + delta.y*delta.y);
|
||||
if (dist < closest_dist) {
|
||||
closest = i;
|
||||
closest_dist = dist;
|
||||
}
|
||||
}
|
||||
if (closest < 0) {
|
||||
SDL_SetError("Couldn't find any displays");
|
||||
}
|
||||
return closest;
|
||||
}
|
||||
|
||||
SDL_VideoDisplay *
|
||||
SDL_GetDisplayForWindow(SDL_Window *window)
|
||||
{
|
||||
return &_this->displays[SDL_GetWindowDisplay(window)];
|
||||
}
|
||||
|
||||
int
|
||||
SDL_SetWindowDisplayMode(SDL_Window * window, const SDL_DisplayMode * mode)
|
||||
{
|
||||
|
@ -920,7 +987,7 @@ SDL_GetWindowDisplayMode(SDL_Window * window, SDL_DisplayMode * mode)
|
|||
fullscreen_mode.h = window->h;
|
||||
}
|
||||
|
||||
if (!SDL_GetClosestDisplayModeForDisplay(window->display,
|
||||
if (!SDL_GetClosestDisplayModeForDisplay(SDL_GetDisplayForWindow(window),
|
||||
&fullscreen_mode,
|
||||
&fullscreen_mode)) {
|
||||
SDL_SetError("Couldn't find display mode match");
|
||||
|
@ -936,15 +1003,19 @@ SDL_GetWindowDisplayMode(SDL_Window * window, SDL_DisplayMode * mode)
|
|||
Uint32
|
||||
SDL_GetWindowPixelFormat(SDL_Window * window)
|
||||
{
|
||||
SDL_VideoDisplay *display = window->display;
|
||||
SDL_DisplayMode *displayMode = &display->current_mode;
|
||||
return displayMode->format;
|
||||
SDL_VideoDisplay *display;
|
||||
SDL_DisplayMode *displayMode;
|
||||
|
||||
CHECK_WINDOW_MAGIC(window, SDL_PIXELFORMAT_UNKNOWN);
|
||||
|
||||
display = SDL_GetDisplayForWindow(window);
|
||||
return display->current_mode.format;
|
||||
}
|
||||
|
||||
static void
|
||||
SDL_UpdateFullscreenMode(SDL_Window * window, SDL_bool attempt)
|
||||
{
|
||||
SDL_VideoDisplay *display = window->display;
|
||||
SDL_VideoDisplay *display = SDL_GetDisplayForWindow(window);
|
||||
|
||||
/* See if we're already processing a window */
|
||||
if (display->updating_fullscreen) {
|
||||
|
@ -971,19 +1042,17 @@ SDL_UpdateFullscreenMode(SDL_Window * window, SDL_bool attempt)
|
|||
|
||||
if (FULLSCREEN_VISIBLE(window)) {
|
||||
/* Hide any other fullscreen windows */
|
||||
SDL_Window *other;
|
||||
for (other = display->windows; other; other = other->next) {
|
||||
if (other != window && FULLSCREEN_VISIBLE(other)) {
|
||||
SDL_MinimizeWindow(other);
|
||||
}
|
||||
if (display->fullscreen_window != window) {
|
||||
SDL_MinimizeWindow(display->fullscreen_window);
|
||||
}
|
||||
}
|
||||
|
||||
display->updating_fullscreen = SDL_FALSE;
|
||||
|
||||
/* See if there are any fullscreen windows */
|
||||
for (window = display->windows; window; window = window->next) {
|
||||
if (FULLSCREEN_VISIBLE(window)) {
|
||||
for (window = _this->windows; window; window = window->next) {
|
||||
if (FULLSCREEN_VISIBLE(window) &&
|
||||
SDL_GetDisplayForWindow(window) == display) {
|
||||
SDL_DisplayMode fullscreen_mode;
|
||||
if (SDL_GetWindowDisplayMode(window, &fullscreen_mode) == 0) {
|
||||
SDL_SetDisplayModeForDisplay(display, &fullscreen_mode);
|
||||
|
@ -1022,7 +1091,6 @@ SDL_CreateWindow(const char *title, int x, int y, int w, int h, Uint32 flags)
|
|||
}
|
||||
SDL_GL_LoadLibrary(NULL);
|
||||
}
|
||||
display = &_this->displays[0]; /* FIXME */
|
||||
window = (SDL_Window *)SDL_calloc(1, sizeof(*window));
|
||||
window->magic = &_this->window_magic;
|
||||
window->id = _this->next_object_id++;
|
||||
|
@ -1031,12 +1099,11 @@ SDL_CreateWindow(const char *title, int x, int y, int w, int h, Uint32 flags)
|
|||
window->w = w;
|
||||
window->h = h;
|
||||
window->flags = (flags & allowed_flags);
|
||||
window->display = display;
|
||||
window->next = display->windows;
|
||||
if (display->windows) {
|
||||
display->windows->prev = window;
|
||||
window->next = _this->windows;
|
||||
if (_this->windows) {
|
||||
_this->windows->prev = window;
|
||||
}
|
||||
display->windows = window;
|
||||
_this->windows = window;
|
||||
|
||||
if (_this->CreateWindow && _this->CreateWindow(_this, window) < 0) {
|
||||
SDL_DestroyWindow(window);
|
||||
|
@ -1063,24 +1130,21 @@ SDL_CreateWindow(const char *title, int x, int y, int w, int h, Uint32 flags)
|
|||
SDL_Window *
|
||||
SDL_CreateWindowFrom(const void *data)
|
||||
{
|
||||
SDL_VideoDisplay *display;
|
||||
SDL_Window *window;
|
||||
|
||||
if (!_this) {
|
||||
SDL_UninitializedVideo();
|
||||
return NULL;
|
||||
}
|
||||
display = &_this->displays[0]; /* FIXME */
|
||||
window = (SDL_Window *)SDL_calloc(1, sizeof(*window));
|
||||
window->magic = &_this->window_magic;
|
||||
window->id = _this->next_object_id++;
|
||||
window->flags = SDL_WINDOW_FOREIGN;
|
||||
window->display = display;
|
||||
window->next = display->windows;
|
||||
if (display->windows) {
|
||||
display->windows->prev = window;
|
||||
window->next = _this->windows;
|
||||
if (_this->windows) {
|
||||
_this->windows->prev = window;
|
||||
}
|
||||
display->windows = window;
|
||||
_this->windows = window;
|
||||
|
||||
if (!_this->CreateWindowFrom ||
|
||||
_this->CreateWindowFrom(_this, window, data) < 0) {
|
||||
|
@ -1171,13 +1235,9 @@ SDL_GetWindowFromID(Uint32 id)
|
|||
if (!_this) {
|
||||
return NULL;
|
||||
}
|
||||
/* FIXME: Should we keep a separate hash table for these? */
|
||||
for (i = _this->num_displays; i--;) {
|
||||
SDL_VideoDisplay *display = &_this->displays[i];
|
||||
for (window = display->windows; window; window = window->next) {
|
||||
if (window->id == id) {
|
||||
return window;
|
||||
}
|
||||
for (window = _this->windows; window; window = window->next) {
|
||||
if (window->id == id) {
|
||||
return window;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
|
@ -1298,29 +1358,36 @@ SDL_SetWindowPosition(SDL_Window * window, int x, int y)
|
|||
if (y != SDL_WINDOWPOS_UNDEFINED) {
|
||||
window->y = y;
|
||||
}
|
||||
if (_this->SetWindowPosition) {
|
||||
_this->SetWindowPosition(_this, window);
|
||||
if (!(window->flags & SDL_WINDOW_FULLSCREEN)) {
|
||||
if (_this->SetWindowPosition) {
|
||||
_this->SetWindowPosition(_this, window);
|
||||
}
|
||||
SDL_SendWindowEvent(window, SDL_WINDOWEVENT_MOVED, x, y);
|
||||
}
|
||||
SDL_SendWindowEvent(window, SDL_WINDOWEVENT_MOVED, x, y);
|
||||
}
|
||||
|
||||
void
|
||||
SDL_GetWindowPosition(SDL_Window * window, int *x, int *y)
|
||||
{
|
||||
if (_this && window && window->magic == &_this->window_magic) {
|
||||
/* Clear the values */
|
||||
if (x) {
|
||||
*x = 0;
|
||||
}
|
||||
if (y) {
|
||||
*y = 0;
|
||||
}
|
||||
|
||||
CHECK_WINDOW_MAGIC(window, );
|
||||
|
||||
/* Fullscreen windows are always at their display's origin */
|
||||
if (window->flags & SDL_WINDOW_FULLSCREEN) {
|
||||
} else {
|
||||
if (x) {
|
||||
*x = window->x;
|
||||
}
|
||||
if (y) {
|
||||
*y = window->y;
|
||||
}
|
||||
} else {
|
||||
if (x) {
|
||||
*x = 0;
|
||||
}
|
||||
if (y) {
|
||||
*y = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1341,6 +1408,20 @@ SDL_SetWindowSize(SDL_Window * window, int w, int h)
|
|||
void
|
||||
SDL_GetWindowSize(SDL_Window * window, int *w, int *h)
|
||||
{
|
||||
int dummy;
|
||||
|
||||
if (!w) {
|
||||
w = &dummy;
|
||||
}
|
||||
if (!h) {
|
||||
h = &dummy;
|
||||
}
|
||||
|
||||
*w = 0;
|
||||
*h = 0;
|
||||
|
||||
CHECK_WINDOW_MAGIC(window, );
|
||||
|
||||
if (_this && window && window->magic == &_this->window_magic) {
|
||||
if (w) {
|
||||
*w = window->w;
|
||||
|
@ -1450,7 +1531,7 @@ SDL_RestoreWindow(SDL_Window * window)
|
|||
}
|
||||
|
||||
int
|
||||
SDL_SetWindowFullscreen(SDL_Window * window, int fullscreen)
|
||||
SDL_SetWindowFullscreen(SDL_Window * window, SDL_bool fullscreen)
|
||||
{
|
||||
CHECK_WINDOW_MAGIC(window, -1);
|
||||
|
||||
|
@ -1610,8 +1691,6 @@ SDL_OnWindowRestored(SDL_Window * window)
|
|||
void
|
||||
SDL_OnWindowFocusGained(SDL_Window * window)
|
||||
{
|
||||
SDL_VideoDisplay *display = window->display;
|
||||
|
||||
if ((window->flags & (SDL_WINDOW_INPUT_GRABBED | SDL_WINDOW_FULLSCREEN))
|
||||
&& _this->SetWindowGrab) {
|
||||
_this->SetWindowGrab(_this, window);
|
||||
|
@ -1621,8 +1700,6 @@ SDL_OnWindowFocusGained(SDL_Window * window)
|
|||
void
|
||||
SDL_OnWindowFocusLost(SDL_Window * window)
|
||||
{
|
||||
SDL_VideoDisplay *display = window->display;
|
||||
|
||||
/* If we're fullscreen on a single-head system and lose focus, minimize */
|
||||
if ((window->flags & SDL_WINDOW_FULLSCREEN) &&
|
||||
_this->num_displays == 1) {
|
||||
|
@ -1638,14 +1715,12 @@ SDL_OnWindowFocusLost(SDL_Window * window)
|
|||
SDL_Window *
|
||||
SDL_GetFocusWindow(void)
|
||||
{
|
||||
SDL_VideoDisplay *display;
|
||||
SDL_Window *window;
|
||||
|
||||
if (!_this) {
|
||||
return NULL;
|
||||
}
|
||||
display = &_this->displays[0]; /* FIXME */
|
||||
for (window = display->windows; window; window = window->next) {
|
||||
for (window = _this->windows; window; window = window->next) {
|
||||
if (window->flags & SDL_WINDOW_INPUT_FOCUS) {
|
||||
return window;
|
||||
}
|
||||
|
@ -1677,6 +1752,11 @@ SDL_DestroyWindow(SDL_Window * window)
|
|||
SDL_GL_UnloadLibrary();
|
||||
}
|
||||
|
||||
display = SDL_GetDisplayForWindow(window);
|
||||
if (display->fullscreen_window == window) {
|
||||
display->fullscreen_window = NULL;
|
||||
}
|
||||
|
||||
/* Now invalidate magic */
|
||||
window->magic = NULL;
|
||||
|
||||
|
@ -1693,14 +1773,13 @@ SDL_DestroyWindow(SDL_Window * window)
|
|||
}
|
||||
|
||||
/* Unlink the window from the list */
|
||||
display = window->display;
|
||||
if (window->next) {
|
||||
window->next->prev = window->prev;
|
||||
}
|
||||
if (window->prev) {
|
||||
window->prev->next = window->next;
|
||||
} else {
|
||||
display->windows = window->next;
|
||||
_this->windows = window->next;
|
||||
}
|
||||
|
||||
SDL_free(window);
|
||||
|
@ -1763,11 +1842,8 @@ SDL_VideoQuit(void)
|
|||
SDL_EnableScreenSaver();
|
||||
|
||||
/* Clean up the system video */
|
||||
for (i = _this->num_displays; i--;) {
|
||||
SDL_VideoDisplay *display = &_this->displays[i];
|
||||
while (display->windows) {
|
||||
SDL_DestroyWindow(display->windows);
|
||||
}
|
||||
while (_this->windows) {
|
||||
SDL_DestroyWindow(_this->windows);
|
||||
}
|
||||
_this->VideoQuit(_this);
|
||||
|
||||
|
|
|
@ -72,7 +72,7 @@ SDL_GLContext
|
|||
Cocoa_GL_CreateContext(_THIS, SDL_Window * window)
|
||||
{
|
||||
NSAutoreleasePool *pool;
|
||||
SDL_VideoDisplay *display = window->display;
|
||||
SDL_VideoDisplay *display = SDL_GetDisplayForWindow(window);
|
||||
SDL_DisplayData *displaydata = (SDL_DisplayData *)display->driverdata;
|
||||
NSOpenGLPixelFormatAttribute attr[32];
|
||||
NSOpenGLPixelFormat *fmt;
|
||||
|
|
|
@ -86,7 +86,6 @@ struct SDL_WindowData
|
|||
SDL_Window *window;
|
||||
NSWindow *nswindow;
|
||||
SDL_bool created;
|
||||
CGDirectDisplayID display;
|
||||
Cocoa_WindowListener *listener;
|
||||
struct SDL_VideoData *videodata;
|
||||
};
|
||||
|
|
|
@ -403,8 +403,6 @@ SetupWindowData(_THIS, SDL_Window * window, NSWindow *nswindow, SDL_bool created
|
|||
{
|
||||
NSAutoreleasePool *pool;
|
||||
SDL_VideoData *videodata = (SDL_VideoData *) _this->driverdata;
|
||||
SDL_VideoDisplay *display = window->display;
|
||||
SDL_DisplayData *displaydata = (SDL_DisplayData *) display->driverdata;
|
||||
SDL_WindowData *data;
|
||||
|
||||
/* Allocate the window data */
|
||||
|
@ -416,7 +414,6 @@ SetupWindowData(_THIS, SDL_Window * window, NSWindow *nswindow, SDL_bool created
|
|||
data->window = window;
|
||||
data->nswindow = nswindow;
|
||||
data->created = created;
|
||||
data->display = displaydata->display;
|
||||
data->videodata = videodata;
|
||||
|
||||
pool = [[NSAutoreleasePool alloc] init];
|
||||
|
@ -438,9 +435,8 @@ SetupWindowData(_THIS, SDL_Window * window, NSWindow *nswindow, SDL_bool created
|
|||
[contentView release];
|
||||
|
||||
ConvertNSRect(&rect);
|
||||
Cocoa_GetDisplayBounds(_this, display, &bounds);
|
||||
window->x = (int)rect.origin.x - bounds.x;
|
||||
window->y = (int)rect.origin.y - bounds.y;
|
||||
window->x = (int)rect.origin.x;
|
||||
window->y = (int)rect.origin.y;
|
||||
window->w = (int)rect.size.width;
|
||||
window->h = (int)rect.size.height;
|
||||
}
|
||||
|
@ -493,27 +489,27 @@ Cocoa_CreateWindow(_THIS, SDL_Window * window)
|
|||
{
|
||||
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
|
||||
NSWindow *nswindow;
|
||||
SDL_VideoDisplay *display = window->display;
|
||||
SDL_VideoDisplay *display = SDL_GetDisplayForWindow(window);
|
||||
NSRect rect;
|
||||
SDL_Rect bounds;
|
||||
unsigned int style;
|
||||
|
||||
Cocoa_GetDisplayBounds(_this, display, &bounds);
|
||||
if ((window->flags & SDL_WINDOW_FULLSCREEN)
|
||||
|| window->x == SDL_WINDOWPOS_CENTERED) {
|
||||
|| SDL_WINDOWPOS_ISCENTERED(window->x)) {
|
||||
rect.origin.x = bounds.x + (bounds.w - window->w) / 2;
|
||||
} else if (window->x == SDL_WINDOWPOS_UNDEFINED) {
|
||||
} else if (SDL_WINDOWPOS_ISUNDEFINED(window->x)) {
|
||||
rect.origin.x = bounds.x;
|
||||
} else {
|
||||
rect.origin.x = bounds.x + window->x;
|
||||
rect.origin.x = window->x;
|
||||
}
|
||||
if ((window->flags & SDL_WINDOW_FULLSCREEN)
|
||||
|| window->y == SDL_WINDOWPOS_CENTERED) {
|
||||
|| SDL_WINDOWPOS_ISCENTERED(window->y)) {
|
||||
rect.origin.y = bounds.y + (bounds.h - window->h) / 2;
|
||||
} else if (window->x == SDL_WINDOWPOS_UNDEFINED) {
|
||||
} else if (SDL_WINDOWPOS_ISUNDEFINED(window->y)) {
|
||||
rect.origin.y = bounds.y;
|
||||
} else {
|
||||
rect.origin.y = bounds.y + window->y;
|
||||
rect.origin.y = window->y;
|
||||
}
|
||||
rect.size.width = window->w;
|
||||
rect.size.height = window->h;
|
||||
|
@ -599,22 +595,22 @@ Cocoa_SetWindowPosition(_THIS, SDL_Window * window)
|
|||
{
|
||||
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
|
||||
NSWindow *nswindow = ((SDL_WindowData *) window->driverdata)->nswindow;
|
||||
SDL_VideoDisplay *display = window->display;
|
||||
SDL_VideoDisplay *display = SDL_GetDisplayForWindow(window);
|
||||
NSRect rect;
|
||||
SDL_Rect bounds;
|
||||
|
||||
Cocoa_GetDisplayBounds(_this, display, &bounds);
|
||||
if ((window->flags & SDL_WINDOW_FULLSCREEN)
|
||||
|| window->x == SDL_WINDOWPOS_CENTERED) {
|
||||
|| SDL_WINDOWPOS_ISCENTERED(window->x)) {
|
||||
rect.origin.x = bounds.x + (bounds.w - window->w) / 2;
|
||||
} else {
|
||||
rect.origin.x = bounds.x + window->x;
|
||||
rect.origin.x = window->x;
|
||||
}
|
||||
if ((window->flags & SDL_WINDOW_FULLSCREEN)
|
||||
|| window->y == SDL_WINDOWPOS_CENTERED) {
|
||||
|| SDL_WINDOWPOS_ISCENTERED(window->y)) {
|
||||
rect.origin.y = bounds.y + (bounds.h - window->h) / 2;
|
||||
} else {
|
||||
rect.origin.y = bounds.y + window->y;
|
||||
rect.origin.y = window->y;
|
||||
}
|
||||
rect.size.width = window->w;
|
||||
rect.size.height = window->h;
|
||||
|
|
|
@ -135,7 +135,7 @@ DirectFB_SetContext(_THIS, SDL_Window *window)
|
|||
* This has simply no effect.
|
||||
*/
|
||||
|
||||
SDL_VideoDisplay *display = window->display;
|
||||
SDL_VideoDisplay *display = SDL_GetDisplayForWindow(window);
|
||||
DFB_DisplayData *dispdata = (DFB_DisplayData *) display->driverdata;
|
||||
|
||||
/* FIXME: should we handle the error */
|
||||
|
|
|
@ -170,7 +170,7 @@ DirectFB_ShowCursor(SDL_Cursor * cursor)
|
|||
if (!window)
|
||||
return -1;
|
||||
else {
|
||||
SDL_VideoDisplay *display = window->display;
|
||||
SDL_VideoDisplay *display = SDL_GetDisplayForWindow(window);
|
||||
|
||||
if (display) {
|
||||
DFB_DisplayData *dispdata =
|
||||
|
@ -222,7 +222,7 @@ DirectFB_FreeCursor(SDL_Cursor * cursor)
|
|||
static void
|
||||
DirectFB_WarpMouse(SDL_Mouse * mouse, SDL_Window * window, int x, int y)
|
||||
{
|
||||
SDL_VideoDisplay *display = window->display;
|
||||
SDL_VideoDisplay *display = SDL_GetDisplayForWindow(window);
|
||||
DFB_DisplayData *dispdata = (DFB_DisplayData *) display->driverdata;
|
||||
DFB_WindowData *windata = (DFB_WindowData *) window->driverdata;
|
||||
DFBResult ret;
|
||||
|
|
|
@ -301,7 +301,7 @@ SDL_Renderer *
|
|||
DirectFB_CreateRenderer(SDL_Window * window, Uint32 flags)
|
||||
{
|
||||
SDL_DFB_WINDOWDATA(window);
|
||||
SDL_VideoDisplay *display = window->display;
|
||||
SDL_VideoDisplay *display = SDL_GetDisplayForWindow(window);
|
||||
SDL_Renderer *renderer = NULL;
|
||||
DirectFB_RenderData *data = NULL;
|
||||
DFBSurfaceCapabilities scaps;
|
||||
|
@ -409,7 +409,7 @@ DirectFB_AcquireVidLayer(SDL_Renderer * renderer, SDL_Texture * texture)
|
|||
{
|
||||
//SDL_DFB_RENDERERDATA(renderer);
|
||||
SDL_Window *window = renderer->window;
|
||||
SDL_VideoDisplay *display = window->display;
|
||||
SDL_VideoDisplay *display = SDL_GetDisplayForWindow(window);
|
||||
SDL_DFB_DEVICEDATA(display->device);
|
||||
DFB_DisplayData *dispdata = (DFB_DisplayData *) display->driverdata;
|
||||
DirectFB_TextureData *data = texture->driverdata;
|
||||
|
@ -465,7 +465,7 @@ static int
|
|||
DirectFB_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture)
|
||||
{
|
||||
SDL_Window *window = renderer->window;
|
||||
SDL_VideoDisplay *display = window->display;
|
||||
SDL_VideoDisplay *display = SDL_GetDisplayForWindow(window);
|
||||
SDL_DFB_DEVICEDATA(display->device);
|
||||
DirectFB_TextureData *data;
|
||||
DFBSurfaceDescription dsc;
|
||||
|
@ -1129,7 +1129,7 @@ static void
|
|||
DirectFB_DestroyRenderer(SDL_Renderer * renderer)
|
||||
{
|
||||
DirectFB_RenderData *data = (DirectFB_RenderData *) renderer->driverdata;
|
||||
SDL_VideoDisplay *display = renderer->window->display;
|
||||
SDL_VideoDisplay *display = renderer->SDL_GetDisplayForWindow(window);
|
||||
|
||||
#if 0
|
||||
if (display->palette) {
|
||||
|
|
|
@ -62,17 +62,17 @@ DirectFB_CreateWindow(_THIS, SDL_Window * window)
|
|||
bshaped = 1;
|
||||
|
||||
/* Fill the window description. */
|
||||
if (window->x == SDL_WINDOWPOS_CENTERED) {
|
||||
if (SDL_WINDOWPOS_ISCENTERED(window->x)) {
|
||||
x = (dispdata->cw - window->w) / 2;
|
||||
} else if (window->x == SDL_WINDOWPOS_UNDEFINED) {
|
||||
} else if (SDL_WINDOWPOS_ISUNDEFINED(window->x)) {
|
||||
x = 0;
|
||||
} else {
|
||||
x = window->x;
|
||||
}
|
||||
|
||||
if (window->y == SDL_WINDOWPOS_CENTERED) {
|
||||
if (SDL_WINDOWPOS_ISCENTERED(window->y)) {
|
||||
y = (dispdata->ch - window->h) / 2;
|
||||
} else if (window->y == SDL_WINDOWPOS_UNDEFINED) {
|
||||
} else if (SDL_WINDOWPOS_ISUNDEFINED(window->y)) {
|
||||
y = 0;
|
||||
} else {
|
||||
y = window->y;
|
||||
|
@ -264,17 +264,17 @@ DirectFB_SetWindowPosition(_THIS, SDL_Window * window)
|
|||
SDL_DFB_DISPLAYDATA(window);
|
||||
int x, y;
|
||||
|
||||
if (window->x == SDL_WINDOWPOS_CENTERED) {
|
||||
if (SDL_WINDOWPOS_ISCENTERED(window->x)) {
|
||||
x = (dispdata->cw - window->w) / 2;
|
||||
} else if (window->x == SDL_WINDOWPOS_UNDEFINED) {
|
||||
} else if (SDL_WINDOWPOS_ISUNDEFINED(window->x)) {
|
||||
x = 0;
|
||||
} else {
|
||||
x = window->x;
|
||||
}
|
||||
|
||||
if (window->y == SDL_WINDOWPOS_CENTERED) {
|
||||
if (SDL_WINDOWPOS_ISCENTERED(window->y)) {
|
||||
y = (dispdata->ch - window->h) / 2;
|
||||
} else if (window->y == SDL_WINDOWPOS_UNDEFINED) {
|
||||
} else if (SDL_WINDOWPOS_ISUNDEFINED(window->y)) {
|
||||
y = 0;
|
||||
} else {
|
||||
y = window->y;
|
||||
|
@ -358,7 +358,7 @@ void
|
|||
DirectFB_MaximizeWindow(_THIS, SDL_Window * window)
|
||||
{
|
||||
SDL_DFB_WINDOWDATA(window);
|
||||
SDL_VideoDisplay *display = window->display;
|
||||
SDL_VideoDisplay *display = SDL_GetDisplayForWindow(window);
|
||||
DFBWindowOptions wopts;
|
||||
|
||||
SDL_DFB_CHECK(windata->dfbwin->GetPosition(windata->dfbwin,
|
||||
|
@ -526,7 +526,7 @@ DirectFB_AdjustWindowSurface(SDL_Window * window)
|
|||
|
||||
if (adjust) {
|
||||
#if SDL_DIRECTFB_OPENGL
|
||||
DirectFB_GL_FreeWindowContexts(window->display->device, window);
|
||||
DirectFB_GL_FreeWindowContexts(SDL_GetVideoDevice(), window);
|
||||
#endif
|
||||
|
||||
#if (DFB_VERSION_ATLEAST(1,2,1))
|
||||
|
@ -552,10 +552,10 @@ DirectFB_AdjustWindowSurface(SDL_Window * window)
|
|||
GetSubSurface(windata->window_surface,
|
||||
&windata->client, &windata->surface));
|
||||
#endif
|
||||
DirectFB_WM_RedrawLayout(window->display->device, window);
|
||||
DirectFB_WM_RedrawLayout(SDL_GetVideoDevice(), window);
|
||||
|
||||
#if SDL_DIRECTFB_OPENGL
|
||||
DirectFB_GL_ReAllocWindowContexts(window->display->device, window);
|
||||
DirectFB_GL_ReAllocWindowContexts(SDL_GetVideoDevice(), window);
|
||||
#endif
|
||||
}
|
||||
error:
|
||||
|
|
|
@ -107,7 +107,7 @@ typedef struct
|
|||
SDL_Renderer *
|
||||
NDS_CreateRenderer(SDL_Window * window, Uint32 flags)
|
||||
{
|
||||
SDL_VideoDisplay *display = window->display;
|
||||
SDL_VideoDisplay *display = SDL_GetDisplayForWindow(window);
|
||||
SDL_DisplayMode *displayMode = &display->current_mode;
|
||||
SDL_Renderer *renderer;
|
||||
NDS_RenderData *data;
|
||||
|
@ -462,7 +462,7 @@ NDS_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture,
|
|||
NDS_RenderData *data = (NDS_RenderData *) renderer->driverdata;
|
||||
NDS_TextureData *txdat = (NDS_TextureData *) texture->driverdata;
|
||||
SDL_Window *window = renderer->window;
|
||||
SDL_VideoDisplay *display = window->display;
|
||||
SDL_VideoDisplay *display = SDL_GetDisplayForWindow(window);
|
||||
int Bpp = SDL_BYTESPERPIXEL(texture->format);
|
||||
|
||||
if (txdat->type == NDSTX_BG) {
|
||||
|
@ -487,7 +487,7 @@ NDS_RenderPresent(SDL_Renderer * renderer)
|
|||
{
|
||||
NDS_RenderData *data = (NDS_RenderData *) renderer->driverdata;
|
||||
SDL_Window *window = renderer->window;
|
||||
SDL_VideoDisplay *display = window->display;
|
||||
SDL_VideoDisplay *display = SDL_GetDisplayForWindow(window);
|
||||
|
||||
/* update sprites */
|
||||
// NDS_OAM_Update(&(data->oam_copy), data->sub);
|
||||
|
|
|
@ -417,7 +417,7 @@ PND_gl_createcontext(_THIS, SDL_Window * window)
|
|||
SDL_VideoData *phdata = (SDL_VideoData *) _this->driverdata;
|
||||
SDL_WindowData *wdata = (SDL_WindowData *) window->driverdata;
|
||||
SDL_DisplayData *didata =
|
||||
(SDL_DisplayData *) window->display->driverdata;
|
||||
(SDL_DisplayData *) SDL_GetDisplayForWindow(window)->driverdata;
|
||||
EGLBoolean status;
|
||||
int32_t gfstatus;
|
||||
EGLint configs;
|
||||
|
@ -816,7 +816,7 @@ PND_gl_swapwindow(_THIS, SDL_Window * window)
|
|||
SDL_VideoData *phdata = (SDL_VideoData *) _this->driverdata;
|
||||
SDL_WindowData *wdata = (SDL_WindowData *) window->driverdata;
|
||||
SDL_DisplayData *didata =
|
||||
(SDL_DisplayData *) window->display->driverdata;
|
||||
(SDL_DisplayData *) SDL_GetDisplayForWindow(window)->driverdata;
|
||||
|
||||
|
||||
if (phdata->egl_initialized != SDL_TRUE) {
|
||||
|
|
|
@ -103,7 +103,7 @@ SDL_GLContext UIKit_GL_CreateContext(_THIS, SDL_Window * window)
|
|||
{
|
||||
SDL_uikitopenglview *view;
|
||||
SDL_WindowData *data = (SDL_WindowData *) window->driverdata;
|
||||
UIScreen *uiscreen = (UIScreen *) window->display->driverdata;
|
||||
UIScreen *uiscreen = (UIScreen *) SDL_GetDisplayForWindow(window)->driverdata;
|
||||
UIWindow *uiwindow = data->uiwindow;
|
||||
|
||||
/* construct our view, passing in SDL's OpenGL configuration data */
|
||||
|
|
|
@ -40,7 +40,7 @@
|
|||
|
||||
static int SetupWindowData(_THIS, SDL_Window *window, UIWindow *uiwindow, SDL_bool created)
|
||||
{
|
||||
SDL_VideoDisplay *display = window->display;
|
||||
SDL_VideoDisplay *display = SDL_GetDisplayForWindow(window);
|
||||
UIScreen *uiscreen = (UIScreen *) display->driverdata;
|
||||
SDL_WindowData *data;
|
||||
|
||||
|
@ -85,9 +85,9 @@ static int SetupWindowData(_THIS, SDL_Window *window, UIWindow *uiwindow, SDL_bo
|
|||
}
|
||||
|
||||
int
|
||||
UIKit_CreateWindow(_THIS, SDL_Window *window) {
|
||||
|
||||
SDL_VideoDisplay *display = window->display;
|
||||
UIKit_CreateWindow(_THIS, SDL_Window *window)
|
||||
{
|
||||
SDL_VideoDisplay *display = SDL_GetDisplayForWindow(window);
|
||||
UIScreen *uiscreen = (UIScreen *) display->driverdata;
|
||||
|
||||
// SDL currently puts this window at the start of display's linked list. We rely on this.
|
||||
|
|
|
@ -46,7 +46,7 @@ static int
|
|||
SetupWindowData(_THIS, SDL_Window * window, HWND hwnd, SDL_bool created)
|
||||
{
|
||||
SDL_VideoData *videodata = (SDL_VideoData *) _this->driverdata;
|
||||
SDL_VideoDisplay *display = window->display;
|
||||
SDL_VideoDisplay *display = SDL_GetDisplayForWindow(window);
|
||||
SDL_WindowData *data;
|
||||
|
||||
/* Allocate the window data */
|
||||
|
@ -93,10 +93,8 @@ SetupWindowData(_THIS, SDL_Window * window, HWND hwnd, SDL_bool created)
|
|||
point.x = 0;
|
||||
point.y = 0;
|
||||
if (ClientToScreen(hwnd, &point)) {
|
||||
SDL_Rect bounds;
|
||||
WIN_GetDisplayBounds(_this, display, &bounds);
|
||||
window->x = point.x - bounds.x;
|
||||
window->y = point.y - bounds.y;
|
||||
window->x = point.x;
|
||||
window->y = point.y;
|
||||
}
|
||||
}
|
||||
{
|
||||
|
@ -166,7 +164,7 @@ SetupWindowData(_THIS, SDL_Window * window, HWND hwnd, SDL_bool created)
|
|||
int
|
||||
WIN_CreateWindow(_THIS, SDL_Window * window)
|
||||
{
|
||||
SDL_VideoDisplay *display = window->display;
|
||||
SDL_VideoDisplay *display = SDL_GetDisplayForWindow(window);
|
||||
HWND hwnd;
|
||||
RECT rect;
|
||||
SDL_Rect bounds;
|
||||
|
@ -203,28 +201,28 @@ WIN_CreateWindow(_THIS, SDL_Window * window)
|
|||
}
|
||||
}
|
||||
if ((window->flags & SDL_WINDOW_FULLSCREEN)
|
||||
|| window->x == SDL_WINDOWPOS_CENTERED) {
|
||||
|| SDL_WINDOWPOS_ISCENTERED(window->x)) {
|
||||
x = bounds.x + (bounds.w - w) / 2;
|
||||
} else if (window->x == SDL_WINDOWPOS_UNDEFINED) {
|
||||
} else if (SDL_WINDOWPOS_ISUNDEFINED(window->x)) {
|
||||
if (bounds.x == 0) {
|
||||
x = CW_USEDEFAULT;
|
||||
} else {
|
||||
x = bounds.x;
|
||||
}
|
||||
} else {
|
||||
x = bounds.x + window->x + rect.left;
|
||||
x = window->x + rect.left;
|
||||
}
|
||||
if ((window->flags & SDL_WINDOW_FULLSCREEN)
|
||||
|| window->y == SDL_WINDOWPOS_CENTERED) {
|
||||
|| SDL_WINDOWPOS_ISCENTERED(window->y)) {
|
||||
y = bounds.y + (bounds.h - h) / 2;
|
||||
} else if (window->x == SDL_WINDOWPOS_UNDEFINED) {
|
||||
} else if (SDL_WINDOWPOS_ISUNDEFINED(window->x)) {
|
||||
if (bounds.x == 0) {
|
||||
y = CW_USEDEFAULT;
|
||||
} else {
|
||||
y = bounds.y;
|
||||
}
|
||||
} else {
|
||||
y = bounds.y + window->y + rect.top;
|
||||
y = window->y + rect.top;
|
||||
}
|
||||
|
||||
hwnd =
|
||||
|
@ -366,7 +364,7 @@ WIN_SetWindowIcon(_THIS, SDL_Window * window, SDL_Surface * icon)
|
|||
void
|
||||
WIN_SetWindowPosition(_THIS, SDL_Window * window)
|
||||
{
|
||||
SDL_VideoDisplay *display = window->display;
|
||||
SDL_VideoDisplay *display = SDL_GetDisplayForWindow(window);
|
||||
HWND hwnd = ((SDL_WindowData *) window->driverdata)->hwnd;
|
||||
RECT rect;
|
||||
SDL_Rect bounds;
|
||||
|
@ -406,16 +404,16 @@ WIN_SetWindowPosition(_THIS, SDL_Window * window)
|
|||
}
|
||||
}
|
||||
if ((window->flags & SDL_WINDOW_FULLSCREEN)
|
||||
|| window->x == SDL_WINDOWPOS_CENTERED) {
|
||||
|| SDL_WINDOWPOS_ISCENTERED(window->x)) {
|
||||
x = bounds.x + (bounds.w - w) / 2;
|
||||
} else {
|
||||
x = bounds.x + window->x + rect.left;
|
||||
x = window->x + rect.left;
|
||||
}
|
||||
if ((window->flags & SDL_WINDOW_FULLSCREEN)
|
||||
|| window->y == SDL_WINDOWPOS_CENTERED) {
|
||||
|| SDL_WINDOWPOS_ISCENTERED(window->y)) {
|
||||
y = bounds.y + (bounds.h - h) / 2;
|
||||
} else {
|
||||
y = bounds.y + window->y + rect.top;
|
||||
y = window->y + rect.top;
|
||||
}
|
||||
|
||||
SetWindowPos(hwnd, top, x, y, 0, 0, (SWP_NOCOPYBITS | SWP_NOSIZE));
|
||||
|
@ -452,35 +450,35 @@ WIN_SetWindowSize(_THIS, SDL_Window * window)
|
|||
h = (rect.bottom - rect.top);
|
||||
|
||||
SetWindowPos(hwnd, top, 0, 0, w, h, (SWP_NOCOPYBITS | SWP_NOMOVE));
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef _WIN32_WCE
|
||||
void WINCE_ShowWindow(_THIS, SDL_Window* window, int visible)
|
||||
{
|
||||
SDL_WindowData* windowdata = (SDL_WindowData*) window->driverdata;
|
||||
SDL_VideoData *videodata = (SDL_VideoData *) _this->driverdata;
|
||||
|
||||
if(visible) {
|
||||
if(window->flags & SDL_WINDOW_FULLSCREEN) {
|
||||
if(videodata->SHFullScreen)
|
||||
videodata->SHFullScreen(windowdata->hwnd, SHFS_HIDETASKBAR | SHFS_HIDESTARTICON | SHFS_HIDESIPBUTTON);
|
||||
|
||||
ShowWindow(FindWindow(TEXT("HHTaskBar"), NULL), SW_HIDE);
|
||||
}
|
||||
|
||||
ShowWindow(windowdata->hwnd, SW_SHOW);
|
||||
SetForegroundWindow(windowdata->hwnd);
|
||||
} else {
|
||||
ShowWindow(windowdata->hwnd, SW_HIDE);
|
||||
|
||||
if(window->flags & SDL_WINDOW_FULLSCREEN) {
|
||||
if(videodata->SHFullScreen)
|
||||
videodata->SHFullScreen(windowdata->hwnd, SHFS_SHOWTASKBAR | SHFS_SHOWSTARTICON | SHFS_SHOWSIPBUTTON);
|
||||
|
||||
ShowWindow(FindWindow(TEXT("HHTaskBar"), NULL), SW_SHOW);
|
||||
|
||||
}
|
||||
}
|
||||
#ifdef _WIN32_WCE
|
||||
void WINCE_ShowWindow(_THIS, SDL_Window* window, int visible)
|
||||
{
|
||||
SDL_WindowData* windowdata = (SDL_WindowData*) window->driverdata;
|
||||
SDL_VideoData *videodata = (SDL_VideoData *) _this->driverdata;
|
||||
|
||||
if(visible) {
|
||||
if(window->flags & SDL_WINDOW_FULLSCREEN) {
|
||||
if(videodata->SHFullScreen)
|
||||
videodata->SHFullScreen(windowdata->hwnd, SHFS_HIDETASKBAR | SHFS_HIDESTARTICON | SHFS_HIDESIPBUTTON);
|
||||
|
||||
ShowWindow(FindWindow(TEXT("HHTaskBar"), NULL), SW_HIDE);
|
||||
}
|
||||
|
||||
ShowWindow(windowdata->hwnd, SW_SHOW);
|
||||
SetForegroundWindow(windowdata->hwnd);
|
||||
} else {
|
||||
ShowWindow(windowdata->hwnd, SW_HIDE);
|
||||
|
||||
if(window->flags & SDL_WINDOW_FULLSCREEN) {
|
||||
if(videodata->SHFullScreen)
|
||||
videodata->SHFullScreen(windowdata->hwnd, SHFS_SHOWTASKBAR | SHFS_SHOWSTARTICON | SHFS_SHOWSIPBUTTON);
|
||||
|
||||
ShowWindow(FindWindow(TEXT("HHTaskBar"), NULL), SW_SHOW);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif /* _WIN32_WCE */
|
||||
|
||||
|
|
|
@ -38,15 +38,11 @@
|
|||
static Window
|
||||
GetWindow(_THIS)
|
||||
{
|
||||
SDL_VideoDisplay *display;
|
||||
SDL_Window *window;
|
||||
|
||||
display = _this->displays;
|
||||
if (display) {
|
||||
window = display->windows;
|
||||
if (window) {
|
||||
return ((SDL_WindowData *) window->driverdata)->xwindow;
|
||||
}
|
||||
window = _this->windows;
|
||||
if (window) {
|
||||
return ((SDL_WindowData *) window->driverdata)->xwindow;
|
||||
}
|
||||
return None;
|
||||
}
|
||||
|
|
|
@ -380,7 +380,7 @@ X11_GL_CreateContext(_THIS, SDL_Window * window)
|
|||
SDL_WindowData *data = (SDL_WindowData *) window->driverdata;
|
||||
Display *display = data->videodata->display;
|
||||
int screen =
|
||||
((SDL_DisplayData *) window->display->driverdata)->screen;
|
||||
((SDL_DisplayData *) SDL_GetDisplayForWindow(window)->driverdata)->screen;
|
||||
XWindowAttributes xattr;
|
||||
XVisualInfo v, *vinfo;
|
||||
int n;
|
||||
|
|
|
@ -90,7 +90,7 @@ X11_GetDisplaySize(_THIS, SDL_Window * window, int *w, int *h)
|
|||
{
|
||||
SDL_VideoData *data = (SDL_VideoData *) _this->driverdata;
|
||||
SDL_DisplayData *displaydata =
|
||||
(SDL_DisplayData *) window->display->driverdata;
|
||||
(SDL_DisplayData *) SDL_GetDisplayForWindow(window)->driverdata;
|
||||
XWindowAttributes attr;
|
||||
|
||||
XGetWindowAttributes(data->display, RootWindow(data->display, displaydata->screen), &attr);
|
||||
|
@ -259,7 +259,7 @@ X11_CreateWindow(_THIS, SDL_Window * window)
|
|||
{
|
||||
SDL_VideoData *data = (SDL_VideoData *) _this->driverdata;
|
||||
SDL_DisplayData *displaydata =
|
||||
(SDL_DisplayData *) window->display->driverdata;
|
||||
(SDL_DisplayData *) SDL_GetDisplayForWindow(window)->driverdata;
|
||||
Display *display = data->display;
|
||||
int screen = displaydata->screen;
|
||||
Visual *visual;
|
||||
|
@ -328,19 +328,19 @@ X11_CreateWindow(_THIS, SDL_Window * window)
|
|||
xattr.colormap = XCreateColormap(display, RootWindow(display, screen), visual, AllocNone);
|
||||
|
||||
if (oldstyle_fullscreen
|
||||
|| window->x == SDL_WINDOWPOS_CENTERED) {
|
||||
|| SDL_WINDOWPOS_ISCENTERED(window->x)) {
|
||||
X11_GetDisplaySize(_this, window, &x, NULL);
|
||||
x = (x - window->w) / 2;
|
||||
} else if (window->x == SDL_WINDOWPOS_UNDEFINED) {
|
||||
} else if (SDL_WINDOWPOS_ISUNDEFINED(window->x)) {
|
||||
x = 0;
|
||||
} else {
|
||||
x = window->x;
|
||||
}
|
||||
if (oldstyle_fullscreen
|
||||
|| window->y == SDL_WINDOWPOS_CENTERED) {
|
||||
|| SDL_WINDOWPOS_ISCENTERED(window->y)) {
|
||||
X11_GetDisplaySize(_this, window, NULL, &y);
|
||||
y = (y - window->h) / 2;
|
||||
} else if (window->y == SDL_WINDOWPOS_UNDEFINED) {
|
||||
} else if (SDL_WINDOWPOS_ISUNDEFINED(window->y)) {
|
||||
y = 0;
|
||||
} else {
|
||||
y = window->y;
|
||||
|
@ -377,8 +377,8 @@ X11_CreateWindow(_THIS, SDL_Window * window)
|
|||
sizehints->flags = PMaxSize | PMinSize;
|
||||
}
|
||||
if (!oldstyle_fullscreen
|
||||
&& window->x != SDL_WINDOWPOS_UNDEFINED
|
||||
&& window->y != SDL_WINDOWPOS_UNDEFINED) {
|
||||
&& !SDL_WINDOWPOS_ISUNDEFINED(window->x)
|
||||
&& !SDL_WINDOWPOS_ISUNDEFINED(window->y)) {
|
||||
sizehints->x = x;
|
||||
sizehints->y = y;
|
||||
sizehints->flags |= USPosition;
|
||||
|
@ -713,14 +713,14 @@ X11_SetWindowPosition(_THIS, SDL_Window * window)
|
|||
oldstyle_fullscreen = X11_IsWindowOldFullscreen(_this, window);
|
||||
|
||||
if (oldstyle_fullscreen
|
||||
|| window->x == SDL_WINDOWPOS_CENTERED) {
|
||||
|| SDL_WINDOWPOS_ISCENTERED(window->x)) {
|
||||
X11_GetDisplaySize(_this, window, &x, NULL);
|
||||
x = (x - window->w) / 2;
|
||||
} else {
|
||||
x = window->x;
|
||||
}
|
||||
if (oldstyle_fullscreen
|
||||
|| window->y == SDL_WINDOWPOS_CENTERED) {
|
||||
|| SDL_WINDOWPOS_ISCENTERED(window->y)) {
|
||||
X11_GetDisplaySize(_this, window, NULL, &y);
|
||||
y = (y - window->h) / 2;
|
||||
} else {
|
||||
|
@ -777,7 +777,7 @@ X11_SetWindowMaximized(_THIS, SDL_Window * window, SDL_bool maximized)
|
|||
{
|
||||
SDL_WindowData *data = (SDL_WindowData *) window->driverdata;
|
||||
SDL_DisplayData *displaydata =
|
||||
(SDL_DisplayData *) window->display->driverdata;
|
||||
(SDL_DisplayData *) SDL_GetDisplayForWindow(window)->driverdata;
|
||||
Display *display = data->videodata->display;
|
||||
Atom _NET_WM_STATE = data->videodata->_NET_WM_STATE;
|
||||
Atom _NET_WM_STATE_MAXIMIZED_VERT = data->videodata->_NET_WM_STATE_MAXIMIZED_VERT;
|
||||
|
@ -832,7 +832,7 @@ X11_MinimizeWindow(_THIS, SDL_Window * window)
|
|||
{
|
||||
SDL_WindowData *data = (SDL_WindowData *) window->driverdata;
|
||||
SDL_DisplayData *displaydata =
|
||||
(SDL_DisplayData *) window->display->driverdata;
|
||||
(SDL_DisplayData *) SDL_GetDisplayForWindow(window)->driverdata;
|
||||
Display *display = data->videodata->display;
|
||||
|
||||
XIconifyWindow(display, data->xwindow, displaydata->screen);
|
||||
|
|
|
@ -1015,12 +1015,14 @@ CommonEvent(CommonState * state, SDL_Event * event, int *done)
|
|||
case SDLK_m:
|
||||
if (event->key.keysym.mod & KMOD_CTRL) {
|
||||
/* Ctrl-M maximize */
|
||||
/* FIXME: Which window has focus for this keyboard? */
|
||||
for (i = 0; i < state->num_windows; ++i) {
|
||||
if (SDL_GetWindowFlags(state->windows[i]) & SDL_WINDOW_MAXIMIZED) {
|
||||
SDL_RestoreWindow(state->windows[i]);
|
||||
} else {
|
||||
SDL_MaximizeWindow(state->windows[i]);
|
||||
Uint32 flags = SDL_GetWindowFlags(state->windows[i]);
|
||||
if (flags & SDL_WINDOW_INPUT_FOCUS) {
|
||||
if (flags & SDL_WINDOW_MAXIMIZED) {
|
||||
SDL_RestoreWindow(state->windows[i]);
|
||||
} else {
|
||||
SDL_MaximizeWindow(state->windows[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1028,9 +1030,26 @@ CommonEvent(CommonState * state, SDL_Event * event, int *done)
|
|||
case SDLK_z:
|
||||
if (event->key.keysym.mod & KMOD_CTRL) {
|
||||
/* Ctrl-Z minimize */
|
||||
/* FIXME: Which window has focus for this keyboard? */
|
||||
for (i = 0; i < state->num_windows; ++i) {
|
||||
SDL_MinimizeWindow(state->windows[i]);
|
||||
Uint32 flags = SDL_GetWindowFlags(state->windows[i]);
|
||||
if (flags & SDL_WINDOW_INPUT_FOCUS) {
|
||||
SDL_MinimizeWindow(state->windows[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
case SDLK_RETURN:
|
||||
if (event->key.keysym.mod & KMOD_CTRL) {
|
||||
/* Ctrl-Enter toggle fullscreen */
|
||||
for (i = 0; i < state->num_windows; ++i) {
|
||||
Uint32 flags = SDL_GetWindowFlags(state->windows[i]);
|
||||
if (flags & SDL_WINDOW_INPUT_FOCUS) {
|
||||
if (flags & SDL_WINDOW_FULLSCREEN) {
|
||||
SDL_SetWindowFullscreen(state->windows[i], SDL_FALSE);
|
||||
} else {
|
||||
SDL_SetWindowFullscreen(state->windows[i], SDL_TRUE);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
|
|
@ -49,6 +49,19 @@ main(int argc, char *argv[])
|
|||
/* Check for events */
|
||||
while (SDL_PollEvent(&event)) {
|
||||
CommonEvent(state, &event, &done);
|
||||
|
||||
if (event.type == SDL_WINDOWEVENT) {
|
||||
if (event.window.event == SDL_WINDOWEVENT_MOVED) {
|
||||
SDL_Window *window = SDL_GetWindowFromID(event.window.windowID);
|
||||
if (window) {
|
||||
printf("Window %d moved to %d,%d (display %d)\n",
|
||||
event.window.windowID,
|
||||
event.window.data1,
|
||||
event.window.data2,
|
||||
SDL_GetWindowDisplay(window));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
quit(0);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue