[vlc-commits] commit: Fixed mouse buttons state for msw vouts (close #3519). ( Laurent Aimar )

git at videolan.org git at videolan.org
Sun Jun 13 01:14:14 CEST 2010


vlc/vlc-1.1 | branch: master | Laurent Aimar <fenrir at videolan.org> | Sun Jun 13 00:44:31 2010 +0200| [0e9bb2b6027e3327cf00694cfef5aaa76f446602] | committer: Jean-Baptiste Kempf 

Fixed mouse buttons state for msw vouts (close #3519).

Used SetCapture/ReleaseCapture to emulate what x11 seems to do by default.
(cherry picked from commit 2a1f2f0bf5f14963417fb758910db478ac407a62)

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

> http://git.videolan.org/gitweb.cgi/vlc/vlc-1.1.git/?a=commit;h=0e9bb2b6027e3327cf00694cfef5aaa76f446602
---

 modules/video_output/msw/events.c |   49 +++++++++++++++++++++++++++++++-----
 1 files changed, 42 insertions(+), 7 deletions(-)

diff --git a/modules/video_output/msw/events.c b/modules/video_output/msw/events.c
index 735f713..4192d0f 100644
--- a/modules/video_output/msw/events.c
+++ b/modules/video_output/msw/events.c
@@ -103,6 +103,7 @@ struct event_thread_t
     bool is_cursor_hidden;
     HCURSOR cursor_arrow;
     HCURSOR cursor_empty;
+    unsigned button_pressed;
 
     /* Title */
     char *psz_title;
@@ -161,7 +162,12 @@ static void UpdateCursor( event_thread_t *p_event, bool b_show )
     GetCursorPos(&p);
     HWND hwnd = WindowFromPoint(p);
     if( hwnd == p_event->hvideownd || hwnd == p_event->hwnd )
-        SetCursorPos(p.x, p.y);
+    {
+        if( b_show )
+            SetCursor( cursor );
+        else
+            SetCursorPos( p.x, p.y );
+    }
 }
 
 static HCURSOR EmptyCursor( HINSTANCE instance )
@@ -184,6 +190,21 @@ static HCURSOR EmptyCursor( HINSTANCE instance )
     return cursor;
 }
 
+static void MousePressed( event_thread_t *p_event, HWND hwnd, unsigned button )
+{
+    if( !p_event->button_pressed )
+        SetCapture( hwnd );
+    p_event->button_pressed |= 1 << button;
+    vout_display_SendEventMousePressed( p_event->vd, button );
+}
+
+static void MouseReleased( event_thread_t *p_event, unsigned button )
+{
+    p_event->button_pressed &= ~(1 << button);
+    if( !p_event->button_pressed )
+        ReleaseCapture();
+    vout_display_SendEventMouseReleased( p_event->vd, button );
+}
 /*****************************************************************************
  * EventThread: Create video window & handle its messages
  *****************************************************************************
@@ -321,27 +342,27 @@ static void *EventThread( void *p_this )
             break;
 
         case WM_LBUTTONDOWN:
-            vout_display_SendEventMousePressed(vd, MOUSE_BUTTON_LEFT);
+            MousePressed( p_event, msg.hwnd, MOUSE_BUTTON_LEFT );
             break;
         case WM_LBUTTONUP:
-            vout_display_SendEventMouseReleased(vd, MOUSE_BUTTON_LEFT);
+            MouseReleased( p_event, MOUSE_BUTTON_LEFT );
             break;
         case WM_LBUTTONDBLCLK:
             vout_display_SendEventMouseDoubleClick(vd);
             break;
 
         case WM_MBUTTONDOWN:
-            vout_display_SendEventMousePressed(vd, MOUSE_BUTTON_CENTER);
+            MousePressed( p_event, msg.hwnd, MOUSE_BUTTON_CENTER );
             break;
         case WM_MBUTTONUP:
-            vout_display_SendEventMouseReleased(vd, MOUSE_BUTTON_CENTER);
+            MouseReleased( p_event, MOUSE_BUTTON_CENTER );
             break;
 
         case WM_RBUTTONDOWN:
-            vout_display_SendEventMousePressed(vd, MOUSE_BUTTON_RIGHT);
+            MousePressed( p_event, msg.hwnd, MOUSE_BUTTON_RIGHT );
             break;
         case WM_RBUTTONUP:
-            vout_display_SendEventMouseReleased(vd, MOUSE_BUTTON_RIGHT);
+            MouseReleased( p_event, MOUSE_BUTTON_RIGHT );
             break;
 
         case WM_KEYDOWN:
@@ -746,6 +767,19 @@ static long FAR PASCAL DirectXEventProc( HWND hwnd, UINT message,
         return 1;
     }
 #endif
+    if( message == WM_CAPTURECHANGED )
+    {
+        for( int button = 0; p_event->button_pressed; button++ )
+        {
+            unsigned m = 1 << button;
+            if( p_event->button_pressed & m )
+                vout_display_SendEventMouseReleased( p_event->vd, button );
+            p_event->button_pressed &= ~m;
+        }
+        p_event->button_pressed = 0;
+        return 0;
+    }
+
     if( hwnd == p_event->hvideownd )
     {
 #ifdef MODULE_NAME_IS_directx
@@ -1041,6 +1075,7 @@ event_thread_t *EventThreadCreate( vout_display_t *vd)
     vlc_cond_init( &p_event->wait );
 
     p_event->is_cursor_hidden = false;
+    p_event->button_pressed = 0;
     p_event->psz_title = NULL;
     p_event->source = vd->source;
     vout_display_PlacePicture(&p_event->place, &vd->source, vd->cfg, true);



More information about the vlc-commits mailing list