Skip to content

Commit 1732eab

Browse files
hebastofanquake
authored andcommitted
build, qt: Fix regression in rendering on macOS Big Sur
1 parent c870027 commit 1732eab

File tree

2 files changed

+92
-0
lines changed

2 files changed

+92
-0
lines changed

depends/packages/qt.mk

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ $(package)_patches += fix_qt_pkgconfig.patch mac-qmake.conf fix_no_printer.patch
1212
$(package)_patches += dont_hardcode_x86_64.patch fix_montery_include.patch
1313
$(package)_patches += fix_android_jni_static.patch dont_hardcode_pwd.patch
1414
$(package)_patches += qtbase-moc-ignore-gcc-macro.patch fix_limits_header.patch
15+
$(package)_patches += fix_bigsur_style.patch
1516

1617
$(package)_qttranslations_file_name=qttranslations-$($(package)_suffix)
1718
$(package)_qttranslations_sha256_hash=d5788e86257b21d5323f1efd94376a213e091d1e5e03b45a95dd052b5f570db8
@@ -235,6 +236,7 @@ define $(package)_preprocess_cmds
235236
patch -p1 -i $($(package)_patch_dir)/qtbase-moc-ignore-gcc-macro.patch && \
236237
patch -p1 -i $($(package)_patch_dir)/fix_limits_header.patch && \
237238
patch -p1 -i $($(package)_patch_dir)/fix_montery_include.patch && \
239+
patch -p1 -i $($(package)_patch_dir)/fix_bigsur_style.patch && \
238240
mkdir -p qtbase/mkspecs/macx-clang-linux &&\
239241
cp -f qtbase/mkspecs/macx-clang/qplatformdefs.h qtbase/mkspecs/macx-clang-linux/ &&\
240242
cp -f $($(package)_patch_dir)/mac-qmake.conf qtbase/mkspecs/macx-clang-linux/qmake.conf && \
Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
Fix rendering in macOS BigSur
2+
3+
See: https://bugreports.qt.io/browse/QTBUG-86513.
4+
5+
Upstream commits (combined in this patch):
6+
- Qt 6.0: 40fb97e97f550b8afd13ecc3a038d9d0c2d82bbb
7+
- Qt 6.0: 3857f104cac127f62e64e55a20613f0ac2e6b843
8+
- Qt 6.1: abee4cdd5925a8513f51784754fca8fa35031732
9+
10+
--- old/qtbase/src/plugins/styles/mac/qmacstyle_mac.mm
11+
+++ new/qtbase/src/plugins/styles/mac/qmacstyle_mac.mm
12+
@@ -3870,6 +3870,7 @@ void QMacStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPainter
13+
const auto cs = d->effectiveAquaSizeConstrain(opt, w);
14+
// Extra hacks to get the proper pressed appreance when not selected or selected and inactive
15+
const bool needsInactiveHack = (!isActive && isSelected);
16+
+ const bool isBigSurOrAbove = QOperatingSystemVersion::current() >= QOperatingSystemVersion::MacOSBigSur;
17+
const auto ct = !needsInactiveHack && (isSelected || tp == QStyleOptionTab::OnlyOneTab) ?
18+
QMacStylePrivate::Button_PushButton :
19+
QMacStylePrivate::Button_PopupButton;
20+
@@ -3878,6 +3879,12 @@ void QMacStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPainter
21+
auto *pb = static_cast<NSButton *>(d->cocoaControl(cw));
22+
23+
auto vOffset = isPopupButton ? 1 : 2;
24+
+ if (isBigSurOrAbove) {
25+
+ // Make it 1, otherwise, offset is very visible compared
26+
+ // to selected tab (which is not a popup button).
27+
+ vOffset = 1;
28+
+ }
29+
+
30+
if (tabDirection == QMacStylePrivate::East)
31+
vOffset -= 1;
32+
const auto outerAdjust = isPopupButton ? 1 : 4;
33+
@@ -3894,9 +3901,22 @@ void QMacStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPainter
34+
frameRect = frameRect.adjusted(-innerAdjust, 0, outerAdjust, 0);
35+
else
36+
frameRect = frameRect.adjusted(-outerAdjust, 0, innerAdjust, 0);
37+
+
38+
+ if (isSelected && isBigSurOrAbove) {
39+
+ // 1 pixed of 'roundness' is still visible on the right
40+
+ // (the left is OK, it's rounded).
41+
+ frameRect = frameRect.adjusted(0, 0, 1, 0);
42+
+ }
43+
+
44+
break;
45+
case QStyleOptionTab::Middle:
46+
frameRect = frameRect.adjusted(-innerAdjust, 0, innerAdjust, 0);
47+
+
48+
+ if (isSelected && isBigSurOrAbove) {
49+
+ // 1 pixel of 'roundness' is still visible on both
50+
+ // sides - left and right.
51+
+ frameRect = frameRect.adjusted(-1, 0, 1, 0);
52+
+ }
53+
break;
54+
case QStyleOptionTab::End:
55+
// Pressed state hack: tweak adjustments in preparation for flip below
56+
@@ -3904,6 +3924,11 @@ void QMacStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPainter
57+
frameRect = frameRect.adjusted(-innerAdjust, 0, outerAdjust, 0);
58+
else
59+
frameRect = frameRect.adjusted(-outerAdjust, 0, innerAdjust, 0);
60+
+
61+
+ if (isSelected && isBigSurOrAbove) {
62+
+ // 1 pixel of 'roundness' is still visible on the left.
63+
+ frameRect = frameRect.adjusted(-1, 0, 0, 0);
64+
+ }
65+
break;
66+
case QStyleOptionTab::OnlyOneTab:
67+
frameRect = frameRect.adjusted(-outerAdjust, 0, outerAdjust, 0);
68+
@@ -3951,7 +3976,10 @@ void QMacStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPainter
69+
NSPopUpArrowPosition oldPosition = NSPopUpArrowAtCenter;
70+
NSPopUpButtonCell *pbCell = nil;
71+
auto rAdjusted = r;
72+
- if (isPopupButton && tp == QStyleOptionTab::OnlyOneTab) {
73+
+ if (isPopupButton && (tp == QStyleOptionTab::OnlyOneTab || isBigSurOrAbove)) {
74+
+ // Note: starting from macOS BigSur NSPopupButton has this
75+
+ // arrow 'button' in a different place and it became
76+
+ // quite visible 'in between' inactive tabs.
77+
pbCell = static_cast<NSPopUpButtonCell *>(pb.cell);
78+
oldPosition = pbCell.arrowPosition;
79+
pbCell.arrowPosition = NSPopUpNoArrow;
80+
@@ -3959,6 +3987,10 @@ void QMacStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPainter
81+
// NSPopUpButton in this state is smaller.
82+
rAdjusted.origin.x -= 3;
83+
rAdjusted.size.width += 6;
84+
+ if (isBigSurOrAbove) {
85+
+ if (tp == QStyleOptionTab::End)
86+
+ rAdjusted.origin.x -= 2;
87+
+ }
88+
}
89+
}
90+

0 commit comments

Comments
 (0)