SDL2 Input Focus

I am currently trying to build and run an UnrealEngine4 demo application that uses SDL2 on an armv7 embedded Linux system with an X server running but no window manager.

I can see that the application is not responding to keyboard events, although the mouse works fine.

Digging further, it turns out the problem is that UE4 ignores the keyboard event if SDL_Event.key.windowID does not match the SDL_Window application id. I tested this by calling SDL_GetKeyboardFocus () and it turns out that the window ID for keyboard focus is 0, while the application window ID is 5.

Digging a little further into SDL2, it looks like the keyboard focus is set to a specific SDL window after the focusIn event is received from the X server. (see X11_DispatchEvent () in SDL_x11events.c).

It looks like if you are using X11 without a window manager, however this focusIn event is never raised by the X server, as already stated here:

FocusIn / FocusOut not generated

After hacking X11_RaiseWindow () in SDL_x11windows.c adding:

X11_XSetInputFocus (display, data-> xwindow, RevertToParent, CurrentTime); SDL_SetKeyboardFocus (data-> windows);

was able to finally handle keyboard events.

Does this assessment sound correct? If this is so clean solution? I'm still digging, but any suggestion would be greatly appreciated.

thank

+3


source to share


1 answer


This turned out to be a bug in the SDL, which we just clicked on the fix for:

https://hg.libsdl.org/SDL/rev/aa4e4768c6c1



This fix will be in SDL 2.0.4 and should be rolled out to Unreal shortly thereafter.

0


source







All Articles