xcb: send QTabletEvent before QMouseEvent
authorShawn Rutledge <shawn.rutledge@digia.com>
Wed, 19 Aug 2015 13:22:53 +0000 (15:22 +0200)
committerShawn Rutledge <shawn.rutledge@theqtcompany.com>
Wed, 19 Aug 2015 14:14:21 +0000 (14:14 +0000)
It was a regression: drawing applications which can handle both mouse
and tablet events should not need to wait to see whether a mouse event
will be followed by a corresponding tablet event.  The tablet event is
preferred because it has all the tablet parameters (pressure etc.)
Also, show the timestamp of each mouse event in the log message,
which helps to verify the correspondence.

Task-number: QTBUG-47702
Change-Id: I9e832c19de935ec1243138eb4c1484284f61cbfc
Reviewed-by: Laszlo Agocs <laszlo.agocs@theqtcompany.com>
src/plugins/platforms/xcb/qxcbconnection_xi2.cpp
src/plugins/platforms/xcb/qxcbwindow.cpp

index 335236578b510894b36c47c8fd06af7ba9683e3f..d7688be0ff226c1f56cade79a11a53f1c5ee9ca8 100644 (file)
@@ -971,15 +971,6 @@ bool QXcbConnection::xi2HandleTabletEvent(void *event, TabletData *tabletData, Q
     xXIGenericDeviceEvent *xiEvent = static_cast<xXIGenericDeviceEvent *>(event);
     xXIDeviceEvent *xiDeviceEvent = reinterpret_cast<xXIDeviceEvent *>(xiEvent);
 
-#ifdef XCB_USE_XINPUT22
-    // Synthesize mouse events since otherwise there are no mouse events from
-    // the pen on the XI 2.2+ path.
-    if (xi2MouseEvents() && eventListener)
-        eventListener->handleXIMouseEvent(reinterpret_cast<xcb_ge_event_t *>(event));
-#else
-    Q_UNUSED(eventListener);
-#endif
-
     switch (xiEvent->evtype) {
     case XI_ButtonPress: {
         Qt::MouseButton b = xiToQtMouseButton(xiDeviceEvent->detail);
@@ -1064,6 +1055,16 @@ bool QXcbConnection::xi2HandleTabletEvent(void *event, TabletData *tabletData, Q
         handled = false;
         break;
     }
+
+#ifdef XCB_USE_XINPUT22
+    // Synthesize mouse events since otherwise there are no mouse events from
+    // the pen on the XI 2.2+ path.
+    if (xi2MouseEvents() && eventListener)
+        eventListener->handleXIMouseEvent(reinterpret_cast<xcb_ge_event_t *>(event));
+#else
+    Q_UNUSED(eventListener);
+#endif
+
     return handled;
 }
 
index af4a88b7bc65e4b8e3fa9b0fde58fc0ec945e41d..4fdebe1ebba97715e4ce1a9cbe2712f07b9dc3d9 100644 (file)
@@ -2249,17 +2249,17 @@ void QXcbWindow::handleXIMouseEvent(xcb_ge_event_t *event)
 
     switch (ev->evtype) {
     case XI_ButtonPress:
-        qCDebug(lcQpaXInput, "XI2 mouse press, button %d", button);
+        qCDebug(lcQpaXInput, "XI2 mouse press, button %d, time %d", button, ev->time);
         conn->setButton(button, true);
         handleButtonPressEvent(event_x, event_y, root_x, root_y, ev->detail, modifiers, ev->time);
         break;
     case XI_ButtonRelease:
-        qCDebug(lcQpaXInput, "XI2 mouse release, button %d", button);
+        qCDebug(lcQpaXInput, "XI2 mouse release, button %d, time %d", button, ev->time);
         conn->setButton(button, false);
         handleButtonReleaseEvent(event_x, event_y, root_x, root_y, ev->detail, modifiers, ev->time);
         break;
     case XI_Motion:
-        qCDebug(lcQpaXInput, "XI2 mouse motion %d,%d", event_x, event_y);
+        qCDebug(lcQpaXInput, "XI2 mouse motion %d,%d, time %d", event_x, event_y, ev->time);
         handleMotionNotifyEvent(event_x, event_y, root_x, root_y, modifiers, ev->time);
         break;
     default: