diff --git a/examples/dialog/dialog.cpp b/examples/dialog/dialog.cpp index d0b82e4..eebda61 100644 --- a/examples/dialog/dialog.cpp +++ b/examples/dialog/dialog.cpp @@ -99,5 +99,7 @@ void Dialog::setupUi() helper->setSystemButton(titleBar->minimizeButton(), SystemButtonType::Minimize); helper->setSystemButton(titleBar->maximizeButton(), SystemButtonType::Maximize); 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); } diff --git a/examples/dialog/main.cpp b/examples/dialog/main.cpp index a4e8609..500b2d3 100644 --- a/examples/dialog/main.cpp +++ b/examples/dialog/main.cpp @@ -52,6 +52,7 @@ int main(int argc, char *argv[]) const int exec = QCoreApplication::exec(); + // Not necessary, but if you don't call it, there will be some small memory leaks. FramelessHelper::Widgets::uninitialize(); return exec; diff --git a/examples/mainwindow/main.cpp b/examples/mainwindow/main.cpp index 727ff5b..d33b461 100644 --- a/examples/mainwindow/main.cpp +++ b/examples/mainwindow/main.cpp @@ -52,6 +52,7 @@ int main(int argc, char *argv[]) const int exec = QCoreApplication::exec(); + // Not necessary, but if you don't call it, there will be some small memory leaks. FramelessHelper::Widgets::uninitialize(); return exec; diff --git a/examples/openglwidget/main.cpp b/examples/openglwidget/main.cpp index a5b66f4..90adc46 100644 --- a/examples/openglwidget/main.cpp +++ b/examples/openglwidget/main.cpp @@ -104,6 +104,7 @@ int main(int argc, char *argv[]) const int exec = QCoreApplication::exec(); + // Not necessary, but if you don't call it, there will be some small memory leaks. FramelessHelper::Widgets::uninitialize(); return exec; diff --git a/examples/widget/main.cpp b/examples/widget/main.cpp index b1059ec..4dd4f3d 100644 --- a/examples/widget/main.cpp +++ b/examples/widget/main.cpp @@ -52,6 +52,7 @@ int main(int argc, char *argv[]) const int exec = QCoreApplication::exec(); + // Not necessary, but if you don't call it, there will be some small memory leaks. FramelessHelper::Widgets::uninitialize(); return exec; diff --git a/include/FramelessHelper/Widgets/private/widgetssharedhelper_p.h b/include/FramelessHelper/Widgets/private/widgetssharedhelper_p.h index 99360fb..a458caa 100644 --- a/include/FramelessHelper/Widgets/private/widgetssharedhelper_p.h +++ b/include/FramelessHelper/Widgets/private/widgetssharedhelper_p.h @@ -69,6 +69,8 @@ Q_SIGNALS: private: #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 m_targetWidget; QPointer m_screen; #else diff --git a/src/core/framelesshelper_win.cpp b/src/core/framelesshelper_win.cpp index c308db0..12a908b 100644 --- a/src/core/framelesshelper_win.cpp +++ b/src/core/framelesshelper_win.cpp @@ -46,7 +46,8 @@ Q_LOGGING_CATEGORY(lcFramelessHelperWin, "wangwenx190.framelesshelper.core.impl. 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_STRING_CONSTANT(MonitorFromWindow) FRAMELESSHELPER_STRING_CONSTANT(GetMonitorInfoW) @@ -74,6 +75,12 @@ FRAMELESSHELPER_STRING_CONSTANT(FindWindowW) FRAMELESSHELPER_STRING_CONSTANT(UnregisterClassW) FRAMELESSHELPER_BYTEARRAY_CONSTANT2(DontOverrideCursor, "FRAMELESSHELPER_DONT_OVERRIDE_CURSOR") 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 { @@ -451,14 +458,10 @@ Q_GLOBAL_STATIC(Win32Helper, g_win32Helper) const HWND fallbackTitleBarWindowHandle = CreateWindowExW((WS_EX_LAYERED | WS_EX_NOREDIRECTIONBITMAP), kFallbackTitleBarWindowClassName, nullptr, WS_CHILD, 0, 0, 0, 0, parentWindowHandle, nullptr, instance, nullptr); - Q_ASSERT_X(fallbackTitleBarWindowHandle, "createFallbackTitleBarWindow()", - "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."); + Q_ASSERT_X(fallbackTitleBarWindowHandle, "createFallbackTitleBarWindow()", kFallbackTitleBarErrorMessage); if (!fallbackTitleBarWindowHandle) { WARNING << Utils::getSystemErrorMessage(kCreateWindowExW); + WARNING << kFallbackTitleBarErrorMessage; return false; } // Layered windows won't become visible unless we call the SetLayeredWindowAttributes()