Skip to content

Support to wlr_layer_shell#4044

Open
SergioRibera wants to merge 13 commits intorust-windowing:masterfrom
SergioRibera:layer_shell
Open

Support to wlr_layer_shell#4044
SergioRibera wants to merge 13 commits intorust-windowing:masterfrom
SergioRibera:layer_shell

Conversation

@SergioRibera
Copy link
Copy Markdown

@SergioRibera SergioRibera commented Dec 18, 2024

  • Tested on all platforms changed
  • Added an entry to the changelog module if knowledge of this change could be valuable to users
  • Updated documentation to reflect any user-facing changes, including notes of platform-specific behavior
  • Created or updated an example program if it would help users understand this functionality

Yup, this is another PR trying to integrate layer_shell support to winit, personally I use this feature a lot and even considered making my own windowing system to support this feature, but that would be counterproductive to the ecosystem and I prefer to add this feature so the rest can enjoy it.

My main goal is to try to preserve as much as possible the interaction with the default API, to some extent I think it is a success but there are things that can not be avoided to change.

Clearly and as you will notice this PR is strongly inspired by #2832 I decided to make another one due to the low activity on the original author's github instead of contacting him and contributing to his fork.

Fixes #2582

Unresolved design questions:

  • I would imagine Anchor, KeyboardInteractivity, and Layer should be reexported in winit::platform::wayland Exposed Types
  • Additionally this also gives us the possibility to do other cool things in wayland like moving the window at will or getting the position of the window (here we probably have to debate whether storing the position is wise).

@SergioRibera SergioRibera changed the title Support to wlr_layer_shell (YET another PR, 2024 updated) Support to wlr_layer_shell Dec 18, 2024
Copy link
Copy Markdown
Member

@kchibisov kchibisov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The response is the same as for other PRs, not unless backend split is done, which I hope should be soon.

@SergioRibera
Copy link
Copy Markdown
Author

The response is the same as for other PRs, not unless backend split is done, which I hope should be soon.

Well, it seems completely make sense to me, is there any site where they are discussing this topic? I will leave the PR open for now and keep it updated with respect to the main winit branch.

@kchibisov
Copy link
Copy Markdown
Member

Everything you need is present on github issues here and opened PRs. You can subscribe to #3433 .

@SergioRibera
Copy link
Copy Markdown
Author

Perfect, thank you, I also joined the matrix server that you have in the README, I will be in contact to help you with whatever you need 🦀

@SergioRibera SergioRibera force-pushed the layer_shell branch 2 times, most recently from 094555a to 36a3906 Compare January 3, 2025 18:22
@madsmtm madsmtm added S - enhancement Wouldn't this be the coolest? DS - wayland Affects the Wayland backend, or generally free Unix platforms labels Jan 4, 2025
danbulant added a commit to danbulant/winit that referenced this pull request Jan 5, 2025
@SergioRibera SergioRibera force-pushed the layer_shell branch 3 times, most recently from 07e57c2 to 08d03de Compare February 3, 2025 02:08
@SergioRibera SergioRibera force-pushed the layer_shell branch 4 times, most recently from 34d55fb to e831bcc Compare March 20, 2025 19:53
@vikigenius
Copy link
Copy Markdown

vikigenius commented Jun 8, 2025

Are you still planning to update the PR? With the new splitting up into crates, is the expectation that all this will move to the winit-wayland crate?

@SergioRibera
Copy link
Copy Markdown
Author

@vikigenius yep, a little while ago I saw that they already updated the modules, but this week I didn't have time to update the PR but I plan to do it as soon as I'm free

@SergioRibera
Copy link
Copy Markdown
Author

Hey, just to notify, I am going to continue this in another PR, the restructuring made some disastrous changes in what I had, so I prefer to have a clean and new PR, I hope the manteiners agree

@kchibisov
Copy link
Copy Markdown
Member

kchibisov commented Jun 27, 2025

I'd add that after we've split things, you can implement layer-shell by ripping of xdg shell and its related stuff (e.g. winit-layer-shell). And also, it doesn't have to be here. While I still want it to be here, winit users now would likely accept winit-core rather than winit crate itself, so you won't need to deal with e.g. upstream review where we figure things and just use layer shell.

@SergioRibera SergioRibera reopened this Jun 27, 2025
@SergioRibera
Copy link
Copy Markdown
Author

Hey, I've been going through the restructure and recovering some past changes I've put together a base, it doesn't compile yet, but I'll be making adjustments and integrating an example to be able to do local testing, I'll just say that the PR has come back to life

@kchibisov
Copy link
Copy Markdown
Member

Though, just thinking that may be direct integrating into winit-wayland at this stage is also fine. You just don't have to expose it through winit-core. And you can also define a trait for new layer-shell events directly inside the winit-wayland.

@SergioRibera SergioRibera force-pushed the layer_shell branch 2 times, most recently from c5f8172 to a7d2f71 Compare December 20, 2025 06:42
friedow added a commit to friedow/centerpiece that referenced this pull request Feb 3, 2026
Over the past year centerpiece startup time has gotten slower and
slower. This is mostly due to iced receiving more features and not being
optimized for fast startup performance. The most pressing issue which
influences the startup time of centerpiece negatively is font loading.
This is tracked over #183,
has been an issue for a long time and does not seem to be fixed anytime
soon.

Since centerpiece is using a very minimal feature set of iced, I've been
thinking about switching to another, more lightweight, ui library for
quite some time. This PR contains the change from iced to egui.

My recent tests have shown the following startup times of centerpiece
- with iced ca. ~550ms
- with egui ca. ~190ms

This biggest issue right now is that eui has no support for the wayland
layer shell protocol. egui is waiting for layer shell support in winit
(rust-windowing/winit#2582,
rust-windowing/winit#4044).

We'll be merging this PR anyways, even if it does not provide native
floating support in wayland, it does provide a significant performance
improvement. Floating can be fixed by configuring floating for
centerpiece windows in your window manager. We'll keep this change on
main for quite a while and if we decide to release it without floating
support, it will become a breaking change.

This resolves #246.
This resolves #174.
Copy link
Copy Markdown

@WERDXZ WERDXZ left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you very much for doing this,

after reviewing the file. it seems like there are bit too much difference between layer shell and xdg window. It might be reasonable to split it into two separate crate (or a feature gated module). Specifically I think we need a separate "window" state and Window.

@SergioRibera
Copy link
Copy Markdown
Author

SergioRibera commented Mar 20, 2026

Thank you very much for doing this,

after reviewing the file. it seems like there are bit too much difference between layer shell and xdg window. It might be reasonable to split it into two separate crate (or a feature gated module). Specifically I think we need a separate "window" state and Window.

I understand that it can be tricky to maintain parity between the two, but the difference isn’t that significant, and I think the solution we have now is quite prudent, because it preserves a single API from the outside while handling the differences internally. If we split it into smaller crates, it will be much harder to maintain, and you’ll end up with two completely different APIs, making the code and external usage much more verbose. So far, there are only a few things that Wayland doesn’t support due to the protocol, but I don’t think they’re enough to warrant splitting it up.

My biggest concern with this release is that many of us need an official solution from Winit for LayerShell support in Wayland, so I hope we’ll see progress sooner rather than later.

Regardless of the decision, I’d like to be kept in the loop, and if you’d like me to implement whatever decision you make, I’d be happy to do so. For now, I’ll try to keep this PR up to date 🫡

@BANanaD3V
Copy link
Copy Markdown

BANanaD3V commented Mar 24, 2026

Hello! What's the state of this PR? I'm waiting for this to merge so layershell support could potentially be added directly to iced.

The current implementation adds layershell support into the window itself - is this a good idea? Layershells are not designed to be used as xdg surfaces, as per the protocol. Note, that you should not use it to move the window at will or get its position either, as suggested in the initial PR comment.

In my opinion ideally we should think of wayland as mainly wl_surface with a role - be it xdg toplevel or a layer_shell. Maybe rename the Window into WlSurface on a second look, Window works fine too I think, doesn't really matter. I will have to look at the architecture more thoroughly. This approach also allows implementing session_lock later on with minimal architectural changes.

I could also help fixing the layer_surface destruction bug.

@BANanaD3V
Copy link
Copy Markdown

Alright, I've looked into the bug and merged upstream into the branch (will push to my fork soon). As you know, layershells get destroyed when an output disconnects. The problem is with who is responsible for that. It seems like winit does not expose output events.

What this means is that we need to keep track of what layershells were on which output, which is not that hard to do. The problem with that is flexibility - let's say I'm developing a wayland bar. I'd much rather manage my outputs myself (and that's what people do). It doesn't really make sense to be any other way - if your outputs are managed by winit the application can't really know what's happening, so I think the perfect solution would be exposing the output events to the user. In case that is not possible, the shell state saving behavior should be opt-in.

So, what should the design choice be?

@madsmtm
Copy link
Copy Markdown
Member

madsmtm commented Mar 24, 2026

What's the state of this PR?

Wayland maintainer (Kirill) is a bit busy last I heard, but will hopefully maybe get more time soon.

@BANanaD3V
Copy link
Copy Markdown

Wayland maintainer (Kirill) is a bit busy last I heard, but will hopefully maybe get more time soon.

I see. Well, in the meantime I think we should figure out an optimal design for the layershell and output management as I've described in my previous comment.

@SergioRibera
Copy link
Copy Markdown
Author

Hey, I just updated the PR to reflect the latest changes on the master branch.

Well, in the meantime I think we should figure out an optimal design for the layershell and output management as I've described in my previous comment.

I’d really like to move forward with this PR so it can be merged. We can easily discuss your comments. I’d also like to make sure the API is solid so that, in the future, it’ll be easy to extend the capabilities of the layer_shell, as you mentioned with session_lock. So I'm really open to any suggestions, review, comments or disscussion (probably on the Matrix channel)

@BANanaD3V
Copy link
Copy Markdown

BANanaD3V commented Mar 25, 2026

Can you send the matrix room? Thanks. Joined.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

DS - wayland Affects the Wayland backend, or generally free Unix platforms S - enhancement Wouldn't this be the coolest?

Development

Successfully merging this pull request may close these issues.

Feature request: Support for Wayland's wlr-layer-shell protocol