Commit Graph

1082 Commits (bb10)

Author SHA1 Message Date
Matthias Rauter 2f5e2f4630 Silence warning in tst_qwidget.cpp
Amends: 1a0f056f318417ba5e54c8110257b75cf5537acb

Change-Id: Ib67016bbb7d5abe48224d23d49e36e2e01e416fc
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
(cherry picked from commit 2c15086b7ed561b59cfb0d028c35d15631c12738)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
(cherry picked from commit b05f06d5b97263a194e14edf6ea5a7b649c6db64)
2025-02-18 22:58:30 +00:00
Frédéric Lefebvre 4337841f04 tst_QGestureRecognizer::swipeGesture set FramelessWindowHint
tst_QGestureRecognizer::swipeGesture() is flaky as sometimes the
gesture event is being sent before the widget's position has
been updated.

The gesture starts in the window frame.

Set flag Qt::FramelessWindowFrame to prevent this from
happening.

Fix flakiness on Opensuse 15

Change-Id: I794b022b5a51146ddfa7d6029509c6fa43b9aad6
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
(cherry picked from commit 6dc0e593939cbeaeb45392d8daf7fcd90e8cb0f8)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
(cherry picked from commit 829b67074e2d1523ec9730fc76e31f41c416ad87)
2025-02-11 19:48:45 +00:00
Frédéric Lefebvre 9eec05de3f tst_QGestureRecognizer::touchReplay give fix position
tst_QGestureRecognizer::panGesture() is flaky as sometimes
the gesture event is being sent outside of the parent. It
is being sent in the window frame instead of in the widget.

Fix position of the parent and verify that it is correct.

Fix flakiness on Opensuse 15

Change-Id: I00eacb80a7e2e658345d3bc56cdef0c0024d1a1d
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
(cherry picked from commit 3766b9cb3cb49fdef626526181b6a7fe26870e29)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
(cherry picked from commit 69738c76b49dc2f6ce77d9db0fbcb08eed7ecff9)
2025-02-11 19:48:45 +00:00
Frédéric Lefebvre 442614e8fb Tst_QGestureRecognizer::panGesture set FramelessWindowHint
tst_QGestureRecognizer::panGesture() is flaky as sometimes the gesture
event is being sent before the frame and position has had time to
update. The event then starts in the frame and is not received by the
widget.

Set FramelessWindowHint flag to the widget, to remove the need of
updating its frame position and position.

Fix flakiness on Opensuse 15

Pick-to: 6.5
Change-Id: Id88510a91e3ed0d5ff92fdc31422503744448b3e
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
(cherry picked from commit fc0e788d029beac251fda40650154fc6865e1649)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
(cherry picked from commit ea55328741c6a1aceb7b1a456c00d976be940a42)
2025-02-10 21:26:25 +00:00
Giuseppe D'Angelo d25dbb9a7b tst_QGestureRecognizer: do not leak the point device
QTest::createTouchDevice() passes ownership of the device to the caller,
so make sure to delete it.

Change-Id: I100d3de9eab8ec9f88ed3e0850ada9d988bd962e
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
(cherry picked from commit 28d0e658e297b5de52fb0cccaede08179c7f4b8c)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
(cherry picked from commit 8ef6d4ede857691798465eafcb7571f6c42c0ba9)
2025-02-02 15:38:10 +00:00
Thiago Macieira c17da11f5f tst_Q*Application: add tests for unusual qApp creations and exits
This commit adds one unusual creation and three more unusual exits:
* creation of the Q*Application in a thread (QTBUG-130895)
* exits using ::exit() instead of returning from main():
  * from the main thread's event loop
  * from an auxiliary thread
  * from inside an auxiliary thread's event loop

All of these exercise the moment the QAdoptedThread & QThreadData for
the main thread is destroyed, which are, respectively:
* thread exit time, running thread-specific destructors
* inside exit(), running atexit()-like callbacks (qthread_*.cpp)
* [tst_static_q*application] inside exit(), running static destructors
  (added in commit 1da7558bfd7626bcc40a214a90ae5027f32f6c7f)

Unlike the tst_static_q*application tests, the calls to ::exit() cannot
be a regular QtTest because that would cause the log output to be
incomplete. The threaded Q*Application could be a test of its own, but
since I needed to add the helper anyway, I chose to add the test there.

For the majority of the tests, the failure mode is going to be a crash
on exit.

Task-number: QTBUG-12673
Task-number: QTBUG-132429
Change-Id: I1062ef500356bd97dd0cfffda4aeeda9afa138e8
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
(cherry picked from commit bfbd1a281dd00c47df315c06e895bf5d53cd8764)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
(cherry picked from commit ea6d467c050c9e4ab58f970f6720b428ec43c8e2)
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2025-01-20 13:31:34 -08:00
Thiago Macieira 5acbda4b06 QThread/Unix: revert to pthread destruction instead of thread_local
Amends 65093a84c2b94b1543fd4593bc45d491951d28d4, which changed how we
destroyed the main thread's QThreadData. This merges the call to
destroy_current_thread_data() for both types of Unix systems: those with
broken thread_local destructors and those with working ones. It turns
out that the function got called too early for us in those working
systems (see updated comment).

The clean up of the QThreadData is split into two different mechanisms:
 * for any auxiliary thread, when it exits, PThread will call back to
   destroy_current_thread_data()
 * for the thread that called ::exit(), PThread won't, but ::exit() will
   invoke set_thread_data()::TlsKey's destructor

This is different from the situation that existed prior to commit
65093a84c2b94b1543fd4593bc45d491951d28d4: first, there's no code in
qcoreapplication.cpp for this (all in qthread_unix.cpp). Second one may
call ::exit() from any thread, whether that is the thread that called
main(), the thread Qt thinks is theMainThread, or any other.

This commit moves the tst_QCoreApplication check for no extant objects
to a new test. I've chosen to add a new test instead of running a helper
binary via QProcess because we do have a couple of !QT_CONFIG(process)
platforms in the CI, and this is too important.

Credit to OSS-Fuzz for finding this, though it is not itself a fuzzying
problem (all tests of a given structure were crashing on exit).

Fixes: QTBUG-132381
Task-number: QTBUG-130895
Task-number: QTBUG-129927
Task-number: QTBUG-129846
Task-number: QTBUG-130341
Task-number: QTBUG-117996
Change-Id: Ie294dce7263b4189f89ffffd9155ec71d31b89d9
Reviewed-by: Robert Löhning <robert.loehning@qt.io>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
(cherry picked from commit 1da7558bfd7626bcc40a214a90ae5027f32f6c7f)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
(cherry picked from commit 6dc19b55fc6d6dd3198b744f713101cf3b77c0c8)
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2025-01-14 02:21:01 -03:00
Tor Arne Vestbø eaaab38c3a Extend blacklisting of tst_QWidget::showMinimizedKeepsFocus to macOS 15
It's flaky on all version.

Change-Id: I01b2f0877efc100578c55d69e9f9ed65c02b2aab
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
(cherry picked from commit 1ce019815ba62245fd8ae6e8fb5e47f77621c3be)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
(cherry picked from commit 5051e2b97b44e43ddbdc9ec2beddb162e2d61a0d)
2024-12-20 04:30:28 +00:00
Christian Ehrlicher f70803eefb QBoxLayout: don't crash on passing invalid index
Passing an invalid index gives an assertion in debug mode and crashes in
release mode due to an out-of-bounds access. Fix it by appending the
given widget (same as passing a negative index which is documented).

Pick-to: 6.5 6.2
Fixes: QTBUG-130275
Change-Id: Id0c245e185acc36e5d07cea1d22619bb0e9eee07
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
(cherry picked from commit 0f9062ec71021c256dba7ee8498f036d7aac0821)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
(cherry picked from commit 3c0f08ab7064d2c4183844613f08b3630f180fef)
2024-12-19 05:16:38 +00:00
Frédéric Lefebvre 8a874d5b31 Fix flakiness in tst_QWidget::saveRestoreGeometry()
Add setWindowFlags(Qt::X11BypassWindowManagerHint) to bypass the
creation of the frame. We are checking the geometry of the widget
itself, not of his frame in this test.

Remove the comments preventing that it can be flaky when debugging.

Remove unnecessary QApplication::processEvents().

Remove several unnecessary qWait().

Change-Id: I4a4bcf5cb9522a9a504925c1ae31f0677deae3b1
Pick-to: 6.7 6.5
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
(cherry picked from commit cf45ae08bc90b5dbbd20a7e7842856805205bca4)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-11-29 16:58:42 +00:00
Johannes Grunenberg 4a27d0fe0a QWidget: clamp own rect in pointInsideRectAndMask
The rect of an empty widget (i.e. 0 width/height) will, after adjusting
by -1, be invalid as it will have a width/height of -1. In turn, calling
contains(p) on that rect can return true even though the rect is empty.

Fixes: QTBUG-131001
Pick-to: 6.8.1
Change-Id: I604f5942589f1c1079cae90bd0d3b104344d2c55
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Reviewed-by: David Faure <david.faure@kdab.com>
(cherry picked from commit 1731d8af741a0a6cc6cd293be4aef52103d0899b)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-11-11 19:47:03 +00:00
Friedemann Kleint cb0ac3d471 Tests: Reduce the number of module includes
They are an unnecessary hit on build time.
Rewrite the tests using the standard Qt conventions.

Change-Id: Iac47e62c58b1805c3b4a0ac4f4b3db206c66cc65
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
(cherry picked from commit 6ddf74716d7b2fe0df5dd9c0172f9ecf936d5c5d)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-11-04 19:42:27 +00:00
Liang Qi 8719c2f784 tests: use qWaitForWindowFocused() instead of qWaitForWindowActive()
This depends on 9eb06a2848 .

This follows bc7821764b4d50fbb4e0ca1b84f85980ce15eeb0 and
5709baea2c261f77f955ab76c074a39c9c3993aa.

There are lots of work to remove QApplicationPrivate::setActiveWindow()
in test code, see also QTBUG-121488. We need to adapt them for Wayland.

Task-number: QTBUG-125446
Task-number: QTBUG-121488
Change-Id: I093568c1d89de31c3893d3c7b139f1db33579633
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
(cherry picked from commit f42979cf6937c78c412fcfa25ec011fb66b48132)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-10-03 08:37:05 +00:00
Liang Qi faff79d59e tests: blacklist tst_QWindowContainer::testFocus() on Wayland
Task-number: QTBUG-129292
Change-Id: I1b0dfae10b7b0f5348605121da1903d9c7247dba
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
(cherry picked from commit 7039232c2e4c623b341461526a22f775b1196882)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-10-03 08:37:04 +00:00
Liang Qi 18a24eabbe tests: skip tst_QWidget_window::tst_dnd_events() on u2404 x11
Task-number: QTBUG-129567
Change-Id: I108a468033a9579b07a379470a43aa94d5cf9ec0
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Reviewed-by: Dimitrios Apostolou <jimis@qt.io>
(cherry picked from commit c851602020cd564d42c9721eb19888471a11107c)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-10-03 08:36:59 +00:00
Liang Qi 8b21bf2ae2 tests: blacklist tst_QWidget_window::mouseMoveWithPopup() on u2404 x11
Task-number: QTBUG-129568
Change-Id: Ie1d9fc7e32c0766d55324aae0dbd07218ac8599f
Reviewed-by: Dimitrios Apostolou <jimis@qt.io>
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
(cherry picked from commit c5ee1f68c02ca3942c94f246fba56ef4ffe7f229)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-10-03 08:36:57 +00:00
Tor Arne Vestbø 964b16e6d3 tst_QWidget::tabOrderWithProxyOutOfOrder: Ensure Qt::TabFocusAllControls
The test requires Qt::TabFocusAllControls, so Qt::TabFocusTextControls
and/or Qt::TabFocusListControls, which is the default on macOS, is not
sufficient.

Change-Id: Iaf84c7ba67b978b942f396911048716417c38c03
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
(cherry picked from commit 283cfe0b80f83833a549d79e2787f5b936d90236)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-09-23 14:44:13 +00:00
Liang Qi 59a3f43031 tests: blacklist tst_QWidget_window::setWindowState(maximized)
on u24.04 x11

Task-number: QTBUG-129026
Change-Id: I14bf0ff3f2704aa1f7fccfdd57164f935892ae46
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
(cherry picked from commit 90ed33091a62ddfd53fc2cd8c232089367aca80b)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-09-20 00:43:17 +00:00
Liang Qi 802c798703 tests: update row names in tst_QWidget_window::setWindowState()
Task-number: QTBUG-129026
Change-Id: I18c02b0a099924bd64115a1721c1d4f26b91f110
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
(cherry picked from commit 0c1c91aee9c9f4aa2e67412ebec885f92f06a5dc)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-09-20 00:43:10 +00:00
Tero Heikkinen 7413f60436 Add QEXPECT_FAIL for failing tst_qwdidget test on Windows ARM
tst_QWidget::render_windowOpacity
  - Fails constantly, therefore QEXPECT_FAIL better than blacklist

tst_QWidget::enterLeaveOnWindowShowHide(dialog)
  - Known flaky, but doesn't need blacklist as it passes when
    rerun is used, no need for actions.

Task-number: QTBUG-128371
Task-number: QTBUG-128372
Task-number: QTQAINFRA-6396
Change-Id: I806419996fedea22628eecf311e977c74066d748
Reviewed-by: Tero Heikkinen <tero.heikkinen@qt.io>
Reviewed-by: Dimitrios Apostolou <jimis@qt.io>
(cherry picked from commit 975b4c078036427d2bf7026f1ba50ad095d83172)
Reviewed-by: Tony Sarajärvi <tony.sarajarvi@qt.io>
2024-09-19 15:09:46 +00:00
Liang Qi 1a7f6925ab tests: use qWaitForWindowFocused() instead of qWaitForWindowActive()
This depends on 9eb06a2848 .

Done-with: Inho Lee <inho.lee@qt.io>
Task-number: QTBUG-107157
Pick-to: 6.7
Change-Id: I9f4521c27ebc847596a94eed0c9116d71905def2
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
(cherry picked from commit bc7821764b4d50fbb4e0ca1b84f85980ce15eeb0)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-09-19 14:41:49 +02:00
Axel Spoerl 0a8a34fbe1 Remove tst_QWidget::render_task252837()
The test function renders a pixmap into a widget that is never shown.
It checks for a crash, without failing or passing.

tst_QWidget::render_graphicsEffect() tests the same code path.

Remove the unneeded test function.

Change-Id: I1b64e0466c5a133deec28d0f74ef5acd9858e1ea
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
(cherry picked from commit dfdcb90ffdec0c3a4f7c1c5c59dfba5c04b8c521)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-08-25 12:54:34 +00:00
Tor Arne Vestbø 79be5fa986 Make QWidgetPrivate::setVisible virtual
Initially the function was used as a helper function for QWidget,
implemented in da55a1b041. But with
e0bb9e81ab we started overriding it
e.g. QDialog. This "worked" because QDialog itself would call the
private helper, but left a footgun when called via a plain QWidget
pointer, as we did in 5ba0982b28.

That specific instance of the problem was solved by the change in
fc4c6fb5f6bd6bd63b13f1f8b5b7a7289a5fd230, but the trap still exists.

To ensure we can use the function in a polymorphic context in the
future we make it virtual.

Task-number: QTBUG-127806
Change-Id: Ic0810c5439b1e696cfbf199e701f41217acc5742
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
(cherry picked from commit 1a0f056f318417ba5e54c8110257b75cf5537acb)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-08-12 17:26:50 +00:00
Axel Spoerl a94b3deb49 Add missing break in tst_QWidget::reparentWindowHandles()
6c036012b5f2304a05af29f29daa7582603f79ae added a case branch to a
switch before the break of the previous case.

Amend the commit and add the missing break.

Task-number: QTBUG-127641
Task-number: QTBUG-125149
Task-number: QTBUG-122747
Pick-to: 6.7 6.5
Change-Id: I3f2b3e07db463b72fa99af493f40cbc1a783f1ed
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
(cherry picked from commit 1d409c0854d664bafc2a35b33cb73129a51c947a)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-08-12 09:43:38 +00:00
Liang Qi afd6ae6091 tests: blacklist tst_QWidget::saveRestoreGeometry() on u24.04 x11
Task-number: QTBUG-126495
Change-Id: I26905d7c2bbcad9a092bbd8084494a1ad0af9ee3
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
(cherry picked from commit a660c8e94daca1c362fd955d28a01f715b62ade3)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-08-10 07:57:18 +00:00
Tor Arne Vestbø 5400025796 widgets: Persist window Qt::Popup state when reparenting parent widget
As a result of c956eb8edd we are now
reparenting QWindows managed by QWidgets when the widget itself or
any of its parent widgets are reparented. When reparenting a child
widget from being a child to a top level, or top level to child, we
need to know the new top level state to determine if the QWindow
should have a QWindow parent or not. As the window flags of the
widget are in flux during the reparenting, we were using the new
window flags of the reparented widget to determine this.

However, for QWidget children of the widget that's being reparented
we can't use the window flags of the reparented widget. We must use
the flags of the child itself. These flags are not in flux, so we
can use QWidget::windowFlags() directly.

Failing to propagate the child widget window flags was causing us to
lose the transient parent relationship to its parent QWindow for
popup windows.

Fixes: QTBUG-127641
Fixes: QTBUG-125149
Task-number: QTBUG-122747
Pick-to: 6.7 6.5
Change-Id: I6dbc5ff5ad019b0f9188516ff3d645e860a9627b
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
Reviewed-by: Volodymyr Zibarov <gogan419@gmail.com>
(cherry picked from commit 6c036012b5f2304a05af29f29daa7582603f79ae)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-08-07 09:29:02 +00:00
Liang Qi eadaecdc63 tests: skip tst_QApplication::abortQuitOnShow() on Wayland - 2
This amends 91079e64d8 .

It needs to have a QGuiApplication object before the check.

Task-number: QTBUG-123172
Change-Id: I51929431e69e4584c46e2dc08ca9c33b48b900c6
Reviewed-by: Inho Lee <inho.lee@qt.io>
(cherry picked from commit e743931294d9d9c4e5a27d2644fd1cd354ce56cb)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-07-25 20:06:40 +00:00
Axel Spoerl 678dccb7ac Revert "Update window state in QWindowsWindow and QXcbWindow geometry setters"
This reverts commit 99c8ffb9f2. It fixed
QTBUG-104201, which in essence pointed out a state mismatch between
widgets and platform windows on Linux (X11 and wayland). Mismatches
occurred in the margins between calls to QWidget and async screen
rendering: While the widget layer reported the expected size, the
platform layer did so only after the rendering thread had finished.

As mentioned in the comments of QTBUG-104201, the state mismatch is
predictable, temporary and consistent.

By bridging the time gab, an async operation was made to look
synchronous. That gave more comfort to application developers. By
oversight, it broke code that relied on the platform window state
reflecting physical rendering. This has caused QTBUG-126479 as a
regression.

Both purposes can't be served at the same time: The platform window
state either reflects rendering, or the expected state. It's therefore
justified to revert.

Reason for revert: <Causes QTBUG-126479>

Pick-to: 6.7 6.5
Fixes: QTBUG-126479
Task-number: QTBUG-104201
Change-Id: I22380a6a463822a1cb4be90a44d2775954c7ca82
Reviewed-by: Liang Qi <liang.qi@qt.io>
(cherry picked from commit 7d7be38d95eb82ef3e0be5250440072d8b5bc4b2)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-07-17 01:49:09 +00:00
Tor Arne Vestbø f0f9cc602f Let QWindowContainer know when its top level is about to be destroyed
When the top level window that a QWindowContainer is in is about to
be destroyed the QWindowContainer must reparent the contained window
into a dummy window, as otherwise the destruction of the top level
will bring down the contained window as well.

We were notifying the window container about this situation when
the window container was moved from being a top level itself, to
being a child widget, but did not have any logic for other ways
the window container could lose its parent QWindow.

An example of this was when RHI-needs would result in recreating
the top revel with a different RHI backend.

We now have a last minute call to toplevelAboutToBeDestroyed in
QWidgetPrivate::deleteTLSysExtra().

Fixes: QTBUG-126303
Pick-to: 6.7 6.5
Change-Id: I5b14e156956ae76a8f53cac31904eaadee9e791f
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
(cherry picked from commit 006cbf658ea1f5986bbe1baafa7c146780320661)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-06-20 19:30:49 +00:00
Shawn Rutledge b1481a1663 Fix MouseButtonDblClick synthesis from touch double-tap
When QGuiApplicationPrivate::processTouchEvent() sees that the
touch event was not handled, and calls processMouseEvent(), the latter
uses the QEventPoint with pointId 0 regardless of the original
touchpoint ID. Now it updates the persistent QEventPoint from the
original touchpoint so that a double-click event will not be ruled out
because of the timestamp delta or position delta (movement since press)
being too large.

Fixes: QTBUG-125993
Pick-to: 6.7 6.5
Change-Id: I8e9b007818107ac2329454e0ccfb2ac9e506b617
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
(cherry picked from commit 2a0b907f11b9c0ad46322ba06482861423246d93)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-06-11 16:36:38 +00:00
Tor Arne Vestbø eb4cb71925 widgets: Use per-surface-format RHI support and compositor
The RHI support and compositor in QPlatformBackingStore were
tied to the surface format of the top level window owning
the backing store.

This meant that inserting an RHI-enabled widget (QRhiWidget,
QOpenGLWidget, QQuickWidget, QWebEngineView) into the widget
hierarchy required recreating the top level window with a
matching surface format that could support the RHI composition.

It also meant that we could not have two RHI enabled widgets
with different surface format requirements (Metal and OpenGL
for example) in the same top level widget hierarchy.

The recreation of the window had various visual side effects,
such as temporarily switching out of full screen state, or the
widget rendering a frame of black, as well as more serious
problems such as not correctly restoring the window geometry.

In addition, if client code had pulled out the winId() of the
window, and did not invalidate these references on window
destruction via QEvent::WinIdChange or QEvent::PlatformSurface,
the client would reference stale window handles. Although
this is a programming error (QWidget::winId() specifically
mentions this requirement), we should avoid recreation if
we can.

We were already supporting flushing the backingstore to
individual native child widgets, but always did so via a
single RHI managed by the platform backingstore. By
expanding QPlatformBackingStore to keep one set of RHI
support and compositor per surface format, we can refine
the logic in QWidget and QWidgetRepaintManager to not
require recreating the top level. Native child widgets
are then flushed independently, including any RHI textures
and raster content that overlaps with the widget.

We still assume that a single RHI support and compositor
can be be used for multiple windows, as long as those
windows have the same surface format. In the future, if
needed, we can refine this to use one set per surface
format e.g.

Fixes: QTBUG-119221
Fixes: QTBUG-121181
Fixes: QTBUG-120096
Task-number: QTBUG-115652
Task-number: QTBUG-108344
Task-number: QTBUG-113557
Task-number: QTBUG-119309
Change-Id: I2635ed3d20c2fb76eab3b8130007dd656a0b93e5
Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
2024-06-01 00:24:34 +02:00
Shawn Rutledge e4ef0f03e6 Move popup management from QApplication to QGuiApplication
We need to be able to have true popup windows in Qt Quick and Controls,
including handling the press-drag-release sequence to select one entry
from a menu or combobox. After the mouse press, a new window is created.
On some platforms (such as xcb), the new window gets window system grabs
of both keyboard and mouse (QApplicationPrivate::openPopup() calls
grabForPopup() and it actually works); while on others, the pre-existing
window continues to get the whole sequence of mouse events until the
release. In the latter case, Qt needs to forward events from the
original window to the popup. Until now, the list of popups was
QApplicationPrivate::popupWidgets.

Now we track the open popups as a list of QWindows rather than QWidgets,
in QGuiApplicationPrivate::popup_list, and add a set of static functions
to manage that list. Functions such as QApplication::activePopupWidget()
QApplicationPrivate::openPopup() and closePopup() are rewritten to make
requests to QGuiApplicationPrivate.

276943c8b7 made
QGuiApplicationPrivate::closeAllPopups() virtual. That is now reverted,
because we're putting QGuiApplication in charge of popup management
and trying to minimize widget-specific behavior. So far,
QApplicationPrivate::closePopup() is still overridden to take care
of focus changes.

So far, QtGui does not take care of closing popups when the user
clicks outside: the active popup window gets those events, and needs
to close itself if the click occurs outside. An attempt to move this
logic raised some issues with legacy widget test cases.

Using a touchscreen to press on QMenuBar and open a QMenu, drag to
a menu item and release, is temporarily broken for now. The plan is
to fix it in a subsequent patch.

Task-number: QTBUG-68080
Task-number: QTBUG-69777
Change-Id: I02b5034987b5ee8909917d305f414c8b0db9c7f5
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
2024-05-31 10:40:31 -07:00
Axel Spoerl 2d4993899f Widgets focus abstraction: Fix re-parenting
Focus abstraction in 58d5d4b7c2 was
supposed to be behavior-neutral. QWidgetPrivate::reparentFocusChildren
used QObject::findChildren() to find children inside and outside the
current focus chain. If the re-parented widget had only direct children
and the focus chain was equal to creation-order, the result was
identical to previous behavior.

When the re-parented widget had grandchildren, the behavior differred.
While not being detected by existing tests, it caused a regression.

Re-implement the previous logic: Iterate through the focus chain,
instead of relying on QObject::findChildren() returning a complete and
well-ordered list.

Modify tst_QWidget::focusChainOnReparent() in order to cover the
regression.

This amends 58d5d4b7c2.

Fixes: QTBUG-125257
Change-Id: Iff4f1d0d9b6117c50c8980dfb6eebfc6f6d4a710
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2024-05-23 01:12:32 +02:00
Christian Ehrlicher f6fdd91941 Tests/QWidget: fix hoverPosition test for openSUSE
On some xcb platforms the xcb_configure_notify_event_t is sent after the
window is fully exposed which leads to a wrong position for
QWidget::mapToGlobal(). In this case this results in a wrong position
for QCursor::setPos() which lets the test fail.
Fix it by waiting for a move event with a position != 0,0 before calling
mapToParent/Global().

Pick-to: 6.7 6.5 6.2
Fixes: QTBUG-123998
Change-Id: Ic5e989c4497ccf3ed720a521f9d7e73632b4b1fc
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
2024-05-16 22:18:53 +02:00
Volodymyr Zibarov 4585cacaa9 Add way to override when to show context menu
Add Qt::ContextMenuTrigger enum used with
QStyleHints::setContextMenuTrigger() to override default platform
behavior when to trigger context menu event.
The default is to show context menu on mouse press on
UNIX systems and on mouse release on Windows.

Give developer a possibility to override platform default behavior
to make cross platform application that behaves the same way on all
platforms

Task-number: QTBUG-93486
Change-Id: Ic832d3d8a7c355a8adb46868fff9cfd19988cf3c
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2024-05-13 22:32:34 +00:00
Volker Hilsheimer 95d4e6baba ColorScheme: make QStyleHints::colorScheme writable for applications
Applications can request the color scheme to be either explicitly light
or dark, or to follow the system default by setting the scheme to
Qt::ColorScheme::Unknown.

Setting the color scheme will make the request to the QPlatformTheme
implementation, which can then use the appropriate implementation to
set the application's appearance so that both palette and window
decoration follow the requested color scheme. This should trigger
theme change and palette change events. A change to the effective
scheme should then call back into QStyleHintsPrivate::updateColorScheme,
which will emit the changed signal for the property.

Implement this for macOS (Cocoa), iOS, Android, and Windows.

On macOS, we have to use deprecated AppKit APIs; the replacements for
those APIs are not suitable for this use case. On iOS, the setting is
for each UIWindow, which we can update or initialize based on an
explicitly requested scheme.

On Android we can piggy-back on the logic added when dark theme support
was introduced in b4a9bb1f6a.

On Windows, we have to fake a dark palette if the dark scheme is
requested on a light system, as there is no API to read a dark palette.
However, we also have to ignore any application preference if a high-
contrast accessibility theme is selected by the user (we report the
color scheme as unknown; there are both light and dark high-contrast
themes), and read the system palette using the GetSysColor API, which
is used for light mode. And we need to initialize windows with the
correct frame if the application explicitly overrides the system color
scheme.

Add an auto-test to the QApplication test, as that gives us the most
coverage to confirm that QStyleHints emits the changed signal, and that
Theme- and PaletteChange events are received by the toplevel widget
when the color scheme actually changes. This test has to be skipped
on platforms where we cannot set the color scheme programmatically.

Add the option to explicitly select the color scheme to the widget
gallery example, and default it to dark mode.

Fixes: QTBUG-124490
Change-Id: I7302993c0121284bf9d3b72e3149c6abbe6bd261
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2024-05-10 01:15:12 +02:00
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