/*****************************************************************************
* vout.m: MacOS X video output module
*****************************************************************************
- * Copyright (C) 2001-2007 the VideoLAN team
+ * Copyright (C) 2001-2008 the VideoLAN team
* $Id$
*
* Authors: Colin Delacroix <colin@zoy.org>
* Derk-Jan Hartman <hartman at videolan dot org>
* Eric Petit <titer@m0k.org>
* Benjamin Pracht <bigben at videolan dot org>
- * Felix K\9fhne <fkuehne at videolan dot org>
+ * Felix 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
*****************************************************************************/
#include <errno.h> /* ENOMEM */
#include <stdlib.h> /* free() */
-#include <string.h> /* strerror() */
+#include <string.h>
/* BeginFullScreen, EndFullScreen */
#include <QuickTime/QuickTime.h>
*****************************************************************************/
@implementation VLCVoutView
-- (id)initWithFrame:(NSRect)frameRect
+- (id)initWithFrame: (NSRect)frameRect
{
[super initWithFrame: frameRect];
p_vout = NULL;
return self;
}
-- (BOOL)setVout: (vout_thread_t *) vout subView: (NSView *) view
- frame: (NSRect *) frame
+- (BOOL)setVout: (vout_thread_t *) vout
+ subView: (NSView *) view
+ frame: (NSRect *) frame
{
int i_device;
NSAutoreleasePool *o_pool = [[NSAutoreleasePool alloc] init];
p_vout = NULL;
s_frame = nil;
o_window = nil;
- p_real_vout = NULL;
+ p_real_vout = NULL;
}
- (void)updateTitle
{
- NSMutableString * o_title = nil, * o_mrl = nil;
+ NSString * o_title = nil;
+ NSMutableString * o_mrl = nil;
input_thread_t * p_input;
if( p_vout == NULL )
return;
}
- if( input_GetItem(p_input)->psz_name != NULL )
- o_title = [NSMutableString stringWithUTF8String:
- input_GetItem(p_input)->psz_name];
- if( input_GetItem(p_input)->psz_uri != NULL )
- o_mrl = [NSMutableString stringWithUTF8String:
- input_GetItem(p_input)->psz_uri];
+ char *psz_nowPlaying = input_item_GetNowPlaying ( input_GetItem( p_input ) );
+ char *psz_name = input_item_GetName( input_GetItem( p_input ) );
+ char *psz_uri = input_item_GetURI( input_GetItem( p_input ) );
+ if( psz_nowPlaying != NULL )
+ o_title = [NSString stringWithUTF8String: psz_nowPlaying];
+ else if( psz_name != NULL )
+ o_title = [NSString stringWithUTF8String: psz_name];
+
+ if( psz_uri != NULL )
+ o_mrl = [NSMutableString stringWithUTF8String: psz_uri];
+
+ FREENULL( psz_nowPlaying );
+ FREENULL( psz_name );
+ FREENULL( psz_uri );
+
if( o_title == nil )
o_title = o_mrl;
[o_mrl deleteCharactersInRange: prefix_range];
if( [o_mrl characterAtIndex:0] == '/' )
- {
+ {
/* it's a local file */
[o_window setRepresentedFilename: o_mrl];
}
}
else
{
- [o_window setTitle: [NSString stringWithCString: VOUT_TITLE]];
+ [o_window setTitle: [NSString stringWithUTF8String: VOUT_TITLE]];
}
vlc_object_release( p_input );
}
- (BOOL)isFullscreen
{
vlc_value_t val;
+ if( !p_real_vout ) return NO;
var_Get( p_real_vout, "fullscreen", &val );
return( val.b_bool );
}
- (void)manage
{
/* Disable Screensaver, when we're playing something, but allow it on pause */
+ if( !VLCIntf || !VLCIntf->p_sys || !VLCIntf->p_sys->i_play_status )
+ return;
+
if( VLCIntf->p_sys->i_play_status == PLAYING_S )
UpdateSystemActivity( UsrActivity );
}
return o_window;
}
+- (void)scrollWheel:(NSEvent *)theEvent
+{
+ VLCControls * o_controls = (VLCControls *)[[NSApp delegate] getControls];
+ [o_controls scrollWheel: theEvent];
+}
+
- (void)keyDown:(NSEvent *)o_event
{
unichar key = 0;
{
/* FIXME: this isn't the appropriate place, but we can't receive
* NSRightMouseDown some how */
- msg_Dbg( p_vout, "received NSRightMouseUp" );
+ msg_Dbg( p_vout, "received NSRightMouseUp" );
[NSMenu popUpContextMenu: [[VLCMain sharedInstance] getVoutMenu] withEvent: o_event forView: [[[VLCMain sharedInstance] getControls] getVoutView]];
}
- (void)enterFullscreen
{
- [[o_view class] resetVout: p_vout];
+ [[o_view class] performSelectorOnMainThread:@selector(resetVout:) withObject:[NSValue valueWithPointer:p_vout] waitUntilDone:YES];
[[[[VLCMain sharedInstance] getControls] getFSPanel] setActive: nil];
}
- (void)leaveFullscreen
{
- [[o_view class] resetVout: p_vout];
+ [[o_view class] performSelectorOnMainThread:@selector(resetVout:) withObject:[NSValue valueWithPointer:p_vout] waitUntilDone:YES];
[[[[VLCMain sharedInstance] getControls] getFSPanel] setNonActive: nil];
}
/* o_window needs to point to our o_embeddedwindow, super might have set it
* to the fullscreen window that o_embeddedwindow setups during fullscreen */
o_window = o_embeddedwindow;
-
+
if( b_return )
{
+ [o_window lockFullscreenAnimation];
+
[o_window setAlphaValue: var_GetFloat( p_vout, "macosx-opaqueness" )];
+
[self updateTitle];
/* Make the window the front and key window before animating */
[self scaleWindowWithFactor: 1.0 animate: [o_window isVisible] && (![o_window isFullscreen])];
+ [o_window setAspectRatio:NSMakeSize([o_window frame].size.width, [o_window frame].size.height)];
+
/* Make sure our window is visible, if we are not in fullscreen */
if (![o_window isFullscreen])
[o_window makeKeyAndOrderFront: self];
+ [o_window unlockFullscreenAnimation];
}
return b_return;
if(!playlist_IsPlaying( p_playlist ))
[o_window performSelectorOnMainThread: @selector(orderOut:) withObject: self waitUntilDone: YES];
-
+
vlc_object_release( p_playlist );
[super closeVout];
p_real_vout = [VLCVoutView getRealVout: p_vout];
i_device = var_GetInteger( p_real_vout->p_libvlc, "video-device" );
- b_black = var_GetBool( p_vout, "macosx-black" );
+ b_black = NO;
b_embedded = var_GetBool( p_vout, "macosx-embedded" );
/* Find out on which screen to open the window */
NSRect screen_rect = [o_screen frame];
screen_rect.origin.x = screen_rect.origin.y = 0;
+ b_black = var_GetBool( p_vout, "macosx-black" );
+
/* move the FSPanel to front in case that it is currently shown
* this won't and is not supposed to work when it's fading right now */
if( [[[[VLCMain sharedInstance] getControls] getFSPanel] isDisplayed] )
- [[[[VLCMain sharedInstance] getControls] getFSPanel] orderFront: self];
-
+ [[[[VLCMain sharedInstance] getControls] getFSPanel] setActive: nil];
+
/* tell the fspanel to move itself to front next time it's triggered */
[[[[VLCMain sharedInstance] getControls] getFSPanel] setVoutWasUpdated: i_device];
styleMask: NSBorderlessWindowMask
backing: NSBackingStoreBuffered
defer: YES screen: o_screen];
-
- if( b_black == VLC_TRUE )
- [o_screen blackoutOtherScreens];
-
+
if( b_menubar_screen )
{
SetSystemUIMode( kUIModeAllHidden, kUIOptionAutoShowMenuBar);
if( b_black == VLC_TRUE )
{
CGAcquireDisplayFadeReservation(kCGMaxDisplayReservationInterval, &token);
- CGDisplayFade( token, 2 , kCGDisplayBlendSolidColor, kCGDisplayBlendNormal, 0, 0, 0, false );
+ CGDisplayFade( token, 0.6 , kCGDisplayBlendNormal, kCGDisplayBlendSolidColor, 0, 0, 0, YES );
+
+ [o_screen blackoutOtherScreens];
+
+ CGDisplayFade( token, 0.3 , kCGDisplayBlendSolidColor, kCGDisplayBlendNormal, 0, 0, 0, NO );
CGReleaseDisplayFadeReservation( token);
}
}
{
/* XXX waitUntilDone = NO to avoid a possible deadlock when hitting
Command-Q */
- [self setContentView: NULL];
[self performSelectorOnMainThread: @selector(closeReal:)
withObject: NULL waitUntilDone: NO];
}
- (id)closeReal:(id)sender
{
- [NSScreen unblackoutScreens];
if( b_black == VLC_TRUE )
{
CGDisplayFadeReservationToken token;
CGAcquireDisplayFadeReservation(kCGMaxDisplayReservationInterval, &token);
- CGDisplayFade( token, 2, kCGDisplayBlendSolidColor, kCGDisplayBlendNormal, 0, 0, 0, false );
+ CGDisplayFade( token, 0.3 , kCGDisplayBlendNormal, kCGDisplayBlendSolidColor, 0, 0, 0, YES );
+
+ [self disableScreenUpdatesUntilFlush];
+ [self orderOut: self];
+
+ CGDisplayFade( token, 0.6 , kCGDisplayBlendSolidColor, kCGDisplayBlendNormal, 0, 0, 0, YES );
CGReleaseDisplayFadeReservation( token);
CGDisplayRestoreColorSyncSettings();
}
+ [NSScreen unblackoutScreens];
+
SetSystemUIMode( kUIModeNormal, 0);
[super close];
/* this does only work in embedded mode */