From 18ebcc1156363266e9a36aa0236009d5fd542e97 Mon Sep 17 00:00:00 2001 From: Christian Muehlhaeuser Date: Wed, 16 Jan 2013 13:15:46 +0100 Subject: [PATCH] * Added Tomahawk::toggleFullscreen on OSX. --- src/mac/TomahawkApp_Mac.h | 1 + src/mac/TomahawkApp_Mac.mm | 20 ++++++++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/src/mac/TomahawkApp_Mac.h b/src/mac/TomahawkApp_Mac.h index e258c6719..5de03cc04 100644 --- a/src/mac/TomahawkApp_Mac.h +++ b/src/mac/TomahawkApp_Mac.h @@ -46,6 +46,7 @@ void setApplicationHandler(PlatformInterface* handler); void checkForUpdates(); // Pass in a QObject with slots "fullScreenEntered() and fullScreenExited() in order to be notified +void toggleFullscreen(); void enableFullscreen( QObject* notifier ); }; diff --git a/src/mac/TomahawkApp_Mac.mm b/src/mac/TomahawkApp_Mac.mm index ef4e81e07..3d856ba13 100644 --- a/src/mac/TomahawkApp_Mac.mm +++ b/src/mac/TomahawkApp_Mac.mm @@ -250,6 +250,26 @@ void Tomahawk::checkForUpdates() { #define LION_FULLSCREEN_EXIT_NOTIFICATION_VALUE @"NSWindowDidExitFullScreenNotification" #endif +void Tomahawk::toggleFullscreen() +{ + if ( QSysInfo::MacintoshVersion != QSysInfo::MV_SNOWLEOPARD && + QSysInfo::MacintoshVersion != QSysInfo::MV_LEOPARD ) + { + qDebug() << "Toggling Lion Full-screeen"; + // Can't include TomahawkApp.h in a .mm file, pulls in InfoSystem.h which uses + // the objc keyword 'id' + foreach( QWidget* w, QApplication::topLevelWidgets() ) + { + if ( qobject_cast< TomahawkWindow* >( w ) ) + { + NSView *nsview = (NSView *)w->winId(); + NSWindow *nswindow = [nsview window]; + [nswindow toggleFullScreen: nil]; + } + } + } +} + void Tomahawk::enableFullscreen( QObject* receiver ) { // We don't support anything below leopard, so if it's not [snow] leopard it must be lion