Skip to content

Commit bf4ab1f

Browse files
The max window size resize constraint should be unset if set to infinity (#20079)
# Objective The problem here is that if one tries to set the window resize constraint back to e.g. Default::default() where the max window size happens to be infinity then the max window resize constraint won't actually be changed at all, thus making it impossible to actually do this change. I believe this logic might be copied from the window creation logic over here: https://github.com/bevyengine/bevy/blob/6792cebfd0d49a167aeb70fa03a136a512707e53/crates/bevy_winit/src/winit_windows.rs#L262 In that instance the logic makes sense because it is known that the max size constraint will be None, since it's initialized to default at the top of that function. ## Solution Unconditionally set the max size constraint, just to None if either dimension is Infinity, which should produce the same outcome as the window creation logic ## Testing - Did you test these changes? If so, how? Only in so far that I confirmed the problem: if you try to change resize constraints back to Default::default() then no change will be made to the max resize constraint. This was confirmed after spotting the issue, so spotting it clearly had some predictive power. - Are there any parts that need more testing? - How can other people (reviewers) test your changes? Is there anything specific they need to know? - If relevant, what platforms did you test these changes on, and are there any important ones you can't test? I found this problem when researching a different problem that only shows up on X11, where the resize constraint prevents full screen from working correctly. Unfortunately we've confirmed that fixing this problem, while helpful on Windows, isn't enough to fix the full issue on X11. But that problem is unrelated to this and needs to be done in addition to this one, which is clearly a bug on every platform. Co-authored-by: Alice Cecile <alice.i.cecile@gmail.com>
1 parent cd41c83 commit bf4ab1f

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

crates/bevy_winit/src/system.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -435,9 +435,13 @@ pub(crate) fn changed_windows(
435435
};
436436

437437
winit_window.set_min_inner_size(Some(min_inner_size));
438-
if constraints.max_width.is_finite() && constraints.max_height.is_finite() {
439-
winit_window.set_max_inner_size(Some(max_inner_size));
440-
}
438+
winit_window.set_max_inner_size(
439+
if constraints.max_width.is_finite() && constraints.max_height.is_finite() {
440+
Some(max_inner_size)
441+
} else {
442+
None
443+
},
444+
);
441445
}
442446

443447
if window.position != cache.position

0 commit comments

Comments
 (0)