summaryrefslogtreecommitdiffstats
path: root/src/widgets/kernel
Commit message (Collapse)AuthorAgeFilesLines
* Fix QWidget::restoreGeometry when restored geometry is off screenAxel Spoerl2022-12-162-10/+67
| | | | | | | | | | | | | | | | | | | | | | | If a widget's geometry is restored to a screen, which is smaller than the one it was saved from, - the widget could appear (partly) off screen - the widget's title bar and resize handles could be inaccessible This patch refactors and documents checkRestoredGeometry. In a first step, the restored geometry's size is checked against a given screen size. It is corrected if necessary. In a second step, the restored geometry is moved inside the screen, if necessary. It makes the function a static member of QWidgetPrivate in order to expose it for auto testing and adds a respective test function to tst_QWidget. Fixes: QTBUG-77385 Fixes: QTBUG-4397 Task-number: QTBUG-69104 Pick-to: 6.5 6.4 Change-Id: I7172e27bfef86d82cd51de70b40de42e8895bae6 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* Add static_cast for QKeyEventLu YaNing2022-12-132-2/+2
| | | | | | | | Use static_cast to convert a QEvent to a QKeyEvent, replacing (QKeyEvent*)e Change-Id: I52ac3f46aec42600251cf737db2e71c04f2b45c7 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Beautify QApplication::compressEventAxel Spoerl2022-12-091-27/+41
| | | | | | | | | | | Replace if-statement to check compressable event types with a switch. Replace if / else if sequence dispatching to type specific compression code paths with a switch. Replace iterated for loop with a ranged one. Task-number: QTBUG-107808 Change-Id: I9054b625f1898fa793f78de1b477a2113a4e33f0 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* QWidget: use window device pixel ratio for metricsDavid Edmundson2022-12-081-3/+2
| | | | | | | | | | | Most code uses the window/backing store DPR, except for this path that uses the screen. On wayland it's possible to get a different ratio for the screen and window which causes some subtle rendering issues. For other platforms behavior shouldn't change. Change-Id: Ie390ba3bdfc183815df9e7e79e508d3e15d61f25 Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
* Deliver tablet events to the toplevel widget if there is no childVolker Hilsheimer2022-12-021-4/+3
| | | | | | | | | | | | | | | | | | | | | QWidgetWindow dispatched only tablet presses to the toplevel widget if no child was found at the position; other events, such as hover events, were discarded. The tabletTracking test case even documented that shortcoming in a comment. Fix that by falling back to the toplevel widget for any event. As before, only press events initialize the tablet grabbing target widget. Remove the now unneeded parent widget from the test case, and move the test class into the only test function that uses it. Amends ea615b421b76668332a3029ad31fa725b5bb9e58 and 8fd6cef3724b2d676c5f6ae235956192d85eac39. Pick-to: 6.4 Fixes: QTBUG-108747 Change-Id: I79050f1e063931e439945f64b50712dcc1ecb18c Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* Support stereoscopic rendering with QGraphicsViewKristoffer Skau2022-12-011-0/+5
| | | | | | | | | | | | | | | | This patch adds a manual test and the required work in graphicsview and qwidget private apis to support stereoscopic rendeing. Basically it works by doing the drawing in QGraphicsView::paintEvent twice, once for each buffer. This way the scene items are rendered to both buffers. There's also an update to resolvement in QOpenGLWidgetPrivate so that multisampling works correctly. [ChangeLog][Widgets][QGraphicsView] Added support for stereoscopic rendering. Task-number: QTBUG-64587 Change-Id: I20650682daa805b64fe7f0d2ba086917d3f12229 Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
* Add support for stereoscopic content in QOpenGLWidgetKristoffer Skau2022-11-282-2/+9
| | | | | | | | | | | | | | | | | Need to add the plumbing necessary to support two textures in QOpenGLWidget and use these in the backing store. The changes required on the RHI level is already done in an earlier patch. Then paintGL() needs to be called twice, once for each buffer. Also add overloads for the other functions of QOopenGLWidget where it makes sense to query for left or right buffer. Then finally create an example. [ChangeLog][Widgets][QOpenGLWidget] Added support for stereoscopic rendering. Fixes: QTBUG-64587 Change-Id: I5a5c53506dcf8a56442097290dceb7eb730d50ce Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
* Fix rhi flush eval perf. and native window problemsLaszlo Agocs2022-11-142-16/+19
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This effectively reverts a4a51f6a641f4bf0a863251d6d3e026d81de6280 while solving the problem that change intended to fix by an alternative approach: Swap the order of checks for rhi-based flushing. Checking the widgets' wishes first was a mistake. We should first check what is forced, e.g. via the env.vars. Then only move on investigating the child widget hierarchy if there was nothing specific requested. This way having a QOpenGLWidget in a window and running with QT_WIDGETS_RHI=1 QT_WIDGETS_RHI_BACKEND=vulkan will prioritize the forced request (Vulkan) and so the QOpenGLWidget will gracefully not render anything while printing the expected warning to tell what's going on. The expensive recursion plaguing the construction of larger widget hierarchies is now avoided, that should no longer take seconds due to walking the entire widget hierarchy of the top-level window every time a new widget is added to it. However, this then uncovered a set of problems concerning native child widgets. The repaint manager seems to have an obvious mistake where the usage of rhi (and so textures and whatnot) is decided based on 'widget' (which is either a top-level or a native child) instead of 'tlw' (which is the top-level with the backingstore). The usesRhiFlush flag only really matters for a real top-level, not for native child widgets. The rhi-based flushing is tied to the backingstore, and the backingstore comes from the top-level widget. Finally, make the qopenglwidget autotest to actually exercise something when it comes to QOpenGLWidgets (or their ancestors) turned native. The original code from a long time ago does not really test native child widgets, because it turns the top-level into native which is quite superfluous since the toplevel is backed by a native window (and a backingstore) anyway. Pick-to: 6.4 Task-number: QTBUG-105017 Fixes: QTBUG-108344 Fixes: QTBUG-108277 Change-Id: I1785b0ca627cf151aad06a5489f63874d787f087 Reviewed-by: Andy Nichols <andy.nichols@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* Fix focus chain with compound widgets if created out of orderVolker Hilsheimer2022-11-041-2/+29
| | | | | | | | | | | | | | | | | | | | | | When a compound widget is created not directly before its children, then another widget will be in the focus chain between the compound and the compound's first child. If one of those children is then made the focus proxy of the compound, then the widget in between becomes unreachable by tabbing. To fix this, detect that we set the focus proxy to be a descendent of the compound widget, and then move the compound widget directly in front of its first child in the focus chain. This way we can't have any gaps in the focus chain. Augment the test case with a corresponding scenario. As a drive-by, move the debug helper up in the code so that it can be easier used, and set object names on relevant widgets. Pick-to: 6.4 6.2 5.15 Fixes: QTBUG-89156 Change-Id: I17057719a90f59629087afbd1d2ca58c1aa1d8f6 Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
* Revert "Accessibility: don't emit focus change when reason is window activation"Volker Hilsheimer2022-11-031-9/+5
| | | | | | | | | | | | This reverts commit 79a11470f3c4c61951906223f97001a77ce36500, which resulted in QTBUG-105735. The new behavior is worse and affects multiple screen readers, while the old issue is isolated to Windows Narrator and could be considered a narrator bug. Task-number: QTBUG-105735 Pick-to: 6.2 6.4 Change-Id: Ic8be1dbd592a3fdf2c3219ec4c5524bc2c7f0f6a Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io>
* Port from container::count() and length() to size() - V5Marc Mutz2022-11-032-5/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is a semantic patch using ClangTidyTransformator as in qtbase/df9d882d41b741fef7c5beeddb0abe9d904443d8, but extended to handle typedefs and accesses through pointers, too: const std::string o = "object"; auto hasTypeIgnoringPointer = [](auto type) { return anyOf(hasType(type), hasType(pointsTo(type))); }; auto derivedFromAnyOfClasses = [&](ArrayRef<StringRef> classes) { auto exprOfDeclaredType = [&](auto decl) { return expr(hasTypeIgnoringPointer(hasUnqualifiedDesugaredType(recordType(hasDeclaration(decl))))).bind(o); }; return exprOfDeclaredType(cxxRecordDecl(isSameOrDerivedFrom(hasAnyName(classes)))); }; auto renameMethod = [&] (ArrayRef<StringRef> classes, StringRef from, StringRef to) { return makeRule(cxxMemberCallExpr(on(derivedFromAnyOfClasses(classes)), callee(cxxMethodDecl(hasName(from), parameterCountIs(0)))), changeTo(cat(access(o, cat(to)), "()")), cat("use '", to, "' instead of '", from, "'")); }; renameMethod(<classes>, "count", "size"); renameMethod(<classes>, "length", "size"); except that the on() matcher has been replaced by one that doesn't ignoreParens(). a.k.a qt-port-to-std-compatible-api V5 with config Scope: 'Container'. Added two NOLINTNEXTLINEs in tst_qbitarray and tst_qcontiguouscache, to avoid porting calls that explicitly test count(). Change-Id: Icfb8808c2ff4a30187e9935a51cad26987451c22 Reviewed-by: Ivan Solovev <ivan.solovev@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* QApplication: send QHoverEvents with correct scenePosition()Shawn Rutledge2022-10-231-2/+4
| | | | | | | | | | | | | | | | The QHoverEvent ctor takes two points: pos and globalPos; pos is then passed as both the scene and global pos to the QSinglePointEvent ctor, which calls QMutableEventPoint::setScenePosition() on the persistent QEventPoint instance and then detaches befeore setting ephemeral state. Therefore, we must construct QHoverEvent with scene position first, not local position, so that the right value is persisted; it's better to set local position after the detach(), whereas it's too late to fix the persistent point then. Pick-to: 6.4 Fixes: QTBUG-106918 Change-Id: I45726a9ec05bba2fe0cde6f5fb87c269105caca6 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Set alphaBufferSize to -1 when disabling translucency in QtWidgetsPeter Varga2022-10-211-1/+1
| | | | | | | | | | | -1 is the default value for QSurfaceFormat::alphaBufferSize. Changing it to 0 may result an unexpected pixel format change by ARB OpenGL extension. Pick-to: 6.4 Fixes: QTBUG-107629 Change-Id: Ia6a1b90fba6c43b6872b406f4fd946d937135cf8 Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
* Add missing repaintManager checkLaszlo Agocs2022-10-171-1/+1
| | | | | | | | | | | | | | | | | | | | | | | This is likely a problem only after the 6.4 changes to move QQuickWidget composition from OpenGL to QRhi. Add an extra check to the condition when bailing out. In QWidgetPrivate (qwidget.cpp) all similar calls into the repaintManager are guarded by if (tlwExtra && tlwExtra->backingStore && tlwExtra->repaintManager) therefore it makes sense to perform the same check in the other file too. The assumption is that the check was not added here due to being outside of qwidget.cpp. Change-Id: Ic94d4e5153f4a194a997cd669b0f7c48c7932d97 Fixes: QTBUG-107166 Pick-to: 6.4 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* Port from qAsConst() to std::as_const()Marc Mutz2022-10-113-5/+5
| | | | | | | | | | | | | | | | We've been requiring C++17 since Qt 6.0, and our qAsConst use finally starts to bother us (QTBUG-99313), so time to port away from it now. Since qAsConst has exactly the same semantics as std::as_const (down to rvalue treatment, constexpr'ness and noexcept'ness), there's really nothing more to it than a global search-and-replace, with manual unstaging of the actual definition and documentation in dist/, src/corelib/doc/ and src/corelib/global/. Task-number: QTBUG-99313 Change-Id: I4c7114444a325ad4e62d0fcbfd347d2bbfb21541 Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
* Replace qExchange with std::exchangeMarc Mutz2022-10-071-1/+1
| | | | | | | | | | | | | None of these users require C++20 constexpr or C++23 noexcept, the only remaining difference between std::exchange and qExchange. This leaves a single qExchange() user, in QScopedValueRollback, that requires the constexpr version, only available from C++20, and thus remains unported. Task-number: QTBUG-99313 Change-Id: Iea46f6ed61d6bd8a5b2fd9d9ec4d70c980b443a2 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Port from container.count()/length() to size()Marc Mutz2022-10-048-33/+33
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is semantic patch using ClangTidyTransformator: auto QtContainerClass = expr(hasType(namedDecl(hasAnyName(<classes>)))).bind(o) makeRule(cxxMemberCallExpr(on(QtContainerClass), callee(cxxMethodDecl(hasAnyName({"count", "length"), parameterCountIs(0))))), changeTo(cat(access(o, cat("size"), "()"))), cat("use 'size()' instead of 'count()/length()'")) a.k.a qt-port-to-std-compatible-api with config Scope: 'Container'. <classes> are: // sequential: "QByteArray", "QList", "QQueue", "QStack", "QString", "QVarLengthArray", "QVector", // associative: "QHash", "QMultiHash", "QMap", "QMultiMap", "QSet", // Qt has no QMultiSet Change-Id: Ibe8837be96e8d30d1846881ecd65180c1bc459af Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Update documentation of qWaitForWindowActive / qWaitForWindowExposedAxel Spoerl2022-09-301-13/+16
| | | | | | | | | | Sharpen existing documentation with a focus on use cases and differences between both methods / overrides in qtestsupport_gui and qtestsupport_widgets. Pick-to: 6.4 6.2 5.15 Change-Id: I62b7be437dd43bb0b114af66de51fb4d1f55b671 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Fix build with disabled accessibilityAlexey Edelev2022-09-291-1/+1
| | | | | | | | Amends 8539e641f6f48a605547f66c47266d19e537f74e Task-number: QTBUG-106941 Change-Id: Ieffe1ac0050c9f1377e4260376acb2f8cdc0f985 Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
* Make commit() call in QTouchEventWidgetSequence explicitAxel Spoerl2022-09-201-1/+1
| | | | | | | | | | | | Calling commit() in the QTouchEventWidgetSequence destructor bypasses the vtable. This causes a compiler warning. This patch eliminates the warning by explicitly calling QTouchEventWidgetSequence::commit(). Pick-to: 6.4 Change-Id: I1354aa22d2a85a609adc307338d118c5789df93f Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io>
* Get rid of copypasted code between isWindowBlocked's overridesMikolaj Boc2022-09-202-65/+8
| | | | | | | | | | | | | | | | | The code in QGuiApplication::isWindowBlocked and QApplication::isWindowBlocked is very similar, a result of copying and pasting. Due to the copying it is difficult to modify the code and the implementation is hard to comprehend, too. There are ultimately only two parts that are different. First is that QApplication's override may also specify a certain window as non-blockable if it is a popup window. Second, default modality is computed in QApplication if a modal window does not have one assigned. The differing parts have been extracted following the template method design pattern. Pick-to: 6.4 Change-Id: I3b9aa206a3c7211fe022730943bf6f76aa5ae6d2 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Clear WA_UnderMouse attribute when widget gets hiddenSanthosh Kumar2022-09-201-0/+9
| | | | | | | | | | | | | | | | | | | | | From 6.3 onward, hiding a widget doesn't automatically clear QT::WA_UnderMouse attribute. This leads to multiple buttons drawn with highlighted rectangle at the same time (refer bug). The behavior is observed after commit 0246bfd40a2cc5ea9cfc035146e6dd865b334c68 made as part of bug QTBUG-53286. This patch clears WA_UnderMouse attribute in widget hideChildren() and subsequently, widgets that are hidden will not inherit this attribute on the next show operation. The attribute will be set only when the widget is under mouse cursor. Fixes: QTBUG-104805 Pick-to: 6.4 Change-Id: I4988eb72577fd557a328fd08bb09fa2fbded3138 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Simplify obtaining of parent in isWindowBlockedMikolaj Boc2022-09-121-8/+2
| | | | | | | The new way is more readable as it uses an existing API Change-Id: Id253c9e6405d11f16bdb5f55288dcfcf4b1641c6 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* Propagate the event acceptance correctly with context menu on RMBMikolaj Boc2022-09-071-0/+2
| | | | | | | | | | The context menu event created in QWidgetWindow::handleMouseEvent does not forward its acceptance flag on which a client may rely. Task-number: QTBUG-106389 Backport-to: 6.4 6.4.0 Change-Id: I17a53ebd23b4ae0a2721c629f3ecc7aeec56233d Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* Move QMacAutoReleasePool from qglobal.h to qcore_mac_p.hSona Kurazyan2022-09-011-0/+4
| | | | | | | | And include qcore_mac_p.h where needed. Task-number: QTBUG-99313 Change-Id: Idb1b005f1b5938e8cf329ae06ffaf0d249874db2 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* Restore signature of qt_handleTouchEvent()Kai Köhne2022-08-311-2/+2
| | | | | | | | | | | | | | The function return value changed in commit e1f25b1c8. Anyhow, this breaks the AUT probe of Squish on Windows, as long as it is built against an older Qt version. Squish can of course be adjusted eventually, but let's allow some grace period. Pick-to: 6.4 Fixes: SQUISH-15324 Change-Id: I289ed43bffcf292aa2eae3962a4661ed5c29100e Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Deprecate QApplication::setActiveWindow() and mark as internalTor Arne Vestbø2022-08-274-11/+26
| | | | | | | | | | | | | | The function is used the internal window activation machinery and should not be called by user code. Many tests still use this function, and should be ported over to QWidget::activateWindow(). For now they are using the private helper in QApplicationPrivate, so that we can progress with the public API deprecation. Change-Id: I29f1575acf9efdcbae4c005ee9b2eb1bb0c8e5b5 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* Refactor QApplication::event from if/else to switch statementVolker Hilsheimer2022-08-261-8/+16
| | | | | | | | And it wasn't even 'else if' in all the places where it should have been. Pick-to: 6.4 Change-Id: I5a48bfe27cc01fa1fbea1995e8c9cb1be427511a Reviewed-by: Doris Verria <doris.verria@qt.io>
* Re-create TLW's window only when its surface type is really changedIlya Fedin2022-08-241-1/+1
| | | | | | | Fixes: QTBUG-105017 Pick-to: 6.4 Change-Id: If5826172efb53b6df15dd3b7ba91b09d733cc77f Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
* Evaluate TranslucentBackground when (re)creating the windowLaszlo Agocs2022-08-011-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | The problem is reported in combination with the new 6.4 way of handling texture-based widgets, but this looks like something that has always been missing: Setting WA_TranslucentBackground changes the QWidgetWindow's format, and this is done upon calling setAttribute(). That's good for most cases, but the changes to the QWindow's format are lost when the window is destroyed and then the widget gets another window later. This is not that common, but can happen. For example, if a top-level widget is parented under something else, and then later it is parented to null again, so that it is toplevel once again, background transparency can be lost because nothing re-evaluates the WA_TranslucentBackground flag after the initial setAttribute(), and so the widget's second QWidgetWindow is not set up accordingly (because this new QWindow may not have alpha specified in the QSurfaceFormat which may or may not be a problem, depending on the platform / windowing system) The simple solution is to evaluate the attribute not just when setting it, but also when a new QWidgetWindow is created for the widget. Fixes: QTBUG-104952 Pick-to: 6.4 Change-Id: I92746caea5561544f90395d5473ac28d43143924 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Remove qvariant_p.hThiago Macieira2022-07-271-1/+0
| | | | | Change-Id: I3859764fed084846bcb0fffd1704480153e34973 Reviewed-by: Ievgenii Meshcheriakov <ievgenii.meshcheriakov@qt.io>
* QShortcut::parentWidget(): Add QT_DEPRECATED_VERSION_X_6_0Ivan Solovev2022-07-211-1/+1
| | | | | | | | | | | | | And fix the usage that raised a deprecation warning. As a drive-by: fix the deprecation declaration of QShortcut::id() to use QT_DEPRECATED_VERSION_6_0 instead of pure Q_DECL_DEPRECATED. Task-number: QTBUG-104857 Pick-to: 6.4 6.3 6.2 Change-Id: I5710127864909ce9352c7428e6aabbc89981b8f2 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> Reviewed-by: Marc Mutz <marc.mutz@qt.io>
* Do not use QExposedEvent::region() in internal codeIvan Solovev2022-07-131-5/+2
| | | | | | | Task-number: QTBUG-104857 Pick-to: 6.4 6.3 6.2 Change-Id: I5ee41802ecc4d6291aaaa1f0efddd20027c1c1e4 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Improve widget painting under dpr>1 by enabling smooth pixmap scalingEirik Aavitsland2022-07-121-0/+1
| | | | | | | | | | | | | | | | | Smooth scaling of icons etc. give far better visual results, particularly with fractional dpr scaling. So enable this generally in QStylePainter, and make more of the relevant widgets use QStylePainter instead of QPainter directly. Differences can be seen in the widgets examples, e.g. textedit, gallery, stylesheet (Pagefold), mdi. Pick-to: 6.4 6.3 6.2 Task-number: QTBUG-96223 Fixes: QTBUG-101058 Change-Id: I3c34a455d097e5f6a6a09d3b020528b4fbda4d85 Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io> Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* QWidget: use WA_InputMethodEnabled when ImEnabled is not implementedRichard Moe Gustavsen2022-07-081-9/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | In Qt 6.3, a check for WA_InputMethodEnabled was removed in QWidget, to support IM queries also for read-only widgets (7c6e4af48). This caused a regression on iOS, which made the input panel open for widgets that didn't support IM at all. A patch was merged that solved the regression (3b12305575), but it didn't take the widget attribute into account. Since not doing so has the potential to cause regressions, this patch will modify the affected code once more, so that we instead fall back to test WA_InputMethodEnabled when ImEnabled is not implemented. This will match closely to the way ImEnabled was implemented in Qt 6.2. Since we, with this change, now require that either ImEnabled or WA_InputMethodEnabled is set, our own input widgets will fail to support IM text selection when they're read-only, since they actually don't implement ImEnabled. This patch will therefore also make sure that we do so. Task-number: QTBUG-104527 Pick-to: 6.4 6.3 Change-Id: I70ad910aec38d0a74f4dd7d3115d3c45c16d2b3b Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Make it possible to check the accepted state of touch events in testsShawn Rutledge2022-07-082-5/+7
| | | | | | | | | | | | | | | | | | | | | | | QTouchEventSequence simulates a QPA touch event, potentially containing multiple points. (Despite the name, it only calls qt_handleTouchEvent() once, so it cannot really send a sequence of events; however, one event can contain multiple touchpoints.) Delivery is synchronous, and we keep return values through the QWindowSystemInterface::handleTouchEvent() template functions; so the remaining step is to return a bool from qt_handleTouchEvent(), so that we can return a bool from commit(). This allows tests to see the same perspective as a platform plugin can: check whether the event was accepted or not, after delivery is complete. Some tests in Qt Quick need to start doing that, to enforce correct behavior in QQuickDeliveryAgent. [ChangeLog][QtTestLib] QTouchEventSequence::commit() now returns a bool so that tests can check whether the event was accepted during delivery. Pick-to: 6.4 Task-number: QTBUG-104656 Change-Id: I9cf87909a3f847dedbdeca257013e309ac19cf0d Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* Harden drag and drop handling in widget windowLaszlo Agocs2022-07-011-7/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | User code in an event handler can do arbitrary things, including operations that lead to destroying the QWidgetWindow. An example is what the autotest does: reparenting the top-level widget to under another top-level upon the drop. Internally this leads to destroying the drop target's QWidgetWindow as the widget is now a child, not a top-level. In fact some of the existing drag and drop handling code seems to be prepared to handle the case of having the drag target widget destroyed in the user's event handler during a drag-move. But none of it is prepared for having the QWidgetWindow destroyed upon returning from forwardEvent(). The associated bug report has the same root cause, it is just popping up now via the new 6.4 behavior: adding a QOpenGLWidget to a widget hierarchy upon a drop leads to getting a new QWidgetWindow (if the window only had regular raster widgets before). To solve this, avoid touching members on 'this' after the forwardEvent(). It looks like the handlers for mouse events follow this pattern already, no member data is touched after forwarding events (not sure if that is intentional or just incidental but it is the safe solution, even if this is not feasible everywhere, but ideally input events should take this into account). Fixes: QTBUG-104596 Pick-to: 6.4 6.3 6.2 Change-Id: I96c704cadcd799fc5619b776e939dfdf313a27dd Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io> Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* QLayout: add className() to a warning messageAhmad Samir2022-07-011-10/+11
| | | | | | | | | | | | | | | | Since objectName() isn't always set, the className() makes it slightly easier to find and fix the issue. Also unify some wording "produce a warning", which is generic enough to fit: print warning in terminal print warning in logviewer (if you're unlucky and have to use Windows?) print warning in system journal (if you're unlucky have to use binary systemd journal logs) Pick-to: 6.4 Change-Id: I7522d65666cb5829c33c45039b8646dd535e21ea Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* IM: Don't let all widgets support IM by defaultRichard Moe Gustavsen2022-07-011-2/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | A new property Qt::ImEnabled was added in Qt 5.3. Since the already existing widgets with IM support (3rd party included) didn't implement this property, QWidget got the fall back logic that if a widget was queried for Qt::ImEnabled, and the returned QVariant was invalid (the widget didn't implement it), we would, for backwards compatibility with Qt 4, return "true" (meaning that the widget supports IM). But a side effect from this fallback logic, is that now any widget that doesn't implement ImEnabled (or input methods at all) report that they support IM. This will confuse platforms like iOS, which uses ImEnabled to decide if the input panel should show, and if text selection tools should be enabled. The result is therefore that if you click on a QPushButton, the input panel will open. This patch will implement a more careful strategy to check if a widget implements IM, if ImEnabled is missing. Rather than saying that all widgets that don't implement ImEnabled supports IM, we now require that the widget also returns a valid QVariant for Qt::ImSurroundingText. We assume then, that a widget that doesn't do so will anyway not be in need of input method support from the platform. Fixes: QTBUG-104527 Pick-to: 6.4 6.3 6.2 Change-Id: Ib391fd1daae92c4325e9ccb59730fbdd7c9328fc Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* QBoxLayout: Add assertion that catches out of bounds insertion indicesMarcel Kummer2022-06-181-0/+1
| | | | | | | | | | | | | | | As of Qt6, QList will assert that an insertion index is in range of existing values. QBoxLayout interprets negative indices as "append at the end". That part is covered. Indices larger than the number of items in the layout would trigger the assertion in QList, but after the insert method had returned. That would make it hard to debug. This change asserts the index range before inserting, thus making it easier to spot the problem. Fixes: QTBUG-103775 Change-Id: Ida099f785263fe8a5c8a1d0a48c4ff87713549b4 Pick-to: 6.2 6.3 6.4 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* QBoxLayout: Pull out handling for negative insertion indicesMarcel Kummer2022-06-171-16/+14
| | | | | | | | | | | This snippet occurs in every insert function further down. Let's pull it out in preparation for adding an assertion that the index is in range, which would also need to be added to every insert function. Fixes: QTBUG-103775 Change-Id: I419f57434f860df4c947853ac307826994f0198b Pick-to: 6.2 6.3 6.4 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Accessibility: don't emit focus change when reason is window activationVolker Hilsheimer2022-06-161-5/+9
| | | | | | | | | | | | | | | | | | | | If a window becomes active, then the accessibility system gets informed about that already. Qt puts focus on the focus child of the activated window afterwards, and if this emits another accessibility event, then accessibility clients like Windows Narrator will stop reading the activated window, and instead read about the focused widget. This makes dialogs like message boxes poorly accessible. Accessibility clients already know that a window became active, and can query Qt about the focused child within that window. Amend test case. Fixes: QTBUG-101585 Pick-to: 6.4 6.3 6.2 Change-Id: I2d6bff7c415a6f29c4a4f7f4e4be38079fb976ca Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io>
* Fix typos in docs and commentsKai Köhne2022-06-151-1/+1
| | | | | | | | | Found by codespell Pick-to: 6.4 Change-Id: Ie3e301a23830c773a2e9aff487c702a223d246eb Reviewed-by: Nicholas Bennett <nicholas.bennett@qt.io> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* Replace QT_NO_ACCESSIBILITY with QT_CONFIG(accessibility)Allan Sandfeld Jensen2022-06-157-21/+21
| | | | | | | Pick-to: 6.4 Change-Id: Iee4bd8970810be1b23bdba65a74de912401dca65 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Marc Mutz <marc.mutz@qt.io>
* Add support for painting at integer DPR with downscaleMorten Sørvig2022-06-141-2/+13
| | | | | | | | | | | | | | | | | | | Enable by setting QT_WIDGETS_HIGHDPI_DOWNSCALE=1 and QT_WIDGETS_RHI=1. This will make the backing store and painter operate at the next highest integer DPR in cases where QWindow::devicePixelRatio() returns a fractional value. The backing store image will then be downscaled to the target DPR at flush time, using the RHI flush pipeline. [ChangeLog][QWidgets] Added experimental support for always painting at an integer device pixel ratio (rounding the DPR up if necessary), followed by a downscale to the target DPR.Enable by setting QT_WIDGETS_HIGHDPI_DOWNSCALE=1 and QT_WIDGETS_RHI=1. Pick-to: 6.4 Task-number: QTBUG-86344 Change-Id: Id5b834a0e3499818b0b656161f5e0c38a6caa340 Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
* Make rhiFlush() support custom source DPRMorten Sørvig2022-06-141-0/+1
| | | | | | | | | | | | | | | | | | | | | | | The rhiFlush() implementation currently assumes that QWindow->devicePixelRatio() is the correct scale factor for transforming device independent window geometry to source geometry. However, this assumption does not hold if/when we add support for drawing to a rounded-up DPR, with a downscale later in the rhiFlush implementation. Fix this by adding a sourceDevicePixelRatio argument to rhiFlush(), which is set to either QWindow::devicePixelRatio() or QWidget::devicePixelRatio(), depending on from where it is used. Change deviceRect() and friends in qbackingstoredefualtcompositor.cpp to be scale*() functions instead which take a scale factor instead of a QWindow. Update call sites to use srouceDevicePixelRatio where that makes sense. Pick-to: 6.4 Change-Id: Idb7b1e2f36816a201e00f0defe100d2dc079cb17 Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
* QApplication: Remove QApplicationPrivateBase porting macroThiago Macieira2022-06-132-4/+2
| | | | | | | | | This was last used in 2011, before Qt 5.0 release, when QPA was yet another windowing system, not the only option. Change-Id: Ia4a094014ddb48cc9f6dfffd16f83aad1b7109e7 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
* Q*ApplicationPrivate: remove unused "flags" argumentsThiago Macieira2022-06-142-5/+5
| | | | | | | | | | | | | | | | 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. Pick-to: 6.4 Change-Id: Ia4a094014ddb48cc9f6dfffd16f83a7b58ff95d3 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Refactor if-else snake into switch statementVolker Hilsheimer2022-05-241-19/+20
| | | | | Change-Id: I597d5cbdddf4a2fbbe8b9de2ae252cdeadce9d11 Reviewed-by: Thorbjørn Lund Martsum <tmartsum@gmail.com>
* Fix QWidget::metric to use widget screen dpr instead of app-dprThorbjørn Lund Martsum2022-05-241-13/+4
| | | | | | | | | | | | | Use the widget screen dpr in calculations rather than qApp->devicePixelRatio(). The screen may have been directly set (without the window handle being initialized) Task-number: QTBUG-103309 Task-number: QTBUG-49663 Task-number: QTBUG-101947 Task-number: QTBUG-102982 Change-Id: I2af2073640b171baf68575e3bc93b29b6a9a471d Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>