winit: Fix the maximize window not being disabled for fixed-size windows

The workaround of PR #6997 does not work anymore as the window is created much later. Apply the workaround when creating the window.
This commit is contained in:
Simon Hausmann 2025-06-26 17:32:16 +02:00 committed by Simon Hausmann
parent 4823ffa490
commit fae218fa6b

View file

@ -233,13 +233,6 @@ impl WinitWindowOrNone {
match self {
Self::HasWindow { window, .. } => {
window.set_resizable(resizable);
// Workaround for winit bug #2990
// Non-resizable windows can still contain a maximize button,
// so we'd have to additionally remove the button.
let mut buttons = window.enabled_buttons();
buttons.set(WindowButtons::MAXIMIZE, resizable);
window.set_enabled_buttons(buttons);
}
Self::None(attributes) => attributes.borrow_mut().resizable = resizable,
}
@ -439,6 +432,7 @@ impl WinitWindowAdapter {
// a) need to compute the correct size based on the scale factor before it's shown on the screen (handled by set_visible)
// b) need to create the accesskit adapter before it's shown on the screen, as required by accesskit.
let show_after_creation = std::mem::replace(&mut window_attributes.visible, false);
let resizable = window_attributes.resizable;
let overriding_scale_factor = std::env::var("SLINT_SCALE_FACTOR")
.ok()
@ -492,6 +486,15 @@ impl WinitWindowAdapter {
self.set_visibility(WindowVisibility::ShownFirstTime)?;
}
{
// Workaround for winit bug #2990
// Non-resizable windows can still contain a maximize button,
// so we'd have to additionally remove the button.
let mut buttons = winit_window.enabled_buttons();
buttons.set(WindowButtons::MAXIMIZE, resizable);
winit_window.set_enabled_buttons(buttons);
}
self.shared_backend_data
.register_window(winit_window.id(), (self.self_weak.upgrade().unwrap()) as _);