[Development] Calling QWindow::requestActivate after QWindow::show and before QTest::qWaitForWindowActive
Giuseppe D'Angelo
giuseppe.dangelo at kdab.com
Wed Aug 13 11:30:34 CEST 2025
Hi,
Il 13/08/25 10:02, Moss Heim via Development ha scritto:
> I would just like to point out that removing these calls (for example in
> tst_focus::policy) causes some tests to fail consistently with XCB on
> Ubuntu 24.04 and 25.04. As best I can tell this is due to "focus
> stealing prevention" behavior in GNOME[1]. We also saw this in the
> WebEngine project, both on CI and locally, which triggered me to ask the
> original question on Teams which is linked from the codereview comment.[2]
>
> In other words, as best I can tell you are not guaranteed to get active
> focus when opening and closing several windows in rapid succession on
> GNOME, this could be from a race condition or from some throttling
> behavior. If it's expected that show()ing a window**/always/**gives it
> active focus in these instances, I believe there is some bug in Qt's XCB
> platform code.
TBH, if a WM decides not to give focus to a window (to prevent focus
stealing and what not), it shouldn't give it even after a
requestActivate() or somesuch. But that's another discussion.
More on topic: if ultimately it is platform specific whether show()
alone is sufficient or one needs show()+requestAcivate() (+ QVERIFY),
couldn't this combination be packaged in some QtTest helper function, so
that people can simply call that function and it'll always do the right
thing?
My 2 c,
--
Giuseppe D'Angelo | giuseppe.dangelo at kdab.com | Senior Software Engineer
KDAB (France) S.A.S., a KDAB Group company
Tel. France +33 (0)4 90 84 08 53, http://www.kdab.com
KDAB - Trusted Software Excellence
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 4850 bytes
Desc: Firma crittografica S/MIME
URL: <http://lists.qt-project.org/pipermail/development/attachments/20250813/b3fd2010/attachment.bin>
More information about the Development
mailing list