10 ms·
Without wlroots it would need several times more loc.
by aleksis 8y ago
Without wlroots it would need several times more loc.
- Sir_Cmpwn 8y agoWithout Xlib and the X11 server, so would TinyWM.
- Shish2k 8y agoNot to mention if you didn't use libc - and think of how many loc it'd need if you wanted to implement the kernel and userspace tools too! Thankfully, we live in a world where libraries exist and we can use them to handle the low-level details, and then we only need to care about the 500 lines of meaningful application-specific logic :D
- rain1 8y agototally missing the point edit: can't reply to you because of all the downvotes
- Shish2k 8y agoSo explain the point? In several threads recently I've seen people say "The application's line count is higher if you also count the libraries as part of the application!" - I mean yeah, sure, that's a factually correct statement, but... so what?
- evmar 8y agoThe point is that this app is 500 lines of C but it'd be two lines of Python: from wayland import solution_to_the_problem solution_to_the_problem() In this case, wlroots is literally a library for writing a compositor. ("A small demonstration of the wlroots API" would have been a fine title for this post. Pretending it's a small amount of code is silly.) "I made a tiny webserver using only the Linux kernel" is impressive. "I made a tiny webserver using only the Golang webserver API" is not as impressive. "I made a tiny social networking website using the Golang webserver API" is heading back towards impressive.
- Sir_Cmpwn 8y agoYou don't have to be impressed, but I don't necessarily think it's disingenuous. A "small" Wayland compositor which doesn't use a library like wlroots is nigh impossible. The code for handling DRM+KMS alone is over 2000 lines of code, and that's tangental to the goal of "make a Wayland compositor". I'd compare it to saying a game written with GLFW isn't impressive because they didn't do all of the work to set up an application window.
- evmar 8y agoI agree. It's a spectrum and my Python example is showing one extreme of obviously unimpressive. I was just trying to answer the comment I was responding to.
- juliangoldsmith 8y agoFor a toy compositor, is there any reason not to just use SDL? The DRM and KMS side of things is interesting, but doesn't help much in understanding the Wayland protocol.
- Sir_Cmpwn 8y agoYou certainly could make a compositor with SDL, but I don't think it would be any better than wlroots. We also provide an abstraction of the underlying window system, the same code which runs your compositor in an X11 window can also run it on KMS+DRM without any changes (the compositor in this very link can run on X11, Wayland, and DRM+KMS with no changes). It also gives you a number of useful things like an implementation[0] of xdg-shell, which alone can be a couple thousand lines long. Also, negotiating graphics resources with clients is going to require you to get into the gritty OpenGL details if you intend to be efficient (and some clients don't even support shared memory, so it's also a matter of compatability). You'd also need to implement the seat to have input support, which can be another ~1,000 lines of code. GTK+ requires the data device to be implemented as well - over 1,000 more lines of code in wlroots[2]. [0] https://github.com/swaywm/wlroots/tree/master/types/xdg_shell https://github.com/swaywm/wlroots/tree/master/types/xdg_shel... [1] https://github.com/swaywm/wlroots/tree/master/types/seat https://github.com/swaywm/wlroots/tree/master/types/seat [2] https://github.com/swaywm/wlroots/tree/master/types/data_device https://github.com/swaywm/wlroots/tree/master/types/data_dev... That being said, a simple compositor which only supports a subset of this stuff, uses SDL for rendering, doesn't support a lot of important features (like GTK+ dropdowns and context menus), and directly implements the Wayland protocols, could probably be done in one or two thoundand lines of code. In order to be equivalent in functionality to the TinyWL compositor I posted today, it would probably need to approach 5-6,000 lines.