2012-10-02 19:26:37 +02:00
|
|
|
/*****************************************************************************
|
|
|
|
* VLCVoutWindowController.m: MacOS X interface module
|
|
|
|
*****************************************************************************
|
2014-02-02 20:47:01 +01:00
|
|
|
* Copyright (C) 2012-2014 VLC authors and VideoLAN
|
2012-10-02 19:26:37 +02:00
|
|
|
* $Id$
|
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*****************************************************************************/
|
|
|
|
|
2015-07-21 14:08:18 +02:00
|
|
|
#include <vlc_vout_display.h>
|
|
|
|
|
2014-02-02 20:47:01 +01:00
|
|
|
#import "CompatibilityFixes.h"
|
2012-10-02 19:26:37 +02:00
|
|
|
#import "VLCVoutWindowController.h"
|
2012-10-02 21:05:26 +02:00
|
|
|
#import "intf.h"
|
2012-10-27 12:36:22 +02:00
|
|
|
#import "MainWindow.h"
|
2012-10-20 15:15:19 +02:00
|
|
|
#import "VideoView.h"
|
2012-10-02 19:26:37 +02:00
|
|
|
|
2013-01-12 16:29:26 +01:00
|
|
|
#import "VideoEffects.h"
|
|
|
|
#import "AudioEffects.h"
|
|
|
|
#import "playlistinfo.h"
|
|
|
|
#import "bookmarks.h"
|
|
|
|
#import "TrackSynchronization.h"
|
2015-07-11 14:32:20 +02:00
|
|
|
#import "ResumeDialogController.h"
|
|
|
|
#import "playlist.h"
|
2013-01-12 16:29:26 +01:00
|
|
|
|
2015-07-21 14:08:18 +02:00
|
|
|
static atomic_bool b_intf_starting = ATOMIC_VAR_INIT(false);
|
|
|
|
|
|
|
|
static int WindowControl(vout_window_t *, int i_query, va_list);
|
|
|
|
|
|
|
|
int WindowOpen(vout_window_t *p_wnd, const vout_window_cfg_t *cfg)
|
|
|
|
{
|
|
|
|
@autoreleasepool {
|
|
|
|
if (cfg->type != VOUT_WINDOW_TYPE_INVALID
|
|
|
|
&& cfg->type != VOUT_WINDOW_TYPE_NSOBJECT)
|
|
|
|
return VLC_EGENERIC;
|
|
|
|
|
|
|
|
msg_Dbg(p_wnd, "Opening video window");
|
|
|
|
|
|
|
|
if (!atomic_load(&b_intf_starting)) {
|
|
|
|
msg_Err(p_wnd, "Cannot create vout as Mac OS X interface was not found");
|
|
|
|
return VLC_EGENERIC;
|
|
|
|
}
|
|
|
|
|
|
|
|
NSRect proposedVideoViewPosition = NSMakeRect(cfg->x, cfg->y, cfg->width, cfg->height);
|
|
|
|
|
|
|
|
VLCVoutWindowController *voutController = [[VLCMain sharedInstance] voutController];
|
|
|
|
if (!voutController) {
|
|
|
|
return VLC_EGENERIC;
|
|
|
|
}
|
|
|
|
[voutController.lock lock];
|
|
|
|
|
|
|
|
SEL sel = @selector(setupVoutForWindow:withProposedVideoViewPosition:);
|
|
|
|
NSInvocation *inv = [NSInvocation invocationWithMethodSignature:[voutController methodSignatureForSelector:sel]];
|
|
|
|
[inv setTarget:voutController];
|
|
|
|
[inv setSelector:sel];
|
|
|
|
[inv setArgument:&p_wnd atIndex:2]; // starting at 2!
|
|
|
|
[inv setArgument:&proposedVideoViewPosition atIndex:3];
|
|
|
|
|
|
|
|
[inv performSelectorOnMainThread:@selector(invoke) withObject:nil
|
|
|
|
waitUntilDone:YES];
|
|
|
|
|
|
|
|
VLCVoutView *videoView = nil;
|
|
|
|
[inv getReturnValue:&videoView];
|
|
|
|
|
|
|
|
// this method is not supposed to fail
|
|
|
|
assert(videoView != nil);
|
|
|
|
|
|
|
|
msg_Dbg(VLCIntf, "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);
|
|
|
|
|
|
|
|
[voutController.lock unlock];
|
|
|
|
|
|
|
|
p_wnd->type = VOUT_WINDOW_TYPE_NSOBJECT;
|
|
|
|
p_wnd->control = WindowControl;
|
|
|
|
|
|
|
|
return VLC_SUCCESS;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static int WindowControl(vout_window_t *p_wnd, int i_query, va_list args)
|
|
|
|
{
|
|
|
|
@autoreleasepool {
|
|
|
|
VLCVoutWindowController *voutController = [[VLCMain sharedInstance] voutController];
|
|
|
|
if (!voutController) {
|
|
|
|
return VLC_EGENERIC;
|
|
|
|
}
|
|
|
|
[voutController.lock lock];
|
|
|
|
|
|
|
|
switch(i_query) {
|
|
|
|
case VOUT_WINDOW_SET_STATE:
|
|
|
|
{
|
|
|
|
unsigned i_state = va_arg(args, unsigned);
|
|
|
|
|
|
|
|
if (i_state & VOUT_WINDOW_STATE_BELOW)
|
|
|
|
{
|
|
|
|
msg_Dbg(p_wnd, "Ignore change to VOUT_WINDOW_STATE_BELOW");
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
|
|
|
NSInteger i_cooca_level = NSNormalWindowLevel;
|
|
|
|
if (i_state & VOUT_WINDOW_STATE_ABOVE)
|
|
|
|
i_cooca_level = NSStatusWindowLevel;
|
|
|
|
|
|
|
|
SEL sel = @selector(setWindowLevel:forWindow:);
|
|
|
|
NSInvocation *inv = [NSInvocation invocationWithMethodSignature:[voutController methodSignatureForSelector:sel]];
|
|
|
|
[inv setTarget:voutController];
|
|
|
|
[inv setSelector:sel];
|
|
|
|
[inv setArgument:&i_cooca_level atIndex:2]; // starting at 2!
|
|
|
|
[inv setArgument:&p_wnd atIndex:3];
|
|
|
|
[inv performSelectorOnMainThread:@selector(invoke) withObject:nil
|
|
|
|
waitUntilDone:NO];
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case VOUT_WINDOW_SET_SIZE:
|
|
|
|
{
|
|
|
|
unsigned int i_width = va_arg(args, unsigned int);
|
|
|
|
unsigned int i_height = va_arg(args, unsigned int);
|
|
|
|
|
|
|
|
NSSize newSize = NSMakeSize(i_width, i_height);
|
|
|
|
SEL sel = @selector(setNativeVideoSize:forWindow:);
|
|
|
|
NSInvocation *inv = [NSInvocation invocationWithMethodSignature:[voutController methodSignatureForSelector:sel]];
|
|
|
|
[inv setTarget:voutController];
|
|
|
|
[inv setSelector:sel];
|
|
|
|
[inv setArgument:&newSize atIndex:2]; // starting at 2!
|
|
|
|
[inv setArgument:&p_wnd atIndex:3];
|
|
|
|
[inv performSelectorOnMainThread:@selector(invoke) withObject:nil
|
|
|
|
waitUntilDone:NO];
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case VOUT_WINDOW_SET_FULLSCREEN:
|
|
|
|
{
|
|
|
|
if (var_InheritBool(VLCIntf, "video-wallpaper")) {
|
|
|
|
msg_Dbg(p_wnd, "Ignore fullscreen event as video-wallpaper is on");
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
|
|
|
int i_full = va_arg(args, int);
|
|
|
|
BOOL b_animation = YES;
|
|
|
|
|
|
|
|
SEL sel = @selector(setFullscreen:forWindow:withAnimation:);
|
|
|
|
NSInvocation *inv = [NSInvocation invocationWithMethodSignature:[voutController methodSignatureForSelector:sel]];
|
|
|
|
[inv setTarget:voutController];
|
|
|
|
[inv setSelector:sel];
|
|
|
|
[inv setArgument:&i_full atIndex:2]; // starting at 2!
|
|
|
|
[inv setArgument:&p_wnd atIndex:3];
|
|
|
|
[inv setArgument:&b_animation atIndex:4];
|
|
|
|
[inv performSelectorOnMainThread:@selector(invoke) withObject:nil
|
|
|
|
waitUntilDone:NO];
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
default:
|
|
|
|
{
|
|
|
|
msg_Warn(p_wnd, "unsupported control query");
|
|
|
|
[voutController.lock unlock];
|
|
|
|
return VLC_EGENERIC;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
out:
|
|
|
|
[voutController.lock unlock];
|
|
|
|
return VLC_SUCCESS;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void WindowClose(vout_window_t *p_wnd)
|
|
|
|
{
|
|
|
|
@autoreleasepool {
|
|
|
|
VLCVoutWindowController *voutController = [[VLCMain sharedInstance] voutController];
|
|
|
|
if (!voutController) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
[voutController.lock lock];
|
|
|
|
[voutController performSelectorOnMainThread:@selector(removeVoutforDisplay:) withObject:[NSValue valueWithPointer:p_wnd] waitUntilDone:NO];
|
|
|
|
[voutController.lock unlock];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-07-15 15:18:57 +02:00
|
|
|
@interface VLCVoutWindowController ()
|
|
|
|
{
|
|
|
|
NSMutableDictionary *o_vout_dict;
|
|
|
|
KeyboardBacklight *o_keyboard_backlight;
|
|
|
|
|
|
|
|
NSPoint top_left_point;
|
|
|
|
|
|
|
|
// save the status level if at least one video window is on status level
|
|
|
|
NSUInteger i_statusLevelWindowCounter;
|
|
|
|
NSInteger i_currentWindowLevel;
|
|
|
|
|
|
|
|
BOOL b_mainwindow_has_video;
|
|
|
|
}
|
|
|
|
@end
|
|
|
|
|
2012-10-02 19:26:37 +02:00
|
|
|
@implementation VLCVoutWindowController
|
|
|
|
|
|
|
|
- (id)init
|
|
|
|
{
|
|
|
|
self = [super init];
|
2015-07-21 14:08:18 +02:00
|
|
|
if (self) {
|
|
|
|
atomic_store(&b_intf_starting, true);
|
|
|
|
o_vout_dict = [[NSMutableDictionary alloc] init];
|
|
|
|
o_keyboard_backlight = [[KeyboardBacklight alloc] init];
|
|
|
|
i_currentWindowLevel = NSNormalWindowLevel;
|
|
|
|
_currentStatusWindowLevel = NSFloatingWindowLevel;
|
|
|
|
}
|
2012-10-02 19:26:37 +02:00
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void)dealloc
|
|
|
|
{
|
2012-10-20 15:15:19 +02:00
|
|
|
NSArray *keys = [o_vout_dict allKeys];
|
|
|
|
for (NSValue *key in keys)
|
|
|
|
[self removeVoutforDisplay:key];
|
|
|
|
|
2015-05-28 20:24:43 +02:00
|
|
|
if (var_InheritBool(VLCIntf, "macosx-dim-keyboard")) {
|
|
|
|
[o_keyboard_backlight switchLightsInstantly:YES];
|
|
|
|
}
|
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
|
|
|
{
|
2012-10-27 12:36:22 +02:00
|
|
|
BOOL b_nonembedded = NO;
|
|
|
|
BOOL b_nativeFullscreenMode = [[VLCMain sharedInstance] nativeFullscreenMode];
|
|
|
|
BOOL b_video_deco = var_InheritBool(VLCIntf, "video-deco");
|
|
|
|
BOOL b_video_wallpaper = var_InheritBool(VLCIntf, "video-wallpaper");
|
2012-10-27 12:45:01 +02:00
|
|
|
BOOL b_multiple_vout_windows = [o_vout_dict count] > 0;
|
2012-10-27 12:36:22 +02:00
|
|
|
VLCVoutView *o_vout_view;
|
|
|
|
VLCVideoWindowCommon *o_new_video_window;
|
|
|
|
|
2013-06-20 21:15:56 +02:00
|
|
|
// should be called before any window resizing occurs
|
2014-03-03 22:22:09 +01:00
|
|
|
if (!b_multiple_vout_windows)
|
|
|
|
[[VLCMainWindow sharedInstance] videoplayWillBeStarted];
|
2013-06-20 21:15:56 +02:00
|
|
|
|
2012-12-25 20:36:04 +01:00
|
|
|
if (b_multiple_vout_windows && b_video_wallpaper)
|
|
|
|
b_video_wallpaper = 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
|
2012-10-27 12:36:22 +02:00
|
|
|
if ((b_video_wallpaper || !b_video_deco) && !b_nativeFullscreenMode) {
|
|
|
|
// b_video_wallpaper is priorized over !b_video_deco
|
|
|
|
|
|
|
|
msg_Dbg(VLCIntf, "Creating background / blank window");
|
|
|
|
NSScreen *screen = [NSScreen screenWithDisplayID:(CGDirectDisplayID)var_InheritInteger(VLCIntf, "macosx-vdev")];
|
|
|
|
if (!screen)
|
|
|
|
screen = [[VLCMainWindow sharedInstance] screen];
|
|
|
|
|
|
|
|
NSRect window_rect;
|
|
|
|
if (b_video_wallpaper)
|
|
|
|
window_rect = [screen frame];
|
|
|
|
else
|
|
|
|
window_rect = [[VLCMainWindow sharedInstance] frame];
|
|
|
|
|
|
|
|
NSUInteger mask = NSBorderlessWindowMask;
|
2015-07-15 20:26:46 +02:00
|
|
|
if (!b_video_deco)
|
2012-10-27 12:36:22 +02:00
|
|
|
mask |= NSResizableWindowMask;
|
|
|
|
|
|
|
|
BOOL b_no_video_deco_only = !b_video_wallpaper;
|
|
|
|
o_new_video_window = [[VLCVideoWindowCommon alloc] initWithContentRect:window_rect styleMask:mask backing:NSBackingStoreBuffered defer:YES];
|
|
|
|
[o_new_video_window setDelegate:o_new_video_window];
|
2013-11-25 17:36:27 +01:00
|
|
|
[o_new_video_window setReleasedWhenClosed: NO];
|
2012-10-27 12:36:22 +02:00
|
|
|
|
|
|
|
if (b_video_wallpaper)
|
|
|
|
[o_new_video_window setLevel:CGWindowLevelForKey(kCGDesktopWindowLevelKey) + 1];
|
|
|
|
|
|
|
|
[o_new_video_window setBackgroundColor: [NSColor blackColor]];
|
|
|
|
[o_new_video_window setCanBecomeKeyWindow: !b_video_wallpaper];
|
|
|
|
[o_new_video_window setCanBecomeMainWindow: !b_video_wallpaper];
|
|
|
|
[o_new_video_window setAcceptsMouseMovedEvents: !b_video_wallpaper];
|
|
|
|
[o_new_video_window setMovableByWindowBackground: !b_video_wallpaper];
|
|
|
|
[o_new_video_window useOptimizedDrawing: YES];
|
|
|
|
|
|
|
|
o_vout_view = [[VLCVoutView alloc] initWithFrame:[[o_new_video_window contentView] bounds]];
|
|
|
|
[o_vout_view setAutoresizingMask:NSViewWidthSizable | NSViewHeightSizable];
|
|
|
|
[[o_new_video_window contentView] addSubview:o_vout_view positioned:NSWindowAbove relativeTo:nil];
|
|
|
|
[o_new_video_window setVideoView:o_vout_view];
|
|
|
|
|
|
|
|
|
|
|
|
if (b_video_wallpaper)
|
|
|
|
[o_new_video_window orderBack:nil];
|
|
|
|
else {
|
2012-12-27 11:41:25 +01:00
|
|
|
// no frame autosave for additional vout windows
|
|
|
|
if (!b_multiple_vout_windows) {
|
|
|
|
// initial window position
|
|
|
|
[o_new_video_window center];
|
|
|
|
[o_new_video_window setFrameAutosaveName:@"extra-videowindow"];
|
|
|
|
}
|
2013-04-03 18:38:58 +02:00
|
|
|
|
2012-10-27 12:36:22 +02:00
|
|
|
[o_new_video_window setContentMinSize: NSMakeSize(f_min_video_height, f_min_video_height)];
|
|
|
|
}
|
|
|
|
|
|
|
|
b_nonembedded = YES;
|
|
|
|
} else {
|
2014-02-22 23:47:55 +01:00
|
|
|
if ((var_InheritBool(VLCIntf, "embedded-video") && !b_mainwindow_has_video)) {
|
2012-12-27 11:41:25 +01:00
|
|
|
// setup embedded video
|
2015-07-14 22:10:40 +02:00
|
|
|
o_new_video_window = [VLCMainWindow sharedInstance];
|
|
|
|
o_vout_view = [o_new_video_window videoView];
|
2014-02-22 23:47:55 +01:00
|
|
|
b_mainwindow_has_video = YES;
|
2012-10-27 12:36:22 +02:00
|
|
|
b_nonembedded = NO;
|
|
|
|
} 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];
|
2015-07-14 22:10:40 +02:00
|
|
|
o_new_video_window = (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
|
|
|
|
if (b_multiple_vout_windows)
|
|
|
|
[o_new_video_window setFrameAutosaveName:@""];
|
|
|
|
|
2012-10-27 12:36:22 +02:00
|
|
|
[o_new_video_window setDelegate: o_new_video_window];
|
|
|
|
[o_new_video_window setLevel:NSNormalWindowLevel];
|
|
|
|
[o_new_video_window useOptimizedDrawing: YES];
|
2015-07-14 22:10:40 +02:00
|
|
|
o_vout_view = [o_new_video_window videoView];
|
2012-10-27 12:36:22 +02:00
|
|
|
b_nonembedded = YES;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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
|
|
|
|
2012-10-27 12:36:22 +02:00
|
|
|
if (!b_video_wallpaper) {
|
2013-11-25 17:38:01 +01:00
|
|
|
// set (only!) window origin if specified
|
2012-11-10 21:16:20 +01:00
|
|
|
if (b_nonembedded) {
|
2013-11-25 17:38:01 +01:00
|
|
|
NSRect window_rect = [o_new_video_window 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;
|
|
|
|
|
2012-11-10 21:16:20 +01:00
|
|
|
[o_new_video_window setFrame:window_rect display:YES];
|
|
|
|
}
|
2012-12-27 11:41:25 +01:00
|
|
|
|
|
|
|
// cascade windows if we have more than one vout
|
|
|
|
if (b_multiple_vout_windows) {
|
|
|
|
if ([o_vout_dict count] == 1) {
|
2015-07-20 14:29:35 +02:00
|
|
|
NSWindow * o_first_window = [o_vout_dict objectForKey: [[o_vout_dict allKeys] firstObject]];
|
2012-12-27 11:41:25 +01:00
|
|
|
|
|
|
|
NSPoint topleftbase = NSMakePoint(0, [o_first_window frame].size.height);
|
|
|
|
top_left_point = [o_first_window convertBaseToScreen: topleftbase];
|
|
|
|
}
|
|
|
|
|
|
|
|
top_left_point = [o_new_video_window cascadeTopLeftFromPoint: top_left_point];
|
|
|
|
[o_new_video_window setFrameTopLeftPoint: top_left_point];
|
|
|
|
}
|
2013-04-03 18:38:58 +02:00
|
|
|
|
2013-11-25 17:38:01 +01:00
|
|
|
// resize window
|
2012-11-10 21:16:20 +01:00
|
|
|
[o_new_video_window setNativeVideoSize:videoViewSize];
|
|
|
|
|
2012-10-27 12:36:22 +02:00
|
|
|
[o_new_video_window makeKeyAndOrderFront: self];
|
|
|
|
}
|
2012-11-10 21:16:20 +01:00
|
|
|
|
2012-10-27 12:36:22 +02:00
|
|
|
[o_new_video_window setAlphaValue: config_GetFloat(VLCIntf, "macosx-opaqueness")];
|
|
|
|
|
|
|
|
[o_vout_view setVoutThread:(vout_thread_t *)p_wnd->p_parent];
|
2013-02-08 19:39:11 +01:00
|
|
|
[o_new_video_window setHasActiveVideo: YES];
|
2015-07-14 22:10:40 +02:00
|
|
|
[o_vout_dict setObject:o_new_video_window forKey:[NSValue valueWithPointer:p_wnd]];
|
2012-10-20 15:15:19 +02:00
|
|
|
|
2014-04-15 18:44:48 +02:00
|
|
|
[[VLCMain sharedInstance] setActiveVideoPlayback: YES];
|
2014-03-03 22:22:09 +01:00
|
|
|
[[VLCMainWindow sharedInstance] setNonembedded:!b_mainwindow_has_video];
|
|
|
|
|
|
|
|
// beware of order, setActiveVideoPlayback:, setHasActiveVideo: and setNonembedded: must be called before
|
|
|
|
if ([o_new_video_window class] == [VLCMainWindow class])
|
|
|
|
[[VLCMainWindow sharedInstance] changePlaylistState: psVideoStartedOrStoppedEvent];
|
|
|
|
|
2012-11-15 19:45:00 +01:00
|
|
|
if (b_nonembedded) {
|
2015-03-08 17:49:01 +01:00
|
|
|
// events might be posted before window is created, so call them again
|
2015-06-27 22:31:54 +02:00
|
|
|
[[[VLCMain sharedInstance] mainWindow] updateName];
|
|
|
|
[[[VLCMain sharedInstance] mainWindow] updateWindow]; // update controls bar
|
2012-10-27 13:00:50 +02: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
|
|
|
|
char *psz_splitter = var_GetString(pl_Get(VLCIntf), "video-splitter");
|
|
|
|
BOOL b_have_splitter = psz_splitter != NULL && *psz_splitter != '\0';
|
|
|
|
free(psz_splitter);
|
|
|
|
|
2015-03-14 15:59:26 +01:00
|
|
|
if (!b_video_wallpaper && !b_have_splitter && (var_InheritBool(VLCIntf, "fullscreen") || var_GetBool(pl_Get(VLCIntf), "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
|
|
|
|
var_SetBool(p_wnd->p_parent, "fullscreen", 1);
|
|
|
|
|
|
|
|
[self setFullscreen:1 forWindow:p_wnd withAnimation:NO];
|
|
|
|
}
|
|
|
|
|
|
|
|
NSEnableScreenUpdates();
|
|
|
|
|
2015-07-14 22:10:40 +02:00
|
|
|
return o_vout_view;
|
2012-10-02 19:26:37 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
- (void)removeVoutforDisplay:(NSValue *)o_key
|
|
|
|
{
|
|
|
|
VLCVideoWindowCommon *o_window = [o_vout_dict objectForKey:o_key];
|
2012-11-15 19:45:00 +01:00
|
|
|
if (!o_window) {
|
2012-10-02 21:05:26 +02:00
|
|
|
msg_Err(VLCIntf, "Cannot close nonexisting window");
|
|
|
|
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();
|
2014-03-30 21:43:15 +02:00
|
|
|
BOOL b_native = [[VLCMainWindow sharedInstance] nativeFullscreenMode];
|
|
|
|
|
|
|
|
// 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
|
|
|
|
2012-10-02 19:26:37 +02:00
|
|
|
[o_vout_dict removeObjectForKey:o_key];
|
2013-10-25 18:19:43 +02:00
|
|
|
if ([o_vout_dict count] == 0) {
|
2012-10-27 13:13:21 +02:00
|
|
|
[[VLCMain sharedInstance] setActiveVideoPlayback:NO];
|
2013-10-25 18:19:43 +02:00
|
|
|
i_statusLevelWindowCounter = 0;
|
|
|
|
}
|
2014-03-03 22:22:09 +01:00
|
|
|
|
|
|
|
if ([o_window class] == [VLCMainWindow class]) {
|
|
|
|
b_mainwindow_has_video = NO;
|
|
|
|
|
|
|
|
// video in main window might get stopped while another vout is open
|
|
|
|
if ([o_vout_dict count] > 0)
|
|
|
|
[[VLCMainWindow sharedInstance] setNonembedded:YES];
|
|
|
|
|
|
|
|
// beware of order, setActiveVideoPlayback:, setHasActiveVideo: and setNonembedded: must be called before
|
|
|
|
[[VLCMainWindow sharedInstance] changePlaylistState: psVideoStartedOrStoppedEvent];
|
|
|
|
}
|
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
|
|
|
|
{
|
|
|
|
VLCVideoWindowCommon *o_window = [o_vout_dict objectForKey:[NSValue valueWithPointer:p_wnd]];
|
2012-11-15 19:45:00 +01:00
|
|
|
if (!o_window) {
|
2012-10-02 21:05:26 +02:00
|
|
|
msg_Err(VLCIntf, "Cannot set size for nonexisting window");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
[o_window setNativeVideoSize:size];
|
|
|
|
}
|
|
|
|
|
2013-01-12 16:29:26 +01:00
|
|
|
- (void)setWindowLevel:(NSInteger)i_level forWindow:(vout_window_t *)p_wnd
|
|
|
|
{
|
2013-11-09 17:26:46 +01:00
|
|
|
VLCVideoWindowCommon *o_window = [o_vout_dict objectForKey:[NSValue valueWithPointer:p_wnd]];
|
|
|
|
if (!o_window) {
|
|
|
|
msg_Err(VLCIntf, "Cannot set level for nonexisting window");
|
|
|
|
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) {
|
|
|
|
i_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 {
|
2013-10-25 18:19:43 +02:00
|
|
|
if (i_statusLevelWindowCounter > 0)
|
|
|
|
i_statusLevelWindowCounter--;
|
|
|
|
|
2013-01-12 16:29:26 +01:00
|
|
|
if (i_statusLevelWindowCounter == 0) {
|
|
|
|
[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
|
|
|
{
|
|
|
|
intf_thread_t *p_intf = VLCIntf;
|
|
|
|
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;
|
|
|
|
playlist_t *p_playlist = pl_Get(p_intf);
|
2014-03-04 18:09:24 +01:00
|
|
|
BOOL b_fullscreen = i_full != 0;
|
2013-02-15 20:19:08 +01:00
|
|
|
|
|
|
|
if (!var_GetBool(p_playlist, "fullscreen") != !b_fullscreen)
|
|
|
|
var_SetBool(p_playlist, "fullscreen", b_fullscreen);
|
|
|
|
|
|
|
|
VLCVideoWindowCommon *o_current_window = nil;
|
|
|
|
if(p_wnd)
|
|
|
|
o_current_window = [o_vout_dict objectForKey:[NSValue valueWithPointer:p_wnd]];
|
|
|
|
|
2015-05-28 20:24:43 +02:00
|
|
|
if (var_InheritBool(p_intf, "macosx-dim-keyboard")) {
|
|
|
|
[o_keyboard_backlight switchLightsAsync:!b_fullscreen];
|
|
|
|
}
|
|
|
|
|
2013-02-15 20:19:08 +01:00
|
|
|
if (b_nativeFullscreenMode) {
|
|
|
|
if(!o_current_window)
|
2013-04-03 18:38:58 +02:00
|
|
|
o_current_window = [VLCMainWindow sharedInstance];
|
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) {
|
|
|
|
input_thread_t * p_input = pl_CurrentInput(p_intf);
|
|
|
|
if (p_input != NULL && [[VLCMain sharedInstance] activeVideoPlayback]) {
|
|
|
|
// 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
|
|
|
|
|
|
|
}
|
|
|
|
if (p_input)
|
|
|
|
vlc_object_release(p_input);
|
|
|
|
} 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
|
|
|
|
|
|
|
|
- (void)updateWindowsControlsBarWithSelector:(SEL)aSel
|
|
|
|
{
|
|
|
|
[o_vout_dict enumerateKeysAndObjectsUsingBlock:^(id key, id obj, BOOL *stop) {
|
|
|
|
if ([obj respondsToSelector:@selector(controlsBar)]) {
|
|
|
|
id o_controlsBar = [obj controlsBar];
|
|
|
|
if (o_controlsBar)
|
|
|
|
[o_controlsBar performSelector:aSel];
|
|
|
|
}
|
|
|
|
}];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void)updateWindowsUsingBlock:(void (^)(VLCVideoWindowCommon *o_window))windowUpdater
|
|
|
|
{
|
|
|
|
[o_vout_dict enumerateKeysAndObjectsUsingBlock:^(id key, id obj, BOOL *stop) {
|
|
|
|
if ([obj isKindOfClass: [NSWindow class]])
|
|
|
|
windowUpdater(obj);
|
|
|
|
}];
|
|
|
|
}
|
|
|
|
|
2013-01-12 16:29:26 +01:00
|
|
|
- (void)updateWindowLevelForHelperWindows:(NSInteger)i_level
|
|
|
|
{
|
|
|
|
if (var_InheritBool(VLCIntf, "video-wallpaper"))
|
|
|
|
return;
|
|
|
|
|
|
|
|
i_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];
|
2015-07-15 16:54:31 +02:00
|
|
|
[[VLCMainWindow sharedInstance] 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];
|
2015-07-15 18:25:53 +02:00
|
|
|
[[VLCInfo sharedInstance] 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
|