Skip to content

fix(windows): delay maximize window if hidden - #1306

Open
Legend-Master wants to merge 2 commits into
tauri-apps:devfrom
Legend-Master:delay-maximize-if-hidden
Open

fix(windows): delay maximize window if hidden#1306
Legend-Master wants to merge 2 commits into
tauri-apps:devfrom
Legend-Master:delay-maximize-if-hidden

Conversation

@Legend-Master

@Legend-Master Legend-Master commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

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 maximize

This is mainly for the tauri's window-state plugin since you need to set visible: false to avoid flashing. This will allow you to set both maximized + hidden without causing a flashing window.

@github-actions

github-actions Bot commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

Package Changes Through 137254e

There are 1 changes which include tao with minor

Planned Package Versions

The following package releases are the planned based on the context of changes in this pull request.

package current next
tao 0.36.0 0.37.0

Add another change file through the GitHub UI by following this link.


Read about change files or the docs at github.com/jbolda/covector

@Legend-Master

Legend-Master commented Aug 12, 2026

Copy link
Copy Markdown
Contributor Author

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 {

@FabianLars

Copy link
Copy Markdown
Member

just woke up so i may be dense, i just apply that diff, run cargo run --example window and see how the window behaves?
I think it looks good.

Bildschirmaufnahme.2026-08-12.um.10.41.37.mov

@Legend-Master

Copy link
Copy Markdown
Contributor Author

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)

@FabianLars

Copy link
Copy Markdown
Member

Looking like the size is the maximized size on macOS?

Yes. is this good? 😂

@Legend-Master

Copy link
Copy Markdown
Contributor Author

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.

@Legend-Master
Legend-Master marked this pull request as ready for review August 12, 2026 10:43
@Legend-Master
Legend-Master requested a review from a team as a code owner August 12, 2026 10:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants