Smithay / smithay

A smithy for rusty wayland compositors
MIT License
1.83k stars 156 forks source link

Examples folder #99

Open IMFUZZ opened 6 years ago

IMFUZZ commented 6 years ago

Likes wlc.rs and wlroots-rs, it would be nice to have some basic examples of the working functionalities. I know this isn't an issue but I wasn't sure where to post this.

IMFUZZ commented 6 years ago

I also saw that there was a link to some examples in the "Version 0.1 of Smithay" article released on the official website some time ago, but the link is dead since it doesn't exist anymore. (https://github.com/Smithay/smithay/tree/master/examples).

elinorbgr commented 6 years ago

We recently moved and fused these examples into an example compositor written using smithay: anvil, which is in the directory with the same name in this repo.

The main reason why we chose to not keep around a few examples additionally to it is that, is that given the current smithay scope is much lower-level compared to wlc or wlroots, a "basic minimal example" needs to be already almost a thousand lines of code.

At this point, the difference between this and an actual reference compositor is pretty small, hence our choice to rather focus on anvil. Granted it could have more comments and documentation, and that's absolutely something that is planned at some point, though our bandwidth is pretty limited and this is lower priority than making things actually work.

Thus, if you are interested, don't hesitate to look at anvil and report whatever is unclear and would need more comments. If you even feel like helping us clarify all this, I'd be happy to answer any questions and/or merge PRs improving anvil's docs. :wink:

ddevault commented 6 years ago

I'm not sure you understand how wlroots actually works if you think that Smithay is lower level than it. As far as I can tell Smithay's design is quite similar to wlroots. Honestly until now I thought your approach was reading the wlroots code and making something similar in Rust. Our examples are things like standalone demos of the backends, libinput, output transforms, etc, something I think Smithay would benefit from having as well. Unless you can't actually use any of those features of Smithay alone?

elinorbgr commented 6 years ago

I'll admit I have not studied much the public API of wlroots, and mostly studied your work to get some understanding of how all the things work, given the general wayland documentation is what it is... So you're right, my claim that smithay is lower level than wlroots, at least in goal, was baseless. Apologies for that.

Now, after some look on the wlroots examples, it still appear to me that wlroots currently has more higher-level abstractions than smithay, especially regarding the backend side. Though I guess we are aiming to get something similar at some point, if we manage it...

What I mean is that we don't have anything close to wlr_backend_autocreate nor any renderer abstraction yet. Thus to actually draw something on the screen, you currently need to add quite a lot of boilerplate on top of what smithay provides.

Thus, I'm not certain of the usefulness of independent examples if each one needs to incorporate half of anvil's code just to be able to run. At this pout they are not "small examples" any more.

Unless you meant something else, and I missed you point?

ddevault commented 6 years ago

What I mean is that we don't have anything close to wlr_backend_autocreate

For what it's worth, wlr_backend_autocreate basically just picks the Wayland backend if WAYLAND_DISPLAY is set, or the X11 backend if DISPLAY is set, or the DRM+libinput backends if not. Such a function in Smithay would be trivial to add.

As for the renderer abstraction, fair enough. Without something like that, making smaller examples might be too annoying to be worth it.

elinorbgr commented 6 years ago

Well, our current status with the "DRM+libinput" backend is that it's still pretty bare-bones, and notably it still requires a fair amount of boilerplate to handle udev correctly. With time we'll get somewhere regarding that, I guess.

So... as a first step, I could try to throw a few winit-based examples, that could only be run as an x11 or wayland client. I still only have that much temporal bandwidth, though.

But yeah, our general design principle is to first integrate as minimal as possible abstractions, and then build new abstractions on top of that. And I feel that we're still too low on backend abstractions to meaningfully be able to present "small examples". But with more time and work, we aim to be able to integrate some of anvil code as proper generic abstractions into smithay, hopefully this would open the door to more meaningful minimal examples.

wiiznokes commented 4 months ago

I'm reading the compositor.rs example and it only make 78 lines. I guess there were a lot of improvement since 2018 :)

wiiznokes commented 4 months ago

Yet, there is not a single comment, and just running the example do nothing for me. Can the example be run inside a wayland comp ? (i'm running cosmic-comp)

Drakulix commented 4 months ago

Yet, there is not a single comment, and just running the example do nothing for me. Can the example be run inside a wayland comp ? (i'm running cosmic-comp)

The compositor.rs just implements the wayland compositor interface, it doesn't open any window.

The smallest fully functional compositor you can find here, is the smallvil subproject.