summaryrefslogtreecommitdiffstats
path: root/src/gui/kernel
Commit message (Collapse)AuthorAgeFilesLines
* Centralize the implementation of move assignment operatorsGiuseppe D'Angelo2020-10-033-10/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | At the moment we have two main strategies for dealing with move assignment in Qt: 1) move-and-swap, used by "containers" (in the broad sense): containers, but also smart pointers and similar classes that can hold user-defined types; 2) pure swap, used by containers that hold only memory (e.g. QString, QByteArray, ...) as well as most implicitly shared datatypes. Given the fact that a move assignment operator's code is just boilerplate (whether it's move-and-swap or pure swap), provide two _strictly internal_ macros to help write them, and apply the macros across corelib and gui, porting away from the hand-rolled implementations. The rule of thumb when porting to the new macros is: * Try to stick to the existing code behavior, unless broken * if changing, then follow this checklist: * if the class does not have a move constructor => pure swap (but consider ADDING a move constructor, if possible!) * if the class does have a move constructor, try to follow the criteria above, namely: * if the class holds only memory, pure swap; * if the class may hold anything else but memory (file handles, etc.), then move and swap. Noteworthy details: * some operators planned to be removed in Qt 6 were not ported; * as drive-by, some move constructors were simplified to be using qExchange(); others were outright broken and got fixed; * some contained some more interesting code and were not touched. Change-Id: Idaab3489247dcbabb6df3fa1e5286b69e1d372e9 Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
* Ignore mouse events where globalPos contains NaNSteffen Kieß2020-10-021-0/+5
| | | | | | | | | | | | | | A NaN value in globalPos can cause an endless recursion in QGuiApplicationPrivate::processMouseEvent() when e->enhancedMouseEvent() is true and this is not a move event. When an event contains a NaN in globalPos, print a warning and ignore the event. Pick-to: 5.15 Fixes: QTBUG-86207 Change-Id: I8789e465921789569715e52c98193f91945ea982 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* End touch->mouse synthesis when the chosen touchpoint is releasedShawn Rutledge2020-10-021-27/+33
| | | | | | | | | | | | | | | | During delivery of a TouchBegin event, if no widget accepts it, we begin treating the first touchpoint as a synth-mouse, as before. If a second touchpoint is pressed or released in any order, it's irrelevant: the fake mouse button is released as soon as the first touchpoint is released. This fixes the bug that such a scenario caused the mouse release not to be sent, so that a widget could get "stuck" in pressed state. Done-with: Tang Haixiang <tanghaixiang@uniontech.com> Fixes: QTBUG-86253 Pick-to: 5.15 Change-Id: I7fbbe120539d8ded8ef5e7cf712a27bd69391e02 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Treat a double-click event as an update event with stationary pointShawn Rutledge2020-09-301-4/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | The sequence is still press, release, press, double-click, release. isBeginEvent() should not be true for a double-click event: the second click began with a normal MouseButtonPress, and the MouseButtonDblClick event is a way of sending updated state to tell the recipient that the second click was special, occurring within such spatial and temporal constraints that it can be interpreted as a double-click. It never has a different position either, because MouseButtonDblClick is a synthetic event occurring at the same position as the second press; so we might as well say its QEventPoint is Stationary. Together, these changes fix tst_controls::Basic::DelayButton::test_mouse in Controls 2, without any changes in qtdeclarative. In QQuickWindowPrivate::deliverPointerEvent(), if isBeginEvent() == true, it delivers to all items under the point position(s) first, and then if all _updated_ points were not accepted, it continues delivery to grabbers; whereas if isBeginEvent() == false, it delivers only to grabbers. isBeginEvent() and QEventPoint::state() are important to that algorithm. Amends 6d6ed64d6ca27c1b5fec305e6ed9b923b5bb1037 Task-number: QTBUG-87018 Change-Id: I95def9704652147540df5cc065354a0fe04ed626 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Get rid of some #ifdef qt6Allan Sandfeld Jensen2020-09-301-5/+0
| | | | | | | | | None of this code is even compiled in qt6. Change-Id: I5891cc9459320083ad3908fcbf646f3ba75b8a4d Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io> Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Emit QScreen::geometryChanged when the logical DPI changesFriedemann Kleint2020-09-302-6/+11
| | | | | | | | | | | | | | | | | | | | Add the missing call to QScreenPrivate::emitGeometryChangeSignals() along with an emission of physicalDotsPerInchChanged() since that is calculated from geometry and physical size. Rearrange the code in QGuiApplicationPrivate::processScreenGeometryChange() to prevent duplicate emissions of geometryChanged(), physicalDotsPerInchChanged() which this change would introduce. Amends 5290027e3bab75f14fc0a2b7c206594d9cb91e76. Pick-to: 5.15 Task-number: QTBUG-76902 Task-number: QTBUG-79248 Fixes: QTBUG-86604 Change-Id: I3dc2ec5ccd9c6413e92f9246242f323e8afc5e57 Reviewed-by: David Edmundson <davidedmundson@kde.org>
* Fix assumed version typoAllan Sandfeld Jensen2020-09-301-2/+2
| | | | | | | Deprecated from 6.0, but necessary for migration. Change-Id: Idb1264e6ecca9400086970c15270b803c8fd391b Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* Fix qdoc warning: button(s) are members of QSinglePointEventVolker Hilsheimer2020-09-271-25/+0
| | | | | | | ... and documented there already. Change-Id: Ie66362d3b668caf93b100befef08bc91ae8add2f Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* Use WAYLAND_DISPLAY and DISPLAY instead of XDG_SESSION_TYPEJohan Klokkhammer Helsing2020-09-271-18/+35
| | | | | | | | | | | | | | | | XDG_SESSION_TYPE is a non-standard part of systemd, and not set if you run a compositor from the command line, for instance. [ChangeLog][Wayland] XDG_SESSION_TYPE is no longer used to determine which platform plugin to use. Instead, if WAYLAND_DISPLAY is set in the environment, wayland is used. Similarly, if DISPLAY is set, xcb is used. If both are detected, wayland will be attempted first, then xcb. Gnome-shell is still skipped for automatic wayland detection. Fixes: QTBUG-75732 Change-Id: Ieed123330662dc29eafa31148a9b99ba0810de90 Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
* Replace Q_REQUIRED_RESULT with [[nodiscard]]Allan Sandfeld Jensen2020-09-251-2/+2
| | | | | | | It was already used many places directly making the code inconsistent. Change-Id: I3b14bc6c333640fb3ba33c71eba97e78c973e44b Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Get rid of QMutableEventPoint::stationaryWithModifiedPropertyShawn Rutledge2020-09-253-20/+0
| | | | | | | | | | | | | | | | Omitting stationary points from touch events is such a marginal optimization that this code probably isn't worth maintaining. It wasn't implemented correctly this time either, according to the tst_QQuickMultiPointTouchArea::stationaryTouchWithChangingPressure() test. [ChangeLog][QtGui][QPointerEvent] We no longer attempt to avoid delivery of stationary points within QTouchEvent: every pressed point is now included in every TouchUpdate event. Task-number: QTBUG-77142 Change-Id: If1fd666fb3057a17e0dffdd7ca7138693126b02b Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Fix some qdoc warnings: undocumented parametersVolker Hilsheimer2020-09-251-1/+1
| | | | | Change-Id: I5d37f620caccbd1445c99a602b71779bdedd37d3 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* Simplify QHighDpi::fromNativeLocalExposedRegion()Alexander Volkov2020-09-231-7/+3
| | | | | | | ... by using QRectF::toAlignedRect(). Change-Id: I310b2f0ad87c541aa0d63d6a8061783aff791abb Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
* Fix documentation of QPointerEvent::pointsVolker Hilsheimer2020-09-231-15/+6
| | | | | | | As drive-by, fix qdoc warning in related internal documentation. Change-Id: I7716a9b126e38e99dcd11c6af2e91b8ec7bf4346 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@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>
* Cleanup API of QMimeDataLars Knoll2020-09-212-9/+9
| | | | | | | | | | | | | Do not use QVariant::Type anymore, instead use QMetaType For some reason, this pushed the qvariant autotest over the limit where MSVC requires the /bigobj flag, so add that one. [ChangeLog][QtCore][QMimeData] The signature of the virtual retrieveData() function has changed and now takes a QMetaType instead of a QVariant::Type. Change-Id: Ib46773bd731ee2177b1ef74d8162d744be7017ef Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* Emit CancelGrabExclusive when one grabber is replaced by anotherShawn Rutledge2020-09-181-1/+2
| | | | | | | | | | | | | | Qt Quick Pointer Handlers depend on this behavior: QQuickPointerHandler::onGrabChanged() receives only the grabber that was losing the grab or the one that is receiving it, not both at the same time. UngrabExclusive means the original grabber simply relinquished the grab by setting the exclusive grabber to null. CancelGrabExclusive means the new grabber took over the grab that the old grabber had before. Task-number: QTBUG-86729 Change-Id: Iefca6fe91b11fcb03d2c6ac3598841c924facb22 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Fix running with placeholder screen and high-dpi enabledEskil Abrahamsen Blomfeldt2020-09-181-0/+1
| | | | | | | | | | | | | | | | | After we started defaulting to high-dpi enabled, it was discovered that it does not work correctly with the placeholder screen. Since the placeholder screen has no physical size, and the default implementation of logicalDpi() divides by the physical size, we got a scale factor of NaN in the high-dpi code. The effect of this was that the nooutput test in Qt Wayland would fail, because it did not get the events it was expecting, since the window geometry was never set to a valid rect in the resize() call. Task-number: QTBUG-86698 Change-Id: I7ee68db9a13446b414502ae0f26fd214531c673a Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* Rename is[Begin|Update|End]Event, reimplement in QWheelEventShawn Rutledge2020-09-172-10/+38
| | | | | | | | | | | | | | These states correspond well with ScrollPhase, and this abstraction makes it possible to handle wheel events the same way as mouse events in Qt Quick: on "begin" we deliver to all Items and Handlers until all points (the only point) are accepted; on "update" and "end" we deliver only to the exclusive grabber, if there is one, and to any passive grabbers. Change-Id: I702dbd4f2c1bf5962eb3dbb9e4b725300a00a887 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io> Reviewed-by: Paul Wicking <paul.wicking@qt.io> Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Deprecate implicit QPixmap conversion to QBitmapVolker Hilsheimer2020-09-172-2/+2
| | | | | | | | | | | | | | | | It is lossy, so should be requested explicitly, using a dedicated fromPixmap factory function. Deprecate the constructor and assignment operator, and make the constructor explicit. [ChangeLog][QtGui][QBitmap] Implicitly constructing and assigning to a QBitmap from a QPixmap has been deprecated, and the respective constructor has been made explicit. Use the fromPixmap factory function instead. Change-Id: I68ce85b26c901415137b664a1db687021d48bae0 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* QPointingDevPriv::setExclusiveGrabber: emit grabChanged with point foundShawn Rutledge2020-09-171-1/+1
| | | | | | | | | | | | | | | | | | ...not with the given point. Since QEventPoint has a constructor that takes an id, it's possible to write something like pointerEvent->setExclusiveGrabber(pointId, object) which will construct a QEventPoint on-the-fly, containing only an id. (That was unintentional, but perhaps useful sometimes.) setExclusiveGrabber() looks up the persistent point, but if we emit the signal with the given point, it is missing the device. A handler connected to that signal might reasonably assume that the point is a complete instance; so we'd better emit the complete instance that we found. (OTOH if the given point was a detached instance, it might also be unexpected that the signal emits the persistent instance instead of the given instance.) Amends 2692237bb1b0c0f50b7cc5d920eb8ab065063d47 Change-Id: Iee16363dcb22c1dc07b0cc0a81930218e22fa19e Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Add more QPointerEvent functions needed in Qt QuickShawn Rutledge2020-09-176-0/+195
| | | | | Change-Id: I87a874477b89eb3f5951930f03e305d896a24c2e Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Mouse->touch synthesis: send touch event with mouse deviceShawn Rutledge2020-09-161-6/+1
| | | | | | | | | | | In 4e400369c08db251cd489fec1229398c224d02b4 we began to send synth-mouse events from the touch device, but in the opposite direction it was not consistent. Add autotests to prove that it's consistent both ways now. Change-Id: I7df2328fef224dc1529ca5d27411cd8a5a9c8df9 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Calculate velocity in QMutEventPoint::setTimestamp() with Kalman filterShawn Rutledge2020-09-163-6/+67
| | | | | | | | | | | | | | This functionality was only in Qt Quick in Qt 5. Now we move it up to QtGui so that every QEventPoint will have a valid velocity() before being delivered anywhere. [ChangeLog][QtGui][QPointerEvent] Every QEventPoint should now carry a valid velocity(): if the operating system doesn't provide it, Qt will calculate it, using a simple Kalman filter to provide a weighted average over time. Fixes: QTBUG-33891 Change-Id: I40352f717f0ad6edd87cf71ef55e955a591eeea1 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Track grab state in QPointingDevicePrivate::activePointsShawn Rutledge2020-09-1610-256/+559
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* Switch QSurfaceFormat::colorSpace to a QColorSpaceAllan Sandfeld Jensen2020-09-152-7/+34
| | | | | | | Allows more flexibility in the future. Change-Id: Idcf2d8ddaee268a7b5d55379ccb42dd9b3c33abf Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* Remove QPointerEvent::isPointAccepted() and setPointAccepted()Shawn Rutledge2020-09-141-2/+0
| | | | | | | | They are redundant, not in use, and got added without implementation in a81859a3c8d0f8b4367fc63988e1d653d34ed48a. Change-Id: Ifed1fbf97a8158c2801df09dac47bf1fc90795d4 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Plumb application quit through platform pluginTor Arne Vestbø2020-09-144-0/+24
| | | | | | | | | | | | | | | | | | If we have a platform plugin we ask the platform to quit, and if not we fall back to the base implementation of QCoreApplication that sends Quit events directly. This allows the platform to involve the rest of the system in the process. The platform will then come back with a spontaneous quit via QWSI::handleApplicationTermination(), which will then send the corresponding Quit even from QGuiApplication like normal. Task-number: QTBUG-45262 Task-number: QTBUG-33235 Task-number: QTBUG-72013 Task-number: QTBUG-59782 Change-Id: I0000aaf7192e4b905933c5da0e53901c6c88f26a Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Doc: Fix documentation issues for event and input device classesTopi Reinio2020-09-103-181/+287
| | | | | | | | | | | | | | * Document the new base classes QPointerEvent and QSinglePointEvent, and move relevant documentation to be located under them. * Replace linking to deprecated functions with their new counterparts. * Remove non-existent function and parameter documentation. * Document QEventPoint::State enum. * Prefer \obsolete over \deprecated and fix the usage. * Document the Capabilities enum in the correct location and add docs for the missing enum values. Change-Id: Ic8f2732f2e90ecbf522cd744c601cedcc574825c Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* Move grabbing API from QEventPoint to QPointerEventShawn Rutledge2020-09-102-64/+115
| | | | | | | | | | | | | | | | | | | | | | We plan to move storage of the grabbers into QPointingDevice so that QEventPoint will store only data that does not need to persist between deliveries of individual events. These API changes prepare for that. addPassiveGrabber/removePassiveGrabber is a better API than setPassiveGrabbers(), because it will never require constructing a temporary QList just to call the function. Eventually we need to emit signals to notify about grab changes, so it's better to have incremental changes to the list rather than needing to iterate and find differences. Fix up the docs. QEventPoint IDs are no longer written in hex in debug output. That was done in Qt 5 because an ID was a composite of device ID with the OS-provided touchpoint ID; but since the QPointingDevice is always available, it's more readable if the IDs are in decimal. Change-Id: I86b9016d9b28c331ca05c7c108d9788de93fb642 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Cleanup QAction::visible propertyAllan Sandfeld Jensen2020-09-104-17/+27
| | | | | | | | Gives it its own changed signal, and simplifies setting from group, while fixing an inconsistency in propagation. Change-Id: I22b243210260a8878144fa4b60204df46f847f37 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Give QEventPoint a d-pointer after allShawn Rutledge2020-09-103-94/+222
| | | | | | | | | | I still have doubts that QEventPoint can't be made small enough that copying would be cheaper than reference-counting and all the indirections in now-noninline accessors, but this gives us the usual freedom to change the data members later on. Change-Id: I792f7fc85ac3a9538589da9d7618b647edf0e70c Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Refactor testlib touch functions into qtestsupport_gui and _widgetsShawn Rutledge2020-09-082-1/+121
| | | | | | | | | | | | | Because we removed public setters from QTouchEvent and QEventPoint in 4e400369c08db251cd489fec1229398c224d02b4 and now it's proposed to give QEventPoint a d-pointer again, the implementation of QTouchEventSequence needs to start using QMutableEventPoint: being a friend will no longer be enough, because the member variables won't be accessible in the future. But because we have separate test libs for Gui and Widgets, it needs to be further refactored into two classes. Change-Id: I0bfc0978fc4187348ac872e1330d95259d557b69 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Remove deprecated API from QSurfaceFormatMarcel Krems2020-09-082-43/+0
| | | | | Change-Id: I8dacdaa18cea967a85e8835c2440ba53ee5df2e1 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* Get rid of hasPendingEvents() and flush()Lars Knoll2020-09-061-1/+0
| | | | | | | They are unused. Change-Id: I77383f2be45551401ed9c2f88285511134cc8b0d Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* Tighten up QDialogButtonBox::ButtonLayout enumVolker Hilsheimer2020-09-032-11/+0
| | | | | | | | | | ... and the equivalent enum in QPlatformDialogHelper. No need to keep numerical values the same anymore. Remove ### Qt 6 comment. Change-Id: Ib369ea6ca2362f6ab0f71a3a6c90c4adaa7f11cd Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* Fix build without features.highdpiscalingTasuku Suzuki2020-09-041-2/+2
| | | | | | | Broken since 37d5aaa4b42f9c837f0d27edb9da2185971d02be Change-Id: Id741f23ccae4f619e6a389ee71b3e7fe0c599989 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
* Long live QKeyCombination!Giuseppe D'Angelo2020-09-039-33/+59
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | C++20 via P1120 is deprecating arithmetic operations between unrelated enumeration types, and GCC 10 is already complaining. Hence, these operations might become illegal in C++23 or C++26 at the latest. A case of this that affects Qt is in key combinations: a QKeySequence can be constructed by summing / ORing modifiers and a key, for instance: Qt::CTRL + Qt::Key_A Qt::SHIFT | Qt::CTRL | Qt::Key_G (recommended, see below) The problem is that the modifiers and the key belong to different enumerations (and there's 2 enumerations for the modifier, and one for the key). To solve this: add a dedicated class to represent a combination of keys, and operators between those enumerations to build instances of this class. I would've simply defined operator|, but again docs and pre-existing code use operator+ as well, so added both to at least tackle simple cases (modifier + key). Multiple modifiers create a problem: operator+ between them yields int, not the corresponding flags type (because operator+ is not overloaded for this use case): Qt::CTRL + Qt::SHIFT + Qt::Key_A \__________________/ / int / \______________/ int Not only this loses track of the datatypes involved, but it would also then "add" the key (with NO warnings, now its int + enum, so it's not mixing enums!) and yielding int again. I don't want to special-case this; the point of the class is that int is the wrong datatype. Everything works just fine when using operator| instead: Qt::CTRL | Qt::SHIFT | Qt::Key_A \__________________/ / Qt::Modifiers / \______________/ QKeyCombination So I'm defining operator+ so that the simple cases still work, but also deprecating it. Port some code around Qt to the new class. In certain cases, it's a huge win for clarity. In some others, I've just added the necessary casts to make it still compile without warnings, without attempting refactorings. [ChangeLog][QtCore][QKeyCombination] New class to represent a combination of a key and zero or more modifiers, to be used when defining shortcuts or similar. [ChangeLog][Potentially Source-Incompatible Changes] A keyboard modifier (such as Qt::CTRL, Qt::AltModifier, etc.) should be combined with a key (such as Qt::Key_A, Qt::Key_F1, etc.) by using operator|, not operator+. The result is now an object of type QKeyCombination, that stores the key and the modifiers. Change-Id: I657a3a328232f059023fff69c5031ee31cc91dd6 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* High-DPI: Remove legacy environment variablesTor Arne Vestbø2020-09-021-35/+2
| | | | | | | | | | | | | QT_DEVICE_PIXEL_RATIO is replaced by QT_SCALE_FACTOR, while QT_AUTO_SCREEN_SCALE_FACTOR is replaced by QT_ENABLE_HIGHDPI_SCALING. Since High-DPI is now always enabled, there's no reason to keep the code path for android.app.auto_screen_scale_factor. Also, based on the original commit message that introduced this code, the value of the property should have been true. Change-Id: Ib34b1deeab46c488c67c4d64f087599b4a54dc55 Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
* Document native interfacesFriedemann Kleint2020-09-025-9/+17
| | | | | | | | | | | | | | As the private headers are not included by default in the precompiled header QDoc builds for QtGui, create a custom module header for the documentation build and pull in the required headers. Add dummy declarations for Windows-specific types for building docs on non-Windows platforms. Task-number: QTBUG-83252 Change-Id: I225ed08f68cf4f7c1f1d093424070b13ce36aa51 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* Remove "fallback session management"Andreas Hartmetz2020-09-014-96/+1
| | | | | | | | | | | | | | With the Qt6 compatibility break, it can finally be removed. Closing windows (which might quit the application with quitOnLastWindowClosed() true, the default) acted contrary to the documentation of the commitDataRequest() signal, which could have been a hint. This removes the workaround API from the fix for QTBUG-49667 and also removes the problematic feature that it worked around. Change-Id: I672be58864ef062df7fb7f2a81658b92c4feedd2 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Doc: Compile droparea snippetPaul Wicking2020-09-011-1/+1
| | | | | | | | | | | droparea.h has been removed. Remove all code that depends on that header except the one snippet that is still used. Add minimal code to allow the snippet to be compiled. Done-with: Nico Vertriest <nico.vertriest@qt.io> Task-number: QTBUG-81486 Change-Id: I58c80d3527c82389ccff97567f4c75c33aec0f5e Reviewed-by: Topi Reiniö <topi.reinio@qt.io>
* Deprecate and remove uses of AA_DisableHighDpiScalingTor Arne Vestbø2020-08-311-9/+1
| | | | | | Change-Id: Ibadce68775858c524b998aacad310905ba2c2e8e Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> Reviewed-by: Morten Johan Sørvig <morten.sorvig@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>
* Remove QWSIPrivate::EventType::FrameStrutMouseTor Arne Vestbø2020-08-311-1/+0
| | | | | Change-Id: I66eb05ae7ed58ff3375b756c29a96d5067251cc3 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
* High-DPI: Remove usage of Qt::AA_EnableHighDpiScalingTor Arne Vestbø2020-08-281-1/+1
| | | | | | | | This attribute is now on by default. Change-Id: I7c9d2e3445d204d3450758673048d514bc9c850c Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io> Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* High-DPI: Don’t round scale factors in Qt 6Morten Johan Sørvig2020-08-281-6/+1
| | | | | | | | | | | | | | | | | | | | | | | | | Set HighDpiScaleFactorRoundingPolicy to PassThough by default. This makes Qt track the system UI setting accurately, and is overall the least confusing option. Historically, Qt has rounded the scale factor (for example, Windows 175% -> DPR 2) due to faulty handling of fractional scale factors in Qt Widgets and with the native Windows style. Other areas of Qt such as Qt Quick have had few issues with fractional scale factors and support this well. Qt has never rounded the scale factor on the Android platform. Support for fractional scale factors in Qt Widgets and the windows style has improved, which makes changing the default for Qt 6 viable. Task-number: QTBUG-83068 Change-Id: I38b60f621f95be8ebb6cb84a07d3370fec19ab92 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* High-DPI: Enable scaling by default in Qt 6Morten Johan Sørvig2020-08-281-7/+3
| | | | | | | | | | | | | | | Enable high-DPI support for all platforms which use QHighDpiScaling. This changes the default behavior of Qt applications on X11, Windows, and Android. Qt::AA_EnableHighDpiScaling is now effectively on by default, and Qt 6 applications do not have to set this application attribute. Opting out is possible by setting the Qt::AA_DisableHighDpiScaling attribute. Task-number: QTBUG-83068 Change-Id: Ia2bd3e6f490130afcacd3a951bc50dbb40a79d7f Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* Doc: Fix documentation warnings for Qt GUITopi Reinio2020-08-286-35/+26
| | | | | | | | | | | | * Drop deprecation warnings for now-dropped items * Use the 'qt6' define and a new \nothing doc macro to conditionally document items on Qt 6 * Add a custom module header for docs that pulls in also Vulkan headers * Add \internal command for internal classes/functions * Move QtGUI-related code snippets from widgets to gui docs Change-Id: Ieb386b96631a49568d09059906d307c45c01d93a Reviewed-by: Paul Wicking <paul.wicking@qt.io>
* Add QOffScreenSurface platform API abstractionAssam Boudjelthia2020-08-276-72/+206
| | | | | | | | | | | | | | | | | | | | | This follows the work done in 6ff79478a44fce12ca18832a56db4a370a9ff417. The API is available by including qoffscreensurface.h, scoped in the QPlatformInterface namespace. The namespace exposes platform specific type-safe interfaces that provide: a) Factory functions for adopting native contexts, e.g. QAndroidPlatformOffscreenSurface::fromNative(ANativeWindow); b) Access to underlying native handles, e.g. surface->platformInterface<QAndroidPlatformOffscreenSurface>() ->nativeSurface() Fixes: QTBUG-85874 Change-Id: I29c459866e0355a52320d5d473e8b147e050acb3 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>