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
......@@ -2,7 +2,7 @@
<archive type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="7.10">
<data>
<int key="IBDocument.SystemTarget">1050</int>
<string key="IBDocument.SystemVersion">12C54</string>
<string key="IBDocument.SystemVersion">12C60</string>
<string key="IBDocument.InterfaceBuilderVersion">851</string>
<string key="IBDocument.AppKitVersion">1187.34</string>
<string key="IBDocument.HIToolboxVersion">625.00</string>
......@@ -21,7 +21,9 @@
</object>
<object class="NSMutableArray" key="IBDocument.EditedObjectIDs">
<bool key="EncodedWithXMLCoder">YES</bool>
<integer value="2"/>
<integer value="2730"/>
<integer value="334"/>
<integer value="4756"/>
</object>
<object class="NSArray" key="IBDocument.PluginDependencies">
<bool key="EncodedWithXMLCoder">YES</bool>
......@@ -2082,6 +2084,7 @@
<int key="NSMnemonicLoc">2147483647</int>
<reference key="NSOnImage" ref="447396056"/>
<reference key="NSMixedImage" ref="100133332"/>
<int key="NSTag">1</int>
</object>
<object class="NSMenuItem" id="633479871">
<reference key="NSMenu" ref="598695780"/>
......@@ -2091,6 +2094,7 @@
<int key="NSMnemonicLoc">2147483647</int>
<reference key="NSOnImage" ref="447396056"/>
<reference key="NSMixedImage" ref="100133332"/>
<int key="NSTag">2</int>
</object>
<object class="NSMenuItem" id="115305473">
<reference key="NSMenu" ref="598695780"/>
......@@ -2100,6 +2104,7 @@
<int key="NSMnemonicLoc">2147483647</int>
<reference key="NSOnImage" ref="447396056"/>
<reference key="NSMixedImage" ref="100133332"/>
<int key="NSTag">3</int>
</object>
<object class="NSMenuItem" id="137277528">
<reference key="NSMenu" ref="598695780"/>
......@@ -6953,46 +6958,6 @@ LCAuLi4</string>
</object>
<int key="connectionID">4738</int>
</object>
<object class="IBConnectionRecord">
<object class="IBActionConnection" key="connection">
<string key="label">resizeVideoWindow:</string>
<reference key="source" ref="651263286"/>
<reference key="destination" ref="306486441"/>
</object>
<int key="connectionID">4741</int>
</object>
<object class="IBConnectionRecord">
<object class="IBActionConnection" key="connection">
<string key="label">resizeVideoWindow:</string>
<reference key="source" ref="651263286"/>
<reference key="destination" ref="848898341"/>
</object>
<int key="connectionID">4742</int>
</object>
<object class="IBConnectionRecord">
<object class="IBActionConnection" key="connection">
<string key="label">resizeVideoWindow:</string>
<reference key="source" ref="651263286"/>
<reference key="destination" ref="633479871"/>
</object>
<int key="connectionID">4743</int>
</object>
<object class="IBConnectionRecord">
<object class="IBActionConnection" key="connection">
<string key="label">resizeVideoWindow:</string>
<reference key="source" ref="651263286"/>
<reference key="destination" ref="115305473"/>
</object>
<int key="connectionID">4744</int>
</object>
<object class="IBConnectionRecord">
<object class="IBActionConnection" key="connection">
<string key="label">toggleFullscreen:</string>
<reference key="source" ref="651263286"/>
<reference key="destination" ref="606474125"/>
</object>
<int key="connectionID">4745</int>
</object>
<object class="IBConnectionRecord">
<object class="IBActionConnection" key="connection">
<string key="label">floatOnTop:</string>
......@@ -7009,14 +6974,6 @@ LCAuLi4</string>
</object>
<int key="connectionID">4747</int>
</object>
<object class="IBConnectionRecord">
<object class="IBActionConnection" key="connection">
<string key="label">toggleFullscreen:</string>
<reference key="source" ref="651263286"/>
<reference key="destination" ref="788765547"/>
</object>
<int key="connectionID">4748</int>
</object>
<object class="IBConnectionRecord">
<object class="IBActionConnection" key="connection">
<string key="label">createVideoSnapshot:</string>
......@@ -8009,6 +7966,54 @@ LCAuLi4</string>
</object>
<int key="connectionID">5395</int>
</object>
<object class="IBConnectionRecord">
<object class="IBActionConnection" key="connection">
<string key="label">resizeVideoWindow:</string>
<reference key="source" ref="651263286"/>
<reference key="destination" ref="306486441"/>
</object>
<int key="connectionID">5403</int>
</object>
<object class="IBConnectionRecord">
<object class="IBActionConnection" key="connection">
<string key="label">resizeVideoWindow:</string>
<reference key="source" ref="651263286"/>
<reference key="destination" ref="848898341"/>
</object>
<int key="connectionID">5404</int>
</object>
<object class="IBConnectionRecord">
<object class="IBActionConnection" key="connection">
<string key="label">resizeVideoWindow:</string>
<reference key="source" ref="651263286"/>
<reference key="destination" ref="633479871"/>
</object>
<int key="connectionID">5405</int>
</object>
<object class="IBConnectionRecord">
<object class="IBActionConnection" key="connection">
<string key="label">resizeVideoWindow:</string>
<reference key="source" ref="651263286"/>
<reference key="destination" ref="115305473"/>
</object>
<int key="connectionID">5406</int>
</object>
<object class="IBConnectionRecord">
<object class="IBActionConnection" key="connection">
<string key="label">toggleFullscreen:</string>
<reference key="source" ref="651263286"/>
<reference key="destination" ref="606474125"/>
</object>
<int key="connectionID">5407</int>
</object>
<object class="IBConnectionRecord">
<object class="IBActionConnection" key="connection">
<string key="label">toggleFullscreen:</string>
<reference key="source" ref="651263286"/>
<reference key="destination" ref="788765547"/>
</object>
<int key="connectionID">5408</int>
</object>
</object>
<object class="IBMutableOrderedSet" key="objectRecords">
<object class="NSArray" key="orderedObjects">
......@@ -12118,9 +12123,9 @@ LCAuLi4</string>
<string>{{600, 612}, {137, 103}}</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<boolean value="YES"/>
<string>{{476, 681}, {604, 310}}</string>
<string>{{528, 635}, {604, 310}}</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>{{476, 681}, {604, 310}}</string>
<string>{{528, 635}, {604, 310}}</string>
<boolean value="YES"/>
<boolean value="YES"/>
<boolean value="NO"/>
......@@ -12206,12 +12211,12 @@ LCAuLi4</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<boolean value="YES"/>
<boolean value="YES"/>
<string>{{816, 570}, {64, 6}}</string>
<string>{{1009, 808}, {64, 6}}</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<boolean value="YES"/>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<boolean value="YES"/>
<string>{{816, 550}, {64, 6}}</string>
<string>{{1009, 788}, {64, 6}}</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<boolean value="YES"/>
<string>{{340, 613}, {488, 40}}</string>
......@@ -12229,7 +12234,7 @@ LCAuLi4</string>
<boolean value="YES"/>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<boolean value="YES"/>
<string>{{390, 199}, {161, 223}}</string>
<string>{{838, 667}, {161, 223}}</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<boolean value="YES"/>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
......@@ -12313,14 +12318,14 @@ LCAuLi4</string>
<boolean value="YES"/>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<boolean value="YES"/>
<string>{{450, 715}, {518, 20}}</string>
<string>{{472, 974}, {518, 20}}</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<boolean value="YES"/>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<boolean value="YES"/>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<boolean value="YES"/>
<string>{{829, 352}, {208, 363}}</string>
<string>{{801, 611}, {208, 363}}</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<boolean value="YES"/>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
......@@ -12947,7 +12952,7 @@ LCAuLi4</string>
</object>
</object>
<nil key="sourceID"/>
<int key="maxID">5395</int>
<int key="maxID">5408</int>
</object>
<object class="IBClassDescriber" key="IBDocument.Classes">
<object class="NSMutableArray" key="referencedPartialClassDescriptions">
......@@ -15041,6 +15046,7 @@ LCAuLi4</string>
<string>dropzoneButtonAction:</string>
<string>removePodcast:</string>
<string>removePodcastWindowAction:</string>
<string>toggleFullscreenForCurrentWindow:</string>
<string>togglePlaylist:</string>
</object>
<object class="NSMutableArray" key="dict.values">
......@@ -15051,6 +15057,7 @@ LCAuLi4</string>
<string>id</string>
<string>id</string>
<string>id</string>
<string>id</string>
</object>
</object>
<object class="NSMutableDictionary" key="actionInfosByName">
......@@ -15062,6 +15069,7 @@ LCAuLi4</string>
<string>dropzoneButtonAction:</string>
<string>removePodcast:</string>
<string>removePodcastWindowAction:</string>
<string>toggleFullscreenForCurrentWindow:</string>
<string>togglePlaylist:</string>
</object>
<object class="NSMutableArray" key="dict.values">
......@@ -15086,6 +15094,10 @@ LCAuLi4</string>
<string key="name">removePodcastWindowAction:</string>
<string key="candidateClassName">id</string>
</object>
<object class="IBActionInfo">
<string key="name">toggleFullscreenForCurrentWindow:</string>
<string key="candidateClassName">id</string>
</object>
<object class="IBActionInfo">
<string key="name">togglePlaylist:</string>
<string key="candidateClassName">id</string>
......@@ -15097,7 +15109,6 @@ LCAuLi4</string>
<object class="NSArray" key="dict.sortedKeys">
<bool key="EncodedWithXMLCoder">YES</bool>
<string>o_chosen_category_lbl</string>
<string>o_current_video_window</string>
<string>o_dropzone_box</string>
<string>o_dropzone_btn</string>
<string>o_dropzone_lbl</string>
......@@ -15133,7 +15144,6 @@ LCAuLi4</string>
<string>id</string>
<string>id</string>
<string>id</string>
<string>id</string>
<string>VLCFSPanel</string>
<string>id</string>
<string>id</string>
......@@ -15164,7 +15174,6 @@ LCAuLi4</string>
<object class="NSArray" key="dict.sortedKeys">
<bool key="EncodedWithXMLCoder">YES</bool>
<string>o_chosen_category_lbl</string>
<string>o_current_video_window</string>
<string>o_dropzone_box</string>
<string>o_dropzone_btn</string>
<string>o_dropzone_lbl</string>
......@@ -15199,10 +15208,6 @@ LCAuLi4</string>
<string key="name">o_chosen_category_lbl</string>
<string key="candidateClassName">id</string>
</object>
<object class="IBToOneOutletInfo">
<string key="name">o_current_video_window</string>
<string key="candidateClassName">id</string>
</object>
<object class="IBToOneOutletInfo">
<string key="name">o_dropzone_box</string>
<string key="candidateClassName">id</string>
......@@ -15963,6 +15968,17 @@ LCAuLi4</string>
<object class="IBPartialClassDescription">
<string key="className">VLCVoutView</string>
<string key="superclassName">NSView</string>
<object class="NSMutableDictionary" key="actions">
<string key="NS.key.0">toggleFullscreenForCurrentWindow:</string>
<string key="NS.object.0">id</string>
</object>
<object class="NSMutableDictionary" key="actionInfosByName">
<string key="NS.key.0">toggleFullscreenForCurrentWindow:</string>
<object class="IBActionInfo" key="NS.object.0">
<string key="name">toggleFullscreenForCurrentWindow:</string>
<string key="candidateClassName">id</string>
</object>
</object>
<object class="IBClassDescriptionSource" key="sourceIdentifier">
<string key="majorKey">IBProjectSource</string>
<string key="minorKey">../../../modules/gui/macosx/VideoView.h</string>
......
......@@ -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;