fix(xorg): dispatch key events via XInput XTEST device for GDK3 compatibility#642
Open
rubenvereecken wants to merge 1 commit into
Open
Conversation
GDK3 (used by Firefox/Camoufox) selects XI2 for the seat keyboard at startup and ignores core-protocol KeyPress events. XTestFakeKeyEvent produces core events, so typed characters from the Neko viewer silently never reach Firefox. Fix: discover the "Virtual core XTEST keyboard" XInput1 device at startup, cache it, and dispatch key events via XTestFakeDeviceKeyEvent which goes through the XI path. Falls back to the old core XTest path if the device isn't found. Requires -lXi (libxi-dev at build, libxi6 at runtime).
Owner
|
How could we test this? Only a simple smoke test would be enough. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The problem
Neko's keyboard input doesn't reach Firefox (or any GTK3/GDK3 application). You can see the key events in
xev, but the browser ignores them. Mouse works fine.Why it happens
GDK3 selects XI2 (X Input Extension 2) for its seat keyboard at startup. Once XI2 is active, GDK3 only processes
XI_KeyPress/XI_KeyReleaseevents — it stops listening for core-protocolKeyPressevents entirely.XTestFakeKeyEventproduces core-protocol key events. These are real X11 events (they show up inxev, they're sent by the X server), but GDK3's XI2 event loop never sees them.The fix
At display open, discover the "Virtual core XTEST keyboard" XInput1 device via
XListInputDevices()and cache it. InXKey(), dispatch viaXTestFakeDeviceKeyEvent(which goes through the XI path) instead ofXTestFakeKeyEvent(core path).Falls back to the original
XTestFakeKeyEventif the XTEST device can't be found — preserves existing behaviour on unusual X server configurations.Requires linking against
libXi(-lXiadded to CGO_LDFLAGS). Build dep:libxi-dev, runtime dep:libxi6.