mirror of https://github.com/encounter/SDL.git
Mac: Added a hint to opt-out of new Spaces code.
This commit is contained in:
parent
3889d47887
commit
9e67444a36
|
@ -347,6 +347,26 @@ extern "C" {
|
||||||
*/
|
*/
|
||||||
#define SDL_HINT_VIDEO_WINDOW_SHARE_PIXEL_FORMAT "SDL_VIDEO_WINDOW_SHARE_PIXEL_FORMAT"
|
#define SDL_HINT_VIDEO_WINDOW_SHARE_PIXEL_FORMAT "SDL_VIDEO_WINDOW_SHARE_PIXEL_FORMAT"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief A variable that dictates policy for fullscreen Spaces on Mac OS X.
|
||||||
|
*
|
||||||
|
* This hint only applies to Mac OS X.
|
||||||
|
*
|
||||||
|
* The variable can be set to the following values:
|
||||||
|
* "0" - Disable Spaces support (FULLSCREEN_DESKTOP won't use them and
|
||||||
|
* SDL_WINDOW_RESIZABLE windows won't offer the "fullscreen"
|
||||||
|
* button on their titlebars).
|
||||||
|
* "1" - Enable Spaces support (FULLSCREEN_DESKTOP will use them and
|
||||||
|
* SDL_WINDOW_RESIZABLE windows will offer the "fullscreen"
|
||||||
|
* button on their titlebars.
|
||||||
|
*
|
||||||
|
* The default value is "1". Spaces are disabled regardless of this hint if
|
||||||
|
* the OS isn't at least Mac OS X Lion (10.7). This hint must be set before
|
||||||
|
* any windows are created.
|
||||||
|
*/
|
||||||
|
#define SDL_HINT_VIDEO_MAC_FULLSCREEN_SPACES "SDL_VIDEO_MAC_FULLSCREEN_SPACES"
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief An enumeration of hint priorities
|
* \brief An enumeration of hint priorities
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -46,6 +46,7 @@
|
||||||
typedef struct SDL_VideoData
|
typedef struct SDL_VideoData
|
||||||
{
|
{
|
||||||
SInt32 osversion;
|
SInt32 osversion;
|
||||||
|
int allow_spaces;
|
||||||
unsigned int modifierFlags;
|
unsigned int modifierFlags;
|
||||||
void *key_layout;
|
void *key_layout;
|
||||||
SDLTranslatorResponder *fieldEdit;
|
SDLTranslatorResponder *fieldEdit;
|
||||||
|
|
|
@ -148,9 +148,15 @@ VideoBootStrap COCOA_bootstrap = {
|
||||||
int
|
int
|
||||||
Cocoa_VideoInit(_THIS)
|
Cocoa_VideoInit(_THIS)
|
||||||
{
|
{
|
||||||
|
SDL_VideoData *data = (SDL_VideoData *) _this->driverdata;
|
||||||
|
|
||||||
Cocoa_InitModes(_this);
|
Cocoa_InitModes(_this);
|
||||||
Cocoa_InitKeyboard(_this);
|
Cocoa_InitKeyboard(_this);
|
||||||
Cocoa_InitMouse(_this);
|
Cocoa_InitMouse(_this);
|
||||||
|
|
||||||
|
const char *hint = SDL_GetHint(SDL_HINT_VIDEO_MAC_FULLSCREEN_SPACES);
|
||||||
|
data->allow_spaces = ( (data->osversion >= 0x1070) && (!hint || (*hint != '0')) );
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -38,6 +38,7 @@
|
||||||
#include "SDL_cocoashape.h"
|
#include "SDL_cocoashape.h"
|
||||||
#include "SDL_cocoamouse.h"
|
#include "SDL_cocoamouse.h"
|
||||||
#include "SDL_cocoaopengl.h"
|
#include "SDL_cocoaopengl.h"
|
||||||
|
#include "SDL_assert.h"
|
||||||
|
|
||||||
/* #define DEBUG_COCOAWINDOW */
|
/* #define DEBUG_COCOAWINDOW */
|
||||||
|
|
||||||
|
@ -121,9 +122,7 @@ GetWindowStyle(SDL_Window * window)
|
||||||
{
|
{
|
||||||
unsigned int style;
|
unsigned int style;
|
||||||
|
|
||||||
if ((window->flags & SDL_WINDOW_FULLSCREEN_DESKTOP) == SDL_WINDOW_FULLSCREEN_DESKTOP) {
|
if (window->flags & SDL_WINDOW_FULLSCREEN) {
|
||||||
style = (NSTitledWindowMask|NSClosableWindowMask|NSMiniaturizableWindowMask);
|
|
||||||
} else if (window->flags & SDL_WINDOW_FULLSCREEN) {
|
|
||||||
style = NSBorderlessWindowMask;
|
style = NSBorderlessWindowMask;
|
||||||
} else {
|
} else {
|
||||||
if (window->flags & SDL_WINDOW_BORDERLESS) {
|
if (window->flags & SDL_WINDOW_BORDERLESS) {
|
||||||
|
@ -262,11 +261,12 @@ SetWindowStyle(SDL_Window * window, unsigned int style)
|
||||||
{
|
{
|
||||||
SDL_Window *window = _data->window;
|
SDL_Window *window = _data->window;
|
||||||
NSWindow *nswindow = _data->nswindow;
|
NSWindow *nswindow = _data->nswindow;
|
||||||
|
SDL_VideoData *videodata = ((SDL_WindowData *) window->driverdata)->videodata;
|
||||||
|
|
||||||
if (state && ((window->flags & SDL_WINDOW_FULLSCREEN_DESKTOP) != SDL_WINDOW_FULLSCREEN_DESKTOP)) {
|
if (!videodata->allow_spaces) {
|
||||||
|
return NO; /* Spaces are forcibly disabled. */
|
||||||
|
} else if (state && ((window->flags & SDL_WINDOW_FULLSCREEN_DESKTOP) != SDL_WINDOW_FULLSCREEN_DESKTOP)) {
|
||||||
return NO; /* we only allow you to make a Space on FULLSCREEN_DESKTOP windows. */
|
return NO; /* we only allow you to make a Space on FULLSCREEN_DESKTOP windows. */
|
||||||
} else if (![nswindow respondsToSelector: @selector(toggleFullScreen:)]) {
|
|
||||||
return NO; /* No Spaces support? Older Mac OS X? */
|
|
||||||
} else if (state == isFullscreenSpace) {
|
} else if (state == isFullscreenSpace) {
|
||||||
return YES; /* already there. */
|
return YES; /* already there. */
|
||||||
}
|
}
|
||||||
|
@ -281,7 +281,7 @@ SetWindowStyle(SDL_Window * window, unsigned int style)
|
||||||
}
|
}
|
||||||
inFullscreenTransition = YES;
|
inFullscreenTransition = YES;
|
||||||
|
|
||||||
/* you need to be FullScreenPrimary, or toggleFullScreen doesn't work. Unset it again in windowDid[Enter|Exit]FullScreen. */
|
/* you need to be FullScreenPrimary, or toggleFullScreen doesn't work. Unset it again in windowDidExitFullScreen. */
|
||||||
[nswindow setCollectionBehavior:NSWindowCollectionBehaviorFullScreenPrimary];
|
[nswindow setCollectionBehavior:NSWindowCollectionBehaviorFullScreenPrimary];
|
||||||
[nswindow performSelectorOnMainThread: @selector(toggleFullScreen:) withObject:nswindow waitUntilDone:NO];
|
[nswindow performSelectorOnMainThread: @selector(toggleFullScreen:) withObject:nswindow waitUntilDone:NO];
|
||||||
return YES;
|
return YES;
|
||||||
|
@ -987,6 +987,7 @@ SetupWindowData(_THIS, SDL_Window * window, NSWindow *nswindow, SDL_bool created
|
||||||
int
|
int
|
||||||
Cocoa_CreateWindow(_THIS, SDL_Window * window)
|
Cocoa_CreateWindow(_THIS, SDL_Window * window)
|
||||||
{
|
{
|
||||||
|
SDL_VideoData *videodata = (SDL_VideoData *) _this->driverdata;
|
||||||
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
|
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
|
||||||
NSWindow *nswindow;
|
NSWindow *nswindow;
|
||||||
SDL_VideoDisplay *display = SDL_GetDisplayForWindow(window);
|
SDL_VideoDisplay *display = SDL_GetDisplayForWindow(window);
|
||||||
|
@ -1031,7 +1032,9 @@ Cocoa_CreateWindow(_THIS, SDL_Window * window)
|
||||||
}
|
}
|
||||||
[nswindow setBackgroundColor:[NSColor blackColor]];
|
[nswindow setBackgroundColor:[NSColor blackColor]];
|
||||||
|
|
||||||
if ([nswindow respondsToSelector: @selector(toggleFullScreen:)]) {
|
if (videodata->allow_spaces) {
|
||||||
|
SDL_assert(videodata->osversion >= 0x1070);
|
||||||
|
SDL_assert([nswindow respondsToSelector:@selector(toggleFullScreen:)]);
|
||||||
/* we put FULLSCREEN_DESKTOP windows in their own Space, without a toggle button or menubar, later */
|
/* we put FULLSCREEN_DESKTOP windows in their own Space, without a toggle button or menubar, later */
|
||||||
if (window->flags & SDL_WINDOW_RESIZABLE) {
|
if (window->flags & SDL_WINDOW_RESIZABLE) {
|
||||||
/* resizable windows are Spaces-friendly: they get the "go fullscreen" toggle button on their titlebar. */
|
/* resizable windows are Spaces-friendly: they get the "go fullscreen" toggle button on their titlebar. */
|
||||||
|
|
Loading…
Reference in New Issue