autotests: Fix a race condition in X11WindowTest

NETWinInfo queries the window state and setState() will do nothing if the
proposed new state matches the cached server side state.

On the other hand, given how the test is structured, there can be pending
fullscreen changes on the kwin side that are yet to be sent to the X server
when the NETWinInfo object is created.

This change fixes that race condition by adding an explicit Xcb::sync().
This commit is contained in:
Vlad Zahorodnii 2024-07-10 14:14:32 +03:00
parent 75075fdb89
commit 53b61ce5d7

View file

@ -2168,15 +2168,20 @@ void X11WindowTest::testFullscreenLayerWithActiveWaylandWindow()
QVERIFY(window->isFullScreen());
workspace()->slotWindowFullScreen();
QVERIFY(!window->isFullScreen());
// and fullscreen through X API
NETWinInfo info(c.get(), windowId, kwinApp()->x11RootWindow(), NET::Properties(), NET::Properties2());
info.setState(NET::FullScreen, NET::FullScreen);
NETRootInfo rootInfo(c.get(), NET::Properties());
rootInfo.setActiveWindow(windowId, NET::FromApplication, XCB_CURRENT_TIME, XCB_WINDOW_NONE);
xcb_flush(c.get());
QTRY_VERIFY(window->isFullScreen());
QCOMPARE(workspace()->stackingOrder().last(), window);
QCOMPARE(workspace()->stackingOrder().last(), window);
{
Xcb::sync(); // sync so NETWinInfo fetches the correct current state
NETWinInfo info(c.get(), windowId, kwinApp()->x11RootWindow(), NET::Properties(), NET::Properties2());
info.setState(NET::FullScreen, NET::FullScreen);
NETRootInfo rootInfo(c.get(), NET::Properties());
rootInfo.setActiveWindow(windowId, NET::FromApplication, XCB_CURRENT_TIME, XCB_WINDOW_NONE);
xcb_flush(c.get());
QTRY_VERIFY(window->isFullScreen());
QCOMPARE(workspace()->stackingOrder().last(), window);
QCOMPARE(workspace()->stackingOrder().last(), window);
}
// activate wayland window again
workspace()->activateWindow(waylandWindow);