Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

x11: Support xcb-keysyms as fallback when XKB support not available #679

Merged
merged 3 commits into from
Nov 30, 2023

Conversation

aperezdc
Copy link
Member

These patch set pulls the parts of the code from #303 which implement usage of xcb-keysyms to handle keyboard input event translation, adding a few niceties on top:

  • Allow passing -Dx11_keyboard= to Meson to choose which methods are supported. It is possible to use xkb, xcb-keysyms, or both. Passing an empty list disables keyboard input to web views.
  • If support for both XKB and xcb-keysyms, then XKB will be preferred, and if not available then xcb-keysyms is used as fallback.
  • Lastly, add a Wrap subproject definition that teaches Meson how to download a tarball and build a static xcb-keysyms library when not available. The library is a single .c file so it does not add much weight to the X11 platform plug-in, and we make it less likely that people may end up without keyboard input support.

Finally, I want to thank @agordon who was the person that originally wrote the code 🙏🏼

@aperezdc aperezdc added the enhancement New feature or request label Nov 30, 2023
@aperezdc aperezdc self-assigned this Nov 30, 2023
Copy link
Member

@psaavedra psaavedra left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. r+

Notice, I0've not tested alternatives builds with/without the COG_X11_USE_XCB_KEYSYMS manually. I assume this works.

Massage the parts from #303 which deal with input using xcb-keysyms to
be included in the x11 platform plug-in. This provides a fallback that
can be used when XKB initialization fails, typically in cases where the
X server does not support XKB or has the support disabled. XKB is a X11
protocol extension after all, and it is wrong to assume that it will be
always available. While at it, allow running without keyboard support,
producing a warning in this case.
Allow disabling the XKB support in the x11 platform plug-in at build
time. For this, introduce a new "x11_keyboard" Meson build option that
can be set to use xkb, xcb-keysyms, both, or none. Preprocessor guards
are introduced where needed to skip the XKB code.
Add a Wrap subproject definition for the xcb-keysyms dependency. It is
a very simple library with a single C source file, so it is easy to make
Meson build definitions for it that get added on top of the tarball
release fetched by Meson if xcb-keysyms is not available. This way it is
guaranteed that there will be at least some support for keyboard input
if the XKB extension is not available in the X server, or not enabled at
build time.
@aperezdc
Copy link
Member Author

LGTM. r+

Notice, I've not tested alternatives builds with/without the COG_X11_USE_XCB_KEYSYMS manually. I assume this works.

I tested the build options here before submitting the PR 😄

@aperezdc aperezdc merged commit e00ce6e into master Nov 30, 2023
5 checks passed
@aperezdc aperezdc deleted the aperezdc/xcb-keysyms branch November 30, 2023 19:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants