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

[Request]: Make xkbcommon optional #782

Open
Quackdoc opened this issue Jan 8, 2025 · 2 comments
Open

[Request]: Make xkbcommon optional #782

Quackdoc opened this issue Jan 8, 2025 · 2 comments

Comments

@Quackdoc
Copy link

Quackdoc commented Jan 8, 2025

When cross compiling cosmic applications it can be very useful to be able to disable dependencies that require native libraries. In the case of libcosmic, the only offender here is xkbcommon.

As a proof of concept I patched various deps to disable xkbcommon crate, cross compiled to gnu arm cargo build --release --target aarch64-unknown-linux-gnu, loaded it on my phone and ran it. The application in question that I used was cosmic-edit, the patches below, wayland worked fine, x11 has broken keyboard input (though this is possibly a winit related issue as some other other winit applications share similar issues, for context prior discussion is here YaLTeR/niri#713)

(note I had to patch [dev-dependnecies] too for these which is why they are here)

[patch.'https://github.com/Smithay/smithay-clipboard']
smithay-clipboard = { path = "./smithay-clipboard" }

[patch.'https://github.com/pop-os/smithay-clipboard']
smithay-clipboard = { path = "./pop-clipboard" }

[patch.'https://github.com/pop-os/cosmic-protocols']
cosmic-client-toolkit = { path = "./cosmic-protocols/client-toolkit" }

It would be nice to be able to conveniently cross compile libcosmic applications.

@ids1024
Copy link
Member

ids1024 commented Jan 8, 2025

xkbcommon is used to map keycodes and modifiers to keysyms.

This isn't really optional for any application that takes keyboard input. The alternative would be to re-implement it in Rust, which would be nice but is non-trivial while correctly handling all keyboard layouts and xkb options.

Libwayland is also needed, but not at compile time since it's loaded with dlopen. I guess winit is also using dlopen for xkbcommon with https://github.com/rust-windowing/xkbcommon-dl, though the dependency tree also has the xkbcommon crate. So If it worked for you, then xkbcommon was present at runtime on the arm device, but not at build time?

@Quackdoc
Copy link
Author

Quackdoc commented Jan 8, 2025

Interesting, I haven't noticed any breakages, in usage.

The alternative would be to re-implement it in Rust, which would be nice but is non-trivial while correctly handling all keyboard layouts and xkb options.

there is https://github.com/rano-oss/wkb but I'm not sure the scope of this. It does rely on xkbcommon, but I'm not sure if that is just a WIP thing while they work on it or not. I do know that it doesn't seem like it is usable yet, but it may be worth keeping an eye on?

I guess winit is also using dlopen for xkbcommon with https://github.com/rust-windowing/xkbcommon-dl, though the dependency tree also has the xkbcommon crate. So If it worked for you, then xkbcommon was present at runtime on the arm device, but not at build time?

This is correct, xkbcommon-dl does also work and would work for me as I do have it on device.

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

No branches or pull requests

3 participants
@ids1024 @Quackdoc and others