Avoid duplicate emulated mouse events with XInput2
When using a touch screen on a Linux machine, we receive both touch-events and emulated mouse events from XInput, on top of that we synthesize mouse- events ourselves for the touch events. This patch grabs the touch device for touch events whenever it processes a touch-begin thereby avoiding XInput from synthesizing mouse events. Task-number: QTBUG-35157 Change-Id: I5849d5841be236d6719cd080af2e9e39eb9cdd84 Reviewed-by: Laszlo Agocs <laszlo.agocs@digia.com>bb10
parent
8a6766d78b
commit
2c65b78b40
|
|
@ -432,6 +432,22 @@ void QXcbConnection::xi2HandleEvent(xcb_ge_event_t *event)
|
|||
qDebug() << " touchpoint " << touchPoint.id << " state " << touchPoint.state << " pos norm " << touchPoint.normalPosition <<
|
||||
" area " << touchPoint.area << " pressure " << touchPoint.pressure;
|
||||
QWindowSystemInterface::handleTouchEvent(platformWindow->window(), xiEvent->time, dev->qtTouchDevice, m_touchPoints.values());
|
||||
if (has_touch_without_mouse_emulation) {
|
||||
// We need to grab the touch event to prevent mouse emulation.
|
||||
if (xiEvent->evtype == XI_TouchBegin) {
|
||||
XIEventMask xieventmask;
|
||||
unsigned int bitMask = 0;
|
||||
unsigned char *xiBitMask = reinterpret_cast<unsigned char *>(&bitMask);
|
||||
xieventmask.deviceid = xiEvent->deviceid;
|
||||
xieventmask.mask = xiBitMask;
|
||||
xieventmask.mask_len = sizeof(bitMask);
|
||||
bitMask |= XI_TouchBeginMask;
|
||||
bitMask |= XI_TouchUpdateMask;
|
||||
bitMask |= XI_TouchEndMask;
|
||||
XIGrabDevice(static_cast<Display *>(m_xlib_display), xiEvent->deviceid, platformWindow->winId(), xiEvent->time, None, GrabModeAsync, GrabModeAsync, true, &xieventmask);
|
||||
} else if (xiEvent->evtype == XI_TouchEnd)
|
||||
XIUngrabDevice(static_cast<Display *>(m_xlib_display), xiEvent->deviceid, xiEvent->time);
|
||||
}
|
||||
if (touchPoint.state == Qt::TouchPointReleased)
|
||||
// If a touchpoint was released, we can forget it, because the ID won't be reused.
|
||||
m_touchPoints.remove(touchPoint.id);
|
||||
|
|
|
|||
Loading…
Reference in New Issue