Skip to content

SDL2 fails to get focus when running in X11 directly #1867

@SDLBugzilla

Description

@SDLBugzilla

This bug report was migrated from our old Bugzilla tracker.

Reported in version: 2.0.3
Reported for operating system, platform: Linux, x86_64

Comments on the original bug report:

On 2015-05-22 22:16:31 +0000, Dank Maymays wrote:

Many applications using SDL rely on SDL_Event.key.windowID matching the ID of the application's SDL_Window. The keyboard focus is set to a particular SDL window after a focusIn event is received from the X server (see X11_DispatchEvent() in SDL_x11events.c). However, if you're running X11 without a window manager, this focusIn event is never generated by the X-server as noted at http://stackoverflow.com/questions/18234136/focusin-focusout-not-generated

First, this behavior is not correct, as many X11 applications run fine and get and lose focus correctly without any window manager. An example is xterm: moving the mouse in and out of its area when it's run without Gnome/KDE/twm/anything still puts it in/out of focus and lets it/stops it from receiving typing.

Second, running X11 without a window manager has important use cases for kiosks, embedded applications, and so on, so saying this bug is not important because it will not affect anyone is unacceptable.

One possible fix is to add to X11_RaiseWindow() in SDL_x11windows.c the following:

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

On 2015-05-31 06:06:30 +0000, Ryan C. Gordon wrote:

Whoops, I didn't see this bug report, and had opened another one when I fixed the issue. This should be good to go now.

--ryan.

*** This bug has been marked as a duplicate of bug 2997 ***

Metadata

Metadata

Assignees

No one assigned

    Labels

    duplicateThis issue or pull request already exists

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions