Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

simple_layer example: Handle 0 width/height in configure correctly #482

Merged

Conversation

bbb651
Copy link
Contributor

@bbb651 bbb651 commented Dec 18, 2024

The wlr-layer-shell-unstable protocol says:

If the width or height arguments are zero, it means the client should decide its own window dimension.

While the wording doesn't make it clear, I think it's reasonable to assume it's talking about each dimension separately - the word "dimension" isn't plural, and there's legitimate use cases for this behavior (e.g. scrolling compositors like niri).

Relevent issue: https://gitlab.freedesktop.org/wayland/wayland-protocols/-/issues/155 (about xdg-shell not layer-shell, the wording comes from there)

This can also be written as:

self.width = Some(configure.new_size.0).filter(|width| *width != 0).unwrap_or(256);
self.height = Some(configure.new_size.1).filter(|height| *height != 0).unwrap_or(256);

or plain ifs, which might be a little bit more readable, but I feel like using and encouraging NonZeroU32 is more idiomatic and flexible. It's not clear what's the MSRV policy, but I avoided NonZero since it's pretty new (rust 1.79.0).

The `wlr-layer-shell-unstable` protocol says:
> If the width or height arguments are zero, it means the client should decide its own window dimension.

While the wording doesn't make it clear, I think it's reasonable to
assume it's talking about each dimension *separately* - the word
"dimension" isn't plural, and there's legitimate use cases for this
behavior (e.g. scrolling compositors like niri).

Relevent issue: https://gitlab.freedesktop.org/wayland/wayland-protocols/-/issues/155
(about xdg-shell not layer-shell, the wording comes from there)
@wash2 wash2 merged commit c19ae99 into Smithay:master Feb 14, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants