[vlc-commits] win32:vout_window: handle mouse buttons pressing

Steve Lhomme git at videolan.org
Thu Apr 4 12:30:49 CEST 2019


vlc | branch: master | Steve Lhomme <robux4 at ycbcr.xyz> | Wed Apr  3 13:21:10 2019 +0200| [a6b45e2e2bb71b690be6ea5e2eb4d17fde1c6632] | committer: Steve Lhomme

win32:vout_window: handle mouse buttons pressing

The code is copied from events.c

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

 modules/video_output/win32/window.c | 67 +++++++++++++++++++++++++++++++++++++
 1 file changed, 67 insertions(+)

diff --git a/modules/video_output/win32/window.c b/modules/video_output/win32/window.c
index 1d374bd226..05628d13ea 100644
--- a/modules/video_output/win32/window.c
+++ b/modules/video_output/win32/window.c
@@ -33,6 +33,7 @@
 #include <vlc_common.h>
 #include <vlc_plugin.h>
 #include <vlc_vout_window.h>
+#include <vlc_mouse.h>
 
 #include <shellapi.h>                                         /* ExtractIcon */
 
@@ -57,6 +58,9 @@ typedef struct vout_window_sys_t
     WCHAR class_main[256];
     HICON vlc_icon;
 
+    /* mouse */
+    unsigned button_pressed;
+
     /* cursor */
     bool       is_cursor_hidden;
     HCURSOR    cursor_arrow;
@@ -217,6 +221,24 @@ static void SetAbove( vout_window_t *wnd, enum vout_window_state state )
     }
 }
 
+static void MousePressed( vout_window_t *wnd, HWND hwnd, unsigned button )
+{
+    vout_window_sys_t *sys = wnd->sys;
+    if( !sys->button_pressed )
+        SetCapture( hwnd );
+    sys->button_pressed |= 1 << button;
+    vout_window_ReportMousePressed(wnd, button);
+}
+
+static void MouseReleased( vout_window_t *wnd, unsigned button )
+{
+    vout_window_sys_t *sys = wnd->sys;
+    sys->button_pressed &= ~(1 << button);
+    if( !sys->button_pressed )
+        ReleaseCapture();
+    vout_window_ReportMouseReleased(wnd, button);
+}
+
 /*****************************************************************************
  * WinVoutEventProc: This is the window event processing function.
  *****************************************************************************
@@ -264,6 +286,50 @@ static long FAR PASCAL WinVoutEventProc( HWND hwnd, UINT message,
     case WM_NCMOUSEMOVE:
         break;
 
+    case WM_CAPTURECHANGED:
+    {
+        vout_window_sys_t *sys = wnd->sys;
+        for( int button = 0; sys->button_pressed; button++ )
+        {
+            unsigned m = 1 << button;
+            if( sys->button_pressed & m )
+                vout_window_ReportMouseReleased(wnd, button);
+            sys->button_pressed &= ~m;
+        }
+        sys->button_pressed = 0;
+        break;
+    }
+
+    case WM_LBUTTONDOWN:
+        MousePressed( wnd, hwnd, MOUSE_BUTTON_LEFT );
+        return 0;
+    case WM_LBUTTONUP:
+        MouseReleased( wnd, MOUSE_BUTTON_LEFT );
+        return 0;
+    case WM_LBUTTONDBLCLK:
+        vout_window_ReportMouseDoubleClick(wnd, MOUSE_BUTTON_LEFT);
+        return 0;
+
+    case WM_MBUTTONDOWN:
+        MousePressed( wnd, hwnd, MOUSE_BUTTON_CENTER );
+        return 0;
+    case WM_MBUTTONUP:
+        MouseReleased( wnd, MOUSE_BUTTON_CENTER );
+        return 0;
+    case WM_MBUTTONDBLCLK:
+        vout_window_ReportMouseDoubleClick(wnd, MOUSE_BUTTON_CENTER);
+        return 0;
+
+    case WM_RBUTTONDOWN:
+        MousePressed( wnd, hwnd, MOUSE_BUTTON_RIGHT );
+        return 0;
+    case WM_RBUTTONUP:
+        MouseReleased( wnd, MOUSE_BUTTON_RIGHT );
+        return 0;
+    case WM_RBUTTONDBLCLK:
+        vout_window_ReportMouseDoubleClick(wnd, MOUSE_BUTTON_RIGHT);
+        return 0;
+
     case WM_SYSCOMMAND:
         switch (wParam)
         {
@@ -557,6 +623,7 @@ static int Open(vout_window_t *wnd)
     if( GetModuleFileName( NULL, app_path, MAX_PATH ) )
         sys->vlc_icon = ExtractIcon( hInstance, app_path    , 0 );
 
+    sys->button_pressed = 0;
     sys->is_cursor_hidden = false;
     sys->hide_timeout = var_InheritInteger( wnd, "mouse-hide-timeout" );
     sys->cursor_arrow = LoadCursor(NULL, IDC_ARROW);



More information about the vlc-commits mailing list