Commit 0cdef305 authored by Felix Paul Kühne's avatar Felix Paul Kühne

macosx: re-implemented VLCVoutView and removed dead or outdated code

parent e3a1b511
......@@ -70,10 +70,8 @@ contrib-macosx-$(ARCH)-$(CONTRIBREV).tar.bz2:
(cd build-src && rm -rf *gecko* && $(MAKE) .gecko)
# libiconv.la is no longer present on Snow Leopard, so fix possible references to it, which would
# result in linking issues
ifdef HAVE_MACOSX_DARWIN_10
(cd $(PREFIX)/lib && sed -e 's%/usr/lib/libiconv.la%$(PREFIX)/lib/libiconv.la%g' -i.orig *.la && rm -f *.la.orig)
(cd build-src && rm -f .iconv && $(MAKE) .iconv-from-os)
endif
touch .$(CONTRIBREV)
using-bin: .$(CONTRIBREV)
......
......@@ -2,9 +2,9 @@
<archive type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="7.10">
<data>
<int key="IBDocument.SystemTarget">1040</int>
<string key="IBDocument.SystemVersion">11C26</string>
<string key="IBDocument.SystemVersion">11A511</string>
<string key="IBDocument.InterfaceBuilderVersion">851</string>
<string key="IBDocument.AppKitVersion">1138.11</string>
<string key="IBDocument.AppKitVersion">1138</string>
<string key="IBDocument.HIToolboxVersion">566.00</string>
<object class="NSMutableDictionary" key="IBDocument.PluginVersions">
<bool key="EncodedWithXMLCoder">YES</bool>
......@@ -21,14 +21,14 @@
</object>
<object class="NSMutableArray" key="IBDocument.EditedObjectIDs">
<bool key="EncodedWithXMLCoder">YES</bool>
<integer value="1617"/>
<integer value="2730"/>
<integer value="4682"/>
<integer value="4596"/>
<integer value="915"/>
<integer value="334"/>
<integer value="283"/>
<integer value="1617"/>
<integer value="2730"/>
<integer value="4722"/>
<integer value="283"/>
<integer value="2"/>
<integer value="334"/>
</object>
<object class="NSArray" key="IBDocument.PluginDependencies">
<bool key="EncodedWithXMLCoder">YES</bool>
......@@ -1217,7 +1217,7 @@
<bool key="CIEnabled">YES</bool>
</object>
<int key="NSViewLayerContentsRedrawPolicy">2</int>
<string key="NSClassName">NSView</string>
<string key="NSClassName">VLCVoutView</string>
</object>
</object>
<string key="NSFrameSize">{604, 310}</string>
......@@ -16238,6 +16238,25 @@ LCAuLi4</string>
<string key="superclassName">NSView</string>
<reference key="sourceIdentifier" ref="736371707"/>
</object>
<object class="IBPartialClassDescription">
<string key="className">VLCVoutView</string>
<string key="superclassName">NSView</string>
<object class="NSMutableDictionary" key="outlets">
<string key="NS.key.0">o_window</string>
<string key="NS.object.0">id</string>
</object>
<object class="NSMutableDictionary" key="toOneOutletInfosByName">
<string key="NS.key.0">o_window</string>
<object class="IBToOneOutletInfo" key="NS.object.0">
<string key="name">o_window</string>
<string key="candidateClassName">id</string>
</object>
</object>
<object class="IBClassDescriptionSource" key="sourceIdentifier">
<string key="majorKey">IBDocumentRelativeSource</string>
<string key="minorKey">../../../../../modules/gui/macosx/vout.h</string>
</object>
</object>
</object>
<object class="NSMutableArray" key="referencedPartialClassDescriptionsV3.2+">
<bool key="EncodedWithXMLCoder">YES</bool>
......
......@@ -56,5 +56,4 @@
- (void)setAspectRatioLocked:(BOOL)b_value;
- (BOOL)aspectRatioIsLocked;
- (void)toggleFullscreen;
- (id)voutView;
@end
......@@ -23,7 +23,6 @@
#import "CoreInteraction.h"
#import "intf.h"
#import "vout.h"
#import "open.h"
#import <vlc_playlist.h>
#import <vlc_input.h>
......@@ -93,9 +92,6 @@ static VLCCoreInteraction *_o_sharedInstance = nil;
- (void)stop
{
var_SetInteger( VLCIntf->p_libvlc, "key-action", ACTIONID_STOP );
/* Close the window directly, because we do know that there
* won't be anymore video. It's currently waiting a bit. */
[[[self voutView] window] orderOut:self];
}
- (void)faster
......@@ -270,26 +266,4 @@ static VLCCoreInteraction *_o_sharedInstance = nil;
vlc_object_release( p_input );
}
}
- (id)voutView
{
id o_window;
id o_voutView = nil;
id o_embeddedViewList = [[VLCMain sharedInstance] embeddedList];
NSEnumerator *o_enumerator = [[NSApp orderedWindows] objectEnumerator];
while( !o_voutView && ( o_window = [o_enumerator nextObject] ) )
{
/* We have an embedded vout */
if( [o_embeddedViewList windowContainsEmbedded: o_window] )
{
o_voutView = [o_embeddedViewList viewForWindow: o_window];
}
/* We have a detached vout */
else if( [[o_window className] isEqualToString: @"VLCVoutWindow"] )
{
o_voutView = [o_window voutView];
}
}
return [[o_voutView retain] autorelease];
}
@end
......@@ -251,6 +251,7 @@
var:(const char *)psz_variable
selector:(SEL)pf_callback;
- (id)voutMenu;
@end
/*****************************************************************************
......
......@@ -623,6 +623,11 @@ static VLCMainMenu *_o_sharedInstance = nil;
}
}
- (id)voutMenu
{
return o_vout_menu;
}
#pragma mark -
#pragma mark Panels
......@@ -1204,8 +1209,7 @@ static VLCMainMenu *_o_sharedInstance = nil;
{
if( [o_title isEqualToString: _NS("Float on Top")] )
{
var_Get( p_vout, "video-on-top", &val );
[o_mi setState: val.b_bool ? NSOnState : NSOffState];
[o_mi setState: var_GetBool( p_vout, "video-on-top" )];
}
bEnabled = TRUE;
......@@ -1215,8 +1219,7 @@ static VLCMainMenu *_o_sharedInstance = nil;
}
if( [o_title isEqualToString: _NS("Fullscreen")] )
{
var_Get( p_playlist, "fullscreen", &val );
[o_mi setState: val.b_bool];
[o_mi setState: var_GetBool( p_playlist, "fullscreen" )];
bEnabled = TRUE;
}
[self setupMenus]; /* Make sure video menu is up to date */
......
......@@ -157,6 +157,8 @@
- (void)hasBecomeFullscreen;
- (void)setFrameOnMainThread:(NSData*)packedargs;
- (id)fspanel;
@end
@interface VLCProgressBarGradientEffect : NSView {
......
......@@ -646,8 +646,8 @@ static VLCMainWindow *_o_sharedInstance = nil;
int i_volume_step = 0;
i_volume_step = config_GetInt( VLCIntf->p_libvlc, "volume-step" );
[o_volume_sld setFloatValue: (float)i_lastShownVolume / i_volume_step];
if ([o_fspanel respondsToSelector:@selector(setVolumeLevel:)])
[o_fspanel setVolumeLevel: (float)i_lastShownVolume / i_volume_step];
// if ([o_fspanel respondsToSelector:@selector(setVolumeLevel:)])
// [o_fspanel setVolumeLevel: (float)i_lastShownVolume / i_volume_step];
}
}
......@@ -1292,6 +1292,10 @@ static VLCMainWindow *_o_sharedInstance = nil;
}
}
- (id)fspanel
{
return o_fspanel;
}
#pragma mark -
#pragma mark Side Bar Data handling
......
......@@ -166,19 +166,6 @@
}
}
- (IBAction)toogleFullscreen:(id)sender {
[[VLCCoreInteraction sharedInstance] toggleFullscreen];
}
- (BOOL) isFullscreen {
id o_vout_view = [[VLCCoreInteraction sharedInstance] voutView];
if( o_vout_view )
{
return [o_vout_view isFullscreen];
}
return NO;
}
- (IBAction)telxTransparent:(id)sender
{
vlc_object_t *p_vbi;
......@@ -329,11 +316,14 @@
/* Escape */
if( key == (unichar) 0x1b )
{
id o_vout_view = [[VLCCoreInteraction sharedInstance] voutView];
if( o_vout_view && [o_vout_view isFullscreen] )
vout_thread_t *p_vout = getVout();
if (p_vout)
{
[o_vout_view toggleFullscreen];
eventHandled = YES;
if (var_GetBool( p_vout, "fullscreen" ))
{
[[VLCCoreInteraction sharedInstance] toggleFullscreen];
eventHandled = YES;
}
}
}
else if( key == ' ' )
......
......@@ -38,6 +38,8 @@
/* SetSystemUIMode, ... */
#import <Carbon/Carbon.h>
#if 0
/*****************************************************************************
* VLCEmbeddedWindow Implementation
*****************************************************************************/
......@@ -1006,3 +1008,5 @@
NSRectFill(divider);*/
}
@end
#endif
......@@ -178,13 +178,15 @@
- (void)setActive:(id)noData
{
if( [[VLCCoreInteraction sharedInstance] voutView] != nil )
vout_thread_t *p_vout = getVout();
if (p_vout)
{
if( [[[VLCCoreInteraction sharedInstance] voutView] isFullscreen] )
if (var_GetBool( p_vout, "fullscreen" ))
{
b_nonActive = NO;
[self fadeIn];
}
vlc_object_release( p_vout );
}
}
......@@ -247,8 +249,13 @@
- (void)mouseExited:(NSEvent *)theEvent
{
/* give up our focus, so the vout may show us again without letting the user clicking it */
if( [[[VLCCoreInteraction sharedInstance] voutView] isFullscreen] )
[[[[VLCCoreInteraction sharedInstance] voutView] window] makeKeyWindow];
vout_thread_t *p_vout = getVout();
if (p_vout)
{
if (var_GetBool( p_vout, "fullscreen" ))
[[[[VLCCoreInteraction sharedInstance] voutView] window] makeKeyWindow];
vlc_object_release( p_vout );
}
}
- (void)hideMouse
......
......@@ -744,10 +744,6 @@ static VLCMain *_o_sharedMainInstance = nil;
[NSApp activateIgnoringOtherApps:YES];
[o_remote stopListening: self];
var_SetInteger( p_intf->p_libvlc, "key-action", ACTIONID_STOP );
/* Close the window directly, because we do know that there
* won't be anymore video. It's currently waiting a bit. */
[[[o_coreinteraction voutView] window] orderOut:self];
}
#pragma mark -
......@@ -1276,6 +1272,15 @@ unsigned int CocoaKeyToVLC( unichar i_key )
- (void)updatePlaybackPosition
{
[o_mainwindow updateTimeSlider];
input_thread_t * p_input;
p_input = pl_CurrentInput( p_intf );
if( p_input )
{
if( var_GetInteger( p_input, "state" ) == PLAYING_S )
UpdateSystemActivity( UsrActivity );
vlc_object_release( p_input );
}
}
- (void)updateVolume
......
/*****************************************************************************
* vout.h: MacOS X interface module
* vout.h: MacOS X video output module
*****************************************************************************
* Copyright (C) 2001-2007 the VideoLAN team
* Copyright (C) 2002-2011 the VideoLAN team
* $Id$
*
* Authors: Colin Delacroix <colin@zoy.org>
* Florian G. Pflug <fgp@phlo.org>
* Jon Lech Johansen <jon-vl@nanocrew.net>
* Authors: Derk-Jan Hartman <hartman at videolan dot org>
* Eric Petit <titer@m0k.org>
* Benjamin Pracht <bigben at videolan dot org>
* Pierre d'Herbemont <pdherbemont # videolan org>
* Felix Paul Kühne <fkuehne at videolan dot org>
*
* 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
......@@ -25,107 +25,13 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
#import "misc.h"
/*****************************************************************************
* VLCEmbeddedList interface
*****************************************************************************/
@interface VLCEmbeddedList : NSObject
{
NSMutableArray * o_embedded_array;
}
- (id)embeddedVout;
- (void)releaseEmbeddedVout: (id)o_vout_view;
- (void)addEmbeddedVout: (id)o_vout_view;
- (BOOL)windowContainsEmbedded: (id)o_window;
- (id)viewForWindow: (id)o_window;
@end
/*****************************************************************************
* VLCVoutView interface
*****************************************************************************/
@protocol VLCVoutViewResetting
+ (void)resetVout: (vout_thread_t *)p_vout;
@end
@interface VLCVoutView : NSView
{
vout_thread_t * p_vout;
NSRect * s_frame;
NSView * o_view;
NSView <VLCVoutViewResetting> * o_view;
vout_thread_t * p_real_vout;
id o_window;
}
- (BOOL)setVout: (vout_thread_t *) p_arg_vout subView: (NSView *) view
frame: (NSRect *) s_arg_frame;
- (void)closeVout;
- (void)updateTitle;
- (void)manage;
- (void)scaleWindowWithFactor: (float)factor animate: (BOOL)animate;
- (void)setOnTop:(BOOL)b_on_top;
- (void)toggleFloatOnTop;
- (void)toggleFullscreen;
- (BOOL)isFullscreen;
- (void)snapshot;
- (id)voutWindow;
+ (id)voutView: (vout_thread_t *)p_vout subView: (NSView *) view
frame: (NSRect *) s_frame;
+ (vout_thread_t *)realVout: (vout_thread_t *)p_vout;
- (void)enterFullscreen;
- (void)leaveFullscreen;
@end
/*****************************************************************************
* VLCVoutDetachedView interface
*****************************************************************************/
@interface VLCDetachedVoutView : VLCVoutView
{
mtime_t i_time_mouse_last_moved;
}
- (void)hideMouse: (BOOL)b_hide;
@end
/*****************************************************************************
* VLCEmbeddedView interface
*****************************************************************************/
@interface VLCEmbeddedVoutView : VLCVoutView
{
BOOL b_used;
id o_embeddedwindow;
}
- (void)setUsed: (BOOL)b_new_used;
- (BOOL)isUsed;
@end
/*****************************************************************************
* VLCVoutWindow interface
*****************************************************************************/
@interface VLCVoutWindow : VLCWindow
{
vout_thread_t * p_vout;
VLCVoutView * o_view;
NSRect * s_frame;
bool b_init_ok;
BOOL fullscreen;
NSRect initialFrame;
}
- (id) initWithVout: (vout_thread_t *) p_vout view: (VLCVoutView *) view
frame: (NSRect *) s_frame;
- (id)initMainThread: (id) sender;
- (void)leaveFullscreen;
- (void)enterFullscreen;
- (id)voutView;
@end
@end
\ No newline at end of file
/*****************************************************************************
* vout.m: MacOS X video output module
*****************************************************************************
* Copyright (C) 2001-2011 the VideoLAN team
* Copyright (C) 2002-2011 the VideoLAN team
* $Id$
*
* Authors: Colin Delacroix <colin@zoy.org>
* Florian G. Pflug <fgp@phlo.org>
* Jon Lech Johansen <jon-vl@nanocrew.net>
* Derk-Jan Hartman <hartman at videolan dot org>
* Authors: Derk-Jan Hartman <hartman at videolan dot org>
* Eric Petit <titer@m0k.org>
* Benjamin Pracht <bigben at videolan dot org>
* Pierre d'Herbemont <pdherbemont # videolan org>
* Felix Paul Kühne <fkuehne at videolan dot org>
*
* 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
......@@ -30,34 +28,20 @@
/*****************************************************************************
* Preamble
*****************************************************************************/
#include <stdlib.h> /* free() */
#include <string.h>
/* prevent system sleep */
#import <CoreServices/CoreServices.h>
/* FIXME: HACK!! */
#ifdef __x86_64__
#import <CoreServices/../Frameworks/OSServices.framework/Headers/Power.h>
#endif
/* SystemUIMode */
#import <Carbon/Carbon.h>
#include "intf.h"
#include "fspanel.h"
#include "vout.h"
#import "controls.h"
#import "embeddedwindow.h"
#include <vlc_common.h>
#include <vlc_vout_window.h>
#include <vlc_vout_display.h>
#include <vlc_keys.h>
#include <vlc_url.h>
#if 0
#import <stdlib.h> /* free() */
#import <string.h>
#import "intf.h"
#import "fspanel.h"
#import "vout.h"
#import "CoreInteraction.h"
#import "MainMenu.h"
#import "MainWindow.h"
#import <vlc_common.h>
#import <vlc_vout_window.h>
#import <vlc_vout_display.h>
#import <vlc_keys.h>
/*****************************************************************************
* DeviceCallback: Callback triggered when the video-device variable is changed
*****************************************************************************/
......@@ -76,182 +60,90 @@ int DeviceCallback( vlc_object_t *p_this, const char *psz_variable,
return VLC_SUCCESS;
}
/*****************************************************************************
* VLCEmbeddedList implementation
*****************************************************************************/
@implementation VLCEmbeddedList
- (id)init
{
[super init];
o_embedded_array = [NSMutableArray array];
return self;
}
- (id)embeddedVout
{
unsigned int i;
for( i = 0; i < [o_embedded_array count]; i++ )
{
id o_vout_view = [o_embedded_array objectAtIndex: i];
if( ![o_vout_view isUsed] )
{
[o_vout_view setUsed: YES];
return o_vout_view;
}
}
return nil;
}
- (void)releaseEmbeddedVout: (id)o_vout_view
{
if( [o_embedded_array containsObject: o_vout_view] )
{
[o_vout_view setUsed: NO];
}
else
{
msg_Warn( VLCIntf, "cannot find Video Output");
}
}
- (void)addEmbeddedVout: (id)o_vout_view
{
if( ![o_embedded_array containsObject: o_vout_view] )
{
[o_embedded_array addObject: o_vout_view];
}
}
- (BOOL)windowContainsEmbedded: (id)o_window
{
return ([self viewForWindow: o_window] == nil ? NO : YES );
}
- (id)viewForWindow: (id)o_window
{
if( o_embedded_array != nil )
{
id o_enumerator = [o_embedded_array objectEnumerator];
id o_current_embedded;
if( o_window != nil )
{
while( (o_current_embedded = [o_enumerator nextObject]) )
{
if( [o_current_embedded voutWindow] == o_window )
{
return o_current_embedded;
}
}
}
}
return nil;
}
@end
/*****************************************************************************
* VLCVoutView implementation
*****************************************************************************/
@implementation VLCVoutView
- (id)initWithFrame: (NSRect)frameRect
- (void)setVoutView:(id)theView
{
self = [super initWithFrame: frameRect];
p_vout = NULL;
o_view = nil;
s_frame = &frameRect;
p_real_vout = NULL;
o_window = nil;
return self;
}
vout_thread_t * p_vout = getVout();
if( !p_vout )
return;
- (BOOL)setVout: (vout_thread_t *) vout
subView: (NSView *) view
frame: (NSRect *) frame
{
int i_device;
NSAutoreleasePool *o_pool = [[NSAutoreleasePool alloc] init];
NSArray *o_screens = [NSScreen screens];
p_vout = vout;
o_view = view;
s_frame = frame;
if( [o_screens count] <= 0 )
{
msg_Err( VLCIntf, "no OSX screens available" );
return NO;
return;
}
p_real_vout = [VLCVoutView realVout: p_vout];
/* Get the pref value when this is the first time, otherwise retrieve the device from the top level video-device var */
if( var_Type( p_real_vout->p_libvlc, "video-device" ) == 0 )
if( var_Type( p_vout->p_libvlc, "video-device" ) == 0 )
{
i_device = var_GetInteger( p_vout, "macosx-vdev" );
}
else
{
i_device = var_GetInteger( p_real_vout->p_libvlc, "video-device" );
i_device = var_GetInteger( p_vout->p_libvlc, "video-device" );
}
/* Setup the menuitem for the multiple displays. */
if( var_Type( p_real_vout, "video-device" ) == 0 )
if( var_Type( p_vout, "video-device" ) == 0 )
{
int i = 1;
vlc_value_t val2, text;
NSScreen * o_screen;
var_Create( p_real_vout, "video-device", VLC_VAR_INTEGER |
VLC_VAR_HASCHOICE );
var_Create( p_vout, "video-device", VLC_VAR_INTEGER |
VLC_VAR_HASCHOICE );
text.psz_string = _("Fullscreen Video Device");
var_Change( p_real_vout, "video-device", VLC_VAR_SETTEXT, &text, NULL );
var_Change( p_vout, "video-device", VLC_VAR_SETTEXT, &text, NULL );
NSEnumerator * o_enumerator = [o_screens objectEnumerator];
val2.i_int = 0;
text.psz_string = _("Default");
var_Change( p_real_vout, "video-device",
VLC_VAR_ADDCHOICE, &val2, &text );
var_Set( p_real_vout, "video-device", val2 );
var_Change( p_vout, "video-device", VLC_VAR_ADDCHOICE, &val2, &text );
var_Set( p_vout, "video-device", val2 );
while( (o_screen = [o_enumerator nextObject]) != NULL )
{
char psz_temp[255];
NSRect s_rect = [o_screen frame];
snprintf( psz_temp, sizeof(psz_temp)/sizeof(psz_temp[0])-1,
"%s %d (%dx%d)", _("Screen"), i,
(int)s_rect.size.width, (int)s_rect.size.height );
snprintf( psz_temp, sizeof(psz_temp)/sizeof(psz_temp[0])-1, "%s %d (%dx%d)", _("Screen"), i, (int)s_rect.size.width, (int)s_rect.size.height );
text.psz_string = psz_temp;
val2.i_int = (int)[o_screen displayID];
var_Change( p_real_vout, "video-device",
VLC_VAR_ADDCHOICE, &val2, &text );
var_Change( p_vout, "video-device", VLC_VAR_ADDCHOICE, &val2, &text );
if( (int)[o_screen displayID] == i_device )
{
var_Set( p_real_vout, "video-device", val2 );
var_Set( p_vout, "video-device", val2 );
}
i++;
}
var_AddCallback( p_real_vout, "video-device", DeviceCallback,
NULL );
var_AddCallback( p_vout, "video-device", DeviceCallback,
NULL );
val2.b_bool = true;
var_Set( p_real_vout, "intf-change", val2 );
var_Set( p_vout, "intf-change", val2 );
}
/* Add the view. It's automatically resized to fit the window */
if (o_view) {
[o_view removeFromSuperview];
[o_view release];
}
o_view = theView;
[o_view retain];
[self addSubview: o_view];
[self setAutoresizesSubviews: YES];
[o_pool release];
return YES;
/* make sure that we look alright */
[[self window] setAlphaValue: var_CreateGetFloat( p_vout, "macosx-opaqueness" )];
vlc_object_release( p_vout );
}