-/**
- Zooms the receiver. This method calls the delegate method
- windowShouldZoom:toFrame: to determine if the window should
- be allowed to zoom to full screen.
- *
- * This method is based upon NSWindow.m, part of the GNUstep GUI Library, licensed under LGPLv2+.
- * Authors: Scott Christley <scottc@net-community.com>, Venkat Ajjanagadde <venkat@ocbi.com>,
- * Felipe A. Rodriguez <far@ix.netcom.com>, Richard Frith-Macdonald <richard@brainstorm.co.uk>
- * Copyright (C) 1996 Free Software Foundation, Inc.
- */
-- (void)customZoom:(id)sender
-{
- NSRect maxRect = [[self screen] visibleFrame];
- NSRect currentFrame = [self frame];
-
- if ([[self delegate] respondsToSelector: @selector(windowWillUseStandardFrame:defaultFrame:)])
- {
- maxRect = [[self delegate] windowWillUseStandardFrame: self defaultFrame: maxRect];
- }
-
- maxRect = [self customConstrainFrameRect: maxRect toScreen: [self screen]];
-
- // Compare the new frame with the current one
- if ((abs(NSMaxX(maxRect) - NSMaxX(currentFrame)) < DIST)
- && (abs(NSMaxY(maxRect) - NSMaxY(currentFrame)) < DIST)
- && (abs(NSMinX(maxRect) - NSMinX(currentFrame)) < DIST)
- && (abs(NSMinY(maxRect) - NSMinY(currentFrame)) < DIST))
- {
- // Already in zoomed mode, reset user frame, if stored
- if ([self frameAutosaveName] != nil)
- {
- [self setFrame: previousSavedFrame display: YES animate: YES];
- [self saveFrameUsingName: [self frameAutosaveName]];
- }
- return;
- }
-
- if ([self frameAutosaveName] != nil)
- {
- [self saveFrameUsingName: [self frameAutosaveName]];
- previousSavedFrame = [self frame];
- }
-
- [self setFrame: maxRect display: YES animate: YES];
-}
-
-- (void)windowResizedOrMoved:(NSNotification *)notification
-{
- [self saveFrameUsingName: [self frameAutosaveName]];
-}
-
-- (void)applicationWillTerminate:(NSNotification *)notification
-{
- [self saveFrameUsingName: [self frameAutosaveName]];
-}
-
-- (void)someWindowWillClose:(NSNotification *)notification
-{
- if([notification object] == o_detached_video_window || ([notification object] == self && !b_nonembedded))
- {
- if ([[VLCMain sharedInstance] activeVideoPlayback])
- [[VLCCoreInteraction sharedInstance] stop];
- }
-}
-
-- (void)someWindowWillMiniaturize:(NSNotification *)notification
-{
- if (config_GetInt( VLCIntf, "macosx-pause-minimized" ))
- {
- if([notification object] == o_detached_video_window || ([notification object] == self && !b_nonembedded))
- {
- if([[VLCMain sharedInstance] activeVideoPlayback])
- [[VLCCoreInteraction sharedInstance] pause];
- }
- }
-}
-
-- (NSSize)windowWillResize:(NSWindow *)window toSize:(NSSize)proposedFrameSize
-{
- id videoWindow = [o_video_view window];
- if (![[VLCMain sharedInstance] activeVideoPlayback] || nativeVideoSize.width == 0. || nativeVideoSize.height == 0. || window != videoWindow)
- return proposedFrameSize;
-
- // needed when entering lion fullscreen mode
- if( b_fullscreen )
- return proposedFrameSize;
-
- if( [[VLCCoreInteraction sharedInstance] aspectRatioIsLocked] )
- {
- NSRect videoWindowFrame = [videoWindow frame];
- NSRect viewRect = [o_video_view convertRect:[o_video_view bounds] toView: nil];
- NSRect contentRect = [videoWindow contentRectForFrameRect:videoWindowFrame];
- float marginy = viewRect.origin.y + videoWindowFrame.size.height - contentRect.size.height;
- float marginx = contentRect.size.width - viewRect.size.width;
- if( b_dark_interface && b_video_deco )
- marginy += [o_titlebar_view frame].size.height;
-
- proposedFrameSize.height = (proposedFrameSize.width - marginx) * nativeVideoSize.height / nativeVideoSize.width + marginy;
- }
-
- return proposedFrameSize;
-}
-
-#pragma mark -
-#pragma mark Update interface and respond to foreign events
-- (void)showDropZone
-{
- b_dropzone_active = YES;
- [o_right_split_view addSubview: o_dropzone_view positioned:NSWindowAbove relativeTo:o_playlist_table];
- [o_dropzone_view setFrame: [o_playlist_table frame]];
- if (OSX_LEOPARD)
- [o_playlist_table setHidden:YES];
- else
- [[o_playlist_table animator] setHidden:YES];
-}
-
-- (void)hideDropZone
-{
- b_dropzone_active = NO;
- [o_dropzone_view removeFromSuperview];
- if (OSX_LEOPARD)
- [o_playlist_table setHidden: NO];
- else
- [[o_playlist_table animator] setHidden: NO];
-}
-
-- (void)hideSplitView
-{
- NSRect winrect = [self frame];
- i_lastSplitViewHeight = [o_split_view frame].size.height;
- winrect.size.height = winrect.size.height - i_lastSplitViewHeight;
- winrect.origin.y = winrect.origin.y + i_lastSplitViewHeight;
- [self setFrame: winrect display: YES animate: YES];
- [self performSelector:@selector(hideDropZone) withObject:nil afterDelay:0.1];
- if (b_dark_interface)
- {
- [self setContentMinSize: NSMakeSize( 604., [o_bottombar_view frame].size.height + [o_titlebar_view frame].size.height )];
- [self setContentMaxSize: NSMakeSize( FLT_MAX, [o_bottombar_view frame].size.height + [o_titlebar_view frame].size.height )];
- }
- else
- {
- [self setContentMinSize: NSMakeSize( 604., [o_bottombar_view frame].size.height )];
- [self setContentMaxSize: NSMakeSize( FLT_MAX, [o_bottombar_view frame].size.height )];
- }
-
- b_splitview_removed = YES;
-}
-
-- (void)showSplitView
-{
- [self updateWindow];
- if (b_dark_interface)
- [self setContentMinSize:NSMakeSize( 604., 288. + [o_titlebar_view frame].size.height )];
- else
- [self setContentMinSize:NSMakeSize( 604., 288. )];
- [self setContentMaxSize: NSMakeSize( FLT_MAX, FLT_MAX )];
-
- NSRect winrect;
- winrect = [self frame];
- winrect.size.height = winrect.size.height + i_lastSplitViewHeight;
- winrect.origin.y = winrect.origin.y - i_lastSplitViewHeight;
- [self setFrame: winrect display: YES animate: YES];
-
- [self performSelector:@selector(resizePlaylistAfterCollapse) withObject: nil afterDelay:0.75];
-
- b_splitview_removed = NO;
-}
-
-- (NSString *)getCurrentTimeAsString:(input_thread_t *)p_input
-{
- assert( p_input != nil );
-
- vlc_value_t time;
- char psz_time[MSTRTIME_MAX_SIZE];
-
- var_Get( p_input, "time", &time );
-
- mtime_t dur = input_item_GetDuration( input_GetItem( p_input ) );
- if( [o_time_fld timeRemaining] && dur > 0 )
- {
- mtime_t remaining = 0;
- if( dur > time.i_time )
- remaining = dur - time.i_time;
- return [NSString stringWithFormat: @"-%s", secstotimestr( psz_time, ( remaining / 1000000 ) )];
- }
- else
- return [NSString stringWithUTF8String: secstotimestr( psz_time, ( time.i_time / 1000000 ) )];
-}
-
-- (void)updateTimeSlider
-{
- input_thread_t * p_input;
- p_input = pl_CurrentInput( VLCIntf );
- if( p_input )
- {
- NSString * o_time;
- vlc_value_t pos;
- float f_updated;
-
- var_Get( p_input, "position", &pos );
- f_updated = 10000. * pos.f_float;
- [o_time_sld setFloatValue: f_updated];
-
- o_time = [self getCurrentTimeAsString: p_input];
-
- mtime_t dur = input_item_GetDuration( input_GetItem( p_input ) );
- if (dur == -1) {
- [o_time_sld setEnabled: NO];
- [o_time_sld setHidden: YES];
- [o_time_sld_fancygradient_view setHidden: YES];
- } else {
- [o_time_sld setEnabled: YES];
- [o_time_sld setHidden: NO];
- [o_time_sld_fancygradient_view setHidden: NO];
- }
-
- [o_time_fld setStringValue: o_time];
- [o_time_fld setNeedsDisplay:YES];
- [o_fspanel setStreamPos: f_updated andTime: o_time];
- vlc_object_release( p_input );
- }
- else
- {
- [o_time_sld setFloatValue: 0.0];
- [o_time_fld setStringValue: @"00:00"];
- [o_time_sld setEnabled: NO];
- [o_time_sld setHidden: YES];
- [o_time_sld_fancygradient_view setHidden: YES];
- if (b_video_deco)
- [o_detached_time_sld_fancygradient_view setHidden: YES];
- }
-
- if (b_video_deco)
- {
- [o_detached_time_sld setFloatValue: [o_time_sld floatValue]];
- [o_detached_time_sld setEnabled: [o_time_sld isEnabled]];
- [o_detached_time_fld setStringValue: [o_time_fld stringValue]];
- [o_detached_time_sld setHidden: [o_time_sld isHidden]];
- }
-}
-
-- (void)updateVolumeSlider
-{
- playlist_t * p_playlist = pl_Get( VLCIntf );
- int i_volume = lroundf(aout_VolumeGet( p_playlist ) * AOUT_VOLUME_DEFAULT);
- BOOL b_muted = [[VLCCoreInteraction sharedInstance] isMuted];
-
- if( !b_muted )
- {
- [o_volume_sld setIntValue: i_volume];
- [o_fspanel setVolumeLevel: i_volume];
- }
- else
- [o_volume_sld setIntValue: 0];
-
- [o_volume_sld setEnabled: !b_muted];
- [o_volume_up_btn setEnabled: !b_muted];
-}
-
-- (void)updateName
-{
- NSAutoreleasePool *o_pool = [[NSAutoreleasePool alloc] init];
- input_thread_t * p_input;
- p_input = pl_CurrentInput( VLCIntf );
- if( p_input )
- {
- NSString *aString;
- char *format = var_InheritString( VLCIntf, "input-title-format" );
- char *formated = str_format_meta( p_input, format );
- free( format );
- aString = [NSString stringWithUTF8String:formated];
- free( formated );
-
- char *uri = input_item_GetURI( input_GetItem( p_input ) );
-
- NSURL * o_url = [NSURL URLWithString: [NSString stringWithUTF8String: uri]];
- if ([o_url isFileURL])
- {
- [self setRepresentedURL: o_url];
- [o_detached_video_window setRepresentedURL: o_url];
- } else {
- [self setRepresentedURL: nil];
- [o_detached_video_window setRepresentedURL: nil];
- }
- free( uri );
-
- if ([aString isEqualToString:@""])
- {
- if ([o_url isFileURL])
- aString = [[NSFileManager defaultManager] displayNameAtPath: [o_url path]];
- else
- aString = [o_url absoluteString];
- }
-
- [self setTitle: aString];
- [o_fspanel setStreamTitle: aString];
- vlc_object_release( p_input );
- }
- else
- {
- [self setTitle: _NS("VLC media player")];
- [self setRepresentedURL: nil];
- }
-
- [o_pool release];
-}
-
-- (void)updateWindow
-{
- bool b_input = false;
- bool b_plmul = false;
- bool b_control = false;
- bool b_seekable = false;
- bool b_chapters = false;
-
- playlist_t * p_playlist = pl_Get( VLCIntf );
-
- PL_LOCK;
- b_plmul = playlist_CurrentSize( p_playlist ) > 1;
- PL_UNLOCK;
-
- input_thread_t * p_input = playlist_CurrentInput( p_playlist );
-
- bool b_buffering = NO;
-
- if( ( b_input = ( p_input != NULL ) ) )
- {
- /* seekable streams */
- cachedInputState = input_GetState( p_input );
- if ( cachedInputState == INIT_S || cachedInputState == OPENING_S )
- b_buffering = YES;
-
- /* seekable streams */
- b_seekable = var_GetBool( p_input, "can-seek" );
-
- /* check whether slow/fast motion is possible */
- b_control = var_GetBool( p_input, "can-rate" );
-
- /* chapters & titles */
- //FIXME! b_chapters = p_input->stream.i_area_nb > 1;
-
- vlc_object_release( p_input );
- }
-
- if( b_buffering )
- {
- [o_progress_bar startAnimation:self];
- [o_progress_bar setIndeterminate:YES];
- [o_progress_bar setHidden:NO];
- } else {
- [o_progress_bar stopAnimation:self];
- [o_progress_bar setHidden:YES];
- }
-
- [o_stop_btn setEnabled: b_input];
- [o_fwd_btn setEnabled: (b_seekable || b_plmul || b_chapters)];
- [o_bwd_btn setEnabled: (b_seekable || b_plmul || b_chapters)];
- if (b_show_jump_buttons)
- {
- [o_prev_btn setEnabled: (b_seekable || b_plmul || b_chapters)];
- [o_next_btn setEnabled: (b_seekable || b_plmul || b_chapters)];
- }
- if (b_video_deco)
- {
- [o_detached_fwd_btn setEnabled: (b_seekable || b_plmul || b_chapters)];
- [o_detached_bwd_btn setEnabled: (b_seekable || b_plmul || b_chapters)];
- }
- [[VLCMainMenu sharedInstance] setRateControlsEnabled: b_control];
-
- [o_time_sld setEnabled: b_seekable];
- [self updateTimeSlider];
- [o_fspanel setSeekable: b_seekable];
-
- PL_LOCK;
- if ([[[VLCMain sharedInstance] playlist] currentPlaylistRoot] != p_playlist->p_local_category || p_playlist->p_local_category->i_children > 0)
- [self hideDropZone];
- else
- [self showDropZone];
- PL_UNLOCK;
- [o_sidebar_view setNeedsDisplay:YES];
-}
-
-- (void)setPause
-{
- [o_play_btn setImage: o_pause_img];
- [o_play_btn setAlternateImage: o_pause_pressed_img];
- [o_play_btn setToolTip: _NS("Pause")];
- if (b_video_deco)
- {
- [o_detached_play_btn setImage: o_pause_img];
- [o_detached_play_btn setAlternateImage: o_pause_pressed_img];
- [o_detached_play_btn setToolTip: _NS("Pause")];
- }
- [o_fspanel setPause];
-}
-
-- (void)setPlay
-{
- [o_play_btn setImage: o_play_img];
- [o_play_btn setAlternateImage: o_play_pressed_img];
- [o_play_btn setToolTip: _NS("Play")];
- if (b_video_deco)
- {
- [o_detached_play_btn setImage: o_play_img];
- [o_detached_play_btn setAlternateImage: o_play_pressed_img];
- [o_detached_play_btn setToolTip: _NS("Play")];
- }
- [o_fspanel setPlay];
-}
-
-- (void)drawFancyGradientEffectForTimeSlider
-{
- if (OSX_LEOPARD)
- return;
-
- NSAutoreleasePool * o_pool = [[NSAutoreleasePool alloc] init];
- CGFloat f_value = [o_time_sld knobPosition];
- if (f_value > 7.5)
- {
- NSRect oldFrame = [o_time_sld_fancygradient_view frame];
- if (f_value != oldFrame.size.width)
- {
- if ([o_time_sld_fancygradient_view isHidden])
- [o_time_sld_fancygradient_view setHidden: NO];
- [o_time_sld_fancygradient_view setFrame: NSMakeRect( oldFrame.origin.x, oldFrame.origin.y, f_value, oldFrame.size.height )];
- }
-
- if (b_nonembedded && b_video_deco)
- {
- f_value = [o_detached_time_sld knobPosition];
- oldFrame = [o_detached_time_sld_fancygradient_view frame];
- if (f_value != oldFrame.size.width)
- {
- if ([o_detached_time_sld_fancygradient_view isHidden])
- [o_detached_time_sld_fancygradient_view setHidden: NO];
- [o_detached_time_sld_fancygradient_view setFrame: NSMakeRect( oldFrame.origin.x, oldFrame.origin.y, f_value, oldFrame.size.height )];
- }
- }
- }
- else
- {
- NSRect frame;
- frame = [o_time_sld_fancygradient_view frame];
- if (frame.size.width > 0)
- {
- frame.size.width = 0;
- [o_time_sld_fancygradient_view setFrame: frame];
-
- if (b_video_deco)
- {
- frame = [o_detached_time_sld_fancygradient_view frame];
- frame.size.width = 0;
- [o_detached_time_sld_fancygradient_view setFrame: frame];
- }
- }
- [o_time_sld_fancygradient_view setHidden: YES];
- if (b_video_deco)
- [o_detached_time_sld_fancygradient_view setHidden: YES];
- }
- [o_pool release];
-}
-
-#pragma mark -
-#pragma mark Video Output handling
-- (id)videoView
-{
- return o_video_view;
-}
-
-- (id)setupVideoView
-{
- // TODO: make lion fullscreen compatible with macosx-background and !embedded-video
- if( var_InheritBool( VLCIntf, "macosx-background" ) && !b_nativeFullscreenMode )
- {
- msg_Dbg( VLCIntf, "Creating background window" );
- NSScreen *screen = [NSScreen screenWithDisplayID:(CGDirectDisplayID)var_InheritInteger( VLCIntf, "macosx-vdev" )];
- if( !screen )
- screen = [self screen];
- NSRect screen_rect = [screen frame];
-
- if( o_extra_video_window )
- [o_extra_video_window release];
-
- o_extra_video_window = [[VLCWindow alloc] initWithContentRect:screen_rect styleMask: NSBorderlessWindowMask backing:NSBackingStoreBuffered defer:NO];
- [o_extra_video_window setLevel: CGWindowLevelForKey(kCGDesktopWindowLevelKey) + 1];
- [o_extra_video_window setBackgroundColor: [NSColor blackColor]];
- [o_extra_video_window setCanBecomeKeyWindow: NO];
- [o_extra_video_window setCanBecomeMainWindow: NO];
- [o_extra_video_window useOptimizedDrawing: YES];
- [o_extra_video_window setMovableByWindowBackground: NO];
-
- [o_video_view retain];
- if ([o_video_view superview] != NULL)
- [o_video_view removeFromSuperviewWithoutNeedingDisplay];
- screen_rect.origin.x = screen_rect.origin.y = 0;
- [o_video_view setFrame: screen_rect];
- [[o_extra_video_window contentView] addSubview: o_video_view positioned:NSWindowAbove relativeTo:nil];
- [o_video_view release];
-
- [o_extra_video_window orderBack:nil];
-
- b_nonembedded = YES;
- }
- else
- {
- if ((var_InheritBool( VLCIntf, "embedded-video" ) || b_nativeFullscreenMode) && b_video_deco)
- {
- if ([o_video_view window] != self)
- {
- [o_video_view removeFromSuperviewWithoutNeedingDisplay];
- [o_video_view setFrame: [o_split_view frame]];
- [[self contentView] addSubview:o_video_view positioned:NSWindowAbove relativeTo:nil];
- }
- b_nonembedded = NO;
- }
- else
- {
- if ([o_video_view superview] != NULL)
- [o_video_view removeFromSuperviewWithoutNeedingDisplay];
-
- NSRect videoFrame;
- videoFrame.size = [[o_detached_video_window contentView] frame].size;
- if (b_video_deco)
- {
- videoFrame.size.height -= [o_detached_bottombar_view frame].size.height;
- if( b_dark_interface )
- videoFrame.size.height -= [o_detached_titlebar_view frame].size.height;
-
- videoFrame.origin.x = .0;
- videoFrame.origin.y = [o_detached_bottombar_view frame].size.height;
- }
- else
- {
- videoFrame.origin.y = .0;
- videoFrame.origin.x = .0;
- }
-
- [o_video_view setFrame: videoFrame];
- [[o_detached_video_window contentView] addSubview: o_video_view positioned:NSWindowAbove relativeTo:nil];
- [o_detached_video_window setLevel:NSNormalWindowLevel];
- [o_detached_video_window useOptimizedDrawing: YES];
- b_nonembedded = YES;
- }
-
- [[o_video_view window] makeKeyAndOrderFront: self];
-
- vout_thread_t *p_vout = getVout();
- if (p_vout)
- {
- if( var_GetBool( p_vout, "video-on-top" ) )
- [[o_video_view window] setLevel: NSStatusWindowLevel];
- else
- [[o_video_view window] setLevel: NSNormalWindowLevel];
- vlc_object_release( p_vout );
- }
- }
-
- [[o_video_view window] setAlphaValue: config_GetFloat( VLCIntf, "macosx-opaqueness" )];
- return o_video_view;
-}
-
-- (void)setVideoplayEnabled
-{
- BOOL b_videoPlayback = [[VLCMain sharedInstance] activeVideoPlayback];
-
- if( b_videoPlayback )
- {
- // look for 'start at fullscreen'
- [[VLCMain sharedInstance] fullscreenChanged];
- }
- else
- {
- [self makeFirstResponder: nil];
- [o_detached_video_window orderOut: nil];
- if( o_extra_video_window )
- [o_extra_video_window orderOut: nil];
-
- if( [self level] != NSNormalWindowLevel )
- [self setLevel: NSNormalWindowLevel];
- if( [o_detached_video_window level] != NSNormalWindowLevel )
- [o_detached_video_window setLevel: NSNormalWindowLevel];
-
- // restore alpha value to 1 for the case that macosx-opaqueness is set to < 1
- [self setAlphaValue:1.0];
- }
-
- if( b_nativeFullscreenMode )
- {
- if( [NSApp presentationOptions] & NSApplicationPresentationFullScreen )
- [o_bottombar_view setHidden: b_videoPlayback];
- else
- [o_bottombar_view setHidden: NO];
- if( b_videoPlayback && b_fullscreen )
- [o_fspanel setActive: nil];
- if( !b_videoPlayback )
- [o_fspanel setNonActive: nil];
- }
-
- if (!b_videoPlayback && b_fullscreen)
- {
- if (!b_nativeFullscreenMode)
- [[VLCCoreInteraction sharedInstance] toggleFullscreen];
- }
-}
-
-- (void)resizeWindow
-{
- if( b_fullscreen || ( b_nativeFullscreenMode && [NSApp presentationOptions] & NSApplicationPresentationFullScreen ) )
- return;
-
- id o_videoWindow = b_nonembedded ? o_detached_video_window : self;
- NSSize windowMinSize = [o_videoWindow minSize];
- NSRect screenFrame = [[o_videoWindow screen] visibleFrame];
-
- NSPoint topleftbase = NSMakePoint( 0, [o_videoWindow frame].size.height );
- NSPoint topleftscreen = [o_videoWindow convertBaseToScreen: topleftbase];
-
- unsigned int i_width = nativeVideoSize.width;
- unsigned int i_height = nativeVideoSize.height;
- if (i_width < windowMinSize.width)
- i_width = windowMinSize.width;
- if (i_height < f_min_video_height)
- i_height = f_min_video_height;
-
- /* Calculate the window's new size */
- NSRect new_frame;
- new_frame.size.width = [o_videoWindow frame].size.width - [o_video_view frame].size.width + i_width;
- new_frame.size.height = [o_videoWindow frame].size.height - [o_video_view frame].size.height + i_height;
- new_frame.origin.x = topleftscreen.x;
- new_frame.origin.y = topleftscreen.y - new_frame.size.height;
-
- /* make sure the window doesn't exceed the screen size the window is on */
- if( new_frame.size.width > screenFrame.size.width )
- {
- new_frame.size.width = screenFrame.size.width;
- new_frame.origin.x = screenFrame.origin.x;
- }
- if( new_frame.size.height > screenFrame.size.height )
- {
- new_frame.size.height = screenFrame.size.height;
- new_frame.origin.y = screenFrame.origin.y;
- }
- if( new_frame.origin.y < screenFrame.origin.y )
- new_frame.origin.y = screenFrame.origin.y;
-
- CGFloat right_screen_point = screenFrame.origin.x + screenFrame.size.width;
- CGFloat right_window_point = new_frame.origin.x + new_frame.size.width;
- if( right_window_point > right_screen_point )
- new_frame.origin.x -= ( right_window_point - right_screen_point );
-
- if (OSX_LEOPARD)
- [o_videoWindow setFrame:new_frame display:YES];
- else
- [[o_videoWindow animator] setFrame:new_frame display:YES];
-}
-
-- (void)setNativeVideoSize:(NSSize)size
-{
- nativeVideoSize = size;
-
- if( var_InheritBool( VLCIntf, "macosx-video-autoresize" ) && !b_fullscreen && !var_InheritBool( VLCIntf, "macosx-background" ) )
- [self performSelectorOnMainThread:@selector(resizeWindow) withObject:nil waitUntilDone:NO];
-}
-
-// Called automatically if window's acceptsMouseMovedEvents property is true
-- (void)mouseMoved:(NSEvent *)theEvent
-{
- if (b_fullscreen)
- [self recreateHideMouseTimer];
-
- [super mouseMoved: theEvent];
-}
-
-- (void)recreateHideMouseTimer
-{
- if (t_hide_mouse_timer != nil) {
- [t_hide_mouse_timer invalidate];
- [t_hide_mouse_timer release];
- }
-
- t_hide_mouse_timer = [NSTimer scheduledTimerWithTimeInterval:2
- target:self
- selector:@selector(hideMouseCursor:)
- userInfo:nil
- repeats:NO];
- [t_hide_mouse_timer retain];
-}
-
-// NSTimer selectors require this function signature as per Apple's docs
-- (void)hideMouseCursor:(NSTimer *)timer
-{
- [NSCursor setHiddenUntilMouseMoves: YES];
-}
-
-#pragma mark -
-#pragma mark Fullscreen support
-- (void)showFullscreenController
-{
- if (b_fullscreen && [[VLCMain sharedInstance] activeVideoPlayback] )
- [o_fspanel fadeIn];
-}
-
-- (BOOL)isFullscreen
-{
- return b_fullscreen;
-}
-
-- (void)lockFullscreenAnimation
-{
- [o_animation_lock lock];
-}
-
-- (void)unlockFullscreenAnimation
-{
- [o_animation_lock unlock];
-}
-
-- (void)enterFullscreen
-{
- NSMutableDictionary *dict1, *dict2;
- NSScreen *screen;
- NSRect screen_rect;
- NSRect rect;
- BOOL blackout_other_displays = var_InheritBool( VLCIntf, "macosx-black" );
- o_current_video_window = [o_video_view window];
-
- screen = [NSScreen screenWithDisplayID:(CGDirectDisplayID)var_InheritInteger( VLCIntf, "macosx-vdev" )];
- [self lockFullscreenAnimation];
-
- if (!screen)
- {
- msg_Dbg( VLCIntf, "chosen screen isn't present, using current screen for fullscreen mode" );
- screen = [o_current_video_window screen];
- }
- if (!screen)
- {
- msg_Dbg( VLCIntf, "Using deepest screen" );
- screen = [NSScreen deepestScreen];
- }
-
- screen_rect = [screen frame];
-
- [o_fullscreen_btn setState: YES];
- if (b_video_deco)
- [o_detached_fullscreen_btn setState: YES];
-
- [self recreateHideMouseTimer];
-
- if( blackout_other_displays )
- [screen blackoutOtherScreens];
-
- /* Make sure we don't see the window flashes in float-on-top mode */
- i_originalLevel = [o_current_video_window level];
- [o_current_video_window setLevel:NSNormalWindowLevel];
-
- /* Only create the o_fullscreen_window if we are not in the middle of the zooming animation */
- if (!o_fullscreen_window)
- {
- /* We can't change the styleMask of an already created NSWindow, so we create another window, and do eye catching stuff */
-
- rect = [[o_video_view superview] convertRect: [o_video_view frame] toView: nil]; /* Convert to Window base coord */
- rect.origin.x += [o_current_video_window frame].origin.x;
- rect.origin.y += [o_current_video_window frame].origin.y;
- o_fullscreen_window = [[VLCWindow alloc] initWithContentRect:rect styleMask: NSBorderlessWindowMask backing:NSBackingStoreBuffered defer:YES];
- [o_fullscreen_window setBackgroundColor: [NSColor blackColor]];
- [o_fullscreen_window setCanBecomeKeyWindow: YES];
- [o_fullscreen_window setCanBecomeMainWindow: YES];
-
- if (![o_current_video_window isVisible] || [o_current_video_window alphaValue] == 0.0)
- {
- /* We don't animate if we are not visible, instead we
- * simply fade the display */
- CGDisplayFadeReservationToken token;
-
- if( blackout_other_displays )
- {
- CGAcquireDisplayFadeReservation( kCGMaxDisplayReservationInterval, &token );
- CGDisplayFade( token, 0.5, kCGDisplayBlendNormal, kCGDisplayBlendSolidColor, 0, 0, 0, YES );
- }
-
- if ([screen isMainScreen])
- {
- if (OSX_LEOPARD)
- SetSystemUIMode( kUIModeAllHidden, kUIOptionAutoShowMenuBar);
- else
- [NSApp setPresentationOptions:(NSApplicationPresentationAutoHideDock | NSApplicationPresentationAutoHideMenuBar)];
- }
-
- [[o_video_view superview] replaceSubview:o_video_view with:o_temp_view];
- [o_temp_view setFrame:[o_video_view frame]];
- [o_fullscreen_window setContentView:o_video_view];
-
- [o_fullscreen_window makeKeyAndOrderFront:self];
- [o_fullscreen_window orderFront:self animate:YES];
-
- [o_fullscreen_window setFrame:screen_rect display:YES animate:YES];
- [o_fullscreen_window setLevel:NSNormalWindowLevel];
-
- if( blackout_other_displays )
- {
- CGDisplayFade( token, 0.3, kCGDisplayBlendSolidColor, kCGDisplayBlendNormal, 0, 0, 0, NO );
- CGReleaseDisplayFadeReservation( token );
- }
-
- /* Will release the lock */
- [self hasBecomeFullscreen];
-
- return;
- }
-
- /* Make sure we don't see the o_video_view disappearing of the screen during this operation */
- NSDisableScreenUpdates();
- [[o_video_view superview] replaceSubview:o_video_view with:o_temp_view];
- [o_temp_view setFrame:[o_video_view frame]];
- [o_fullscreen_window setContentView:o_video_view];
- [o_fullscreen_window makeKeyAndOrderFront:self];
- NSEnableScreenUpdates();