From 34c5c28cecb07e858001628bb1a0054acf508eb6 Mon Sep 17 00:00:00 2001 From: narzoul Date: Tue, 6 Apr 2021 11:51:40 +0200 Subject: [PATCH] Update window visible regions during VirtualScreen::update --- DDrawCompat/Gdi/PresentationWindow.cpp | 7 +++++++ DDrawCompat/Gdi/PresentationWindow.h | 1 + DDrawCompat/Gdi/VirtualScreen.cpp | 2 ++ DDrawCompat/Gdi/Window.cpp | 5 +++++ 4 files changed, 15 insertions(+) diff --git a/DDrawCompat/Gdi/PresentationWindow.cpp b/DDrawCompat/Gdi/PresentationWindow.cpp index a7d6247..09dedff 100644 --- a/DDrawCompat/Gdi/PresentationWindow.cpp +++ b/DDrawCompat/Gdi/PresentationWindow.cpp @@ -13,6 +13,7 @@ namespace HANDLE g_presentationWindowThread = nullptr; unsigned g_presentationWindowThreadId = 0; HWND g_messageWindow = nullptr; + bool g_isThreadReady = false; LRESULT CALLBACK messageWindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { @@ -97,6 +98,7 @@ namespace return 0; } + g_isThreadReady = true; Gdi::WinProc::installHooks(); Compat::closeDbgEng(); @@ -150,6 +152,11 @@ namespace Gdi return GetWindowThreadProcessId(hwnd, nullptr) == g_presentationWindowThreadId; } + bool isThreadReady() + { + return g_isThreadReady; + } + void setWindowPos(HWND hwnd, const WINDOWPOS& wp) { sendMessageBlocking(hwnd, WM_SETPRESENTATIONWINDOWPOS, 0, reinterpret_cast(&wp)); diff --git a/DDrawCompat/Gdi/PresentationWindow.h b/DDrawCompat/Gdi/PresentationWindow.h index ed46999..0984ca9 100644 --- a/DDrawCompat/Gdi/PresentationWindow.h +++ b/DDrawCompat/Gdi/PresentationWindow.h @@ -9,6 +9,7 @@ namespace Gdi HWND create(HWND owner); void destroy(HWND hwnd); bool isPresentationWindow(HWND hwnd); + bool isThreadReady(); void setWindowPos(HWND hwnd, const WINDOWPOS& wp); void setWindowRgn(HWND hwnd, HRGN rgn); void startThread(); diff --git a/DDrawCompat/Gdi/VirtualScreen.cpp b/DDrawCompat/Gdi/VirtualScreen.cpp index c395111..ca412e7 100644 --- a/DDrawCompat/Gdi/VirtualScreen.cpp +++ b/DDrawCompat/Gdi/VirtualScreen.cpp @@ -11,6 +11,7 @@ #include #include #include +#include #include namespace @@ -275,6 +276,7 @@ namespace Gdi } } + Gdi::Window::updateAll(); Gdi::redraw(nullptr); return LOG_RESULT(true); } diff --git a/DDrawCompat/Gdi/Window.cpp b/DDrawCompat/Gdi/Window.cpp index 74a9740..bd1c184 100644 --- a/DDrawCompat/Gdi/Window.cpp +++ b/DDrawCompat/Gdi/Window.cpp @@ -512,6 +512,11 @@ namespace Gdi void updateAll() { LOG_FUNC("Window::updateAll"); + if (!Gdi::PresentationWindow::isThreadReady()) + { + return; + } + UpdateWindowContext context; context.processId = GetCurrentProcessId(); context.virtualScreenRegion = VirtualScreen::getRegion();