summaryrefslogtreecommitdiffstats
path: root/src/gui/kernel/qwindow.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Use SPDX license identifiersLucie Gérard2022-05-161-38/+2
| | | | | | | | | | | | | Replace the current license disclaimer in files by a SPDX-License-Identifier. Files that have to be modified by hand are modified. License files are organized under LICENSES directory. Task-number: QTBUG-67283 Change-Id: Id880c92784c40f3bbde861c0d93f58151c18b9f1 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Lars Knoll <lars.knoll@qt.io> Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
* 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>
* Compose render-to-texture widgets through QRhiLaszlo Agocs2022-03-111-7/+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>
* QWindowPrivate: de-inline dtor and ctorMarc Mutz2022-01-201-0/+6
| | | | | | | | | | | | | | It's private API, but exported, so de-inline the dtor to pin the vtable in QtGui instead of potentially duplicating it in every library that uses the class. Ditto ctor, but that's just code hygiene: we don't want the code to be duplicated across all users. Pick-to: 6.3 Task-number: QTBUG-45582 Change-Id: I91ea38be20fc67795466a68ca5721837255b33a0 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* QWindow: Remove unnecessary castVolker Hilsheimer2022-01-141-2/+1
| | | | | | | | | We already have a QMouseEvent, don't static_cast the QEvent again to the parent-class of QMouseEvent. Pick-to: 6.3 6.2 Change-Id: Ifd8a5a82d0a8ded564a68ec4f3ae877886c6e1c7 Reviewed-by: Marc Mutz <marc.mutz@qt.io>
* QWindow: fix UB (invalid static_cast)Marc Mutz2022-01-141-1/+6
| | | | | | | | | | | | | | | | | | | Do the cast to QMouseEvent only after we determined that it's actually a QMouseEvent. Says ubsan: src/gui/kernel/qwindow.cpp:2558:27: runtime error: downcast of address 0x7fffca0e5af0 which does not point to an object of type 'QMouseEvent' 0x7fffca0e5af0: note: object is of type 'QShowEvent' ff 7f 00 00 b0 09 01 b8 61 7f 00 00 11 00 00 00 00 00 00 00 b3 8a b5 41 00 00 00 00 80 50 5a cc ^~~~~~~~~~~~~~~~~~~~~~~ vptr for 'QShowEvent' Only cast _after_ determining that `ev` is-a mouse event. Amends 3d71c4b740d23d5c3f380f495990f35ea17dc2a0. Pick-to: 6.3 6.2 Change-Id: I8455c998e2f4390a1483c1a097eb095358963ace Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Fix qobject_cast on partially destroyed QWidget/QWindowGiuseppe D'Angelo2022-01-051-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | QWidget and QWindow use bits in QObjectPrivate to provide for a couple of shortcuts -- one in qobject_cast, and another in the isWidgetType() / isWindowType() functions in QObject. These can be optimized by simply looking at the bits, without actually doing more expensive runtime casts. These bits were set on construction, but not unset on destruction. The result was for instance that destroying a QWidget would report that the object was still a QWidget when ~QObject was reached. Fix this 1) by setting the bits only when QWidget / QWindow constructors start; 2) by resetting the bits once ~QWidget / ~QWindow are completed. Technically speaking this is not 100% correct in the presence of data members, but luckily those classes don't have any. Amend an existing test for QWidget (whose comment said exactly the opposite of what the test actually did) and add a test for QWindow. Some other code was wrongly relying on isWidgetType() returning true for destroyed QWidgets; amend it as needed. [ChangeLog][QtCore][QObject] Using qobject_cast on partially constructed or destroyed QWidget/QWindow instances now yields correct results. Similarly, using the convenience isWidgetType() / isWindowType() functions now correctly return false on such instances. Before, qobject_cast (and the convenience functions) would erroneously report that a given object was a QWidget (resp. QWindow) even during that object's construction (before QObject's constructor had completed) or destruction (after QWidget's (resp. QWindow's) destructors had been completed). This was semantically wrong and inconsistent with other ways of gathering runtime type information regarding such an object (e.g. dynamic_cast, obj->metaObject()->className() and so on). Pick-to: 6.3 Change-Id: Ic45a887951755a9d1a3b838590f1e9f2c4ae6e92 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Marc Mutz <marc.mutz@qt.io> Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* QWindow: use std::exchange when ... exchanging valuesMarc Mutz2021-12-301-3/+1
| | | | | | | | | Replaces a three-liner with a more elegant, idiomatic one-liner. Pick-to: 6.3 Change-Id: I57fbe5d808dffa44f6fceffb97c47f0c84ccd3df Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* QWindowPrivate: fix inconsistent inline on some methodsMarc Mutz2021-12-301-2/+2
| | | | | | | | | | | Two functions' implementations were marked as inline, when their definitons weren't. This is non-sensical, bordering on dangerous, so remove the inline keyword. Pick-to: 6.3 6.2 5.15 Change-Id: Iece21f9552aede273fa1f5a7aef0c94307fa5142 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* Remove unused statements in QWindowDavid Skoland2021-10-261-2/+0
| | | | | Change-Id: I91f0d23d22923f7c2b8c9099371288d226d541c6 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Centralize maybeLastWindowClosed checking in QWindowTor Arne Vestbø2021-10-201-3/+23
| | | | | | | | | | | | | | | | | 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>
* Prevent recursive calls to QWindow::closeTor Arne Vestbø2021-10-181-0/+2
| | | | | | | | | QWidget will call close() in its destructor, which we might end up in if a user deletes the widget in the closeEvent. Pick-to: 6.2 Change-Id: I39684aec0ca130033dad60f2bbf823364a5edcec Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Deduplicate lastWindowClosed handlingTor Arne Vestbø2021-10-161-7/+16
| | | | | | | | | | | | | | | | | | | | | | | 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>
* Fix high DPI position of foreign child windows on WindowsJoerg Bornemann2021-10-151-1/+2
| | | | | | | | | | | | | | | | | | | | Suppose you have a child window that is a foreign window. In the bug report's example it's a QAxWidget that wraps the Windows Media Player. This means, we have a non-top-level QWindow with a platformWindow assigned. If windows:dpiawareness is set to 1 (system-DPI aware) and the window is displayed on a screen with origin != (0, 0), then we called QPlatformWindow::setGeometry with a position in native coordinates. This moved the child window outside of the visible area. Fix this by calling QHighDpi::toNativeWindowGeometry instead of QHighDpi::toNativePixels. The former function takes child windows properly into account. Pick-to: 6.2 Fixes: QTBUG-96114 Change-Id: Ibb0f844b10aece8ede99cb34289c0430ac283fa0 Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
* Call QWidget close handling in QWidget::close for non-toplevel native widgetsDoris Verria2021-10-141-1/+1
| | | | | | | | | | | | | | Since commit 7ba75d0 we close the QWindow in QWidget::close for native widgets and trigger the closeEvent in QWidgetWindow. However, if the widget's window handle is not a top level window, QWindow::close() will not close the window, failing in this way to deliver the closeEvent and call the close handling in QWidgetPrivate::handleClose. To fix, call handleClose() from QWidget::close for such widgets. Task-number: QTBUG-74606 Pick-to: 6.2 Change-Id: Ied342eced3340aaf19b5443762935b1a5fc5c27b Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* gui: Fix typos in documentationJonas Kvinge2021-10-121-1/+1
| | | | | | Pick-to: 5.15 6.2 Change-Id: I533f5a55cd0cd60a76990b552d7dab51a301ac1c Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
* gui: Fix typos in source code commentsJonas Kvinge2021-10-121-2/+2
| | | | | | Pick-to: 5.15 6.2 Change-Id: Ie53e5542a8f93856470982939ecd8ec90b323d69 Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
* Deduplicate maybeQuitOnLastWindowClosed handlingTor Arne Vestbø2021-09-171-38/+13
| | | | | | | | | | | | | | | | | | 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>
* Use QHighDpi::toNativeWindowGeometry()Morten Sørvig2021-09-151-7/+1
| | | | | | | | | This function implements the isTopLevel() logic, which we now don’t have to duplicate at each call site. Change-Id: Ic8b857aa7cd3c3c23d5e950d9f50b66c81ba3ccf Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io> Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* Clear up QWindow::isActive() documentationTor Arne Vestbø2021-09-081-1/+3
| | | | | | | | | | The isActive function does not determine if a window should be active, but whether it is currently active. The way the documentation was phrased may have lead people to believe the former. Pick-to: 6.2 6.2.0 5.15 Change-Id: I05a4cb3d8784a2fefa24bdd42ea96cfdae22b9d1 Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
* Fix segfault when closing widget and destroying window in QDialog::doneVolker Hilsheimer2021-09-061-3/+7
| | | | | | | | | | | | On OpenSUSE we seem to get an Enter event after or while the QWindow is closed, and that appears to reset the currentMouseWindow after we cleared it in QWindowPrivate::destroy. Apply a workaround similar to the focus_window to make sure that currentMouseWindow and currentMousePressWindow don't point to destroyed objects. Pick-to: 6.2 Change-Id: I61afdaa7d8d1d437058624012319460be2f2567f Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* Doc: add more notes about full screen windows on macOSVolker Hilsheimer2021-09-031-0/+3
| | | | | | | Fixes: QTBUG-68069 Pick-to: 6.2 5.15 Change-Id: I8fc99f708cfa19a9c8cc8d13f6889549c79dd3b3 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* Doc: add note that hiding a window doesn't close a full screen spaceVolker Hilsheimer2021-09-031-0/+7
| | | | | | | Fixes: QTBUG-52450 Pick-to: 6.2 5.15 Change-Id: I3f819bac470b5a883a74fb58f6fa2d27740eaaf2 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* QWidget: close the QWindow in QWidget::closeVolker Hilsheimer2021-09-021-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | We want to close the window, end full screen mode on macOS, and free platform resources. This is all done by QWindow::close. QWindow::close closes the platform window, triggering a closeEvent to QWidgetWindow, which then calls QWidgetPrivate::close_helper. This way, closing a window via QWidget::close, QWindow::close, or interactively by the user are all equivalent. The QCloseEvent generated by the widget needs to be spontaneous for window-system generated events (i.e. the user clicked the close button), and non-spontaneous if the window closes because of a call to QWindow::close. To keep track of whether the event originated in an explicit call to QWindow::close, add a boolean to the QWindowPrivate. Add a test case that verifies that the window resources is destroyed, and that events are delivered as they should. Done-with: Morten Johan Sørvig <morten.sorvig@qt.io> Fixes: QTBUG-46701 Pick-to: 6.2 Change-Id: Iacb6a2c8d5e880b16b0c8f0c9257ed94bed36f5b Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@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>
* Expose the native interfaces of QScreen/QWindowFriedemann Kleint2021-06-071-0/+26
| | | | | | | | Add the macros. Task-number: QTBUG-84220 Change-Id: Ica23b9e4d5c1ca072acb5356e6f2be28d5199fa6 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* QWindow: synthesize a QContextMenuEvent from relevant mouse eventsVolker Hilsheimer2021-05-061-0/+30
| | | | | | | | | | | | | | | QWindow receives keyboard originated context menu events, so it should also receive events originating from a right-button mouse event. Remove the incorrect statement about the special acceptance flag for context menu events. There is no such thing, the event gets delievered after the corresponding mouse press/release event. Fixes: QTBUG-59988 Task-number: QTBUG-93486 Change-Id: I148310440604e74f600932cc1898fa152c483a61 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* Remove Qt6 switches from QtGuiAllan Sandfeld Jensen2021-05-051-4/+0
| | | | | | | Removing now dead code Change-Id: I021539da6517fdb8443f8ae9431fc172b7910cfc Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
* Set QGuiApplicationPrivate variables after platform window is destroyedAndy Shaw2021-04-081-11/+11
| | | | | | | | | | | | | By setting these variables after the platform window has been destroyed, it will enable any platform specific code to handle changes in terms of focus and so on before the destruction of the window changes these directly. For example, this will prevent a problem with iOS where it keeps track of the current focus object as the signal indicating that the change to focus will still be emitted. This is before the variable is set to nullptr if there is no parent window. Change-Id: Ie540c10760d06dc62e163ccf6f6edea200b43bbf Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* Clarify QWindowPrivate::maybeQuitOnLastWindowClosedTor Arne Vestbø2020-12-171-3/+3
| | | | | | | | | | | | | We only need to check QGuiApplication::quitOnLastWindowClosed() at the point where we've actually concluded that the last window was closed. Checking for !q->parent() was redundant, as we were already exiting early when !q->isTopLevel(). Pick-to: 6.0 5.15 Change-Id: I934e186d707361b31d19692c04d2e17b7ba0f49e Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
* Doc: Fix documentation warnings for Qt GUITopi Reinio2020-11-191-1/+1
| | | | | | | | | | | | | | | - Remove obsolete dependencies and references. - Restore previously deleted snippet code referenced in richtext.qdoc. - Add widgets snippets path to exampledirs; some classes were moved from QtWidgets to QtGUI and related \snippet commands were broken. - Mark internal functions under QNativeInterface::Private as \internal. Task-number: QTBUG-86295 Change-Id: I9c165c860c7191dac65972d702698a1745bff77f Reviewed-by: Paul Wicking <paul.wicking@qt.io>
* Adjust code format, add space after 'if'Zhang Sheng2020-11-161-1/+1
| | | | | | Change-Id: Ice081c891ff7f4b766f49dd4bd5cf18c30237acf Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io> Reviewed-by: hjk <hjk@qt.io>
* Change terminology to "look and feel"Jerome Pasion2020-10-291-1/+1
| | | | | | | | -should be "look and feel" Task-number: QTBUG-88010 Change-Id: Icd71c84e2331faa317a228cdbaaa82e7598b781f Reviewed-by: Paul Wicking <paul.wicking@qt.io>
* high-dpi: Re-implement mapToGlobal and mapFromGlobalMorten Johan Sørvig2020-10-201-6/+22
| | | | | | | | | | | | | | | | | | | | (This code is required to handle corner cases such as a QWindow covering multiple screens, where the normal code path does not give correct results.) Move the map[to|from]Global implementation from qhighdpiscaling.cpp, and implement it in terms of [to|from]NativeGlobalPosition. These functions implement the required screenAt()-type searching. The implementation strategy for both mapping functions is to first map to the native coordinate system, perform the globalPos addition or subtraction, and then map the result back to device independent coordinates. Task-number: QTBUG-81695 Change-Id: I44e9e68651634650964e839b1e564b50f434553f Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io> Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
* high-dpi: Set screen on QWindow::setGeometry()Morten Johan Sørvig2020-10-201-1/+11
| | | | | | | | | | | | | | | Keep (requested) geometry and screen in sync, which is required for correct high-dpi scaling. The platform plugin can still override with new geometry (and screen), as usual. This has previously been fixed/worked around for QDialog, see QTBUG-52735. That fix can now be removed in favor of this change in QWindow. Change-Id: Ieadb1bfee5fb966c5c2052e9daa5ba124a87f3cd Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
* QHighDpi: window geometry scaling functionsMorten Johan Sørvig2020-10-201-6/+4
| | | | | | | | | | | | | | | | | | Add functions which scales window geometry: framNativeWindowGeometry() toNativeWindowGeometry() These correctly handles top-level and child windows, where top-level window positions scale around the screen origin while child window positions scale around (0, 0). Modify call cites to use the new functions. We no longer need the isTopLevel checks at the call site. Change-Id: I0158672d46a3f52dfc7d37d021fc5cebd7859200 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io> Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
* Introduce QWindow::paintEvent with QPA plumbingTor Arne Vestbø2020-08-261-13/+34
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The explicit paint event on QtGui and QPA level allows us to untangle the expose event, which today has at least 3 different meanings. It also allows us to follow the platform more closely in its semantics of when painting can happen. On some platforms a paint can come in before a window is exposed, e.g. to prepare the first frame. On others a paint can come in after a window has been de-exposed, to save a snapshot of the window for use in an application switcher or similar. The expose keeps its semantics of being a barrier signaling that the application can now render at will, for example in a threaded render loop. There are two compatibility code paths in this patch: 1. For platform plugins that do not yet report the PaintEvents capability, QtGui will synthesize paint events on the platform's behalf, based on the existing expose events coming from the platform. 2. For applications that do not yet implement paintEvent, QtGui will send expose events instead, ensuring the same behavior as before. For now none of the platform plugins deliver paint events natively, so the first compatibility code path is always active. Task-numnber: QTBUG-82676 Change-Id: I0fbe0d4cf451d6a1f07f5eab8d376a6c8a53ce8c Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
* Add fixme note to QWindowPrivate::setVisible about visibility during createTor Arne Vestbø2020-07-201-1/+7
| | | | | Change-Id: I71cb5b560538887f85d92178ff17eaaecaf06904 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Change QWindow/QWidget::map(To/From)(Global/Parent) to operate in floatFriedemann Kleint2020-07-141-9/+26
| | | | | | | | | | | | | | | Change the functions to operate in float and add the QPoint versions as overload calling them. This is more in-line with the event accessors using float and allows for removing some workarounds using a delta when converting touch points. Leave QPlatformWindow::map(To/From)Global() as is for now and add helpers for float. Change-Id: I2d46b8dbda8adff26539e358074b55073dc80b6f Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io> Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Add ; to Q_UNUSEDLars Schmertmann2020-07-071-1/+1
| | | | | | | | This is required to remove the ; from the macro with Qt 6. Task-number: QTBUG-82978 Change-Id: I3f0b6717956ca8fa486bed9817b89dfa19f5e0e1 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
* Merge QWindow::parent overloadsVolker Hilsheimer2020-06-081-11/+0
| | | | | Change-Id: Ibec0f41de16694c38cf24fcdd4eeba74df62a1dd Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* Add virtual QWindow::closeEvent handlerVolker Hilsheimer2020-05-051-1/+15
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The default implementation does nothing; the processing of accepted close events remains in the QWidget::event handler, so that subclasses don't have to call the super class in order to free window system resources and emit lastWindowClosed signals. QWidgetWindow::event is reimplemented to handle QEvent::Close as well, calling QWidgetPrivate::close_helper, which then delivers a separate QCloseEvent to the widget. The order of execution for widgets is after this change: 1) QWidgetWindow::event 2) QWidgetWindow::handleCloseEvent (calls QWidget::event/closeEvent) 3) QWindow::event 4) QWindow::closeEvent <- does nothing, not overridden 5) default cleanup handling in QWindow::event and for Qt Quick after the corresponding change in qtdeclarative: 1) QQuickWindow::event 2) QWindow::event 3) QQuickWindow::closeEvent <- emits closed 4) default cleanup handling in QWindow::event [ChangeLog][QtGui][QWindow] closeEvent has been added as a virtual function. Task-number: QTBUG-31019 Change-Id: I201f5ee9c6a73b949986648e3bd288d2c7898f28 Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io> Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* Prevent asserts in certain QWindow re-creation casesLaszlo Agocs2020-04-211-2/+7
| | | | | | | | | | | | | | | | | | | | Amends 402efef57bb6a04ad778d3139100becc2cba31eb. The original patch has a problem, namely that it directly calls QPlatformWindow::requestUpdate() instead of going through QWindow::requestUpdate(). As there is a chance that an update gets scheduled between the creation of the QPlatformWindow and this extra, optional invocation of requestUpdate() at the end of QWindow::create(), this becomes quite unsafe because QPlatformWindow, unlike QWindow, is not graceful: it will just assert if there is a pending update still. Solve the whole thing by storing the updateRequestPending flag of QWindowPrivate, then resetting it, and then going through the safe, public QWindow::requestUpdate() when our copy of the flag says so. Task-number: QTBUG-81400 Task-number: QTBUG-70957 Pick-to: 5.15 Change-Id: I99aedfae3928b75301b46a4666c169e657ff8079 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* Merge remote-tracking branch 'origin/5.14' into 5.15Qt Forward Merge Bot2020-02-291-3/+7
|\ | | | | | | Change-Id: I851c0328c3c38ea67b5ad115b205ac6a1262706e
| * Fix geometry handling for native child windowsFriedemann Kleint2020-02-281-3/+7
| | | | | | | | | | | | | | | | | | | | | | | | Don't move the native child window position for native child windows. Initial-patch-by: Błażej Szczygieł <spaz16@wp.pl> Task-number: QTBUG-82312 Fixes: QTBUG-79166 Change-Id: I117ef08da13c8e90ff60cf034126c9efdc17b836 Reviewed-by: Błażej Szczygieł <mumei6102@gmail.com> Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io> Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
* | Add QWindow::startSystemMove and startSystemResizeJohan Klokkhammer Helsing2020-01-281-1/+71
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This can be used to create custom client side window decorations. Refactors the xcb implementation to use edges instead of corners and we now use the last mouse position for `root_x` and `root_y` in the `_NET_WM_MOVERESIZE` event. Touch has also been changed, so just pick a point that's currently being pressed. The workaround for QTBUG-69716 has now been moved to QSizeGrip, as the comment in the bug report says that it should ideally be fixed at the widget level. On Windows, we no longer abort when GetSystemMenu returns false. I assume this code was added to check whether the window didn't have any decorations and not resize in that case. However, since the point of this patch is to let windows without native decorations resize/move, it makes most sense to remove the check. Adds a manual test, which calls QWindow::startSystemMove and startSystemResize on touch and mouse events. [ChangeLog][QtGui] Added API for starting interactive window resize and move operations handled by the system. Fixes: QTBUG-73011 Change-Id: I7e47a0b2cff182af71d3d479d6e3746f08ea30aa Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* | Merge remote-tracking branch 'origin/5.14' into 5.15Qt Forward Merge Bot2020-01-181-1/+0
|\| | | | | | | Change-Id: I12148e7b20bcdb72d9b328035d528c99633b1e92
| * Doc: Fix qdoc compilation errors qtbaseNico Vertriest2020-01-171-1/+0
| | | | | | | | | | | | Task-number: QTBUG-79824 Change-Id: I5a39525e3e735415ba96e2d585c5de754deb15de Reviewed-by: Venugopal Shivashankar <Venugopal.Shivashankar@qt.io>
* | Merge remote-tracking branch 'origin/5.14' into 5.15Liang Qi2019-12-161-1/+1
|\| | | | | | | | | | | | | | | Conflicts: src/network/ssl/qsslsocket.cpp src/widgets/kernel/qapplication.cpp Change-Id: Ib7421cc2df59d0969f89b3fbd65a17ea76ffef3b