X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=modules%2Fgui%2Fmacosx%2Fvout.m;h=bc7900e9ba4af45ceddbd17678ff61a14a723029;hb=6368b52db44d9e1c5dcc1b937df09b9c4e96fa90;hp=279cfdcfe25fb786f7650a7021a39f1ce9ba8c4f;hpb=3af039a0d25dbb6d7a3e5949c521f72a36c730fa;p=vlc diff --git a/modules/gui/macosx/vout.m b/modules/gui/macosx/vout.m index 279cfdcfe2..bc7900e9ba 100644 --- a/modules/gui/macosx/vout.m +++ b/modules/gui/macosx/vout.m @@ -1,7 +1,7 @@ /***************************************************************************** * 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 @@ -10,7 +10,7 @@ * Derk-Jan Hartman * Eric Petit * Benjamin Pracht - * Felix KŸhne + * Felix Kühne * * 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 @@ -32,7 +32,7 @@ *****************************************************************************/ #include /* ENOMEM */ #include /* free() */ -#include /* strerror() */ +#include /* BeginFullScreen, EndFullScreen */ #include @@ -143,7 +143,7 @@ int DeviceCallback( vlc_object_t *p_this, const char *psz_variable, *****************************************************************************/ @implementation VLCVoutView -- (id)initWithFrame:(NSRect)frameRect +- (id)initWithFrame: (NSRect)frameRect { [super initWithFrame: frameRect]; p_vout = NULL; @@ -155,8 +155,9 @@ int DeviceCallback( vlc_object_t *p_this, const char *psz_variable, 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]; @@ -265,12 +266,13 @@ int DeviceCallback( vlc_object_t *p_this, const char *psz_variable, 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 ) @@ -285,12 +287,21 @@ int DeviceCallback( vlc_object_t *p_this, const char *psz_variable, 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; @@ -304,7 +315,7 @@ int DeviceCallback( vlc_object_t *p_this, const char *psz_variable, [o_mrl deleteCharactersInRange: prefix_range]; if( [o_mrl characterAtIndex:0] == '/' ) - { + { /* it's a local file */ [o_window setRepresentedFilename: o_mrl]; } @@ -318,7 +329,7 @@ int DeviceCallback( vlc_object_t *p_this, const char *psz_variable, } else { - [o_window setTitle: [NSString stringWithCString: VOUT_TITLE]]; + [o_window setTitle: [NSString stringWithUTF8String: VOUT_TITLE]]; } vlc_object_release( p_input ); } @@ -430,6 +441,9 @@ int DeviceCallback( vlc_object_t *p_this, const char *psz_variable, - (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 ); } @@ -442,22 +456,7 @@ int DeviceCallback( vlc_object_t *p_this, const char *psz_variable, - (void)scrollWheel:(NSEvent *)theEvent { VLCControls * o_controls = (VLCControls *)[[NSApp delegate] getControls]; - float f_absvalue = [theEvent deltaY] > 0.0f ? [theEvent deltaY] : -[theEvent deltaY]; - int i; - f_absvalue /= 2.0f; - f_absvalue += 1.0f; - - /* Set the volume */ - if (f_absvalue > 1.1f) - { - for (i = 0; i < (int)f_absvalue; i++) - { - if ([theEvent deltaY] < 0.0f) - [o_controls volumeDown: self]; - else - [o_controls volumeUp: self]; - } - } + [o_controls scrollWheel: theEvent]; } - (void)keyDown:(NSEvent *)o_event @@ -605,7 +604,7 @@ int DeviceCallback( vlc_object_t *p_this, const char *psz_variable, { /* 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]]; } @@ -723,7 +722,6 @@ int DeviceCallback( vlc_object_t *p_this, const char *psz_variable, var_Create( p_vout, "macosx-opaqueness", VLC_VAR_FLOAT | VLC_VAR_DOINHERIT ); var_Create( p_vout, "macosx-background", VLC_VAR_BOOL | VLC_VAR_DOINHERIT ); var_Create( p_vout, "macosx-black", VLC_VAR_BOOL | VLC_VAR_DOINHERIT ); - var_Create( p_vout, "macosx-embedded", VLC_VAR_BOOL | VLC_VAR_DOINHERIT ); /* We only wait for NSApp to initialise if we're not embedded (as in the @@ -751,7 +749,7 @@ int DeviceCallback( vlc_object_t *p_this, const char *psz_variable, { if ( VLCIntf && !(p_vout->b_fullscreen) && !(var_GetBool( p_vout, "macosx-background" )) && - var_GetBool( p_vout, "macosx-embedded") ) + var_GetBool( p_vout, "embedded-video") ) { o_return = [[[VLCMain sharedInstance] getEmbeddedList] getEmbeddedVout]; @@ -772,13 +770,13 @@ int DeviceCallback( vlc_object_t *p_this, const char *psz_variable, - (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]; } @@ -945,7 +943,7 @@ int DeviceCallback( vlc_object_t *p_this, const char *psz_variable, /* 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]; @@ -960,6 +958,8 @@ int DeviceCallback( vlc_object_t *p_this, const char *psz_variable, [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]; @@ -975,7 +975,7 @@ int DeviceCallback( vlc_object_t *p_this, const char *psz_variable, if(!playlist_IsPlaying( p_playlist )) [o_window performSelectorOnMainThread: @selector(orderOut:) withObject: self waitUntilDone: YES]; - + vlc_object_release( p_playlist ); [super closeVout]; @@ -1030,7 +1030,7 @@ int DeviceCallback( vlc_object_t *p_this, const char *psz_variable, p_real_vout = [VLCVoutView getRealVout: p_vout]; i_device = var_GetInteger( p_real_vout->p_libvlc, "video-device" ); b_black = NO; - b_embedded = var_GetBool( p_vout, "macosx-embedded" ); + b_embedded = var_GetBool( p_vout, "embedded-video" ); /* Find out on which screen to open the window */ o_screen = [NSScreen screenWithDisplayID: (CGDirectDisplayID)i_device]; @@ -1053,7 +1053,7 @@ int DeviceCallback( vlc_object_t *p_this, const char *psz_variable, * 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] setActive: nil]; - + /* tell the fspanel to move itself to front next time it's triggered */ [[[[VLCMain sharedInstance] getControls] getFSPanel] setVoutWasUpdated: i_device]; @@ -1062,7 +1062,7 @@ int DeviceCallback( vlc_object_t *p_this, const char *psz_variable, styleMask: NSBorderlessWindowMask backing: NSBackingStoreBuffered defer: YES screen: o_screen]; - + if( b_menubar_screen ) { SetSystemUIMode( kUIModeAllHidden, kUIOptionAutoShowMenuBar); @@ -1157,7 +1157,7 @@ int DeviceCallback( vlc_object_t *p_this, const char *psz_variable, CGDisplayFadeReservationToken token; CGAcquireDisplayFadeReservation(kCGMaxDisplayReservationInterval, &token); CGDisplayFade( token, 0.3 , kCGDisplayBlendNormal, kCGDisplayBlendSolidColor, 0, 0, 0, YES ); - + [self disableScreenUpdatesUntilFlush]; [self orderOut: self];