From a1361dfa7e3057dc046f80f662cbbcaa594c624b Mon Sep 17 00:00:00 2001 From: John Maguire Date: Tue, 9 Oct 2012 14:56:17 +0200 Subject: [PATCH] Enable fullscreen support for OS X 10.7+ Fixes issue #2329 --- src/core/mac_startup.h | 2 ++ src/core/mac_startup.mm | 15 +++++++++++++++ src/main.cpp | 3 +++ 3 files changed, 20 insertions(+) diff --git a/src/core/mac_startup.h b/src/core/mac_startup.h index c4c603dd2..a0ff9e8b7 100644 --- a/src/core/mac_startup.h +++ b/src/core/mac_startup.h @@ -5,6 +5,7 @@ class MacGlobalShortcutBackend; class QObject; +class QWidget; class PlatformInterface { public: @@ -28,6 +29,7 @@ QString GetApplicationSupportPath(); QString GetMusicDirectory(); bool MigrateLegacyConfigFiles(); +void EnableFullScreen(const QWidget& main_window); } // namespace mac diff --git a/src/core/mac_startup.mm b/src/core/mac_startup.mm index 7e5bc7b84..cd2a78a48 100644 --- a/src/core/mac_startup.mm +++ b/src/core/mac_startup.mm @@ -52,11 +52,13 @@ #import #endif +#include #include #include #include #include #include +#include #include @@ -472,4 +474,17 @@ void DumpDictionary(CFDictionaryRef dict) { NSLog(@"%@", d); } +// NSWindowCollectionBehaviorFullScreenPrimary +static const NSUInteger kFullScreenPrimary = 1 << 7; + +void EnableFullScreen(const QWidget& main_window) { + if (QSysInfo::MacintoshVersion == QSysInfo::MV_SNOWLEOPARD) { + return; // Unsupported on 10.6 + } + + NSView* view = reinterpret_cast(main_window.winId()); + NSWindow* window = [view window]; + [window setCollectionBehavior: kFullScreenPrimary]; +} + } // namespace mac diff --git a/src/main.cpp b/src/main.cpp index de707a376..8ffa494f8 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -431,6 +431,9 @@ int main(int argc, char *argv[]) { // Window MainWindow w(&app, tray_icon.get(), &osd); +#ifdef Q_OS_DARWIN + mac::EnableFullScreen(w); +#endif // Q_OS_DARWIN #ifdef HAVE_GIO ScanGIOModulePath(); #endif