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

Brendon Justin git at videolan.org
Thu Jan 5 00:51:17 CET 2012


vlc/vlc-1.2 | branch: master | Brendon Justin <brendonjustin at gmail.com> | Tue Jan  3 15:33:25 2012 -0500| [68eeac8e40cece0b88aa2a372085aea11a074e62] | committer: 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: Felix Paul Kühne <fkuehne at videolan.org>
(cherry picked from commit 07dcbf50fc83a85ee92643285d7164cfe04aafdf)

Signed-off-by: Jean-Baptiste Kempf <jb at videolan.org>

> http://git.videolan.org/gitweb.cgi/vlc/vlc-1.2.git/?a=commit;h=68eeac8e40cece0b88aa2a372085aea11a074e62
---

 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 c84f383..3405521 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];



More information about the vlc-commits mailing list