Commit 68eeac8e authored by Brendon Justin's avatar Brendon Justin Committed by Jean-Baptiste Kempf

macosx: hide the mouse cursor in Lion fullscreen

Though #5327 is closed, 1.2 and 1.3 nightlies do not work
as expected.  The patch makes the cursor hide after every
mouse movement.
Signed-off-by: default avatarFelix Paul Kühne <fkuehne@videolan.org>
(cherry picked from commit 07dcbf50)
Signed-off-by: default avatarJean-Baptiste Kempf <jb@videolan.org>
parent 9aa83524
...@@ -110,6 +110,8 @@ ...@@ -110,6 +110,8 @@
NSRecursiveLock * o_animation_lock; NSRecursiveLock * o_animation_lock;
NSSize nativeVideoSize; NSSize nativeVideoSize;
NSTimer *t_hide_mouse_timer;
NSInteger i_originalLevel; NSInteger i_originalLevel;
NSRect previousSavedFrame; NSRect previousSavedFrame;
} }
...@@ -152,6 +154,9 @@ ...@@ -152,6 +154,9 @@
- (void)resizeWindow; - (void)resizeWindow;
- (void)setNativeVideoSize:(NSSize)size; - (void)setNativeVideoSize:(NSSize)size;
- (void)hideMouseCursor:(NSTimer *)timer;
- (void)recreateHideMouseTimer;
/* fullscreen handling */ /* fullscreen handling */
- (void)showFullscreenController; - (void)showFullscreenController;
- (BOOL)isFullscreen; - (BOOL)isFullscreen;
......
...@@ -120,6 +120,7 @@ static VLCMainWindow *_o_sharedInstance = nil; ...@@ -120,6 +120,7 @@ static VLCMainWindow *_o_sharedInstance = nil;
/* setup the styled interface */ /* setup the styled interface */
b_nativeFullscreenMode = config_GetInt( VLCIntf, "macosx-nativefullscreenmode" ); b_nativeFullscreenMode = config_GetInt( VLCIntf, "macosx-nativefullscreenmode" );
i_lastShownVolume = -1; i_lastShownVolume = -1;
t_hide_mouse_timer = nil;
[o_play_btn setToolTip: _NS("Play/Pause")]; [o_play_btn setToolTip: _NS("Play/Pause")];
[o_bwd_btn setToolTip: _NS("Backward")]; [o_bwd_btn setToolTip: _NS("Backward")];
...@@ -1143,6 +1144,35 @@ static VLCMainWindow *_o_sharedInstance = nil; ...@@ -1143,6 +1144,35 @@ static VLCMainWindow *_o_sharedInstance = nil;
} }
} }
// Called automatically if window's acceptsMouseMovedEvents property is true
- (void)mouseMoved:(NSEvent *)theEvent
{
if (b_fullscreen) {
[self recreateHideMouseTimer];
}
}
- (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 -
#pragma mark Fullscreen support #pragma mark Fullscreen support
- (void)showFullscreenController - (void)showFullscreenController
...@@ -1198,7 +1228,7 @@ static VLCMainWindow *_o_sharedInstance = nil; ...@@ -1198,7 +1228,7 @@ static VLCMainWindow *_o_sharedInstance = nil;
[o_fullscreen_btn setState: YES]; [o_fullscreen_btn setState: YES];
[NSCursor setHiddenUntilMouseMoves: YES]; [self recreateHideMouseTimer];
if( blackout_other_displays ) if( blackout_other_displays )
[screen blackoutOtherScreens]; [screen blackoutOtherScreens];
...@@ -1623,10 +1653,11 @@ static VLCMainWindow *_o_sharedInstance = nil; ...@@ -1623,10 +1653,11 @@ static VLCMainWindow *_o_sharedInstance = nil;
- (void)windowWillEnterFullScreen:(NSNotification *)notification - (void)windowWillEnterFullScreen:(NSNotification *)notification
{ {
[o_video_view setFrame: [[self contentView] frame]]; [o_video_view setFrame: [[self contentView] frame]];
[NSCursor setHiddenUntilMouseMoves: YES];
b_fullscreen = YES; b_fullscreen = YES;
[o_fspanel setVoutWasUpdated: (int)[[self screen] displayID]]; [o_fspanel setVoutWasUpdated: (int)[[self screen] displayID]];
[self recreateHideMouseTimer];
if (b_dark_interface) if (b_dark_interface)
{ {
[o_titlebar_view removeFromSuperviewWithoutNeedingDisplay]; [o_titlebar_view removeFromSuperviewWithoutNeedingDisplay];
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment