summaryrefslogtreecommitdiffstats
path: root/macosx/tkMacOSXScrlbr.c
diff options
context:
space:
mode:
authorculler <culler>2019-10-30 14:31:28 (GMT)
committerculler <culler>2019-10-30 14:31:28 (GMT)
commit946660a5304fa11d00983930250de71b71771a59 (patch)
treeb0a96f8f8688d9407f50f22e30dc13b3d8b3069d /macosx/tkMacOSXScrlbr.c
parentab6d53027cf2347ee194bed0cb5ce40564f50558 (diff)
downloadtk-946660a5304fa11d00983930250de71b71771a59.zip
tk-946660a5304fa11d00983930250de71b71771a59.tar.gz
tk-946660a5304fa11d00983930250de71b71771a59.tar.bz2
Alternative fix to [de579935a9] - just allow weird looking thumbs.
Diffstat (limited to 'macosx/tkMacOSXScrlbr.c')
-rw-r--r--macosx/tkMacOSXScrlbr.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/macosx/tkMacOSXScrlbr.c b/macosx/tkMacOSXScrlbr.c
index a189646..ce7ac58 100644
--- a/macosx/tkMacOSXScrlbr.c
+++ b/macosx/tkMacOSXScrlbr.c
@@ -214,12 +214,20 @@ static void drawMacScrollbar(
CGContextStrokeLineSegments(context, outer, 2);
/*
- * Do not display the thumb unless scrolling is possible.
+ * Do not display the thumb unless scrolling is possible, in accordance
+ * with macOS behavior.
+ *
+ * Native scrollbars and Ttk scrollbars are always 15 pixels wide, but we
+ * allow Tk scrollbars to have any width, even if it looks bad. To prevent
+ * sporadic assertion errors when drawing skinny thumbs we must make sure
+ * the radius is at most half the width.
*/
if (scrollPtr->firstFraction > 0.0 || scrollPtr->lastFraction < 1.0) {
CGRect thumbBounds = {thumbOrigin, thumbSize};
- path = CGPathCreateWithRoundedRect(thumbBounds, 4, 4, NULL);
+ int width = scrollPtr->vertical ? thumbSize.width : thumbSize.height;
+ int radius = width >= 8 ? 4 : width >> 1;
+ path = CGPathCreateWithRoundedRect(thumbBounds, radius, radius, NULL);
CGContextBeginPath(context);
CGContextAddPath(context, path);
if (msPtr->info.trackInfo.scrollbar.pressState != 0) {