summaryrefslogtreecommitdiffstats
path: root/src/gui/kernel/qguiapplication.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Fix improper moc includes inside the Qt namespaceThiago Macieira2022-06-201-2/+2
| | | | | | | Change-Id: Id0fb9ab0089845ee8843fffd16fa1b1413fd0d41 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> (cherry picked from commit 23bf260f10f4b507e2e19398a16574ca77fe774d) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* Replace QT_NO_ACCESSIBILITY with QT_CONFIG(accessibility)Allan Sandfeld Jensen2022-06-151-2/+2
| | | | | | | | Change-Id: Iee4bd8970810be1b23bdba65a74de912401dca65 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Marc Mutz <marc.mutz@qt.io> (cherry picked from commit f53f7095044275767e389d16aabad5ff7144ec9f) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* Q*ApplicationPrivate: remove unused "flags" argumentsThiago Macieira2022-06-141-4/+4
| | | | | | | | | | | | | | | | | They weren't flags. They were the version of Qt that was used in compiling the application itself. The protection against rollback isn't necessary any more, since qversiontagging.h, which applies to everything and not just the main application binary. And using them to make decisions on functionality or behavior is misguided (see previous commit). This commit does not deprecate the front-end classes' argument. In the future, we may find some need for them. Change-Id: Ia4a094014ddb48cc9f6dfffd16f83a7b58ff95d3 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> (cherry picked from commit fb1e0eee078f3f797a72b38e6981348b5ae5810c) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* xcb: Delete touch points without target windowsTang Haixiang2022-05-201-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | 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-39/+3
| | | | | | | | | | | | | 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: replace remaining uses of QLatin1String with QLatin1StringViewSona Kurazyan2022-04-281-4/+4
| | | | | | Task-number: QTBUG-98434 Change-Id: I98c27030c783f968cbf38dc966ce486dc366b302 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* QtGui: use _L1 for for creating Latin-1 string literalsSona Kurazyan2022-04-281-5/+7
| | | | | | Task-number: QTBUG-98434 Change-Id: Idcb71c1d27125333a53b6bdd3e1af0d4c66617fa Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* Send ThemeChange event to all windows when system theme changesTor Arne Vestbø2022-04-221-4/+5
| | | | | | | | | | | | | | | | | | | The QWSI event for theme change has an optional window parameter to specify the window affected, but most platform react to global theme changes, and end up passing nullptr into the event. The reasonable thing to do in QGuiApplication in that case is send a theme change event to every QWindow, so that they are all notified about the situation. This approach is what the Windows platform plugin was doing already, but did so by iterating manually over the windows, resulting in multiple calls to QGuiApplicationPrivate::handleThemeChanged -- one for each QWSI event. Change-Id: Ifb27b6c31231377c0df389a592cafd0075d3d8bb Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io> Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Rename QGuiApplicationPrivate::notifyThemeChanged to handleThemeChangedTor Arne Vestbø2022-04-211-15/+15
| | | | | | | | The work done by QGuiApplicationPrivate in response to a theme change goes beyond notifying. Change-Id: I27c74adf6549c553e659c7b8e271945ce753031c Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* QtGui: stop using QLatin1Char constructor for creating char literalsSona Kurazyan2022-04-131-5/+5
| | | | | | | | | Required for porting away from QLatin1Char/QLatin1String in scope of QTBUG-98434. Change-Id: I308d86cefcbfd126929b68f9a853d420840c965f Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Marc Mutz <marc.mutz@qt.io>
* QFontDatabase: Update docs for QGuiApplication::fontDatabaseChanged()Tor Arne Vestbø2022-04-051-1/+4
| | | | | | | | The signal can be emitted not only when user fonts are added or removed, but also when the system fonts change. Change-Id: I8f066ac87e7bc68843cd9014cd3c31af2f3a7890 Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
* QPA: improve plugin and theme documentation and logging outputMitch Curtis2022-04-041-5/+27
| | | | | | | | This makes it easier to understand which plugin and theme are loaded. Change-Id: I0eee395e1b7da5d5017d8f7839beefb547fdc7b0 Pick-to: 6.2 6.3 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* Apply Q_CONSTINIT across the codebaseMarc Mutz2022-03-291-1/+1
| | | | | | | | | Still not complete. Just grepping for static and thread_local. Task-number: QTBUG-100486 Change-Id: I90ca14e8db3a95590ecde5f89924cf6fcc9755a3 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Short live Q_CONSTINIT!Marc Mutz2022-03-261-39/+39
| | | | | | | | | | | | | | | | | | It expands to the first available of - constinit (C++20) - [[clang::require_constant_initialization]] (Clang) - __constinit (GCC >= 10) Use it around the code (on and near static QBasicAtomic; this patch makes no attempt to find all statics in qtbase). [ChangeLog][QtCore][QtGlobal] Added macro Q_CONSTINIT. Fixes: QTBUG-100484 Change-Id: I11e0363a7acb3464476859d12ec7f94319d82be7 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* Notify about focus object changes upon widget destructionVolker Hilsheimer2022-03-251-1/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | If the active QWidget gets destroyed, then QWidgetWindow::focusObject will return nullptr. If then no other object takes focus, then we'd never emit change signals, and QGuiApplication's _q_updateFocusObject (which then informs the input context and emits signals) didn't get called. This left the input context with a dangling focus object pointer, which resulted in crashes. If the QWidget clears its focus, but the corresponding window doesn't know that it had focus, then fall back to the widget's focus widget to see if we have a change in focus, so that signals get emitted. Add a test case that shows that we didn't call _q_updateFocusObject by counting emissions of the QGuiApplication::focusObjectChanged signal, which we emit in this function. The signal is emitted more than once both when showing a widget, and now also when destroying a widget that has a focus child. The former is a previous issue, the latter is an improvement to not emitting the signal at all. Pick-to: 6.3 6.2 Fixes: QTBUG-101423 Fixes: QTBUG-101321 Change-Id: Ib96a397211d442f52ce795a3eebd055a0ef51b0d Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* QGuiApplication: use translation-based layout direction unless explicitly setVolker Hilsheimer2022-02-241-12/+25
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The stored layout direction used to get changed during initialization to what was auto-detected based on the translation. Changing the translation then overwrote that stored value, even if an explicit call to setLayoutDirection was made by the application. Calling QGuiApplication::setLayoutDirection(Auto) has so far been a no-op. Change this logic so that the stored layout direction continues to be LayoutDirectionAuto also if it's set based on auto-detection, and only overwrite it when explicitly called with a non-Auto value. This way, applications can set a layout direction that stays unchanged even when translators are installed. Add test coverage that uses a QTranslator. In practice, this is not a change of behavior, unless applications called setLayoutDirection(Auto) (which is no longer a no-op), or called setLayoutDirection() and then installed a translator and expected the translator's layout direction to come into effect in spite of the explicit setting. [ChangeLog][Gui][QGuiApplication] Calling setLayoutDirection with a non- auto value now disables the auto-detection based on installed translators. Applications that explicitly set a layout direction and also want translators installed afterwards to take effect should reset the layout direction to Auto, which is now no longer a no-op. Fixes: QTBUG-100632 Pick-to: 6.3 Change-Id: I1fdcebd43a9b1b468ff95bf15f53f441bb214e08 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Make QGuiApplicationPrivate::lastCursorPosition.toPoint() safe to useShawn Rutledge2022-02-221-2/+11
| | | | | | | | | | | | | | | | | | | QGuiApplicationPrivate::lastCursorPosition is initialized with qInf(); so before Qt has seen a mouse move event, attempting to convert to QPoint is an error. It's best to have one place where we do the qIsInf() check rather than several (and otherwise prefer using the QPointF as-is rather than converting to QPoint at all). Introduce a helper class that contains a QPointF, and provides a safe conversion to QPoint, as well as simple accessors for clients using QPointF. Fixes: QTBUG-52472 Task-number: QTBUG-45045 Change-Id: I83fad1bfb658e03fa876344552f1d5bb751d9f81 Pick-to: 6.2 6.3 Reviewed-by: Marc Mutz <marc.mutz@qt.io> Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* Convert Vulkan instance setup from Qt Quick into a Gui helperLaszlo Agocs2022-02-151-0/+8
| | | | | | | | | Make it possible to reuse what's in QSGRhiSupport from other modules as well. Both Gui (texture-based widget/backingstore composition) and Multimedia are potential users of this in the future. Change-Id: I1b50cc5efd6811e9bc95f6287b9576931d4bcc44 Reviewed-by: Christian Strømme <christian.stromme@qt.io>
* Core: Remove 'properties' featureKai Köhne2022-02-141-2/+0
| | | | | | | | | | | | | Even QtCore alone cannot be built without the properties feature since Qt 5.5. While fixing this is easy, other modules like dbus, networking are also using QObject::property() and friends liberally. All in all I doubt that anybody will miss the feature (otherwise it would have been fixed in the last decade). Change-Id: Iaf3cc20bda54ee2ff3b809fac8fa82b94ecc88c0 Reviewed-by: Lars Knoll <lars.knoll@qt.io> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* QGuiAppPrivate::processMouseEvent: don't assume eventpoint didn't moveShawn Rutledge2022-02-041-5/+9
| | | | | | | | | | | | | | | | | | | During delivery of a pointer event, another type might be synthesized from it; and we are not yet "done" with all access to the original event until the delivery of the synthesized event is completed. Further, there could be a nested event loop if exec() is called on a dialog. If QPointingDevicePrivate::pointById() causes activePoints to grow (for example if we handle a fresh incoming touch event in the nested event loop), reallocation could cause the persistentPoint reference near the top of processMouseEvent() to be dangling by the time we get to the bottom; so we need to call queryPointById() again to be sure to get the persistent QEventPoint that is actually used in the current mouse event to ungrab. Fixes: QTBUG-97157 Pick-to: 6.2 6.3 Change-Id: Ib3b90eef5db691675b03474fd75981e972d11d2d Reviewed-by: Marc Mutz <marc.mutz@qt.io>
* QGuiApplication: invert meaning of qt_is_gui_usedMarc Mutz2022-02-021-1/+1
| | | | | | | | | | | | | | | | | | The default value was true, which is non-zero, forcing the variable out of the BSS and into the DATA segment. Fix by inverting the meaning so the default value can be false. Since qt_is_gui_unused sounds a bit complicated, however, take a cue from the variable's only writer and rename it qt_is_tty_app. Pick-to: 6.3 Change-Id: I198e9786f7e71178d69fecb5179287bf39b3a1d6 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* QGuiApplication: constant-initialize lastCursorPositionMarc Mutz2022-02-011-2/+2
| | | | | | | | | | | | | Because we used (exported) qInf() to initialize static QPointF QGuiApplicationPrivate::lastCursorPosition, the initialization was done at runtime. Fix by using qt_inf(), which is inline and constexpr. Pick-to: 6.3 6.2 5.15 Change-Id: I8b07c6c8bf1f644eaa88f2f33166045726915725 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* evdev: Prevent race condition in touch events processingJungi Byun2022-01-261-0/+3
| | | | | | | | | | | | | | | | | Unlike other input devices, touch devices are managed by corresponding handler threads which are not the main thread. InputEvent that is inherited by TouchEvent has a constant pointer member for device, but in touch events case, handler threads may destroy the device which is pointed by events while processing these events in main thread, and this may cause critical potential issues such as crash. In order to prevent this race condition, move device of QEvdevTouchScreenHandler into main thread and delete this device later if QGuiApplication instance exists when handler thread quits, and check event's device is valid when processing touch events. Change-Id: I02583238d97d768abcc544ee882160eda3178282 Reviewed-by: Elvis Lee <kwangwoong.lee@lge.com> Reviewed-by: Shawn Rutledge <shawn.rutledge@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>
* QGuiApplication: port the last user of QMutableEventPoint::from()Marc Mutz2022-01-141-14/+16
| | | | | | | | | | | | ... to the new static setter API, preventing the undefined behavior that from() depended on. Remove from() and constFrom(). Task-number: QTBUG-99615 Pick-to: 6.3 Change-Id: I69c52aa286eaf51303734e42184af36815cf828a Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* QMutableEventPoint: add static overloads of settersMarc Mutz2022-01-081-5/+3
| | | | | | | | | | | | | | These overloads don't require a cast from QEventPoint to QMutableEventPoint, thus avoiding undefined behavior. Port easy users of QMutableEventPosition::(const)from() to the new API. Pick-to: 6.3 Task-number: QTBUG-99615 Change-Id: I4e9228322134ef7c712ca478ee8286466efc3585 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* QGuiApplication: remove an unneeded const_castMarc Mutz2022-01-081-1/+1
| | | | | | | | | | QPointingDevicePrivate::pointById() already returns (mutable) EventPointData*, so the eventPoint member is mutable, too. Task-number: QTBUG-99615 Pick-to: 6.3 6.2 Change-Id: Iae1e665cab4b83b63e0e693bf7c4689e99aa3bae Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* QGuiApplication: remove a use of QMutableEventPointMarc Mutz2022-01-061-1/+1
| | | | | | | | | | The 'persistentPoint' reference is never used as a QMutableEventPoint, so don't cast to it (which is UB). Pick-to: 6.3 6.2 Task-number: QTBUG-99615 Change-Id: I7fdfb2427a09d691242bf1fa28e202ba326ea678 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* QGuiApplication: properly decode path command-line argumentsThiago Macieira2021-11-101-2/+2
| | | | | | | | | Using QFile::decodeName, not QString::fromLocal8Bit. Pick-to: 6.2 Change-Id: Ice04365c72984d07a64dfffd16b47dcbfee23341 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io> Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Centralize maybeLastWindowClosed checking in QWindowTor Arne Vestbø2021-10-201-18/+5
| | | | | | | | | | | | | | | | | Instead of plumbing QWidgetWindow close events via handleCloseEvent, we just implement closeEvent directly. This allows QWindow do save the state of the window/widget before the close event, so that we know whether we should trigger lastWindowClosed handling, even if the window was deleted as a result of the close event. This also relieves QGuiApplication and QApplication from dealing with the close logic in their notify functions, so that these functions can focus on the propagation of events -- not how the event is handled. Change-Id: I8b586b53a53b1df1d8630c1acb635c60f191bb4b Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Decouple quitOnLastWindowClosed from quitLockEnabledTor Arne Vestbø2021-10-181-6/+11
| | | | | | | | | | | | | | | | | | | In a512e210ac5b032c5fc2edf1ddf72e5a414485fda512e21 quitOnLastWindowClosed was changed to be implemented in terms of quitLockEnabled, but without any documentation to that end. Although the two features are similar (automatic quit under certain conditions), and interact, it doesn't make sense to overlap them until we actually expose them as a single property (automaticQuit e.g.) The logic for determining whether we can can quit automatically has been refactored to take both properties into account, on both a Core and Gui level. The call sites still need to check the individual properties to determine whether to activate automatic quit for that particular code path. Change-Id: I38c3e8cb30db373ea73dd45f150e5048c0db2f4d Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Deduplicate lastWindowClosed handlingTor Arne Vestbø2021-10-161-26/+24
| | | | | | | | | | | | | | | | | | | | | | | Whenever a window was closed, we had logic to check if it was the last window, and if so emitted lastWindowClosed and then tried to quit the application. But the automatic quit process also checked if there were any remaining windows, as this process could be triggered as a result of a QEventLoopLocker going out of scope. The two paths now share the same logic for determining if there are any remaining windows. The docs have been updated to reflect the original intent of the logic, dealing only with primary windows (top levels without a transient parent). This was how both the original code paths implemented their logic. For historical reasons the Qt::WA_QuitOnClose attribute is closely tied to the lastWindowClosed signal, and isn't merely limited to controlling whether we try an automatic quit when the last window closes. For now this behavior has been kept, but the docs have been updated to clarify how the attribute is handled in practice. Change-Id: If3d06b065236aad2e59e9091cac3146bc4cf79f6 Reviewed-by: Doris Verria <doris.verria@qt.io> Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Remove unneeded function QGuiApplicationPrivate::emitLastWindowClosedTor Arne Vestbø2021-10-131-8/+2
| | | | | | | | It only has a single call site nowadays. Change-Id: I6f486dec51f76e1fb231fb7276bc8c856885bee1 Reviewed-by: Doris Verria <doris.verria@qt.io> Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* gui: Fix typos in documentationJonas Kvinge2021-10-121-2/+2
| | | | | | Pick-to: 5.15 6.2 Change-Id: I533f5a55cd0cd60a76990b552d7dab51a301ac1c Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
* Remove conditioning on Android embeddedEdward Welbourne2021-09-171-3/+3
| | | | | | | | It is no longer handled separately from Android. This effectively reverts commit 6d50f746fe05a7008b63818e77784dd0c99270a1 Change-Id: Ic2d75b8c5a09895810913311ab2fe3355d4d2983 Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
* Deduplicate maybeQuitOnLastWindowClosed handlingTor Arne Vestbø2021-09-171-3/+27
| | | | | | | | | | | | | | | | | | The functionality now lives in QGuiApplication, and is triggered by QGuiApplication and QApplication after dispatching the close event to the window. The slight difference between how a Qt GUI and Qt Widget app determines if a window should contribute to the close-on-quit behavior has been abstracted into a QWindowPrivate helper. The additional checks that were in place for skipping out of the whole maybeQuitOnLastWindowClosed machinery have been kept. Task-number: QTBUG-53286 Change-Id: I81bd474755f9adb3a2b082621e5ecaa1c4726808 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Fix QGuiApplication command line options documentation for X11Tor Arne Vestbø2021-09-171-3/+3
| | | | | | | Fixes: QTBUG-96600 Pick-to: 6.2 5.15 Change-Id: Ic3670b952d97270cce4f0a8df8bba79e934e4a6d Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Use wayland platform plugin on GNOME wayland sessions by defaultJan Grulich2021-09-091-15/+1
| | | | | | | | | | | Qt wayland platform plugin has improved quite a lot and it is now pretty much usable on Gnome. It also improves user experience a lot on HiDPI displays. Pick-to: 6.2 Change-Id: I943e0bb969f384bdc3c603e290ce9c8358b70f63 Reviewed-by: Aleix Pol Gonzalez <aleixpol@kde.org> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QGuiApplication: move two static variables from DATA to BSSMarc Mutz2021-08-101-2/+2
| | | | | | | | | | | | | | | | | The {mouse,touch}DoubleXDistance variables were initialized to -1, which forces them into the DATA segments. But this value is completely unused, since these variables are also set in initThemeHints(), called from QGuiApplicationPrivate::init(), before their only user, QGuiApplicationPrivate::processMouseEvent(), can possibly execute. By changing the default value to 0, then, we allow the compiler to place these variables into the BSS segment. Change-Id: I86144559ee2410b844f70a4f2499c8d3140d14cf Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* Add native interface for X11 application, exposing display and connectionTor Arne Vestbø2021-08-061-0/+17
| | | | | | | | | | | | | | | | | | | | | The major use-case of the now private QX11Info from Qt X11 Extras was getting hold of the Xlib display and XCB connection, for example in KDE: https://lxr.kde.org/search?%21v=kf5-qt5&_filestring=&_string=QX11Info A new native interface for QGuiApplication has now been added that exposes these two properties, e.g.: if (auto *x11App = app.nativeInterface<QX11Application>()) qDebug() << x11App->display() << x11App->connection(); To avoid type clashes one of the enum values of QXcbNativeInterface's ResourceType had to be renamed. Pick-to: 6.2 Task-number: QTBUG-93633 Change-Id: I2e366a2bb88bd3965ac6172ad000ae32209f43e7 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Improve WM_DPICHANGED handlingMorten Johan Sørvig2021-08-061-1/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Resize QPlatformWindow on DPI change, so that QWindow size can stay approximately constant. For example, a 100x100 QWindow at 100% scaling will have a 100x100 QPlatformWindow. If the scaling is changed to 200% then the QPlatformWindow is resized to 200x200, while the size of the QWindow stays at at 100x100. In practice the QWindow size will also change slightly, due to inaccuracies in how we adjust for the size of the non-client window area. This will be addressed in a later commit. We can get DPI change independently of screen change, so no resizing should happen in screen change events. Disable the resize code in QGuiApplication for Q_OS_WIN, and remove the WithinDpiChanged flag. The new flow for handling DPI change is: 1) Send screen change (if any), so that the correct screen will be used when calculating scale factors during the following resize. 2) Resize the native window, which will trigger geometry change events, possibly also for the QWindow. 3) Resize child windows; WM_DPICHANGED is sent to top-level windows only. Fixes: QTBUG-89294 Pick-to: 6.2 Change-Id: I0e2d44bae72d20ebdafc3d410db7be9964ad851b Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
* Doc: Ensure deprecated APIs in Gui are documented as suchNico Vertriest2021-07-261-2/+2
| | | | | | | | | | | Added missing #if-ery and deprecation macros to a QFont constructor that was only documented as deprecated. Fixes: QTBUG-94521 Fixes: QTBUG-95310 Pick-to: 6.2 6.1 Change-Id: I3d0418a3f7dca191a9068cc22627fe4deb7c53c5 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* Use member function instead of template function to resolve native interfaceTor Arne Vestbø2021-07-171-3/+2
| | | | | | | | | | | | | | The use of a freestanding function is not needed now that the name doesn't alias the nativeInterface accessor function, and was just adding complexity to the machinery. People not familiar with the code will have an easier time following the flow through the helper member function, and we no longer need to declare our own export macros. Pick-to: 6.2 Change-Id: I17530b7e89939cfc19ab8ffaa076b7129ae02dcf Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Rename QNativeGestureEvent::deltas() to delta(); clarify docsShawn Rutledge2021-07-141-1/+1
| | | | | | | | | | | | | | | | | 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>
* QColorTrcLut: hold in shared_ptrMarc Mutz2021-07-121-8/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | ... instead of raw pointers or QSharedPointer. Raw pointers are, of course, a no-no in modern code. In particular, when the result is then held in shared_ptr or QSharedPointer, make_shared or QSharedPointer::create() should be used to reduce number of memory allocations. Since this is private API, we're free to use std::shared_ptr, which does only half the atomic operations on copies, compared to QSharedPointer, so is more efficient. For either make_shared or QSharedPointer::create(), we need to work around the private ctor, which we do by inheriting a member-function local class from QColorTrcLut and make_shared'ing that. As a member-function-local class, it has access to the otherwise private parts of QColorTrcLut, including its default constructor. As a public subclass, shared_ptr has no problem performing the derived-to-base pointer adjustment in the return statement. This way, we can use make_shared even though our target's class' ctor is private. Change-Id: Icb11249b54cd5e544e692f6a0bf1f9dda1710454 Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io> Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
* Deliver WindowActivate/Deactivate events to QWindowVolker Hilsheimer2021-06-111-1/+9
| | | | | | | | | | We need those events to trigger palette color group changes in QQuickItem without having to connect every item to yet another QWindow signal. Task-number: QTBUG-93752 Pick-to: 6.2 Change-Id: I8534808cdaab828e5876f8fda31567aeb1b4272a Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* macOS: allow Qt::AA_DontShowShortcutsInContextMenus overridesVolker Hilsheimer2021-06-071-1/+4
| | | | | | | | | | | | | | | | | | | | | | | | | Following the discussion in QTBUG-69452, the resulting change in cc33dd079796437bafed8f42de7fbf8f17d19ec8, and the documentation of QAction::shortcutVisibleInContextMenu, the intention is that the attribute allows the overriding of the platform default. However, QAction did ask both the attribute and the platform integration, making the override impossible. Instead, ask only the attribute, but default the value of the attribute to what the platform integration provides. [ChangeLog][QtGui][QAction] The shortcutVisibleInContextMenu property defaults to the value of the Qt::AA_DontShowShortcutsInContextMenus attribute, which in turn defaults to the platform integration. To override the default, set the application attribute after instantiating QApplication, or override the default for each QAction instance. Task-number: QTBUG-73990 Pick-to: 5.15 6.1 Change-Id: Iaba330913555d93d05efe1b3965a6aea39db5554 Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io> Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* Doc: Use \deprecated instead of \obsoletePaul Wicking2021-05-261-2/+2
| | | | | | Task-number: QTBUG-93990 Change-Id: I4e512354a49dde6678ca89cabc56bc76ba666bb3 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* Type erase native interfaces via string instead of typeidTor Arne Vestbø2021-05-201-2/+2
| | | | | | | | | | The latter forces users to build with RTTI enabled, as the typeid use is in our public headers. Surprisingly this is also the case even without instantiating the relevant template. Change-Id: Icd18a2b85b250e0b77960797e5c43b7eaf9bd891 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Windows QPA: Fix dock widget drag&drop failureAndre de la Rocha2021-05-171-1/+1
| | | | | | | | | | | | | | | | | | | A previous change to fix QTBUG-85431 has caused this issue by emulating the behavior of the non-enhanced mouse event handler in a particular case, where mouse move events that did not change position were ignored. However, some of these events seem to be involved in the dock drag&drop implementation. This issue is also reproduced in pre-5.15 releases, predating the QTBUG-85431 fix, by disabling the enhanced mouse event handler by setting the QT_QPA_DISABLE_ENHANCED_MOUSE env var. However, the ignored events in the current issue seem to be non-client events only, while the QTBUG-85431 issue was related to client mouse events. So we can restrict the test added in the QTBUG-85431 fix and have both issues fixed. Fixes: QTBUG-92182 Pick-to: 5.15 6.0 6.1 Change-Id: I98c0c8597912c7f4fe58af375a5a560695a82746 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>