From 2fafa7a4333db2f2d6a24fa729ac59d0cf52f309 Mon Sep 17 00:00:00 2001 From: Yuhang Zhao <2546789017@qq.com> Date: Fri, 19 Nov 2021 14:29:44 +0800 Subject: [PATCH] Fix the border width of the examples Amends commit 3aba956d6662207dfbff2b7cc10b77b5b80e79b8 Signed-off-by: Yuhang Zhao <2546789017@qq.com> --- examples/mainwindow/mainwindow.cpp | 2 +- examples/quick/qml/main.qml | 2 +- examples/widget/widget.cpp | 2 +- utilities_win32.cpp | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/examples/mainwindow/mainwindow.cpp b/examples/mainwindow/mainwindow.cpp index 6e913e6..53c6298 100644 --- a/examples/mainwindow/mainwindow.cpp +++ b/examples/mainwindow/mainwindow.cpp @@ -142,7 +142,7 @@ void MainWindow::paintEvent(QPaintEvent *event) || (area == ColorizationArea::All)); const QColor borderColor = (isActiveWindow() ? (colorizedBorder ? Utilities::getColorizationColor() : Qt::black) : Qt::darkGray); const auto borderThickness = static_cast(Utilities::getWindowVisibleFrameBorderThickness(winId())); - painter.setPen({borderColor, qMax(borderThickness, devicePixelRatioF())}); + painter.setPen({borderColor, borderThickness}); painter.drawLines(lines); painter.restore(); } diff --git a/examples/quick/qml/main.qml b/examples/quick/qml/main.qml index 3d1328a..f2be90a 100644 --- a/examples/quick/qml/main.qml +++ b/examples/quick/qml/main.qml @@ -36,7 +36,7 @@ Window { title: qsTr("Hello, World!") color: "#f0f0f0" - property real _flh_margin: ((window.visibility === Window.Maximized) | (window.visibility === Window.FullScreen)) ? 0.0 : Math.max(1.0, Screen.devicePixelRatio) + property real _flh_margin: ((window.visibility === Window.Maximized) | (window.visibility === Window.FullScreen)) ? 0.0 : 1.0 property var _win_prev_state: null FramelessHelper { diff --git a/examples/widget/widget.cpp b/examples/widget/widget.cpp index b845f9a..bd6cb83 100644 --- a/examples/widget/widget.cpp +++ b/examples/widget/widget.cpp @@ -158,7 +158,7 @@ void Widget::paintEvent(QPaintEvent *event) || (area == ColorizationArea::All)); const QColor borderColor = (isActiveWindow() ? (colorizedBorder ? Utilities::getColorizationColor() : Qt::black) : Qt::darkGray); const auto borderThickness = static_cast(Utilities::getWindowVisibleFrameBorderThickness(winId())); - painter.setPen({borderColor, qMax(borderThickness, devicePixelRatioF())}); + painter.setPen({borderColor, borderThickness}); painter.drawLines(lines); painter.restore(); } diff --git a/utilities_win32.cpp b/utilities_win32.cpp index 6bcf364..4504d50 100644 --- a/utilities_win32.cpp +++ b/utilities_win32.cpp @@ -329,7 +329,7 @@ int Utilities::getWindowVisibleFrameBorderThickness(const WId winId) const HRESULT hr = DwmGetWindowAttribute(hWnd, _DWMWA_VISIBLE_FRAME_BORDER_THICKNESS, &value, sizeof(value)); if (SUCCEEDED(hr)) { const QWindow *w = findWindow(winId); - return static_cast(qRound(static_cast(value) * (w ? w->devicePixelRatio() : 1.0))); + return static_cast(qRound(static_cast(value) / (w ? w->devicePixelRatio() : 1.0))); } else { // We just eat this error because this enum value was introduced in a very // late Windows 10 version, so querying it's value will always result in