Zhao Yuhang
2025-02-09 5e1c012c539e74804454d45a1b945093afdb8f4f
apply some fixes and workarounds
5个文件已修改
49 ■■■■■ 已修改文件
README.md 14 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
examples/qml/QWKButton.qml 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
examples/qml/main.qml 3 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/core/contexts/win32windowcontext.cpp 18 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/widgets/widgetwindowagent_win.cpp 12 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
README.md
@@ -45,20 +45,6 @@
|:-------------------------------:|:---------------------------------:|
| ![image](./docs/images/mac.png) | ![image](./docs/images/linux.png) |
## Products who use QWK
### Jami
![jami](https://jami.net/content/images/2024/02/Screenshot-2024-01-22-160459-1.jpg)
[Jami](https://jami.net/) is a free/libre, end-to-end encrypted, and private communication software.
### Tietie
![tietie](https://tietieapp.com/tietie.png)
[Tietie](https://tietieapp.com) is a simple and easy to use clipboard management software. Multi-format support, powerful search ability.
## Requirements
| Component | Requirement |          Details          |
examples/qml/QWKButton.qml
@@ -1,5 +1,5 @@
import QtQuick 2.15
import QtQuick.Controls 2.15
import QtQuick.Controls.Basic 2.15
Button {
    id: root
examples/qml/main.qml
@@ -1,6 +1,6 @@
import QtQuick 2.15
import QtQuick.Window 2.15
import QtQuick.Controls 2.15
import QtQuick.Controls.Basic 2.15
import Qt.labs.platform 1.1
import QWindowKit 1.0
@@ -144,6 +144,7 @@
        color: "#FEFEFE"
        Component.onCompleted: {
            if ($curveRenderingAvailable) {
                console.log("Curve rendering for text is available.")
                timeLabel.renderType = Text.CurveRendering
            }
        }
src/core/contexts/win32windowcontext.cpp
@@ -33,6 +33,10 @@
#include "qwkglobal_p.h"
#include "qwkwindowsextra_p.h"
#if (QT_VERSION >= QT_VERSION_CHECK(6, 6, 0)) && (QT_VERSION <= QT_VERSION_CHECK(6, 6, 1))
#  error Current Qt version has a critical bug which will break QWK functionality. Please upgrade to > 6.6.1 or downgrade to < 6.6.0
#endif
namespace QWK {
    enum IconButtonClickLevelFlag {
@@ -922,7 +926,8 @@
            // from the top side. In the end I found that we only need to extend from the left
            // side if we extend long enough. In this way we can see the special material even
            // when the host object is a QWidget and the title bar still remain hidden. But even
            // though this solution seems perfect, I really don't know why it works.
            // though this solution seems perfect, I really don't know why it works. The following
            // hack is totally based on experiments.
            static constexpr const MARGINS margins = {65536, 0, 0, 0};
            apis.pDwmExtendFrameIntoClientArea(hwnd, &margins);
        };
@@ -2016,6 +2021,17 @@
        // and align it with the upper-left corner of our new client area".
        const auto clientRect = wParam ? &(reinterpret_cast<LPNCCALCSIZE_PARAMS>(lParam))->rgrc[0]
                                       : reinterpret_cast<LPRECT>(lParam);
        [[maybe_unused]] const auto& d3dFlickerReducer = qScopeGuard([this]() {
            // When we receive this message, it means the window size has changed
            // already, and it seems this message always come before any client
            // area size notifications (eg. WM_WINDOWPOSCHANGED and WM_SIZE). Let
            // D3D paint immediately to let user see the latest result as soon as
            // possible.
            if (m_windowHandle && m_windowHandle->surfaceType() == QSurface::Direct3DSurface
                && isDwmCompositionEnabled() && DynamicApis::instance().pDwmFlush) {
                DynamicApis::instance().pDwmFlush();
            }
        });
        if (isSystemBorderEnabled()) {
            // Store the original top margin before the default window procedure applies the
            // default frame.
src/widgets/widgetwindowagent_win.cpp
@@ -55,8 +55,16 @@
        }
        void updateGeometry() override {
            widget->setContentsMargins(isNormalWindow() ? QMargins(0, borderThickness(), 0, 0)
                                                        : QMargins());
            // The window top border is manually painted by QWK so we want to give
            // some margins to avoid it covering real window contents, however, we
            // found that there are some rounding issues for the thin border and
            // thus this small trick doesn't work very well when the DPR is not
            // integer. So far we haven't found a perfect solution, so just don't
            // set any margins. In theory the window content will only be covered
            // by 1px or so, it should not be a serious issue in the real world.
            //
            // widget->setContentsMargins(isNormalWindow() ? QMargins(0, borderThickness(), 0, 0)
            //                                             : QMargins());
        }
        bool isWindowActive() const override {