2012-10-02 19:26:37 +02:00
|
|
|
/*****************************************************************************
|
2018-06-10 10:57:03 +02:00
|
|
|
* VLCVideoOutputProvider.m: MacOS X interface module
|
2012-10-02 19:26:37 +02:00
|
|
|
*****************************************************************************
|
2019-03-26 15:54:09 +01:00
|
|
|
* Copyright (C) 2012-2019 VLC authors and VideoLAN
|
2012-10-02 19:26:37 +02:00
|
|
|
*
|
|
|
|
* Authors: Felix Paul Kühne <fkuehne -at- videolan -dot- org>
|
|
|
|
* David Fuhrmann <david dot fuhrmann at googlemail dot com>
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
|
|
|
|
*****************************************************************************/
|
|
|
|
|
2019-02-01 17:54:34 +01:00
|
|
|
#import "VLCVideoOutputProvider.h"
|
|
|
|
|
2015-07-21 14:08:18 +02:00
|
|
|
#include <vlc_vout_display.h>
|
|
|
|
|
2019-02-01 17:54:34 +01:00
|
|
|
#import "extensions/NSScreen+VLCAdditions.h"
|
|
|
|
|
|
|
|
#import "main/CompatibilityFixes.h"
|
|
|
|
#import "main/VLCMain.h"
|
|
|
|
#import "windows/mainwindow/VLCMainWindow.h"
|
|
|
|
#import "windows/video/VLCDetachedVideoWindow.h"
|
|
|
|
#import "windows/video/VLCVoutView.h"
|
2019-03-26 15:54:09 +01:00
|
|
|
#import "playlist/VLCPlaylistController.h"
|
|
|
|
#import "playlist/VLCPlayerController.h"
|
2019-02-01 17:54:34 +01:00
|
|
|
|
|
|
|
#import "panels/dialogs/VLCResumeDialogController.h"
|
|
|
|
#import "panels/VLCVideoEffectsWindowController.h"
|
|
|
|
#import "panels/VLCAudioEffectsWindowController.h"
|
2019-03-10 19:00:57 +01:00
|
|
|
#import "panels/VLCInformationWindowController.h"
|
2019-02-01 17:54:34 +01:00
|
|
|
#import "panels/VLCBookmarksWindowController.h"
|
|
|
|
#import "panels/VLCTrackSynchronizationWindowController.h"
|
2013-01-12 16:29:26 +01:00
|
|
|
|
2018-12-02 19:40:26 +01:00
|
|
|
static int WindowEnable(vout_window_t *p_wnd, const vout_window_cfg_t *cfg)
|
2018-12-02 10:59:51 +01:00
|
|
|
{
|
|
|
|
@autoreleasepool {
|
2018-12-02 19:40:26 +01:00
|
|
|
msg_Dbg(p_wnd, "Opening video window");
|
|
|
|
|
|
|
|
NSRect proposedVideoViewPosition = NSMakeRect(cfg->x, cfg->y, cfg->width, cfg->height);
|
|
|
|
|
2018-12-02 10:59:51 +01:00
|
|
|
VLCVideoOutputProvider *voutProvider = [[VLCMain sharedInstance] voutProvider];
|
|
|
|
if (!voutProvider) {
|
2018-12-02 19:40:26 +01:00
|
|
|
return VLC_EGENERIC;
|
2018-12-02 10:59:51 +01:00
|
|
|
}
|
|
|
|
|
2018-12-02 19:40:26 +01:00
|
|
|
__block VLCVoutView *videoView = nil;
|
|
|
|
|
|
|
|
dispatch_sync(dispatch_get_main_queue(), ^{
|
|
|
|
videoView = [voutProvider setupVoutForWindow:p_wnd
|
|
|
|
withProposedVideoViewPosition:proposedVideoViewPosition];
|
|
|
|
});
|
|
|
|
|
|
|
|
// this method is not supposed to fail
|
|
|
|
assert(videoView != nil);
|
|
|
|
|
|
|
|
msg_Dbg(getIntf(), "returning videoview with proposed position x=%i, y=%i, width=%i, height=%i", cfg->x, cfg->y, cfg->width, cfg->height);
|
|
|
|
p_wnd->handle.nsobject = (void *)CFBridgingRetain(videoView);
|
|
|
|
}
|
|
|
|
if (cfg->is_fullscreen)
|
|
|
|
vout_window_SetFullScreen(p_wnd, NULL);
|
|
|
|
return VLC_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void WindowDisable(vout_window_t *p_wnd)
|
|
|
|
{
|
|
|
|
@autoreleasepool {
|
|
|
|
VLCVideoOutputProvider *voutProvider = [[VLCMain sharedInstance] voutProvider];
|
|
|
|
|
|
|
|
dispatch_async(dispatch_get_main_queue(), ^{
|
|
|
|
[voutProvider removeVoutForDisplay:[NSValue valueWithPointer:p_wnd]];
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void WindowResize(vout_window_t *p_wnd,
|
|
|
|
unsigned i_width, unsigned i_height)
|
|
|
|
{
|
|
|
|
@autoreleasepool {
|
|
|
|
VLCVideoOutputProvider *voutProvider = [[VLCMain sharedInstance] voutProvider];
|
|
|
|
|
2018-12-02 10:59:51 +01:00
|
|
|
dispatch_async(dispatch_get_main_queue(), ^{
|
|
|
|
[voutProvider setNativeVideoSize:NSMakeSize(i_width, i_height)
|
|
|
|
forWindow:p_wnd];
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-12-02 11:13:56 +01:00
|
|
|
static void WindowSetState(vout_window_t *p_wnd, unsigned i_state)
|
|
|
|
{
|
|
|
|
if (i_state & VOUT_WINDOW_STATE_BELOW)
|
|
|
|
msg_Dbg(p_wnd, "Ignore change to VOUT_WINDOW_STATE_BELOW");
|
|
|
|
|
|
|
|
@autoreleasepool {
|
|
|
|
VLCVideoOutputProvider *voutProvider = [[VLCMain sharedInstance] voutProvider];
|
|
|
|
|
2019-03-26 16:04:13 +01:00
|
|
|
NSInteger i_cocoa_level = NSNormalWindowLevel;
|
2018-12-02 11:13:56 +01:00
|
|
|
|
|
|
|
if (i_state & VOUT_WINDOW_STATE_ABOVE)
|
2019-03-26 16:04:13 +01:00
|
|
|
i_cocoa_level = NSStatusWindowLevel;
|
2018-12-02 11:13:56 +01:00
|
|
|
|
|
|
|
dispatch_async(dispatch_get_main_queue(), ^{
|
2019-03-26 16:04:13 +01:00
|
|
|
[voutProvider setWindowLevel:i_cocoa_level forWindow:p_wnd];
|
2018-12-02 11:13:56 +01:00
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-12-01 16:38:16 +01:00
|
|
|
static const char windowed;
|
|
|
|
|
|
|
|
static void WindowSetFullscreen(vout_window_t *p_wnd, const char *psz_id)
|
|
|
|
{
|
|
|
|
if (var_InheritBool(getIntf(), "video-wallpaper")) {
|
|
|
|
msg_Dbg(p_wnd, "Ignore fullscreen event as video-wallpaper is on");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2019-01-13 10:05:11 +01:00
|
|
|
int i_full = psz_id != &windowed;
|
2018-12-01 16:38:16 +01:00
|
|
|
BOOL b_animation = YES;
|
|
|
|
|
|
|
|
@autoreleasepool {
|
|
|
|
VLCVideoOutputProvider *voutProvider = [[VLCMain sharedInstance] voutProvider];
|
|
|
|
|
|
|
|
dispatch_async(dispatch_get_main_queue(), ^{
|
|
|
|
[voutProvider setFullscreen:i_full
|
|
|
|
forWindow:p_wnd
|
|
|
|
withAnimation:b_animation];
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void WindowUnsetFullscreen(vout_window_t *wnd)
|
|
|
|
{
|
|
|
|
WindowSetFullscreen(wnd, &windowed);
|
|
|
|
}
|
|
|
|
|
2015-07-21 14:08:18 +02:00
|
|
|
static atomic_bool b_intf_starting = ATOMIC_VAR_INIT(false);
|
|
|
|
|
2018-12-01 15:12:16 +01:00
|
|
|
static const struct vout_window_operations ops = {
|
2018-12-02 19:40:26 +01:00
|
|
|
WindowEnable,
|
|
|
|
WindowDisable,
|
2018-12-02 10:59:51 +01:00
|
|
|
WindowResize,
|
2018-12-02 19:40:26 +01:00
|
|
|
NULL,
|
2018-12-02 11:13:56 +01:00
|
|
|
WindowSetState,
|
2018-12-01 16:38:16 +01:00
|
|
|
WindowUnsetFullscreen,
|
|
|
|
WindowSetFullscreen,
|
2018-12-01 15:12:16 +01:00
|
|
|
};
|
|
|
|
|
2018-12-08 15:17:42 +01:00
|
|
|
int WindowOpen(vout_window_t *p_wnd)
|
2015-07-21 14:08:18 +02:00
|
|
|
{
|
2018-12-02 19:40:26 +01:00
|
|
|
if (!atomic_load(&b_intf_starting)) {
|
|
|
|
msg_Err(p_wnd, "Cannot create vout as Mac OS X interface was not found");
|
|
|
|
return VLC_EGENERIC;
|
2015-07-21 14:08:18 +02:00
|
|
|
}
|
|
|
|
|
2018-12-02 19:40:26 +01:00
|
|
|
p_wnd->type = VOUT_WINDOW_TYPE_NSOBJECT;
|
|
|
|
p_wnd->ops = &ops;
|
|
|
|
return VLC_SUCCESS;
|
2015-07-21 14:08:18 +02:00
|
|
|
}
|
|
|
|
|
2018-06-10 10:57:03 +02:00
|
|
|
@interface VLCVideoOutputProvider ()
|
2015-07-15 15:18:57 +02:00
|
|
|
{
|
2019-03-26 16:04:13 +01:00
|
|
|
NSMutableDictionary *_voutWindows;
|
|
|
|
VLCKeyboardBacklightControl *_keyboardBacklight;
|
2015-07-15 15:18:57 +02:00
|
|
|
|
2019-03-26 16:04:13 +01:00
|
|
|
NSPoint _topLeftPoint;
|
2015-07-15 15:18:57 +02:00
|
|
|
|
|
|
|
// save the status level if at least one video window is on status level
|
2019-03-26 16:04:13 +01:00
|
|
|
NSUInteger _statusLevelWindowCounter;
|
|
|
|
NSInteger _currentWindowLevel;
|
2015-07-15 15:18:57 +02:00
|
|
|
|
2019-03-26 16:04:13 +01:00
|
|
|
BOOL b_mainWindowHasVideo;
|
2019-03-26 15:54:09 +01:00
|
|
|
|
|
|
|
VLCPlayerController *_playerController;
|
2015-07-15 15:18:57 +02:00
|
|
|
}
|
|
|
|
@end
|
|
|
|
|
2018-06-10 10:57:03 +02:00
|
|
|
@implementation VLCVideoOutputProvider
|
2012-10-02 19:26:37 +02:00
|
|
|
|
|
|
|
- (id)init
|
|
|
|
{
|
|
|
|
self = [super init];
|
2015-07-21 14:08:18 +02:00
|
|
|
if (self) {
|
|
|
|
atomic_store(&b_intf_starting, true);
|
2019-03-26 16:04:13 +01:00
|
|
|
_voutWindows = [[NSMutableDictionary alloc] init];
|
|
|
|
_keyboardBacklight = [[VLCKeyboardBacklightControl alloc] init];
|
|
|
|
_currentWindowLevel = NSNormalWindowLevel;
|
2015-07-21 14:08:18 +02:00
|
|
|
_currentStatusWindowLevel = NSFloatingWindowLevel;
|
|
|
|
}
|
2012-10-02 19:26:37 +02:00
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void)dealloc
|
|
|
|
{
|
2019-03-26 16:04:13 +01:00
|
|
|
NSArray *keys = [_voutWindows allKeys];
|
2012-10-20 15:15:19 +02:00
|
|
|
for (NSValue *key in keys)
|
2017-08-07 21:17:14 +02:00
|
|
|
[self removeVoutForDisplay:key];
|
2012-10-20 15:15:19 +02:00
|
|
|
|
2016-01-09 12:29:56 +01:00
|
|
|
if (var_InheritBool(getIntf(), "macosx-dim-keyboard")) {
|
2019-03-26 16:04:13 +01:00
|
|
|
[_keyboardBacklight switchLightsInstantly:YES];
|
2015-05-28 20:24:43 +02:00
|
|
|
}
|
2012-10-02 19:26:37 +02:00
|
|
|
}
|
|
|
|
|
2013-02-15 20:19:08 +01:00
|
|
|
#pragma mark -
|
|
|
|
#pragma mark Methods for vout provider
|
2012-10-27 12:36:22 +02:00
|
|
|
|
2012-11-10 21:16:20 +01:00
|
|
|
- (VLCVoutView *)setupVoutForWindow:(vout_window_t *)p_wnd withProposedVideoViewPosition:(NSRect)videoViewPosition
|
2012-10-02 19:26:37 +02:00
|
|
|
{
|
2019-03-26 16:04:13 +01:00
|
|
|
VLCMain *mainInstance = [VLCMain sharedInstance];
|
|
|
|
_playerController = [[mainInstance playlistController] playerController];
|
|
|
|
VLCVoutView *voutView;
|
|
|
|
VLCVideoWindowCommon *newVideoWindow;
|
2017-08-07 21:57:07 +02:00
|
|
|
BOOL isEmbedded = YES;
|
2019-03-26 16:04:13 +01:00
|
|
|
BOOL isNativeFullscreen = [mainInstance nativeFullscreenMode];
|
2017-08-07 21:57:06 +02:00
|
|
|
BOOL windowDecorations = var_InheritBool(getIntf(), "video-deco");
|
|
|
|
BOOL videoWallpaper = var_InheritBool(getIntf(), "video-wallpaper");
|
2019-03-26 16:04:13 +01:00
|
|
|
BOOL multipleVoutWindows = [_voutWindows count] > 0;
|
2012-10-27 12:36:22 +02:00
|
|
|
|
2013-06-20 21:15:56 +02:00
|
|
|
// should be called before any window resizing occurs
|
2017-08-07 21:57:06 +02:00
|
|
|
if (!multipleVoutWindows)
|
2019-03-26 16:04:13 +01:00
|
|
|
[[mainInstance mainWindow] videoplayWillBeStarted];
|
2013-06-20 21:15:56 +02:00
|
|
|
|
2017-08-07 21:57:06 +02:00
|
|
|
if (multipleVoutWindows && videoWallpaper)
|
|
|
|
videoWallpaper = false;
|
2012-11-10 21:16:20 +01:00
|
|
|
|
2013-06-12 20:47:19 +02:00
|
|
|
// TODO: make lion fullscreen compatible with video-wallpaper
|
2017-08-07 21:57:06 +02:00
|
|
|
if ((videoWallpaper || !windowDecorations) && !isNativeFullscreen) {
|
|
|
|
// videoWallpaper is priorized over !windowDecorations
|
2012-10-27 12:36:22 +02:00
|
|
|
|
2016-01-09 12:29:56 +01:00
|
|
|
msg_Dbg(getIntf(), "Creating background / blank window");
|
|
|
|
NSScreen *screen = [NSScreen screenWithDisplayID:(CGDirectDisplayID)var_InheritInteger(getIntf(), "macosx-vdev")];
|
2012-10-27 12:36:22 +02:00
|
|
|
if (!screen)
|
2019-03-26 16:04:13 +01:00
|
|
|
screen = [[mainInstance mainWindow] screen];
|
2012-10-27 12:36:22 +02:00
|
|
|
|
|
|
|
NSRect window_rect;
|
2017-08-07 21:57:06 +02:00
|
|
|
if (videoWallpaper)
|
2012-10-27 12:36:22 +02:00
|
|
|
window_rect = [screen frame];
|
|
|
|
else
|
2019-03-26 16:04:13 +01:00
|
|
|
window_rect = [[mainInstance mainWindow] frame];
|
2012-10-27 12:36:22 +02:00
|
|
|
|
|
|
|
NSUInteger mask = NSBorderlessWindowMask;
|
2017-08-07 21:57:06 +02:00
|
|
|
if (!windowDecorations)
|
2012-10-27 12:36:22 +02:00
|
|
|
mask |= NSResizableWindowMask;
|
|
|
|
|
2017-08-07 21:57:06 +02:00
|
|
|
newVideoWindow = [[VLCVideoWindowCommon alloc] initWithContentRect:window_rect styleMask:mask backing:NSBackingStoreBuffered defer:YES];
|
|
|
|
[newVideoWindow setDelegate:newVideoWindow];
|
|
|
|
[newVideoWindow setReleasedWhenClosed: NO];
|
2012-10-27 12:36:22 +02:00
|
|
|
|
2017-08-07 21:57:06 +02:00
|
|
|
if (videoWallpaper)
|
|
|
|
[newVideoWindow setLevel:CGWindowLevelForKey(kCGDesktopWindowLevelKey) + 1];
|
2012-10-27 12:36:22 +02:00
|
|
|
|
2017-08-07 21:57:06 +02:00
|
|
|
[newVideoWindow setBackgroundColor: [NSColor blackColor]];
|
|
|
|
[newVideoWindow setCanBecomeKeyWindow: !videoWallpaper];
|
|
|
|
[newVideoWindow setCanBecomeMainWindow: !videoWallpaper];
|
|
|
|
[newVideoWindow setAcceptsMouseMovedEvents: !videoWallpaper];
|
|
|
|
[newVideoWindow setMovableByWindowBackground: !videoWallpaper];
|
2012-10-27 12:36:22 +02:00
|
|
|
|
2017-08-07 21:57:06 +02:00
|
|
|
voutView = [[VLCVoutView alloc] initWithFrame:[[newVideoWindow contentView] bounds]];
|
|
|
|
[voutView setAutoresizingMask:NSViewWidthSizable | NSViewHeightSizable];
|
|
|
|
[[newVideoWindow contentView] addSubview:voutView positioned:NSWindowAbove relativeTo:nil];
|
|
|
|
[newVideoWindow setVideoView:voutView];
|
2012-10-27 12:36:22 +02:00
|
|
|
|
|
|
|
|
2017-08-07 21:57:06 +02:00
|
|
|
if (videoWallpaper)
|
|
|
|
[newVideoWindow orderBack:nil];
|
2012-10-27 12:36:22 +02:00
|
|
|
else {
|
2012-12-27 11:41:25 +01:00
|
|
|
// no frame autosave for additional vout windows
|
2017-08-07 21:57:06 +02:00
|
|
|
if (!multipleVoutWindows) {
|
2012-12-27 11:41:25 +01:00
|
|
|
// initial window position
|
2017-08-07 21:57:06 +02:00
|
|
|
[newVideoWindow center];
|
|
|
|
[newVideoWindow setFrameAutosaveName:@"extra-videowindow"];
|
2012-12-27 11:41:25 +01:00
|
|
|
}
|
2013-04-03 18:38:58 +02:00
|
|
|
|
2017-08-07 21:57:06 +02:00
|
|
|
[newVideoWindow setContentMinSize: NSMakeSize(f_min_video_height, f_min_video_height)];
|
2012-10-27 12:36:22 +02:00
|
|
|
}
|
|
|
|
|
2017-08-07 21:57:07 +02:00
|
|
|
isEmbedded = NO;
|
2012-10-27 12:36:22 +02:00
|
|
|
} else {
|
2019-03-26 16:04:13 +01:00
|
|
|
if ((var_InheritBool(getIntf(), "embedded-video") && !b_mainWindowHasVideo)) {
|
2012-12-27 11:41:25 +01:00
|
|
|
// setup embedded video
|
2019-03-26 16:04:13 +01:00
|
|
|
newVideoWindow = [mainInstance mainWindow] ;
|
2017-08-07 21:57:06 +02:00
|
|
|
voutView = [newVideoWindow videoView];
|
2019-03-26 16:04:13 +01:00
|
|
|
b_mainWindowHasVideo = YES;
|
2017-08-07 21:57:07 +02:00
|
|
|
isEmbedded = YES;
|
2012-10-27 12:36:22 +02:00
|
|
|
} else {
|
2012-12-27 11:41:25 +01:00
|
|
|
// setup detached window with controls
|
2012-10-27 12:36:22 +02:00
|
|
|
NSWindowController *o_controller = [[NSWindowController alloc] initWithWindowNibName:@"DetachedVideoWindow"];
|
|
|
|
[o_controller loadWindow];
|
2017-08-07 21:57:06 +02:00
|
|
|
newVideoWindow = (VLCDetachedVideoWindow *)[o_controller window];
|
2012-10-27 12:36:22 +02:00
|
|
|
|
2012-12-27 11:41:25 +01:00
|
|
|
// no frame autosave for additional vout windows
|
2017-08-07 21:57:06 +02:00
|
|
|
if (multipleVoutWindows)
|
|
|
|
[newVideoWindow setFrameAutosaveName:@""];
|
|
|
|
|
|
|
|
[newVideoWindow setDelegate: newVideoWindow];
|
|
|
|
[newVideoWindow setLevel:NSNormalWindowLevel];
|
|
|
|
voutView = [newVideoWindow videoView];
|
2017-08-07 21:57:07 +02:00
|
|
|
isEmbedded = NO;
|
2012-10-27 12:36:22 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-06-20 20:53:18 +02:00
|
|
|
NSSize videoViewSize = NSMakeSize(videoViewPosition.size.width, videoViewPosition.size.height);
|
|
|
|
|
2014-03-19 20:14:51 +01:00
|
|
|
// Avoid flashes if video will directly start in fullscreen
|
|
|
|
NSDisableScreenUpdates();
|
2013-06-20 20:53:18 +02:00
|
|
|
|
2017-08-07 21:57:06 +02:00
|
|
|
if (!videoWallpaper) {
|
2013-11-25 17:38:01 +01:00
|
|
|
// set (only!) window origin if specified
|
2017-08-07 21:57:07 +02:00
|
|
|
if (!isEmbedded) {
|
2017-08-07 21:57:06 +02:00
|
|
|
NSRect window_rect = [newVideoWindow frame];
|
2013-04-30 15:52:05 +02:00
|
|
|
if (videoViewPosition.origin.x > 0.)
|
|
|
|
window_rect.origin.x = videoViewPosition.origin.x;
|
|
|
|
if (videoViewPosition.origin.y > 0.)
|
|
|
|
window_rect.origin.y = videoViewPosition.origin.y;
|
|
|
|
|
2017-08-07 21:57:06 +02:00
|
|
|
[newVideoWindow setFrame:window_rect display:YES];
|
2012-11-10 21:16:20 +01:00
|
|
|
}
|
2012-12-27 11:41:25 +01:00
|
|
|
|
|
|
|
// cascade windows if we have more than one vout
|
2017-08-07 21:57:06 +02:00
|
|
|
if (multipleVoutWindows) {
|
2019-03-26 16:04:13 +01:00
|
|
|
if ([_voutWindows count] == 1) {
|
|
|
|
NSWindow * firstWindow = [_voutWindows objectForKey: [[_voutWindows allKeys] firstObject]];
|
2012-12-27 11:41:25 +01:00
|
|
|
|
2017-08-07 21:57:06 +02:00
|
|
|
NSRect topleftBaseRect = NSMakeRect(0, [firstWindow frame].size.height, 0, 0);
|
2019-03-26 16:04:13 +01:00
|
|
|
_topLeftPoint = [firstWindow convertRectToScreen: topleftBaseRect].origin;
|
2012-12-27 11:41:25 +01:00
|
|
|
}
|
|
|
|
|
2019-03-26 16:04:13 +01:00
|
|
|
_topLeftPoint = [newVideoWindow cascadeTopLeftFromPoint: _topLeftPoint];
|
|
|
|
[newVideoWindow setFrameTopLeftPoint: _topLeftPoint];
|
2012-12-27 11:41:25 +01:00
|
|
|
}
|
2013-04-03 18:38:58 +02:00
|
|
|
|
2013-11-25 17:38:01 +01:00
|
|
|
// resize window
|
2017-08-07 21:57:06 +02:00
|
|
|
[newVideoWindow setNativeVideoSize:videoViewSize];
|
2012-11-10 21:16:20 +01:00
|
|
|
|
2017-08-07 21:57:06 +02:00
|
|
|
[newVideoWindow makeKeyAndOrderFront: self];
|
2012-10-27 12:36:22 +02:00
|
|
|
}
|
2012-11-10 21:16:20 +01:00
|
|
|
|
2018-02-28 18:13:04 +01:00
|
|
|
[newVideoWindow setAlphaValue: config_GetFloat("macosx-opaqueness")];
|
2012-10-27 12:36:22 +02:00
|
|
|
|
2019-02-27 18:27:01 +01:00
|
|
|
[voutView setVoutThread:(vout_thread_t *)vlc_object_parent(p_wnd)];
|
2017-08-07 21:57:06 +02:00
|
|
|
[newVideoWindow setHasActiveVideo: YES];
|
2019-03-26 16:04:13 +01:00
|
|
|
[_voutWindows setObject:newVideoWindow forKey:[NSValue valueWithPointer:p_wnd]];
|
2012-10-20 15:15:19 +02:00
|
|
|
|
2019-03-26 16:04:13 +01:00
|
|
|
[mainInstance setActiveVideoPlayback: YES];
|
|
|
|
[[mainInstance mainWindow] setNonembedded:!b_mainWindowHasVideo];
|
2014-03-03 22:22:09 +01:00
|
|
|
|
|
|
|
// beware of order, setActiveVideoPlayback:, setHasActiveVideo: and setNonembedded: must be called before
|
2017-08-07 21:57:06 +02:00
|
|
|
if ([newVideoWindow class] == [VLCMainWindow class])
|
2019-03-26 16:04:13 +01:00
|
|
|
[[mainInstance mainWindow] changePlaylistState: psVideoStartedOrStoppedEvent];
|
2014-03-03 22:22:09 +01:00
|
|
|
|
2014-03-19 20:14:51 +01:00
|
|
|
// TODO: find a cleaner way for "start in fullscreen"
|
|
|
|
// Start in fs, because either prefs settings, or fullscreen button was pressed before
|
2019-03-26 15:54:09 +01:00
|
|
|
|
|
|
|
/* detect the video-splitter and prevent starts in fullscreen if it is enabled */
|
|
|
|
char *psz_splitter = var_GetString(voutView.voutThread, "video-splitter");
|
2014-03-19 20:14:51 +01:00
|
|
|
BOOL b_have_splitter = psz_splitter != NULL && *psz_splitter != '\0';
|
|
|
|
free(psz_splitter);
|
|
|
|
|
2019-03-26 15:54:09 +01:00
|
|
|
if (!videoWallpaper && !b_have_splitter && (var_InheritBool(getIntf(), "fullscreen") || _playerController.fullscreen)) {
|
2014-03-19 20:14:51 +01:00
|
|
|
|
|
|
|
// this is not set when we start in fullscreen because of
|
|
|
|
// fullscreen settings in video prefs the second time
|
2019-02-27 18:27:01 +01:00
|
|
|
var_SetBool(vlc_object_parent(p_wnd), "fullscreen", 1);
|
2014-03-19 20:14:51 +01:00
|
|
|
|
|
|
|
[self setFullscreen:1 forWindow:p_wnd withAnimation:NO];
|
|
|
|
}
|
|
|
|
|
|
|
|
NSEnableScreenUpdates();
|
|
|
|
|
2017-08-07 21:57:06 +02:00
|
|
|
return voutView;
|
2012-10-02 19:26:37 +02:00
|
|
|
}
|
|
|
|
|
2017-08-07 21:17:14 +02:00
|
|
|
- (void)removeVoutForDisplay:(NSValue *)o_key
|
2012-10-02 19:26:37 +02:00
|
|
|
{
|
2019-03-26 16:04:13 +01:00
|
|
|
VLCMain *mainInstance = [VLCMain sharedInstance];
|
|
|
|
VLCVideoWindowCommon *o_window = [_voutWindows objectForKey:o_key];
|
2012-11-15 19:45:00 +01:00
|
|
|
if (!o_window) {
|
2016-01-09 12:29:56 +01:00
|
|
|
msg_Err(getIntf(), "Cannot close nonexisting window");
|
2012-10-02 21:05:26 +02:00
|
|
|
return;
|
|
|
|
}
|
2012-10-02 19:26:37 +02:00
|
|
|
|
2014-03-31 19:26:05 +02:00
|
|
|
[[o_window videoView] releaseVoutThread];
|
|
|
|
|
|
|
|
// set active video to no BEFORE closing the window and exiting fullscreen
|
|
|
|
// (avoid stopping playback due to NSWindowWillCloseNotification, preserving fullscreen state)
|
|
|
|
[o_window setHasActiveVideo: NO];
|
|
|
|
|
2014-03-19 09:48:07 +01:00
|
|
|
// prevent visible extra window if in fullscreen
|
|
|
|
NSDisableScreenUpdates();
|
2019-03-26 16:04:13 +01:00
|
|
|
BOOL b_native = [[mainInstance mainWindow] nativeFullscreenMode];
|
2014-03-30 21:43:15 +02:00
|
|
|
|
|
|
|
// close fullscreen, without changing fullscreen vars
|
|
|
|
if (!b_native && ([o_window fullscreen] || [o_window inFullscreenTransition]))
|
|
|
|
[o_window leaveFullscreenWithAnimation:NO];
|
|
|
|
|
|
|
|
// native fullscreen window will not be closed if
|
|
|
|
// fullscreen was triggered without video
|
|
|
|
if ((b_native && [o_window class] == [VLCMainWindow class] && [o_window fullscreen] && [o_window windowShouldExitFullscreenWhenFinished])) {
|
|
|
|
[o_window toggleFullScreen:self];
|
|
|
|
}
|
2012-10-08 19:41:31 +02:00
|
|
|
|
2014-02-22 23:50:39 +01:00
|
|
|
if ([o_window class] != [VLCMainWindow class]) {
|
2013-02-09 10:51:12 +01:00
|
|
|
[o_window close];
|
2012-10-02 19:26:37 +02:00
|
|
|
}
|
2014-03-19 09:48:07 +01:00
|
|
|
NSEnableScreenUpdates();
|
2012-10-20 15:15:19 +02:00
|
|
|
|
2019-03-26 16:04:13 +01:00
|
|
|
[_voutWindows removeObjectForKey:o_key];
|
|
|
|
if ([_voutWindows count] == 0) {
|
|
|
|
[mainInstance setActiveVideoPlayback:NO];
|
|
|
|
_statusLevelWindowCounter = 0;
|
2013-10-25 18:19:43 +02:00
|
|
|
}
|
2014-03-03 22:22:09 +01:00
|
|
|
|
|
|
|
if ([o_window class] == [VLCMainWindow class]) {
|
2019-03-26 16:04:13 +01:00
|
|
|
b_mainWindowHasVideo = NO;
|
2014-03-03 22:22:09 +01:00
|
|
|
|
|
|
|
// video in main window might get stopped while another vout is open
|
2019-03-26 16:04:13 +01:00
|
|
|
if ([_voutWindows count] > 0)
|
|
|
|
[[mainInstance mainWindow] setNonembedded:YES];
|
2014-03-03 22:22:09 +01:00
|
|
|
|
|
|
|
// beware of order, setActiveVideoPlayback:, setHasActiveVideo: and setNonembedded: must be called before
|
2019-03-26 16:04:13 +01:00
|
|
|
[[mainInstance mainWindow] changePlaylistState: psVideoStartedOrStoppedEvent];
|
2014-03-03 22:22:09 +01:00
|
|
|
}
|
2012-10-02 19:26:37 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-10-02 21:05:26 +02:00
|
|
|
- (void)setNativeVideoSize:(NSSize)size forWindow:(vout_window_t *)p_wnd
|
|
|
|
{
|
2019-03-26 16:04:13 +01:00
|
|
|
VLCVideoWindowCommon *o_window = [_voutWindows objectForKey:[NSValue valueWithPointer:p_wnd]];
|
2012-11-15 19:45:00 +01:00
|
|
|
if (!o_window) {
|
2016-01-09 12:29:56 +01:00
|
|
|
msg_Err(getIntf(), "Cannot set size for nonexisting window");
|
2012-10-02 21:05:26 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
[o_window setNativeVideoSize:size];
|
|
|
|
}
|
|
|
|
|
2013-01-12 16:29:26 +01:00
|
|
|
- (void)setWindowLevel:(NSInteger)i_level forWindow:(vout_window_t *)p_wnd
|
|
|
|
{
|
2019-03-26 16:04:13 +01:00
|
|
|
VLCVideoWindowCommon *o_window = [_voutWindows objectForKey:[NSValue valueWithPointer:p_wnd]];
|
2013-11-09 17:26:46 +01:00
|
|
|
if (!o_window) {
|
2016-01-09 12:29:56 +01:00
|
|
|
msg_Err(getIntf(), "Cannot set level for nonexisting window");
|
2013-11-09 17:26:46 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2013-01-12 16:29:26 +01:00
|
|
|
// only set level for helper windows to normal if no status vout window exist anymore
|
|
|
|
if(i_level == NSStatusWindowLevel) {
|
2019-03-26 16:04:13 +01:00
|
|
|
_statusLevelWindowCounter++;
|
2013-11-09 17:26:46 +01:00
|
|
|
// window level need to stay on normal in fullscreen mode
|
2014-01-26 18:17:21 +01:00
|
|
|
if (![o_window fullscreen] && ![o_window inFullscreenTransition])
|
2013-11-09 17:26:46 +01:00
|
|
|
[self updateWindowLevelForHelperWindows:i_level];
|
2013-01-12 16:29:26 +01:00
|
|
|
} else {
|
2019-03-26 16:04:13 +01:00
|
|
|
if (_statusLevelWindowCounter > 0)
|
|
|
|
_statusLevelWindowCounter--;
|
2013-10-25 18:19:43 +02:00
|
|
|
|
2019-03-26 16:04:13 +01:00
|
|
|
if (_statusLevelWindowCounter == 0) {
|
2013-01-12 16:29:26 +01:00
|
|
|
[self updateWindowLevelForHelperWindows:i_level];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
[o_window setWindowLevel:i_level];
|
|
|
|
}
|
|
|
|
|
2014-03-19 20:14:51 +01:00
|
|
|
- (void)setFullscreen:(int)i_full forWindow:(vout_window_t *)p_wnd withAnimation:(BOOL)b_animation
|
2013-02-15 20:19:08 +01:00
|
|
|
{
|
2016-01-09 12:29:56 +01:00
|
|
|
intf_thread_t *p_intf = getIntf();
|
2013-02-15 20:19:08 +01:00
|
|
|
BOOL b_nativeFullscreenMode = [[VLCMain sharedInstance] nativeFullscreenMode];
|
2013-04-03 18:38:58 +02:00
|
|
|
|
2013-02-15 20:19:08 +01:00
|
|
|
if (!p_intf || (!b_nativeFullscreenMode && !p_wnd))
|
|
|
|
return;
|
2014-03-04 18:09:24 +01:00
|
|
|
BOOL b_fullscreen = i_full != 0;
|
2013-02-15 20:19:08 +01:00
|
|
|
|
2019-03-26 15:54:09 +01:00
|
|
|
if (!_playerController.fullscreen != !b_fullscreen) {
|
|
|
|
_playerController.fullscreen = b_fullscreen;
|
|
|
|
}
|
2013-02-15 20:19:08 +01:00
|
|
|
|
|
|
|
VLCVideoWindowCommon *o_current_window = nil;
|
|
|
|
if(p_wnd)
|
2019-03-26 16:04:13 +01:00
|
|
|
o_current_window = [_voutWindows objectForKey:[NSValue valueWithPointer:p_wnd]];
|
2013-02-15 20:19:08 +01:00
|
|
|
|
2015-05-28 20:24:43 +02:00
|
|
|
if (var_InheritBool(p_intf, "macosx-dim-keyboard")) {
|
2019-03-26 16:04:13 +01:00
|
|
|
[_keyboardBacklight switchLightsAsync:!b_fullscreen];
|
2015-05-28 20:24:43 +02:00
|
|
|
}
|
|
|
|
|
2013-02-15 20:19:08 +01:00
|
|
|
if (b_nativeFullscreenMode) {
|
|
|
|
if(!o_current_window)
|
2015-08-11 12:44:49 +02:00
|
|
|
o_current_window = [[VLCMain sharedInstance] mainWindow] ;
|
2013-02-15 20:19:08 +01:00
|
|
|
assert(o_current_window);
|
|
|
|
|
|
|
|
// fullscreen might be triggered twice (vout event)
|
|
|
|
// so ignore duplicate events here
|
2014-01-26 18:17:21 +01:00
|
|
|
if((b_fullscreen && !([o_current_window fullscreen] || [o_current_window inFullscreenTransition])) ||
|
2013-02-15 20:19:08 +01:00
|
|
|
(!b_fullscreen && [o_current_window fullscreen])) {
|
|
|
|
|
|
|
|
[o_current_window toggleFullScreen:self];
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
assert(o_current_window);
|
|
|
|
|
|
|
|
if (b_fullscreen) {
|
2019-03-26 15:54:09 +01:00
|
|
|
if (_playerController.playerState != VLC_PLAYER_STATE_STOPPED && [[VLCMain sharedInstance] activeVideoPlayback]) {
|
2013-02-15 20:19:08 +01:00
|
|
|
// activate app, as method can also be triggered from outside the app (prevents nasty window layout)
|
|
|
|
[NSApp activateIgnoringOtherApps:YES];
|
2014-03-19 20:14:51 +01:00
|
|
|
[o_current_window enterFullscreenWithAnimation:b_animation];
|
2013-02-15 20:19:08 +01:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
// leaving fullscreen is always allowed
|
2014-03-19 09:48:07 +01:00
|
|
|
[o_current_window leaveFullscreenWithAnimation:YES];
|
2013-02-15 20:19:08 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#pragma mark -
|
|
|
|
#pragma mark Misc methods
|
|
|
|
|
2015-08-13 21:06:24 +02:00
|
|
|
- (void)updateControlsBarsUsingBlock:(void (^)(VLCControlsBarCommon *controlsBar))block
|
2013-02-15 20:19:08 +01:00
|
|
|
{
|
2019-03-26 16:04:13 +01:00
|
|
|
[_voutWindows enumerateKeysAndObjectsUsingBlock:^(id key, id obj, BOOL *stop) {
|
2015-08-13 21:06:24 +02:00
|
|
|
|
2013-02-15 20:19:08 +01:00
|
|
|
if ([obj respondsToSelector:@selector(controlsBar)]) {
|
2015-08-13 21:06:24 +02:00
|
|
|
VLCControlsBarCommon *o_controlsBar = [obj controlsBar];
|
|
|
|
if (o_controlsBar && block)
|
|
|
|
block(o_controlsBar);
|
2013-02-15 20:19:08 +01:00
|
|
|
}
|
|
|
|
}];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void)updateWindowsUsingBlock:(void (^)(VLCVideoWindowCommon *o_window))windowUpdater
|
|
|
|
{
|
2019-03-26 16:04:13 +01:00
|
|
|
[_voutWindows enumerateKeysAndObjectsUsingBlock:^(id key, id obj, BOOL *stop) {
|
2013-02-15 20:19:08 +01:00
|
|
|
if ([obj isKindOfClass: [NSWindow class]])
|
|
|
|
windowUpdater(obj);
|
|
|
|
}];
|
|
|
|
}
|
|
|
|
|
2013-01-12 16:29:26 +01:00
|
|
|
- (void)updateWindowLevelForHelperWindows:(NSInteger)i_level
|
|
|
|
{
|
2016-01-09 12:29:56 +01:00
|
|
|
if (var_InheritBool(getIntf(), "video-wallpaper"))
|
2013-01-12 16:29:26 +01:00
|
|
|
return;
|
|
|
|
|
2019-03-26 16:04:13 +01:00
|
|
|
_currentWindowLevel = i_level;
|
2014-08-31 20:51:36 +02:00
|
|
|
if (i_level == NSNormalWindowLevel) {
|
2015-07-15 16:54:31 +02:00
|
|
|
_currentStatusWindowLevel = NSFloatingWindowLevel;
|
2014-08-31 20:51:36 +02:00
|
|
|
} else {
|
2015-07-15 16:54:31 +02:00
|
|
|
_currentStatusWindowLevel = i_level + 1;
|
2014-08-31 20:51:36 +02:00
|
|
|
}
|
2013-01-12 16:29:26 +01:00
|
|
|
|
2015-07-15 16:54:31 +02:00
|
|
|
NSInteger currentStatusWindowLevel = self.currentStatusWindowLevel;
|
2014-08-31 20:51:36 +02:00
|
|
|
|
2015-07-21 18:16:26 +02:00
|
|
|
VLCMain *main = [VLCMain sharedInstance];
|
2019-03-26 16:04:13 +01:00
|
|
|
[[main mainWindow] setWindowLevel:i_level];
|
2015-08-02 13:22:53 +02:00
|
|
|
[[main videoEffectsPanel] updateCocoaWindowLevel:currentStatusWindowLevel];
|
2015-08-02 13:14:18 +02:00
|
|
|
[[main audioEffectsPanel] updateCocoaWindowLevel:currentStatusWindowLevel];
|
2016-01-02 18:37:25 +01:00
|
|
|
[[main currentMediaInfoPanel] updateCocoaWindowLevel:currentStatusWindowLevel];
|
2015-07-21 18:16:26 +02:00
|
|
|
[[main bookmarks] updateCocoaWindowLevel:currentStatusWindowLevel];
|
2015-08-02 13:00:14 +02:00
|
|
|
[[main trackSyncPanel] updateCocoaWindowLevel:currentStatusWindowLevel];
|
2015-07-21 18:16:26 +02:00
|
|
|
[[main resumeDialog] updateCocoaWindowLevel:currentStatusWindowLevel];
|
2013-01-12 16:29:26 +01:00
|
|
|
}
|
|
|
|
|
2012-11-15 19:45:00 +01:00
|
|
|
@end
|