SDL_RaiseWindow does not steal focus

Hey everyone,

I’m having problems stealing focus for my game in Linux. Basically,
I’m creating the game window as hidden, do some background
initialization and then show it once it’s done:

SDL_Window *Window = Viewport->GetSDL2Window();
if (Window)
{
const Uint32 WindowFlags = SDL_GetWindowFlags(Window);
if (WindowFlags & SDL_WINDOW_HIDDEN)
SDL_ShowWindow(Window);

static const Uint32 DesiredFlags = SDL_WINDOW_INPUT_GRABBED
| SDL_WINDOW_INPUT_FOCUS
| SDL_WINDOW_MOUSE_FOCUS;
if ((WindowFlags & DesiredFlags) != DesiredFlags)
{
SDL_RaiseWindow(Window);
SDL_SetWindowGrab(Window, SDL_TRUE);
SDL_SetRelativeMouseMode(SDL_TRUE);
}
}

The thing is - nothing happens. Mouse remains where it was, keyboard
focus remains where it was. Running an iteration of the event pump
reveals that SDL_WINDOWEVENT_FOCUS_GAINED is not generated.

Not immediately, that it is. It is generated several dozen frames
later on and grabbing input in reaction to that event works just fine.

Any idea why this delay occurs and how I can force stealing the focus
immediately?

Regards,

Leszek