Maybe check that topmostWindow->windowId() == unfocusedOnUpdatesDisabledWindowId, too, to prevent the previous app from stealing focus if the topmost window was changed between DisplayOff/DisplayOn.