vlc | branch: master | Brendon Justin <brendonjus...@gmail.com> | Tue Jan 3 15:33:25 2012 -0500| [07dcbf50fc83a85ee92643285d7164cfe04aafdf] | committer: Felix Paul Kühne
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: Felix Paul Kühne <fkue...@videolan.org> > http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=07dcbf50fc83a85ee92643285d7164cfe04aafdf --- modules/gui/macosx/MainWindow.h | 5 +++++ modules/gui/macosx/MainWindow.m | 35 +++++++++++++++++++++++++++++++++-- 2 files changed, 38 insertions(+), 2 deletions(-) diff --git a/modules/gui/macosx/MainWindow.h b/modules/gui/macosx/MainWindow.h index 4892931..c3e24d7 100644 --- a/modules/gui/macosx/MainWindow.h +++ b/modules/gui/macosx/MainWindow.h @@ -110,6 +110,8 @@ NSRecursiveLock * o_animation_lock; NSSize nativeVideoSize; + NSTimer *t_hide_mouse_timer; + NSInteger i_originalLevel; NSRect previousSavedFrame; } @@ -152,6 +154,9 @@ - (void)resizeWindow; - (void)setNativeVideoSize:(NSSize)size; +- (void)hideMouseCursor:(NSTimer *)timer; +- (void)recreateHideMouseTimer; + /* fullscreen handling */ - (void)showFullscreenController; - (BOOL)isFullscreen; diff --git a/modules/gui/macosx/MainWindow.m b/modules/gui/macosx/MainWindow.m index 3c5521f..96a7416 100644 --- a/modules/gui/macosx/MainWindow.m +++ b/modules/gui/macosx/MainWindow.m @@ -120,6 +120,7 @@ static VLCMainWindow *_o_sharedInstance = nil; /* setup the styled interface */ b_nativeFullscreenMode = config_GetInt( VLCIntf, "macosx-nativefullscreenmode" ); i_lastShownVolume = -1; + t_hide_mouse_timer = nil; [o_play_btn setToolTip: _NS("Play/Pause")]; [o_bwd_btn setToolTip: _NS("Backward")]; @@ -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 Fullscreen support - (void)showFullscreenController @@ -1198,7 +1228,7 @@ static VLCMainWindow *_o_sharedInstance = nil; [o_fullscreen_btn setState: YES]; - [NSCursor setHiddenUntilMouseMoves: YES]; + [self recreateHideMouseTimer]; if( blackout_other_displays ) [screen blackoutOtherScreens]; @@ -1623,10 +1653,11 @@ static VLCMainWindow *_o_sharedInstance = nil; - (void)windowWillEnterFullScreen:(NSNotification *)notification { [o_video_view setFrame: [[self contentView] frame]]; - [NSCursor setHiddenUntilMouseMoves: YES]; b_fullscreen = YES; [o_fspanel setVoutWasUpdated: (int)[[self screen] displayID]]; + [self recreateHideMouseTimer]; + if (b_dark_interface) { [o_titlebar_view removeFromSuperviewWithoutNeedingDisplay]; _______________________________________________ vlc-commits mailing list vlc-commits@videolan.org http://mailman.videolan.org/listinfo/vlc-commits