win: remove unnecessary code & add some comments

Signed-off-by: Yuhang Zhao <2546789017@qq.com>
This commit is contained in:
Yuhang Zhao 2023-06-04 13:28:14 +08:00
parent 907fdeae67
commit 00b67ead0e
1 changed files with 7 additions and 9 deletions

View File

@ -416,11 +416,15 @@ static inline void cleanupFallbackWindow()
{ {
const HINSTANCE instance = GetModuleHandleW(nullptr); const HINSTANCE instance = GetModuleHandleW(nullptr);
if (!instance) { if (!instance) {
WARNING << Utils::getSystemErrorMessage(kGetModuleHandleW); //WARNING << Utils::getSystemErrorMessage(kGetModuleHandleW);
return; return;
} }
// According to MSDN, if the window class is registered from a shared library,
// we will need to unregister it manually. Only the code which is directly
// linked into the executable doesn't need manual unregistration, because
// Windows will take care of it for us.
if (UnregisterClassW(kFallbackTitleBarWindowClassName, instance) == FALSE) { if (UnregisterClassW(kFallbackTitleBarWindowClassName, instance) == FALSE) {
WARNING << Utils::getSystemErrorMessage(kUnregisterClassW); //WARNING << Utils::getSystemErrorMessage(kUnregisterClassW);
} }
} }
@ -589,20 +593,14 @@ void FramelessHelperWin::removeWindow(const WId windowId)
g_win32Helper()->nativeEventFilter.reset(); g_win32Helper()->nativeEventFilter.reset();
} }
} }
HWND hwnd = nullptr;
auto it = g_win32Helper()->fallbackTitleBarToParentWindowMapping.constBegin(); auto it = g_win32Helper()->fallbackTitleBarToParentWindowMapping.constBegin();
while (it != g_win32Helper()->fallbackTitleBarToParentWindowMapping.constEnd()) { while (it != g_win32Helper()->fallbackTitleBarToParentWindowMapping.constEnd()) {
if (it.value() == windowId) { if (it.value() == windowId) {
const WId key = it.key(); g_win32Helper()->fallbackTitleBarToParentWindowMapping.remove(it.key());
hwnd = reinterpret_cast<HWND>(key);
g_win32Helper()->fallbackTitleBarToParentWindowMapping.remove(key);
break; break;
} }
++it; ++it;
} }
if (DestroyWindow(hwnd) == FALSE) {
WARNING << Utils::getSystemErrorMessage(kDestroyWindow);
}
} }
bool FramelessHelperWin::nativeEventFilter(const QByteArray &eventType, void *message, QT_NATIVE_EVENT_RESULT_TYPE *result) bool FramelessHelperWin::nativeEventFilter(const QByteArray &eventType, void *message, QT_NATIVE_EVENT_RESULT_TYPE *result)