diff --git a/include/FramelessHelper/Core/framelesshelpercore_global.h b/include/FramelessHelper/Core/framelesshelpercore_global.h index be5d7c4..3517690 100644 --- a/include/FramelessHelper/Core/framelesshelpercore_global.h +++ b/include/FramelessHelper/Core/framelesshelpercore_global.h @@ -70,18 +70,26 @@ QT_END_NAMESPACE #if (QT_VERSION < QT_VERSION_CHECK(5, 14, 0)) # define qExchange(a, b) std::exchange(a, b) +#endif + +#ifndef Q_NAMESPACE_EXPORT // Since 5.14 # define Q_NAMESPACE_EXPORT(...) Q_NAMESPACE #endif +// QColor can't be constexpr before 5.14 +#if (QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)) +# define Q_COLOR_CONSTEXPR constexpr +#else +# define Q_COLOR_CONSTEXPR +#endif + // MOC can't handle C++ attributes before 5.15. #if (QT_VERSION >= QT_VERSION_CHECK(5, 15, 0)) # define Q_NODISCARD [[nodiscard]] # define Q_MAYBE_UNUSED [[maybe_unused]] -# define Q_CONSTEXPR2 constexpr // There's a Q_CONSTEXPR from Qt, which behaves differently. #else # define Q_NODISCARD # define Q_MAYBE_UNUSED -# define Q_CONSTEXPR2 #endif #if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)) @@ -96,6 +104,10 @@ QT_END_NAMESPACE # define QUtf8String(str) QString::fromUtf8(str) #endif +#ifndef Q_GADGET_EXPORT // Since 6.3 +# define Q_GADGET_EXPORT(...) Q_GADGET +#endif + #if (QT_VERSION >= QT_VERSION_CHECK(6, 4, 0)) using namespace Qt::Literals::StringLiterals; #endif @@ -214,19 +226,19 @@ Q_NAMESPACE_EXPORT(FRAMELESSHELPER_CORE_API) # define kDefaultTransparentColor QColorConstants::Transparent # define kDefaultDarkGrayColor QColorConstants::DarkGray #else // (QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)) - [[maybe_unused]] inline Q_CONSTEXPR2 const QColor kDefaultBlackColor = {0, 0, 0}; // #000000 - [[maybe_unused]] inline Q_CONSTEXPR2 const QColor kDefaultWhiteColor = {255, 255, 255}; // #FFFFFF - [[maybe_unused]] inline Q_CONSTEXPR2 const QColor kDefaultTransparentColor = {0, 0, 0, 0}; - [[maybe_unused]] inline Q_CONSTEXPR2 const QColor kDefaultDarkGrayColor = {169, 169, 169}; // #A9A9A9 + [[maybe_unused]] inline Q_COLOR_CONSTEXPR const QColor kDefaultBlackColor = {0, 0, 0}; // #000000 + [[maybe_unused]] inline Q_COLOR_CONSTEXPR const QColor kDefaultWhiteColor = {255, 255, 255}; // #FFFFFF + [[maybe_unused]] inline Q_COLOR_CONSTEXPR const QColor kDefaultTransparentColor = {0, 0, 0, 0}; + [[maybe_unused]] inline Q_COLOR_CONSTEXPR const QColor kDefaultDarkGrayColor = {169, 169, 169}; // #A9A9A9 #endif // (QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)) -[[maybe_unused]] inline Q_CONSTEXPR2 const QColor kDefaultSystemLightColor = {240, 240, 240}; // #F0F0F0 -[[maybe_unused]] inline Q_CONSTEXPR2 const QColor kDefaultSystemDarkColor = {32, 32, 32}; // #202020 -[[maybe_unused]] inline Q_CONSTEXPR2 const QColor kDefaultFrameBorderActiveColor = {77, 77, 77}; // #4D4D4D -[[maybe_unused]] inline Q_CONSTEXPR2 const QColor kDefaultFrameBorderInactiveColorDark = {87, 89, 89}; // #575959 -[[maybe_unused]] inline Q_CONSTEXPR2 const QColor kDefaultFrameBorderInactiveColorLight = {166, 166, 166}; // #A6A6A6 -[[maybe_unused]] inline Q_CONSTEXPR2 const QColor kDefaultSystemButtonBackgroundColor = {204, 204, 204}; // #CCCCCC -[[maybe_unused]] inline Q_CONSTEXPR2 const QColor kDefaultSystemCloseButtonBackgroundColor = {232, 17, 35}; // #E81123 +[[maybe_unused]] inline Q_COLOR_CONSTEXPR const QColor kDefaultSystemLightColor = {240, 240, 240}; // #F0F0F0 +[[maybe_unused]] inline Q_COLOR_CONSTEXPR const QColor kDefaultSystemDarkColor = {32, 32, 32}; // #202020 +[[maybe_unused]] inline Q_COLOR_CONSTEXPR const QColor kDefaultFrameBorderActiveColor = {77, 77, 77}; // #4D4D4D +[[maybe_unused]] inline Q_COLOR_CONSTEXPR const QColor kDefaultFrameBorderInactiveColorDark = {87, 89, 89}; // #575959 +[[maybe_unused]] inline Q_COLOR_CONSTEXPR const QColor kDefaultFrameBorderInactiveColorLight = {166, 166, 166}; // #A6A6A6 +[[maybe_unused]] inline Q_COLOR_CONSTEXPR const QColor kDefaultSystemButtonBackgroundColor = {204, 204, 204}; // #CCCCCC +[[maybe_unused]] inline Q_COLOR_CONSTEXPR const QColor kDefaultSystemCloseButtonBackgroundColor = {232, 17, 35}; // #E81123 [[maybe_unused]] inline const QByteArray kDontOverrideCursorVar = FRAMELESSHELPER_BYTEARRAY_LITERAL("FRAMELESSHELPER_DONT_OVERRIDE_CURSOR"); diff --git a/include/FramelessHelper/Core/private/framelessmanager_p.h b/include/FramelessHelper/Core/private/framelessmanager_p.h index c57daf2..593a097 100644 --- a/include/FramelessHelper/Core/private/framelessmanager_p.h +++ b/include/FramelessHelper/Core/private/framelessmanager_p.h @@ -24,10 +24,11 @@ #pragma once -#include +#include FRAMELESSHELPER_BEGIN_NAMESPACE +struct SystemParameters; class FramelessManager; class FRAMELESSHELPER_CORE_API FramelessManagerPrivate : public QObject @@ -51,7 +52,7 @@ public: Q_NODISCARD QString wallpaper() const; Q_NODISCARD Global::WallpaperAspectStyle wallpaperAspectStyle() const; - static void addWindow(FramelessParamsConst params); + static void addWindow(const SystemParameters *params); static void removeWindow(const WId windowId); Q_INVOKABLE void notifySystemThemeHasChangedOrNot(); diff --git a/src/core/micamaterial.cpp b/src/core/micamaterial.cpp index 4e334fb..c2155f8 100644 --- a/src/core/micamaterial.cpp +++ b/src/core/micamaterial.cpp @@ -72,7 +72,7 @@ using namespace Global; [[maybe_unused]] static constexpr const qreal kDefaultNoiseOpacity = 0.04; [[maybe_unused]] static constexpr const qreal kDefaultBlurRadius = 128.0; -[[maybe_unused]] static Q_CONSTEXPR2 const QColor kDefaultSystemLightColor2 = {243, 243, 243}; // #F3F3F3 +[[maybe_unused]] static Q_COLOR_CONSTEXPR const QColor kDefaultSystemLightColor2 = {243, 243, 243}; // #F3F3F3 #ifndef FRAMELESSHELPER_CORE_NO_BUNDLE_RESOURCE FRAMELESSHELPER_STRING_CONSTANT2(NoiseImageFilePath, ":/org.wangwenx190.FramelessHelper/resources/images/noise.png") diff --git a/src/core/utils_mac.mm b/src/core/utils_mac.mm index ae4ba34..bf31354 100644 --- a/src/core/utils_mac.mm +++ b/src/core/utils_mac.mm @@ -591,7 +591,7 @@ Q_GLOBAL_STATIC(MacUtilsData, g_macUtilsData); const auto proxy = new NSWindowProxy(qwindow, nswindow); g_macUtilsData()->hash.insert(windowId, proxy); } - static const auto hook = []() -> int { + volatile static const auto hook = []() -> int { registerUninitializeHook([](){ const QMutexLocker locker(&g_macUtilsData()->mutex); if (g_macUtilsData()->hash.isEmpty()) { @@ -767,7 +767,7 @@ bool Utils::isBlurBehindWindowSupported() void Utils::registerThemeChangeNotification() { - static MacOSThemeObserver observer; + volatile static MacOSThemeObserver observer; Q_UNUSED(observer); }