-
Notifications
You must be signed in to change notification settings - Fork 567
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
Port X11 backend from xcb to x11rb. #1025
Conversation
/bloat |
🗜 Bloat check ⚖️Comparing 76b9234 against 0085e16
|
I think bloat only does macos, so it won't pick up changes in x11. I did the comparison myself, though, and got this (sizes in KB):
|
Thanks a lot for doing the comparison, I completely forgot about that bot being macOS only. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks like a pretty nice diff overall 👍
I had a look using |
it should be possible to adapt the |
In this case, we would also need it to take a feature flag...
…On Thu, Jun 11, 2020, 20:34 Colin Rofls ***@***.***> wrote:
it should be possible to adapt the bloat stuff to take a backend as an
argument or something 🤔
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#1025 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AALBRMKWMS3I4XZURAMTRW3RWGAZNANCNFSM4NZX5CHQ>
.
|
libxcb is basically a big Thus, x11rb really does a lot more than libxcb. If you want to call that "bloat" or not is up for debate. :-) (By the way, x11rb doing actual parsing is why it supports more extension than the XCB crate; some of the on-the-wire stuff does not really map to C TL;DR: Even when also considering the size of |
It's not that I think 100kb is excessive, but I do think it might be possible (if not a high priority) to improve. According to |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just skimmed parts of this for now. Mostly I was looking at x11rb
itself and I think the general idea of migrating to that library is a good one. 👍
@@ -74,59 +72,61 @@ struct State { | |||
|
|||
impl Application { | |||
pub fn new() -> Result<Application, Error> { | |||
let (conn, screen_num) = Connection::connect_with_xlib_display()?; | |||
let (conn, screen_num) = XCBConnection::connect(None)?; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I haven't really investigated this stuff with either library, but is this an equivalent port? The connect_with_xlib_display
docs say that going through XLib is needed for OpenGL support. I'm not sure if cairo uses OpenGL but if it does - does the new connection also provide that?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To my knowledge Cairo does not use OpenGL by default. There is an experimental feature for it but otherwise it uses the platform library (X11 on Linux). So it should be fine if there is no OpenGL available, unless we want to use it ourselves.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suspect that we will want OpenGL support eventually. If not for cairo, then for #891-related stuff. But it looks like it will need some work on the x11rb side.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess you will want to use the x11
crate for this. (The following "talks C
", I haven't looked at the Rust bindings of any of this.)
- create you
Display*
viax11
. - Get the underlying XCB Connection via
XGetXCBConnection
. This gives you anxcb_connection_t*
. - This pointer can be given to
x11rb::XCBConnection::from_raw_xcb_connection(dpy, false)
. - If you want to handle events through x11rb and libxcb, you should call
XSetEventQueueOwner(dpy, XCBOwnsEventQueue)
. Otherwise, libX11 might randomly eat your events / move them to its own event queue. - One you drop /
XCloseDisplay
theDisplay*
, any further use of theXCBConnection
might cause demons to fly through your nose, so be careful (by the way: Similar fun can result with cairo, but cairo makes it much easier to accidentally continue using the connection after it was closed / freed.).
Congratulations, you now have a single X11 connection which you can access through all of libX11, libxcb and x11rb.
API-wise, I do not see anything that could be added to x11rb. The two functions I mentioned above live in libX11.so
and libX11-xcb.so
and x11rb certainly has no business depending on them.
Edit: This is also what connect_with_xlib_display
does (minus the setting of the event queue owner...?) https://github.com/rtbo/rust-xcb/blob/69a9d0126d40e7e3a9b354c07fbf31a81443b105/src/base.rs#L637-L640
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the detailed information! I'd prefer not to block this PR on OpenGL support, so I've just dropped in a comment for now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The broken link aside, this looks great!
Happy to be using a well maintained and Rusty library from now on 😄
// libxcb, you should call XSetEventQueueOwner(dpy, XCBOwnsEventQueue). Otherwise, libX11 | ||
// might randomly eat your events / move them to its own event queue. | ||
// | ||
// https://github.com/xi-editor/druid/pull/1025/files/76b923417183bd103f61e56b56a56474b7417cec#r442777892 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This link is broken for me.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, fixed, and I'll merge when CI lets me. Definitely nice to be using a library that is both rusty and actively maintained to the point where the maintainer drops by and tells us what we should be doing better 😄
This ports the X11 backend from the
xcb
crate to thex11rb
crate, as discussed in #989. Overall, I have a positive impression ofx11rb
, as compared toxcb
: it's actively maintained, it uses actual rust enums in many places, and it doesn't need unsafe for event handling. Also, it supports the present extension (a blocker for #989) and the xinput extension (which presumably we'll need at some point), unlikexcb
.