Minimizing the window might trigger a focus change to the dummy window, while restoring and setting foreground should change the foreground back to the focus window.
However, the X window manager will instead send WM_TAKE_FOCUS event to the dummy window and to the focus window concurrently, and the dummy window might reply to it *after* we've restored the foreground to the focus window. This will later cause the device window to fail to get foreground, and the tests to randomly fail.
(This works around a foreground window race condition that will be difficult to fix otherwise, as it can happen in a cross-process context as well)