Enable fullscreen support for OS X 10.7+

Fixes issue #2329
This commit is contained in:
John Maguire 2012-10-09 14:56:17 +02:00
parent 4a96ce9561
commit a1361dfa7e
3 changed files with 20 additions and 0 deletions

View File

@ -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

View File

@ -52,11 +52,13 @@
#import <Sparkle/SUUpdater.h>
#endif
#include <QApplication>
#include <QCoreApplication>
#include <QDir>
#include <QEvent>
#include <QFile>
#include <QSettings>
#include <QWidget>
#include <QtDebug>
@ -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<NSView*>(main_window.winId());
NSWindow* window = [view window];
[window setCollectionBehavior: kFullScreenPrimary];
}
} // namespace mac

View File

@ -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