From 0e20973bdbbb4a8e2a48b347d155114006dbd528 Mon Sep 17 00:00:00 2001 From: chichid Date: Wed, 26 Jun 2019 00:04:49 -0400 Subject: [PATCH] Fix 968: Invisible windows steal focus from visible windows Win32 (#968) --- CHANGELOG.md | 1 + src/platform_impl/windows/window.rs | 3 ++- src/platform_impl/windows/window_state.rs | 7 +++++-- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ddc68165..d4469498 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ - Change `Event::Suspended(true / false)` to `Event::Suspended` and `Event::Resumed`. - On X11, fix sanity check which checks that a monitor's reported width and height (in millimeters) are non-zero when calculating the DPI factor. +- On Windows, when a window is initially invisible, it won't take focus from the existing visible windows. # 0.20.0 Alpha 1 diff --git a/src/platform_impl/windows/window.rs b/src/platform_impl/windows/window.rs index 64419204..54089219 100644 --- a/src/platform_impl/windows/window.rs +++ b/src/platform_impl/windows/window.rs @@ -271,7 +271,8 @@ impl Window { winuser::SWP_ASYNCWINDOWPOS | winuser::SWP_NOZORDER | winuser::SWP_NOREPOSITION - | winuser::SWP_NOMOVE, + | winuser::SWP_NOMOVE + | winuser::SWP_NOACTIVATE, ); winuser::UpdateWindow(self.window.0); } diff --git a/src/platform_impl/windows/window_state.rs b/src/platform_impl/windows/window_state.rs index ee9d953b..14cc7144 100644 --- a/src/platform_impl/windows/window_state.rs +++ b/src/platform_impl/windows/window_state.rs @@ -307,7 +307,9 @@ impl WindowFlags { y, w, h, - winuser::SWP_NOZORDER | winuser::SWP_FRAMECHANGED, + winuser::SWP_NOZORDER + | winuser::SWP_FRAMECHANGED + | winuser::SWP_NOACTIVATE, ); } None => { @@ -322,7 +324,8 @@ impl WindowFlags { winuser::SWP_NOZORDER | winuser::SWP_NOMOVE | winuser::SWP_NOSIZE - | winuser::SWP_FRAMECHANGED, + | winuser::SWP_FRAMECHANGED + | winuser::SWP_NOACTIVATE, ); } }