summaryrefslogtreecommitdiffstats
path: root/src/plugins/platforms/xcb/qxcbconnection_xi2.cpp
Commit message (Collapse)AuthorAgeFilesLines
* xcb: try to repopulate xinput2 devices when neededLiang Qi2024-03-221-1/+10
| | | | | | | | | | And try to not call Q_ASSERT() to avoid crash. Fixes: QTBUG-123554 Pick-to: 6.7 6.6 6.5 Change-Id: I9443c5f0ab4ca7a858df9b328f517b48ab8f122d Reviewed-by: Axel Spoerl <axel.spoerl@qt.io> Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
* xcb: replace a warning with debug info in qxcbconnection_xi2.cppLiang Qi2023-10-071-1/+1
| | | | | | | Fixes: QTBUG-117820 Pick-to: 6.6 6.5 Change-Id: I3b89305e1a8d92a02166efee7067108572f7a97a Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* Show decimal device IDs in QInputDevice qDebug outputShawn Rutledge2023-06-201-1/+1
| | | | | | | | | | | | The lack of 0x adornment made hex confusing. `xinput list` shows device IDs as decimal, and device IDs appear in decimal in some categorized qt.qpa.input.devices log messages, so let's be consistent here too. Also fixed one more that was inconsistent in that category: "scroll event from unregistered device <x>" Change-Id: I98a39b30b1bc030611d3cfe9dd5e95886faf48ff Pick-to: 6.5 6.6 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* xcb: Use QWSI::handleTabletEnterLeaveProximityEvent(.. QPointingDev* ..)Shawn Rutledge2023-06-201-6/+4
| | | | | | | | | | | | | | | | | | | We want to pass the QPointingDevice* because we've already identified it by its "system ID" (xinput device number). The other versions of handleTabletEnterProximityEvent and handleTabletLeaveProximityEvent try to identify the stylus by only its deviceType, pointerType and unique ID, which can go wrong if there are multiple tablet devices and the unique ID is not provided (as with N-trig and Wacom tablets being used at the same time). Anyway this fixes a TODO comment from 6589f2ed0cf78c9b8a5bdffcdc458dc40a974c60 Leave a "deprecated" comment by the QWSI functions that should not be used. Pick-to: 6.6 6.5 Task-number: QTBUG-104878 Change-Id: Id9f19c60b54b7900b02d5f87b5d12f9a9189721d Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* xcb: Don't clear touch or tablet devices due to device hierarchy eventShawn Rutledge2023-06-201-11/+15
| | | | | | | | | | | | | | | | | | | | | | | When QXcbConnection::xi2SetupDevices() reacts to a device hierarchy event and re-discovers an already-known slave device, it doesn't call xi2SetupSlavePointerDevice() again. I.e. it won't attempt to add it to m_touchDevices or m_tabletData because it was already known. So it should not clear m_touchDevices or m_tabletData either, but only remove the touch devices that are known to have disappeared. Tablet styli normally come and go from proximity, so it's ok to avoid deleting the corresponding device data. Also fix some other failure cases after testing hotplugging more with tests/manual/inputdevices: there should be no crashes, no duplicated devices after plugging (although the QAIM might have a bug that makes it look that way), no leftover instances after unplugging. Amends 2a9d93efc68324ce5e41831ea46a3945f1c4531d Pick-to: 6.6 6.5 6.5.2 Fixes: QTBUG-114334 Change-Id: I30f5e532f7dd3a465d56ecdd34d893cbadbf0453 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* xcb: Delete QInputDevice instances that X11 no longer findsShawn Rutledge2023-03-211-22/+60
| | | | | | | | | | | | | | | | | | | | | | | | QXcbConnection::xi2HandleHierarchyEvent() calls xi2SetupDevices() whenever the event tells us that a device was added or removed; but until now, those instances were not getting deleted until application exit. That was a memory leak, and also tended to get us confused when a newly-attached device happened to reuse the same device ID of something that was there before but had been removed in the meantime. Now, we hope that QInputDevice::devices() will be in sync with reality as X11 presents it to us. Amends da5dea807f497bc6004f40e966e5d882a2ba72b0 6589f2ed0cf78c9b8a5bdffcdc458dc40a974c60 etc. Task-number: QTBUG-46412 Fixes: QTBUG-56214 Fixes: QTBUG-98720 Fixes: QTBUG-99331 Task-number: QTBUG-104878 Fixes: QTBUG-112141 Pick-to: 6.2 6.5 6.5.0 Change-Id: I573805a41a12850f94561a030071f1437c4dc37e Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
* Fix build with -no-feature-gesturesTasuku Suzuki2023-02-111-0/+2
| | | | | | | | Disable xcb touchpad gesture when gestures is not available Pick-to: 6.5 Change-Id: Idd2fec38646fad4cbda20ab1e560949c8e8844ff Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* XCB: do not use reserved identifiersGiuseppe D'Angelo2023-02-071-41/+41
| | | | | | | | | | | Any identifier starting with underscore followed by a capital letter is reserved for the implementation in C++, so don't use them. Rename the entries in the Atom enumeration by adding an "Atom" prefix to them. Pick-to: 6.2 6.4 6.5 Change-Id: I059e2093149f39cc9324cd1159c0d9e076eda93a Reviewed-by: JiDe Zhang <zhangjide@uniontech.com> Reviewed-by: Liang Qi <liang.qi@qt.io>
* Port from qAsConst() to std::as_const()Marc Mutz2022-10-111-3/+3
| | | | | | | | | | | | | | | | We've been requiring C++17 since Qt 6.0, and our qAsConst use finally starts to bother us (QTBUG-99313), so time to port away from it now. Since qAsConst has exactly the same semantics as std::as_const (down to rvalue treatment, constexpr'ness and noexcept'ness), there's really nothing more to it than a global search-and-replace, with manual unstaging of the actual definition and documentation in dist/, src/corelib/doc/ and src/corelib/global/. Task-number: QTBUG-99313 Change-Id: I4c7114444a325ad4e62d0fcbfd347d2bbfb21541 Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
* Port from container.count()/length() to size()Marc Mutz2022-10-041-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is semantic patch using ClangTidyTransformator: auto QtContainerClass = expr(hasType(namedDecl(hasAnyName(<classes>)))).bind(o) makeRule(cxxMemberCallExpr(on(QtContainerClass), callee(cxxMethodDecl(hasAnyName({"count", "length"), parameterCountIs(0))))), changeTo(cat(access(o, cat("size"), "()"))), cat("use 'size()' instead of 'count()/length()'")) a.k.a qt-port-to-std-compatible-api with config Scope: 'Container'. <classes> are: // sequential: "QByteArray", "QList", "QQueue", "QStack", "QString", "QVarLengthArray", "QVector", // associative: "QHash", "QMultiHash", "QMap", "QMultiMap", "QSet", // Qt has no QMultiSet Change-Id: Ibe8837be96e8d30d1846881ecd65180c1bc459af Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Fix Wacom proximity on xcb againShawn Rutledge2022-07-201-6/+5
| | | | | | | | | | | | | | Amends 8e506fdd299d2fa18172209bea316f484e234e19 Also remove the lcQpaXInputEvents().isDebugEnabled() check to ensure that the qCDebug output is emitted. It was meant as an optimization, but skipping of printf-style qCDebugs when the logging category is disabled is efficient enough. Pick-to: 6.3 6.4 Fixes: QTBUG-104875 Change-Id: Id8dc710a8fdb596ddce70380a577205fc52df4cc Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* QXcbConnection::xi2ReportTabletEvent(): get device, check capabilitiesShawn Rutledge2022-07-131-4/+7
| | | | | | | | | | | | | | In Qt 5, RotationStylus was a device type; in Qt 6, we have the Rotation capability flag instead. The event does not tell us whether rotation is valid or not, so to distinguish a valid zero value from a zero that means it's absent, we need to check device capabilities. Anyway it's better to get the QPointingDevice instance earlier and call the newer version of QWindowSystemInterface::handleTabletEvent(). Fixes: QTBUG-104877 Change-Id: I896c02727d586381489f79fd4ebea3451adfa403 Pick-to: 6.2 6.3 6.4 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* xcb: Delete touch points without target windowsTang Haixiang2022-05-201-1/+5
| | | | | | | | | | | | | | | | | | | | | | | | When XCB_INPUT_TOUCH_BEGIN closes a popup, we then receive XCB_INPUT_TOUCH_END, and cannot find a target window (because it's destroyed). If we don't deliver it, we need to at least clear the stored point from QPointingDevicePrivate::activePoints. Then when we deliver the next touch press, m_fakeMouseSourcePointId also needs to be reset. It's now even more paramount that autotests (and real-world touchscreens) must never omit any active touchpoint from a touch event. If a point doesn't move, it must be included in the QTouchEvent, with Stationary state. If not, QGuiApp::processTouchEvent() could generate multiple TouchBegin events in a row, which gets other bits of logic confused, here and there. Fixes: QTBUG-94557 Fixes: QTBUG-98519 Fixes: QTBUG-102751 Fixes: QTBUG-103706 Pick-to: 6.2 6.3 5.15 Change-Id: Ia95e410a2bb8bc7784aa5d296fac2b89e53a9f55 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* Use SPDX license identifiersLucie Gérard2022-05-161-38/+2
| | | | | | | | | | | | | Replace the current license disclaimer in files by a SPDX-License-Identifier. Files that have to be modified by hand are modified. License files are organized under LICENSES directory. Task-number: QTBUG-67283 Change-Id: Id880c92784c40f3bbde861c0d93f58151c18b9f1 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Lars Knoll <lars.knoll@qt.io> Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
* XCB: fix leaked QXcbScrollingDevicePrivateLiang Qi2022-05-131-2/+10
| | | | | | | | | | | | | | | | | | | | | | | | | ==1585319== 1,112 (720 direct, 392 indirect) bytes in 2 blocks are definitely lost in loss record 110 of 123 ==1585319== at 0x483EF2F: operator new(unsigned long) (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so) ==1585319== by 0x7D01D6C: QXcbConnection::xi2SetupSlavePointerDevice(void*, bool, QPointingDevice*)::{lambda()#1}::operator()() const (qxcbconnection_xi2.cpp:262) ==1585319== by 0x7D025C2: QXcbConnection::xi2SetupSlavePointerDevice(void*, bool, QPointingDevice*) (qxcbconnection_xi2.cpp:316) ==1585319== by 0x7D03D2D: QXcbConnection::xi2SetupDevices() (qxcbconnection_xi2.cpp:499) ==1585319== by 0x7CE81A3: QXcbConnection::QXcbConnection(QXcbNativeInterface*, bool, unsigned int, char const*) (qxcbconnection.cpp:105) ==1585319== by 0x7D27BEA: QXcbIntegration::QXcbIntegration(QList<QString> const&, int&, char**) (qxcbintegration.cpp:199) ==1585319== by 0x7C9D282: QXcbIntegrationPlugin::create(QString const&, QList<QString> const&, int&, char**) (qxcbmain.cpp:56) ==1585319== by 0x4B516DE: QPlatformIntegration* qLoadPlugin<QPlatformIntegration, QPlatformIntegrationPlugin, QList<QString> const&, int&, char**&>(QFactoryLoader const*, QString const&, QList<QString> const&, int&, char**&) (qfactoryloader_p.h:108) ==1585319== by 0x4B512A9: QPlatformIntegrationFactory::create(QString const&, QList<QString> const&, int&, char**, QString const&) (qplatformintegrationfactory.cpp:71) ==1585319== by 0x4B074EC: init_platform(QString const&, QString const&, QString const&, int&, char**) (qguiapplication.cpp:1209) ==1585319== by 0x4B0A646: QGuiApplicationPrivate::createPlatformIntegration() (qguiapplication.cpp:1491) ==1585319== by 0x4B0A7C9: QGuiApplicationPrivate::createEventDispatcher() (qguiapplication.cpp:1508) ==1585319== by 0x568853F: QCoreApplicationPrivate::init() (qcoreapplication.cpp:847) ==1585319== by 0x4B0A89F: QGuiApplicationPrivate::init() (qguiapplication.cpp:1532) ==1585319== by 0x4B05D16: QGuiApplication::QGuiApplication(int&, char**, int) (qguiapplication.cpp:653) ==1585319== by 0x451613: main (tst_qmetatype.cpp:2141) Fixes: QTBUG-95468 Pick-to: 6.3 6.2 Change-Id: I7e0b82c2d2fe464082d8fffd1696c0122c3b35b7 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* Plugins: use _L1 for for creating Latin-1 string literalsSona Kurazyan2022-05-041-9/+11
| | | | | | | | | As a drive-by, fix qsizetype -> int narrowing conversion warnings for the touched lines. Task-number: QTBUG-98434 Change-Id: I7fadd3cf27ad099028d70f05956303e3af62c0f5 Reviewed-by: Marc Mutz <marc.mutz@qt.io>
* xcb: Show valuator atom names properly in categorized loggingShawn Rutledge2022-02-091-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | During a touch update, this looked questionable since I don't have any barcode readers or buttonboxes attached: XI2 touch event type 19 seq 1481 detail 193 pos 116.3, 77.8 root pos 6476.3, 2941.8 on window 3e00006 valuator BARCODE value 47796.365791 from range 0.000000 -> 65535.000000 valuator BUTTONBOX value 59504.858830 from range 0.000000 -> 65535.000000 touchpoint 193 state QEventPoint::Updated pos norm QPointF(0.729326,0.907986) area QRectF(... After the fix it's like this: XI2 touch event type 19 seq 1235 detail 201 pos 154.0, 64.3 root pos 6168.0, 2794.3 on window 5000006 valuator Abs MT Position X value 45520.589958 from range 0.000000 -> 65535.000000 valuator Abs MT Position Y value 56519.790001 from range 0.000000 -> 65535.000000 touchpoint 201 state QEventPoint::Updated pos norm QPointF(0.6946,0.862437) area QRectF(... ValuatorClassInfo's QXcbAtom::Atom is a Qt enum, which has to be converted to xcb_atom_t before we can call xcb_get_atom_name_name. Originally in ce2fe90faad84a6e3a976a6f111a0fa4883937d9 vci was of type XIValuatorClassInfo; then 7499d4404f9eb7223674cd0523f35eff1be7c1c9 changed it to our ValuatorClassInfo struct, but didn't add the lookup indirection to this qCDebug. Pick-to: 5.15 6.2 6.3 Change-Id: Ib6107f17d6c6c209573e3df54149d6cfffc0b8b6 Reviewed-by: Liang Qi <liang.qi@qt.io>
* xcb: Implement support for touchpad gesturesPovilas Kanapickas2021-11-151-3/+213
| | | | | | | | | | | | | | | | | | | | They map to the data exposed by libinput exactly the same way as touchpad gestures on Wayland. The implementation is functionally the same and follows the same patterns to preserve similar behavior across X11 and Wayland. For example, we use the last known pointer position as the position for gestures, even though on X11 this data is available as part of events. The new implementation is only enabled if the used xcb supports the required APIs. [ChangeLog][Platform Specific Changes][X11] Touchpads can now detect multi-finger gestures and send RotateNativeGesture, ZoomNativeGesture and PanNativeGesture events, since XInput 2.4 and X Server 21.1. Change-Id: If404dcf8385210deadeb7e7c6d29171e9abc9e50 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* xcb: Use byte buffer for event masksPovilas Kanapickas2021-10-161-23/+30
| | | | | | | | | | This prepares for use of masks larger than 32 bits which happens on XI 2.4. Additionally, since the XI protocol always sends the masks using little-endian, the XI protocol support on big-endian machines was currently broken. Change-Id: Id22131e075059cea783b5be0691a673a457c7364 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* xcb: update connection time when possibleLiang Qi2021-09-061-0/+1
| | | | | | | | | At least we try to do it with all events triggered by user. Pick-to: 5.15 6.1 6.2 Change-Id: I28b399a2517600f7da2c91a50fecdf58b9d81fb6 Reviewed-by: JiDe Zhang <zhangjide@uniontech.com> Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* xcb: fix QWindow::startSystemMove()/Resize() triggered by touchLiang Qi2021-06-161-0/+5
| | | | | | | | | | Abort the system move/resise at XCB_INPUT_TOUCH_END. Limit the behavior only on supported platforms, such as KDE and OpenBox. Change-Id: I53c86979ca56f4de8c5cf2807f781abdad6987b2 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* xcb: fix QWindow::startSystemMove()/Resize() triggered by mouseLiang Qi2021-06-161-2/+45
| | | | | | | | | | | | | | | | We can't get mouse release event from master pointers after QXcbWindow::doStartSystemMoveResize() which calls xcb_ungrab_pointer(), it looks like most X11 WMs work as that. So we try to get mouse release event from slave pointers. Based on https://specifications.freedesktop.org/wm-spec/1.4/ar01s04.html , we need to send _NET_WM_MOVERESIZE_CANCEL when we get mouse release event. Task-number: QTBUG-91077 Change-Id: I01e74a01c87b381ee7cd6f20d51a1fa61c0e98fc Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* xcb: Fix touch grab handling on pre-XI 2.2Povilas Kanapickas2021-06-011-4/+6
| | | | | | | | This is only a theoretical bug fix because systems that don't support XI 2.2 are ten years old by now. Change-Id: Ia3770a6ca626b60d0f1e4cd2fdc611adf99cbf25 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* xcb: use QXcbScrollingDevice for a touchpadShawn Rutledge2021-03-081-9/+24
| | | | | | | | | | | | | When using XQuartz on macOS, the virtual pointer device is detected as a touchpad, not a mouse; but QXcbConnection::xi2HandleScrollEvent() expects the device to be an instance of QXcbScrollingDevice for storage of some state. A touchpad that has the scrolling capability must be that type, not a plain QPointingDevice. Fixes: QTBUG-91402 Pick-to: 6.1 Change-Id: I1b82766d4a3f87f656e56c0d8904def26fb0979a Reviewed-by: Liang Qi <liang.qi@qt.io>
* Fix Wacom Art Pen detection on xcbShawn Rutledge2021-02-121-1/+2
| | | | | | Fixes: QTBUG-91102 Change-Id: I6cd7af26153457609c1fa8fb0a9e167939d592fc Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* Add qHypot() to qmath.h, exposing and extending std::hypot()Edward Welbourne2021-01-271-3/+3
| | | | | | | | | | | | | | | | | | | | We have plenty of places where we add some squares and take a square root; this may be done more accurately and faster by hypot(). Introduce QHypotHelper to handle hypot with more than 3 parameters, and with 3 when the C++17 version is missing (which it never should be). Include an overload taking arbitrarily many valus and ensure that we can use qHypot() with qfloat16. Illustrate with some example uses, add some tests. [ChangeLog][QtCore][QMath] Header <QMath> now provides qHypot(), an implementation of std::hypot() taking arbitrarily many numeric values, including support for qfloat16, while avoiding the overflow and underflow problems that arise when naively taking the square root of a sum of squares. Change-Id: Ia4e3913fe83fc27d17d8e7f1a52f03ad445c1fed Reviewed-by: Andrei Golubev <andrei.golubev@qt.io> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* Handle XCB_INPUT_DEVICE_TYPE_MASTER_POINTER properlyPaul Olav Tvete2020-12-251-4/+3
| | | | | | | | Make sure we use the new QXcbScrollingDevice class for the "core pointer" as well. Change-Id: I97575e8125cbb2aa280662aa675e61021c21ea59 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Fix out-of-bounds writePaul Olav Tvete2020-12-231-14/+16
| | | | | | | | | | | | | Change ac210c73e4 introduced the requirement that all input devices with Scroll capability must have a QXcbScrollingDevicePrivate as their d_ptr. However, this was not enforced, and would fail for the "Virtual core pointer". To fix this, always use qobject_cast to verify that the device is of the correct type. Change-Id: I4a6b1d4d79308eb04e9f52dda00294fffe377bdf Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* xcb: report wheel events from the correct device instanceShawn Rutledge2020-12-151-74/+97
| | | | | | | | | | | | | | | | | Until now, all wheel events came from one "core pointer". It's useful in Qt Quick to tell the devices apart, because some support smooth scrolling and some don't. Also remove the QHash storing legacy ScrollingDevice structs, and use a subclass of QPointingDevicePrivate instead. Task-number: QTBUG-46412 Task-number: QTBUG-72167 Task-number: QTBUG-69433 Change-Id: Ie6a3d8dd494f981e8706b9a66a1021dfb51baec4 Reviewed-by: Liang Qi <liang.qi@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Fix highdpi conversion of QTabletEvent coordinates on xcbShawn Rutledge2020-12-081-4/+2
| | | | | | | | | | | | | | | Amends 1535fc9fb9ddbfce1680979c0634b4fdf8d75fca : when high-dpi scaling is enabled, there was an offset from the cursor position to the event position, because QWindow::mapFromGlobal() works in device-independent pixels, but we are using actual screen pixels here. Pick-to: 6.0 Pick-to: 5.15 Pick-to: 5.12 Task-number: QTBUG-77826 Change-Id: Ic8743b9e5c4041065f530ed1d9d6c49337b0207a Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io> Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
* xcb: remove QT_XCB_NO_XI2_MOUSE code pathGatis Paeglis2020-08-231-122/+2
| | | | | | | | | | | | | | | This code path was deprecated in 5.12 and scheduled for removal in Qt 6. See 9184384bc9d9d71a146fff535021357258a0295e. According to the source comments from f48170b479df359f47af12b03a501d9d0c386e66, apperantly XInput2 had some issues when running on Xinerama screens and therefore there was a check for it in xi2MouseEventsDisabled(). We plan to remove Xinerama support, therefore Xinerama handling in xi2MouseEventsDisabled() is irrelevant. Task-number: QTBUG-69412 Change-Id: I384d7c46337358caecccf644acc8ffbd381dc69d Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* Refactor pointer event hierarchyShawn Rutledge2020-07-101-8/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Some goals that have hopefully been achieved are: - make QPointerEvent and QEventPoint resemble their Qt Quick counterparts to such an extent that we can remove those wrappers and go back to delivering the original events in Qt Quick - make QEventPoint much smaller than QTouchEvent::TouchPoint, with no pimpl - remove most public setters - reduce the usage of complex constructors that take many arguments - don't repeat ourselves: move accessors and storage upwards rather than having redundant ones in subclasses - standardize the set of accessors in QPointerEvent - maintain source compatibility as much as possible: do not require modifying event-handling code in any QWidget subclass To avoid public setters we now introduce a few QMutable* subclasses. This is a bit like the Builder pattern except that it doesn't involve constructing a separate disposable object: the main event type can be cast to the mutable type at any time to enable modifications, iff the code is linked with gui-private. Therefore event classes can have less-"complete" constructors, because internal Qt code can use setters the same way it could use the ones in QTouchEvent before; and the event classes don't need many friends. Even some read-accessors can be kept private unless we are sure we want to expose them. Task-number: QTBUG-46266 Fixes: QTBUG-72173 Change-Id: I740e4e40165b7bc41223d38b200bbc2b403e07b6 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Separate QPD::tabletDevice into priv tabletDevice and queryTabletDeviceShawn Rutledge2020-07-071-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | There doesn't seem to be any reason users will need to query tablet devices by their IDs, because every event comes with a complete instance already, and we have QInputDevice::devices() to list them all. QPointingDevicePrivate::tabletDevice() can create a new instance if a matching one is not found (and complains about that); it's intended for use in QtGui, as a way to find the device if it was not part of the QWSI event. Now it sets the parent of those auto-created instances to QCoreApplication to avoid a memory leak. On the other hand, queryTabletDevice() is intended for use in platform plugins that need to check whether an instance exists; but they will take care of creating new instances themselves, and thus have more control over the parent and the details being stored. Now that the systemId can also be given, the search is more likely to have a unique result, on window systems that provide device IDs. Rename id() to systemId() to clarify that it's a system-specific unique device ID of some sort, not the same as the uniqueId that a stylus has. However it seems that in practice, this will often be 0; so clarify that if it's not unique, QInputDevicePrivate::fromId() and queryTabletDevice() may not always find the right instance. Clarify the function usage via comments. Change-Id: I82bb8d1c26eeaf06f07c290828aa17ec4a31646b Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Use QList instead of QVector in pluginsJarek Kobus2020-07-061-2/+2
| | | | | | Task-number: QTBUG-84469 Change-Id: Ic86f4a3000592a1c9ae62e4a83f4fe39832a6b24 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
* xcb: fix seatId to be master-keyboard-id << 16 | master-pointer-idShawn Rutledge2020-06-181-1/+1
| | | | | | | | | | | | Amends 6589f2ed0cf78c9b8a5bdffcdc458dc40a974c60 to match the comment. If the master device we found is a keyboard, then its own ID is the keyboard ID, and the attachment is a pointer; but if the master device we found is a pointer, then its attachment is the master keyboard. In practice, this gives all devices the same seatId on normal single-user sessions. Change-Id: Ibe7d7cdee7b3fe642efacd0349c109271059cb36 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* Introduce QInputDevice hierarchy; replace QTouchDeviceShawn Rutledge2020-06-161-125/+279
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We have seen during the Qt 5 series that QMouseEvent::source() does not provide enough information: if it is synthesized, it could have come from any device for which mouse events are synthesized, not only from a touchscreen. By providing in every QInputEvent as complete information about the actual source device as possible, we will enable very fine-tuned behavior in the object that handles each event. Further, we would like to support multiple keyboards, pointing devices, and named groups of devices that are known as "seats" in Wayland. In Qt 5, QPA plugins registered each touchscreen as it was discovered. Now we extend this pattern to all input devices. This new requirement can be implemented gradually; for now, if a QTWSI input event is received wtihout a device pointer, a default "core" device will be created on-the-fly, and a warning emitted. In Qt 5, QTouchEvent::TouchPoint::id() was forced to be unique even when multiple devices were in use simultaneously. Now that each event identifies the device it came from, this hack is no longer needed. A stub of the new QPointerEvent is added; it will be developed further in subsequent patches. [ChangeLog][QtGui][QInputEvent] Every QInputEvent now carries a pointer to an instance of QInputDevice, or the subclass QPointingDevice in case of mouse, touch and tablet events. Each platform plugin is expected to create the device instances, register them, and provide valid pointers with all input events. If this is not done, warnings are emitted and default devices are created as necessary. When the device has accurate information, it provides the opportunity to fine-tune behavior depending on device type and capabilities: for example if a QMouseEvent is synthesized from a touchscreen, the recipient can see which touchscreen it came from. Each device also has a seatName to distinguish users on multi-user windowing systems. Touchpoint IDs are no longer unique on their own, but the combination of ID and device is. Fixes: QTBUG-46412 Fixes: QTBUG-72167 Task-number: QTBUG-69433 Task-number: QTBUG-52430 Change-Id: I933fb2b86182efa722037b7a33e404c5daf5292a Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* Make xcb plugin compile with -no-feature-tableteventShawn Rutledge2020-02-201-2/+0
| | | | | | | | | fixed1616ToReal() is used for touch and scroll events too, not just tablet. Task-number: QTBUG-82168 Change-Id: Idcdd6365b5619824b41c1278e5dc5ffb81c400f8 Reviewed-by: Andy Shaw <andy.shaw@qt.io>
* Add QWindow::startSystemMove and startSystemResizeJohan Klokkhammer Helsing2020-01-281-6/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This can be used to create custom client side window decorations. Refactors the xcb implementation to use edges instead of corners and we now use the last mouse position for `root_x` and `root_y` in the `_NET_WM_MOVERESIZE` event. Touch has also been changed, so just pick a point that's currently being pressed. The workaround for QTBUG-69716 has now been moved to QSizeGrip, as the comment in the bug report says that it should ideally be fixed at the widget level. On Windows, we no longer abort when GetSystemMenu returns false. I assume this code was added to check whether the window didn't have any decorations and not resize in that case. However, since the point of this patch is to let windows without native decorations resize/move, it makes most sense to remove the check. Adds a manual test, which calls QWindow::startSystemMove and startSystemResize on touch and mouse events. [ChangeLog][QtGui] Added API for starting interactive window resize and move operations handled by the system. Fixes: QTBUG-73011 Change-Id: I7e47a0b2cff182af71d3d479d6e3746f08ea30aa Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* Merge remote-tracking branch 'origin/5.14' into 5.15Qt Forward Merge Bot2020-01-071-2/+4
|\ | | | | | | Change-Id: I6c81e3cb6272adc5c3de2513792bd48604ff4dd0
| * tablets on xcb: report correct local coordinates to nested windowsShawn Rutledge2020-01-061-2/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Change e4532224145a0a72cde9b40cb7fd39011624d1c1 tried to map global position directly from the desktop to the window that should receive the event. That's fine for single-window applications; but media players like OBS and VLC often use embedded windows to play video. So the mapping needs to traverse the window parent hierarchy somehow. In this patch it's done by calling QWindow::mapFromGlobal(), but that only works with integer coordinates (QPoint). To preserve the fix for QTBUG-48151 (and other jitter bugs), we need sub-pixel accuracy; so we have to add back the fractional part after mapping the int part. Fixes: QTBUG-77826 Change-Id: Ib52ce14138e477182e0ef53b0ff30ce1eff40372 Reviewed-by: Gatis Paeglis <gatis.paeglis@qt.io>
* | Tidy nullptr usageAllan Sandfeld Jensen2019-12-061-2/+2
| | | | | | | | | | | | | | | | | | | | | | Move away from using 0 as pointer literal. Done using clang-tidy. This is not complete as run-clang-tidy can't handle all of qtbase in one go. Change-Id: I1076a21f32aac0dab078af6f175f7508145eece0 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io> Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* | Deprecate constructing QFlags from a pointerAllan Sandfeld Jensen2019-11-201-1/+1
|/ | | | | | | | | This was used to support QFlags f = 0 initialization, but with 0 used as a pointer literal now considered bad form, it had been changed many places to QFlags f = nullptr, which is meaningless and confusing. Change-Id: I4bc592151c255dc5cab1a232615caecc520f02e8 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QPoint/F: add transposed()Marc Mutz2019-08-071-3/+3
| | | | | | | | | | | | For symmetry with QSize and QRect and because there were some users in Qt. Port those users. [ChangeLog][QtCore][QPoint/QPointF] Added transposed(). Change-Id: If4f23dbcf7d67983a6b1885e0d1d538115b49e2b Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Merge remote-tracking branch 'origin/5.12' into 5.13Qt Forward Merge Bot2019-05-091-0/+4
|\ | | | | | | | | | | | | | | | | | | | | Conflicts: src/corelib/tools/qlocale_data_p.h (Regenerated by running the scripts in util/local_database/) src/gui/opengl/qopengltextureuploader.cpp Done-With: Edward Welbourne <edward.welbourne@qt.io> Done-With: Allan Sandfeld Jensen <allan.jensen@qt.io> Change-Id: I12df7f066ed0a25eb109f61c4b8d8dea63b683e2
| * Add an ID for recognition of UGEE tabletsDmitry Kazakov2019-05-071-0/+4
| | | | | | | | | | | | Change-Id: I2228ee9d53aa23a2d2cd9970a363d8424e744093 Reviewed-by: Frederik Gladhorn <frederik.gladhorn@qt.io> Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* | Merge remote-tracking branch 'origin/5.12' into 5.13Qt Forward Merge Bot2019-04-021-0/+30
|\| | | | | | | Change-Id: Ia5d893e57deb78bc32e2053a5a79543ff847fe32
| * Fix tablet jitter on X11Dmitry Kazakov2019-04-011-0/+30
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We should get the correct stylus position from the valuators, not from the X11-provided global position. Global position is rounded to the nearest FP16 values, which is not enough for smooth painting. [ChangeLog][Platform Specific Changes][X11 / XCB] QTabletEvent coordinates now come from AbsX/AbsY valuators in the X11 event, in more precise 32.32 fixed-point format, scaled to fit the virtual desktop. It's possible to revert to using the legacy 16.16-format event_x/event_y coordinates as in previous releases by setting the QT_XCB_TABLET_LEGACY_COORDINATES environment variable. Task-number: QTBUG-45375 Fixes: QTBUG-48151 Change-Id: Ie701446b3586296bcb8fb09158f387ba6a7cbf07 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* | Add a few qAsConst() to range-for to prevent detachmentsSergio Martins2018-12-101-3/+3
|/ | | | | | | | | | | places indicated by clazy As a drive-by, fixed minor styling issues in the affected lines. Change-Id: I88d3fc0c8573cde0e61f19a18dd9ea697ee40c34 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Luca Beldi <v.ronin@yahoo.it> Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
* xcb: qxcbconnection_basicGatis Paeglis2018-10-171-43/+18
| | | | | | | | | | | | A basic base class that creates a connection and initializes extensions. The goal was to reduce the size of qxcbconnection.h/cpp. Made QXcbAtom into a class that handles atom initialization and exposes the relevant APIs. Before this patch, all of that logic was inside of qxcbconnection.h/cpp. Change-Id: Ia893c3b31e2343dfbe62fe2aa6bfd0017abf46ea Reviewed-by: Gatis Paeglis <gatis.paeglis@qt.io>
* xcb: cleanup QXcbConnection::handleXcbEvent()Gatis Paeglis2018-08-161-2/+1
| | | | | | | | | | | | | | | - the usage of 'handled' variable was a mess. - remove "generic" from API names. The naming was probably influenced too much from underlying C API (xcb_generic_event_t): - handleGenericEvent() -> handleNativeEvent() to be consistent with QWindow::nativeEvent(). - dropped unnecessary 'long *result' from signature. It is useful only on MS Windows. - genericEventFilterType() -> nativeEventType(), it *is* an event type, not a filter type. - XCB_CLIENT_MESSAGE was not passed to QWindow::nativeEvent(), which is done via HANDLE_PLATFORM_WINDOW_EVENT. - minor: added some 'auto's where it makes sense and improved some variable names. Change-Id: Id1c9896054e2dbd9a79bacd88394149c8cf2cdea Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>