add more comments

Signed-off-by: Yuhang Zhao <2546789017@qq.com>
This commit is contained in:
Yuhang Zhao 2022-09-11 10:43:48 +08:00
parent 6a46844853
commit 55fe04000e
7 changed files with 18 additions and 7 deletions

View File

@ -99,5 +99,7 @@ void Dialog::setupUi()
helper->setSystemButton(titleBar->minimizeButton(), SystemButtonType::Minimize); helper->setSystemButton(titleBar->minimizeButton(), SystemButtonType::Minimize);
helper->setSystemButton(titleBar->maximizeButton(), SystemButtonType::Maximize); helper->setSystemButton(titleBar->maximizeButton(), SystemButtonType::Maximize);
helper->setSystemButton(titleBar->closeButton(), SystemButtonType::Close); helper->setSystemButton(titleBar->closeButton(), SystemButtonType::Close);
// Special hack to disable the overriding of the mouse cursor, it's totally different
// with making the window un-resizable, so we don't use setFixedSize() here.
FramelessWidgetsHelperPrivate::get(helper)->setProperty(FRAMELESSHELPER_BYTEARRAY_LITERAL("FRAMELESSHELPER_DONT_OVERRIDE_CURSOR"), true); FramelessWidgetsHelperPrivate::get(helper)->setProperty(FRAMELESSHELPER_BYTEARRAY_LITERAL("FRAMELESSHELPER_DONT_OVERRIDE_CURSOR"), true);
} }

View File

@ -52,6 +52,7 @@ int main(int argc, char *argv[])
const int exec = QCoreApplication::exec(); const int exec = QCoreApplication::exec();
// Not necessary, but if you don't call it, there will be some small memory leaks.
FramelessHelper::Widgets::uninitialize(); FramelessHelper::Widgets::uninitialize();
return exec; return exec;

View File

@ -52,6 +52,7 @@ int main(int argc, char *argv[])
const int exec = QCoreApplication::exec(); const int exec = QCoreApplication::exec();
// Not necessary, but if you don't call it, there will be some small memory leaks.
FramelessHelper::Widgets::uninitialize(); FramelessHelper::Widgets::uninitialize();
return exec; return exec;

View File

@ -104,6 +104,7 @@ int main(int argc, char *argv[])
const int exec = QCoreApplication::exec(); const int exec = QCoreApplication::exec();
// Not necessary, but if you don't call it, there will be some small memory leaks.
FramelessHelper::Widgets::uninitialize(); FramelessHelper::Widgets::uninitialize();
return exec; return exec;

View File

@ -52,6 +52,7 @@ int main(int argc, char *argv[])
const int exec = QCoreApplication::exec(); const int exec = QCoreApplication::exec();
// Not necessary, but if you don't call it, there will be some small memory leaks.
FramelessHelper::Widgets::uninitialize(); FramelessHelper::Widgets::uninitialize();
return exec; return exec;

View File

@ -69,6 +69,8 @@ Q_SIGNALS:
private: private:
#if (QT_VERSION < QT_VERSION_CHECK(5, 15, 0)) #if (QT_VERSION < QT_VERSION_CHECK(5, 15, 0))
// Due to a Qt bug, we can't initialize the QPointer objects with nullptr.
// The bug was fixed in Qt 5.15.
QPointer<QWidget> m_targetWidget; QPointer<QWidget> m_targetWidget;
QPointer<QScreen> m_screen; QPointer<QScreen> m_screen;
#else #else

View File

@ -46,7 +46,8 @@ Q_LOGGING_CATEGORY(lcFramelessHelperWin, "wangwenx190.framelesshelper.core.impl.
using namespace Global; using namespace Global;
static constexpr const wchar_t kFallbackTitleBarWindowClassName[] = L"org.wangwenx190.FramelessHelper.FallbackTitleBarWindow\0"; [[maybe_unused]] static constexpr const wchar_t kFallbackTitleBarWindowClassName[] =
L"org.wangwenx190.FramelessHelper.FallbackTitleBarWindow\0";
FRAMELESSHELPER_BYTEARRAY_CONSTANT2(Win32MessageTypeName, "windows_generic_MSG") FRAMELESSHELPER_BYTEARRAY_CONSTANT2(Win32MessageTypeName, "windows_generic_MSG")
FRAMELESSHELPER_STRING_CONSTANT(MonitorFromWindow) FRAMELESSHELPER_STRING_CONSTANT(MonitorFromWindow)
FRAMELESSHELPER_STRING_CONSTANT(GetMonitorInfoW) FRAMELESSHELPER_STRING_CONSTANT(GetMonitorInfoW)
@ -74,6 +75,12 @@ FRAMELESSHELPER_STRING_CONSTANT(FindWindowW)
FRAMELESSHELPER_STRING_CONSTANT(UnregisterClassW) FRAMELESSHELPER_STRING_CONSTANT(UnregisterClassW)
FRAMELESSHELPER_BYTEARRAY_CONSTANT2(DontOverrideCursor, "FRAMELESSHELPER_DONT_OVERRIDE_CURSOR") FRAMELESSHELPER_BYTEARRAY_CONSTANT2(DontOverrideCursor, "FRAMELESSHELPER_DONT_OVERRIDE_CURSOR")
FRAMELESSHELPER_STRING_CONSTANT(DestroyWindow) FRAMELESSHELPER_STRING_CONSTANT(DestroyWindow)
[[maybe_unused]] static constexpr const char kFallbackTitleBarErrorMessage[] =
"FramelessHelper is unable to create the fallback title bar window, and thus the snap layout feature will be disabled"
" unconditionally. You can ignore this error and continue running your application, nothing else will be affected, "
"no need to worry. But if you really need the snap layout feature, please add a manifest file to your application and "
"explicitly declare Windows 11 compatibility in it. If you just want to hide this error message, please use the "
"FramelessConfig class to officially disable the snap layout feature for Windows 11.";
struct Win32HelperData struct Win32HelperData
{ {
@ -451,14 +458,10 @@ Q_GLOBAL_STATIC(Win32Helper, g_win32Helper)
const HWND fallbackTitleBarWindowHandle = CreateWindowExW((WS_EX_LAYERED | WS_EX_NOREDIRECTIONBITMAP), const HWND fallbackTitleBarWindowHandle = CreateWindowExW((WS_EX_LAYERED | WS_EX_NOREDIRECTIONBITMAP),
kFallbackTitleBarWindowClassName, nullptr, WS_CHILD, 0, 0, 0, 0, kFallbackTitleBarWindowClassName, nullptr, WS_CHILD, 0, 0, 0, 0,
parentWindowHandle, nullptr, instance, nullptr); parentWindowHandle, nullptr, instance, nullptr);
Q_ASSERT_X(fallbackTitleBarWindowHandle, "createFallbackTitleBarWindow()", Q_ASSERT_X(fallbackTitleBarWindowHandle, "createFallbackTitleBarWindow()", kFallbackTitleBarErrorMessage);
"FramelessHelper is unable to create the fallback title bar window, and thus the snap layout feature will be disabled. "
"You can ignore this error and continue running your application, nothing else will be affected, so no need to worry. "
"But if you need the snap layout feature, please add a manifest file to your application and explicitly declare Windows"
" 11 compatibility in it. If you want to hide this error dialog, please use the FramelessConfig class to disable the "
" snap layout feature for Windows 11.");
if (!fallbackTitleBarWindowHandle) { if (!fallbackTitleBarWindowHandle) {
WARNING << Utils::getSystemErrorMessage(kCreateWindowExW); WARNING << Utils::getSystemErrorMessage(kCreateWindowExW);
WARNING << kFallbackTitleBarErrorMessage;
return false; return false;
} }
// Layered windows won't become visible unless we call the SetLayeredWindowAttributes() // Layered windows won't become visible unless we call the SetLayeredWindowAttributes()