xcb: Add qt.qpa.input.events and guard mouse event logs too
Make mouse behave like touch and scrolling does: only do high frequency qCDebugs when the category is enabled. Switch over mouse, touch and scroll event logging to a new sub-category: qt.qpa.input.events. This way qt.qpa.input in itself behaves sanely on xcb, similarly to f.ex. eglfs, giving only the basic, but important info. Change-Id: I8dd588e72ae9d1c66096489fa3c5291f6d318ca0 Reviewed-by: Gatis Paeglis <gatis.paeglis@qt.io>bb10
parent
7e4f0ad961
commit
5178773f11
|
|
@ -101,6 +101,7 @@ QT_BEGIN_NAMESPACE
|
|||
|
||||
Q_LOGGING_CATEGORY(lcQpaXInput, "qt.qpa.input")
|
||||
Q_LOGGING_CATEGORY(lcQpaXInputDevices, "qt.qpa.input.devices")
|
||||
Q_LOGGING_CATEGORY(lcQpaXInputEvents, "qt.qpa.input.events")
|
||||
Q_LOGGING_CATEGORY(lcQpaScreen, "qt.qpa.screen")
|
||||
|
||||
// this event type was added in libxcb 1.10,
|
||||
|
|
@ -1107,7 +1108,8 @@ void QXcbConnection::handleXcbEvent(xcb_generic_event_t *event)
|
|||
// the rest we need to manage ourselves
|
||||
m_buttons = (m_buttons & ~0x7) | translateMouseButtons(ev->state);
|
||||
m_buttons |= translateMouseButton(ev->detail);
|
||||
qCDebug(lcQpaXInput, "legacy mouse press, button %d state %X", ev->detail, static_cast<unsigned int>(m_buttons));
|
||||
if (Q_UNLIKELY(lcQpaXInputEvents().isDebugEnabled()))
|
||||
qCDebug(lcQpaXInputEvents, "legacy mouse press, button %d state %X", ev->detail, static_cast<unsigned int>(m_buttons));
|
||||
HANDLE_PLATFORM_WINDOW_EVENT(xcb_button_press_event_t, event, handleButtonPressEvent);
|
||||
}
|
||||
case XCB_BUTTON_RELEASE: {
|
||||
|
|
@ -1115,15 +1117,17 @@ void QXcbConnection::handleXcbEvent(xcb_generic_event_t *event)
|
|||
m_keyboard->updateXKBStateFromCore(ev->state);
|
||||
m_buttons = (m_buttons & ~0x7) | translateMouseButtons(ev->state);
|
||||
m_buttons &= ~translateMouseButton(ev->detail);
|
||||
qCDebug(lcQpaXInput, "legacy mouse release, button %d state %X", ev->detail, static_cast<unsigned int>(m_buttons));
|
||||
if (Q_UNLIKELY(lcQpaXInputEvents().isDebugEnabled()))
|
||||
qCDebug(lcQpaXInputEvents, "legacy mouse release, button %d state %X", ev->detail, static_cast<unsigned int>(m_buttons));
|
||||
HANDLE_PLATFORM_WINDOW_EVENT(xcb_button_release_event_t, event, handleButtonReleaseEvent);
|
||||
}
|
||||
case XCB_MOTION_NOTIFY: {
|
||||
xcb_motion_notify_event_t *ev = (xcb_motion_notify_event_t *)event;
|
||||
m_keyboard->updateXKBStateFromCore(ev->state);
|
||||
m_buttons = (m_buttons & ~0x7) | translateMouseButtons(ev->state);
|
||||
qCDebug(lcQpaXInput, "legacy mouse move %d,%d button %d state %X", ev->event_x, ev->event_y,
|
||||
ev->detail, static_cast<unsigned int>(m_buttons));
|
||||
if (Q_UNLIKELY(lcQpaXInputEvents().isDebugEnabled()))
|
||||
qCDebug(lcQpaXInputEvents, "legacy mouse move %d,%d button %d state %X", ev->event_x, ev->event_y,
|
||||
ev->detail, static_cast<unsigned int>(m_buttons));
|
||||
HANDLE_PLATFORM_WINDOW_EVENT(xcb_motion_notify_event_t, event, handleMotionNotifyEvent);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -79,6 +79,7 @@ QT_BEGIN_NAMESPACE
|
|||
|
||||
Q_DECLARE_LOGGING_CATEGORY(lcQpaXInput)
|
||||
Q_DECLARE_LOGGING_CATEGORY(lcQpaXInputDevices)
|
||||
Q_DECLARE_LOGGING_CATEGORY(lcQpaXInputEvents)
|
||||
Q_DECLARE_LOGGING_CATEGORY(lcQpaScreen)
|
||||
|
||||
class QXcbVirtualDesktop;
|
||||
|
|
|
|||
|
|
@ -555,8 +555,8 @@ void QXcbConnection::xi2HandleEvent(xcb_ge_event_t *event)
|
|||
case XI_TouchBegin:
|
||||
case XI_TouchUpdate:
|
||||
case XI_TouchEnd:
|
||||
if (Q_UNLIKELY(lcQpaXInput().isDebugEnabled()))
|
||||
qCDebug(lcQpaXInput, "XI2 touch event type %d seq %d detail %d pos %6.1f, %6.1f root pos %6.1f, %6.1f on window %x",
|
||||
if (Q_UNLIKELY(lcQpaXInputEvents().isDebugEnabled()))
|
||||
qCDebug(lcQpaXInputEvents, "XI2 touch event type %d seq %d detail %d pos %6.1f, %6.1f root pos %6.1f, %6.1f on window %x",
|
||||
event->event_type, xiDeviceEvent->sequenceNumber, xiDeviceEvent->detail,
|
||||
fixed1616ToReal(xiDeviceEvent->event_x), fixed1616ToReal(xiDeviceEvent->event_y),
|
||||
fixed1616ToReal(xiDeviceEvent->root_x), fixed1616ToReal(xiDeviceEvent->root_y),xiDeviceEvent->event);
|
||||
|
|
@ -613,8 +613,8 @@ void QXcbConnection::xi2ProcessTouch(void *xiDevEvent, QXcbWindow *platformWindo
|
|||
double value;
|
||||
if (!xi2GetValuatorValueIfSet(xiDeviceEvent, n, &value))
|
||||
continue;
|
||||
if (Q_UNLIKELY(lcQpaXInput().isDebugEnabled()))
|
||||
qCDebug(lcQpaXInput, " valuator %20s value %lf from range %lf -> %lf",
|
||||
if (Q_UNLIKELY(lcQpaXInputEvents().isDebugEnabled()))
|
||||
qCDebug(lcQpaXInputEvents, " valuator %20s value %lf from range %lf -> %lf",
|
||||
atomName(vci->label).constData(), value, vci->min, vci->max );
|
||||
if (vci->label == atom(QXcbAtom::RelX)) {
|
||||
nx = valuatorNormalized(value, vci);
|
||||
|
|
@ -741,8 +741,8 @@ void QXcbConnection::xi2ProcessTouch(void *xiDevEvent, QXcbWindow *platformWindo
|
|||
touchPoint.area = QRectF(x - w/2, y - h/2, w, h);
|
||||
touchPoint.normalPosition = QPointF(nx, ny);
|
||||
|
||||
if (Q_UNLIKELY(lcQpaXInput().isDebugEnabled()))
|
||||
qCDebug(lcQpaXInput) << " touchpoint " << touchPoint.id << " state " << touchPoint.state << " pos norm " << touchPoint.normalPosition <<
|
||||
if (Q_UNLIKELY(lcQpaXInputEvents().isDebugEnabled()))
|
||||
qCDebug(lcQpaXInputEvents) << " touchpoint " << touchPoint.id << " state " << touchPoint.state << " pos norm " << touchPoint.normalPosition <<
|
||||
" area " << touchPoint.area << " pressure " << touchPoint.pressure;
|
||||
QWindowSystemInterface::handleTouchEvent(platformWindow->window(), xiDeviceEvent->time, dev->qtTouchDevice, dev->touchPoints.values());
|
||||
if (touchPoint.state == Qt::TouchPointReleased)
|
||||
|
|
@ -874,8 +874,8 @@ void QXcbConnection::updateScrollingDevice(ScrollingDevice &scrollingDevice, int
|
|||
scrollingDevice.lastScrollPosition.setY(vci->value);
|
||||
}
|
||||
}
|
||||
if (lcQpaXInput().isDebugEnabled() && lastScrollPosition != scrollingDevice.lastScrollPosition)
|
||||
qCDebug(lcQpaXInput, "scrolling device %d moved from (%f, %f) to (%f, %f)", scrollingDevice.deviceId,
|
||||
if (Q_UNLIKELY(lcQpaXInputEvents().isDebugEnabled() && lastScrollPosition != scrollingDevice.lastScrollPosition))
|
||||
qCDebug(lcQpaXInputEvents, "scrolling device %d moved from (%f, %f) to (%f, %f)", scrollingDevice.deviceId,
|
||||
lastScrollPosition.x(), lastScrollPosition.y(),
|
||||
scrollingDevice.lastScrollPosition.x(),
|
||||
scrollingDevice.lastScrollPosition.y());
|
||||
|
|
@ -1108,9 +1108,10 @@ bool QXcbConnection::xi2HandleTabletEvent(void *event, TabletData *tabletData, Q
|
|||
}
|
||||
// TODO maybe have a hash of tabletData->deviceId to device data so we can
|
||||
// look up the tablet name here, and distinguish multiple tablets
|
||||
qCDebug(lcQpaXInput, "XI2 proximity change on tablet %d (USB %x): last tool: %x id %x current tool: %x id %x TabletDevice %d",
|
||||
tabletData->deviceId, ptr[_WACSER_USB_ID], ptr[_WACSER_LAST_TOOL_SERIAL], ptr[_WACSER_LAST_TOOL_ID],
|
||||
ptr[_WACSER_TOOL_SERIAL], ptr[_WACSER_TOOL_ID], tabletData->tool);
|
||||
if (Q_UNLIKELY(lcQpaXInputEvents().isDebugEnabled()))
|
||||
qCDebug(lcQpaXInputEvents, "XI2 proximity change on tablet %d (USB %x): last tool: %x id %x current tool: %x id %x TabletDevice %d",
|
||||
tabletData->deviceId, ptr[_WACSER_USB_ID], ptr[_WACSER_LAST_TOOL_SERIAL], ptr[_WACSER_LAST_TOOL_ID],
|
||||
ptr[_WACSER_TOOL_SERIAL], ptr[_WACSER_TOOL_ID], tabletData->tool);
|
||||
}
|
||||
XFree(data);
|
||||
}
|
||||
|
|
@ -1181,8 +1182,8 @@ void QXcbConnection::xi2ReportTabletEvent(TabletData &tabletData, void *event)
|
|||
}
|
||||
}
|
||||
|
||||
if (Q_UNLIKELY(lcQpaXInput().isDebugEnabled()))
|
||||
qCDebug(lcQpaXInput, "XI2 event on tablet %d with tool %d type %d seq %d detail %d time %d "
|
||||
if (Q_UNLIKELY(lcQpaXInputEvents().isDebugEnabled()))
|
||||
qCDebug(lcQpaXInputEvents, "XI2 event on tablet %d with tool %d type %d seq %d detail %d time %d "
|
||||
"pos %6.1f, %6.1f root pos %6.1f, %6.1f buttons 0x%x pressure %4.2lf tilt %d, %d rotation %6.2lf",
|
||||
tabletData.deviceId, tabletData.tool, ev->evtype, ev->sequenceNumber, ev->detail, ev->time,
|
||||
fixed1616ToReal(ev->event_x), fixed1616ToReal(ev->event_y),
|
||||
|
|
|
|||
|
|
@ -2419,7 +2419,7 @@ void QXcbWindow::handleXIMouseEvent(xcb_ge_event_t *event, Qt::MouseEventSource
|
|||
}
|
||||
|
||||
const char *sourceName = 0;
|
||||
if (lcQpaXInput().isDebugEnabled()) {
|
||||
if (Q_UNLIKELY(lcQpaXInputEvents().isDebugEnabled())) {
|
||||
const QMetaObject *metaObject = qt_getEnumMetaObject(source);
|
||||
const QMetaEnum me = metaObject->enumerator(metaObject->indexOfEnumerator(qt_getEnumName(source)));
|
||||
sourceName = me.valueToKey(source);
|
||||
|
|
@ -2427,17 +2427,20 @@ void QXcbWindow::handleXIMouseEvent(xcb_ge_event_t *event, Qt::MouseEventSource
|
|||
|
||||
switch (ev->evtype) {
|
||||
case XI_ButtonPress:
|
||||
qCDebug(lcQpaXInput, "XI2 mouse press, button %d, time %d, source %s", button, ev->time, sourceName);
|
||||
if (Q_UNLIKELY(lcQpaXInputEvents().isDebugEnabled()))
|
||||
qCDebug(lcQpaXInputEvents, "XI2 mouse press, button %d, time %d, source %s", button, ev->time, sourceName);
|
||||
conn->setButton(button, true);
|
||||
handleButtonPressEvent(event_x, event_y, root_x, root_y, ev->detail, modifiers, ev->time, source);
|
||||
break;
|
||||
case XI_ButtonRelease:
|
||||
qCDebug(lcQpaXInput, "XI2 mouse release, button %d, time %d, source %s", button, ev->time, sourceName);
|
||||
if (Q_UNLIKELY(lcQpaXInputEvents().isDebugEnabled()))
|
||||
qCDebug(lcQpaXInputEvents, "XI2 mouse release, button %d, time %d, source %s", button, ev->time, sourceName);
|
||||
conn->setButton(button, false);
|
||||
handleButtonReleaseEvent(event_x, event_y, root_x, root_y, ev->detail, modifiers, ev->time, source);
|
||||
break;
|
||||
case XI_Motion:
|
||||
qCDebug(lcQpaXInput, "XI2 mouse motion %d,%d, time %d, source %s", event_x, event_y, ev->time, sourceName);
|
||||
if (Q_UNLIKELY(lcQpaXInputEvents().isDebugEnabled()))
|
||||
qCDebug(lcQpaXInputEvents, "XI2 mouse motion %d,%d, time %d, source %s", event_x, event_y, ev->time, sourceName);
|
||||
handleMotionNotifyEvent(event_x, event_y, root_x, root_y, modifiers, ev->time, source);
|
||||
break;
|
||||
default:
|
||||
|
|
|
|||
Loading…
Reference in New Issue