diff options
author | planetmaker <planetmaker@openttd.org> | 2011-09-04 17:49:08 +0000 |
---|---|---|
committer | planetmaker <planetmaker@openttd.org> | 2011-09-04 17:49:08 +0000 |
commit | bce482c76fca80f38aba591eb687754207ba7aa4 (patch) | |
tree | 1e4a56ff32a9dc08d1ec78cdd619c0b4f4c5bb56 /src/video/cocoa/wnd_quartz.mm | |
parent | 5001b27cced8fb84283392cbbc44b67c30513d9e (diff) | |
download | openttd-bce482c76fca80f38aba591eb687754207ba7aa4.tar.xz |
(svn r22893) -Fix [FS#4744]: [OSX] Compilation on OSX 10.7 was broken (based on patch by leecbaker)
-Add: [OSX] Support for fullscreen mode when compiled against SDK 10.7. Otherwise fullscreen mode is disabled when OpenTTD is run on OSX Lion
Diffstat (limited to 'src/video/cocoa/wnd_quartz.mm')
-rw-r--r-- | src/video/cocoa/wnd_quartz.mm | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/src/video/cocoa/wnd_quartz.mm b/src/video/cocoa/wnd_quartz.mm index 0f2b4b0ad..356b7ac7e 100644 --- a/src/video/cocoa/wnd_quartz.mm +++ b/src/video/cocoa/wnd_quartz.mm @@ -78,6 +78,7 @@ public: virtual bool ChangeResolution(int w, int h); virtual bool IsFullscreen() { return false; } + virtual bool ToggleFullscreen(); /* Full screen mode on OSX 10.7 */ virtual int GetWidth() { return window_width; } virtual int GetHeight() { return window_height; } @@ -220,6 +221,19 @@ void WindowQuartzSubdriver::GetDeviceInfo() ); } +/** Switch to full screen mode on OSX 10.7 + * @return Whether we switched to full screen + */ +bool WindowQuartzSubdriver::ToggleFullscreen() +{ +#if (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_7) + [this->window toggleFullScreen:this->window]; + return true; +#else + return false; +#endif +} + bool WindowQuartzSubdriver::SetVideoMode(int width, int height) { this->setup = true; @@ -252,6 +266,29 @@ bool WindowQuartzSubdriver::SetVideoMode(int width, int height) return false; } + /* Add built in full-screen support when available (OS X 10.7 and higher) + * This code actually compiles for 10.5 and later, but only makes sense in conjunction + * with the quartz fullscreen support as found only in 10.7 and later + */ +#if (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_7) + if ([this->window respondsToSelector:@selector(toggleFullScreen:)]) { + /* Constants needed to build on pre-10.7 systems. Source: NSWindow documentation. */ + const int NSWindowCollectionBehaviorFullScreenPrimary = 1 << 7; + const int NSWindowFullScreenButton = 7; + + NSWindowCollectionBehavior behavior = [this->window collectionBehavior]; + behavior |= NSWindowCollectionBehaviorFullScreenPrimary; + [window setCollectionBehavior:behavior]; + + NSButton* fullscreenButton = + [this->window standardWindowButton:NSWindowFullScreenButton]; + [fullscreenButton setAction:@selector(toggleFullScreen:)]; + [fullscreenButton setTarget:this->window]; + + [this->window setCollectionBehavior: NSWindowCollectionBehaviorFullScreenPrimary]; + } +#endif + [ this->window setDriver:this ]; char caption[50]; |