From 435aa118acb49b658b3685d3682fc75eda671291 Mon Sep 17 00:00:00 2001 From: Claudio Cambra Date: Thu, 3 Nov 2022 02:12:25 +0100 Subject: [PATCH] macosx: Refactor setupVoutForWindow video window video activation for readability Signed-off-by: Claudio Cambra --- .../windows/video/VLCVideoOutputProvider.m | 27 +++++++++++-------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/modules/gui/macosx/windows/video/VLCVideoOutputProvider.m b/modules/gui/macosx/windows/video/VLCVideoOutputProvider.m index baa0adb2dd..c74975e92c 100644 --- a/modules/gui/macosx/windows/video/VLCVideoOutputProvider.m +++ b/modules/gui/macosx/windows/video/VLCVideoOutputProvider.m @@ -359,18 +359,28 @@ int WindowOpen(vlc_window_t *p_wnd) [videoWindow makeKeyAndOrderFront: self]; } +- (void)setupVideoOutputForVideoWindow:(VLCVideoWindowCommon *)videoWindow withVlcWindow:(vlc_window_t *)p_wnd +{ + VLCVoutView *voutView = videoWindow.videoView; + + [videoWindow setAlphaValue:config_GetFloat("macosx-opaqueness")]; + [_voutWindows setObject:videoWindow forKey:[NSValue valueWithPointer:p_wnd]]; + [voutView setVoutThread:(vout_thread_t *)vlc_object_parent(p_wnd)]; + videoWindow.hasActiveVideo = YES; + _playerController.activeVideoPlayback = YES; + [VLCMain sharedInstance].libraryWindow.nonembedded = !b_mainWindowHasVideo; +} + - (VLCVoutView *)setupVoutForWindow:(vlc_window_t *)p_wnd withProposedVideoViewPosition:(NSRect)videoViewPosition { - VLCMain *mainInstance = [VLCMain sharedInstance]; - _playerController = mainInstance.playlistController.playerController; + _playerController = [VLCMain sharedInstance].playlistController.playerController; VLCVideoWindowCommon *newVideoWindow = [self setupVideoWindow]; + VLCVoutView *voutView = newVideoWindow.videoView; BOOL isEmbedded = [newVideoWindow isKindOfClass:[VLCLibraryWindow class]]; BOOL multipleVoutWindows = _voutWindows.count > 0; BOOL videoWallpaper = var_InheritBool(getIntf(), "video-wallpaper") && !multipleVoutWindows; - VLCVoutView *voutView = newVideoWindow.videoView; - // Avoid flashes if video will directly start in fullscreen [NSAnimationContext beginGrouping]; @@ -378,13 +388,8 @@ int WindowOpen(vlc_window_t *p_wnd) [self setupPositionAndSizeForVideoWindow:newVideoWindow atPosition:videoViewPosition]; } - [newVideoWindow setAlphaValue:config_GetFloat("macosx-opaqueness")]; - [_voutWindows setObject:newVideoWindow forKey:[NSValue valueWithPointer:p_wnd]]; - [voutView setVoutThread:(vout_thread_t *)vlc_object_parent(p_wnd)]; - newVideoWindow.hasActiveVideo = YES; - _playerController.activeVideoPlayback = YES; - mainInstance.libraryWindow.nonembedded = !b_mainWindowHasVideo; - + [self setupVideoOutputForVideoWindow:newVideoWindow withVlcWindow:p_wnd]; + // TODO: find a cleaner way for "start in fullscreen" // Start in fs, because either prefs settings, or fullscreen button was pressed before /* detect the video-splitter and prevent starts in fullscreen if it is enabled */