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

Replace Xlib by XCB written in Rust #386

Closed
tomaka opened this issue Apr 22, 2015 · 7 comments
Closed

Replace Xlib by XCB written in Rust #386

tomaka opened this issue Apr 22, 2015 · 7 comments

Comments

@tomaka
Copy link
Contributor

tomaka commented Apr 22, 2015

Motivation

  • Linking to xlib at compile-time forces people to have xlib installed. This is not problematic for the moment, but it will be once wayland is supported.
  • Xlib has a lot of race conditions. PRs like Fix race condition with XOpenIM #221 are hacky. XCB can be implemented in safe Rust, which would mean less crashes.

Process

  • Rewrite XCB in Rust, by generating code from the XML files.
  • Use xcb-rs for window creation and events handling.
  • Use xlib/glx for OpenGL context creation by dlopening the appropriate libraries. See http://xcb.freedesktop.org/opengl/. Unfortunately video drivers are tightly coupled to Xlib, so it's not possible to entirely remove it.

Alternatives

Wait for Wayland to be the most used windowing system, which should be the case around 2084.

@glennw
Copy link

glennw commented Apr 22, 2015

This is a fantastic idea - just today I have run into two xlib related threading issues in servo.

@tomaka
Copy link
Contributor Author

tomaka commented Apr 25, 2015

Unfortunately after some investigations I don't think it's possible, except if we replicate the internals of libxcb.

@emberian
Copy link

@tomaka is there are particular problem with replicating its internals? I just took a look around and it doesn't seem too bad. (I think I might volunteer to implement this...)

@tomaka
Copy link
Contributor Author

tomaka commented May 17, 2015

I'm not sure if that's a good idea, though.

You have to use xlib to open an X connection (that will be passed to GLX), then get a pointer to the XCB object from the Display.

You would therefore lose most of the advantages of using Rust. It wouldn't bring anything over using XCB directly.

@tomaka tomaka closed this as completed May 17, 2015
@rtbo
Copy link

rtbo commented Mar 12, 2016

@tomaka FYI I reactivated rust-xcb development this year. handling Displayand xcb::Connection is feasible in a relative clean way. I made an example to show how to setup an open gl context (xlib_xcb feature adds a Display pointer in the Connection object). you still need to link to xlib though

@Rain-Alderson
Copy link

I'd love to see glutin get support for xcb as well. The vulkan implementation on my computer only has support for VK_KHR_xcb_surface and not VK_KHR_xlib_surface.

@kvark
Copy link
Contributor

kvark commented May 11, 2016

@Ben-Alderson see rust-windowing/winit#5

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

No branches or pull requests

6 participants