Skip to content

X11 New Technology #6

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

Open
wants to merge 141 commits into
base: new-keyboard-linux
Choose a base branch
from
Open

Conversation

mahkoh
Copy link

@mahkoh mahkoh commented Nov 19, 2021

  • Tested on all platforms changed
  • Compilation warnings were addressed
  • cargo fmt has been run on this branch
  • cargo doc builds successfully
  • Added an entry to CHANGELOG.md if knowledge of this change could be valuable to users
  • Updated documentation to reflect any user-facing changes, including notes of platform-specific behavior
  • Created or updated an example program if it would help users understand this functionality
  • Updated feature matrix, if new features were added or implemented
  • None of the above.

This is a work in progress. I'll comment in the upstream issue.

@daxpedda
Copy link

I just discovered this and would like to point that it would be amazing if a switch to x11rb is successful.
It would make it easier for rust-windowing#1818 to be resolved. Though I suppose there are other solutions for this too.

@mahkoh
Copy link
Author

mahkoh commented Jan 20, 2022

It would make no difference since we would still link to libxcb dynamically.

@daxpedda
Copy link

daxpedda commented Jan 20, 2022

I thought that dynamically linking to libxcb is not necessary for x11rb to work, but a feature. Does winit need this feature? Or am I having some other misconceptions here? Sorry for my naivety on this topic.

@mahkoh
Copy link
Author

mahkoh commented Jan 20, 2022

I suppose you are right. Though for now we had no plans to expose this feature. Furthermore we would still dlopen other libraries such as xkbcommon. Most significantly, you would not be able to simply use accelerated rendering via opengl/vulkan in this case. It would still be possible to do accelerated rendering by using the low level kernel apis directly for presentation, but this would require quite a bit of linux-specific code (and might not work with the properietary nvidia drivers.)

@daxpedda
Copy link

Furthermore we would still dlopen other libraries such as xkbcommon. Most significantly, you would not be able to simply use accelerated rendering via opengl/vulkan in this case.

I don't know enough about this, but I was hoping that x11rb would at least be a step in the right direction of support musl.

I guess xkbcommon can't be replaced (unless somebody RIIR) and I don't know anything about the handle that is needed by something like wgpu to use it for OpenGL/Vulkan to even guess at solution to that. So at the end it will have to be statically linked for musl I'm assuming.

It would be great if somebody knowledgeable about this drops a comment on what's necessary to get winit going on musl in rust-windowing#1818 so even somebody like me can contribute towards it.

@i509VCB
Copy link

i509VCB commented Jan 20, 2022

I thought that dynamically linking to libxcb is not necessary for x11rb to work, but a feature. Does winit need this feature? Or am I having some other misconceptions here? Sorry for my naivety on this topic.

Given there may be environments where X11 doesn't even exist (Wayland only with no XWayland), I would assume dlopen is the ideal solution here

@mahkoh
Copy link
Author

mahkoh commented Jan 20, 2022

Keep in mind that drivers are usually opened via dlopen. If you wanted to avoid this, you would have to statically link drivers for all graphics cards that you want to support.

@daxpedda
Copy link

Given there may be environments where X11 doesn't even exist (Wayland only with no XWayland), I would assume dlopen is the ideal solution here

I was asking myself already how this is supposed to be handled with a musl library. I don't know, I guess there would have to be a separate mechanism to detect if X11 or Wayland is the preferred DE.

Keep in mind that drivers are usually opened via dlopen. If you wanted to avoid this, you would have to statically link drivers for all graphics cards that you want to support.

I'm not entirely sure what that means. For example Vulkan can be statically linked, see ash-rs/ash#457 for example. I am unaware of having to link drivers for each graphics card.

@mahkoh
Copy link
Author

mahkoh commented Jan 20, 2022

libvulkan.so is merely a proxy that loads the actual driver at runtime with dlopen: https://github.com/KhronosGroup/Vulkan-Loader/blob/77f3ea476ec0636c34dfd141e96be64173d96977/loader/vk_loader_platform.h#L252

@daxpedda
Copy link

That's good to know. So I guess it is impossible to make a graphical app on the musl target?

@mahkoh
Copy link
Author

mahkoh commented Jan 20, 2022

I suppose it would be possible on alpine where musl is linked dynamically.

@daxpedda
Copy link

Apparently I had a wrong impression of things then. Thank you so much for enlightening me!

@mahkoh
Copy link
Author

mahkoh commented May 3, 2022

Over the past few months I've been working on a wayland compositor [1]. Similarly to what people have expressed in this issue, I wanted the same binary to work on pure wayland systems and on systems with X available. Therefore linking to libxcb was not acceptable for me. In the end I decided to roll my own pure rust X client instead of using x11rb since x11rb had no support for async programming. But since winit does not make use of async that shouldn't matter for winit.

Long story short I've come around to seeing the value in pure-rust winit applications. I'm no longer opposed to porting my branch to x11rb. @psychon has already shown above that it should not be too hard to go through the code and simply replace the xcb calls with the equivalent x11rb calls.

That being said, since I'm no longer using X myself, I probably won't do it myself. If you have any questions while doing the port feel free to ask me about it.

[1] https://github.com/mahkoh/jay

@maroider maroider force-pushed the new-keyboard-linux branch 10 times, most recently from 7d59987 to ba8023a Compare June 15, 2022 04:01
@maroider maroider force-pushed the new-keyboard-linux branch 3 times, most recently from 0676c39 to 6c7820e Compare July 7, 2022 07:46
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.

7 participants