Minor tweaks

Signed-off-by: Yuhang Zhao <2546789017@qq.com>
This commit is contained in:
Yuhang Zhao 2021-03-11 21:06:56 +08:00
parent bd05c66e23
commit c19a4f7f74
5 changed files with 41 additions and 31 deletions

View File

@ -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;
}

View File

@ -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);

View File

@ -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);
}

View File

@ -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();

View File

@ -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;