diff --git a/DDrawCompat/Gdi/WinProc.cpp b/DDrawCompat/Gdi/WinProc.cpp index d149eaa..66b0bad 100644 --- a/DDrawCompat/Gdi/WinProc.cpp +++ b/DDrawCompat/Gdi/WinProc.cpp @@ -1,7 +1,6 @@ #include #include -#include #include #include "Common/Hook.h" @@ -27,12 +26,10 @@ namespace HWINEVENTHOOK g_objectStateChangeEventHook = nullptr; std::set g_windowPosChangeNotifyFuncs; - void disableDwmAttributes(HWND hwnd); void onActivate(HWND hwnd); void onCreateWindow(HWND hwnd); void onDestroyWindow(HWND hwnd); void onWindowPosChanged(HWND hwnd); - void removeDropShadow(HWND hwnd); LRESULT CALLBACK callWndRetProc(int nCode, WPARAM wParam, LPARAM lParam) { @@ -77,17 +74,6 @@ namespace return LOG_RESULT(CallNextHookEx(nullptr, nCode, wParam, lParam)); } - void disableDwmAttributes(HWND hwnd) - { - DWMNCRENDERINGPOLICY ncRenderingPolicy = DWMNCRP_DISABLED; - DwmSetWindowAttribute(hwnd, DWMWA_NCRENDERING_POLICY, - &ncRenderingPolicy, sizeof(ncRenderingPolicy)); - - BOOL disableTransitions = TRUE; - DwmSetWindowAttribute(hwnd, DWMWA_TRANSITIONS_FORCEDISABLED, - &disableTransitions, sizeof(disableTransitions)); - } - void hookThread(DWORD threadId) { Compat::ScopedCriticalSection lock(g_threadIdToHookCs); @@ -197,8 +183,6 @@ namespace } hookThread(GetWindowThreadProcessId(hwnd, nullptr)); - disableDwmAttributes(hwnd); - removeDropShadow(hwnd); Gdi::PaintHandlers::onCreateWindow(hwnd); Gdi::Window::add(hwnd); } @@ -225,20 +209,11 @@ namespace notifyFunc(); } - if (Gdi::Window::get(hwnd)) + if (Gdi::Window::get(hwnd) || Gdi::Window::add(hwnd)) { Gdi::Window::updateAll(); } } - - void removeDropShadow(HWND hwnd) - { - const auto style = GetClassLongPtr(hwnd, GCL_STYLE); - if (style & CS_DROPSHADOW) - { - SetClassLongPtr(hwnd, GCL_STYLE, style ^ CS_DROPSHADOW); - } - } } namespace Gdi @@ -269,6 +244,7 @@ namespace Gdi GetCurrentProcessId(), 0, WINEVENT_INCONTEXT); EnumWindows(initTopLevelWindow, 0); + Gdi::Window::updateAll(); } void watchWindowPosChanges(WindowPosChangeNotifyFunc notifyFunc) diff --git a/DDrawCompat/Gdi/Window.cpp b/DDrawCompat/Gdi/Window.cpp index 8967f02..ae419ea 100644 --- a/DDrawCompat/Gdi/Window.cpp +++ b/DDrawCompat/Gdi/Window.cpp @@ -1,3 +1,5 @@ +#include + #include "Common/Hook.h" #include "Common/Log.h" #include "D3dDdi/ScopedCriticalSection.h" @@ -17,13 +19,6 @@ namespace DWORD g_presentationWindowThreadId = 0; HWND g_messageWindow = nullptr; - ATOM getComboLBoxAtom() - { - WNDCLASS wc = {}; - static ATOM comboLBoxAtom = static_cast(GetClassInfo(nullptr, "ComboLBox", &wc)); - return comboLBoxAtom; - } - LRESULT CALLBACK messageWindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { LOG_FUNC("messageWindowProc", hwnd, Compat::logWm(uMsg), Compat::hex(wParam), Compat::hex(lParam)); @@ -197,8 +192,19 @@ namespace Gdi , m_colorKey(CLR_INVALID) , m_alpha(255) , m_isLayered(GetWindowLong(m_hwnd, GWL_EXSTYLE)& WS_EX_LAYERED) - , m_isUpdating(false) { + DWMNCRENDERINGPOLICY ncRenderingPolicy = DWMNCRP_DISABLED; + DwmSetWindowAttribute(hwnd, DWMWA_NCRENDERING_POLICY, &ncRenderingPolicy, sizeof(ncRenderingPolicy)); + + BOOL disableTransitions = TRUE; + DwmSetWindowAttribute(hwnd, DWMWA_TRANSITIONS_FORCEDISABLED, &disableTransitions, sizeof(disableTransitions)); + + const auto style = GetClassLongPtr(hwnd, GCL_STYLE); + if (style & CS_DROPSHADOW) + { + SetClassLongPtr(hwnd, GCL_STYLE, style & ~CS_DROPSHADOW); + } + if (!m_isLayered) { SendNotifyMessage(g_messageWindow, WM_CREATEPRESENTATIONWINDOW, 0, reinterpret_cast(hwnd)); @@ -343,8 +349,7 @@ namespace Gdi bool Window::isTopLevelWindow(HWND hwnd) { - return !(GetWindowLongPtr(hwnd, GWL_STYLE) & WS_CHILD) || GetParent(hwnd) == GetDesktopWindow() || - getComboLBoxAtom() == GetClassLong(hwnd, GCW_ATOM); + return GetDesktopWindow() == GetAncestor(hwnd, GA_PARENT); } void Window::remove(HWND hwnd) @@ -384,12 +389,6 @@ namespace Gdi void Window::update() { D3dDdi::ScopedCriticalSection lock; - if (m_isUpdating) - { - return; - } - m_isUpdating = true; - const bool isLayered = GetWindowLong(m_hwnd, GWL_EXSTYLE) & WS_EX_LAYERED; if (isLayered != m_isLayered) { @@ -428,8 +427,6 @@ namespace Gdi swap(m_visibleRegion, newVisibleRegion); calcInvalidatedRegion(newWindowRect, newVisibleRegion); - - m_isUpdating = false; } void Window::updateAll() diff --git a/DDrawCompat/Gdi/Window.h b/DDrawCompat/Gdi/Window.h index d047e4a..0bc69a1 100644 --- a/DDrawCompat/Gdi/Window.h +++ b/DDrawCompat/Gdi/Window.h @@ -51,7 +51,6 @@ namespace Gdi COLORREF m_colorKey; BYTE m_alpha; bool m_isLayered; - bool m_isUpdating; static std::map> s_windows; };