summaryrefslogtreecommitdiffstats
path: root/macosx
diff options
context:
space:
mode:
authorculler <culler>2020-05-30 14:35:52 (GMT)
committerculler <culler>2020-05-30 14:35:52 (GMT)
commitf5badcc4c99f99da82da6b138e7afb70f492305d (patch)
tree0ecea9e34f94573adbb451ace3b802c30ea32058 /macosx
parent3315ad85a29eee53ac2c7b8b9845f148ff99edaf (diff)
parent9ba4c746ec344f1455e03c2f97ca0ae7c95d139f (diff)
downloadtk-f5badcc4c99f99da82da6b138e7afb70f492305d.zip
tk-f5badcc4c99f99da82da6b138e7afb70f492305d.tar.gz
tk-f5badcc4c99f99da82da6b138e7afb70f492305d.tar.bz2
Merge 8.6
Diffstat (limited to 'macosx')
-rw-r--r--macosx/tkMacOSXBitmap.c1
-rw-r--r--macosx/tkMacOSXFont.c33
-rw-r--r--macosx/tkMacOSXInt.h2
-rw-r--r--macosx/tkMacOSXPrivate.h2
-rw-r--r--macosx/tkMacOSXSubwindows.c8
-rw-r--r--macosx/tkMacOSXWindowEvent.c35
-rw-r--r--macosx/tkMacOSXWm.c34
7 files changed, 58 insertions, 57 deletions
diff --git a/macosx/tkMacOSXBitmap.c b/macosx/tkMacOSXBitmap.c
index 615192b..2b08235 100644
--- a/macosx/tkMacOSXBitmap.c
+++ b/macosx/tkMacOSXBitmap.c
@@ -317,7 +317,6 @@ TkpGetNativeAppBitmap(
OSType iconType;
if (OSTypeFromString(name, &iconType) == TCL_OK) {
NSString *iconUTI = OSTYPE_TO_UTI(iconType);
- printf("Found image for UTI %s\n", iconUTI.UTF8String);
NSImage *iconImage = [[NSWorkspace sharedWorkspace]
iconForFileType: iconUTI];
pixmap = PixmapFromImage(display, iconImage, NSSizeToCGSize(size));
diff --git a/macosx/tkMacOSXFont.c b/macosx/tkMacOSXFont.c
index 7fc0113..13a5de0 100644
--- a/macosx/tkMacOSXFont.c
+++ b/macosx/tkMacOSXFont.c
@@ -105,7 +105,7 @@ static void DrawCharsInContext(Display *display, Drawable drawable,
* To avoid an extra copy, a TKNSString object wraps a Tcl_DString with an
* NSString that uses the DString's buffer as its character buffer. It can be
* constructed from a Tcl_DString and it has a DString property that handles
- * converting from an NSString to a Tcl_DString
+ * converting from an NSString to a Tcl_DString.
*/
@implementation TKNSString
@@ -133,7 +133,6 @@ static void DrawCharsInContext(Display *display, Drawable drawable,
_string = [[NSString alloc] initWithString:aString];
self.UTF8String = _string.UTF8String;
}
- printf("Initialized with string %s\n", self.UTF8String);
return self;
}
@@ -166,32 +165,16 @@ static void DrawCharsInContext(Display *display, Drawable drawable,
* The DString has not been initialized. Construct it from
* our string's unicode characters.
*/
-
- char buffer[2*TCL_UTF_MAX];
- unsigned int index, length, ch;
+ char *p;
+ unsigned int index;
Tcl_DStringInit(&_ds);
-#if TCL_UTF_MAX == 3
- for (index = 0; index < [_string length]; index++) {
- UniChar uni = [_string characterAtIndex: index];
-
- if (CFStringIsSurrogateHighCharacter(uni)) {
- UniChar low = [_string characterAtIndex: ++index];
- ch = CFStringGetLongCharacterForSurrogatePair(uni, low);
- } else {
- ch = uni;
- }
- length = TkUniCharToUtf(ch, buffer);
- Tcl_DStringAppend(&_ds, buffer, length);
- }
-#else
+ Tcl_DStringSetLength(&_ds, 3 * [_string length]);
+ p = Tcl_DStringValue(&_ds);
for (index = 0; index < [_string length]; index++) {
- ch = (int) [_string characterAtIndex: index];
- length = Tcl_UniCharToUtf(ch, buffer);
- Tcl_DStringAppend(&_ds, buffer, length);
+ p += Tcl_UniCharToUtf([_string characterAtIndex: index], p);
}
-
-#endif
+ Tcl_DStringSetLength(&_ds, p - Tcl_DStringValue(&_ds));
}
return _ds;
}
@@ -1056,7 +1039,7 @@ TkpMeasureCharsInContext(
[attributedString release];
[string release];
length = ceil(width - offset);
- fit = (Tcl_UtfAtIndex(source, index) - source) - rangeStart;
+ fit = (TkUtfAtIndex(source, index) - source) - rangeStart;
done:
#ifdef TK_MAC_DEBUG_FONTS
TkMacOSXDbgMsg("measure: source=\"%s\" range=\"%.*s\" maxLength=%d "
diff --git a/macosx/tkMacOSXInt.h b/macosx/tkMacOSXInt.h
index 9cb75d2..58761d5 100644
--- a/macosx/tkMacOSXInt.h
+++ b/macosx/tkMacOSXInt.h
@@ -200,8 +200,6 @@ MODULE_SCOPE void TkpClipDrawableToRect(Display *display, Drawable d, int x,
MODULE_SCOPE void TkpRetainRegion(TkRegion r);
MODULE_SCOPE void TkpReleaseRegion(TkRegion r);
MODULE_SCOPE void TkpShiftButton(NSButton *button, NSPoint delta);
-MODULE_SCOPE Bool TkpAppIsDrawing(void);
-MODULE_SCOPE void TkpDisplayWindow(Tk_Window tkwin);
MODULE_SCOPE Bool TkTestLogDisplay(void);
MODULE_SCOPE Bool TkMacOSXInDarkMode(Tk_Window tkwin);
diff --git a/macosx/tkMacOSXPrivate.h b/macosx/tkMacOSXPrivate.h
index a0645f7..be69fcd 100644
--- a/macosx/tkMacOSXPrivate.h
+++ b/macosx/tkMacOSXPrivate.h
@@ -527,7 +527,7 @@ VISIBILITY_HIDDEN
* byte sequence as initial data. So we add a new class which does provide
* such a constructor. It also has a DString property which is a DString whose
* string pointer is a byte sequence encoding the NSString with the current Tk
- * encoding, namely UTF-8 if TCL_MAX >= 4 or CESU-8 if TCL_MAX = 3.
+ * encoding, namely UTF-8 if TCL_UTF_MAX >= 4 or CESU-8 if TCL_UTF_MAX = 3.
*
*---------------------------------------------------------------------------
*/
diff --git a/macosx/tkMacOSXSubwindows.c b/macosx/tkMacOSXSubwindows.c
index 5063fa3..6602564 100644
--- a/macosx/tkMacOSXSubwindows.c
+++ b/macosx/tkMacOSXSubwindows.c
@@ -698,16 +698,10 @@ XConfigureWindow(
if (value_mask & CWStackMode) {
NSView *view = TkMacOSXDrawableView(macWin);
- Rect bounds;
- NSRect r;
if (view) {
TkMacOSXInvalClipRgns((Tk_Window) winPtr->parentPtr);
- TkMacOSXWinBounds(winPtr, &bounds);
- r = NSMakeRect(bounds.left,
- [view bounds].size.height - bounds.bottom,
- bounds.right - bounds.left, bounds.bottom - bounds.top);
- [view setNeedsDisplayInRect:r];
+ TkpRedrawWidget((Tk_Window) winPtr);
}
}
diff --git a/macosx/tkMacOSXWindowEvent.c b/macosx/tkMacOSXWindowEvent.c
index cb4ffd1..76b2b04 100644
--- a/macosx/tkMacOSXWindowEvent.c
+++ b/macosx/tkMacOSXWindowEvent.c
@@ -382,26 +382,41 @@ extern NSString *NSWindowDidOrderOffScreenNotification;
/*
*----------------------------------------------------------------------
*
- * TkpAppIsDrawing --
+ * TkpAppCanDraw --
*
* A widget display procedure can call this to determine whether it is
- * being run inside of the drawRect method. This is needed for some tests,
- * especially of the Text widget, which record data in a global Tcl
- * variable and assume that display procedures will be run in a
- * predictable sequence as Tcl idle tasks.
+ * being run inside of the drawRect method. If not, it may be desirable
+ * for the display procedure to simply clear the REDRAW_PENDING flag
+ * and return. The widget can be recorded in order to schedule a
+ * redraw, via and Expose event, from within drawRect.
+ *
+ * This is also needed for some tests, especially of the Text widget,
+ * which record data in a global Tcl variable and assume that display
+ * procedures will be run in a predictable sequence as Tcl idle tasks.
*
* Results:
- * True only while running the drawRect method of a TKContentView;
+ * True if called from the drawRect method of a TKContentView with
+ * tkwin NULL or pointing to a widget in the current focusView.
*
* Side effects:
- * None
+ * The tkwin parameter may be recorded to handle redrawing the widget
+ * later.
*
*----------------------------------------------------------------------
*/
-MODULE_SCOPE Bool
-TkpAppIsDrawing(void) {
- return [NSApp isDrawing];
+int
+TkpAppCanDraw(Tk_Window tkwin) {
+ if (![NSApp isDrawing]) {
+ return 0;
+ }
+ if (tkwin) {
+ TkWindow *winPtr = (TkWindow *)tkwin;
+ NSView *view = TkMacOSXDrawableView(winPtr->privatePtr);
+ return (view == [NSView focusView]);
+ } else {
+ return 1;
+ }
}
/*
diff --git a/macosx/tkMacOSXWm.c b/macosx/tkMacOSXWm.c
index 9117159..cab2b9a 100644
--- a/macosx/tkMacOSXWm.c
+++ b/macosx/tkMacOSXWm.c
@@ -6174,28 +6174,40 @@ TkMacOSXMakeRealWindowExist(
/*
*----------------------------------------------------------------------
*
- * TkpDisplayWindow --
+ * TkpRedrawWidget --
*
- * Mark the contentView of this window as needing display so the window
- * will be drawn by the window manager. If this is called within the
- * drawRect method, do nothing.
+ * Mark the bounding rectangle of this widget as needing display so the
+ * widget will be drawn by [NSView drawRect:]. If this is called within
+ * the drawRect method, do nothing.
*
* Results:
* None.
*
* Side effects:
- * The window's contentView is marked as needing display.
+ * The widget's bounding rectangle is marked as dirty.
*
*----------------------------------------------------------------------
*/
-MODULE_SCOPE void
-TkpDisplayWindow(Tk_Window tkwin) {
- if (![NSApp isDrawing]) {
- TkWindow *winPtr = (TkWindow *) tkwin;
- NSWindow *w = TkMacOSXDrawableWindow(winPtr->window);
+void
+TkpRedrawWidget(Tk_Window tkwin) {
+ TkWindow *winPtr = (TkWindow *) tkwin;
+ NSWindow *w;
+ Rect tkBounds;
+ NSRect bounds;
- [[w contentView] setNeedsDisplay: YES];
+ if ([NSApp isDrawing]) {
+ return;
+ }
+ w = TkMacOSXDrawableWindow(winPtr->window);
+ if (w) {
+ NSView *view = [w contentView];
+ TkMacOSXWinBounds(winPtr, &tkBounds);
+ bounds = NSMakeRect(tkBounds.left,
+ [view bounds].size.height - tkBounds.bottom,
+ tkBounds.right - tkBounds.left,
+ tkBounds.bottom - tkBounds.top);
+ [view setNeedsDisplayInRect:bounds];
}
}