We are currently migrating Bugzilla to GitHub issues.
Any changes made to the bug tracker now will be lost, so please do not post new bugs or make changes to them.
When we're done, all bug URLs will redirect to their equivalent location on the new bug tracker.

Bug 2748 - [Patch] Fix Key and Textinput event order on X11 (issue introduced post-2.0.3)
Summary: [Patch] Fix Key and Textinput event order on X11 (issue introduced post-2.0.3)
Status: RESOLVED FIXED
Alias: None
Product: SDL
Classification: Unclassified
Component: events (show other bugs)
Version: HG 2.0
Hardware: All Linux
: P2 normal
Assignee: Ryan C. Gordon
QA Contact: Sam Lantinga
URL:
Keywords: target-2.0.4, triage-2.0.4
Depends on:
Blocks:
 
Reported: 2014-10-08 02:16 UTC by Zack Middleton (zturtleman)
Modified: 2015-05-27 00:23 UTC (History)
4 users (show)

See Also:


Attachments
X11: Add textinput event after key event (888 bytes, patch)
2014-10-08 02:16 UTC, Zack Middleton (zturtleman)
Details | Diff
Pump IBus events after XEvents to make sure TEXTINPUT comes after KEYDOWN (1.01 KB, patch)
2014-10-13 17:06 UTC, Alex Baines
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Zack Middleton (zturtleman) 2014-10-08 02:16:12 UTC
Created attachment 1890 [details]
X11: Add textinput event after key event

The X11 IBUS support changes made SDL_TEXTINPUT event come before SDL_KEYDOWN event. This is inconsistent with SDL's X11 backend in 2.0.3 and other SDL backends I've tested or looked at the SDL code for (Windows, DirectFB, Cocoa, iOS, Mir, and Wayland).

I found this because the in-game console in ioquake3 (which I'm a developer of) can be toggled using ` (grave) key or character event. The textinput handler ignores text if last key was console toggle. With the current mercurial SDL2 X11 code the console gets toggled twice each press (cannot open) due to textinput event before key event.

The attached patch makes SDL X11 backend add SDL_KEYDOWN event before SDL_TEXTINPUT event. I don't think this affects IBUS. With and without this patch; if SDL_IBus_ProcessKeyEvent handles the key event, the function calls to add SDL key and textinput events in X11_DispatchEvent are not run.
Comment 1 Alex Baines 2014-10-13 17:06:53 UTC
Created attachment 1897 [details]
Pump IBus events after XEvents to make sure TEXTINPUT comes after KEYDOWN

Looks like I broke this, sorry about that!

Your patch looks good, I've made an additional one that pumps the IBus events after the X events. This should make sure you always get the KEYDOWN ones first even if IBus handled the key press.
Comment 2 Ryan C. Gordon 2015-02-19 05:22:19 UTC
Marking a large number of bugs with the "triage-2.0.4" keyword at once. Sorry if you got a lot of email from this. This is to help me sort through some bugs in regards to a 2.0.4 release. We may or may not fix this bug for 2.0.4, though!
Comment 3 Ryan C. Gordon 2015-04-07 04:57:58 UTC
(sorry if you get a lot of copies of this email, I'm marking several bugs at once)

Marking bugs for the (mostly) final 2.0.4 TODO list. This means we're hoping to resolve this bug before 2.0.4 ships if possible. In a perfect world, the open bug count with the target-2.0.4 keyword is zero when we ship.

(Note that closing a bug report as WONTFIX, INVALID or WORKSFORME might still happen.)

--ryan.
Comment 4 Ryan C. Gordon 2015-05-27 00:23:50 UTC
Whoops, I fixed this independently, too, with the exact same change that Zack made.

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

I've put Alex's patch in revision control, too...

    https://hg.libsdl.org/SDL/rev/044cafe15108

...which should resolve this bug.

Thanks!

--ryan.