fix(windows): delay maximize window if hidden - #1306
Conversation
Package Changes Through 137254eThere are 1 changes which include tao with minor Planned Package VersionsThe following package releases are the planned based on the context of changes in this pull request.
Add another change file through the GitHub UI by following this link. Read about change files or the docs at github.com/jbolda/covector |
|
This change made so that the size and position remain the pre-maximized while the window's hidden, @FabianLars could you help test if this is also the case for macOS? (it seems to be the case on Linux) diff --git a/examples/window.rs b/examples/window.rs
index c4804fc4..7dce477c 100644
--- a/examples/window.rs
+++ b/examples/window.rs
@@ -2,6 +2,8 @@
// Copyright 2021-2023 Tauri Programme within The Commons Conservancy
// SPDX-License-Identifier: Apache-2.0
+use std::{sync::Arc, thread::sleep, time::Duration};
+
use tao::{
event::{Event, WindowEvent},
event_loop::{ControlFlow, EventLoop},
@@ -12,18 +14,31 @@ use tao::{
fn main() {
let event_loop = EventLoop::new();
- let mut window = Some(
+ let mut window = Some(Arc::new(
WindowBuilder::new()
.with_title("A fantastic window!")
.with_inner_size(tao::dpi::LogicalSize::new(300.0, 300.0))
.with_min_inner_size(tao::dpi::LogicalSize::new(200.0, 200.0))
+ .with_visible(false)
.build(&event_loop)
.unwrap(),
- );
+ ));
+
+ // window.as_ref().unwrap().set_visible(false);
+ window.as_ref().unwrap().set_maximized(true);
+
+ let window_clone = window.clone();
+
+ std::thread::spawn(move || {
+ sleep(Duration::from_secs(3));
+ dbg!(window_clone.as_ref().unwrap().inner_size());
+ window_clone.as_ref().unwrap().set_visible(true);
+ // window_clone.as_ref().unwrap().set_maximized(true);
+ });
event_loop.run(move |event, _, control_flow| {
*control_flow = ControlFlow::Wait;
- println!("{event:?}");
+ // println!("{event:?}");
match event {
Event::WindowEvent {
|
|
just woke up so i may be dense, i just apply that diff, run Bildschirmaufnahme.2026-08-12.um.10.41.37.mov |
|
Looking like the size is the maximized size on macOS? I can't think of if this can cause problems right now but I always want to be careful with this type of changes. (before this change, on Windows, if you have a hidden window and then call maximize, it will show the window very briefly and then hide it again, now if you query the size/pos of the window, you get the states after the maximization, but now you get the pre-maximized states) |
Yes. is this good? 😂 |
|
Maybe? Like you can do something based on the window's size and position before showing the window. That being said, flashing it to get the correct size is a no go for me anyways so maybe let's just roll with this. |
Fix #1142
Fix tauri-apps/tauri#14068
On Windows, delay maximizing the window if it's hidden to avoid it flashing briefly. This also changed the size and position returned to pre-maximized states if you query them with the window being hidden and called
maximizeThis is mainly for the tauri's window-state plugin since you need to set
visible: falseto avoid flashing. This will allow you to set both maximized + hidden without causing a flashing window.