diff --git a/framelesshelper_win32.cpp b/framelesshelper_win32.cpp index e58e9ef..6e18ed4 100644 --- a/framelesshelper_win32.cpp +++ b/framelesshelper_win32.cpp @@ -74,14 +74,9 @@ #define GET_Y_LPARAM(lp) ((int) (short) HIWORD(lp)) #endif -static inline bool shouldUseNativeTitleBar() -{ - return qEnvironmentVariableIsSet(_flh_global::_flh_useNativeTitleBar_flag); -} - static inline bool shouldHaveWindowFrame() { - if (shouldUseNativeTitleBar()) { + if (Utilities::shouldUseNativeTitleBar()) { // We have to use the original window frame unconditionally if we // want to use the native title bar. return true; @@ -286,7 +281,7 @@ bool FramelessHelperWin::nativeEventFilter(const QByteArray &eventType, void *me // preserve the four window borders. So we just remove the whole // window frame, otherwise the code will become much more complex. - if (shouldUseNativeTitleBar()) { + if (Utilities::shouldUseNativeTitleBar()) { break; } @@ -543,7 +538,7 @@ bool FramelessHelperWin::nativeEventFilter(const QByteArray &eventType, void *me // another branch, if you are interested in it, you can give it a // try. - if (shouldUseNativeTitleBar()) { + if (Utilities::shouldUseNativeTitleBar()) { break; } @@ -690,7 +685,7 @@ bool FramelessHelperWin::nativeEventFilter(const QByteArray &eventType, void *me } case WM_SETICON: case WM_SETTEXT: { - if (shouldUseNativeTitleBar()) { + if (Utilities::shouldUseNativeTitleBar()) { break; } diff --git a/qtacryliceffecthelper.cpp b/qtacryliceffecthelper.cpp index 50acc9b..3da4e6d 100644 --- a/qtacryliceffecthelper.cpp +++ b/qtacryliceffecthelper.cpp @@ -173,6 +173,11 @@ void QtAcrylicEffectHelper::paintWindowBackground(QPainter *painter, const QRegi if (!painter || clip.isEmpty()) { return; } + // TODO: should we limit it to Win32 only? Or should we do something about the + // acrylic brush instead? + if (Utilities::disableExtraProcessingForBlur()) { + return; + } if (!checkWindow()) { return; } @@ -188,6 +193,11 @@ void QtAcrylicEffectHelper::paintWindowBackground(QPainter *painter, const QRect if (!painter || !rect.isValid()) { return; } + // TODO: should we limit it to Win32 only? Or should we do something about the + // acrylic brush instead? + if (Utilities::disableExtraProcessingForBlur()) { + return; + } if (!checkWindow()) { return; } @@ -206,11 +216,6 @@ void QtAcrylicEffectHelper::paintBackground(QPainter *painter, const QRect &rect if (!checkWindow()) { return; } - // TODO: should we limit it to Win32 only? Or should we do something about the - // acrylic brush instead? - if (qEnvironmentVariableIsSet(_flh_global::_flh_acrylic_disableExtraProcess)) { - return; - } if (Utilities::shouldUseTraditionalBlur()) { const QPainter::CompositionMode mode = painter->compositionMode(); painter->setCompositionMode(QPainter::CompositionMode_Clear); diff --git a/utilities.cpp b/utilities.cpp index 9b2d8e7..e8405db 100644 --- a/utilities.cpp +++ b/utilities.cpp @@ -382,3 +382,23 @@ bool Utilities::shouldUseWallpaperBlur() { return !shouldUseTraditionalBlur(); } + +bool Utilities::disableExtraProcessingForBlur() +{ + return qEnvironmentVariableIsSet(_flh_global::_flh_acrylic_disableExtraProcess); +} + +bool Utilities::forceEnableTraditionalBlur() +{ + return qEnvironmentVariableIsSet(_flh_global::_flh_acrylic_forceEnableTraditionalBlur_flag); +} + +bool Utilities::forceDisableWallpaperBlur() +{ + return qEnvironmentVariableIsSet(_flh_global::_flh_acrylic_forceDisableWallpaperBlur_flag); +} + +bool Utilities::shouldUseNativeTitleBar() +{ + return qEnvironmentVariableIsSet(_flh_global::_flh_useNativeTitleBar_flag); +} diff --git a/utilities.h b/utilities.h index 31ab7d4..db3e86b 100644 --- a/utilities.h +++ b/utilities.h @@ -68,6 +68,11 @@ FRAMELESSHELPER_EXPORT QRect alignedRect(const Qt::LayoutDirection direction, co FRAMELESSHELPER_EXPORT void blurImage(QImage &blurImage, const qreal radius, const bool quality, const int transposed = 0); FRAMELESSHELPER_EXPORT void blurImage(QPainter *painter, QImage &blurImage, const qreal radius, const bool quality, const bool alphaOnly, const int transposed = 0); +FRAMELESSHELPER_EXPORT bool disableExtraProcessingForBlur(); +FRAMELESSHELPER_EXPORT bool forceEnableTraditionalBlur(); +FRAMELESSHELPER_EXPORT bool forceDisableWallpaperBlur(); +FRAMELESSHELPER_EXPORT bool shouldUseNativeTitleBar(); + #ifdef Q_OS_WINDOWS // Windows specific FRAMELESSHELPER_EXPORT bool isWin7OrGreater(); diff --git a/utilities_win32.cpp b/utilities_win32.cpp index dc50bec..abb9e52 100644 --- a/utilities_win32.cpp +++ b/utilities_win32.cpp @@ -662,21 +662,6 @@ bool Utilities::isWin10OrGreater(const int subVer) #endif } -static inline bool disableExtraProcessingForBlur() -{ - return qEnvironmentVariableIsSet(_flh_global::_flh_acrylic_disableExtraProcess); -} - -static inline bool forceEnableDwmBlur() -{ - return qEnvironmentVariableIsSet(_flh_global::_flh_acrylic_forceEnableTraditionalBlur_flag); -} - -static inline bool forceDisableWallpaperBlur() -{ - return qEnvironmentVariableIsSet(_flh_global::_flh_acrylic_forceDisableWallpaperBlur_flag); -} - static inline bool forceEnableOfficialMSWin10AcrylicBlur() { return qEnvironmentVariableIsSet(_flh_global::_flh_acrylic_forceEnableOfficialMSWin10AcrylicBlur_flag); @@ -701,7 +686,7 @@ bool Utilities::isOfficialMSWin10AcrylicBlurAvailable() if (!isWin10OrGreater()) { return false; } - if (!forceEnableDwmBlur() && !forceDisableWallpaperBlur() && !disableExtraProcessingForBlur()) { + if (!forceEnableTraditionalBlur() && !forceDisableWallpaperBlur() && !disableExtraProcessingForBlur()) { // We can't enable the official Acrylic blur in wallpaper blur mode. return false; } @@ -723,7 +708,7 @@ static inline bool shouldUseOriginalDwmBlur() bool Utilities::shouldUseTraditionalBlur() { - if ((forceEnableDwmBlur() || forceDisableWallpaperBlur() || disableExtraProcessingForBlur()) && shouldUseOriginalDwmBlur()) { + if ((forceEnableTraditionalBlur() || forceDisableWallpaperBlur() || disableExtraProcessingForBlur()) && shouldUseOriginalDwmBlur()) { return true; } return false;