Change: [OSX] Hide Dock and menu during fullscreen mode.

pull/217/head
Michael Lutz 3 years ago
parent 784a4ef9b5
commit c860a247d3

@ -140,7 +140,7 @@ public:
/** Toggle between fullscreen and windowed mode
* @return whether switch was successful
*/
virtual bool ToggleFullscreen() { return false; };
virtual bool ToggleFullscreen(bool fullscreen) { return false; };
/** Return the width of the current view
* @return width of the current view

@ -175,7 +175,7 @@ void QZ_GameSizeChanged()
static CocoaSubdriver *QZ_CreateSubdriver(int width, int height, int bpp, bool fullscreen, bool fallback)
{
CocoaSubdriver *ret = QZ_CreateWindowQuartzSubdriver(width, height, bpp);
if (ret != nullptr && fullscreen) ret->ToggleFullscreen();
if (ret != nullptr && fullscreen) ret->ToggleFullscreen(fullscreen);
if (ret != nullptr) return ret;
if (!fallback) return nullptr;
@ -297,7 +297,7 @@ bool VideoDriver_Cocoa::ToggleFullscreen(bool full_screen)
{
assert(_cocoa_subdriver != NULL);
return _cocoa_subdriver->ToggleFullscreen();
return _cocoa_subdriver->ToggleFullscreen(full_screen);
}
/**
@ -355,8 +355,8 @@ public:
virtual bool ChangeResolution(int w, int h, int bpp);
virtual bool IsFullscreen() { return false; }
virtual bool ToggleFullscreen(); /* Full screen mode on OSX 10.7 */
virtual bool IsFullscreen();
virtual bool ToggleFullscreen(bool fullscreen); /* Full screen mode on OSX 10.7 */
virtual int GetWidth() { return window_width; }
virtual int GetHeight() { return window_height; }
@ -474,11 +474,18 @@ void WindowQuartzSubdriver::GetDeviceInfo()
CGDisplayModeRelease(cur_mode);
}
bool WindowQuartzSubdriver::IsFullscreen()
{
return this->window != nil && ([ this->window styleMask ] & NSWindowStyleMaskFullScreen) != 0;
}
/** Switch to full screen mode on OSX 10.7
* @return Whether we switched to full screen
*/
bool WindowQuartzSubdriver::ToggleFullscreen()
bool WindowQuartzSubdriver::ToggleFullscreen(bool fullscreen)
{
if (this->IsFullscreen() == fullscreen) return true;
if ([ this->window respondsToSelector:@selector(toggleFullScreen:) ]) {
[ this->window performSelector:@selector(toggleFullScreen:) withObject:this->window ];
return true;
@ -531,8 +538,6 @@ bool WindowQuartzSubdriver::SetVideoMode(int width, int height, int bpp)
NSButton* fullscreenButton = [ this->window standardWindowButton:NSWindowFullScreenButton ];
[ fullscreenButton setAction:@selector(toggleFullScreen:) ];
[ fullscreenButton setTarget:this->window ];
[ this->window setCollectionBehavior: NSWindowCollectionBehaviorFullScreenPrimary ];
}
[ this->window setDriver:this ];

@ -67,6 +67,7 @@ extern NSString *OTTDMainLaunchGameEngine;
- (BOOL)windowShouldClose:(id)sender;
- (void)windowDidEnterFullScreen:(NSNotification *)aNotification;
- (void)windowDidChangeScreenProfile:(NSNotification *)aNotification;
- (NSApplicationPresentationOptions)window:(NSWindow *)window willUseFullScreenPresentationOptions:(NSApplicationPresentationOptions)proposedOptions;
@end

@ -860,5 +860,11 @@ static const char *Utf8AdvanceByUtf16Units(const char *str, NSUInteger count)
if (!driver->setup) driver->WindowResized();
}
/** Presentation options to use for fullsreen mode. */
- (NSApplicationPresentationOptions)window:(NSWindow *)window willUseFullScreenPresentationOptions:(NSApplicationPresentationOptions)proposedOptions
{
return NSApplicationPresentationFullScreen | NSApplicationPresentationHideMenuBar | NSApplicationPresentationHideDock;
}
@end
#endif /* WITH_COCOA */

Loading…
Cancel
Save