[vlc-devel] [PATCH] qt5: make the mouse work again, sort of

Rémi Denis-Courmont remi at remlab.net
Fri Oct 23 21:58:26 CEST 2015


╔═══════════════════════════╗
║ PARENTAL ADVISORY:   R-24 ║
║ EXPLICIT CONTENT          ║
║ INAPPROPRIATE KLUDGY HACK ║
╚═══════════════════════════╝

May or may not interfere with touch devices.
May or may not interfere with cursor changes.
May or may not be forward compatible.
---
 configure.ac                                     |  6 ++++++
 modules/gui/qt4/components/interface_widgets.cpp | 21 +++++++++++++++++++++
 2 files changed, 27 insertions(+)

diff --git a/configure.ac b/configure.ac
index 3971c8e..e61cc8d 100644
--- a/configure.ac
+++ b/configure.ac
@@ -3718,6 +3718,12 @@ AS_IF([test "${enable_qt}" != "no"], [
       PKG_CHECK_MODULES([QTX11], [Qt5X11Extras], [
           VLC_ADD_LIBS([qt4],[${QTX11_LIBS}])
           VLC_ADD_CXXFLAGS([qt4],[${QTX11_CFLAGS} -DQT5_HAS_X11])
+          PKG_CHECK_EXISTS([Qt5Gui >= 5.5], [
+              PKG_CHECK_MODULES([XI], [xi], [
+                  VLC_ADD_LIBS([qt4], [${XI_LIBS}])
+                  VLC_ADD_CXXFLAGS([qt4], [${XI_CFLAGS}])
+              ])
+          ])
       ],[
           AC_MSG_WARN([Not building Qt Interface with X11 helpers.])
       ])
diff --git a/modules/gui/qt4/components/interface_widgets.cpp b/modules/gui/qt4/components/interface_widgets.cpp
index 00eca38..6bcc2b9 100644
--- a/modules/gui/qt4/components/interface_widgets.cpp
+++ b/modules/gui/qt4/components/interface_widgets.cpp
@@ -56,6 +56,9 @@
 
 #ifdef Q_WS_X11
 #   include <X11/Xlib.h>
+#   if (QT_VERSION >= 0x050500)
+#       include <X11/extensions/XInput2.h>
+#   endif
 #   include <qx11info_x11.h>
 #endif
 
@@ -150,7 +153,25 @@ WId VideoWidget::request( struct vout_window_t *p_wnd, unsigned int *pi_width,
 
     XGetWindowAttributes( dpy, w, &attr );
     attr.your_event_mask &= ~(ButtonPressMask|ButtonReleaseMask);
+    attr.your_event_mask &= ~PointerMotionMask;
     XSelectInput( dpy, w, attr.your_event_mask );
+# if (QT_VERSION >= 0x050500)
+    int n;
+    XIEventMask *xi_masks = XIGetSelectedEvents( dpy, w, &n );
+    if( xi_masks != NULL )
+    {
+        for( int i = 0; i < n; i++ )
+            if( xi_masks[i].mask_len >= 1 )
+            {
+                xi_masks[i].mask[0] &= ~XI_ButtonPressMask;
+                xi_masks[i].mask[0] &= ~XI_ButtonReleaseMask;
+                xi_masks[i].mask[0] &= ~XI_MotionMask;
+            }
+
+        XISelectEvents( dpy, w, xi_masks, n );
+        XFree( xi_masks );
+    }
+# endif
 #endif
     sync();
     p_window = p_wnd;
-- 
2.6.1



More information about the vlc-devel mailing list