Commit Graph

1046 Commits (5ea248155654b58fcb52ef326dc4d94de83d0409)

Author SHA1 Message Date
Christian Ehrlicher 5ea2481556 QWidget: fix render() in RTL mode
Rendering a widget to a paintdevice via QWidget::render() did not pass
the LayoutDirection mode of the widget to the paintdevice which lead to
wrong rendering of text.
This is especially visible with the windows 11 style which does not draw
some widgets directly on the screen but through a QGraphicsEffect on a
QImage.

Pick-to: 6.7 6.5 6.2
Fixes: QTBUG-124931
Change-Id: If2cfa326d2ca45c42e203a4ae91fd857afa5c69c
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
Reviewed-by: Wladimir Leuschner <wladimir.leuschner@qt.io>
2024-05-08 19:58:17 +02:00
Frédéric Lefebvre a0759dd420 tst_QApplication::focusWidget() remove setActiveWindow() child section
2f6fe3a268 as made calls to
QApplicationPrivate::setActiveWindow() redundant.

Remove redundant calls.

Task-number: QTBUG-121488
Change-Id: Ib3b39f4bd51c87eeeebe329ada163f24390f6bc3
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
2024-05-08 13:37:47 +02:00
Frédéric Lefebvre f75b5b8aca tst_QApplication::focusWidget() remove setActiveWindow()
2f6fe3a268 as made calls to
QApplicationPrivate::setActiveWindow() redundant.

Remove redundant calls.

Task-number: QTBUG-121488
Change-Id: I160e71302b40777d13e2481447bc47ebfc1a784c
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
2024-05-08 13:07:33 +02:00
Frédéric Lefebvre 2e3f607aae tst_QStackedLayout::keepFocusAfterSetCurrent() remove setActiveWindow()
2f6fe3a268 as made calls to
QApplicationPrivate::setActiveWindow() redundant.

Remove redundant calls.

Task-number: QTBUG-121488
Change-Id: Iaf1e79193f0f7013d02d91930cc408af5b0f8e1d
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
2024-05-06 16:29:02 +02:00
Frédéric Lefebvre b64932ba82 tst_QApplication::alert() remove QApplicationPrivate::setActiveWindow()
2f6fe3a268 as made calls to
QApplicationPrivate::setActiveWindow() redundant.

Remove redundant calls.

Task-number: QTBUG-121488
Change-Id: I208ad97d7b56ded15908b96ad03779db849ef6a9
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
2024-05-03 17:11:23 +02:00
Frédéric Lefebvre ec449a8379 tst_QAction::disableShortcutsWithBlockedWidgets remove setActiveWindow
2f6fe3a268 as made calls to
QApplicationPrivate::setActiveWindow() redundant.

Remove redundant calls.

Task-number: QTBUG-121488
Change-Id: Iea02f308c3357ddcb8f52527031b9417d8a175d7
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
2024-04-30 18:30:16 +02:00
Frédéric Lefebvre 800024a42a tst_QAction::repeat() remove QApplicationPrivate::setActiveWindow()
2f6fe3a268 as made calls to
QApplicationPrivate::setActiveWindow() redundant.

Remove redundant calls.

Task-number: QTBUG-121488
Change-Id: I845a0a9220bca176f9c270cb7aee225325c2e7af
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
2024-04-30 18:30:16 +02:00
Frédéric Lefebvre 77acde40c1 tst_QAction::actionEvent() remove QApplicationPrivat::setActiveWindow()
2f6fe3a268 as made calls to
QApplicationPrivate::setActiveWindow() redundant.

Remove redundant calls.

Task-number: QTBUG-121488
Change-Id: I8e58e26382dfc32e0a3475dd601c0377e7378d87
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
2024-04-30 18:30:16 +02:00
Eskil Abrahamsen Blomfeldt 5711aaa017 test: Don't crash when focusWidget() is null
If QApplication::focusWidget() returns null, which was the
case on Wayland under some circumstances, then the code collecting
the error output would crash when dereferencing the null pointer.

This fixes that crash and gets proper test failure output instead.

Pick-to: 6.5 6.7
Fixes: QTBUG-124475
Change-Id: Ic34228be953cf42dfe2ebf75957cd48791e6de7d
Reviewed-by: Liang Qi <liang.qi@qt.io>
2024-04-30 07:14:41 +02:00
Axel Spoerl 913442a75a Widgets focus abstraction: Skip isFocusChainConsistent w/o logging cat
QWidgetPrivate::isFocusChainConsistent() iterates over
QApplication::allWidgets() to identify and log inconsistencies.
In applications with many widgets, this has a major performance
impact.

Disable the check and return true, unless the logging category
qt.widgets.focus is enabled.

Adapt tst_QWidget::focusAbstraction() to enable the logging category.

This amends 58d5d4b7c2.

Fixes: QTBUG-124666
Change-Id: Ia487b381ab45b052638b189bf56acaf4353b1a37
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
2024-04-26 17:26:07 +00:00
Frédéric Lefebvre 58fbbaf00d tst_QWidget_window::tst_dnd() remove setActiveWindow()
2f6fe3a268 has made calls to
QApplicationPrivate::setActiveWindow() redundant.

Remove redundant calls.

Task-number: QTBUG-121488
Change-Id: I2acc02ebd0434de54344fa1e5fa488e7cd81c106
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
2024-04-26 18:19:37 +02:00
Frédéric Lefebvre e8c5cdff81 tst_QTooltip::qtbug64550_stylesheet() remove setActiveWindow()
2f6fe3a268 has made calls to
QApplicationPrivate::setActiveWindow() redundant.

Remove redundant calls.

Task-number: QTBUG-121488
Change-Id: I84928725fb9b6d834439aa8a64171dcf3f7a042e
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
2024-04-26 18:19:37 +02:00
Frédéric Lefebvre 02174b9680 tst_QTooltip::keyEvent() remove QApplicationPrivate::setActiveWindow()
2f6fe3a268 has made calls to
QApplicationPrivate::setActiveWindow() redundant.

Remove redundant calls.

Task-number: QTBUG-121488
Change-Id: I7f87b71237f679575a093ac5d28ddd2c9a911492
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
2024-04-26 17:37:57 +02:00
Frédéric Lefebvre 88fd77172f tst_QShortcut::duplicatedShortcutOverride() remove setActiveWindow()
2f6fe3a268 has made calls to
QApplicationPrivate::setActiveWindow() redundant.

Remove redundant calls.

Task-number: QTBUG-121488
Change-Id: I6ad2841a15dd9286232ad43069e3839faa3fe901
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
2024-04-26 17:37:57 +02:00
Frédéric Lefebvre 7a81b356ca tst_QShortcut::context() remove QApplicationPrivate::setActiveWindow()
2f6fe3a268 has made calls to
QApplicationPrivate::setActiveWindow() redundant.

Remove redundant calls.

Task-number: QTBUG-121488
Change-Id: I650e67f626865796480c422e9d7ff7dcfd11c9ca
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
2024-04-26 17:37:57 +02:00
Frédéric Lefebvre e5b35d9bdb tst_QWidget::grabKeyboard remove QApplicationPrivate::setActiveWindow()
2f6fe3a268 has made calls to
QApplicationPrivate::setActiveWindow() redundant.

Remove redundant calls.

Task-number: QTBUG-121488
Change-Id: Iea870711410dee1347f1020a6f7afc037e520825
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
2024-04-23 09:25:51 +02:00
Frédéric Lefebvre 9aac7b092d tst_QWidget::grabMouse() remove QApplicationPrivate::setActiveWindow()
2f6fe3a268 has made calls to
QApplicationPrivate::setActiveWindow() redundant.

Remove redundant calls.

Task-number: QTBUG-121488
Change-Id: I7fd9005ef66c11f640a50f0db468cdcb07eb621f
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
2024-04-22 19:12:11 +02:00
Frédéric Lefebvre 93e0233717 tst_QWidget::imEnabledNotImplemented() remove setActiveWindow()
2f6fe3a268 has made calls to
QApplicationPrivate::setActiveWindow() redundant.

Remove redundant calls.

Task-number: QTBUG-121488
Change-Id: I432e7ced3e49b570cf9e4057fe98411271693750
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
2024-04-22 19:12:11 +02:00
Frédéric Lefebvre bc5ca2f510 tst_QWidget::enterLeaveOnWindowShowHide() remove setActiveWindow()
2f6fe3a268 has made calls to
QApplicationPrivate::setActiveWindow() redundant.

Remove redundant calls.

Task-number: QTBUG-121488
Change-Id: Ic189b1c55b6bdf0397636b3ae9555cc38b60fc48
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
2024-04-22 19:12:11 +02:00
Frédéric Lefebvre 37b421c186 tst_QWidget::dumpObjectTree remove QApplicationPrivate::setActiveWindow
2f6fe3a268 has made calls to
QApplicationPrivate::setActiveWindow() redundant.

Remove redundant calls.

Task-number: QTBUG-121488
Change-Id: I1cd2d45c54fbeb2b89accc257f2ec5b57f20c013
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
2024-04-22 19:12:11 +02:00
Frédéric Lefebvre 840cc2a6d8 tst_QWidget::clean_qt_x11_enforce_cursor() remove setActiveWindow()
2f6fe3a268 has made calls to
QApplicationPrivate::setActiveWindow() redundant.

Remove redundant calls.

Task-number: QTBUG-121488
Change-Id: I2a3f400e58f86cbc339c355977da784ef5c24800
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
2024-04-22 16:48:50 +02:00
Doris Verria f20be43b82 Set focus to the window container when contained window gains focus
As it is, when a QWindowContainer's embedded window gains focus, the
container doesn't report having focus and QApplication::focusWidget()
will be nullptr. This is because when the embedded window gets focus,
the container will clearFocus() on the old focus widget. To be able
to set focus to the next focus widget (eg: as a result of a key tab
event sent to the container's parent window), the container checks
if its embedded window is already focused, and if so, forwards focus
to its nextInFocusChain(). That is why it keeps track of the (old)
focusWindow.

The problem with the current behavior is that if we want to make focus
navigation via key tabbing work and return focus *from within the
window* back to the normal widget focus chain, the encapsulating widget
needs to remember its focusWidget(), in this case the window container,
in order to be able to set focus to the next/PrevInFocusChain().

That is why we now set the focus to the window container whenever its
contained window gains focus. This means that
QApplication::focusWidget() will be the window container if the contained
window has focus. In this way, we don't have to call clearFocus() on the
old focus widget, or keep track of focus windows, because calling
setFocus() on the container will handle that.

It is worth noting and probably documenting the following caveats:
- even though the window container will be the
qApp's focusWidget(), it won't directly handle keyboard events, but the
contained window will
- we won't be able to respect the window container's focusPolicy in this
case, since the contained window will be activated from interactions
inside it, no matter the container's focusPolicy

[ChangeLog][QtWidgets][QWindowContainer] The window container will
become focused if the contained window becomes focused. This
implies that the QApplication::focusWidget() will be the window
container if the contained window is the focus window.

Task-number: QTBUG-121789
Change-Id: I1050afc59780f7189a0d8e8c95bff27f96f38dbc
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
2024-04-22 16:01:01 +02:00
Frédéric Lefebvre 7f447adcd8 tst_QWidget::showAndMoveChild() remove setActiveWindow()
2f6fe3a268 has made calls to
QApplicationPrivate::setActiveWindow() redundant.

Remove redundant calls.

Task-number: QTBUG-121488
Change-Id: I7bd841574c07d73416f9f63d564fe31a8475fa9e
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2024-04-19 12:13:33 +01:00
Frédéric Lefebvre 04995cf800 tst_QWidget::showMinimizedKeepsFocus() remove setActiveWindow()
2f6fe3a268 has made calls to
QApplicationPrivate::setActiveWindow() redundant.

Remove redundant calls from testing deletion of the focusWidget, testing
reparenting of the focus widget, testing setEnabled(false) and testing
clearFocus sections.

Task-number: QTBUG-121488
Change-Id: I7e46ddb31bd7dbc0492d057d8d84846db8c873aa
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
2024-04-19 12:13:32 +01:00
Frédéric Lefebvre 80baafb900 tst_QWidget::explicitTabOrderWithSpinBox_QTBUG81097 remove setActiveWin
2f6fe3a268 has made calls to
QApplicationPrivate::setActiveWindow() redundant.

Remove redundant calls.

Task-number: QTBUG-121488
Change-Id: I5d6871b192b5c4dda00ef912a806e62a529b629e
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
2024-04-19 12:13:32 +01:00
Frédéric Lefebvre 870dc93dd5 tst_QWidget::appFocusWidgetWhenLosingFocusProxy remove setActiveWindow
2f6fe3a268 has made calls to
QApplicationPrivate::setActiveWindow() redundant.

Remove redundant calls.

Task-number: QTBUG-121488
Change-Id: I2841522f533c7679cc9c254c5fe7c37f5632fd30
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
2024-04-19 12:13:32 +01:00
Frédéric Lefebvre 706de2fe07 tst_QWidget::appFocusWidgetWithFocusProxyLater remove setActiveWindow()
2f6fe3a268 has made calls to
QApplicationPrivate::setActiveWindow() redundant.

Remove redundant calls.

Task-number: QTBUG-121488
Change-Id: I4a0d026fbe5da014723254bb9eb8d614cf50232f
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
2024-04-19 12:13:32 +01:00
Frédéric Lefebvre 021b5e3d3f tst_QWidget::focusChainOnHide remove QApplicationPrivate::setActiveWind
2f6fe3a268 has made calls to
QApplicationPrivate::setActiveWindow() redundant.

Remove redundant calls.

Task-number: QTBUG-121488
Change-Id: I5b429dcaa47cd179785345f9f7a80648574670dd
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
2024-04-18 18:06:01 +01:00
Assam Boudjelthia 44072f43ed Android: blacklist tst_QWidget::setParentChangesFocus
This fails on Android 8, and we want to get Android 8 bump into the CI.

Pick-to: 6.7
Task-number: QTBUG-124291
Change-Id: I179880c38d155df82bcb772f546104d956326647
Reviewed-by: Tinja Paavoseppä <tinja.paavoseppa@qt.io>
2024-04-12 20:12:18 +03:00
Jan Arve Sæther ddc80cc63d Implement QWindowContainer::minimumSizeHint()
It will return the minimumSize of the underlying QWindow.
The container can then be put inside QLayouts without risking to be
shrunk to a smaller size than the QWindow::minimumSize.
Whenever the QWindow::minimumWidth or QWindow::minimumHeight changes, we call QWindowContainer::updateGeometry(), which will make the layout re-query QWindowContainer::minimumSizeHint() again.

Task-number: QTBUG-121798
Change-Id: Ib7ece7d9d75f2e4964ca9042d8d8b95ce3b17739
Reviewed-by: Doris Verria <doris.verria@qt.io>
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
2024-04-12 17:12:18 +00:00
Axel Spoerl ef8e548cf1 QLayout: Consume ChildRemoved event, when layout is disabled
QLayout::widgetEvent() returned early, when the layout was disabled.
That suppressed ChildRemoved events and lead to a crash, when the
layout was enabled again.

Don't return early on ChildRemoved events.
Add an autotest in tst_layout::removeWidget().

Fixes: QTBUG-124151
Pick-to: 6.7 6.5 6.2
Change-Id: Ib0a0bb73978d9fc2c9777d300cf38a8c4496b702
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Reviewed-by: Chris René Lerner <chris.lerner@qt.io>
2024-04-10 19:01:06 +00:00
Axel Spoerl 58d5d4b7c2 Abstract QWidget focus chain management
The focus chain in widgets is implemented as a double-linked list,
using QWidgetPrivate::focus_next and focus_prev as pointers to the
next/previous widget in the focus chain.

These pointers are manipulated directly at many places, which is error
prone and difficult to read.

Build an abstraction layer and remove direct usage of focus_next and
focus_prev. Provide functions to insert and remove widgets to/from the
focus chain.

Add a test function to tst_QWidget.

Task-number: QTBUG-121478
Change-Id: Ide6379c0197137e420352a2976912f2de8a8b338
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
2024-04-04 16:13:29 +02:00
Tor Arne Vestbø 697e1b0397 Decouple rate-limiting of paint-on-screen widgets from top level widget
As part of eacd58d4e7, a mechanism was
added to prevent posting redundant UpdateRequest events to the top
level widget, managed by QWidgetRepaintManager. The mechanism relied
on a boolean that was set when posting an update request event, and
reset when processing the event for the top level widget, as part
of QWidgetRepaintManager::sync().

However, for paint-on-screen widgets, we don't post an update request
to the top level, we post it to the paint-on-screen widget directly.
And when processing that event, we don't paint the widget though the
normal QWidgetRepaintManager machinery, but instead call the paint
event via QWidgetPrivate::paintOnScreen().

As a result, an update() on a paint-on-screen widget would result
in never receiving updates for non-paint-on-screen widgets, as
we assumed there was no reason to send further update requests.

We could fix this by clearing the updateRequestSent flag as part
of the paintOnScreen() code path, but that's incorrect as the flag
represents whether the top level QWidgetRepaintManager needs an
update request event or not, and would lead to missed updates
to normal widgets until the paint-on-screen widget finishes its
update.

Instead, we only set updateRequestSent if we're posting update
requests for non-paint-on-screen widgets, which in practice
means the top level widget.

The paint on screen logic in QWidgetRepaintManager::markDirty
still takes care of rate-limiting the update requests to the
paint-on-screen widget, by comparing the dirty area of the
widget.

There is definite room for improvement here, especially in the
direction of handling update requests via QWindow::requestUpdate
instead of manually posted events, but for now this will have to
do.

Fixes: QTBUG-80167
Pick-to: 6.7 6.6 6.5 6.2 5.15
Change-Id: Ib5685de7ca2fd7cd7883a25bb7bc0255ea242d30
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
2024-04-04 01:26:56 +02:00
Giuseppe D'Angelo 8414a0aa2c Tests: check the output of QFile::open
Wrap the call in QVERIFY.

tst_QTextStream::read0d0d0a was also faulty as it *never* opened
the file because of a broken path. Fix it with QFINDTESTDATA.

Change-Id: I61a8f83beddf098d37fda13cb3bfb4aaa4913fc5
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2024-03-27 04:24:11 +01:00
Frédéric Lefebvre 36e65785ec tst_QWidget::reverseTabOrder remove QApplicationPrivate::setActiveWindo
2f6fe3a268 has made calls to
QApplicationPrivate::setActiveWindow() redundant.

Remove redundant calls.

Task-number: QTBUG-121488
Change-Id: Ifd2c5dcd1cc3d13f689ffd6400ffec0fcc3a6b93
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
2024-03-25 19:16:19 +01:00
Axel Spoerl c0511410e5 tst_QWidget: use focus abstraction instead of focus_next/prev
Focus abstraction in QWidgetPrivate makes direct access to
QWidget::focus_next and focus_prev an antipattern.
Remove usage.

Add object names for better diagnostics when debugging focus issues.

Task-number: QTBUG-121478
Change-Id: Iecd3bdc824bf77c519951f8f7801eb50b29a6e00
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2024-03-22 22:42:16 +00:00
Frédéric Lefebvre e73295f908 tst_QWidget::tabOrderWithProxy remove QApplicationPrivate::setActiveWind
2f6fe3a268 has made calls to
QApplicationPrivate::setActiveWindow() redundant.

Remove redundant calls.

Task-number: QTBUG-121488
Change-Id: Id3b9967ddaa7dbb87eef9faaf4681d7cb014ba8c
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
2024-03-22 20:23:53 +01:00
Frédéric Lefebvre 3cbb6e0e5f tst_QWidget::tabOrderWithProxyDisabled() remove setActiveWindow()
2f6fe3a268 has made calls to
QApplicationPrivate::setActiveWindow() redundant.

Remove redundant calls.

Task-number: QTBUG-121488
Change-Id: I88d39def0e85e147b3621d98d150ee65463be94f
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
2024-03-22 20:23:53 +01:00
Frédéric Lefebvre e4dcebc19b tst_QWidget::tabOrderWithCompoundWidgets() remove setActiveWindow()
2f6fe3a268 has made calls to
QApplicationPrivate::setActiveWindow() redundant.

Remove redundant calls.

Task-number: QTBUG-121488
Change-Id: If805bc0e021625b94edc83d7abccc435c1880bea
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
2024-03-22 20:23:53 +01:00
Frédéric Lefebvre 6d5880d81b tst_QWidget::tabOrderWithProxyOutOfOrder() remove setActiveWindow()
2f6fe3a268 has made calls to
QApplicationPrivate::setActiveWindow() redundant.

Remove redundant calls.

Task-number: QTBUG-121488
Change-Id: I7a4b21018216c2b7cced8d4aa5084c527b694f4a
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
2024-03-22 20:23:52 +01:00
Frédéric Lefebvre 84dc1f2123 tst_QWidget::tabOrderWithCompoundWidgetsNoFocusPolicy remove setActiveW
2f6fe3a268 has made calls to
QApplicationPrivate::setActiveWindow() redundant.

Remove redundant calls.

Task-number: QTBUG-121488
Change-Id: Ieb516cc4fd02230c0ec6bb189da049c3741358dd
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
2024-03-22 20:23:52 +01:00
Frédéric Lefebvre fbcd223507 tst_QWidget::defaultTabOrder() remove setActiveWindow()
2f6fe3a268 has made calls to
QApplicationPrivate::setActiveWindow() redundant.

Remove redundant calls.

Task-number: QTBUG-121488
Change-Id: I2faaf575a04652a395956c7d790ac18d9f3ec9e6
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2024-03-22 14:54:48 +00:00
Frédéric Lefebvre a5b9ba15e2 tst_QWidget::explicitTabOrderWithComplexWidget remove setActiveWindow()
2f6fe3a268 has made calls to
QApplicationPrivate::setActiveWindow() redundant.

Remove redundant calls.

Task-number: QTBUG-121488
Change-Id: I0271f3baf718ca5ae03464bbd415cd0feaa9087d
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2024-03-22 13:51:33 +01:00
Liang Qi 91079e64d8 tests: skip tst_QApplication::abortQuitOnShow() on Wayland
The test started to "crash" since 576c9160b1.

Task-number: QTBUG-123172
Change-Id: I16c78f517f718510aa22a2e24ed3d502edae52e5
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
2024-03-22 09:53:06 +01:00
Tor Arne Vestbø c956eb8edd Reparent QWindow children when reparenting QWidget
When a QWidget was reparented, we would take care to reparent its
backing QWidgetWindow as well, into the nearest QWindow of the
new QWidget parent.

However we would only do this for the reparented widget itself,
and not any of its child widgets. In the case where the widget
has native children with their own QWindows, the widget itself
may not (yet) be native, e.g. if it hasn't been shown yet, or
if the user has set Qt::WA_DontCreateNativeAncestors.

In these scenarios, we would be left with dangling QWindows,
still hanging off their original QWindow parents, which
would eventually lead to crashes.

We now reparent both the QWindow of the reparented widget (as
long as it's not about to be destroyed), and any QQWindow
children we can reach. For each child hierarchy we can stop
once we reach a QWindow, as the QWindow children of that
window will follow along once we reparent the QWindow.

QWindowContainer widgets don't usually have their own
windowHandle(), but still manage a QWindow inside their
parent widget hierarchy. These will not be reparented
during QWidgetPrivate::setParent_sys(), but instead
do their own reparenting later in QWidget::setParent
via QWindowContainer::parentWasChanged(). The only
exception to this is when the top level is about to
be destroyed, in which case we let the window container
know during QWidgetPrivate::setParent_sys().

Finally, although there should not be any leftover
QWindows in the reparented widget once we have done
the QWidgetWindow and QWindowContainer reparenting,
we still do a pass over any remaining QWindows and
reparent those too, since the original code included
this as a possibility.

We could make further improvements in this areas, such
as moving the QWindowContainer::parentWasChanged() call,
but the goal was to keep this change as minimal as possible
so we can back-port it.

Fixes: QTBUG-122747
Pick-to: 6.7.0 6.7 6.6 6.5
Change-Id: I4d1217fce4c3c48cf5f7bfbe9d561ab408ceebb2
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2024-03-14 13:50:36 +00:00
Liang Qi 4dca61cbda Revert "tests: blacklist tst_QWidget::render() on Wayland"
This reverts commit c41733b06b.

Based on the Grafana data, last flaky was August 14, 2023, and
the test works fine on local vm with stressed cpu.

Fixes: QTBUG-115598
Pick-to: 6.7 6.6 6.5
Change-Id: I634598d20a581d4d1443a3fd81e1e9481bfa2545
Reviewed-by: Inho Lee <inho.lee@qt.io>
2024-03-04 10:04:31 +00:00
Yansheng Zhu 70096b2bbd Implement Qt::ImEnabled by isEnabled() and isReadOnly()
Previously, querying Qt::ImEnabled only returned the value of
isEnabling(), which is incorrect for edit widgets with read-only
properties set, as Qt::ImEnabled indicates whether text can be *input*
through the input method, which results in the IM being able to insert
text into read-only edit widgets.

The fixed version uses both isEnabling() and isReadOnly() values to
determine whether input methods need to be enabled. For some platforms
(like iOS and Android) that rely on IM to select text, a check for
ImReadOnly has been added to their QPA plugins to enable handles on
read-only input boxes.

At the same time, the imEnabledNotImplemented function in the test file
tst_qwidget was modified, since ImEnabling should give a _false_ value
when a lineedit is read-only.

Task-number: QTBUG-105009
Task-number: QTBUG-110838
Task-number: QTBUG-119182
Pick-to: 6.7 6.6 6.5
Change-Id: Ia2abcdb3200826d567f90447d4f8b71d0ef1fbf0
Reviewed-by: Yansheng Zhu <670429759@qq.com>
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
2024-03-01 02:22:06 +08:00
Tinja Paavoseppä 32197e94d7 Android: Make timeout in tst_QApplication::abortQuitOnShow() longer
Since the Android emulator on CI is running without hardware accelerated
graphics, showing the widget can take almost the same time as the timeout
for exiting the app with the "wrong" exit code 1. If running on Android,
increase the timeout to 1000 ms to avoid flaky failures. Un-blacklist
tst_QApplication::abortQuitOnShow() since the random failures are
taken care of by this patch.

Task-number: QTBUG-122693
Pick-to: 6.7
Change-Id: Id52ae15b3ab2dbdaf4924b675276dfe3a4168585
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
2024-02-27 17:28:19 +00:00
Chris Lerner 086897a1ae tst_QWidget::realFocusChain: don't remove from iterated QList
The method removed from QWidgetList widgets in a ranged for loop.
That caused items being skipped.

Create a new list by adding positives, instead of removing negatives
from the original.

This amends b1802a164b.

Pick-to: 6.7 6.6
Change-Id: I3f329290187ddc76169ababe8ffa6059d953212d
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2024-02-24 11:41:18 +00:00
Volker Hilsheimer 28572aad11 Blacklist tst_QApplication::abortQuitOnShow on Android
Task-number: QTBUG-122693
Pick-to: 6.7
Change-Id: I48b62a47939037f58ca321e4498d8b98d79042d8
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
Reviewed-by: Tinja Paavoseppä <tinja.paavoseppa@qt.io>
2024-02-23 19:11:04 +01:00