mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-02-21 21:41:09 +00:00
WinUpdater: Replaced PeekMessage with GetMessage - removes a busy loop in favour of a proper wait based message queue
This commit is contained in:
parent
15679a9a70
commit
2ae409ba06
@ -24,7 +24,6 @@ HWND current_progressbar_handle = nullptr;
|
|||||||
ITaskbarList3* taskbar_list = nullptr;
|
ITaskbarList3* taskbar_list = nullptr;
|
||||||
|
|
||||||
Common::Flag running;
|
Common::Flag running;
|
||||||
Common::Flag request_stop;
|
|
||||||
|
|
||||||
int GetWindowHeight(HWND hwnd)
|
int GetWindowHeight(HWND hwnd)
|
||||||
{
|
{
|
||||||
@ -33,6 +32,17 @@ int GetWindowHeight(HWND hwnd)
|
|||||||
|
|
||||||
return rect.bottom - rect.top;
|
return rect.bottom - rect.top;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
LRESULT CALLBACK WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
||||||
|
{
|
||||||
|
switch (uMsg)
|
||||||
|
{
|
||||||
|
case WM_DESTROY:
|
||||||
|
PostQuitMessage(0);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
return DefWindowProc(hwnd, uMsg, wParam, lParam);
|
||||||
|
}
|
||||||
}; // namespace
|
}; // namespace
|
||||||
|
|
||||||
constexpr int PROGRESSBAR_FLAGS = WS_VISIBLE | WS_CHILD | PBS_SMOOTH | PBS_SMOOTHREVERSE;
|
constexpr int PROGRESSBAR_FLAGS = WS_VISIBLE | WS_CHILD | PBS_SMOOTH | PBS_SMOOTHREVERSE;
|
||||||
@ -46,7 +56,7 @@ bool InitWindow()
|
|||||||
InitCommonControls();
|
InitCommonControls();
|
||||||
|
|
||||||
WNDCLASS wndcl = {};
|
WNDCLASS wndcl = {};
|
||||||
wndcl.lpfnWndProc = DefWindowProcW;
|
wndcl.lpfnWndProc = WindowProc;
|
||||||
wndcl.hbrBackground = GetSysColorBrush(COLOR_MENU);
|
wndcl.hbrBackground = GetSysColorBrush(COLOR_MENU);
|
||||||
wndcl.lpszClassName = L"UPDATER";
|
wndcl.lpszClassName = L"UPDATER";
|
||||||
|
|
||||||
@ -124,14 +134,6 @@ bool InitWindow()
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Destroy()
|
|
||||||
{
|
|
||||||
DestroyWindow(window_handle);
|
|
||||||
DestroyWindow(label_handle);
|
|
||||||
DestroyWindow(total_progressbar_handle);
|
|
||||||
DestroyWindow(current_progressbar_handle);
|
|
||||||
}
|
|
||||||
|
|
||||||
void SetTotalMarquee(bool marquee)
|
void SetTotalMarquee(bool marquee)
|
||||||
{
|
{
|
||||||
SetWindowLong(total_progressbar_handle, GWL_STYLE,
|
SetWindowLong(total_progressbar_handle, GWL_STYLE,
|
||||||
@ -199,7 +201,6 @@ void SetDescription(const std::string& text)
|
|||||||
|
|
||||||
void MessageLoop()
|
void MessageLoop()
|
||||||
{
|
{
|
||||||
request_stop.Clear();
|
|
||||||
running.Set();
|
running.Set();
|
||||||
|
|
||||||
if (!InitWindow())
|
if (!InitWindow())
|
||||||
@ -211,19 +212,14 @@ void MessageLoop()
|
|||||||
SetTotalMarquee(true);
|
SetTotalMarquee(true);
|
||||||
SetCurrentMarquee(true);
|
SetCurrentMarquee(true);
|
||||||
|
|
||||||
while (!request_stop.IsSet())
|
|
||||||
{
|
|
||||||
MSG msg;
|
MSG msg;
|
||||||
while (PeekMessage(&msg, window_handle, 0, 0, PM_REMOVE))
|
while (GetMessage(&msg, nullptr, 0, 0))
|
||||||
{
|
{
|
||||||
TranslateMessage(&msg);
|
TranslateMessage(&msg);
|
||||||
DispatchMessage(&msg);
|
DispatchMessage(&msg);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
running.Clear();
|
running.Clear();
|
||||||
|
|
||||||
Destroy();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Init()
|
void Init()
|
||||||
@ -237,7 +233,7 @@ void Stop()
|
|||||||
if (!running.IsSet())
|
if (!running.IsSet())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
request_stop.Set();
|
PostMessage(window_handle, WM_CLOSE, 0, 0);
|
||||||
|
|
||||||
while (running.IsSet())
|
while (running.IsSet())
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user