From f92803d80ecd9a0d798ee0e3e3e32a87eca36693 Mon Sep 17 00:00:00 2001 From: Osspial Date: Wed, 11 Aug 2021 14:02:40 -0400 Subject: [PATCH] Prevent ghost window from showing up on taskbar (#1977) Add WS_EX_TOOLWINDOW to event target window --- CHANGELOG.md | 1 + src/platform_impl/windows/event_loop.rs | 12 +++++++++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 865cc071..9bafaa05 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ - **Breaking:** On Web, remove the `stdweb` backend. - Added `Window::focus_window`to bring the window to the front and set input focus. - On Wayland and X11, implement `is_maximized` method on `Window`. +- On Windows, prevent ghost window from showing up in the taskbar after either several hours of use or restarting `explorer.exe`. - On macOS, fix issue where `ReceivedCharacter` was not being emitted during some key repeat events. - On Wayland, load cursor icons `hand2` and `hand1` for `CursorIcon::Hand`. diff --git a/src/platform_impl/windows/event_loop.rs b/src/platform_impl/windows/event_loop.rs index d8f635be..17d7def6 100644 --- a/src/platform_impl/windows/event_loop.rs +++ b/src/platform_impl/windows/event_loop.rs @@ -596,7 +596,17 @@ fn create_event_target_window() -> HWND { unsafe { let window = winuser::CreateWindowExW( - winuser::WS_EX_NOACTIVATE | winuser::WS_EX_TRANSPARENT | winuser::WS_EX_LAYERED, + winuser::WS_EX_NOACTIVATE + | winuser::WS_EX_TRANSPARENT + | winuser::WS_EX_LAYERED + // WS_EX_TOOLWINDOW prevents this window from ever showing up in the taskbar, which + // we want to avoid. If you remove this style, this window won't show up in the + // taskbar *initially*, but it can show up at some later point. This can sometimes + // happen on its own after several hours have passed, although this has proven + // difficult to reproduce. Alternatively, it can be manually triggered by killing + // `explorer.exe` and then starting the process back up. + // It is unclear why the bug is triggered by waiting for several hours. + | winuser::WS_EX_TOOLWINDOW, THREAD_EVENT_TARGET_WINDOW_CLASS.as_ptr(), ptr::null_mut(), 0,