psychon / x11rb

X11 bindings for the rust programming language, similar to xcb being the X11 C bindings
Apache License 2.0
367 stars 40 forks source link

Move parser for XSETTINGS from winit to x11rb #922

Open notgull opened 7 months ago

notgull commented 7 months ago

In https://github.com/rust-windowing/winit/pull/3222 I added a parser for the data format found by querying the _XSETTINGS_SETTINGS atom. However this parser is not winit-specific. I think it could be useful outside of winit.

x11rb has parsers for other X11-specific formats already (e.g. xcursor, the resource manager), so I think it would make the most sense to move it here. What do the other maintainers think?

cc @kchibisov

psychon commented 7 months ago

Oh, wow, yet another format for something similar to the resource manager stuff... Google suggests that this has a spec: https://specifications.freedesktop.org/xsettings-spec/xsettings-latest.html

So far, my approach was mainly "is there a xcb library for something?", but that's not a rule. So, yeah, I can see some usefulness in having something like that.

Would the code in x11rb then also help in implementing a server? How could x11rb help in implementing this part of the spec (which winit also ignores):

and select for notification on the settings window by calling XSelectInput() with a mask of StructureNotifyMask|PropertyChangeMask.

This part is also currently ignored, but can easily be handled, I guess:

To prevent race conditions a client MUST grab the server while performing these operations using XGrabServer().

x11rb has parsers for other X11-specific formats already (e.g. xcursor, the resource manager),

Due to #883, I have another spontaneous idea: Should all these parsers be moved to separate crates so that they can actually build in parallel? But I guess that's a different topic and there would not be much benefit since they are actually quite small... But separate crates could have x11rb or x11rb-async features and then offer specific APIs to make their usage nicer...

Edit: Some lists of possible setting names: https://codeberg.org/derat/xsettingsd#settings https://www.freedesktop.org/wiki/Specifications/XSettingsRegistry/

notgull commented 7 months ago

I suppose it's probably better to have it in a separate crate, yes.

kchibisov commented 7 months ago

Having parsers in separate crates will be fine, I guess. Though, would be nice to have them discoverable.

Also, there's xcursor crate which also parses the cursors and is used by wayland infra.