summaryrefslogtreecommitdiffstats
path: root/src/gui/kernel/qwindowsysteminterface.cpp
Commit message (Collapse)AuthorAgeFilesLines
* highdpi: Update high-DPI in QWSI::handleScreenLogicalDotsPerInchChangeMorten Sørvig2024-01-081-0/+5
| | | | | | | | | | | | | | | Update m_active early during DPI change to make scaling calls made during the DPI change use the new value. The existing call to updateHighDpiScaling() in QGuiApplicationPrivate:: processScreenLogicalDotsPerInchChange() is supposed to take care of this, however that call is made after the geometry change event is crated (with incorrect geometry) Pick-to: 6.7 Change-Id: Ia0f6006c90355ec69ef92b88a020089ab21e072d Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* testlib: Add test function for simulating wheel eventsDoris Verria2023-12-201-0/+7
| | | | | Change-Id: I28fe4dff7db92fb58922948a3eec460df315318c Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* Rename QWSI::handleWindowActivated to QWSI::handleFocusWindowChangedTor Arne Vestbø2023-11-231-2/+2
| | | | | | | | | | | | | | | | | | | A single QWindow is QGuiApplication::focusWindow() at a time, and this window is typically also QWindow::isActive(), but other windows may also be QWindow::isActive(). For example, we treat any sibling or ancestor of the focusWindow as being QWindow::isActive() as well. In addition, in the case of non-QWindow child windows, we may have to query the platform for the activation state, which means we also need a way for the platform to reflect changes in this state through QWSI. The current API for this, QWSI::handleWindowActivated, is in practice a focus window change API, so as a first step let's rename it to better reflect what it's doing. Task-number: QTBUG-119287 Change-Id: I381baf8505dd13a4a829c961095a8d2ed120092b Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
* Misc.: Fix some narrowing integral conversion warningsAhmad Samir2023-04-251-3/+3
| | | | | | | Drive-by change: use QByteArrayView instead of allocating a QByteArray. Change-Id: Iaf7acbbdb4efbb101b73b30061ce38dd1fa99ca3 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QWSI: Remove handleFrameStrutMouseEvent in favor of handleMouseEvent+typeTor Arne Vestbø2023-03-311-49/+22
| | | | | | | | | | | | | | | The handleMouseEvent function already takes a QEvent::Type, where clients pass in the corresponding mouse press/release/move type. The same applies to the handleFrameStrutMouseEvent. To avoid the chance that clients call these functions with a conflicting event type (handleFrameStrutMouseEvent with MouseButtonPress instead of NonClientAreaMouseButtonPress e.g.), we remove handleFrameStrutMouseEvent altogether and just let clients use the handleMouseEvent function directly with the correct event type. Change-Id: I4a0241c39aedac0d2d8d5163ba05cde72605959c Reviewed-by: Lars Knoll <lars@knoll.priv.no>
* Align QWindowSystemInterface::handleScreenAdded() and handleScreenRemoved()Tor Arne Vestbø2023-03-281-5/+41
| | | | | | | | | | | Having the logic of handleScreenRemoved() inside the QScreen destructor was making it harder to follow the flow of adding and removing screens. As screen management should always go though the QWSI functions, we keep the logic there. Change-Id: I456e77eb8fc10feae7b1f9994b25c9534ea4e430 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Introduce events for Window device pixel ratio changesDavid Edmundson2023-02-131-0/+6
| | | | | | | | | | | | | | | | | | | | | | | | | There is a mix between screen device pixel ratio. Currently we store the property on a per-window basis, but the change notifications are still on a per screen basis which can fall apart on edge cases. On wayland we are getting per window DPR changes without as useful screen change events so it's important to fix. It also has potential to clean up the Windows backend in the future where the backend is currently papering over the two concepts. This patch introduces two new events: A QWindowSystemInterface to trigger a window DPR change independently of a screen change. An event to notify windows the new DPR rather than needing to track signals on the screen. This happens either when the window dpr changes or implicitly through a screen change. This can deprecate an existing event ScreenChangeInternal so the value is reused and renamed for clarity. Change-Id: I637a07fd4520ba3184ccc2c987c29d8d23a65ad3 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* QtGui: Remove double default definitionAmir Masoud Abdol2023-02-071-4/+4
| | | | | | | | | | In all the cases below, the parameters are defined in the qtestsupport_gui.h as well. Pick-to: 6.5 Task-number: QTBUG-109394 Change-Id: I3311d6c23b3a811dbe20286bd4534ca1ed7cd7f3 Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
* Respect custom QWSI event handler when delivering synchronous eventsTor Arne Vestbø2023-01-181-1/+6
| | | | | | | Pick-to: 6.5 6.4 Fixes: QTBUG-110268 Change-Id: I25195904cfc18d593db1be713b6e899e55eb922f Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Port from container.count()/length() to size()Marc Mutz2022-10-041-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* QWSI: Remove dead code for macOS-specific shortcut-override handlingTor Arne Vestbø2022-09-151-17/+13
| | | | | | | | | | | | | | | | | | | | | | The macOS platform plugin exclusively uses handleExtendedKeyEvent() these days, never the simpler handleKeyEvent(), and always passes false for the tryShortcutOverride argument, so the special-cased code was never executed. No other platform passes the optional tryShortcutOverride argument, so it can be removed completely. If we ever need to bring back this kind of logic it should live in the macOS platform plugin, not in the QWSI layer. We have to keep the existing logic for qt_handleKeyEvent() though, as that's exercised through QTest::simulateEvent(). The next step would be to remove the QWindowSystemInterface::handleShortcutEvent() call in QGuiApplicationPrivate::processKeyEvent() and teach existing platform plugins, as well as the QTest machinery, to handle shortcuts explicitly before sending raw key events. Change-Id: I6eb3fd18c64d1619e33e79f076e25efd299a9ba7 Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
* Rename QScreenPrivate::updateHighDpi()Morten Johan Sørvig2022-09-081-1/+1
| | | | | | | | The function updates the cached QScreen geometry; rename it to updateGeometry(). Change-Id: I56077807baa6c515769017dbb842eed10b1d1357 Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
* Apply Q_CONSTINIT where beneficialSona Kurazyan2022-09-011-3/+3
| | | | | | | | | | Applied Q_CONSTINIT to variables with static storage duration, but skipped the POD types with core constant initializers. Task-number: QTBUG-100486 Change-Id: Iaabf824e9cb0f29a405a149912200d4e4b3573c1 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* Restore signature of qt_handleTouchEvent()Kai Köhne2022-08-311-1/+7
| | | | | | | | | | | | | | The function return value changed in commit e1f25b1c8. Anyhow, this breaks the AUT probe of Squish on Windows, as long as it is built against an older Qt version. Squish can of course be adjusted eventually, but let's allow some grace period. Pick-to: 6.4 Fixes: SQUISH-15324 Change-Id: I289ed43bffcf292aa2eae3962a4661ed5c29100e Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Make it possible to check the accepted state of touch events in testsShawn Rutledge2022-07-081-2/+2
| | | | | | | | | | | | | | | | | | | | | | | QTouchEventSequence simulates a QPA touch event, potentially containing multiple points. (Despite the name, it only calls qt_handleTouchEvent() once, so it cannot really send a sequence of events; however, one event can contain multiple touchpoints.) Delivery is synchronous, and we keep return values through the QWindowSystemInterface::handleTouchEvent() template functions; so the remaining step is to return a bool from qt_handleTouchEvent(), so that we can return a bool from commit(). This allows tests to see the same perspective as a platform plugin can: check whether the event was accepted or not, after delivery is complete. Some tests in Qt Quick need to start doing that, to enforce correct behavior in QQuickDeliveryAgent. [ChangeLog][QtTestLib] QTouchEventSequence::commit() now returns a bool so that tests can check whether the event was accepted during delivery. Pick-to: 6.4 Task-number: QTBUG-104656 Change-Id: I9cf87909a3f847dedbdeca257013e309ac19cf0d Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@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>
* QtGui: use _L1 for for creating Latin-1 string literalsSona Kurazyan2022-04-281-1/+3
| | | | | | Task-number: QTBUG-98434 Change-Id: Idcb71c1d27125333a53b6bdd3e1af0d4c66617fa Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* Fix high-dpi and QScreen state initializationMorten Johan Sørvig2022-03-291-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Fix bug where QScreen::geometry() returns incorrect (unscaled) geometry. We maintain state: - QHighDpiScaling::m_active, which is set to true if any screen in QGuiApplication::screens() has a scale factor > 1, in updateHighDpiScaling() - QScreen::m_geometry, which is assigned the scaled screen size in QScreenPrivate::updateHighDpi() Now the problem is that updateHighDpiScaling() requires an up-to date screens list, and that updateHighDpi() requires an up-to date m_active, and that currently updateHighDpi() is called when constructing the QScreen only. This is all a bit unsatisfactory, but for now fix this in the simplest way by adding a second call to updateHighDpi() in handleScreenAdded(), after the call to updateHighDpiScaling(). Pick-to: 6.2 6.3 Fixes-number: QTBUG-101601 Change-Id: I5f442ceb966c77d6746ee885203b67da96612587 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* Don't include qeventpoint_p.h from qevent_p.hMarc Mutz2022-01-141-0/+1
| | | | | | | | | | | The header no longer uses QMutableEventPoint. Fix TUs that relied on the transitive include. Task-number: QTBUG-99615 Pick-to: 6.3 Change-Id: Iae4ff34ea708304fcd365fd763875dd4a97a1cf8 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QWindowSystemInterface: port to QMutableEventPoint static setter APIMarc Mutz2022-01-131-6/+6
| | | | | | | | | | | | | This code was actually ok (no UB), but it's in the way of making QMutableEventPoint a befriendable namespace, so port from using QMutableEventPoint to QEventPoint instances + QMutableEventPoint static setters. Task-number: QTBUG-99615 Pick-to: 6.3 Change-Id: I1f123837d62a2200e36faf89f6912ee59be2f915 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* Doc: Fix qdoc warnngsVenugopal Shivashankar2021-10-231-0/+2
| | | | | | | | | | | qt5/qtbase/src/gui/kernel/qwindowsysteminterface.cpp:75: (qdoc) warning: Cannot tie this documentation to anything [qdoc found a /*! ... */ comment, but there was no topic command (e.g., '\fn', '\page') in the comment and no function definition following the comment.] qt5/qtbase/src/gui/text/qtextformat.cpp:1500: (qdoc) warning: Overrides a previous doc qt5/qtbase/src/gui/text/qtextformat.cpp:1487: (qdoc) warning: (The previous doc is here) qt5/qtbase/src/gui/text/qtextformat.cpp:1533: (qdoc) warning: Overrides a previous doc qt5/qtbase/src/gui/text/qtextformat.cpp:1520: (qdoc) warning: (The previous doc is here) Change-Id: I5a089bef1841d6d69bff4c780805d20e5926fe6f Reviewed-by: Topi Reiniö <topi.reinio@qt.io>
* Allocate synchronously delivered QWSI events on the stackVolker Hilsheimer2021-10-011-178/+132
| | | | | | | | | | | | | | | | | If we know at compile time that a window system interface event will be delivered synchronously, then we can allocate it on the stack avoid a new/delete. This is the case for a large number of events. Add a template helper class that is specialized for the three delivery types to allocate the event object on the stack if possible, and on the heap otherwise. We can use that factory in the event handler functions, via a helper function, to replace the heap-allocation and call to handleWindowSystemEvent. Done-with: Tor Arne Vestbø <tor.arne.vestbo@qt.io> Change-Id: If92fc91ef07f3542a37dfb0fed20e15a3d19b8f0 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* Properly scale gesture positions in hi-DPI casePovilas Kanapickas2021-08-121-3/+15
| | | | | | | | The local/global positions for gestures should be handled the same as for other events as they mean effectively the same thing. Change-Id: Ic5ad995607ecd3daf385a7c7be3b67cbae312e7b Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
* Rename QNativeGestureEvent::deltas() to delta(); clarify docsShawn Rutledge2021-07-141-4/+4
| | | | | | | | | | | | | | | | | In QPanGesture this is called delta(). OTOH we have QWheelEvent::pixelDeltas(). Delta is a vector, and there's only one (with two components). Native gestures hold incremental values: e.g. the pinch gesture event provides an incremental amount of either zooming or rotation (so most events have QNativeGestureEvent::value() very close to 0). It's the same with the pan gesture's delta(). Add better docs for swipe and pan gestures. Change-Id: Ia147c7c9a22e084c3700b1620dec46427d792bd1 Reviewed-by: Povilas Kanapickas <povilas@radix.lt> Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Change QNativeGestureEvent::deltas() to QPointFShawn Rutledge2021-07-141-1/+1
| | | | | | | | | | | | | It came up during 6.2 API review that we prefer all floating-point API to be double-precision on 64-bit platforms, despite the awkwardness of representing a displacement vector with something called a "point". The docs for QPointF explicitly state "A QPointF object can also be used as a vector: Addition and subtraction are defined..." Amends 31f90e99b8f04d9a228c5a0b01319b3f112c1490 Change-Id: I01029661f2586640cbf846f49df164c176d17f7a Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Remove Qt6 switches from QtGuiAllan Sandfeld Jensen2021-05-051-4/+0
| | | | | | | Removing now dead code Change-Id: I021539da6517fdb8443f8ae9431fc172b7910cfc Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
* Call updateHighDpiScaling() on screenAdded()Morten Johan Sørvig2021-04-281-0/+1
| | | | | | | | | | | | | | | | | | | | | | QHighDpiScaling has two init/update functions: - initHighDpiScaling(): called once during QGuiApplication construction - updateHighDpiScaling(): called whenever (relevant) screen configuration changes Currently the calls to updateHighDpiScaling() are made from multiple places including platform code. Simplify by calling it from two locations: - QWindowSystemInterface::handleScreenAdded() - QGuiApplicationPrivate::processScreenLogicalDotsPerInchChange() Replace comment about early calls to qt_defaultDpi with a test which calls qt_defaultDpiX/Y with no screens attached. (Looking at the qt_defaultDpiX() implementation, it is unlikely that there will be a problem as long as updateHighDpiScaling() is called before QGuiApplication::primaryScreen() starts returning a non-null value.) Change-Id: I447db42894617495843a5cb531a1322b000fed62 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* Add storage for (pixel) deltas and fingerCount to QNativeGestureEventShawn Rutledge2021-04-271-4/+15
| | | | | | | | | | | | | | | | | | | | | | | | | | It's not clear now whether trackpad gestures on Windows will need to be so different than on macOS; however, any reasonable int value can be stored in a qreal, and in Qt Quick we like to use floating-point numbers for all "real" values and measurements. So since we need to add more storage, and quint64 m_intValue has never been used, we now replace it with a QVector2D, which should have the same size. The intended use is that PanNativeGesture will include a displacement, probably in pixels, by which the viewport or some target item should be panned or moved. The naming of deltas() is flexible enough to support any gesture with some incremental 2D valuators, though, just as value() has gesture-dependent semantics. fingerCount() will be useful for Qt Quick pointer handlers to filter out events that have the wrong number of fingers, e.g. to require that either a 3-finger pan gesture or 3 individual touchpoints are required to activate DragHandler { minimumPointCount: 3 } (assuming we implement pan gesture support in DragHandler). Fixes: QTBUG-92179 Task-number: QTBUG-92098 Change-Id: I5462aea9047beed6e99075294a62011edd8a59f5 Reviewed-by: Povilas Kanapickas <povilas@radix.lt> Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Remove QWindowSystemInterface::handleGestureEventWithSequenceIdAndValue()Shawn Rutledge2021-03-231-11/+0
| | | | | | | | | This was added in fbfc8ffbf39e2e7a540d4d576ec61bea7db63416 but left unused in Qt 5; and we don't anticipate needing it now either. Change-Id: I3d1f1301c8896df04255ebef5bacb5c5027dc7ae Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io> Reviewed-by: Povilas Kanapickas <povilas@radix.lt>
* Windows QPA: Pass device for synthesized touch/tablet eventsFriedemann Kleint2020-11-271-0/+20
| | | | | | | | | | | Add the overloads for mouse events with device/without timestamp and pass the active tablet or touch device. Task-number: QTBUG-88678 Task-number: QTBUG-46412 Pick-to: 6.0 Change-Id: I8695b493540d0cbf50e9c72afe870a7633de3ab9 Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
* QHighDpi: window geometry scaling functionsMorten Johan Sørvig2020-10-201-6/+2
| | | | | | | | | | | | | | | | | | Add functions which scales window geometry: framNativeWindowGeometry() toNativeWindowGeometry() These correctly handles top-level and child windows, where top-level window positions scale around the screen origin while child window positions scale around (0, 0). Modify call cites to use the new functions. We no longer need the isTopLevel checks at the call site. Change-Id: I0158672d46a3f52dfc7d37d021fc5cebd7859200 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io> Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
* QHighDpi: global geometry scaling functionsMorten Johan Sørvig2020-10-201-15/+15
| | | | | | | | | | | | | Add functions for scaling global coordinates: toNativeGlobalPosition() fromNativeGlobalPosition() These correctly handle the cases where a window spans several screens. Change-Id: I268762499cd8d86a3c417342ddaf2fb6dab4dd20 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io> Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
* QWindowSystemInterface: Add tablet event overloads without timestampsFriedemann Kleint2020-10-171-0/+25
| | | | | | | | On some platforms, tablet events do not have a time stamp. Task-number: QTBUG-46412 Change-Id: I3cc820b1edaaf55511c000fefb805f5a3a7872a6 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* Fix some qdoc warnings: typos and qdoc syntaxVolker Hilsheimer2020-09-221-1/+1
| | | | | Change-Id: Idf5c1490330e0f2e5d4bcf920eb03fc9993b3c8a Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* Track grab state in QPointingDevicePrivate::activePointsShawn Rutledge2020-09-161-0/+27
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | QQuickEventPoint instances were very long-lived and got reused from one event to the next. That was initially done because they were "heavy" QObjects; but it also became useful to store state in them between events. But this is in conflict with the ubiquitous event replay code that assumes it's OK to hold an event instance (especially a QMouseEvent) for any length of time, and then send it to some widget, item or window. Clearly QEventPoints must be stored in the QPointerEvent, if we are to avoid the need for workarounds to keep such old code working. And now they have d-pointers, so copying is cheap. But replay code will need to detach() their QEventPoints now. QEventPoint is useful as an object to hold state, but we now store the truly persistent state separately in an EventPointData struct, in QPointingDevicePrivate::activePoints. Incoming events merely update the persistent points, then we deliver those instead. Thus when event handler code modifies state, it will be remembered even when the delivery is done and the QPA event is destroyed. This gets us a step closer to supporting multiple simultaneous mice. Within pointer events, the points are moved up to QPointerEvent itself: QList<QEventPoint> m_points; This means pointCount(), point(int i) and points() can be non-virtual. However in any QSinglePointEvent, the list only contains one point. We hope that pessimization is worthwhile for the sake of removing virtual functions, simplifying code in event classes themselves, and enabling the use of the range-for loop over points() with any kind of QPointerEvent, not just QTouchEvent. points() is a nicer API for the sake of range-for looping; but point() is more suited to being non-const. In QML it's expected to be OK to emit a signal with a QPointerEvent by value: that will involve copying the event. But QEventPoint instances are explicitly shared, so calling setAccepted() modifies the instance in activePoints (EventPointData.eventPoint.d->accept); and the grabbers are stored separately and thus preserved between events. In code such as MouseArea { onPressed: mouse.accepted = false } we can either continue to emit the QQuickMouseEvent wrapper or perhaps QEvent::setAccepted() could become virtual and set the eventpoint's accepted flag instead, so that it will survive after the event copy that QML sees is discarded. The grabChanged() signal is useful to keep QQuickWindow informed when items or handlers change exclusive or passive grabbers. When a release happens at a different location than the last move event, Qt synthesizes an additional move. But it would be "boring" if QEventPoint::lastXPosition() accessors in any released eventpoint always returned the same as the current QEventPoint::xPosition()s just because of that; and it would mean that the velocity() must always be zero on release, which would make it hard to use the final velocity to drive an animation. So now we expect the lastPositions to be different than current positions in a released eventpoint. De-inline some functions whose implementations might be subject to change later on. Improve documentation. Since we have an accessor for pressTimestamp(), we might as well add one for timestamp() too. That way users get enough information to calculate instantaneous velocity, since the plan is for velocity() to be somewhat smoothed. Change-Id: I2733d847139a1b1bea33c00275459dcd2a145ffc Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Remove unused exported functions from QWSITor Arne Vestbø2020-08-311-17/+0
| | | | | Change-Id: If85231373bc0ec9a9259f628cd0c62a3a75b813b Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
* Introduce QWindow::paintEvent with QPA plumbingTor Arne Vestbø2020-08-261-2/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The explicit paint event on QtGui and QPA level allows us to untangle the expose event, which today has at least 3 different meanings. It also allows us to follow the platform more closely in its semantics of when painting can happen. On some platforms a paint can come in before a window is exposed, e.g. to prepare the first frame. On others a paint can come in after a window has been de-exposed, to save a snapshot of the window for use in an application switcher or similar. The expose keeps its semantics of being a barrier signaling that the application can now render at will, for example in a threaded render loop. There are two compatibility code paths in this patch: 1. For platform plugins that do not yet report the PaintEvents capability, QtGui will synthesize paint events on the platform's behalf, based on the existing expose events coming from the platform. 2. For applications that do not yet implement paintEvent, QtGui will send expose events instead, ensuring the same behavior as before. For now none of the platform plugins deliver paint events natively, so the first compatibility code path is always active. Task-numnber: QTBUG-82676 Change-Id: I0fbe0d4cf451d6a1f07f5eab8d376a6c8a53ce8c Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
* qwsi: revert parts of 00ae1e6b7bf6efa5f5e57d37844e44d521604fb6Gatis Paeglis2020-08-231-23/+2
| | | | | | | | | | | | | | We actually do not need this "mode" in qwsi API. I think while writing the patch from 00ae1e6b7b I got confused by focusing on my test application. We can't know what the native event filter will filter out, therefore it makes sense that we unconditionally do filtering at qwsi level as well for user input vs other events in QWindowSystemInterface::sendWindowSystemEvents(). Pick-to: 5.15 Pick-to: 5.12 Change-Id: Idb23152a24bf3ba3b91804427a6e78f991969c29 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* Refactor pointer event hierarchyShawn Rutledge2020-07-101-42/+26
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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-8/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* Add ; to Q_UNUSEDLars Schmertmann2020-07-071-18/+18
| | | | | | | | This is required to remove the ; from the macro with Qt 6. Task-number: QTBUG-82978 Change-Id: I3f0b6717956ca8fa486bed9817b89dfa19f5e0e1 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
* Add QPointingDevice argument to every QWSI input event handler functionShawn Rutledge2020-06-181-32/+103
| | | | | | | | | | | | | | | | | | | | | | We want every QInputEvent to carry a valid device pointer. It may be some time until all QPA plugins are sending it, but it's necessary to provide the functions for them to start doing that. We now try to maintain the same order of arguments to all the functions. handleTouchEvent(window, timestamp, device, the rest) was already there (except "device" has changed type now), and is used in a lot of platform plugins; so it seems easiest to let that set the precedent, and modify the rest to match. We do that by adding new functions; we can deprecate the older functions after it becomes clear that the new ones work well. However the handleGestureEvent functions have only ever been used in the cocoa plugin, so it's easy to change their argument order right now. Modify tst_qwindow::tabletEvents() to test new tablet event API. Task-number: QTBUG-46412 Change-Id: I1828b61183cf51f3a08774936156c6a91cfc9a12 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* Introduce QInputDevice hierarchy; replace QTouchDeviceShawn Rutledge2020-06-161-88/+38
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* Replace calls to deprecated QEvent accessor functionsShawn Rutledge2020-06-081-1/+1
| | | | | | | Many of these were generated by clazy using the new qevent-accessors check. Change-Id: Ie17af17f50fdc9f47d7859d267c14568cc350fd0 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Remove obsolete storage, constructors and accessors in QEvent subclassesShawn Rutledge2020-05-121-80/+3
| | | | | Change-Id: I5c51244031ff40f1972106ad4fe27010c8be1193 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Merge remote-tracking branch 'origin/5.15' into devQt Forward Merge Bot2020-04-111-4/+5
|\ | | | | | | | | | | | | Conflicts: tests/auto/network/socket/platformsocketengine/platformsocketengine.pri Change-Id: I22daf269a8f28f80630b5f521b91637531156404
| * Remove more calls to deprecated TouchPoint functionsShawn Rutledge2020-04-091-4/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Followup to ed3ed0b9db97a8fab0c03add23228b6b0a96f171 68916fede41d1eca5d07eb6b1db518d41a007616 and 3c159957f863cf8d367a9261e7016e52cd0348c1. In QWindowSystemInterfacePrivate::fromNativeTouchPoints() and QWindowSystemInterfacePrivate::toNativeTouchPoints() we continue using struct TouchPoint's QRectF area as storage for the screen position + ellipse diameters; as the comment says, this is _unrotated_, meaning that rotation is stored separately, and area should not be construed as the bounding box of the rotated ellipse. (In Qt 6 we can make the QPA touchpoint look the same as the QTouchEvent::TouchPoint to eliminate the need to calculate the center of the rect.) In QGraphicsScenePrivate::updateTouchPointsForItem(), setRect() sets the position and the ellipse diameters, but the latter is redundant because the purpose of this function is to localize a touchpoint to the coordinate system of a particular QGraphicsItem. Ellipse diameters should stay the same. In QApplicationPrivate::updateTouchPointsForWidget(), as in QGraphicsScene, we are localizing touchpoints to a widget and to the screen that the widget is shown on, so only the position needs to be set, while preserving the sub-pixel resolution that mapFromGlobal(QPoint) loses. Fixes: QTBUG-83403 Change-Id: I61d29e14cbe38567767b164af6ae895082c5e1a1 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* | Merge remote-tracking branch 'origin/5.15' into devQt Forward Merge Bot2020-04-081-2/+2
|\| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Conflicts: examples/opengl/doc/src/cube.qdoc src/corelib/global/qlibraryinfo.cpp src/corelib/text/qbytearray_p.h src/corelib/text/qlocale_data_p.h src/corelib/time/qhijricalendar_data_p.h src/corelib/time/qjalalicalendar_data_p.h src/corelib/time/qromancalendar_data_p.h src/network/ssl/qsslcertificate.h src/widgets/doc/src/graphicsview.qdoc src/widgets/widgets/qcombobox.cpp src/widgets/widgets/qcombobox.h tests/auto/corelib/tools/qscopeguard/tst_qscopeguard.cpp tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp tests/benchmarks/corelib/io/qdiriterator/qdiriterator.pro tests/manual/diaglib/debugproxystyle.cpp tests/manual/diaglib/qwidgetdump.cpp tests/manual/diaglib/qwindowdump.cpp tests/manual/diaglib/textdump.cpp util/locale_database/cldr2qlocalexml.py util/locale_database/qlocalexml.py util/locale_database/qlocalexml2cpp.py Resolution of util/locale_database/ are based on: https://codereview.qt-project.org/c/qt/qtbase/+/294250 and src/corelib/{text,time}/*_data_p.h were then regenerated by running those scripts. Updated CMakeLists.txt in each of tests/auto/corelib/serialization/qcborstreamreader/ tests/auto/corelib/serialization/qcborvalue/ tests/auto/gui/kernel/ and generated new ones in each of tests/auto/gui/kernel/qaddpostroutine/ tests/auto/gui/kernel/qhighdpiscaling/ tests/libfuzzer/corelib/text/qregularexpression/optimize/ tests/libfuzzer/gui/painting/qcolorspace/fromiccprofile/ tests/libfuzzer/gui/text/qtextdocument/sethtml/ tests/libfuzzer/gui/text/qtextdocument/setmarkdown/ tests/libfuzzer/gui/text/qtextlayout/beginlayout/ by running util/cmake/pro2cmake.py on their changed .pro files. Changed target name in tests/auto/gui/kernel/qaction/qaction.pro tests/auto/gui/kernel/qaction/qactiongroup.pro tests/auto/gui/kernel/qshortcut/qshortcut.pro to ensure unique target names for CMake Changed tst_QComboBox::currentIndex to not test the currentIndexChanged(QString), as that one does not exist in Qt 6 anymore. Change-Id: I9a85705484855ae1dc874a81f49d27a50b0dcff7
| * macOS: Remove all use of deprecated Q_OS_OSX defineTor Arne Vestbø2020-04-031-2/+2
| | | | | | | | | | Change-Id: I49c285604694c93d37c9d1c7cd6d3b1509858319 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* | Merge remote-tracking branch 'origin/5.15' into devSimon Hausmann2020-03-161-54/+56
|\| | | | | | | | | | | | | Conflicts: src/corelib/kernel/qmetatype.cpp Change-Id: I88eb0d3e9c9a38abf7241a51e370c655ae74e38a