Skip to content

Conversation

@wismill
Copy link
Member

@wismill wismill commented Nov 20, 2025

Enable to apps to query the version of the libxkbcommon library actually in use and adapt their behavior: e.g. supported flags and available symbols, etc.

Fixes #932


TODO:

  • Better commit message
  • Documentation with examples (do and don’t)
  • Changelog
  • Add a flag arg to enable future developments?

Enable to apps to query the version of the libxkbcommon library
actually in use and adapt their behavior.
@wismill wismill added this to the 1.14.0 milestone Nov 20, 2025
@wismill wismill requested review from bluetech and whot November 20, 2025 11:56
@wismill
Copy link
Member Author

wismill commented Nov 20, 2025

@bluetech @whot See #932 for the rationale. My main reluctance for this function is that it can be abused or the app workaround get out of sync, while testing failures could be a more robust solution (e.g. unsupported flags1, etc.).

Footnotes

  1. Note that xkb_context_new() currently does not fail on invalid flags. Probably worth fixing.

@Caellian
Copy link

Caellian commented Nov 20, 2025

I will go with symbol testing in the end for what I need. I see xkb_get_version as something useful only if functions like xkb_keymap_is_supported_format, xkb_context_is_flag_supported, etc. are missing for functionality that can't be probed through symbols or require e.g. constructing context+keymap+state to check whether something is supported.

Wayland allows requesting specific protocol versions, so I guess this would simplify some cases the same way it helps with protocol versioning in WL. But I agree now that it's bad to rely solely on version to handle all version differences in the library because that requires the app/bindings/wrapper to stay on top of all the changes to this library.

There's potential for misuse, but it could also pad omissions and mistakes. I suggest you mention in the docs "prefer other means (e.g. checking symbols) instead of relying solely on this value if possible".

@whot
Copy link
Contributor

whot commented Dec 9, 2025

historically libraries exporting a version made it hard(er) for backports like enterprise linuxes to work correctly - you can't backport a single feature without bumping the version number but then you have to backport every new API to be correct. Relying on build-time checks to check if a function exists and/or code compiles (for enums) is a better option than relying on some numbers.

Of course this only works at configure time, not dynamically. And libxkbcommon features aren't backported anywhere afaik but nonetheless, having the version number feels wrong.

@mahkoh
Copy link
Contributor

mahkoh commented Dec 9, 2025

@whot
Copy link
Contributor

whot commented Dec 10, 2025

Given that these are all my fault :)

It's a mix and largely depends on how much effort I want to spend on versions that don't have those features. In the above examples: mtdev 1.1 is 15 years old and had some significant API changes back then. libwacom 0.27 is 8 years old and the only new required features are behind a function check. lua multiple versions is just a no-go, too much effort.

One counter-example for taking the checks to quite some extreme: https://gitlab.freedesktop.org/xorg/driver/xf86-input-libinput/-/blob/master/meson.build?ref_type=heads#L48.

Version checks are still useful for a minimum supported version - it's anything after that minimum that should be dynamic is where they tend to break down (esp. where only a single feature is required).

@mahkoh
Copy link
Contributor

mahkoh commented Dec 10, 2025

Given that these are all my fault :)

It's a mix and largely depends on how much effort I want to spend on versions that don't have those features. In the above examples: mtdev 1.1 is 15 years old and had some significant API changes back then. libwacom 0.27 is 8 years old and the only new required features are behind a function check. lua multiple versions is just a no-go, too much effort.

It's nobodies fault, you're doing the thing that everyone should be doing in my opinion (and what everyone is doing in other languages where static linking is king). But it is hypocritical to do this and then say "having the version number feels wrong" when people who use dlopen want the same courtesy. People who link at compile time have strictly more tools available to do feature detection (within reason), and yet, you're saying that only they should get to use version numbers.

But maybe you're right. There is an easy way to prove it that also benefits everyone using dlopen: From now on, keep the pkg-config version of libinput fixed at 1.30.1. Distributions can still increment the package version number if they need to do so for technical reasons, but the pkg-config version stays fixed. Everyone who wants to use newer libinput features will have to check for their availability at runtime or at compile time with the same mechanism.

@Caellian
Copy link

Caellian commented Dec 12, 2025

I suggest this is closed in favor of #942.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add version query method (xkb_get_version)

4 participants