summaryrefslogtreecommitdiffstats
path: root/src/gui
diff options
context:
space:
mode:
authorJari Tenhunen <jari.tenhunen@iki.fi>2014-08-18 21:08:02 +0300
committerGabriel de Dietrich <gabriel.dedietrich@digia.com>2014-08-20 10:53:09 +0200
commitca12a739c9ee419c6def4ef3a9d267e74b386651 (patch)
tree7933e00a02e71d8e646d8cec6e9367d0cc804a49 /src/gui
parent1344f0d1b97689ea31b41c944f4ed3fcb9a72006 (diff)
QMacStyle: Fix focus frame rendering in Yosemite
Using the HITheme API would result in the frame's right edge to be missing. Instead, we use the recommended technique to draw the focus ring around a custom NSCell. (See https://developer.apple.com/library/mac/documentation/Cocoa/Conceptual/ControlCell/Articles/ManipulateCellControl.html) Backport of 769af6689337285927a2637b184149f688332542 from Qt5/qtbase Change-Id: I8f3992edc065e14632ec4e473732b30bcf4c1937 Reviewed-by: Gabriel de Dietrich <gabriel.dedietrich@digia.com>
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/styles/qmacstyle_mac.mm19
1 files changed, 14 insertions, 5 deletions
diff --git a/src/gui/styles/qmacstyle_mac.mm b/src/gui/styles/qmacstyle_mac.mm
index 65f3ba96ae..78d0d19f99 100644
--- a/src/gui/styles/qmacstyle_mac.mm
+++ b/src/gui/styles/qmacstyle_mac.mm
@@ -3809,11 +3809,20 @@ void QMacStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPainter
}
break;
case CE_FocusFrame: {
- int xOff = proxy()->pixelMetric(PM_FocusFrameHMargin, opt, w) + 1;
- int yOff = proxy()->pixelMetric(PM_FocusFrameVMargin, opt, w) + 1;
- HIRect hirect = CGRectMake(xOff+opt->rect.x(), yOff+opt->rect.y(), opt->rect.width() - 2 * xOff,
- opt->rect.height() - 2 * yOff);
- HIThemeDrawFocusRect(&hirect, true, QMacCGContext(p), kHIThemeOrientationNormal);
+ int xOff = proxy()->pixelMetric(PM_FocusFrameHMargin, opt, w);
+ int yOff = proxy()->pixelMetric(PM_FocusFrameVMargin, opt, w);
+ NSRect rect = NSMakeRect(xOff+opt->rect.x(), yOff+opt->rect.y(), opt->rect.width() - 2 * xOff,
+ opt->rect.height() - 2 * yOff);
+ CGContextSaveGState(cg);
+ [NSGraphicsContext setCurrentContext:[NSGraphicsContext
+ graphicsContextWithGraphicsPort:(CGContextRef)cg flipped:NO]];
+ [NSGraphicsContext saveGraphicsState];
+ NSSetFocusRingStyle(NSFocusRingOnly);
+ NSBezierPath *focusFramePath = [NSBezierPath bezierPathWithRect:rect];
+ [focusFramePath setClip]; // Clear clip path to avoid artifacts when rendering the cursor at zero pos
+ [focusFramePath fill];
+ [NSGraphicsContext restoreGraphicsState];
+ CGContextRestoreGState(cg);
break; }
case CE_MenuItem:
case CE_MenuEmptyArea: