mirror of
https://github.com/narzoul/DDrawCompat
synced 2024-12-30 08:55:36 +01:00
Handle child window parent change to desktop (used by ComboLBox)
This commit is contained in:
parent
3cc5a47156
commit
169b4c0534
@ -1,7 +1,6 @@
|
||||
#include <map>
|
||||
#include <set>
|
||||
|
||||
#include <dwmapi.h>
|
||||
#include <Windows.h>
|
||||
|
||||
#include "Common/Hook.h"
|
||||
@ -27,12 +26,10 @@ namespace
|
||||
HWINEVENTHOOK g_objectStateChangeEventHook = nullptr;
|
||||
std::set<Gdi::WindowPosChangeNotifyFunc> 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)
|
||||
|
@ -1,3 +1,5 @@
|
||||
#include <dwmapi.h>
|
||||
|
||||
#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<ATOM>(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<WPARAM>(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()
|
||||
|
@ -51,7 +51,6 @@ namespace Gdi
|
||||
COLORREF m_colorKey;
|
||||
BYTE m_alpha;
|
||||
bool m_isLayered;
|
||||
bool m_isUpdating;
|
||||
|
||||
static std::map<HWND, std::shared_ptr<Window>> s_windows;
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user