]> git.sesse.net Git - vlc/commitdiff
Centralized mouse auto-hiding code.
authorLaurent Aimar <fenrir@videolan.org>
Wed, 9 Sep 2009 20:46:41 +0000 (22:46 +0200)
committerLaurent Aimar <fenrir@videolan.org>
Mon, 14 Sep 2009 18:18:42 +0000 (20:18 +0200)
modules/video_output/msw/common.c
modules/video_output/msw/direct3d.c
modules/video_output/msw/directx.c
modules/video_output/msw/events.c
modules/video_output/msw/glwin32.c
modules/video_output/msw/vout.h
modules/video_output/msw/wingdi.c

index eefcae9e3d2c735083f28d01a56c3ee31097dcd5..0b56da2bb53e211aad99fd65503fc13c709f700b 100644 (file)
@@ -86,11 +86,6 @@ int CommonInit( vout_thread_t *p_vout )
     SetRectEmpty( &p_sys->rect_parent );
     vlc_mutex_init( &p_sys->lock );
 
-    p_sys->b_cursor_hidden = 0;
-    p_sys->i_lastmoved = mdate();
-    p_sys->i_mouse_hide_timeout =
-        var_GetInteger(p_vout, "mouse-hide-timeout") * 1000;
-
     var_Create( p_vout, "video-title", VLC_VAR_STRING | VLC_VAR_DOINHERIT );
 
     /* Set main window's size */
index 0abb633edef475dafd9bfcf015031900eb6ebc96..d0ba09e0b4af736758494ee49c208ee4edc3e947 100644 (file)
@@ -442,25 +442,7 @@ static int Manage( vout_thread_t *p_vout )
     /*
      * Pointer change
      */
-    if( p_vout->b_fullscreen && !p_vout->p_sys->b_cursor_hidden &&
-        (mdate() - p_vout->p_sys->i_lastmoved) >
-            p_vout->p_sys->i_mouse_hide_timeout )
-    {
-        POINT point;
-        HWND hwnd;
-
-        /* Hide the cursor only if it is inside our window */
-        GetCursorPos( &point );
-        hwnd = WindowFromPoint(point);
-        if( hwnd == p_vout->p_sys->hwnd || hwnd == p_vout->p_sys->hvideownd )
-        {
-            PostMessage( p_vout->p_sys->hwnd, WM_VLC_HIDE_MOUSE, 0, 0 );
-        }
-        else
-        {
-            p_vout->p_sys->i_lastmoved = mdate();
-        }
-    }
+    EventThreadMouseAutoHide( p_vout->p_sys->p_event );
 
     /*
      * "Always on top" status change
index eff8777c726e07616b6482414d401aad20082c16..041e7bcf3970f18eff90534285397d259222c6f9 100644 (file)
@@ -554,25 +554,7 @@ static int Manage( vout_thread_t *p_vout )
     /*
      * Pointer change
      */
-    if( p_vout->b_fullscreen && !p_vout->p_sys->b_cursor_hidden &&
-        (mdate() - p_vout->p_sys->i_lastmoved) >
-            p_vout->p_sys->i_mouse_hide_timeout )
-    {
-        POINT point;
-        HWND hwnd;
-
-        /* Hide the cursor only if it is inside our window */
-        GetCursorPos( &point );
-        hwnd = WindowFromPoint(point);
-        if( hwnd == p_vout->p_sys->hwnd || hwnd == p_vout->p_sys->hvideownd )
-        {
-            PostMessage( p_vout->p_sys->hwnd, WM_VLC_HIDE_MOUSE, 0, 0 );
-        }
-        else
-        {
-            p_vout->p_sys->i_lastmoved = mdate();
-        }
-    }
+    EventThreadMouseAutoHide( p_vout->p_sys->p_event );
 
     /*
      * "Always on top" status change
index 774cc9497955ff578f7cc0459c9cab36c02651b3..642ae914ae1cf32f7b699c35786ea1b9948d5bee 100644 (file)
@@ -200,26 +200,26 @@ static void *EventThread( void *p_this )
                 (abs(mouse_pos.y - old_mouse_pos.y)) > 2 ) )
             {
                 GetCursorPos( &old_mouse_pos );
-                p_event->p_vout->p_sys->i_lastmoved = mdate();
+                p_event->i_lastmoved = mdate();
 
-                if( p_event->p_vout->p_sys->b_cursor_hidden )
+                if( p_event->b_cursor_hidden )
                 {
-                    p_event->p_vout->p_sys->b_cursor_hidden = 0;
+                    p_event->b_cursor_hidden = 0;
                     ShowCursor( TRUE );
                 }
             }
             break;
 
         case WM_VLC_HIDE_MOUSE:
-            if( p_event->p_vout->p_sys->b_cursor_hidden ) break;
-            p_event->p_vout->p_sys->b_cursor_hidden = true;
+            if( p_event->b_cursor_hidden ) break;
+            p_event->b_cursor_hidden = true;
             GetCursorPos( &old_mouse_pos );
             ShowCursor( FALSE );
             break;
 
         case WM_VLC_SHOW_MOUSE:
-            if( !p_event->p_vout->p_sys->b_cursor_hidden ) break;
-            p_event->p_vout->p_sys->b_cursor_hidden = false;
+            if( !p_event->b_cursor_hidden ) break;
+            p_event->b_cursor_hidden = false;
             GetCursorPos( &old_mouse_pos );
             ShowCursor( TRUE );
             break;
@@ -895,6 +895,30 @@ static int DirectXConvertKey( int i_key )
     return 0;
 }
 
+void EventThreadMouseAutoHide( event_thread_t *p_event )
+{
+    vout_thread_t *p_vout = p_event->p_vout;
+
+    if( p_vout->b_fullscreen &&
+        !p_event->b_cursor_hidden &&
+        (mdate() - p_event->i_lastmoved) > p_event->i_mouse_hide_timeout )
+    {
+        /* Hide the cursor only if it is inside our window */
+        POINT point;
+        GetCursorPos( &point );
+
+        HWND hwnd = WindowFromPoint(point);
+        if( hwnd == p_vout->p_sys->hwnd || hwnd == p_vout->p_sys->hvideownd )
+        {
+            PostMessage( p_vout->p_sys->hwnd, WM_VLC_HIDE_MOUSE, 0, 0 );
+        }
+        else
+        {
+            p_event->i_lastmoved = mdate();
+        }
+    }
+}
+
 event_thread_t *EventThreadCreate( vout_thread_t *p_vout )
 {
      /* Create the Vout EventThread, this thread is created by us to isolate
@@ -912,6 +936,11 @@ event_thread_t *EventThreadCreate( vout_thread_t *p_vout )
     p_event->p_vout = p_vout;
     vlc_mutex_init( &p_event->lock );
     vlc_cond_init( &p_event->wait );
+
+    p_event->b_cursor_hidden      = false;
+    p_event->i_lastmoved          = mdate();
+    p_event->i_mouse_hide_timeout =
+        var_GetInteger(p_vout, "mouse-hide-timeout") * 1000;
    
     return p_event;
 }
index 34e5e0dec4878ee4046bf00b279593bb682877ca..1a29662d7326c95c088caf08836286df31e9e7b3 100644 (file)
@@ -283,25 +283,7 @@ static int Manage( vout_thread_t *p_vout )
     /*
      * Pointer change
      */
-    if( p_vout->b_fullscreen && !p_vout->p_sys->b_cursor_hidden &&
-        (mdate() - p_vout->p_sys->i_lastmoved) >
-            p_vout->p_sys->i_mouse_hide_timeout )
-    {
-        POINT point;
-        HWND hwnd;
-
-        /* Hide the cursor only if it is inside our window */
-        GetCursorPos( &point );
-        hwnd = WindowFromPoint(point);
-        if( hwnd == p_vout->p_sys->hwnd || hwnd == p_vout->p_sys->hvideownd )
-        {
-            PostMessage( p_vout->p_sys->hwnd, WM_VLC_HIDE_MOUSE, 0, 0 );
-        }
-        else
-        {
-            p_vout->p_sys->i_lastmoved = mdate();
-        }
-    }
+    EventThreadMouseAutoHide( p_vout->p_sys->p_event );
 
     /*
      * "Always on top" status change
index d01fde0a93c80357f17ed4f85c13457d9aaf5437..2d92e130ca36319f2b7dc16b1643ff1663e2eddf 100644 (file)
@@ -37,6 +37,11 @@ typedef struct
     bool         b_done;
     bool         b_error;
 
+    /* Mouse */
+    volatile bool    b_cursor_hidden;
+    volatile mtime_t i_lastmoved;
+    mtime_t          i_mouse_hide_timeout;
+
 } event_thread_t;
 
 #ifdef MODULE_NAME_IS_wingapi
@@ -112,11 +117,6 @@ struct vout_sys_t
 
     volatile uint16_t i_changes;        /* changes made to the video display */
 
-    /* Mouse */
-    volatile bool b_cursor_hidden;
-    volatile mtime_t    i_lastmoved;
-    mtime_t             i_mouse_hide_timeout;
-
     /* Misc */
     bool      b_on_top_change;
 
@@ -266,6 +266,8 @@ void            EventThreadDestroy( event_thread_t * );
 int             EventThreadStart( event_thread_t * );
 void            EventThreadStop( event_thread_t * );
 
+void            EventThreadMouseAutoHide( event_thread_t * );
+
 /*****************************************************************************
  * Prototypes from common.c
  *****************************************************************************/
index 22d4f88a0ba738b293f52228aeaa3728c87e8c00..35d587b0366aa16474dda51115f804473b8e0c89 100644 (file)
@@ -411,25 +411,7 @@ static int Manage( vout_thread_t *p_vout )
     /*
      * Pointer change
      */
-    if( p_vout->b_fullscreen && !p_vout->p_sys->b_cursor_hidden &&
-        (mdate() - p_vout->p_sys->i_lastmoved) >
-            p_vout->p_sys->i_mouse_hide_timeout )
-    {
-        POINT point;
-        HWND hwnd;
-
-        /* Hide the cursor only if it is inside our window */
-        GetCursorPos( &point );
-        hwnd = WindowFromPoint(point);
-        if( hwnd == p_vout->p_sys->hwnd || hwnd == p_vout->p_sys->hvideownd )
-        {
-            PostMessage( p_vout->p_sys->hwnd, WM_VLC_HIDE_MOUSE, 0, 0 );
-        }
-        else
-        {
-            p_vout->p_sys->i_lastmoved = mdate();
-        }
-    }
+    EventThreadMouseAutoHide( p_vout->p_sys->p_event );
 
     /*
      * "Always on top" status change