Commit b7165d60 authored by David Fuhrmann's avatar David Fuhrmann

macosx: implement vout actions handling for multiple vout windows

Now, everything from the video menu and the basic stuff like fullscreen
should work. If it does'nt (e.g. fullscreen and resize with video-splitter module enabled)
please blame the core first. ;-)

TODO: There might be some getVout()-calls left which should be investigated.

close #6814
parent 87937a2d
......@@ -557,7 +557,7 @@ static VLCCoreInteraction *_o_sharedInstance = nil;
BOOL b_fs = var_ToggleBool(pl_Get(p_intf), "fullscreen");
vout_thread_t *p_vout = getVout();
vout_thread_t *p_vout = getVoutForActiveWindow();
if (p_vout) {
var_SetBool(p_vout, "fullscreen", b_fs);
vlc_object_release(p_vout);
......
......@@ -508,7 +508,7 @@ static VLCMainMenu *_o_sharedInstance = nil;
vlc_object_release(p_aout);
}
vout_thread_t * p_vout = input_GetVout(p_input);
vout_thread_t * p_vout = getVoutForActiveWindow();
if (p_vout != NULL) {
[self setupVarMenuItem: o_mi_aspect_ratio target: (vlc_object_t *)p_vout
......@@ -695,6 +695,7 @@ static VLCMainMenu *_o_sharedInstance = nil;
#pragma mark -
#pragma mark video menu
- (IBAction)toggleFullscreen:(id)sender
{
[[VLCCoreInteraction sharedInstance] toggleFullscreen];
......@@ -704,7 +705,7 @@ static VLCMainMenu *_o_sharedInstance = nil;
{
input_thread_t *p_input = pl_CurrentInput(VLCIntf);
if (p_input) {
vout_thread_t *p_vout = getVout();
vout_thread_t *p_vout = getVoutForActiveWindow();
if (p_vout) {
if (sender == o_mi_half_window)
var_SetFloat(p_vout, "zoom", 0.5);
......@@ -714,7 +715,7 @@ static VLCMainMenu *_o_sharedInstance = nil;
var_SetFloat(p_vout, "zoom", 2.0);
else
{
[[[[[VLCMain sharedInstance] mainWindow] videoView] window] performZoom:sender];
[[NSApp keyWindow] performZoom:sender];
}
vlc_object_release(p_vout);
}
......@@ -726,7 +727,7 @@ static VLCMainMenu *_o_sharedInstance = nil;
{
input_thread_t *p_input = pl_CurrentInput(VLCIntf);
if (p_input) {
vout_thread_t *p_vout = getVout();
vout_thread_t *p_vout = getVoutForActiveWindow();
if (p_vout) {
var_ToggleBool(p_vout, "video-on-top");
vlc_object_release(p_vout);
......@@ -739,7 +740,7 @@ static VLCMainMenu *_o_sharedInstance = nil;
{
input_thread_t *p_input = pl_CurrentInput(VLCIntf);
if (p_input) {
vout_thread_t *p_vout = getVout();
vout_thread_t *p_vout = getVoutForActiveWindow();
if (p_vout) {
var_TriggerCallback(p_vout, "video-snapshot");
vlc_object_release(p_vout);
......@@ -1270,7 +1271,7 @@ static VLCMainMenu *_o_sharedInstance = nil;
bEnabled = FALSE;
if (p_input != NULL) {
vout_thread_t *p_vout = input_GetVout(p_input);
vout_thread_t *p_vout = getVoutForActiveWindow();
if (p_vout != NULL) {
if ([o_title isEqualToString: _NS("Float on Top")])
[o_mi setState: var_GetBool(p_vout, "video-on-top")];
......
......@@ -766,7 +766,7 @@ static VLCMainWindow *_o_sharedInstance = nil;
} else {
if (var_InheritBool(VLCIntf, "embedded-video") || b_nativeFullscreenMode) {
o_vout_view = [o_video_view retain];
o_new_video_window = self;
o_new_video_window = [self retain];
b_nonembedded = NO;
} else {
NSWindowController *o_controller = [[NSWindowController alloc] initWithWindowNibName:@"DetachedVideoWindow"];
......@@ -796,7 +796,7 @@ static VLCMainWindow *_o_sharedInstance = nil;
}
[o_new_video_window setAlphaValue: config_GetFloat(VLCIntf, "macosx-opaqueness")];
[[[VLCMain sharedInstance] voutController] addVout:o_new_video_window forDisplay:p_wnd];
[[[VLCMain sharedInstance] voutController] addVout:[o_new_video_window autorelease] forDisplay:p_wnd];
if(b_nonembedded) {
// event occurs before window is created, so call again
......@@ -868,8 +868,10 @@ static VLCMainWindow *_o_sharedInstance = nil;
[NSCursor setHiddenUntilMouseMoves: YES];
}
#pragma mark -
#pragma mark Fullscreen support
- (void)showFullscreenController
{
if (b_fullscreen && [[VLCMain sharedInstance] activeVideoPlayback])
......
......@@ -25,6 +25,7 @@
#import "VLCVoutWindowController.h"
#import "intf.h"
#import "Windows.h"
#import "VideoView.h"
@implementation VLCVoutWindowController
......@@ -37,12 +38,18 @@
- (void)dealloc
{
NSArray *keys = [o_vout_dict allKeys];
for (NSValue *key in keys)
[self removeVoutforDisplay:key];
[o_vout_dict release];
[super dealloc];
}
- (void)addVout:(VLCVideoWindowCommon *)o_window forDisplay:(vout_window_t *)p_wnd
{
[[o_window videoView] setVoutThread:(vout_thread_t *)p_wnd->p_parent];
[o_vout_dict setObject:o_window forKey:[NSValue valueWithPointer:p_wnd]];
}
......@@ -60,7 +67,8 @@
if (![NSStringFromClass([o_window class]) isEqualToString:@"VLCMainWindow"]) {
[o_window orderOut:self];
}
[[o_window videoView] releaseVoutThread];
[o_vout_dict removeObjectForKey:o_key];
}
......
......@@ -25,6 +25,9 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
#import <vlc_vout.h>
/*****************************************************************************
* VLCVoutView interface
*****************************************************************************/
......@@ -34,5 +37,12 @@
NSTimeInterval t_lastScrollEvent;
CGFloat f_cumulated_magnification;
vout_thread_t *p_vout;
}
- (void)setVoutThread:(vout_thread_t *)p_vout_thread;
- (vout_thread_t *)voutThread;
- (void)releaseVoutThread;
@end
......@@ -51,6 +51,9 @@
- (void)dealloc
{
if (p_vout)
vlc_object_release(p_vout);
[self unregisterDraggedTypes];
[super dealloc];
}
......@@ -119,7 +122,6 @@
key = [[characters lowercaseString] characterAtIndex: 0];
if (key) {
vout_thread_t * p_vout = getVout();
/* Escape should always get you out of fullscreen */
if (key == (unichar) 0x1b) {
playlist_t * p_playlist = pl_Get(VLCIntf);
......@@ -140,9 +142,6 @@
else
msg_Dbg(VLCIntf, "could not send keyevent to VLC core");
if (p_vout)
vlc_object_release(p_vout);
return;
}
}
......@@ -256,6 +255,37 @@
}
}
#pragma mark -
#pragma mark Handling of vout related actions
- (void)setVoutThread:(vout_thread_t *)p_vout_thread
{
assert(p_vout == NULL);
p_vout = p_vout_thread;
vlc_object_hold(p_vout);
}
- (vout_thread_t *)voutThread
{
if (p_vout) {
vlc_object_hold(p_vout);
return p_vout;
}
return NULL;
}
- (void)releaseVoutThread
{
if (p_vout) {
vlc_object_release(p_vout);
p_vout = NULL;
}
}
#pragma mark -
#pragma mark Basic view behaviour and touch events handling
- (BOOL)mouseDownCanMoveWindow
{
return YES;
......
......@@ -32,6 +32,8 @@
* Missing extension to NSWindow
*****************************************************************************/
@class VLCVoutView;
@interface VLCWindow : NSWindow
{
BOOL b_canBecomeKeyWindow;
......@@ -55,12 +57,13 @@
/* animate mode is only supported in >=10.4 */
- (void)closeAndAnimate: (BOOL)animate;
- (VLCVoutView *)videoView;
@end
static const float f_min_video_height = 70.0;
@class VLCVoutView;
@class VLCControlsBarCommon;
/*****************************************************************************
......
......@@ -210,6 +210,15 @@
}
}
- (VLCVoutView *)videoView
{
if ([[self contentView] class] == [VLCVoutView class])
return (VLCVoutView *)[self contentView];
return nil;
}
@end
......@@ -685,7 +694,7 @@
/* We always try to do so */
[NSScreen unblackoutScreens];
vout_thread_t *p_vout = getVout();
vout_thread_t *p_vout = getVoutForActiveWindow();
if (p_vout) {
if (var_GetBool(p_vout, "video-on-top"))
[[o_video_view window] setLevel: NSStatusWindowLevel];
......
......@@ -162,7 +162,7 @@
@implementation NSApplication(ScriptSupport)
- (BOOL)scriptFullscreenMode {
vout_thread_t * p_vout = getVout();
vout_thread_t * p_vout = getVoutForActiveWindow();
if (!p_vout)
return NO;
BOOL b_value = var_GetBool(p_vout, "fullscreen");
......@@ -171,7 +171,7 @@
}
- (void)setScriptFullscreenMode:(BOOL)mode {
vout_thread_t * p_vout = getVout();
vout_thread_t * p_vout = getVoutForActiveWindow();
if (!p_vout)
return;
if (var_GetBool(p_vout, "fullscreen") == mode) {
......
......@@ -53,6 +53,7 @@
// You need to release those objects after use
input_thread_t *getInput(void);
vout_thread_t *getVout(void);
vout_thread_t *getVoutForActiveWindow(void);
audio_output_t *getAout(void);
/*****************************************************************************
......
......@@ -512,6 +512,24 @@ vout_thread_t *getVout(void)
return p_vout;
}
vout_thread_t *getVoutForActiveWindow(void)
{
vout_thread_t *p_vout = nil;
id currentWindow = [NSApp keyWindow];
if ([currentWindow respondsToSelector:@selector(videoView)]) {
VLCVoutView *videoView = [currentWindow videoView];
if (videoView) {
p_vout = [videoView voutThread];
}
}
if (!p_vout)
p_vout = getVout();
return p_vout;
}
audio_output_t *getAout(void)
{
input_thread_t *p_input = getInput();
......@@ -583,12 +601,6 @@ static VLCMain *_o_sharedMainInstance = nil;
return _o_sharedMainInstance;
}
- (void)dealloc
{
[o_vout_controller release];
[super dealloc];
}
- (void)setIntf: (intf_thread_t *)p_mainintf
{
p_intf = p_mainintf;
......@@ -854,6 +866,9 @@ static VLCMain *_o_sharedMainInstance = nil;
[o_mainmenu release];
[o_vout_controller release];
o_vout_controller = nil;
libvlc_Quit(p_intf->p_libvlc);
[o_mainwindow release];
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment