Skip to content

Commit 5e1c012

Browse files
committed
apply some fixes and workarounds
1 parent 6f4ab64 commit 5e1c012

File tree

5 files changed

+30
-19
lines changed

5 files changed

+30
-19
lines changed

README.md

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -45,20 +45,6 @@ You can share your findings, thoughts and ideas on improving / implementing QWin
4545
|:-------------------------------:|:---------------------------------:|
4646
| ![image](./docs/images/mac.png) | ![image](./docs/images/linux.png) |
4747

48-
## Products who use QWK
49-
50-
### Jami
51-
52-
![jami](https://jami.net/content/images/2024/02/Screenshot-2024-01-22-160459-1.jpg)
53-
54-
[Jami](https://jami.net/) is a free/libre, end-to-end encrypted, and private communication software.
55-
56-
### Tietie
57-
58-
![tietie](https://tietieapp.com/tietie.png)
59-
60-
[Tietie](https://tietieapp.com) is a simple and easy to use clipboard management software. Multi-format support, powerful search ability.
61-
6248
## Requirements
6349

6450
| Component | Requirement | Details |

examples/qml/QWKButton.qml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import QtQuick 2.15
2-
import QtQuick.Controls 2.15
2+
import QtQuick.Controls.Basic 2.15
33

44
Button {
55
id: root

examples/qml/main.qml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import QtQuick 2.15
22
import QtQuick.Window 2.15
3-
import QtQuick.Controls 2.15
3+
import QtQuick.Controls.Basic 2.15
44
import Qt.labs.platform 1.1
55
import QWindowKit 1.0
66

@@ -144,6 +144,7 @@ Window {
144144
color: "#FEFEFE"
145145
Component.onCompleted: {
146146
if ($curveRenderingAvailable) {
147+
console.log("Curve rendering for text is available.")
147148
timeLabel.renderType = Text.CurveRendering
148149
}
149150
}

src/core/contexts/win32windowcontext.cpp

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,10 @@
3333
#include "qwkglobal_p.h"
3434
#include "qwkwindowsextra_p.h"
3535

36+
#if (QT_VERSION >= QT_VERSION_CHECK(6, 6, 0)) && (QT_VERSION <= QT_VERSION_CHECK(6, 6, 1))
37+
# 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
38+
#endif
39+
3640
namespace QWK {
3741

3842
enum IconButtonClickLevelFlag {
@@ -922,7 +926,8 @@ namespace QWK {
922926
// from the top side. In the end I found that we only need to extend from the left
923927
// side if we extend long enough. In this way we can see the special material even
924928
// when the host object is a QWidget and the title bar still remain hidden. But even
925-
// though this solution seems perfect, I really don't know why it works.
929+
// though this solution seems perfect, I really don't know why it works. The following
930+
// hack is totally based on experiments.
926931
static constexpr const MARGINS margins = {65536, 0, 0, 0};
927932
apis.pDwmExtendFrameIntoClientArea(hwnd, &margins);
928933
};
@@ -2016,6 +2021,17 @@ namespace QWK {
20162021
// and align it with the upper-left corner of our new client area".
20172022
const auto clientRect = wParam ? &(reinterpret_cast<LPNCCALCSIZE_PARAMS>(lParam))->rgrc[0]
20182023
: reinterpret_cast<LPRECT>(lParam);
2024+
[[maybe_unused]] const auto& d3dFlickerReducer = qScopeGuard([this]() {
2025+
// When we receive this message, it means the window size has changed
2026+
// already, and it seems this message always come before any client
2027+
// area size notifications (eg. WM_WINDOWPOSCHANGED and WM_SIZE). Let
2028+
// D3D paint immediately to let user see the latest result as soon as
2029+
// possible.
2030+
if (m_windowHandle && m_windowHandle->surfaceType() == QSurface::Direct3DSurface
2031+
&& isDwmCompositionEnabled() && DynamicApis::instance().pDwmFlush) {
2032+
DynamicApis::instance().pDwmFlush();
2033+
}
2034+
});
20192035
if (isSystemBorderEnabled()) {
20202036
// Store the original top margin before the default window procedure applies the
20212037
// default frame.

src/widgets/widgetwindowagent_win.cpp

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,16 @@ namespace QWK {
5555
}
5656

5757
void updateGeometry() override {
58-
widget->setContentsMargins(isNormalWindow() ? QMargins(0, borderThickness(), 0, 0)
59-
: QMargins());
58+
// The window top border is manually painted by QWK so we want to give
59+
// some margins to avoid it covering real window contents, however, we
60+
// found that there are some rounding issues for the thin border and
61+
// thus this small trick doesn't work very well when the DPR is not
62+
// integer. So far we haven't found a perfect solution, so just don't
63+
// set any margins. In theory the window content will only be covered
64+
// by 1px or so, it should not be a serious issue in the real world.
65+
//
66+
// widget->setContentsMargins(isNormalWindow() ? QMargins(0, borderThickness(), 0, 0)
67+
// : QMargins());
6068
}
6169

6270
bool isWindowActive() const override {

0 commit comments

Comments
 (0)