mirror of
https://github.com/slint-ui/slint.git
synced 2025-08-04 18:58:36 +00:00
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:
parent
4823ffa490
commit
fae218fa6b
1 changed files with 10 additions and 7 deletions
|
@ -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 _);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue