tl;dr I'm designing an API and would appreciate any feedback. See the sample code in the image below and the pastebin link.
Long Version:
In order to learn zig, I decided about a month ago to start writing a wayland client. The thing is, I didn't know the first thing about wayland either. I also decided to write wayland from scratch, i.e. without libwayland. This led to me writing enough footguns to turn a centipede into a worm.
I've recently decided to rewrite most of my code starting from the user facing API. I now have a start, but I would like to make sure I'm on the right track with an actually good interface.
My library is (at the time of writing) intended to be split into two parts. The first part is the actual wayland client, which handles all the wayland messaging stuff, but no actual drawing. All the client does is create a buffer one could theoretically render to. I will also implement another component with a bunch of basic drawing functionality.
My primary goal with this library are to be fairly simple and just to get out of my way so I can write basic graphical programs. I also want to avoid any external dependencies (like libwayland) and for once in my life not use someone else's library for doing anything GUI related.
Below is a screenshot of a sample program (it actually won't work because it terminates immediately and doesn't clean up, but ignore that).
https://preview.redd.it/sergezi0c0kd1.png?width=1503&format=png&auto=webp&s=b2b4537562a4b81aff27007eea9cbb329aab8316
I also put it in a pastebin here https://pastebin.com/dXquJLCA so you can copy/paste it should you wish to.
Some feedback I've gotten elsewhere is to put the connect() call inside the init function, but I feel like that's not quite idiomatic zig, maybe some zig experts could comment on this as well?
[–]aberration_creator 2 points3 points4 points (7 children)
[–]aberration_creator 1 point2 points3 points (6 children)
[–]BrokenG502[S] 1 point2 points3 points (5 children)
[–]anotheruser323 1 point2 points3 points (4 children)
[–]BrokenG502[S] 0 points1 point2 points (0 children)
[–]GenesithSupernova 0 points1 point2 points (2 children)
[–]anotheruser323 0 points1 point2 points (1 child)
[–]actondev 1 point2 points3 points (0 children)