Hi,
I was trying to mess with tsoding’s sowon application, starting by recompiling it myself.
Repo cloned, Nix-shell with build inputs created, SDL version works! But the RGFW crashs (segfault). Not surprising ; the Makefile of tsoding basically extracted the X11 part of RGFW’s Makefile to make it work, and I’m on Wayland. But for wayland, the RGFW Makefile has a step:
I have two questions :
→ Why are we forced to use header files generated by a tool instead of providing a “wayland library” ?
→ How to replace the path to the correct wayland-protocols in the Makefile? what I did was basically add wayland-scanner and wayland-protocols to my shell.nix, open up the shell, search the nix store for wayland protocols and copy the raw path onto the Makefile, I just have no idea have to do it reliably (one store collect garbage and the path changes when we open up the shell right?)
note: the project compiled as I wished with the above hack, but doesnt behave as expected with the windows glitching and stuff, probably because RGFW on Wayland is still experimental
Wayland is a protocol, defined in a bespoke XML-based format. wayland-scanner is a tool that translates these protocol definitions into C header files.
The idea is that you could use similar utilities to generate bindings for other languages (though in practice the reliance on C-ish memory concepts makes this difficult - at least they tried).
There are various protocol extensions that need to be translated, too, which you’d need to pick out if you wanted to use those, e.g. for wlroots.
You could build a package with “precompiled” header files, but that’s not how wayland expects itself to be built, and no projects do this in practice, so such a package doesn’t exist.
You write a less naïve makefile and set the path to a subdirectory of the wayland-protocols package with an environment variable via your mkShell.
If you were trying to package a third party project with this stupid of a makefile, you’d use the patchPhase to sed out the FHS paths. But ideally you just don’t write makefiles like this to begin with.
Edit: The repo you linked doesn’t have a makefile like this, FWIW, so I have no idea if upstream has better mechanisms in place for this. Unfortunately, programming on C projects also inherently means learning the intricacies of the build scripts of the project in question; The C ecosystem doesn’t really believe in making your life easier.
Unless it’s kept alive by system dependencies that happen to currently depend on the same version, yep.
From what I understand x11 is both the protocol and the implementation of the protocol, while wayland is only the protocol implemented by wlroots based compositors, newer versions of plasma etc. libx11 is meant to implement the base, no extensions, x11 protocol for C devs only.
just to understand if I get the design right:
→ libx11 is only an implementation of the protocol, which can then communicate with the server at runtime
→ we could theoretically create libwayland an implementation of the wayland protocol in the same way
→ wayland creators decided not to do design it this way in order to create versatility in wayland apps, because for example, for x11 we must create the bindings for each language manually and maintaining this for each language is a pain
I’ll try to reproduce this !
Thanks a lot for your help and explanations, I see you’re very dedicated to help newbies here, honestly respect for that, it really means a lot. much love
That’s my understanding, though the choice on the wayland end also means that creating protocol extensions is easy and regularly done by compositors, which makes a generic libwayland a lil’ more cumbersome. Not that that couldn’t be done, of course.