diff --git a/examples/QMainWindow/TitleBar.ui b/examples/QMainWindow/TitleBar.ui
index 848b732..a763cec 100644
--- a/examples/QMainWindow/TitleBar.ui
+++ b/examples/QMainWindow/TitleBar.ui
@@ -146,7 +146,7 @@
Minimize
-
+
:/images/button_minimize_black.svg:/images/button_minimize_black.svg
@@ -187,7 +187,7 @@
Maximize
-
+
:/images/button_maximize_black.svg
:/images/button_restore_black.svg:/images/button_maximize_black.svg
@@ -232,7 +232,7 @@
Close
-
+
:/images/button_close_black.svg:/images/button_close_black.svg
@@ -247,7 +247,7 @@
-
+
diff --git a/examples/Quick/Quick.pro b/examples/Quick/Quick.pro
index 4371988..02cb2df 100644
--- a/examples/Quick/Quick.pro
+++ b/examples/Quick/Quick.pro
@@ -3,4 +3,5 @@ TEMPLATE = app
QT += quick
HEADERS += $$PWD/../../framelessquickhelper.h
SOURCES += $$PWD/../../framelessquickhelper.cpp main.cpp
+RESOURCES += qml.qrc
include($$PWD/../common.pri)
diff --git a/examples/Quick/qml.qrc b/examples/Quick/qml.qrc
new file mode 100644
index 0000000..d379b89
--- /dev/null
+++ b/examples/Quick/qml.qrc
@@ -0,0 +1,8 @@
+
+
+ qml/main.qml
+ qml/MinimizeButton.qml
+ qml/MaximizeButton.qml
+ qml/CloseButton.qml
+
+
diff --git a/examples/resources/qml/CloseButton.qml b/examples/Quick/qml/CloseButton.qml
similarity index 100%
rename from examples/resources/qml/CloseButton.qml
rename to examples/Quick/qml/CloseButton.qml
diff --git a/examples/resources/qml/MaximizeButton.qml b/examples/Quick/qml/MaximizeButton.qml
similarity index 100%
rename from examples/resources/qml/MaximizeButton.qml
rename to examples/Quick/qml/MaximizeButton.qml
diff --git a/examples/resources/qml/MinimizeButton.qml b/examples/Quick/qml/MinimizeButton.qml
similarity index 100%
rename from examples/resources/qml/MinimizeButton.qml
rename to examples/Quick/qml/MinimizeButton.qml
diff --git a/examples/resources/qml/main.qml b/examples/Quick/qml/main.qml
similarity index 100%
rename from examples/resources/qml/main.qml
rename to examples/Quick/qml/main.qml
diff --git a/examples/Win32Demo/Win32Demo.pro b/examples/Win32Demo/Win32Demo.pro
index 3e89606..e18c602 100644
--- a/examples/Win32Demo/Win32Demo.pro
+++ b/examples/Win32Demo/Win32Demo.pro
@@ -1,7 +1,7 @@
TARGET = Win32Demo
TEMPLATE = app
QT += widgets
-LIBS += -luser32
+LIBS += -luser32 -ldwmapi
HEADERS += widget.h
SOURCES += widget.cpp main.cpp
FORMS += widget.ui
diff --git a/examples/Win32Demo/main.cpp b/examples/Win32Demo/main.cpp
index dea2b99..0c82980 100644
--- a/examples/Win32Demo/main.cpp
+++ b/examples/Win32Demo/main.cpp
@@ -24,6 +24,7 @@
#include "widget.h"
#include
+#include
int main(int argc, char *argv[])
{
@@ -54,6 +55,12 @@ int main(int argc, char *argv[])
QApplication::setFont({QLatin1String("Microsoft YaHei")});
Widget widget;
+
+ QStyleOption option;
+ option.initFrom(&widget);
+ widget.setWindowIcon(widget.style()->standardIcon(QStyle::SP_ComputerIcon, &option));
+ widget.setWindowTitle(QObject::tr("Hello, World!"));
+
widget.show();
return QApplication::exec();
diff --git a/examples/Win32Demo/widget.cpp b/examples/Win32Demo/widget.cpp
index f804e19..748dea2 100644
--- a/examples/Win32Demo/widget.cpp
+++ b/examples/Win32Demo/widget.cpp
@@ -25,9 +25,11 @@
#include "widget.h"
#include "../../winnativeeventfilter.h"
#include "ui_widget.h"
+#include
#include
#include
-#include
+#include
+#include
#include
// Copied from windowsx.h
@@ -40,6 +42,33 @@ const char useNativeTitleBar[] = "WNEF_USE_NATIVE_TITLE_BAR";
const char preserveWindowFrame[] = "WNEF_FORCE_PRESERVE_WINDOW_FRAME";
const char forceUseAcrylicEffect[] = "WNEF_FORCE_ACRYLIC_ON_WIN10";
+const QLatin1String systemButtonsStyleSheet(R"(
+#iconButton, #minimizeButton, #maximizeButton, #closeButton {
+ background-color: transparent;
+ border-radius: 0px;
+}
+
+#minimizeButton:hover, #maximizeButton:hover {
+ border-style: none;
+ background-color: #80c7c7c7;
+}
+
+#minimizeButton:pressed, #maximizeButton:pressed {
+ border-style: none;
+ background-color: #80808080;
+}
+
+#closeButton:hover {
+ border-style: none;
+ background-color: #e81123;
+}
+
+#closeButton:pressed {
+ border-style: none;
+ background-color: #8c0a15;
+}
+)");
+
void *getRawHandle(QWidget *widget)
{
Q_ASSERT(widget);
@@ -51,25 +80,77 @@ void updateWindow(QWidget *widget)
Q_ASSERT(widget);
if (widget->isTopLevel()) {
void *handle = getRawHandle(widget);
- WinNativeEventFilter::updateFrameMargins(handle);
+ //WinNativeEventFilter::updateFrameMargins(handle);
WinNativeEventFilter::updateWindow(handle, true, true);
+ widget->update();
}
}
+bool isWin10OrGreater()
+{
+ return QOperatingSystemVersion::current() >= QOperatingSystemVersion::Windows10;
+}
+
bool isGreaterThanWin10_1803()
{
return QOperatingSystemVersion::current()
>= QOperatingSystemVersion(QOperatingSystemVersion::Windows, 10, 0, 17134);
}
+bool isThemeColorEnabled()
+{
+ if (!isWin10OrGreater()) {
+ return false;
+ }
+ bool ok = false;
+ const QSettings registry(QLatin1String(R"(HKEY_CURRENT_USER\Software\Microsoft\Windows\DWM)"),
+ QSettings::NativeFormat);
+ const bool colorPrevalence = registry.value(QLatin1String("ColorPrevalence"), 0).toULongLong(&ok)
+ != 0;
+ return (ok && colorPrevalence);
+}
+
+bool isDarkModeEnabled()
+{
+ if (!isWin10OrGreater()) {
+ return false;
+ }
+ bool ok = false;
+ const QSettings registry(
+ QLatin1String(
+ R"(HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Themes\Personalize)"),
+ QSettings::NativeFormat);
+ const bool appsUseLightTheme
+ = registry.value(QLatin1String("AppsUseLightTheme"), 0).toULongLong(&ok) != 0;
+ return (ok && !appsUseLightTheme);
+}
+
+QColor getThemeColor()
+{
+ DWORD color = 0;
+ BOOL opaqueBlend = FALSE;
+ return SUCCEEDED(DwmGetColorizationColor(&color, &opaqueBlend)) ? QColor::fromRgba(color)
+ : Qt::white;
+}
+
} // namespace
Widget::Widget(QWidget *parent) : QWidget(parent), ui(new Ui::Widget)
{
+ m_bIsWin10OrGreater = isWin10OrGreater();
+
+ m_cThemeColor = getThemeColor();
+
ui->setupUi(this);
ui->forceAcrylicCB->setEnabled(isGreaterThanWin10_1803());
+ if (shouldDrawBorder()) {
+ layout()->setContentsMargins(1, 1, 1, 1);
+ }
+
+ updateTitleBar();
+
connect(ui->iconButton, &QPushButton::clicked, this, [this]() {
POINT pos = {};
GetCursorPos(&pos);
@@ -96,7 +177,7 @@ Widget::Widget(QWidget *parent) : QWidget(parent), ui(new Ui::Widget)
connect(ui->customizeTitleBarCB, &QCheckBox::stateChanged, this, [this](int state) {
const bool enable = state == Qt::Checked;
- ui->windowFrameCB->setEnabled(enable);
+ ui->removeWindowFrameCB->setEnabled(enable);
WinNativeEventFilter::updateQtFrame(windowHandle(),
enable ? WinNativeEventFilter::getSystemMetric(
getRawHandle(this),
@@ -110,12 +191,18 @@ Widget::Widget(QWidget *parent) : QWidget(parent), ui(new Ui::Widget)
}
updateWindow(this);
});
- connect(ui->windowFrameCB, &QCheckBox::stateChanged, this, [this](int state) {
- if (state == Qt::Checked) {
+ connect(ui->removeWindowFrameCB, &QCheckBox::stateChanged, this, [this](int state) {
+ const bool enable = state == Qt::Checked;
+ if (enable) {
qunsetenv(preserveWindowFrame);
} else {
qputenv(preserveWindowFrame, "1");
}
+ if (enable && shouldDrawBorder()) {
+ layout()->setContentsMargins(1, 1, 1, 1);
+ } else {
+ layout()->setContentsMargins(0, 0, 0, 0);
+ }
updateWindow(this);
});
connect(ui->blurEffectCB, &QCheckBox::stateChanged, this, [this](int state) {
@@ -132,6 +219,10 @@ Widget::Widget(QWidget *parent) : QWidget(parent), ui(new Ui::Widget)
WinNativeEventFilter::setBlurEffectEnabled(getRawHandle(this), enable, color);
updateWindow(this);
});
+ connect(ui->extendToTitleBarCB, &QCheckBox::stateChanged, this, [this](int state) {
+ m_bExtendToTitleBar = state == Qt::Checked;
+ updateTitleBar();
+ });
connect(ui->forceAcrylicCB, &QCheckBox::stateChanged, this, [this](int state) {
if (state == Qt::Checked) {
qputenv(forceUseAcrylicEffect, "1");
@@ -149,11 +240,6 @@ Widget::Widget(QWidget *parent) : QWidget(parent), ui(new Ui::Widget)
WinNativeEventFilter::setWindowResizable(getRawHandle(this), enable);
});
- QStyleOption option;
- option.initFrom(this);
- setWindowIcon(style()->standardIcon(QStyle::SP_ComputerIcon, &option));
- setWindowTitle(tr("Hello, World!"));
-
WinNativeEventFilter::WINDOWDATA data = {};
data.ignoreObjects << ui->iconButton << ui->minimizeButton << ui->maximizeButton
<< ui->closeButton;
@@ -167,22 +253,66 @@ Widget::~Widget()
delete ui;
}
+bool Widget::isNormaled() const
+{
+ return !isMinimized() && !isMaximized() && !isFullScreen();
+}
+
+bool Widget::shouldDrawBorder(const bool ignoreWindowState) const
+{
+ return m_bIsWin10OrGreater && (ignoreWindowState ? true : isNormaled())
+ && ui->removeWindowFrameCB->isChecked() && ui->customizeTitleBarCB->isChecked();
+}
+
+bool Widget::shouldDrawThemedBorder(const bool ignoreWindowState) const
+{
+ return (shouldDrawBorder(ignoreWindowState) && isThemeColorEnabled());
+}
+
+QColor Widget::activeBorderColor() const
+{
+ return isThemeColorEnabled() ? m_cThemeColor
+ : (isDarkModeEnabled() ? m_cDefaultActiveBorderColor : Qt::white);
+}
+
+QColor Widget::inactiveBorderColor() const
+{
+ return m_cDefaultInactiveBorderColor;
+}
+
+QColor Widget::borderColor() const
+{
+ return isActiveWindow() ? activeBorderColor() : inactiveBorderColor();
+}
+
bool Widget::eventFilter(QObject *object, QEvent *event)
{
Q_ASSERT(object);
Q_ASSERT(event);
switch (event->type()) {
case QEvent::WindowStateChange: {
- if (isMaximized()) {
- ui->maximizeButton->setIcon(QIcon(QLatin1String(":/images/button_restore_black.svg")));
- } else if (!isFullScreen() && !isMinimized()) {
- ui->maximizeButton->setIcon(QIcon(QLatin1String(":/images/button_maximize_black.svg")));
+ if (shouldDrawBorder(true)) {
+ if (isMaximized()) {
+ layout()->setContentsMargins(0, 0, 0, 0);
+ }
+ if (isNormaled()) {
+ layout()->setContentsMargins(1, 1, 1, 1);
+ }
}
- ui->moveCenterButton->setEnabled(!isMaximized() && !isFullScreen());
- } break;
+ updateTitleBar();
+ ui->moveCenterButton->setEnabled(isNormaled());
+ break;
+ }
case QEvent::WinIdChange:
WinNativeEventFilter::addFramelessWindow(this);
break;
+ case QEvent::WindowActivate:
+ case QEvent::WindowDeactivate: {
+ if (shouldDrawThemedBorder(true)) {
+ updateTitleBar();
+ }
+ break;
+ }
default:
break;
}
@@ -212,9 +342,67 @@ bool Widget::nativeEvent(const QByteArray &eventType, void *message, long *resul
}
break;
}
+ case WM_DWMCOLORIZATIONCOLORCHANGED: {
+ m_cThemeColor = QColor::fromRgba(msg->wParam);
+ if (shouldDrawThemedBorder()) {
+ update();
+ }
+ break;
+ }
default:
break;
}
}
return QWidget::nativeEvent(eventType, message, result);
}
+
+void Widget::paintEvent(QPaintEvent *event)
+{
+ QWidget::paintEvent(event);
+ if (shouldDrawBorder()) {
+ QPainter painter(this);
+ painter.save();
+ painter.setPen(borderColor());
+ painter.drawLine(0, 0, width(), 0);
+ painter.drawLine(0, height(), width(), height());
+ painter.drawLine(0, 0, 0, height());
+ painter.drawLine(width(), 0, width(), height());
+ painter.restore();
+ }
+}
+
+void Widget::updateTitleBar()
+{
+ const bool themedTitleBar = shouldDrawThemedBorder(true) && isActiveWindow();
+ if (themedTitleBar && !m_bExtendToTitleBar) {
+ ui->minimizeButton->setIcon(QIcon(QLatin1String(":/images/button_minimize_white.svg")));
+ ui->closeButton->setIcon(QIcon(QLatin1String(":/images/button_close_white.svg")));
+ if (isMaximized()) {
+ ui->maximizeButton->setIcon(QIcon(QLatin1String(":/images/button_restore_white.svg")));
+ }
+ if (isNormaled()) {
+ ui->maximizeButton->setIcon(QIcon(QLatin1String(":/images/button_maximize_white.svg")));
+ }
+ } else {
+ ui->minimizeButton->setIcon(QIcon(QLatin1String(":/images/button_minimize_black.svg")));
+ ui->closeButton->setIcon(QIcon(QLatin1String(":/images/button_close_black.svg")));
+ if (isMaximized()) {
+ ui->maximizeButton->setIcon(QIcon(QLatin1String(":/images/button_restore_black.svg")));
+ }
+ if (isNormaled()) {
+ ui->maximizeButton->setIcon(QIcon(QLatin1String(":/images/button_maximize_black.svg")));
+ }
+ }
+ const QColor color = m_bExtendToTitleBar ? Qt::transparent
+ : (themedTitleBar ? m_cThemeColor : Qt::white);
+ ui->titleBarWidget->setStyleSheet(systemButtonsStyleSheet
+ + QLatin1String(R"(
+#titleBarWidget {
+ background-color: rgba(%1, %2, %3, %4);
+}
+)")
+ .arg(QString::number(color.red()),
+ QString::number(color.green()),
+ QString::number(color.blue()),
+ QString::number(color.alpha())));
+}
diff --git a/examples/Win32Demo/widget.h b/examples/Win32Demo/widget.h
index b38f8a2..53f21b0 100644
--- a/examples/Win32Demo/widget.h
+++ b/examples/Win32Demo/widget.h
@@ -39,7 +39,16 @@ class Widget : public QWidget
public:
explicit Widget(QWidget *parent = nullptr);
- ~Widget();
+ ~Widget() override;
+
+ bool isNormaled() const;
+
+ bool shouldDrawBorder(const bool ignoreWindowState = false) const;
+ bool shouldDrawThemedBorder(const bool ignoreWindowState = false) const;
+
+ QColor activeBorderColor() const;
+ QColor inactiveBorderColor() const;
+ QColor borderColor() const;
protected:
bool eventFilter(QObject *object, QEvent *event) override;
@@ -48,7 +57,15 @@ protected:
#else
bool nativeEvent(const QByteArray &eventType, void *message, long *result) override;
#endif
+ void paintEvent(QPaintEvent *event) override;
+
+private:
+ void updateTitleBar();
private:
Ui::Widget *ui = nullptr;
+ bool m_bIsWin10OrGreater = false, m_bExtendToTitleBar = false;
+ const QColor m_cDefaultActiveBorderColor = /*{"707070"}*/ Qt::darkGray;
+ const QColor m_cDefaultInactiveBorderColor = /*{"aaaaaa"}*/ Qt::gray;
+ QColor m_cThemeColor = Qt::white;
};
diff --git a/examples/Win32Demo/widget.ui b/examples/Win32Demo/widget.ui
index d901e2d..9bb08b4 100644
--- a/examples/Win32Demo/widget.ui
+++ b/examples/Win32Demo/widget.ui
@@ -13,49 +13,7 @@
Widget
-
- #titleBarWidget {
- background-color: rgb(255, 255, 255);
-}
-
-#iconButton, #minimizeButton, #maximizeButton, #closeButton {
- background-color: transparent;
- border-radius: 0px;
-}
-
-#minimizeButton:hover, #maximizeButton:hover {
- border-style: none;
- background-color: #80c7c7c7;
-}
-
-#minimizeButton:pressed, #maximizeButton:pressed {
- border-style: none;
- background-color: #80808080;
-}
-
-#closeButton:hover {
- border-style: none;
- background-color: #e81123;
-}
-
-#closeButton:pressed {
- border-style: none;
- background-color: #8c0a15;
-}
-
-
- 0
-
-
- 0
-
-
- 0
-
-
- 0
-
-
@@ -161,7 +119,7 @@
-
+
:/images/button_minimize_black.svg:/images/button_minimize_black.svg
@@ -196,7 +154,7 @@
-
+
:/images/button_maximize_black.svg:/images/button_maximize_black.svg
@@ -231,7 +189,7 @@
-
+
:/images/button_close_black.svg:/images/button_close_black.svg
@@ -309,7 +267,7 @@
-
-
+
15
@@ -318,7 +276,7 @@
- Get rid of window frame
+ Remove window frame
true
@@ -339,6 +297,20 @@
+ -
+
+
+
+ 15
+ 75
+ true
+
+
+
+ Extend to title bar
+
+
+
-
@@ -451,7 +423,7 @@
-
+
diff --git a/examples/common.pri b/examples/common.pri
index 4b9cb29..f6ef0c4 100644
--- a/examples/common.pri
+++ b/examples/common.pri
@@ -4,7 +4,7 @@ DEFINES += \
QT_NO_CAST_FROM_ASCII \
QT_NO_CAST_TO_ASCII \
FRAMELESSHELPER_STATIC
-RESOURCES += $$PWD/resources.qrc
+RESOURCES += $$PWD/images.qrc
HEADERS += \
$$PWD/../framelesshelper_global.h \
$$PWD/../framelesswindowsmanager.h
diff --git a/examples/images.qrc b/examples/images.qrc
new file mode 100644
index 0000000..7d61a10
--- /dev/null
+++ b/examples/images.qrc
@@ -0,0 +1,12 @@
+
+
+ images/button_minimize_black.svg
+ images/button_minimize_white.svg
+ images/button_maximize_black.svg
+ images/button_maximize_white.svg
+ images/button_restore_black.svg
+ images/button_restore_white.svg
+ images/button_close_black.svg
+ images/button_close_white.svg
+
+
diff --git a/examples/resources/images/README.txt b/examples/images/README.txt
similarity index 100%
rename from examples/resources/images/README.txt
rename to examples/images/README.txt
diff --git a/examples/resources/images/button_close_black.svg b/examples/images/button_close_black.svg
similarity index 100%
rename from examples/resources/images/button_close_black.svg
rename to examples/images/button_close_black.svg
diff --git a/examples/resources/images/button_close_white.svg b/examples/images/button_close_white.svg
similarity index 100%
rename from examples/resources/images/button_close_white.svg
rename to examples/images/button_close_white.svg
diff --git a/examples/resources/images/button_maximize_black.svg b/examples/images/button_maximize_black.svg
similarity index 100%
rename from examples/resources/images/button_maximize_black.svg
rename to examples/images/button_maximize_black.svg
diff --git a/examples/resources/images/button_maximize_white.svg b/examples/images/button_maximize_white.svg
similarity index 100%
rename from examples/resources/images/button_maximize_white.svg
rename to examples/images/button_maximize_white.svg
diff --git a/examples/resources/images/button_minimize_black.svg b/examples/images/button_minimize_black.svg
similarity index 100%
rename from examples/resources/images/button_minimize_black.svg
rename to examples/images/button_minimize_black.svg
diff --git a/examples/resources/images/button_minimize_white.svg b/examples/images/button_minimize_white.svg
similarity index 100%
rename from examples/resources/images/button_minimize_white.svg
rename to examples/images/button_minimize_white.svg
diff --git a/examples/resources/images/button_restore_black.svg b/examples/images/button_restore_black.svg
similarity index 100%
rename from examples/resources/images/button_restore_black.svg
rename to examples/images/button_restore_black.svg
diff --git a/examples/resources/images/button_restore_white.svg b/examples/images/button_restore_white.svg
similarity index 100%
rename from examples/resources/images/button_restore_white.svg
rename to examples/images/button_restore_white.svg
diff --git a/examples/resources.qrc b/examples/resources.qrc
deleted file mode 100644
index c8da852..0000000
--- a/examples/resources.qrc
+++ /dev/null
@@ -1,18 +0,0 @@
-
-
- resources/qml/main.qml
- resources/qml/MinimizeButton.qml
- resources/qml/MaximizeButton.qml
- resources/qml/CloseButton.qml
-
-
- resources/images/button_minimize_black.svg
- resources/images/button_minimize_white.svg
- resources/images/button_maximize_black.svg
- resources/images/button_maximize_white.svg
- resources/images/button_restore_black.svg
- resources/images/button_restore_white.svg
- resources/images/button_close_black.svg
- resources/images/button_close_white.svg
-
-
diff --git a/winnativeeventfilter.cpp b/winnativeeventfilter.cpp
index 10a7370..9c0fdc4 100644
--- a/winnativeeventfilter.cpp
+++ b/winnativeeventfilter.cpp
@@ -658,9 +658,14 @@ const UINT m_defaultDotsPerInch = USER_DEFAULT_SCREEN_DPI;
const qreal m_defaultDevicePixelRatio = 1.0;
+const char envVarUseNativeTitleBar[] = "WNEF_USE_NATIVE_TITLE_BAR";
+const char envVarPreserveWindowFrame[] = "WNEF_PRESERVE_WINDOW_FRAME";
+const char envVarForceWindowFrame[] = "WNEF_FORCE_PRESERVE_WINDOW_FRAME";
+const char envVarForceAcrylic[] = "WNEF_FORCE_ACRYLIC_ON_WIN10";
+
bool shouldUseNativeTitleBar()
{
- return qEnvironmentVariableIsSet("WNEF_USE_NATIVE_TITLE_BAR");
+ return qEnvironmentVariableIsSet(envVarUseNativeTitleBar);
}
bool shouldHaveWindowFrame()
@@ -670,8 +675,8 @@ bool shouldHaveWindowFrame()
// want to use the native title bar.
return true;
}
- const bool should = qEnvironmentVariableIsSet("WNEF_PRESERVE_WINDOW_FRAME");
- const bool force = qEnvironmentVariableIsSet("WNEF_FORCE_PRESERVE_WINDOW_FRAME");
+ const bool should = qEnvironmentVariableIsSet(envVarPreserveWindowFrame);
+ const bool force = qEnvironmentVariableIsSet(envVarForceWindowFrame);
if (should || force) {
if (force) {
return true;
@@ -689,6 +694,11 @@ bool shouldHaveWindowFrame()
return false;
}
+bool forceEnableAcrylicOnWin10()
+{
+ return qEnvironmentVariableIsSet(envVarForceAcrylic);
+}
+
BOOL IsDwmCompositionEnabled()
{
// Since Win8, DWM composition is always enabled and can't be disabled.
@@ -987,8 +997,8 @@ void UpdateFrameMarginsForWindow(const HWND handle)
margins.cyTopHeight = GetFrameSizeForWindow(handle, TRUE).top;
}
} else {
- //margins.cyTopHeight = 1;
- margins.cyTopHeight = GetFrameSizeForWindow(handle, TRUE).top;
+ margins.cyTopHeight = 1;
+ //margins.cyTopHeight = GetFrameSizeForWindow(handle, TRUE).top;
}
if (shouldUseNativeTitleBar()) {
// If we are going to use the native title bar,
@@ -1612,7 +1622,7 @@ bool WinNativeEventFilter::nativeEventFilter(const QByteArray &eventType,
// Fix the flickering problem when resizing.
// Don't modify the left, right or bottom edge because
// a border line will be seen (at least on Win10).
- clientRect->top -= 1;
+ //clientRect->top -= 1;
}
return true;
}
@@ -2386,18 +2396,23 @@ bool WinNativeEventFilter::setBlurEffectEnabled(void *handle,
wcaData.cbData = sizeof(accentPolicy);
if (enabled) {
if (isWin10OrGreater(17134)) {
- // Enabling the Acrylic effect for Win32 windows is
- // very buggy and it's a bug of Windows 10 itself so
- // it's not fixable from my side.
- if (qEnvironmentVariableIsSet("WNEF_FORCE_ACRYLIC_ON_WIN10")) {
- // Windows 10, version 1803 (10.0.17134)
- // It's not allowed to enable the Acrylic effect for Win32
- // applications until Win10 1803.
+ // Windows 10, version 1803 (10.0.17134)
+ // It's not allowed to enable the Acrylic effect for Win32
+ // applications until Win10 1803.
+ if (forceEnableAcrylicOnWin10()) {
accentPolicy.AccentState = ACCENT_ENABLE_ACRYLICBLURBEHIND;
+ // The gradient color must be set otherwise it'll look
+ // like a classic blur. Use semi-transparent gradient
+ // color to get better appearance.
const QColor color = gradientColor.isValid() ? gradientColor
: QColor(255, 255, 255, 0);
accentPolicy.GradientColor = color.rgba();
} else {
+ // Enabling the Acrylic effect for Win32 windows is
+ // very buggy and it's a bug of Windows 10 itself so
+ // it's not fixable from my side.
+ // So here we switch back to use the classic blur as
+ // a workaround.
accentPolicy.AccentState = ACCENT_ENABLE_BLURBEHIND;
}
} else if (isWin10OrGreater(10240)) {