#import "misc.h"
#import "fspanel.h"
+@interface VLCFSPanel ()
+- (void)hideMouse;
+@end
+
/*****************************************************************************
* VLCFSPanel
*****************************************************************************/
@implementation VLCFSPanel
/* We override this initializer so we can set the NSBorderlessWindowMask styleMask, and set a few other important settings */
- (id)initWithContentRect:(NSRect)contentRect
- styleMask:(unsigned int)aStyle
+ styleMask:(NSUInteger)aStyle
backing:(NSBackingStoreType)bufferingType
defer:(BOOL)flag
{
[win setLevel:NSModalPanelWindowLevel];
i_device = 0;
[win center];
+ hideAgainTimer = fadeTimer = nil;
[self setNonActive:nil];
-
return win;
}
-(void)dealloc
{
[[NSNotificationCenter defaultCenter] removeObserver: self];
-
+
if( hideAgainTimer )
+ {
+ [hideAgainTimer invalidate];
[hideAgainTimer release];
+ }
[self setFadeTimer:nil];
[super dealloc];
}
- (void)setActive:(id)noData
{
- if( [[[[VLCMain sharedInstance] getControls] getVoutView] isFullscreen] )
+ if( [[[VLCMain sharedInstance] controls] voutView] != nil )
{
- b_nonActive = NO;
- [self fadeIn];
+ if( [[[[VLCMain sharedInstance] controls] voutView] isFullscreen] )
+ {
+ b_nonActive = NO;
+ [self fadeIn];
+ }
}
}
- (void)mouseExited:(NSEvent *)theEvent
{
/* give up our focus, so the vout may show us again without letting the user clicking it */
- if( [[[[VLCMain sharedInstance] getControls] getVoutView] isFullscreen] )
- [[[[[VLCMain sharedInstance] getControls] getVoutView] window] makeKeyWindow];
+ if( [[[[VLCMain sharedInstance] controls] voutView] isFullscreen] )
+ [[[[[VLCMain sharedInstance] controls] voutView] window] makeKeyWindow];
+}
+
+- (void)hideMouse
+{
+ [NSCursor setHiddenUntilMouseMoves: YES];
}
- (void)fadeIn
{
- /* in case that the user don't want us to appear, just return here */
- if(! config_GetInt( VLCIntf, "macosx-fspanel" ) || b_nonActive )
+ /* in case that the user don't want us to appear, make sure we hide the mouse */
+
+ if( !config_GetInt( VLCIntf, "macosx-fspanel" ) )
+ {
+ float time = (float)var_CreateGetInteger( VLCIntf, "mouse-hide-timeout" ) / 1000.;
+ [self setFadeTimer:[NSTimer scheduledTimerWithTimeInterval:time target:self selector:@selector(hideMouse) userInfo:nil repeats:NO]];
return;
-
+ }
+
+ if( b_nonActive )
+ return;
+
[self orderFront: nil];
if( [self alphaValue] < 1.0 || b_displayed != YES )
/* get us a valid timer */
if(! b_alreadyCounting )
{
- i_timeToKeepVisibleInSec = config_GetInt( VLCIntf, "mouse-hide-timeout" ) / 500;
- hideAgainTimer = [NSTimer scheduledTimerWithTimeInterval: 0.5
+ i_timeToKeepVisibleInSec = var_CreateGetInteger( VLCIntf, "mouse-hide-timeout" ) / 500;
+ if( hideAgainTimer )
+ {
+ [hideAgainTimer invalidate];
+ [hideAgainTimer autorelease];
+ }
+ /* released in -autoHide and -dealloc */
+ hideAgainTimer = [[NSTimer scheduledTimerWithTimeInterval: 0.5
target: self
selector: @selector(keepVisible:)
userInfo: nil
- repeats: YES];
- [hideAgainTimer fire];
- [hideAgainTimer retain];
+ repeats: YES] retain];
b_alreadyCounting = YES;
}
}
b_keptVisible = NO;
/* count down until we hide ourselfes again and do so if necessary */
- i_timeToKeepVisibleInSec -= 1;
- if( i_timeToKeepVisibleInSec < 1 )
+ if( --i_timeToKeepVisibleInSec < 1 )
{
- [NSCursor setHiddenUntilMouseMoves: YES];
+ [self hideMouse];
[self fadeOut];
- [timer invalidate];
- [timer release];
+ [hideAgainTimer invalidate]; /* released in -autoHide and -dealloc */
b_alreadyCounting = NO;
- timer = NULL;
}
}
{
[timer retain];
[fadeTimer invalidate];
- [fadeTimer release];
+ [fadeTimer autorelease];
fadeTimer=timer;
}
- (IBAction)play:(id)sender
{
- [[[VLCMain sharedInstance] getControls] play: sender];
+ [[[VLCMain sharedInstance] controls] play: sender];
}
- (IBAction)forward:(id)sender
{
- [[[VLCMain sharedInstance] getControls] forward: sender];
+ [[[VLCMain sharedInstance] controls] forward: sender];
}
- (IBAction)backward:(id)sender
{
- [[[VLCMain sharedInstance] getControls] backward: sender];
+ [[[VLCMain sharedInstance] controls] backward: sender];
}
- (IBAction)prev:(id)sender
{
- [[[VLCMain sharedInstance] getControls] prev: sender];
+ [[[VLCMain sharedInstance] controls] prev: sender];
}
- (IBAction)next:(id)sender
{
- [[[VLCMain sharedInstance] getControls] next: sender];
+ [[[VLCMain sharedInstance] controls] next: sender];
}
- (IBAction)windowAction:(id)sender
{
- [[[VLCMain sharedInstance] getControls] windowAction: sender];
+ [[[VLCMain sharedInstance] controls] windowAction: sender];
}
- (IBAction)fsTimeSliderUpdate:(id)sender
- (IBAction)fsVolumeSliderUpdate:(id)sender
{
- [[[VLCMain sharedInstance] getControls] volumeSliderUpdated: sender];
+ [[[VLCMain sharedInstance] controls] volumeSliderUpdated: sender];
}
#define addImage(image, _x, _y, mode, _width) \