From d32770f79de9ed74e04e37363264660ae90dccbc Mon Sep 17 00:00:00 2001 From: kleuter Date: Tue, 23 Nov 2021 16:48:15 +0100 Subject: [PATCH] 5.15.7 - fix for QTBUG-98093 (backport of https://github.com/qt/qtbase/commit/4bee9cdc0ac4bbee7f061e8f6050d704032f6d0f) --- .../qtbase/src/plugins/styles/mac/qmacstyle_mac.mm | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/5.15.7/qtbase/src/plugins/styles/mac/qmacstyle_mac.mm b/5.15.7/qtbase/src/plugins/styles/mac/qmacstyle_mac.mm index 01a55a7..b3130b7 100644 --- a/5.15.7/qtbase/src/plugins/styles/mac/qmacstyle_mac.mm +++ b/5.15.7/qtbase/src/plugins/styles/mac/qmacstyle_mac.mm @@ -468,7 +468,11 @@ static bool setupSlider(NSSlider *slider, const QStyleOptionSlider *sl) if (sl->minimum >= sl->maximum) return false; - slider.frame = sl->rect.toCGRect(); + // NSSlider seems to cache values based on tracking and the last layout of the + // NSView, resulting in incorrect knob rects that break the interaction with + // multiple sliders. So completely reinitialize the slider. + [slider initWithFrame:sl->rect.toCGRect()]; + slider.minValue = sl->minimum; slider.maxValue = sl->maximum; slider.intValue = sl->sliderPosition; @@ -498,6 +502,14 @@ static bool setupSlider(NSSlider *slider, const QStyleOptionSlider *sl) // the cell for its metrics and to draw itself. [slider layoutSubtreeIfNeeded]; + if (sl->state & QStyle::State_Sunken) { + const CGRect knobRect = [slider.cell knobRectFlipped:slider.isFlipped]; + CGPoint pressPoint; + pressPoint.x = CGRectGetMidX(knobRect); + pressPoint.y = CGRectGetMidY(knobRect); + [slider.cell startTrackingAt:pressPoint inView:slider]; + } + return true; }