Skip to content

Commit

Permalink
Allow switching between FS and desktop FS.
Browse files Browse the repository at this point in the history
  • Loading branch information
jorgenpt committed Jan 15, 2014
1 parent a442f12 commit a0c9e64
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/video/SDL_sysvideo.h
Expand Up @@ -79,6 +79,7 @@ struct SDL_Window
int min_w, min_h;
int max_w, max_h;
Uint32 flags;
Uint32 last_fullscreen_flags;

/* Stored position and size for windowed mode */
SDL_Rect windowed;
Expand Down
14 changes: 12 additions & 2 deletions src/video/SDL_video.c
Expand Up @@ -115,6 +115,7 @@ static SDL_VideoDevice *_this = NULL;
return retval; \
}

#define FULLSCREEN_MASK ( SDL_WINDOW_FULLSCREEN_DESKTOP | SDL_WINDOW_FULLSCREEN )

#ifdef __MACOSX__
/* Support for Mac OS X fullscreen spaces */
Expand Down Expand Up @@ -1096,6 +1097,7 @@ SDL_UpdateFullscreenMode(SDL_Window * window, SDL_bool fullscreen)

#ifdef __MACOSX__
if (Cocoa_SetWindowFullscreenSpace(window, fullscreen)) {
window->last_fullscreen_flags = window->flags;
return;
}
#endif
Expand All @@ -1112,7 +1114,9 @@ SDL_UpdateFullscreenMode(SDL_Window * window, SDL_bool fullscreen)

/* See if anything needs to be done now */
if ((display->fullscreen_window == window) == fullscreen) {
return;
if ((window->last_fullscreen_flags & FULLSCREEN_MASK) == (window->flags & FULLSCREEN_MASK)) {
return;
}
}

/* See if there are any fullscreen windows */
Expand Down Expand Up @@ -1157,6 +1161,8 @@ SDL_UpdateFullscreenMode(SDL_Window * window, SDL_bool fullscreen)
}

SDL_RestoreMousePosition(other);

window->last_fullscreen_flags = window->flags;
return;
}
}
Expand All @@ -1175,6 +1181,8 @@ SDL_UpdateFullscreenMode(SDL_Window * window, SDL_bool fullscreen)

/* Restore the cursor position */
SDL_RestoreMousePosition(window);

window->last_fullscreen_flags = window->flags;
}

#define CREATE_FLAGS \
Expand Down Expand Up @@ -1277,6 +1285,7 @@ SDL_CreateWindow(const char *title, int x, int y, int w, int h, Uint32 flags)
}
}
window->flags = ((flags & CREATE_FLAGS) | SDL_WINDOW_HIDDEN);
window->last_fullscreen_flags = window->flags;
window->brightness = 1.0f;
window->next = _this->windows;

Expand Down Expand Up @@ -1318,6 +1327,7 @@ SDL_CreateWindowFrom(const void *data)
window->magic = &_this->window_magic;
window->id = _this->next_object_id++;
window->flags = SDL_WINDOW_FOREIGN;
window->last_fullscreen_flags = window->flags;
window->brightness = 1.0f;
window->next = _this->windows;
if (_this->windows) {
Expand Down Expand Up @@ -1378,6 +1388,7 @@ SDL_RecreateWindow(SDL_Window * window, Uint32 flags)
window->title = NULL;
window->icon = NULL;
window->flags = ((flags & CREATE_FLAGS) | SDL_WINDOW_HIDDEN);
window->last_fullscreen_flags = window->flags;

if (_this->CreateWindow && !(flags & SDL_WINDOW_FOREIGN)) {
if (_this->CreateWindow(_this, window) < 0) {
Expand Down Expand Up @@ -1857,7 +1868,6 @@ SDL_RestoreWindow(SDL_Window * window)
}
}

#define FULLSCREEN_MASK ( SDL_WINDOW_FULLSCREEN_DESKTOP | SDL_WINDOW_FULLSCREEN )
int
SDL_SetWindowFullscreen(SDL_Window * window, Uint32 flags)
{
Expand Down

0 comments on commit a0c9e64

Please sign in to comment.