qpa: Export lcQpaInputDevices (qt.qpa.input.devices) for QPA plugin use

And use from macOS and xcb platform plugins.

Change-Id: I84a2d933551a59cf220ecb6841d8d756e58724a0
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
(cherry picked from commit 9d8744c77b03eb091061976dd084cb0ca3f6252b)
This commit is contained in:
Tor Arne Vestbø 2024-10-29 12:11:31 +01:00
parent c81e250f85
commit b41bded9b8
8 changed files with 26 additions and 30 deletions

View File

@ -28,7 +28,7 @@
QT_BEGIN_NAMESPACE
Q_DECLARE_LOGGING_CATEGORY(lcQpaInputDevices);
Q_DECLARE_EXPORTED_LOGGING_CATEGORY(lcQpaInputDevices, Q_GUI_EXPORT)
class QWindowSystemEventHandler;

View File

@ -40,7 +40,6 @@ Q_DECLARE_LOGGING_CATEGORY(lcQpaInputMethods)
Q_DECLARE_LOGGING_CATEGORY(lcQpaScreen)
Q_DECLARE_LOGGING_CATEGORY(lcQpaApplication)
Q_DECLARE_LOGGING_CATEGORY(lcQpaClipboard)
Q_DECLARE_LOGGING_CATEGORY(lcInputDevices)
Q_DECLARE_LOGGING_CATEGORY(lcQpaDialogs)
Q_DECLARE_LOGGING_CATEGORY(lcQpaMenus)
Q_DECLARE_LOGGING_CATEGORY(lcQpaServices)

View File

@ -27,7 +27,6 @@ Q_LOGGING_CATEGORY(lcQpaInputMethods, "qt.qpa.input.methods")
Q_LOGGING_CATEGORY(lcQpaScreen, "qt.qpa.screen", QtCriticalMsg);
Q_LOGGING_CATEGORY(lcQpaApplication, "qt.qpa.application");
Q_LOGGING_CATEGORY(lcQpaClipboard, "qt.qpa.clipboard")
Q_LOGGING_CATEGORY(lcInputDevices, "qt.qpa.input.devices")
Q_LOGGING_CATEGORY(lcQpaDialogs, "qt.qpa.dialogs")
Q_LOGGING_CATEGORY(lcQpaMenus, "qt.qpa.menus")
Q_LOGGING_CATEGORY(lcQpaServices, "qt.qpa.services")

View File

@ -22,7 +22,7 @@ static const QPointingDevice *pointingDeviceFor(qint64 deviceID)
if (primaryDevice->systemId() == kDefaultPrimaryPointingDeviceId) {
// Adopt existing primary device instead of creating a new one
QPointingDevicePrivate::get(const_cast<QPointingDevice *>(primaryDevice))->systemId = deviceID;
qCDebug(lcInputDevices) << "primaryPointingDevice is now" << primaryDevice;
qCDebug(lcQpaInputDevices) << "primaryPointingDevice is now" << primaryDevice;
return primaryDevice;
} else {
// Register a new device. Name and capabilities may need updating later.
@ -756,7 +756,7 @@ static const QPointingDevice *pointingDeviceFor(qint64 deviceID)
devicePriv->name = "trackpad or magic mouse"_L1;
devicePriv->deviceType = QInputDevice::DeviceType::TouchPad;
devicePriv->capabilities |= QInputDevice::Capability::PixelScroll;
qCDebug(lcInputDevices) << "mouse scrolling: updated capabilities" << device;
qCDebug(lcQpaInputDevices) << "mouse scrolling: updated capabilities" << device;
}
}

View File

@ -44,7 +44,6 @@ QT_BEGIN_NAMESPACE
using namespace Qt::StringLiterals;
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")
Q_LOGGING_CATEGORY(lcQpaEvents, "qt.qpa.events")

View File

@ -27,7 +27,6 @@
QT_BEGIN_NAMESPACE
Q_DECLARE_LOGGING_CATEGORY(lcQpaXInput)
Q_DECLARE_LOGGING_CATEGORY(lcQpaXInputDevices)
Q_DECLARE_LOGGING_CATEGORY(lcQpaXInputEvents)
Q_DECLARE_LOGGING_CATEGORY(lcQpaScreen)
Q_DECLARE_LOGGING_CATEGORY(lcQpaEvents)

View File

@ -242,7 +242,7 @@ void QXcbConnection::xi2SetupSlavePointerDevice(void *info, bool removeExisting,
xcb_input_xi_device_info_name_length(deviceInfo));
const QString name = QString::fromUtf8(nameRaw);
m_xiSlavePointerIds.append(deviceInfo->deviceid);
qCDebug(lcQpaXInputDevices) << "input device " << name << "ID" << deviceInfo->deviceid;
qCDebug(lcQpaInputDevices) << "input device " << name << "ID" << deviceInfo->deviceid;
#if QT_CONFIG(tabletevent)
TabletData tabletData;
#endif
@ -263,7 +263,7 @@ void QXcbConnection::xi2SetupSlavePointerDevice(void *info, bool removeExisting,
case XCB_INPUT_DEVICE_CLASS_TYPE_VALUATOR: {
auto *vci = reinterpret_cast<xcb_input_valuator_class_t *>(classinfo);
const int valuatorAtom = qatom(vci->label);
qCDebug(lcQpaXInputDevices) << " has valuator" << atomName(vci->label) << "recognized?" << (valuatorAtom < QXcbAtom::NAtoms);
qCDebug(lcQpaInputDevices) << " has valuator" << atomName(vci->label) << "recognized?" << (valuatorAtom < QXcbAtom::NAtoms);
#if QT_CONFIG(tabletevent)
if (valuatorAtom < QXcbAtom::NAtoms) {
TabletData::ValuatorClassInfo info;
@ -314,11 +314,11 @@ void QXcbConnection::xi2SetupSlavePointerDevice(void *info, bool removeExisting,
scrollingDevice()->legacyOrientations |= Qt::Horizontal;
}
buttonCount = bci->num_buttons;
qCDebug(lcQpaXInputDevices, " has %d buttons", bci->num_buttons);
qCDebug(lcQpaInputDevices, " has %d buttons", bci->num_buttons);
break;
}
case XCB_INPUT_DEVICE_CLASS_TYPE_KEY:
qCDebug(lcQpaXInputDevices) << " it's a keyboard";
qCDebug(lcQpaInputDevices) << " it's a keyboard";
break;
case XCB_INPUT_DEVICE_CLASS_TYPE_TOUCH:
#if QT_CONFIG(gestures) && QT_XCB_HAS_TOUCHPAD_GESTURES
@ -327,7 +327,7 @@ void QXcbConnection::xi2SetupSlavePointerDevice(void *info, bool removeExisting,
// will be handled in populateTouchDevices()
break;
default:
qCDebug(lcQpaXInputDevices) << " has class" << classinfo->type;
qCDebug(lcQpaInputDevices) << " has class" << classinfo->type;
break;
}
}
@ -385,7 +385,7 @@ void QXcbConnection::xi2SetupSlavePointerDevice(void *info, bool removeExisting,
tabletData.deviceId = deviceInfo->deviceid;
tabletData.name = name;
m_tabletData.append(tabletData);
qCDebug(lcQpaXInputDevices) << " it's a tablet with pointer type" << dbgType;
qCDebug(lcQpaInputDevices) << " it's a tablet with pointer type" << dbgType;
QPointingDevice::Capabilities capsOverride = QInputDevice::Capability::None;
if (tabletData.valuatorInfo.contains(QXcbAtom::AtomAbsTiltX))
capsOverride.setFlag(QInputDevice::Capability::XTilt);
@ -403,18 +403,18 @@ void QXcbConnection::xi2SetupSlavePointerDevice(void *info, bool removeExisting,
if (scrollingDeviceP) {
// Only use legacy wheel button events when we don't have real scroll valuators.
scrollingDeviceP->legacyOrientations &= ~scrollingDeviceP->orientations;
qCDebug(lcQpaXInputDevices) << " it's a scrolling device";
qCDebug(lcQpaInputDevices) << " it's a scrolling device";
}
if (!isTablet) {
TouchDeviceData *dev = populateTouchDevices(deviceInfo, scrollingDeviceP, &used);
if (dev && lcQpaXInputDevices().isDebugEnabled()) {
if (dev && lcQpaInputDevices().isDebugEnabled()) {
if (dev->qtTouchDevice->type() == QInputDevice::DeviceType::TouchScreen)
qCDebug(lcQpaXInputDevices, " it's a touchscreen with type %d capabilities 0x%X max touch points %d",
qCDebug(lcQpaInputDevices, " it's a touchscreen with type %d capabilities 0x%X max touch points %d",
int(dev->qtTouchDevice->type()), qint32(dev->qtTouchDevice->capabilities()),
dev->qtTouchDevice->maximumPoints());
else if (dev->qtTouchDevice->type() == QInputDevice::DeviceType::TouchPad)
qCDebug(lcQpaXInputDevices, " it's a touchpad with type %d capabilities 0x%X max touch points %d size %f x %f",
qCDebug(lcQpaInputDevices, " it's a touchpad with type %d capabilities 0x%X max touch points %d size %f x %f",
int(dev->qtTouchDevice->type()), qint32(dev->qtTouchDevice->capabilities()),
dev->qtTouchDevice->maximumPoints(),
dev->size.width(), dev->size.height());
@ -422,7 +422,7 @@ void QXcbConnection::xi2SetupSlavePointerDevice(void *info, bool removeExisting,
}
if (!QInputDevicePrivate::fromId(deviceInfo->deviceid)) {
qCDebug(lcQpaXInputDevices) << " it's a mouse";
qCDebug(lcQpaInputDevices) << " it's a mouse";
QInputDevice::Capabilities caps = QInputDevice::Capability::Position | QInputDevice::Capability::Hover;
if (scrollingDeviceP) {
scrollingDeviceP->capabilities |= caps;
@ -458,7 +458,7 @@ void QXcbConnection::xi2SetupDevices()
auto reply = Q_XCB_REPLY(xcb_input_xi_query_device, xcb_connection(), XCB_INPUT_DEVICE_ALL);
if (!reply) {
qCDebug(lcQpaXInputDevices) << "failed to query devices";
qCDebug(lcQpaInputDevices) << "failed to query devices";
return;
}
@ -535,7 +535,7 @@ void QXcbConnection::xi2SetupDevices()
}
// previousDevices is now the list of those that are no longer found
qCDebug(lcQpaXInputDevices) << "removed" << previousDevices;
qCDebug(lcQpaInputDevices) << "removed" << previousDevices;
for (auto it = previousDevices.constBegin(); it != previousDevices.constEnd(); ++it) {
const auto id = (*it)->systemId();
m_xiSlavePointerIds.removeAll(id);
@ -544,7 +544,7 @@ void QXcbConnection::xi2SetupDevices()
qDeleteAll(previousDevices);
if (m_xiMasterPointerIds.size() > 1)
qCDebug(lcQpaXInputDevices) << "multi-pointer X detected";
qCDebug(lcQpaInputDevices) << "multi-pointer X detected";
}
QXcbConnection::TouchDeviceData *QXcbConnection::touchDeviceForId(int id)
@ -571,7 +571,7 @@ QXcbConnection::TouchDeviceData *QXcbConnection::populateTouchDevices(void *info
case XCB_INPUT_DEVICE_CLASS_TYPE_TOUCH: {
auto *tci = reinterpret_cast<xcb_input_touch_class_t *>(classinfo);
maxTouchPoints = tci->num_touches;
qCDebug(lcQpaXInputDevices, " has touch class with mode %d", tci->mode);
qCDebug(lcQpaInputDevices, " has touch class with mode %d", tci->mode);
switch (tci->mode) {
case XCB_INPUT_TOUCH_MODE_DEPENDENT:
type = QInputDevice::DeviceType::TouchPad;
@ -589,7 +589,7 @@ QXcbConnection::TouchDeviceData *QXcbConnection::populateTouchDevices(void *info
// gesture device classes.
auto *gci = reinterpret_cast<xcb_input_gesture_class_t *>(classinfo);
maxTouchPoints = gci->num_touches;
qCDebug(lcQpaXInputDevices, " has gesture class");
qCDebug(lcQpaInputDevices, " has gesture class");
type = QInputDevice::DeviceType::TouchPad;
break;
}
@ -659,7 +659,7 @@ QXcbConnection::TouchDeviceData *QXcbConnection::populateTouchDevices(void *info
scrollingDeviceP->seatName = master->seatName();
dev.qtTouchDevice = new QXcbScrollingDevice(*scrollingDeviceP, master);
if (Q_UNLIKELY(!caps.testFlag(QInputDevice::Capability::Scroll)))
qCDebug(lcQpaXInputDevices) << "unexpectedly missing RelVert/HorizWheel atoms for touchpad with scroll capability" << dev.qtTouchDevice;
qCDebug(lcQpaInputDevices) << "unexpectedly missing RelVert/HorizWheel atoms for touchpad with scroll capability" << dev.qtTouchDevice;
*used = true;
} else {
dev.qtTouchDevice = new QPointingDevice(QString::fromUtf8(xcb_input_xi_device_info_name(deviceInfo),
@ -999,7 +999,7 @@ bool QXcbConnection::startSystemMoveResizeForTouch(xcb_window_t window, int edge
m_startSystemMoveResizeInfo.pointid = pointIt.key();
m_startSystemMoveResizeInfo.edges = edges;
setDuringSystemMoveResize(true);
qCDebug(lcQpaXInputDevices) << "triggered system move or resize from touch";
qCDebug(lcQpaInputDevices) << "triggered system move or resize from touch";
return true;
}
}
@ -1010,7 +1010,7 @@ bool QXcbConnection::startSystemMoveResizeForTouch(xcb_window_t window, int edge
void QXcbConnection::abortSystemMoveResize(xcb_window_t window)
{
qCDebug(lcQpaXInputDevices) << "sending client message NET_WM_MOVERESIZE_CANCEL to window: " << window;
qCDebug(lcQpaInputDevices) << "sending client message NET_WM_MOVERESIZE_CANCEL to window: " << window;
m_startSystemMoveResizeInfo.window = XCB_NONE;
const xcb_atom_t moveResize = connection()->atom(QXcbAtom::Atom_NET_WM_MOVERESIZE);
@ -1314,7 +1314,7 @@ void QXcbConnection::xi2UpdateScrollingDevice(QInputDevice *dev)
auto reply = Q_XCB_REPLY(xcb_input_xi_query_device, xcb_connection(), scrollingDevice->systemId);
if (!reply || reply->num_infos <= 0) {
qCDebug(lcQpaXInputDevices, "scrolling device %lld no longer present", scrollingDevice->systemId);
qCDebug(lcQpaInputDevices, "scrolling device %lld no longer present", scrollingDevice->systemId);
return;
}
QPointF lastScrollPosition;
@ -1563,7 +1563,7 @@ bool QXcbConnection::xi2HandleTabletEvent(const void *event, TabletData *tabletD
}
// 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(lcQpaXInputDevices, "XI2 proximity change on tablet %d %s (USB %x): last tool: %x id %x current tool: %x id %x %s",
qCDebug(lcQpaInputDevices, "XI2 proximity change on tablet %d %s (USB %x): last tool: %x id %x current tool: %x id %x %s",
tabletData->deviceId, qPrintable(tabletData->name), ptr[_WACSER_USB_ID],
ptr[_WACSER_LAST_TOOL_SERIAL], ptr[_WACSER_LAST_TOOL_ID],
ptr[_WACSER_TOOL_SERIAL], ptr[_WACSER_TOOL_ID], toolName(tabletData->tool));

View File

@ -2435,7 +2435,7 @@ bool QXcbWindow::startSystemMoveResize(const QPoint &pos, int edges)
if (startedByTouch) {
const QString wmname = connection()->windowManagerName();
if (wmname != "kwin"_L1 && wmname != "openbox"_L1) {
qCDebug(lcQpaXInputDevices) << "only KDE and OpenBox support startSystemMove/Resize which is triggered from touch events: XDG_CURRENT_DESKTOP="
qCDebug(lcQpaInputDevices) << "only KDE and OpenBox support startSystemMove/Resize which is triggered from touch events: XDG_CURRENT_DESKTOP="
<< qgetenv("XDG_CURRENT_DESKTOP");
connection()->abortSystemMoveResize(m_window);
return false;
@ -2473,7 +2473,7 @@ static uint qtEdgesToXcbMoveResizeDirection(Qt::Edges edges)
void QXcbWindow::doStartSystemMoveResize(const QPoint &globalPos, int edges)
{
qCDebug(lcQpaXInputDevices) << "triggered system move or resize via sending _NET_WM_MOVERESIZE client message";
qCDebug(lcQpaInputDevices) << "triggered system move or resize via sending _NET_WM_MOVERESIZE client message";
const xcb_atom_t moveResize = connection()->atom(QXcbAtom::Atom_NET_WM_MOVERESIZE);
xcb_client_message_event_t xev;
xev.response_type = XCB_CLIENT_MESSAGE;