Fix min size hint with Wayland CSD frame#4561
Open
LeonMatthes wants to merge 1 commit into
Open
Conversation
If a window is created with a minimum size hint and then needs client-side decorations on Wayland, the frame will actually reduce the real available size of the client application. This fix takes this into account and causes the window to correctly increase its size based on the height that the frame needs. Closes rust-windowing#4559
1 task
Author
|
Hm, CI is failing on an unrelated clippy warning (the X11 code is not changed by this PR). |
5 tasks
kchibisov
requested changes
Jun 12, 2026
Comment on lines
+324
to
+342
| true | ||
| }, | ||
| Err(err) => { | ||
| warn!("Failed to create client side decorations frame: {err}"); | ||
| self.csd_fails = true; | ||
| false | ||
| }, | ||
| } | ||
| } else if configure.decoration_mode == DecorationMode::Server { | ||
| // Drop the frame for server side decorations to save resources. | ||
| self.frame = None; | ||
| } | ||
| let frame_just_dropped = self.frame.take().is_some(); | ||
| if frame_just_dropped { | ||
| // Without a frame, min/max hints must no longer include border sizes. | ||
| self.reload_min_max_hints(); | ||
| } | ||
| false | ||
| } else { | ||
| false | ||
| }; |
Member
There was a problem hiding this comment.
can you use let mut frame_just_created = false and set to true in this very specific branch, since reading it right now got really hard.
Comment on lines
+345
to
+356
| let current_surface_size = self.surface_size(); | ||
| // On the initial stateless configure, the compositor may echo the requested | ||
| // surface size from before the frame existed. Preserve that size instead of | ||
| // treating it as window geometry and subtracting the frame borders again. | ||
| let preserve_initial_surface_size = frame_just_created | ||
| && is_initial_configure | ||
| && stateless | ||
| && matches!( | ||
| configure.new_size, | ||
| (Some(width), Some(height)) | ||
| if width.get() == current_surface_size.width | ||
| && height.get() == current_surface_size.height |
Member
There was a problem hiding this comment.
This look strange to me. The size is for top-level, so previous state if we used CSD was for top-level with CSD, so we would need to subtract those, no?
Like logically, before we had window 800x600 with CSD, so user surface was smaller, then we got restored with 800x600, so we need to preserve the side with CSD included.
Like configure is for top-level and not for surface, so if you need to do that it sounds like some bug in compositor?
|
|
||
| // Add the borders. | ||
| let size = self | ||
| let applied_size = self |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
If a window is created with a minimum size hint and then needs client-side decorations on Wayland, the frame will actually reduce the real available size of the client application.
This fix takes this into account and causes the window to correctly increase its size based on the height that the frame needs.
Closes #4559
I'm not an expert on how the Wayland protocol works so if there is a better way to do this I am happy to implement it.
Manually tested on niri by modifying the
applicationexample with a min/max size constraint of 500x500.Without this patch the logs contain:
With the patch it turns into:
(875 is 500 when taking the scale factor into account)
Added an entry to thechangelogmodule if knowledge of this change could be valuable to usersUpdated documentation to reflect any user-facing changes, including notes of platform-specific behaviorCreated or updated an example program if it would help users understand this functionality