From 4bb64b0ee500484106adee726c3ef4d58a0fc3ba Mon Sep 17 00:00:00 2001 From: Gabriel de Dietrich Date: Thu, 11 May 2017 18:08:34 +0700 Subject: [PATCH] QMacStyle: Remove HIShapeGetBounds hack MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Link to ApplicationServices since that's where this function is located. Whether this framework may be removed with Carbon is unknown at the moment. It does remove an obscure dependency nonetheless. Change-Id: If6514f70ca434298f1c88457adac51d38a1afa22 Reviewed-by: Tor Arne Vestbø Reviewed-by: Jake Petroules --- src/plugins/styles/mac/mac.pro | 2 +- src/plugins/styles/mac/qmacstyle_mac.mm | 30 +++++++++---------------- 2 files changed, 11 insertions(+), 21 deletions(-) diff --git a/src/plugins/styles/mac/mac.pro b/src/plugins/styles/mac/mac.pro index bf9660eed3..f3c7c1c067 100644 --- a/src/plugins/styles/mac/mac.pro +++ b/src/plugins/styles/mac/mac.pro @@ -10,7 +10,7 @@ HEADERS += \ qmacstyle_mac_p.h \ qmacstyle_mac_p_p.h -LIBS_PRIVATE += -framework AppKit -framework Carbon +LIBS_PRIVATE += -framework AppKit -framework ApplicationServices -framework Carbon DISTFILES += macstyle.json diff --git a/src/plugins/styles/mac/qmacstyle_mac.mm b/src/plugins/styles/mac/qmacstyle_mac.mm index 7adeb8f34c..7cba535863 100644 --- a/src/plugins/styles/mac/qmacstyle_mac.mm +++ b/src/plugins/styles/mac/qmacstyle_mac.mm @@ -43,6 +43,7 @@ */ #include +#include #include "qmacstyle_mac_p.h" #include "qmacstyle_mac_p_p.h" @@ -214,10 +215,6 @@ static const QColor tabBarCloseButtonCrossSelected(115, 115, 115); static const int closeButtonSize = 14; static const qreal closeButtonCornerRadius = 2.0; -// Resolve these at run-time, since the functions was moved in Leopard. -typedef HIRect * (*PtrHIShapeGetBounds)(HIShapeRef, HIRect *); -static PtrHIShapeGetBounds ptrHIShapeGetBounds = 0; - #ifndef QT_NO_TABBAR static bool isVerticalTabs(const QTabBar::Shape shape) { return (shape == QTabBar::RoundedEast @@ -1817,13 +1814,6 @@ QMacStylePrivate::QMacStylePrivate() { defaultButtonStart = CFAbsoluteTimeGetCurrent(); memset(&buttonState, 0, sizeof(ButtonState)); - - if (ptrHIShapeGetBounds == 0) { - QLibrary library(QLatin1String("/System/Library/Frameworks/Carbon.framework/Carbon")); - library.setLoadHints(QLibrary::ExportExternalSymbolsHint); - ptrHIShapeGetBounds = reinterpret_cast(library.resolve("HIShapeGetBounds")); - } - } QMacStylePrivate::~QMacStylePrivate() @@ -4332,7 +4322,7 @@ void QMacStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPainter QCFType titleRegion; QRect newr = opt->rect.adjusted(0, 0, 2, 0); HIThemeGetWindowShape(&tmpRect, &wdi, kWindowTitleBarRgn, &titleRegion); - ptrHIShapeGetBounds(titleRegion, &tmpRect); + HIShapeGetBounds(titleRegion, &tmpRect); newr.translate(newr.x() - int(tmpRect.origin.x), newr.y() - int(tmpRect.origin.y)); titleBarRect = qt_hirectForQRect(newr); } @@ -4921,7 +4911,7 @@ QRect QMacStyle::subElementRect(SubElement sr, const QStyleOption *opt, QCFType shape; HIRect outRect; HIThemeGetButtonShape(&inRect, &bdi, &shape); - ptrHIShapeGetBounds(shape, &outRect); + HIShapeGetBounds(shape, &outRect); rect = QRect(int(outRect.origin.x + DisclosureOffset), int(outRect.origin.y), int(contentRect.origin.x - outRect.origin.x + DisclosureOffset), int(outRect.size.height)); @@ -5395,7 +5385,7 @@ void QMacStyle::drawComplexControl(ComplexControl cc, const QStyleOptionComplex // Small optimization, the same as q->subControlRect QCFType shape; HIThemeGetTrackThumbShape(&tdi, &shape); - ptrHIShapeGetBounds(shape, &macRect); + HIShapeGetBounds(shape, &macRect); tdi.value = slider->sliderValue; } @@ -5840,7 +5830,7 @@ void QMacStyle::drawComplexControl(ComplexControl cc, const QStyleOptionComplex QCFType titleRegion; QRect newr = titlebar->rect.adjusted(0, 0, 2, 0); HIThemeGetWindowShape(&tmpRect, &wdi, kWindowTitleBarRgn, &titleRegion); - ptrHIShapeGetBounds(titleRegion, &tmpRect); + HIShapeGetBounds(titleRegion, &tmpRect); newr.translate(newr.x() - int(tmpRect.origin.x), newr.y() - int(tmpRect.origin.y)); titleBarRect = qt_hirectForQRect(newr); } @@ -5892,7 +5882,7 @@ void QMacStyle::drawComplexControl(ComplexControl cc, const QStyleOptionComplex QCFType titleRegion2; HIThemeGetWindowShape(&titleBarRect, &wdi, kWindowTitleProxyIconRgn, &titleRegion2); - ptrHIShapeGetBounds(titleRegion2, &tmpRect); + HIShapeGetBounds(titleRegion2, &tmpRect); if (tmpRect.size.width != 1) { int iconExtent = proxy()->pixelMetric(PM_SmallIconSize); iw = titlebar->icon.actualSize(QSize(iconExtent, iconExtent)).width(); @@ -5902,7 +5892,7 @@ void QMacStyle::drawComplexControl(ComplexControl cc, const QStyleOptionComplex p->save(); QCFType titleRegion3; HIThemeGetWindowShape(&titleBarRect, &wdi, kWindowTitleTextRgn, &titleRegion3); - ptrHIShapeGetBounds(titleRegion3, &tmpRect); + HIShapeGetBounds(titleRegion3, &tmpRect); p->setClipRect(qt_qrectForHIRect(tmpRect)); QRect br = p->clipRegion().boundingRect(); int x = br.x(), @@ -6246,7 +6236,7 @@ QRect QMacStyle::subControlRect(ComplexControl cc, const QStyleOptionComplex *op if ((scrollBar && sc == SC_ScrollBarSlider) || (!scrollBar && sc == SC_SliderHandle)) { HIThemeGetTrackThumbShape(&tdi, &shape); - ptrHIShapeGetBounds(shape, &macRect); + HIShapeGetBounds(shape, &macRect); } else if (!scrollBar && sc == SC_SliderGroove) { HIThemeGetTrackBounds(&tdi, &macRect); } else if (sc == SC_ScrollBarGroove) { // Only scroll bar parts available... @@ -6320,13 +6310,13 @@ QRect QMacStyle::subControlRect(ComplexControl cc, const QStyleOptionComplex *op QRect tmpRect = titlebar->rect; HIRect titleRect = qt_hirectForQRect(tmpRect); HIThemeGetWindowShape(&titleRect, &wdi, kWindowTitleBarRgn, ®ion); - ptrHIShapeGetBounds(region, &titleRect); + HIShapeGetBounds(region, &titleRect); CFRelease(region); tmpRect.translate(tmpRect.x() - int(titleRect.origin.x), tmpRect.y() - int(titleRect.origin.y)); titleRect = qt_hirectForQRect(tmpRect); HIThemeGetWindowShape(&titleRect, &wdi, wrc, ®ion); - ptrHIShapeGetBounds(region, &titleRect); + HIShapeGetBounds(region, &titleRect); ret = qt_qrectForHIRect(titleRect); } }