[vlc-devel] [PATCH] macosx: hide the mouse cursor in Lion fullscreen

Brendon Justin brendonjustin at gmail.com
Tue Jan 3 21:33:25 CET 2012


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.
---
 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];
-- 
1.7.5.4




More information about the vlc-devel mailing list