From f70efbb9637167315451915b28fffaa36ce73560 Mon Sep 17 00:00:00 2001 From: Silent Date: Mon, 5 Aug 2019 21:46:00 +0200 Subject: [PATCH 1/2] WinUpdater: Create updater window as hidden by default UpdaterCommon attempts to hide updater window directly after creating, so creating it hidden avoids the window from showing for a split second --- Source/Core/WinUpdater/WinUI.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/Core/WinUpdater/WinUI.cpp b/Source/Core/WinUpdater/WinUI.cpp index 97f2da459b..6958be9d40 100644 --- a/Source/Core/WinUpdater/WinUI.cpp +++ b/Source/Core/WinUpdater/WinUI.cpp @@ -45,7 +45,7 @@ LRESULT CALLBACK WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) }; // namespace constexpr int PROGRESSBAR_FLAGS = WS_VISIBLE | WS_CHILD | PBS_SMOOTH | PBS_SMOOTHREVERSE; -constexpr int WINDOW_FLAGS = WS_VISIBLE | WS_CLIPCHILDREN; +constexpr int WINDOW_FLAGS = WS_CLIPCHILDREN; constexpr int PADDING_HEIGHT = 5; namespace UI From 8e7970585492b9c1c17727c2b0a46ce5e7c4130e Mon Sep 17 00:00:00 2001 From: Silent Date: Mon, 5 Aug 2019 21:47:53 +0200 Subject: [PATCH 2/2] WinUpdater: Wait in UI::Init until window is done creating to avoid losing UI::SetVisible signals --- Source/Core/WinUpdater/WinUI.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/Source/Core/WinUpdater/WinUI.cpp b/Source/Core/WinUpdater/WinUI.cpp index 6958be9d40..f6b0a7345c 100644 --- a/Source/Core/WinUpdater/WinUI.cpp +++ b/Source/Core/WinUpdater/WinUI.cpp @@ -12,6 +12,8 @@ #include #include +#include "Common/Event.h" +#include "Common/ScopeGuard.h" #include "Common/StringUtil.h" namespace @@ -23,6 +25,7 @@ HWND current_progressbar_handle = nullptr; ITaskbarList3* taskbar_list = nullptr; std::thread ui_thread; +Common::Event window_created_event; int GetWindowHeight(HWND hwnd) { @@ -54,6 +57,9 @@ bool InitWindow() { InitCommonControls(); + // Notify main thread we're done creating the window when we return + Common::ScopeGuard ui_guard{[] { window_created_event.Set(); }}; + WNDCLASS wndcl = {}; wndcl.lpfnWndProc = WindowProc; wndcl.hbrBackground = GetSysColorBrush(COLOR_MENU); @@ -226,6 +232,9 @@ void MessageLoop() void Init() { ui_thread = std::thread(MessageLoop); + + // Wait for UI thread to finish creating the window (or at least attempting to) + window_created_event.Wait(); } void Stop()