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 <map>
|
||||||
#include <set>
|
#include <set>
|
||||||
|
|
||||||
#include <dwmapi.h>
|
|
||||||
#include <Windows.h>
|
#include <Windows.h>
|
||||||
|
|
||||||
#include "Common/Hook.h"
|
#include "Common/Hook.h"
|
||||||
@ -27,12 +26,10 @@ namespace
|
|||||||
HWINEVENTHOOK g_objectStateChangeEventHook = nullptr;
|
HWINEVENTHOOK g_objectStateChangeEventHook = nullptr;
|
||||||
std::set<Gdi::WindowPosChangeNotifyFunc> g_windowPosChangeNotifyFuncs;
|
std::set<Gdi::WindowPosChangeNotifyFunc> g_windowPosChangeNotifyFuncs;
|
||||||
|
|
||||||
void disableDwmAttributes(HWND hwnd);
|
|
||||||
void onActivate(HWND hwnd);
|
void onActivate(HWND hwnd);
|
||||||
void onCreateWindow(HWND hwnd);
|
void onCreateWindow(HWND hwnd);
|
||||||
void onDestroyWindow(HWND hwnd);
|
void onDestroyWindow(HWND hwnd);
|
||||||
void onWindowPosChanged(HWND hwnd);
|
void onWindowPosChanged(HWND hwnd);
|
||||||
void removeDropShadow(HWND hwnd);
|
|
||||||
|
|
||||||
LRESULT CALLBACK callWndRetProc(int nCode, WPARAM wParam, LPARAM lParam)
|
LRESULT CALLBACK callWndRetProc(int nCode, WPARAM wParam, LPARAM lParam)
|
||||||
{
|
{
|
||||||
@ -77,17 +74,6 @@ namespace
|
|||||||
return LOG_RESULT(CallNextHookEx(nullptr, nCode, wParam, lParam));
|
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)
|
void hookThread(DWORD threadId)
|
||||||
{
|
{
|
||||||
Compat::ScopedCriticalSection lock(g_threadIdToHookCs);
|
Compat::ScopedCriticalSection lock(g_threadIdToHookCs);
|
||||||
@ -197,8 +183,6 @@ namespace
|
|||||||
}
|
}
|
||||||
|
|
||||||
hookThread(GetWindowThreadProcessId(hwnd, nullptr));
|
hookThread(GetWindowThreadProcessId(hwnd, nullptr));
|
||||||
disableDwmAttributes(hwnd);
|
|
||||||
removeDropShadow(hwnd);
|
|
||||||
Gdi::PaintHandlers::onCreateWindow(hwnd);
|
Gdi::PaintHandlers::onCreateWindow(hwnd);
|
||||||
Gdi::Window::add(hwnd);
|
Gdi::Window::add(hwnd);
|
||||||
}
|
}
|
||||||
@ -225,20 +209,11 @@ namespace
|
|||||||
notifyFunc();
|
notifyFunc();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Gdi::Window::get(hwnd))
|
if (Gdi::Window::get(hwnd) || Gdi::Window::add(hwnd))
|
||||||
{
|
{
|
||||||
Gdi::Window::updateAll();
|
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
|
namespace Gdi
|
||||||
@ -269,6 +244,7 @@ namespace Gdi
|
|||||||
GetCurrentProcessId(), 0, WINEVENT_INCONTEXT);
|
GetCurrentProcessId(), 0, WINEVENT_INCONTEXT);
|
||||||
|
|
||||||
EnumWindows(initTopLevelWindow, 0);
|
EnumWindows(initTopLevelWindow, 0);
|
||||||
|
Gdi::Window::updateAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
void watchWindowPosChanges(WindowPosChangeNotifyFunc notifyFunc)
|
void watchWindowPosChanges(WindowPosChangeNotifyFunc notifyFunc)
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
#include <dwmapi.h>
|
||||||
|
|
||||||
#include "Common/Hook.h"
|
#include "Common/Hook.h"
|
||||||
#include "Common/Log.h"
|
#include "Common/Log.h"
|
||||||
#include "D3dDdi/ScopedCriticalSection.h"
|
#include "D3dDdi/ScopedCriticalSection.h"
|
||||||
@ -17,13 +19,6 @@ namespace
|
|||||||
DWORD g_presentationWindowThreadId = 0;
|
DWORD g_presentationWindowThreadId = 0;
|
||||||
HWND g_messageWindow = nullptr;
|
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)
|
LRESULT CALLBACK messageWindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
||||||
{
|
{
|
||||||
LOG_FUNC("messageWindowProc", hwnd, Compat::logWm(uMsg), Compat::hex(wParam), Compat::hex(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_colorKey(CLR_INVALID)
|
||||||
, m_alpha(255)
|
, m_alpha(255)
|
||||||
, m_isLayered(GetWindowLong(m_hwnd, GWL_EXSTYLE)& WS_EX_LAYERED)
|
, 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)
|
if (!m_isLayered)
|
||||||
{
|
{
|
||||||
SendNotifyMessage(g_messageWindow, WM_CREATEPRESENTATIONWINDOW, 0, reinterpret_cast<WPARAM>(hwnd));
|
SendNotifyMessage(g_messageWindow, WM_CREATEPRESENTATIONWINDOW, 0, reinterpret_cast<WPARAM>(hwnd));
|
||||||
@ -343,8 +349,7 @@ namespace Gdi
|
|||||||
|
|
||||||
bool Window::isTopLevelWindow(HWND hwnd)
|
bool Window::isTopLevelWindow(HWND hwnd)
|
||||||
{
|
{
|
||||||
return !(GetWindowLongPtr(hwnd, GWL_STYLE) & WS_CHILD) || GetParent(hwnd) == GetDesktopWindow() ||
|
return GetDesktopWindow() == GetAncestor(hwnd, GA_PARENT);
|
||||||
getComboLBoxAtom() == GetClassLong(hwnd, GCW_ATOM);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Window::remove(HWND hwnd)
|
void Window::remove(HWND hwnd)
|
||||||
@ -384,12 +389,6 @@ namespace Gdi
|
|||||||
void Window::update()
|
void Window::update()
|
||||||
{
|
{
|
||||||
D3dDdi::ScopedCriticalSection lock;
|
D3dDdi::ScopedCriticalSection lock;
|
||||||
if (m_isUpdating)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
m_isUpdating = true;
|
|
||||||
|
|
||||||
const bool isLayered = GetWindowLong(m_hwnd, GWL_EXSTYLE) & WS_EX_LAYERED;
|
const bool isLayered = GetWindowLong(m_hwnd, GWL_EXSTYLE) & WS_EX_LAYERED;
|
||||||
if (isLayered != m_isLayered)
|
if (isLayered != m_isLayered)
|
||||||
{
|
{
|
||||||
@ -428,8 +427,6 @@ namespace Gdi
|
|||||||
swap(m_visibleRegion, newVisibleRegion);
|
swap(m_visibleRegion, newVisibleRegion);
|
||||||
|
|
||||||
calcInvalidatedRegion(newWindowRect, newVisibleRegion);
|
calcInvalidatedRegion(newWindowRect, newVisibleRegion);
|
||||||
|
|
||||||
m_isUpdating = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Window::updateAll()
|
void Window::updateAll()
|
||||||
|
@ -51,7 +51,6 @@ namespace Gdi
|
|||||||
COLORREF m_colorKey;
|
COLORREF m_colorKey;
|
||||||
BYTE m_alpha;
|
BYTE m_alpha;
|
||||||
bool m_isLayered;
|
bool m_isLayered;
|
||||||
bool m_isUpdating;
|
|
||||||
|
|
||||||
static std::map<HWND, std::shared_ptr<Window>> s_windows;
|
static std::map<HWND, std::shared_ptr<Window>> s_windows;
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user