On Tue, 12 Aug 2025 00:52:33 +0000 EXT Mitch Curtis via Development <development@qt-project.org> wrote:
> Hi, > > There's a discussion on > https://codereview.qt-project.org/c/qt/qtdeclarative/+/666818 about > whether we can standardise (by documenting in some form) that we > shouldn't call requestActivate before qWaitForWindowActive. > Essentially, existing code in tests looks like this: > > window->show(); > window->requestActivate(); > QVERIFY(QTest::qWaitForWindowActive(window.data())); > > And would become this: > > window->show(); > QVERIFY(QTest::qWaitForWindowActive(window.data())); > > As Axel has explained, this causes race conditions on XCB, and > apparently is redundant on all platforms: > > > To begin with, an autotest should be as close as possible to a real > > world scenario. When the only window around is being shown, it is > > automatically activated. The additional window->requestActivate() > > redundant and not a real world scenario. This alone justifies its > > removal. > > I'd like to get agreement that this is the right thing to do on all > platforms before proceeding (and then removing it en masse). > > Cheers. > > Confidential There is software doing requestActivate() immediately after show() in the wild, here's an example: setWindowState(windowState() & ~Qt::WindowMinimized); setVisible(true); raise(); activateWindow(); This is a part of a method supposed to raise the window independent of its state: hidden, minimized or just isn't focused. setVisible(true) is the same as show() and activateWindow() is the QWidget's wrapper over QWindow's requestActivate(). FWIW, I saw application reports that raising the window by clicking on the tray icon doesn't work every time on X11, I never forwarded it to Qt due to the minimal reproducible example requirement and the flaky nature of the bug. Hope the bug those tests expose gets fixed rather than silenced by removing those requestActivate(). P.S.: I've tried reimplementing requestActivate() with native XCB code, inspired by QXcbWindow::requestActivateWindow() with only one difference: using the code equivalent to calling connection()->getTimestamp() rather than connection()->time() and it was solving my focus flakiness problem. -- Development mailing list Development@qt-project.org https://lists.qt-project.org/listinfo/development