[vlc-commits] [Git][videolan/vlc][3.0.x] qt: interface_widgets: honor --no-mouse-events

Hugo Beauzée-Luyssen (@chouquette) gitlab at videolan.org
Tue Nov 30 14:19:42 UTC 2021



Hugo Beauzée-Luyssen pushed to branch 3.0.x at VideoLAN / VLC


Commits:
d5e53764 by Alexandre Janniaux at 2021-11-29T11:24:54+01:00
qt: interface_widgets: honor --no-mouse-events

With --no-mouse-events, the mouse events were correctly disabled on
every window platform but not in the Qt provider.

- - - - -


2 changed files:

- modules/gui/qt/components/interface_widgets.cpp
- modules/gui/qt/components/interface_widgets.hpp


Changes:

=====================================
modules/gui/qt/components/interface_widgets.cpp
=====================================
@@ -186,6 +186,8 @@ bool VideoWidget::request( struct vout_window_t *p_wnd )
         default:
             vlc_assert_unreachable();
     }
+
+    enable_mouse_events = var_InheritBool(p_window, "mouse-events");
     return true;
 }
 
@@ -320,31 +322,50 @@ int VideoWidget::qtMouseButton2VLC( Qt::MouseButton qtButton )
 
 void VideoWidget::mouseReleaseEvent( QMouseEvent *event )
 {
+    if ( !p_window || !enable_mouse_events )
+    {
+        event->ignore();
+        return;
+    }
+
     int vlc_button = qtMouseButton2VLC( event->button() );
     if( vlc_button >= 0 )
     {
         vout_window_ReportMouseReleased( p_window, vlc_button );
         event->accept();
+        return;
     }
-    else
-        event->ignore();
+
+    event->ignore();
 }
 
 void VideoWidget::mousePressEvent( QMouseEvent* event )
 {
+    if ( !p_window || enable_mouse_events )
+    {
+        event->ignore();
+        return;
+    }
+
     int vlc_button = qtMouseButton2VLC( event->button() );
     if( vlc_button >= 0 )
     {
         vout_window_ReportMousePressed( p_window, vlc_button );
         event->accept();
+        return;
     }
-    else
-        event->ignore();
+
+    event->ignore();
 }
 
 void VideoWidget::mouseMoveEvent( QMouseEvent *event )
 {
-    if( p_window != NULL )
+    if ( !p_window || !enable_mouse_events )
+    {
+        event->ignore();
+        return;
+    }
+
     {
         QPointF current_pos = event->localPos();
 
@@ -355,21 +376,29 @@ void VideoWidget::mouseMoveEvent( QMouseEvent *event )
 #endif
         vout_window_ReportMouseMoved( p_window, current_pos.x(), current_pos.y() );
         event->accept();
+        return;
     }
-    else
-        event->ignore();
+
+    event->ignore();
 }
 
 void VideoWidget::mouseDoubleClickEvent( QMouseEvent *event )
 {
+    if ( !p_window || !enable_mouse_events )
+    {
+        event->ignore();
+        return;
+    }
+
     int vlc_button = qtMouseButton2VLC( event->button() );
     if( vlc_button >= 0 )
     {
         vout_window_ReportMouseDoubleClick( p_window, vlc_button );
         event->accept();
+        return;
     }
-    else
-        event->ignore();
+
+    event->ignore();
 }
 
 


=====================================
modules/gui/qt/components/interface_widgets.hpp
=====================================
@@ -85,6 +85,8 @@ private:
     QWidget *stable;
     QLayout *layout;
 
+    bool enable_mouse_events;
+
     void reportSize();
 
 signals:



View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/d5e53764ba89d36ca5c300e0cc0f5261b0abe8ac

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/d5e53764ba89d36ca5c300e0cc0f5261b0abe8ac
You're receiving this email because of your account on code.videolan.org.




More information about the vlc-commits mailing list