qt6-bb10/tests
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
..
auto Set focus to the window container when contained window gains focus 2024-04-22 16:01:01 +02:00
baseline Draw list bullets/numbers with CSS text color, not palette color 2024-04-19 04:13:32 -07:00
benchmarks Add QPainter benchmark case re clipping primitives exceeding device 2024-04-18 10:46:08 +02:00
global
libfuzzer Add CMYK support to QColorSpace 2024-04-12 21:53:54 +02:00
manual Fix lance readme: tests/auto/other/lancelot is gone now 2024-04-18 13:15:52 -07:00
shared QWindow: Persist foreign winId to support destroy/create cycles 2024-04-19 14:54:17 +02:00
testserver Correct license for tools files 2024-03-05 12:59:21 +01:00
CMakeLists.txt Rid of 'special case' markers 2023-04-13 18:30:58 +02:00
README

README

This directory contains autotests and benchmarks based on Qt Test. In order
to run the autotests reliably, you need to configure a desktop to match the
test environment that these tests are written for.

Linux X11:

   * The user must be logged in to an active desktop; you can't run the
     autotests without a valid DISPLAY that allows X11 connections.

   * The tests are run against a KDE3 or KDE4 desktop.

   * Window manager uses "click to focus", and not "focus follows mouse". Many
     tests move the mouse cursor around and expect this to not affect focus
     and activation.

   * Disable "click to activate", i.e., when a window is opened, the window
     manager should automatically activate it (give it input focus) and not
     wait for the user to click the window.