summaryrefslogtreecommitdiffstats
path: root/src/gui/kernel
Commit message (Collapse)AuthorAgeFilesLines
* QKeySequence: Add support for Eject and Clear glyphs on macOSLaszlo Papp2022-05-181-0/+2
| | | | | | | | | Presumably, these glyphs have not been needed thus far, hence missing from the corresponding list. Pick-to: 6.2 6.3 Change-Id: I72cb8811f087c40229105f65d52a9c1048d9f9eb Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* QKeySequence/Mac: remove NumEntries variableMarc Mutz2022-05-171-6/+3
| | | | | | | | | | | Keep it DRY. Just let the compiler figure out the size. Pick-to: 6.3 6.2 Change-Id: I2bf1c44d4e2060a9398700d16ab98d67c849814c Reviewed-by: Laszlo Papp <lpapp@kde.org> Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
* Use SPDX license identifiersLucie Gérard2022-05-16159-6052/+328
| | | | | | | | | | | | | 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>
* QKeySequence: Fix the one-off error in the mac glyph array sizeLaszlo Papp2022-05-151-2/+2
| | | | | | | | | | | | | | | | | | | | | | It seems that the size of the corresponding array in the code has a one-off error. This is now fixed. The end of the array passed to lower_bound is wrong because the hard-coded size is size + 1. However, the end is array + size. This is what lower_bound expects from an array. Or any other algorithm for that matter expecting the end of a container as an argument. This can cause issues with something like lower_bound because a potential "empty" fill is not sorted as lower_bound would expect the data structure. It could have been fixed by decreasing the size by one, however it is a more future-proof solution to avoid hard-coding the size and just use std::size(array) instead. Pick-to: 5.15 6.2 6.3 Change-Id: I1d25a5b1a80a3b2634b229e0718108ad5e7808a0 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* Fix versioning of PixelScrollKai Köhne2022-05-131-1/+1
| | | | | | | | | | \since will mark the whole enum as new in 6.2 Amends 673ed80fa42a77c Pick-to: 6.2 6.3 Change-Id: I88bd73d3bf8b0da355e3200b7a9b67fc141a2b93 Reviewed-by: Topi Reiniö <topi.reinio@qt.io>
* QtGui: includemocsMarc Mutz2022-04-2934-0/+68
| | | | | | | | | | | Including moc files directly into their classes' TU tends to improve codegen and enables extended compiler warnings, e.g. about unused private functions or fields. Pick-to: 6.3 6.2 5.15 Task-number: QTBUG-102886 Change-Id: I1945741794c25679a9d94c0d68c8642e2c823502 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* Optimize the QPalette::resolve from the other paletteJiDe Zhang2022-04-281-0/+14
| | | | | | | | | If all the palette's colors are resolved, nothing needs to be done in QPalette::resolve(const QPalette &other). Change-Id: I1573cfa5b5cd1e7eb15f3242aff6ab92e9f8c84b Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* QtGui: replace remaining uses of QLatin1String with QLatin1StringViewSona Kurazyan2022-04-283-6/+6
| | | | | | 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-2814-53/+80
| | | | | | Task-number: QTBUG-98434 Change-Id: Idcb71c1d27125333a53b6bdd3e1af0d4c66617fa Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* Fix unused variables in qtbaseAndrei Golubev2022-04-251-5/+1
| | | | | | | | | | | | | | | | | | | | | | | clang compiler recently got smarter and detects "pseudo used variable" patterns where we declare a variable and only use it in self-increments, self-decrements and other similar expressions Errors: qtbase/src/corelib/text/qlocale.cpp:3898:9: error: variable 'group_cnt' set but not used [-Werror,-Wunused-but-set-variable] int group_cnt = 0; // counts number of group chars ^ qtbase/src/corelib/text/qunicodetools.cpp:1372:21: error: variable 'uc' set but not used [-Werror,-Wunused-but-set-variable] const char16_t *uc = text + from; ^ and more of the kind Remove the ones that have no usage, mark others with [[maybe_unused]] Pick-to: 6.3 6.2 Change-Id: Ib2d0722110e3da8c39e29ec78c0ec290d064c970 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Send ThemeChange event to all windows when system theme changesTor Arne Vestbø2022-04-222-5/+6
| | | | | | | | | | | | | | | | | | | 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-212-16/+16
| | | | | | | | 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>
* QEvent: start to de-inline copy ctor and clone() of all subclassesMarc Mutz2022-04-142-345/+86
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | There's no advantage to them being inline: Absent de-virtualisation, clone() is only supposed to be called through the vtable, and the copy ctor is only supposed to be used in the implementation of clone(). And when the compiler de-virtualises, we don't want the code duplication associated with inlining. Enforce this by introducing new macros to hide the boilerplate. This fixes missing out-of-line dtors in: - QSinglePointEvent - QApplicationStateChangeEvent - QFutureCallOutEvent Wrong covariant return in: - QFutureCallOutEvent And missing clone() reimplementations in: - QCloseEvent - QIconDragEvent - QShowEvent - QHideEvent - QDragEnterEvent - QDragLeaveEvent While these don't carry extra data or members, a dynamic_cast of the result of clone() as well as using the expected covariant return value would fail: QShowEvent *e = ~~~; QShowEvent *e2 = e->clone(); // ERROR: converting QEvent* to QShowEvent* Check that reimplementing clone() is binary compatible (covariant returns may change the numerical pointer value returned, cf. https://community.kde.org/Policies/Binary_Compatibility_Issues_With_C%2B%2B). The copy-assignment operator stays inline for the time being, as the goal is to = delete it in the future. This patch covers, roughly, QtCore and QtGui. [ChangeLog][QtGui][QEvent subclasses] Fixed missing clone() reimplementations on QCloseEvent, QIconDragEvent, QShowEvent, QHideEvent, QDragEnterEvent, and QDragLeaveEvent. Task-number: QTBUG-45582 Task-number: QTBUG-97601 Change-Id: Ib8a0519dbe85a7a8da61050d48be338004dfa69a Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QtGui: stop using QLatin1Char constructor for creating char literalsSona Kurazyan2022-04-1310-35/+35
| | | | | | | | | 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>
* Guard against QWindow being deleted during close eventTor Arne Vestbø2022-04-081-2/+9
| | | | | | | | | | | The QBoolBlocker would end up using a stale d-pointer if the window was deleted during delivery of the close event. Fixes: QTBUG-102327 Pick-to: 6.3 6.2 Change-Id: I8f458581eeabf0d0f27a348ad1f926295caa3a58 Reviewed-by: Dimitrios Apostolou <jimis@qt.io> Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* doc: Warn against using the screen's refresh rate for driving animationsTor Arne Vestbø2022-04-071-0/+5
| | | | | | Pick-to: 6.2 6.3 Change-Id: Id26aae76792a4109b2ea6cca3db69ab505495d65 Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
* QtGui: sweep Q_DECLARE_METATYPE → QT_DECL_METATYPE_EXTERN [2/2]: private APIMarc Mutz2022-04-052-1/+4
| | | | | | | | | | | | | It's one of our best tools to improve compile times. Can't backport to Qt 6.2 because the macros don't exist there. Pick-to: 6.3 Task-number: QTBUG-102206 Change-Id: I80734b4d43928fce0e66329b5b897a2738db9b30 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* QtGui: sweep Q_DECLARE_METATYPE → QT_DECL_METATYPE_EXTERN [1/2]: public APIMarc Mutz2022-04-052-2/+9
| | | | | | | | | | | | | It's one of our best tools to improve compile times. Can't backport to Qt 6.3 or 6.2 because this change introduces new exported symbols. Task-number: QTBUG-102206 Change-Id: Ib8224ed60afa893744f369fe7394d27e89b66c11 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Mårten Nordheim <marten.nordheim@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-042-5/+29
| | | | | | | | 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>
* CoreText: Populate all variants of theme/system fontsTor Arne Vestbø2022-03-301-0/+1
| | | | | | | | | | | | | | | | | | | | | We populate the various QPlatformTheme::Fonts by asking the system for the preferred font for each use-case, but that just gives us a single font descriptor with a single style and weight. If the user then tweaks the font by e.g. making it bold or italic, our font database will not have any knowledge of these variants, and will fall back to another font. To fix this we ask CoreText for all variants of each of the theme fonts, so that each of the theme font families are fully populated. The preferred way to do this on macOS 10.15/iOS 13 and above is by using the font's UI design trait. This avoids asking CoreText for private fonts by family name directly, which is not supported and may result in giving us Times or another fallback font instead. Pick-to: 6.2 6.3 Change-Id: I4aa21624df62ac09a92d7ae0bc2cdde4f6ad6e5f Reviewed-by: Timur Pocheptsov <timur.pocheptsov@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>
* 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-262-40/+40
| | | | | | | | | | | | | | | | | | 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>
* QtGui: compile-optimize inline swap functionsMarc Mutz2022-03-194-5/+5
| | | | | | | | | | | | | | | | | | Instead of using the overly-generic qSwap() monster, use - qt_ptr_swap() for swapping raw pointers - member-swap for swapping smart pointers - std::swap() for swapping scalars In QtCore, this has proven to give a nice reduction in compile time for Qt users, cf. b1b0c2970e480ef460a61f37fa430dc443390358. Pick-to: 6.3 6.2 Task-number: QTBUG-97601 Change-Id: I987ff95e8751a22a4f283655d8225dd16de21178 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Fix deprecated use of QColor::setNamedColorMårten Nordheim2022-03-171-2/+2
| | | | | | | 'Use fromString() instead.' Change-Id: I4efef147a8b0486f2664fd7fe6c35a9c82479b90 Reviewed-by: Marc Mutz <marc.mutz@qt.io>
* Misc: Do not depend on transitive includesFabian Kosmale2022-03-171-3/+4
| | | | | | | | As a drive-by, remove superfluous includes from qnetworkmanagerservice.h and obey the coding conventions for includes in a few more places. Change-Id: I65b68c0cef7598d06a125e97637040392d4be9ff Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Gui: Do not depend on transitive includesFabian Kosmale2022-03-174-2/+7
| | | | | Change-Id: I27321235d9c8428de0cff1e22a618299b9e5a97f Reviewed-by: Marc Mutz <marc.mutz@qt.io>
* GUI: add ScreenWindowGrabbing capabilityLiang Qi2022-03-172-2/+8
| | | | | | | | | On Wayland, there is no protocol to do it yet. Task-number: QTBUG-100792 Task-number: QTBUG-101145 Change-Id: Id72625a8161359111a2d0f43f3215e787778ba6b Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* QAction: Add NOTIFY changed declaration to priority propertyKai Uwe Broulik2022-03-161-1/+1
| | | | | | | | | | | It already emits the signal and was merely missing the declaration. This fixes warnings about depending on non-NOTIFYable properties when binding to the priority property from QML. Pick-to: 6.3 6.2 Change-Id: Ia91ae5d00d722bdb2fc1f89671c3e7faab4b129f Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Fix deprecated use of QBA/Q*String::countMårten Nordheim2022-03-151-1/+1
| | | | | | | 'Use size() or length() instead' Change-Id: I284fce29727c4c1ec9ea38a4e8ea13a9e0af5390 Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
* gui: return first default device when seatName isNullLiang Qi2022-03-132-4/+6
| | | | | | | | | | | | | for QInputDevice::primaryKeyboard() and QPointingDevice::primaryPointingDevice(). This also reverts ae9fefe3c89fd5720ccaad0687f125e32f7c3fe6. Fixes: QTBUG-100790 Pick-to: 6.3 Change-Id: Id02f277db25f823eb29e939e25801325df8e4076 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* Compose render-to-texture widgets through QRhiLaszlo Agocs2022-03-112-11/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | QPlatformTextureList holds a QRhiTexture instead of GLuint. A QPlatformBackingStore now optionally can own a QRhi and a QRhiSwapChain for the associated window. Non-GL rendering must use this QRhi everywhere, whereas GL (QOpenGLWidget) can choose to still rely on resource sharing between contexts. A widget tells that it wants QRhi and the desired configuration in a new virtual function in QWidgetPrivate returning a QPlatformBackingStoreRhiConfig. This is evaluated (among a top-level's all children) upon create() before creating the repaint manager and the QWidgetWindow. In QOpenGLWidget what do request is obvious: it will request an OpenGL-based QRhi. QQuickWidget (or a potential future QRhiWidget) will be more interesting: it needs to honor the standard Qt Quick env.vars. and QQuickWindow APIs (or, in whatever way the user configured the QRhiWidget), and so will set up the config struct accordingly. In addition, the rhiconfig and surface type is (re)evaluated when (re)parenting a widget to a new tlw. If needed, this will now trigger a destroy - create on the tlw. This should be be safe to do in setParent. When multiple child widgets report an enabled rhiconfig, the first one (the first child encountered) wins. So e.g. attempting to have a QOpenGLWidget and a Vulkan-based QQuickWidget in the same top-level window will fail one of the widgets (it likely won't render). RasterGLSurface is no longer used by widgets. Rather, the appropriate surface type is chosen. The rhi support in the backingstore is usable without widgets as well. To make rhiFlush() functional, one needs to call setRhiConfig() after creating the QBackingStore. (like QWidget does to top-level windows) Most of the QT_NO_OPENGL ifdefs are eliminated all over the place. Everything with QRhi is unconditional code at compile time, except the actual initialization. Having to plumb the widget tlw's shareContext (or, now, the QRhi) through QWindowPrivate is no longer needed. The old approach does not scale: to implement composeAndFlush (now rhiFlush) we need more than just a QRhi object, and this way we no longer pollute everything starting from the widget level (QWidget's topextra -> QWidgetWindow -> QWindowPrivate) just to send data around. The BackingStoreOpenGLSupport interface and the QtGui - QtOpenGL split is all gone. Instead, there is a QBackingStoreDefaultCompositor in QtGui which is what the default implementations of composeAndFlush and toTexture call. (overriding composeAndFlush and co. f.ex. in eglfs should continue working mostly as-is, apart from adapting to the texture list changes and getting the native OpenGL texture id out of the QRhiTexture) As QQuickWidget is way too complicated to just port as-is, an rhi manual test (rhiwidget) is introduced as a first step, in ordewr to exercise a simple, custom render-to-texture widget that does something using a (not necessarily OpenGL-backed) QRhi and acts as fully functional QWidget (modeled after QOpenGLWidget). This can also form the foundation of a potential future QRhiWidget. It is also possible to force the QRhi-based flushing always, regardless of the presence of render-to-texture widgets. To exercise this, set the env.var. QT_WIDGETS_RHI=1. This picks a platform-specific default, and can be overridden with QT_WIDGETS_RHI_BACKEND. (in sync with Qt Quick) This can eventually be extended to query the platform plugin as well to check if the platform plugin prefers to always do flushes with a 3D API. QOpenGLWidget should work like before from the user's perspective, while internally it has to do some things differently to play nice and prevent regressions with the new rendering architecture. To exercise this better, the qopenglwidget example gets a new tab-based view (that could perhaps replace the example's main window later on?). The openglwidget manual test is made compatible with Qt 6, and gets a counterpart in form of the dockedopenglwidget manual test, which is a modified version of the cube example that features dock widgets. This is relevant in particular because render-to-texture widgets within a QDockWidget has its own specific quirks, with logic taking this into account, hence testing is essential. For existing applications there are two important consequences with this patch in place: - Once the rhi-based composition is enabled, it stays active for the lifetime of the top-level window. - Dynamically creating and parenting the first render-to-texture widget to an already created tlw will destroy and recreate the tlw (and the underlying window). The visible effects of this depend on the platform. (e.g. the window may disappear and reappear on some, whereas with other windowing systems it is not noticeable at all - this is not really different from similar situtions with reparenting or when moving windows between screens, so should be acceptable in practice) - On iOS raster windows are flushed with Metal (and rhi) from now on (previously this was through OpenGL by making flush() call composeAndFlush(). Change-Id: Id05bd0f7a26fa845f8b7ad8eedda3b0e78ab7a4e Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* Fix QWindow::mapTo|FromGlobal() for the embedded caseSergio Martins2022-03-041-2/+2
| | | | | | | | | | | | | The code didn't make much sense: - QHighDpi::fromNativeLocalPosition should not take global positions - QPlatformWindow::mapFromGlobal() should not take local positions Tested with a basic MFC window that has a QMainWindow as child (parented with QWinWidget from QtWinMigrate). Menus would be off when on a secondary screen with dpi factor > 1 Change-Id: Ib5cbf5d29ed97c786f7f7ba4e868b70cb5435239 Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
* Fix painting clipping glitches with fractional scalingEirik Aavitsland2022-03-021-4/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In QPainter, clipping can only be done on whole pixels. The various ways of specifying a clipping rectangle to the QPainter API have been inconsistent in how fractional rectangles (either specified directly, or as a result of fractional scaling) are mapped (rounded) to integer coordinates. Also, the mappings have not made sure to keep the edge-to-edge property of clip rects under scaling. This is particularly important when scaling QRegions with multiple rects, as QRegion is designed on the assumption that an area can be described as a set of edge-to-edge rects. The fix rounds a clip rect identically with a fill rect. (Indeed, a followup plan would be to merge QRasterPaintEngine's toNormalizedFillRect() with the rectangle rounding function in this commit). Notably, a QRectF clip is now interpreted the same as a QPainterPath clip describing the same area. This modifies d9cc1499954829faf9486fb72056e29f1bad58e3 Task-number: QTBUG-100329 Fixes: QTBUG-95957 Task-number: QTBUG-100343 Pick-to: 6.3 Change-Id: Iaae6464b9b17f8bf3adc69007f6ef8d623bf2c80 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@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-222-3/+25
| | | | | | | | | | | | | | | | | | | 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>
* QPA: add ButtonPressKeys ThemeHintNoah Davis2022-02-162-0/+5
| | | | | | | | | | | | Platforms should allow more than just Qt::Key_Space and Qt::Key_Select to press buttons. KDE Plasma developers want to be able to press buttons with Return/Enter. GTK allows buttons to be pressed with Return/Enter, so this should be considered the native behavior for GNOME as well. Adding this ThemeHint allows customizing the keys that can press a button via a QPlatformTheme subclass. Change-Id: I73284e9b73590fbdd0b94a0cb4557e94b3722af9 Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@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>
* Update docs for QSurface::MetalSurface to include iOSTor Arne Vestbø2022-02-151-3/+3
| | | | | | Pick-to: 6.3 6.2 Change-Id: I67fc47b3dc33960e7dfa78890d16d1e7450e30ab Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* De-duplicate vtables, 2022 editionMarc Mutz2022-02-158-0/+24
| | | | | | | | | | | | | | | | | | | This de-inlines destuctors of classes whose vtables are proven to be duplicated even within the set of Qt libraries. Since these are all private API classes, we can pick all the way back to 6.2, and we don't need the comment that the dtor must always stay empty, like for public classes. As a drive-by, also de-inline the QPaintDeviceWindowPrivate ctor. That's just code hygiene, it doesn't partake in vtable duplicating. Pick-to: 6.3 6.2 Task-number: QTBUG-45582 Change-Id: I3477063d6f42edc9a5d352c47900366fd50c3ef6 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io> Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
* 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>
* Add warning about native interface APIs to platform headersTor Arne Vestbø2022-02-093-0/+27
| | | | | | | | | Those platform specific classes are not covered by our binary/source compatibility guarantee between minor releases. Pick-to: 6.3 Change-Id: I2a69c7ea07feea62fdf9899839e47fc540f89c12 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* qmetatype: Remove left-over module association codeFabian Kosmale2022-02-091-6/+0
| | | | | | | | | Qt 6's metatype does no longer care whether the type is from Core, GUI or a user metatype. Change-Id: I4f41d44a61a9839f58b957219c2404512630587a Reviewed-by: Lars Knoll <lars.knoll@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* doc: clarify that passive-grab API is only for Qt Quick Pointer HandlersShawn Rutledge2022-02-091-4/+4
| | | | | | | | | | ...for now anyway. The plan is to have C++ API for custom handlers later on; and we'll see if we find any other "must-have" use cases. Task-number: QTBUG-68110 Pick-to: 6.2 6.3 Change-Id: I5e624a500af37797345d25bb5f54b146b13a45ca Reviewed-by: Venugopal Shivashankar <Venugopal.Shivashankar@qt.io>
* Deprecate QContextMenuEvent and QMouseEvent ctors without globalPosShawn Rutledge2022-02-052-0/+15
| | | | | | | | | | | | | As with QHoverEvent, it's better to require globalPos rather than "initialized to QCursor::pos(), which may not be appropriate" as the docs have pointed out for many years now. This removes the remaining calls to QCursor::pos() in event constructors. Task-number: QTBUG-52430 Task-number: QTBUG-69433 Task-number: QTBUG-100324 Change-Id: I076dae56f37abaad7085cc95dddee453a80a45f3 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@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>
* Add a QHoverEvent ctor taking global mouse position; deprecate the otherShawn Rutledge2022-02-032-0/+28
| | | | | | | | | | | | | | | | | The QSinglePointEvent ctor assumes that the given globalPos is correct, so it was wrong that the QHoverEvent ctor passed along a local position as global. It's better to require globalPos as an argument; and in fact it seems that everywhere we construct a QHoverEvent, global position is available, or possible to get by transformation (which is better than resorting to QCursor::pos()). Also, don't convert to QPoint: pointer events have qreal resolution and there's no reason to truncate them. Fixes: QTBUG-100324 Change-Id: I919455da36265988d3d149eb97563c9ed0d2c660 Pick-to: 6.3 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@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>