From f1e8c225d27022f1fc307e24d526adeccb385ba4 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Felix=20Paul=20K=C3=BChne?= Date: Tue, 16 Aug 2011 14:09:30 +0200 Subject: [PATCH] macosx: added native fullscreen support for OS X Lion --- NEWS | 2 ++ modules/gui/macosx/AudioEffects.m | 2 ++ modules/gui/macosx/CoreInteraction.m | 11 ++------ modules/gui/macosx/MainWindow.m | 6 ++--- modules/gui/macosx/TrackSynchronization.m | 3 +++ modules/gui/macosx/VideoEffects.m | 3 +++ modules/gui/macosx/about.m | 6 +++++ modules/gui/macosx/bookmarks.m | 3 +++ modules/gui/macosx/fspanel.m | 4 ++- modules/gui/macosx/intf.h | 3 ++- modules/gui/macosx/intf.m | 31 +++++++++++++++++++---- modules/gui/macosx/open.m | 3 +++ modules/gui/macosx/playlistinfo.m | 2 ++ modules/gui/macosx/prefs.m | 3 +++ modules/gui/macosx/simple_prefs.m | 3 +++ modules/gui/macosx/wizard.m | 3 +++ 16 files changed, 69 insertions(+), 19 deletions(-) diff --git a/NEWS b/NEWS index 7e846a0086..8fe68810d7 100644 --- a/NEWS +++ b/NEWS @@ -83,6 +83,7 @@ Interfaces: * Mac OS X: new Track Synchronization panel * Mac OS X: new Video Effects panel for color and geometry adjustments * Mac OS X: re-written Open Disc functionality with automatic media detection + * Mac OS X: support for the native fullscreen mode on OS X Lion * The rc and telnet lua interfaces were merged into a new "cli" interface * dbus: Rewrite of the main loop to use a more efficient poll-based model * dbus: Upgrade to an mpris2 compliant interface, see http://www.mpris.org @@ -99,6 +100,7 @@ Video Output: chroma conversion * New video output for Android platform, based on Surface * Support for 9/10bits output in the OpenGL output + * Updated OpenGL video output for Mac, which requires a Quartz Extreme capable Mac Audio Output: * New audio output based on AudioQueue API for iOS diff --git a/modules/gui/macosx/AudioEffects.m b/modules/gui/macosx/AudioEffects.m index d64a54c64f..1af0c44fc5 100644 --- a/modules/gui/macosx/AudioEffects.m +++ b/modules/gui/macosx/AudioEffects.m @@ -102,6 +102,8 @@ static VLCAudioEffects *_o_sharedInstance = nil; [[o_tableView tabViewItemAtIndex:[o_tableView indexOfTabViewItemWithIdentifier:@"filter"]] setLabel:_NS("Filter")]; [o_window setTitle:_NS("Audio Effects")]; [o_window setExcludedFromWindowsMenu:YES]; + if (NSAppKitVersionNumber >= 1115.2) + [o_window setCollectionBehavior: NSWindowCollectionBehaviorFullScreenAuxiliary]; [self setupEqualizer]; [self resetCompressor]; diff --git a/modules/gui/macosx/CoreInteraction.m b/modules/gui/macosx/CoreInteraction.m index bef0158d6d..cc2af1e165 100644 --- a/modules/gui/macosx/CoreInteraction.m +++ b/modules/gui/macosx/CoreInteraction.m @@ -278,14 +278,7 @@ static VLCCoreInteraction *_o_sharedInstance = nil; - (void)toggleFullscreen { - input_thread_t * p_input = pl_CurrentInput( VLCIntf ); - - if( p_input != NULL ) - { - playlist_t * p_playlist = pl_Get( VLCIntf ); - var_ToggleBool( p_playlist, "fullscreen" ); - - vlc_object_release( p_input ); - } + playlist_t * p_playlist = pl_Get( VLCIntf ); + var_ToggleBool( p_playlist, "fullscreen" ); } @end diff --git a/modules/gui/macosx/MainWindow.m b/modules/gui/macosx/MainWindow.m index d3ec6aca40..2c9790ff06 100644 --- a/modules/gui/macosx/MainWindow.m +++ b/modules/gui/macosx/MainWindow.m @@ -218,6 +218,8 @@ static VLCMainWindow *_o_sharedInstance = nil; o_temp_view = [[NSView alloc] init]; [o_temp_view setAutoresizingMask:NSViewHeightSizable | NSViewWidthSizable]; [o_dropzone_view setFrame: [o_playlist_table frame]]; + if (NSAppKitVersionNumber >= 1115.2) + [self setCollectionBehavior: NSWindowCollectionBehaviorFullScreenPrimary]; /* create the sidebar */ o_sidebaritems = [[NSMutableArray alloc] init]; @@ -803,7 +805,7 @@ static VLCMainWindow *_o_sharedInstance = nil; { [o_video_view removeFromSuperviewWithoutNeedingDisplay]; [o_video_view setFrame: [o_split_view frame]]; - [[self contentView] addSubview: o_video_view]; + [[self contentView] addSubview:o_video_view positioned:NSWindowAbove relativeTo:nil]; } b_nonembedded = NO; } @@ -1313,8 +1315,6 @@ static VLCMainWindow *_o_sharedInstance = nil; /* fullscreenAnimation will be unlocked when animation ends */ } - - /* Make sure setFrame gets executed on main thread especially if we are animating. * (Thus we won't block the video output thread) */ - (void)setFrame:(NSRect)frame display:(BOOL)display animate:(BOOL)animate diff --git a/modules/gui/macosx/TrackSynchronization.m b/modules/gui/macosx/TrackSynchronization.m index 73da112874..848f7529fe 100644 --- a/modules/gui/macosx/TrackSynchronization.m +++ b/modules/gui/macosx/TrackSynchronization.m @@ -61,6 +61,9 @@ static VLCTrackSynchronization *_o_sharedInstance = nil; [o_sv_speed_lbl setStringValue: _NS("Speed of the subtitles:")]; [[o_sv_speed_value_fld formatter] setFormat:[NSString stringWithFormat:@"#,##0.000 %@", _NS("fps")]]; + if (NSAppKitVersionNumber >= 1115.2) + [o_window setCollectionBehavior: NSWindowCollectionBehaviorFullScreenAuxiliary]; + [self resetValues:self]; } diff --git a/modules/gui/macosx/VideoEffects.m b/modules/gui/macosx/VideoEffects.m index 00744f01f0..47aaf637ad 100644 --- a/modules/gui/macosx/VideoEffects.m +++ b/modules/gui/macosx/VideoEffects.m @@ -60,6 +60,9 @@ static VLCVideoEffects *_o_sharedInstance = nil; { [o_window setTitle: _NS("Video Effects")]; [o_window setExcludedFromWindowsMenu:YES]; + if (NSAppKitVersionNumber >= 1115.2) + [o_window setCollectionBehavior: NSWindowCollectionBehaviorFullScreenAuxiliary]; + [[o_tableView tabViewItemAtIndex:[o_tableView indexOfTabViewItemWithIdentifier:@"basic"]] setLabel:_NS("Basic")]; [[o_tableView tabViewItemAtIndex:[o_tableView indexOfTabViewItemWithIdentifier:@"crop"]] setLabel:_NS("Crop")]; [[o_tableView tabViewItemAtIndex:[o_tableView indexOfTabViewItemWithIdentifier:@"geometry"]] setLabel:_NS("Geometry")]; diff --git a/modules/gui/macosx/about.m b/modules/gui/macosx/about.m index 30ad0cb70a..bbd0b67477 100644 --- a/modules/gui/macosx/about.m +++ b/modules/gui/macosx/about.m @@ -67,6 +67,12 @@ static VLAboutBox *_o_sharedInstance = nil; [super dealloc]; } +- (void)awakeFromNib +{ + if (NSAppKitVersionNumber >= 1115.2) + [o_about_window setCollectionBehavior: NSWindowCollectionBehaviorFullScreenAuxiliary]; +} + /***************************************************************************** * VLC About Window *****************************************************************************/ diff --git a/modules/gui/macosx/bookmarks.m b/modules/gui/macosx/bookmarks.m index 7d0f9efbae..412c0f2952 100644 --- a/modules/gui/macosx/bookmarks.m +++ b/modules/gui/macosx/bookmarks.m @@ -71,6 +71,9 @@ static VLCBookmarks *_o_sharedInstance = nil; - (void)awakeFromNib { + if (NSAppKitVersionNumber >= 1115.2) + [o_bookmarks_window setCollectionBehavior: NSWindowCollectionBehaviorFullScreenAuxiliary]; + [self initStrings]; } diff --git a/modules/gui/macosx/fspanel.m b/modules/gui/macosx/fspanel.m index 7802af910c..85fabc1a86 100644 --- a/modules/gui/macosx/fspanel.m +++ b/modules/gui/macosx/fspanel.m @@ -49,7 +49,9 @@ [win setOpaque:NO]; [win setHasShadow: NO]; [win setBackgroundColor:[NSColor clearColor]]; - + if (NSAppKitVersionNumber >= 1115.2) + [win setCollectionBehavior: NSWindowCollectionBehaviorFullScreenAuxiliary]; + /* let the window sit on top of everything else and start out completely transparent */ [win setLevel:NSModalPanelWindowLevel]; i_device = 0; diff --git a/modules/gui/macosx/intf.h b/modules/gui/macosx/intf.h index 917dc6dc04..83a7391856 100644 --- a/modules/gui/macosx/intf.h +++ b/modules/gui/macosx/intf.h @@ -38,6 +38,7 @@ #include #import "SPMediaKeyTap.h" /* for the media key support */ #import "misc.h" +#import "MainWindow.h" /***************************************************************************** * Local prototypes. @@ -108,7 +109,7 @@ struct intf_sys_t BOOL nib_bookmarks_loaded; /* Bookmarks nibfile */ BOOL b_active_videoplayback; - id o_mainwindow; /* VLCMainWindow */ + VLCMainWindow *o_mainwindow; /* VLCMainWindow */ IBOutlet VLCControls * o_controls; /* VLCControls */ IBOutlet VLCPlaylist * o_playlist; /* VLCPlaylist */ diff --git a/modules/gui/macosx/intf.m b/modules/gui/macosx/intf.m index 54ae70f347..0642480bdc 100644 --- a/modules/gui/macosx/intf.m +++ b/modules/gui/macosx/intf.m @@ -41,7 +41,6 @@ #import "intf.h" #import "MainMenu.h" -#import "MainWindow.h" #import "vout.h" #import "prefs.h" #import "playlist.h" @@ -260,7 +259,6 @@ static int InputEvent( vlc_object_t *p_this, const char *psz_var, case INPUT_EVENT_ES: break; case INPUT_EVENT_TELETEXT: - NSLog( @"teletext" ); break; case INPUT_EVENT_AOUT: break; @@ -563,6 +561,9 @@ static VLCMain *_o_sharedMainInstance = nil; var_AddCallback(p_playlist, "volume", VolumeUpdated, self); var_AddCallback(p_playlist, "mute", VolumeUpdated, self); + if ([NSApp currentSystemPresentationOptions] == NSApplicationPresentationFullScreen) + var_SetBool( p_playlist, "fullscreen", YES ); + /* load our Core Dialogs nib */ nib_coredialogs_loaded = [NSBundle loadNibNamed:@"CoreDialogs" owner: NSApp]; @@ -1229,10 +1230,30 @@ unsigned int CocoaKeyToVLC( unichar i_key ) #pragma mark Interface updaters - (void)fullscreenChanged { - if(! [o_mainwindow isFullscreen] ) - [o_mainwindow performSelectorOnMainThread:@selector(enterFullscreen) withObject:nil waitUntilDone:NO]; + playlist_t * p_playlist = pl_Get( VLCIntf ); + BOOL b_fullscreen = var_GetBool( p_playlist, "fullscreen" ); + + if (NSAppKitVersionNumber >= 1115.2) + { + [o_mainwindow toggleFullScreen: self]; + if(b_fullscreen) + [NSApp setPresentationOptions:(NSApplicationPresentationFullScreen)]; + else + [NSApp setPresentationOptions:(NSApplicationPresentationDefault)]; + } else - [o_mainwindow performSelectorOnMainThread:@selector(leaveFullscreen) withObject:nil waitUntilDone:NO]; + { + input_thread_t * p_input = pl_CurrentInput( VLCIntf ); + + if( p_input != NULL ) + { + if(b_fullscreen) + [o_mainwindow performSelectorOnMainThread:@selector(enterFullscreen) withObject:nil waitUntilDone:NO]; + else + [o_mainwindow performSelectorOnMainThread:@selector(leaveFullscreen) withObject:nil waitUntilDone:NO]; + vlc_object_release( p_input ); + } + } } - (void)PlaylistItemChanged diff --git a/modules/gui/macosx/open.m b/modules/gui/macosx/open.m index f5a87182c4..d47f59329c 100644 --- a/modules/gui/macosx/open.m +++ b/modules/gui/macosx/open.m @@ -104,6 +104,9 @@ static VLCOpen *_o_sharedMainInstance = nil; - (void)awakeFromNib { + if (NSAppKitVersionNumber >= 1115.2) + [o_panel setCollectionBehavior: NSWindowCollectionBehaviorFullScreenAuxiliary]; + [o_panel setTitle: _NS("Open Source")]; [o_mrl_lbl setStringValue: _NS("Media Resource Locator (MRL)")]; diff --git a/modules/gui/macosx/playlistinfo.m b/modules/gui/macosx/playlistinfo.m index f40a06fe4e..77e3c303e2 100644 --- a/modules/gui/macosx/playlistinfo.m +++ b/modules/gui/macosx/playlistinfo.m @@ -69,6 +69,8 @@ static VLCInfo *_o_sharedInstance = nil; { [o_info_window setExcludedFromWindowsMenu: YES]; [o_info_window setFloatingPanel: NO]; + if (NSAppKitVersionNumber >= 1115.2) + [o_info_window setCollectionBehavior: NSWindowCollectionBehaviorFullScreenAuxiliary]; [o_info_window setTitle: _NS("Media Information")]; [o_uri_lbl setStringValue: _NS("Location")]; diff --git a/modules/gui/macosx/prefs.m b/modules/gui/macosx/prefs.m index 1bf3080886..03f977ba31 100644 --- a/modules/gui/macosx/prefs.m +++ b/modules/gui/macosx/prefs.m @@ -175,6 +175,9 @@ static VLCPrefs *_o_sharedMainInstance = nil; { p_intf = VLCIntf; + if (NSAppKitVersionNumber >= 1115.2) + [o_prefs_window setCollectionBehavior: NSWindowCollectionBehaviorFullScreenAuxiliary]; + [self initStrings]; [o_prefs_view setBorderType: NSGrooveBorder]; [o_prefs_view setHasVerticalScroller: YES]; diff --git a/modules/gui/macosx/simple_prefs.m b/modules/gui/macosx/simple_prefs.m index cd5b4dbb20..edf4f6e02d 100644 --- a/modules/gui/macosx/simple_prefs.m +++ b/modules/gui/macosx/simple_prefs.m @@ -104,6 +104,9 @@ static VLCSimplePrefs *_o_sharedInstance = nil; [o_sprefs_toolbar setDelegate: self]; [o_sprefs_win setToolbar: o_sprefs_toolbar]; + if (NSAppKitVersionNumber >= 1115.2) + [o_sprefs_win setCollectionBehavior: NSWindowCollectionBehaviorFullScreenAuxiliary]; + /* setup useful stuff */ o_hotkeysNonUseableKeys = [[NSArray arrayWithObjects: @"Command-c", @"Command-x", @"Command-v", @"Command-a", @"Command-," , @"Command-h", @"Command-Alt-h", @"Command-Shift-o", @"Command-o", @"Command-d", @"Command-n", @"Command-s", @"Command-z", @"Command-l", @"Command-r", @"Command-3", @"Command-m", @"Command-w", @"Command-Shift-w", @"Command-Shift-c", @"Command-Shift-p", @"Command-i", @"Command-e", @"Command-Shift-e", @"Command-b", @"Command-Shift-m", @"Command-Ctrl-m", @"Command-?", @"Command-Alt-?", nil] retain]; } diff --git a/modules/gui/macosx/wizard.m b/modules/gui/macosx/wizard.m index 5c462dfd0f..6cb06af4f0 100644 --- a/modules/gui/macosx/wizard.m +++ b/modules/gui/macosx/wizard.m @@ -71,6 +71,9 @@ static VLCWizard *_o_sharedInstance = nil; - (void)awakeFromNib { + if (NSAppKitVersionNumber >= 1115.2) + [o_wizard_window setCollectionBehavior: NSWindowCollectionBehaviorFullScreenAuxiliary]; + /* some minor cleanup */ [o_t2_tbl_plst setEnabled:NO]; o_userSelections = [[NSMutableDictionary alloc] init]; -- 2.39.2