macosx: Fix detached windows, remove need for VLCDetachedWindow

Signed-off-by: Claudio Cambra <developer@claudiocambra.com>
This commit is contained in:
Claudio Cambra 2023-02-22 13:11:07 +01:00 committed by Jean-Baptiste Kempf
parent ba01957e94
commit eb9eb1087b
3 changed files with 34 additions and 7 deletions

View File

@ -130,6 +130,7 @@ static void addShadow(NSImageView *__unsafe_unretained imageView)
- (void)awakeFromNib
{
[super awakeFromNib];
self.identifier = VLCLibraryWindowIdentifier;
if(@available(macOS 10.12, *)) {
@ -148,7 +149,6 @@ static void addShadow(NSImageView *__unsafe_unretained imageView)
self.navigationStack = [[VLCLibraryNavigationStack alloc] init];
self.navigationStack.delegate = self;
self.videoViewController = [[VLCMainVideoViewController alloc] init];
self.videoViewController.view.frame = self.mainSplitView.frame;
self.videoViewController.view.hidden = YES;
self.videoViewController.displayLibraryControls = YES;

View File

@ -281,9 +281,30 @@ int WindowOpen(vlc_window_t *p_wnd)
{
BOOL multipleVoutWindows = _voutWindows.count > 0;
// setup detached window with controls
NSWindowController *o_controller = [[NSWindowController alloc] initWithWindowNibName:@"DetachedVideoWindow"];
[o_controller loadWindow];
VLCVideoWindowCommon *newVideoWindow = (VLCDetachedVideoWindow *)o_controller.window;
NSWindowStyleMask mask = NSWindowStyleMaskClosable |
NSWindowStyleMaskMiniaturizable |
NSWindowStyleMaskResizable |
NSWindowStyleMaskTitled |
NSWindowStyleMaskFullSizeContentView;
VLCVideoWindowCommon *newVideoWindow = [[VLCAspectRatioRetainingVideoWindow alloc] initWithContentRect:NSMakeRect(0,0,300,300)
styleMask:mask
backing:NSBackingStoreBuffered
defer:YES];
newVideoWindow.backgroundColor = [NSColor blackColor];
newVideoWindow.canBecomeKeyWindow = YES;
newVideoWindow.canBecomeMainWindow = YES;
newVideoWindow.acceptsMouseMovedEvents = YES;
newVideoWindow.movableByWindowBackground = YES;
newVideoWindow.minSize = NSMakeSize(VLCVideoWindowCommonMinimalHeight, VLCVideoWindowCommonMinimalHeight);
newVideoWindow.titlebarAppearsTransparent = YES;
newVideoWindow.videoViewController = [[VLCMainVideoViewController alloc] init];
newVideoWindow.videoViewController.displayLibraryControls = NO;
newVideoWindow.videoViewController.view.autoresizingMask = NSViewWidthSizable | NSViewHeightSizable;
newVideoWindow.videoViewController.view.frame = newVideoWindow.contentView.frame;
[newVideoWindow.contentView addSubview:newVideoWindow.videoViewController.view positioned:NSWindowAbove relativeTo:nil];
// no frame autosave for additional vout windows
if (multipleVoutWindows) {
@ -292,6 +313,7 @@ int WindowOpen(vlc_window_t *p_wnd)
newVideoWindow.delegate = newVideoWindow;
newVideoWindow.level = NSNormalWindowLevel;
[newVideoWindow center];
return newVideoWindow;
}
@ -348,12 +370,12 @@ int WindowOpen(vlc_window_t *p_wnd)
// set (only!) window origin if specified
if (!isEmbedded) {
[self setupWindowOriginForVideoWindow:videoWindow
atPosition:videoViewPosition];
if ([videoWindow isKindOfClass:[VLCAspectRatioRetainingVideoWindow class]]) {
[(VLCAspectRatioRetainingVideoWindow*)videoWindow setNativeVideoSize:videoViewSize];
}
[self setupWindowOriginForVideoWindow:videoWindow
atPosition:videoViewPosition];
}
// cascade windows if we have more than one vout

View File

@ -94,6 +94,7 @@ NSString *VLCWindowShouldShowController = @"VLCWindowShouldShowController";
[o_temp_view setAutoresizingMask:NSViewHeightSizable | NSViewWidthSizable];
_playerController = [[[VLCMain sharedInstance] playlistController] playerController];
_videoViewController = [[VLCMainVideoViewController alloc] init];
}
return self;
@ -106,6 +107,10 @@ NSString *VLCWindowShouldShowController = @"VLCWindowShouldShowController";
- (void)awakeFromNib
{
if (_videoViewController == nil) {
_videoViewController = [[VLCMainVideoViewController alloc] init];
}
NSNotificationCenter *notificationCenter = [NSNotificationCenter defaultCenter];
[notificationCenter addObserver:self
selector:@selector(mediaMetadataChanged:)