From 3315ad85a29eee53ac2c7b8b9845f148ff99edaf Mon Sep 17 00:00:00 2001 From: culler Date: Tue, 19 May 2020 20:43:44 +0000 Subject: Aqua: Try processing idle events before each call to [NSApp nextEventMatchingMask ...] --- macosx/tkMacOSXNotify.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/macosx/tkMacOSXNotify.c b/macosx/tkMacOSXNotify.c index 96c9a7a..985d7bc 100644 --- a/macosx/tkMacOSXNotify.c +++ b/macosx/tkMacOSXNotify.c @@ -338,6 +338,7 @@ TkMacOSXEventsSetupProc( * Call this with dequeue=NO -- just checking if the queue is empty. */ + while (Tcl_DoOneEvent(TCL_IDLE_EVENTS|TCL_DONT_WAIT)) {} NSEvent *currentEvent = [NSApp nextEventMatchingMask:NSAnyEventMask untilDate:[NSDate distantPast] @@ -407,6 +408,7 @@ TkMacOSXEventsCheckProc( [NSApp _lockAutoreleasePool]; do { + while (Tcl_DoOneEvent(TCL_IDLE_EVENTS|TCL_DONT_WAIT)) {} modalSession = TkMacOSXGetModalSession(); testEvent = [NSApp nextEventMatchingMask:NSAnyEventMask untilDate:[NSDate distantPast] @@ -420,6 +422,7 @@ TkMacOSXEventsCheckProc( if (testEvent && [[testEvent window] inLiveResize]) { break; } + while (Tcl_DoOneEvent(TCL_IDLE_EVENTS|TCL_DONT_WAIT)) {} currentEvent = [NSApp nextEventMatchingMask:NSAnyEventMask untilDate:[NSDate distantPast] inMode:GetRunLoopMode(modalSession) -- cgit v0.12 From 8bfe6e9b964fb48650e31fac01c29de41ba63d44 Mon Sep 17 00:00:00 2001 From: culler Date: Sat, 30 May 2020 23:13:52 +0000 Subject: A partly but not completely successful attempt to control how drawRect is run. --- generic/tkCanvas.c | 3 + macosx/tkMacOSXDraw.c | 40 ++++++------- macosx/tkMacOSXNotify.c | 115 ++++++++++++++++++++++++++++++++++--- macosx/tkMacOSXPrivate.h | 9 ++- macosx/tkMacOSXSubwindows.c | 73 ++++++++++++++++++------ macosx/tkMacOSXWindowEvent.c | 133 ++++++++++++++++++++----------------------- macosx/tkMacOSXWm.c | 5 +- 7 files changed, 256 insertions(+), 122 deletions(-) diff --git a/generic/tkCanvas.c b/generic/tkCanvas.c index 4d68ade..941e7d2 100644 --- a/generic/tkCanvas.c +++ b/generic/tkCanvas.c @@ -2577,6 +2577,9 @@ DisplayCanvas( #else canvasPtr->drawableXOrigin = canvasPtr->xOrigin; canvasPtr->drawableYOrigin = canvasPtr->yOrigin; +#if 0 + TkpAppCanDraw(tkwin); +#endif pixmap = Tk_WindowId(tkwin); TkpClipDrawableToRect(Tk_Display(tkwin), pixmap, screenX1 - canvasPtr->xOrigin, screenY1 - canvasPtr->yOrigin, diff --git a/macosx/tkMacOSXDraw.c b/macosx/tkMacOSXDraw.c index e56e666..d2d72e4 100644 --- a/macosx/tkMacOSXDraw.c +++ b/macosx/tkMacOSXDraw.c @@ -174,7 +174,9 @@ TkMacOSXBitmapRepFromDrawableRect( if (cg_image) { CGImageRelease(cg_image); } - } else if ((view = TkMacOSXDrawableView(mac_drawable)) != NULL) { + } else if (TkMacOSXDrawableView(mac_drawable) != NULL) { + TKContentView *tkview = (TKContentView *)view; + /* * Convert Tk top-left to NSView bottom-left coordinates. */ @@ -197,7 +199,8 @@ TkMacOSXBitmapRepFromDrawableRect( [view cacheDisplayInRect:view_rect toBitmapImageRep:bitmap_rep]; } else { TkMacOSXDbgMsg("No CGContext - cannot copy from screen to bitmap."); - [view setNeedsDisplay:YES]; + [tkview setTkNeedsDisplay:YES]; + [tkview setTkDirtyRect:[tkview bounds]]; return NULL; } } else { @@ -1622,7 +1625,7 @@ TkMacOSXSetupDrawingContext( if (dc.context) { dc.portBounds = clipBounds = CGContextGetClipBoundingBox(dc.context); } else if (win) { - NSView *view = TkMacOSXDrawableView(macDraw); + TKContentView *view = (TKContentView *)TkMacOSXDrawableView(macDraw); if (!view) { Tcl_Panic("TkMacOSXSetupDrawingContext(): " @@ -1636,31 +1639,22 @@ TkMacOSXSetupDrawingContext( * tells us whether we are being called from one of those methods. * * If the CGContext is not valid then we mark our view as needing - * display in the bounding rectangle of the clipping region and - * return failure. That rectangle should get drawn in a later call - * to drawRect. - * - * As an exception to the above, if mouse buttons are pressed at the - * moment when we fail to obtain a valid context we schedule the entire - * view for a redraw rather than just the clipping region. The purpose - * of this is to make sure that scrollbars get updated correctly. + * display. We could try to optimize by computing a smaller dirty rect + * here. */ if (![NSApp isDrawing] || view != [NSView focusView]) { - NSRect bounds = [view bounds]; - NSRect dirtyNS = bounds; - if ([NSEvent pressedMouseButtons]) { - [view setNeedsDisplay:YES]; - } else { + NSRect dirtyRect = [view bounds]; + if (dc.clipRgn) { + CGRect clipRect; CGAffineTransform t = { .a = 1, .b = 0, .c = 0, .d = -1, .tx = 0, - .ty = dirtyNS.size.height}; - if (dc.clipRgn) { - CGRect dirtyCG = NSRectToCGRect(dirtyNS); - HIShapeGetBounds(dc.clipRgn, &dirtyCG); - dirtyNS = NSRectToCGRect(CGRectApplyAffineTransform(dirtyCG, t)); - } - [view setNeedsDisplayInRect:dirtyNS]; + .ty = dirtyRect.size.height}; + HIShapeGetBounds(dc.clipRgn, &clipRect); + clipRect = CGRectApplyAffineTransform(clipRect, t); + dirtyRect = NSRectFromCGRect(clipRect); } + [view setTkNeedsDisplay:YES]; + [view setTkDirtyRect:NSUnionRect([view tkDirtyRect], dirtyRect)]; canDraw = false; goto end; } diff --git a/macosx/tkMacOSXNotify.c b/macosx/tkMacOSXNotify.c index 985d7bc..f8ac50d 100644 --- a/macosx/tkMacOSXNotify.c +++ b/macosx/tkMacOSXNotify.c @@ -299,6 +299,70 @@ TkMacOSXNotifyExitHandler( /* *---------------------------------------------------------------------- * + * TkMacOSXDrawAllViews -- + * + * This static function is meant to be run as an idle task. It attempts + * to redraw all views which have the tkNeedsDisplay property set to YES. + * This relies on a feature of [NSApp nextEventMatchingMask: ...] which + * is undocumented, namely that it sometimes blocks and calls drawRect + * for all views that need display before it returns. We call it with + * deQueue=NO so that it will not change anything on the AppKit event + * queue, because we only want the side effect that it runs + * drawRect. This function is the only place where NSViews get the + * needsDisplay property set to YES. + * + * The reason for running this as an idle task is to try to arrange that + * all widgets will be fully configured before they are drawn. Any idle + * tasks that might reconfigure them should be higher on the idle queue, + * so they should be run before the display procs are run by drawRect. + * + * If this is called directly with non-NULL clientData parameter then the + * int which it references will be set to the number of windows that need + * display, but the needsDisplay property of those windows will not be + * changed. + * + * Results: + * None. + * + * Side effects: + * Parts of windows my get redrawn. + * + *---------------------------------------------------------------------- + */ + +static void +TkMacOSXDrawAllViews( + ClientData clientData) +{ + int count = 0, *dirtyCount = (int *)clientData; + + for (NSWindow *window in [NSApp windows]) { + if ([[window contentView] isMemberOfClass:[TKContentView class]]) { + TKContentView *view = [window contentView]; + if ([view tkNeedsDisplay]) { + count++; + if (dirtyCount) { + continue; + } + [view setNeedsDisplayInRect:[view tkDirtyRect]]; + } + } else { + [window displayIfNeeded]; + } + } + if (dirtyCount) { + *dirtyCount = count; + } + + [NSApp nextEventMatchingMask:NSAnyEventMask + untilDate:[NSDate distantPast] + inMode:GetRunLoopMode(TkMacOSXGetModalSession()) + dequeue:NO]; +} + +/* + *---------------------------------------------------------------------- + * * TkMacOSXEventsSetupProc -- * * This procedure implements the setup part of the MacOSX event source. It @@ -334,11 +398,13 @@ TkMacOSXEventsSetupProc( static const Tcl_Time zeroBlockTime = { 0, 0 }; [NSApp _resetAutoreleasePool]; - /* - * Call this with dequeue=NO -- just checking if the queue is empty. - */ + /* + * Call this with dequeue=NO to see if there are any events. If so, + * we set the block time to 0 and stop the heartbeat. Tcl_DoOneEvent + * will call the check proc to collect the events and translate them + * into XEvents. But also, drawRect may run. + */ - while (Tcl_DoOneEvent(TCL_IDLE_EVENTS|TCL_DONT_WAIT)) {} NSEvent *currentEvent = [NSApp nextEventMatchingMask:NSAnyEventMask untilDate:[NSDate distantPast] @@ -353,7 +419,7 @@ TkMacOSXEventsSetupProc( } else if (!havePeriodicEvents){ /* - * When the user is not generating events we schedule a "hearbeat" + * When the user is not generating events we schedule a "heartbeat" * event to fire every 0.1 seconds. This helps to make the vwait * command more responsive when there is no user input, e.g. when * running the test suite. @@ -362,6 +428,12 @@ TkMacOSXEventsSetupProc( havePeriodicEvents = YES; [NSEvent startPeriodicEventsAfterDelay:0.0 withPeriod:0.1]; } + + /* + * Without this, new windows are sometimes not completely rendered. + */ + while (Tcl_DoOneEvent(TCL_IDLE_EVENTS)) {} + TkMacOSXDrawAllViews(NULL); } } @@ -388,6 +460,7 @@ TkMacOSXEventsCheckProc( int flags) { NSString *runloopMode = [[NSRunLoop currentRunLoop] currentMode]; + int eventsFound = 0; /* * runloopMode will be nil if we are in a Tcl event loop. @@ -408,7 +481,6 @@ TkMacOSXEventsCheckProc( [NSApp _lockAutoreleasePool]; do { - while (Tcl_DoOneEvent(TCL_IDLE_EVENTS|TCL_DONT_WAIT)) {} modalSession = TkMacOSXGetModalSession(); testEvent = [NSApp nextEventMatchingMask:NSAnyEventMask untilDate:[NSDate distantPast] @@ -422,12 +494,12 @@ TkMacOSXEventsCheckProc( if (testEvent && [[testEvent window] inLiveResize]) { break; } - while (Tcl_DoOneEvent(TCL_IDLE_EVENTS|TCL_DONT_WAIT)) {} currentEvent = [NSApp nextEventMatchingMask:NSAnyEventMask untilDate:[NSDate distantPast] inMode:GetRunLoopMode(modalSession) dequeue:YES]; if (currentEvent) { + /* * Generate Xevents. */ @@ -436,9 +508,12 @@ TkMacOSXEventsCheckProc( NSEvent *processedEvent = [NSApp tkProcessEvent:currentEvent]; Tcl_SetServiceMode(oldServiceMode); if (processedEvent) { + eventsFound++; + #ifdef TK_MAC_DEBUG_EVENTS TKLog(@" event: %@", currentEvent); #endif + if (modalSession) { [NSApp _modalSession:modalSession sendEvent:currentEvent]; } else { @@ -446,6 +521,7 @@ TkMacOSXEventsCheckProc( } } } else { + break; } } while (1); @@ -453,8 +529,31 @@ TkMacOSXEventsCheckProc( /* * Now we can unlock the pool. */ - [NSApp _unlockAutoreleasePool]; + + if (eventsFound == 0) { + + /* + * We found no events for Tcl in this iteration of the Tcl event + * loop, so it should proceed to servicing idle tasks. We add an + * idle task to the end of the idle queue which will redisplay all + * of our dirty windows. We want this to happen after all other + * idle tasks have run so that all widgets will be configured + * before they are displayed. The drawRect method "borrows" the + * idle queue while drawing views. That is, it sends expose events + * which cause display procs to be posted as idle tasks and then + * runs an inner event loop to processes those idle tasks. We are + * trying to arrange for the idle queue to be empty when it starts + * that process and empty when it finishes. + */ + + int dirtyCount = 0; + TkMacOSXDrawAllViews(&dirtyCount); + if (dirtyCount > 0) { + Tcl_CancelIdleCall(TkMacOSXDrawAllViews, NULL); + Tcl_DoWhenIdle(TkMacOSXDrawAllViews, NULL); + } + } } } diff --git a/macosx/tkMacOSXPrivate.h b/macosx/tkMacOSXPrivate.h index be69fcd..fdd07ed 100644 --- a/macosx/tkMacOSXPrivate.h +++ b/macosx/tkMacOSXPrivate.h @@ -307,6 +307,8 @@ MODULE_SCOPE int TkMacOSXRegisterServiceWidgetObjCmd(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]); MODULE_SCOPE unsigned TkMacOSXAddVirtual(unsigned int keycode); +MODULE_SCOPE void TkMacOSXWinNSBounds(TkWindow *winPtr, NSView *view, + NSRect *bounds); #pragma mark Private Objective-C Classes @@ -418,8 +420,12 @@ VISIBILITY_HIDDEN @private NSString *privateWorkingText; Bool _needsRedisplay; + Bool _tkNeedsDisplay; + NSRect _tkDirtyRect; } @property Bool needsRedisplay; +@property Bool tkNeedsDisplay; +@property NSRect tkDirtyRect; @end @interface TKContentView(TKKeyEvent) @@ -428,7 +434,8 @@ VISIBILITY_HIDDEN @end @interface TKContentView(TKWindowEvent) -- (void) generateExposeEvents: (HIShapeRef) shape; + //(HIShapeRef) shape; +- (void) generateExposeEvents: (NSRect) rect; - (void) tkToolbarButton: (id) sender; @end diff --git a/macosx/tkMacOSXSubwindows.c b/macosx/tkMacOSXSubwindows.c index 6602564..53e5bf6 100644 --- a/macosx/tkMacOSXSubwindows.c +++ b/macosx/tkMacOSXSubwindows.c @@ -157,6 +157,7 @@ XMapWindow( winPtr->flags |= TK_MAPPED; if (Tk_IsTopLevel(winPtr)) { if (!Tk_IsEmbedded(winPtr)) { + TKContentView *view = [win contentView]; /* * We want to activate Tk when a toplevel is mapped but we must not @@ -169,7 +170,8 @@ XMapWindow( TkMacOSXApplyWindowAttributes(winPtr, win); [win setExcludedFromWindowsMenu:NO]; [NSApp activateIgnoringOtherApps:NO]; - [[win contentView] setNeedsDisplay:YES]; + [view setTkNeedsDisplay:YES]; + [view setTkDirtyRect: [view bounds]]; if ([win canBecomeKeyWindow]) { [win makeKeyAndOrderFront:NSApp]; } else { @@ -215,7 +217,9 @@ XMapWindow( if ([NSApp isDrawing]) { [[win contentView] setNeedsRedisplay:YES]; } else { - [[win contentView] setNeedsDisplay:YES]; + TKContentView *view = [win contentView]; + [view setTkNeedsDisplay:YES]; + [view setTkDirtyRect:[view bounds]]; } /* @@ -332,7 +336,9 @@ XUnmapWindow( if ([NSApp isDrawing]) { [[win contentView] setNeedsRedisplay:YES]; } else { - [[win contentView] setNeedsDisplay:YES]; + TKContentView *view = [win contentView]; + [view setTkNeedsDisplay:YES]; + [view setTkDirtyRect:[view bounds]]; } return Success; } @@ -986,8 +992,9 @@ InvalViewRect( void *ref) { static CGAffineTransform t; - NSView *view = ref; - + TKContentView *view = ref; + NSRect dirtyRect; + if (!view) { return paramErr; } @@ -997,8 +1004,9 @@ InvalViewRect( NSHeight([view bounds])); break; case kHIShapeEnumerateRect: - [view setNeedsDisplayInRect:NSRectFromCGRect( - CGRectApplyAffineTransform(*rect, t))]; + dirtyRect = NSRectFromCGRect(CGRectApplyAffineTransform(*rect, t)); + [view setTkNeedsDisplay:YES]; + [view setTkDirtyRect:NSUnionRect([view tkDirtyRect], dirtyRect)]; break; } return noErr; @@ -1275,16 +1283,15 @@ TkMacOSXInvalClipRgns( * * TkMacOSXWinBounds -- * - * Given a Tk window this function determines the windows bounds in - * relation to the Macintosh window's coordinate system. This is also the - * same coordinate system as the Tk toplevel window in which this window - * is contained. + * Given a Tk window this function determines the window's bounds in + * the coordinate system of the Tk toplevel window in which this window + * is contained. This fills in a Rect struct. * * Results: * None. * * Side effects: - * None. + * Fills in a Rect. * *---------------------------------------------------------------------- */ @@ -1307,16 +1314,15 @@ TkMacOSXWinBounds( * * TkMacOSXWinCGBounds -- * - * Given a Tk window this function determines the windows bounds in - * relation to the Macintosh window's coordinate system. This is also the - * same coordinate system as the Tk toplevel window in which this window - * is contained. + * Given a Tk window this function determines the window's bounds in + * the coordinate system of the Tk toplevel window in which this window + * is contained. This fills in a CGRect struct. * * Results: * None. * * Side effects: - * None. + * Fill in a CGRect. * *---------------------------------------------------------------------- */ @@ -1331,6 +1337,39 @@ TkMacOSXWinCGBounds( bounds->size.width = winPtr->changes.width; bounds->size.height = winPtr->changes.height; } +/* + *---------------------------------------------------------------------- + * + * TkMacOSXWinNSBounds -- + * + * Given a Tk window this function determines the window's bounds in + * the coordinate system of the TKContentView in which this Tk window + * is contained, which has the origin at the lower left corner. This + * fills in an NSRect struct and requires the TKContentView as a + * parameter + * + * Results: + * None. + * + * Side effects: + * Fills in an NSRect. + * + *---------------------------------------------------------------------- + */ + +void +TkMacOSXWinNSBounds( + TkWindow *winPtr, + NSView *view, + NSRect *bounds) +{ + bounds->size.width = winPtr->changes.width; + bounds->size.height = winPtr->changes.height; + bounds->origin.x = winPtr->privatePtr->xOff; + bounds->origin.y = ([view bounds].size.height - + bounds->size.height - + winPtr->privatePtr->yOff); +} /* *---------------------------------------------------------------------- diff --git a/macosx/tkMacOSXWindowEvent.c b/macosx/tkMacOSXWindowEvent.c index 76b2b04..6e8f7c4 100644 --- a/macosx/tkMacOSXWindowEvent.c +++ b/macosx/tkMacOSXWindowEvent.c @@ -30,8 +30,8 @@ * Declaration of functions used only in this file */ -static int GenerateUpdates(HIShapeRef updateRgn, - CGRect *updateBounds, TkWindow *winPtr); +static int GenerateUpdates( + CGRect *updateBounds, TkWindow *winPtr); static int GenerateActivateEvents(TkWindow *winPtr, int activeFlag); static void DoWindowActivate(ClientData clientData); @@ -407,16 +407,29 @@ extern NSString *NSWindowDidOrderOffScreenNotification; int TkpAppCanDraw(Tk_Window tkwin) { - if (![NSApp isDrawing]) { - return 0; - } + int result; if (tkwin) { TkWindow *winPtr = (TkWindow *)tkwin; - NSView *view = TkMacOSXDrawableView(winPtr->privatePtr); - return (view == [NSView focusView]); + TKContentView *view = (TKContentView *) TkMacOSXDrawableView( + winPtr->privatePtr); + result = ([NSApp isDrawing] && view == [NSView focusView]); +#if 0 + printf("TkAppCanDraw: %s %d %d \n", Tk_PathName(tkwin), + [NSApp isDrawing], (view == [NSView focusView])); + if (!result) { + NSRect dirtyRect; + TkMacOSXWinNSBounds(winPtr, view, &dirtyRect); + printf("TkpAppCanDraw: dirtyRect for %s is %s\n", + Tk_PathName(tkwin), + NSStringFromRect(dirtyRect).UTF8String); + [view setTkNeedsDisplay:YES]; + [view setTkDirtyRect:dirtyRect]; + } +#endif } else { - return 1; + result = [NSApp isDrawing]; } + return result; } /* @@ -424,9 +437,9 @@ TkpAppCanDraw(Tk_Window tkwin) { * * GenerateUpdates -- * - * Given a Macintosh update region and a Tk window this function geneates + * Given an update rectangle and a Tk window, this function geneates * an X Expose event for the window if it meets the update region. The - * function will then recursivly have each damaged window generate Expose + * function will then recursively have each damaged window generate Expose * events for its child windows. * * Results: @@ -440,39 +453,23 @@ TkpAppCanDraw(Tk_Window tkwin) { static int GenerateUpdates( - HIShapeRef updateRgn, CGRect *updateBounds, TkWindow *winPtr) { TkWindow *childPtr; XEvent event; CGRect bounds, damageBounds; - HIShapeRef boundsRgn, damageRgn; TkMacOSXWinCGBounds(winPtr, &bounds); if (!CGRectIntersectsRect(bounds, *updateBounds)) { return 0; } - if (!HIShapeIntersectsRect(updateRgn, &bounds)) { - return 0; - } /* * Compute the bounding box of the area that the damage occured in. */ - boundsRgn = HIShapeCreateWithRect(&bounds); - damageRgn = HIShapeCreateIntersection(updateRgn, boundsRgn); - if (HIShapeIsEmpty(damageRgn)) { - CFRelease(damageRgn); - CFRelease(boundsRgn); - return 0; - } - HIShapeGetBounds(damageRgn, &damageBounds); - - CFRelease(damageRgn); - CFRelease(boundsRgn); - + damageBounds = CGRectIntersection(bounds, *updateBounds); event.xany.serial = LastKnownRequestProcessed(Tk_Display(winPtr)); event.xany.send_event = false; event.xany.window = Tk_WindowId(winPtr); @@ -486,7 +483,7 @@ GenerateUpdates( Tk_QueueWindowEvent(&event, TCL_QUEUE_TAIL); #ifdef TK_MAC_DEBUG_DRAWING - TKLog(@"Expose %p {{%d, %d}, {%d, %d}}", event.xany.window, event.xexpose.x, + TKLog(@"Exposed %p {{%d, %d}, {%d, %d}}", event.xany.window, event.xexpose.x, event.xexpose.y, event.xexpose.width, event.xexpose.height); #endif @@ -499,7 +496,7 @@ GenerateUpdates( if (!Tk_IsMapped(childPtr) || Tk_IsTopLevel(childPtr)) { continue; } - GenerateUpdates(updateRgn, updateBounds, childPtr); + GenerateUpdates(updateBounds, childPtr); } /* @@ -509,7 +506,7 @@ GenerateUpdates( if (Tk_IsContainer(winPtr)) { childPtr = TkpGetOtherWindow(winPtr); if (childPtr != NULL && Tk_IsMapped(childPtr)) { - GenerateUpdates(updateRgn, updateBounds, childPtr); + GenerateUpdates(updateBounds, childPtr); } /* @@ -928,10 +925,10 @@ ConfigureRestrictProc( */ static void -RedisplayView( +RedisplayView( ClientData clientdata) { - NSView *view = (NSView *) clientdata; + TKContentView *view = (TKContentView *) clientdata; /* * Make sure that we are not trying to displaying a view that no longer @@ -941,7 +938,8 @@ RedisplayView( for (NSWindow *w in [NSApp windows]) { if ([w contentView] == view) { - [view setNeedsDisplay:YES]; + [view setTkNeedsDisplay:YES]; + [view setTkDirtyRect:[view bounds]]; break; } } @@ -951,13 +949,13 @@ RedisplayView( - (void) drawRect: (NSRect) rect { - const NSRect *rectsBeingDrawn; - NSInteger rectsBeingDrawnCount; #ifdef TK_MAC_DEBUG_DRAWING TkWindow *winPtr = TkMacOSXGetTkWindow([self window]); - if (winPtr) fprintf(stderr, "drawRect: drawing %s\n", - Tk_PathName(winPtr)); + if (winPtr) { + fprintf(stderr, "drawRect: drawing %s in %s\n", + Tk_PathName(winPtr), NSStringFromRect(rect).UTF8String); + } #endif /* @@ -974,23 +972,11 @@ RedisplayView( [NSApp setIsDrawing: YES]; - [self getRectsBeingDrawn:&rectsBeingDrawn count:&rectsBeingDrawnCount]; - CGFloat height = [self bounds].size.height; - HIMutableShapeRef drawShape = HIShapeCreateMutable(); - - while (rectsBeingDrawnCount--) { - CGRect r = NSRectToCGRect(*rectsBeingDrawn++); - #ifdef TK_MAC_DEBUG_DRAWING - fprintf(stderr, "drawRect: %dx%d@(%d,%d)\n", (int)r.size.width, - (int)r.size.height, (int)r.origin.x, (int)r.origin.y); + fprintf(stderr, "drawRect: %s\n", NSStringFromRect(rect).UTF8String; #endif - r.origin.y = height - (r.origin.y + r.size.height); - HIShapeUnionWithRect(drawShape, &r); - } - [self generateExposeEvents:(HIShapeRef)drawShape]; - CFRelease(drawShape); + [self generateExposeEvents:rect]; [NSApp setIsDrawing: NO]; if ([self needsRedisplay]) { @@ -998,6 +984,9 @@ RedisplayView( Tcl_DoWhenIdle(RedisplayView, self); } + [self setTkNeedsDisplay:NO]; + [self setTkDirtyRect:NSZeroRect]; + #ifdef TK_MAC_DEBUG_DRAWING fprintf(stderr, "drawRect: done.\n"); #endif @@ -1056,9 +1045,7 @@ RedisplayView( * Generate and process expose events to redraw the window. */ - HIRect bounds = NSRectToCGRect([self bounds]); - HIShapeRef shape = HIShapeCreateWithRect(&bounds); - [self generateExposeEvents: shape]; + [self generateExposeEvents: [self bounds]]; [w displayIfNeeded]; /* @@ -1076,11 +1063,11 @@ RedisplayView( * pending idle events are processed so the drawing will actually take place. */ -- (void) generateExposeEvents: (HIShapeRef) shape +- (void) generateExposeEvents: (NSRect) rect { unsigned long serial; - CGRect updateBounds; int updatesNeeded; + CGRect updateBounds; TkWindow *winPtr = TkMacOSXGetTkWindow([self window]); ClientData oldArg; Tk_RestrictProc *oldProc; @@ -1089,20 +1076,18 @@ RedisplayView( } /* - * Generate Tk Expose events. - */ - - HIShapeGetBounds(shape, &updateBounds); - - /* - * All of these events will share the same serial number. + * Generate Tk Expose events. All of these events will share the same + * serial number. */ - - serial = LastKnownRequestProcessed(Tk_Display(winPtr)); - updatesNeeded = GenerateUpdates(shape, &updateBounds, winPtr); - + + updateBounds = NSRectToCGRect(rect); + updateBounds.origin.y = ([self bounds].size.height - updateBounds.origin.y + - updateBounds.size.height); + updatesNeeded = GenerateUpdates(&updateBounds, winPtr); if (updatesNeeded) { + serial = LastKnownRequestProcessed(Tk_Display(winPtr)); + /* * First process all of the Expose events. */ @@ -1120,9 +1105,10 @@ RedisplayView( * effect.) * * Fortunately, Tk schedules all drawing to be done while Tcl is idle. - * So we can do the drawing by processing all of the idle events that - * were created when the expose events were processed. + * So we can do the drawing now by processing all of the idle events + * that were created when the expose events were processed. */ + while (Tcl_DoOneEvent(TCL_IDLE_EVENTS)) {} } } @@ -1202,10 +1188,15 @@ RedisplayView( - (BOOL) isOpaque { NSWindow *w = [self window]; - return (w && (([w styleMask] & NSTexturedBackgroundWindowMask) || - ![w isOpaque]) ? NO : YES); + return (w && (([w styleMask] & NSTexturedBackgroundWindowMask) || + ![w isOpaque]) ? NO : YES); } +/* + * On Catalina this is never called and drawRect clips to the rect that + * is passed to it by AppKit. + */ + - (BOOL) wantsDefaultClipping { return NO; diff --git a/macosx/tkMacOSXWm.c b/macosx/tkMacOSXWm.c index cab2b9a..1b51479 100644 --- a/macosx/tkMacOSXWm.c +++ b/macosx/tkMacOSXWm.c @@ -6201,13 +6201,14 @@ TkpRedrawWidget(Tk_Window tkwin) { } w = TkMacOSXDrawableWindow(winPtr->window); if (w) { - NSView *view = [w contentView]; + TKContentView *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]; + [view setTkNeedsDisplay:YES]; + [view setTkDirtyRect:bounds]; } } -- cgit v0.12 From 11b02278eef59eb2b8412727e92256477ea6188b Mon Sep 17 00:00:00 2001 From: culler Date: Sun, 31 May 2020 21:19:29 +0000 Subject: Add some methods for managing damage rectangles. --- generic/tkCanvas.c | 3 --- macosx/tkMacOSXDraw.c | 10 ++++------ macosx/tkMacOSXPrivate.h | 3 ++- macosx/tkMacOSXSubwindows.c | 5 ++--- macosx/tkMacOSXWindowEvent.c | 23 +++++++++++++++++------ 5 files changed, 25 insertions(+), 19 deletions(-) diff --git a/generic/tkCanvas.c b/generic/tkCanvas.c index 941e7d2..4d68ade 100644 --- a/generic/tkCanvas.c +++ b/generic/tkCanvas.c @@ -2577,9 +2577,6 @@ DisplayCanvas( #else canvasPtr->drawableXOrigin = canvasPtr->xOrigin; canvasPtr->drawableYOrigin = canvasPtr->yOrigin; -#if 0 - TkpAppCanDraw(tkwin); -#endif pixmap = Tk_WindowId(tkwin); TkpClipDrawableToRect(Tk_Display(tkwin), pixmap, screenX1 - canvasPtr->xOrigin, screenY1 - canvasPtr->yOrigin, diff --git a/macosx/tkMacOSXDraw.c b/macosx/tkMacOSXDraw.c index d2d72e4..dcc3d79 100644 --- a/macosx/tkMacOSXDraw.c +++ b/macosx/tkMacOSXDraw.c @@ -1646,15 +1646,13 @@ TkMacOSXSetupDrawingContext( if (![NSApp isDrawing] || view != [NSView focusView]) { NSRect dirtyRect = [view bounds]; if (dc.clipRgn) { - CGRect clipRect; CGAffineTransform t = { .a = 1, .b = 0, .c = 0, .d = -1, .tx = 0, .ty = dirtyRect.size.height}; - HIShapeGetBounds(dc.clipRgn, &clipRect); - clipRect = CGRectApplyAffineTransform(clipRect, t); - dirtyRect = NSRectFromCGRect(clipRect); + HIShapeGetBounds(dc.clipRgn, &clipBounds); + clipBounds = CGRectApplyAffineTransform(clipBounds, t); + dirtyRect = NSRectFromCGRect(clipBounds); } - [view setTkNeedsDisplay:YES]; - [view setTkDirtyRect:NSUnionRect([view tkDirtyRect], dirtyRect)]; + [view addTkDirtyRect:dirtyRect]; canDraw = false; goto end; } diff --git a/macosx/tkMacOSXPrivate.h b/macosx/tkMacOSXPrivate.h index fdd07ed..11dee7c 100644 --- a/macosx/tkMacOSXPrivate.h +++ b/macosx/tkMacOSXPrivate.h @@ -434,7 +434,8 @@ VISIBILITY_HIDDEN @end @interface TKContentView(TKWindowEvent) - //(HIShapeRef) shape; +- (void) addTkDirtyRect: (NSRect) rect; +- (void) clearTkDirtyRect; - (void) generateExposeEvents: (NSRect) rect; - (void) tkToolbarButton: (id) sender; @end diff --git a/macosx/tkMacOSXSubwindows.c b/macosx/tkMacOSXSubwindows.c index 53e5bf6..c25f600 100644 --- a/macosx/tkMacOSXSubwindows.c +++ b/macosx/tkMacOSXSubwindows.c @@ -994,7 +994,7 @@ InvalViewRect( static CGAffineTransform t; TKContentView *view = ref; NSRect dirtyRect; - + if (!view) { return paramErr; } @@ -1005,8 +1005,7 @@ InvalViewRect( break; case kHIShapeEnumerateRect: dirtyRect = NSRectFromCGRect(CGRectApplyAffineTransform(*rect, t)); - [view setTkNeedsDisplay:YES]; - [view setTkDirtyRect:NSUnionRect([view tkDirtyRect], dirtyRect)]; + [view addTkDirtyRect:dirtyRect]; break; } return noErr; diff --git a/macosx/tkMacOSXWindowEvent.c b/macosx/tkMacOSXWindowEvent.c index 5619454..6c7e9ff 100644 --- a/macosx/tkMacOSXWindowEvent.c +++ b/macosx/tkMacOSXWindowEvent.c @@ -399,8 +399,8 @@ extern NSString *NSWindowDidOrderOffScreenNotification; * tkwin NULL or pointing to a widget in the current focusView. * * Side effects: - * The tkwin parameter may be recorded to handle redrawing the widget - * later. + * Currently none. One day the tkwin parameter may be recorded to + * handle redrawing the widget later. * *---------------------------------------------------------------------- */ @@ -925,7 +925,7 @@ ConfigureRestrictProc( */ static void -RedisplayView( +RedisplayView( ClientData clientdata) { TKContentView *view = (TKContentView *) clientdata; @@ -947,6 +947,18 @@ RedisplayView( @implementation TKContentView(TKWindowEvent) +- (void) addTkDirtyRect: (NSRect) rect +{ + _tkNeedsDisplay = YES; + _tkDirtyRect = NSUnionRect(_tkDirtyRect, rect); +} + +- (void) clearTkDirtyRect +{ + _tkNeedsDisplay = NO; + _tkDirtyRect = NSZeroRect; +} + - (void) drawRect: (NSRect) rect { @@ -984,8 +996,7 @@ RedisplayView( Tcl_DoWhenIdle(RedisplayView, self); } - [self setTkNeedsDisplay:NO]; - [self setTkDirtyRect:NSZeroRect]; + [self clearTkDirtyRect]; #ifdef TK_MAC_DEBUG_DRAWING fprintf(stderr, "drawRect: done.\n"); @@ -1079,7 +1090,7 @@ RedisplayView( * Generate Tk Expose events. All of these events will share the same * serial number. */ - + updateBounds = NSRectToCGRect(rect); updateBounds.origin.y = ([self bounds].size.height - updateBounds.origin.y - updateBounds.size.height); -- cgit v0.12 From aeb89ef62c14b00be0853a7539e807bb3937a6f8 Mon Sep 17 00:00:00 2001 From: culler Date: Mon, 1 Jun 2020 21:34:36 +0000 Subject: Better control over when drawRect runs. Add check for drawing outside of the drawRect clipping rectangle. --- generic/tkFont.c | 2 +- macosx/tkMacOSXDraw.c | 55 +++++++++++++++++++++++------------ macosx/tkMacOSXNotify.c | 68 ++++++++++++++++++++++++++------------------ macosx/tkMacOSXPrivate.h | 1 + macosx/tkMacOSXWindowEvent.c | 40 ++++---------------------- tests/canvImg.test | 8 +----- tests/image.test | 17 ++--------- tests/listbox.test | 4 +-- 8 files changed, 90 insertions(+), 105 deletions(-) diff --git a/generic/tkFont.c b/generic/tkFont.c index e53e3f9..17e0aa9 100644 --- a/generic/tkFont.c +++ b/generic/tkFont.c @@ -880,7 +880,7 @@ TheWorldHasChanged( * This is ignored on other platforms. */ - if (!TkpWillDrawWidget(NULL)) { + if (TkpWillDrawWidget(NULL)) { return; } diff --git a/macosx/tkMacOSXDraw.c b/macosx/tkMacOSXDraw.c index dcc3d79..1ec2cfe 100644 --- a/macosx/tkMacOSXDraw.c +++ b/macosx/tkMacOSXDraw.c @@ -1631,30 +1631,47 @@ TkMacOSXSetupDrawingContext( Tcl_Panic("TkMacOSXSetupDrawingContext(): " "no NSView to draw into !"); } + if (dc.clipRgn) { + CGAffineTransform t = { .a = 1, .b = 0, .c = 0, .d = -1, .tx = 0, + .ty = [view bounds].size.height}; + HIShapeGetBounds(dc.clipRgn, &clipBounds); + clipBounds = CGRectApplyAffineTransform(clipBounds, t); + } + if (![NSApp isDrawing] || view != [NSView focusView]) { - /* - * We can only draw into the view when the current CGContext is valid - * and belongs to the view. Validity can only be guaranteed inside of - * a view's drawRect or setFrame methods. The isDrawing attribute - * tells us whether we are being called from one of those methods. - * - * If the CGContext is not valid then we mark our view as needing - * display. We could try to optimize by computing a smaller dirty rect - * here. - */ + /* + * We can only draw into the view when the current CGContext is + * valid and belongs to the view. Validity can only be guaranteed + * inside of a view's drawRect or setFrame methods. The isDrawing + * attribute tells us whether we are being called from one of those + * methods. If the CGContext is not valid then we mark our view as + * needing display. + */ - if (![NSApp isDrawing] || view != [NSView focusView]) { - NSRect dirtyRect = [view bounds]; if (dc.clipRgn) { - CGAffineTransform t = { .a = 1, .b = 0, .c = 0, .d = -1, .tx = 0, - .ty = dirtyRect.size.height}; - HIShapeGetBounds(dc.clipRgn, &clipBounds); - clipBounds = CGRectApplyAffineTransform(clipBounds, t); - dirtyRect = NSRectFromCGRect(clipBounds); + [view addTkDirtyRect:clipBounds]; + } else { + [view addTkDirtyRect:[view bounds]]; } - [view addTkDirtyRect:dirtyRect]; canDraw = false; goto end; + } else if (dc.clipRgn) { + + /* + * Drawing can also fail when we are being called from drawRect but + * the clipping region set by drawRect does not contain the clipping + * region of our drawing context. See bug [2a61eca3a8]. + */ + + CGRect currentClip = CGContextGetClipBoundingBox( + [NSGraphicsContext currentContext].CGContext); + if (!NSContainsRect(currentClip, clipBounds)) { + [view addTkDirtyRect:clipBounds]; + // XXXX we should be able to skip drawing but sometimes the clipBounds + // are wrong. + //canDraw = false; + //goto end; + } } dc.view = view; @@ -1686,6 +1703,7 @@ TkMacOSXSetupDrawingContext( CGContextSetTextDrawingMode(dc.context, kCGTextFill); CGContextConcatCTM(dc.context, t); if (dc.clipRgn) { + #ifdef TK_MAC_DEBUG_DRAWING CGContextSaveGState(dc.context); ChkErr(HIShapeReplacePathInCGContext, dc.clipRgn, dc.context); @@ -1693,6 +1711,7 @@ TkMacOSXSetupDrawingContext( CGContextEOFillPath(dc.context); CGContextRestoreGState(dc.context); #endif /* TK_MAC_DEBUG_DRAWING */ + CGRect r; if (!HIShapeIsRectangular(dc.clipRgn) || !CGRectContainsRect( diff --git a/macosx/tkMacOSXNotify.c b/macosx/tkMacOSXNotify.c index f8ac50d..7de6bec 100644 --- a/macosx/tkMacOSXNotify.c +++ b/macosx/tkMacOSXNotify.c @@ -307,19 +307,20 @@ TkMacOSXNotifyExitHandler( * is undocumented, namely that it sometimes blocks and calls drawRect * for all views that need display before it returns. We call it with * deQueue=NO so that it will not change anything on the AppKit event - * queue, because we only want the side effect that it runs - * drawRect. This function is the only place where NSViews get the - * needsDisplay property set to YES. + * queue, because we only want the side effect that it runs drawRect. The + * only time when any NSViews have the needsDisplay property set to YES + * is during execution of this function. * - * The reason for running this as an idle task is to try to arrange that - * all widgets will be fully configured before they are drawn. Any idle - * tasks that might reconfigure them should be higher on the idle queue, - * so they should be run before the display procs are run by drawRect. + * The reason for running this function as an idle task is to try to + * arrange that all widgets will be fully configured before they are + * drawn. Any idle tasks that might reconfigure them should be higher on + * the idle queue, so they should be run before the display procs are run + * by drawRect. * - * If this is called directly with non-NULL clientData parameter then the - * int which it references will be set to the number of windows that need - * display, but the needsDisplay property of those windows will not be - * changed. + * If this function is called directly with non-NULL clientData parameter + * then the int which it references will be set to the number of windows + * that need display, but the needsDisplay property of those windows will + * not be changed. * * Results: * None. @@ -330,11 +331,11 @@ TkMacOSXNotifyExitHandler( *---------------------------------------------------------------------- */ -static void +void TkMacOSXDrawAllViews( ClientData clientData) { - int count = 0, *dirtyCount = (int *)clientData; + int count = 0, *dirtyCount = (int *)clientData; for (NSWindow *window in [NSApp windows]) { if ([[window contentView] isMemberOfClass:[TKContentView class]]) { @@ -342,22 +343,37 @@ TkMacOSXDrawAllViews( if ([view tkNeedsDisplay]) { count++; if (dirtyCount) { - continue; + continue; } [view setNeedsDisplayInRect:[view tkDirtyRect]]; + [view setTkDirtyRect:NSZeroRect]; } } else { [window displayIfNeeded]; } } if (dirtyCount) { - *dirtyCount = count; + *dirtyCount = count; } - [NSApp nextEventMatchingMask:NSAnyEventMask untilDate:[NSDate distantPast] inMode:GetRunLoopMode(TkMacOSXGetModalSession()) dequeue:NO]; + for (NSWindow *window in [NSApp windows]) { + if ([[window contentView] isMemberOfClass:[TKContentView class]]) { + TKContentView *view = [window contentView]; + + /* + * If we did not run drawRect, we set needsDisplay back to NO. + * Note that if drawRect did run it may have added to Tk's dirty + * rect, due to attempts to draw outside of drawRect's dirty rect. + */ + + if ([view tkNeedsDisplay]) { + [view setNeedsDisplay: NO]; + } + } + } } /* @@ -399,10 +415,11 @@ TkMacOSXEventsSetupProc( [NSApp _resetAutoreleasePool]; /* - * Call this with dequeue=NO to see if there are any events. If so, - * we set the block time to 0 and stop the heartbeat. Tcl_DoOneEvent - * will call the check proc to collect the events and translate them - * into XEvents. But also, drawRect may run. + * Call this with dequeue=NO to see if there are any events. If so, we + * set the block time to 0 and stop the heartbeat. Next Tcl_DoOneEvent + * will call Tcl_WaitForEvent, which will poll instead of waiting since + * the block time is 0. Then it will call check proc to collect the + * events and translate them into XEvents. */ NSEvent *currentEvent = @@ -428,11 +445,7 @@ TkMacOSXEventsSetupProc( havePeriodicEvents = YES; [NSEvent startPeriodicEventsAfterDelay:0.0 withPeriod:0.1]; } - - /* - * Without this, new windows are sometimes not completely rendered. - */ - while (Tcl_DoOneEvent(TCL_IDLE_EVENTS)) {} + while (Tcl_DoOneEvent(TCL_IDLE_EVENTS)) {}; TkMacOSXDrawAllViews(NULL); } } @@ -521,7 +534,6 @@ TkMacOSXEventsCheckProc( } } } else { - break; } } while (1); @@ -529,8 +541,8 @@ TkMacOSXEventsCheckProc( /* * Now we can unlock the pool. */ - [NSApp _unlockAutoreleasePool]; + [NSApp _unlockAutoreleasePool]; if (eventsFound == 0) { /* @@ -552,7 +564,7 @@ TkMacOSXEventsCheckProc( if (dirtyCount > 0) { Tcl_CancelIdleCall(TkMacOSXDrawAllViews, NULL); Tcl_DoWhenIdle(TkMacOSXDrawAllViews, NULL); - } + } } } } diff --git a/macosx/tkMacOSXPrivate.h b/macosx/tkMacOSXPrivate.h index 11dee7c..719b0b1 100644 --- a/macosx/tkMacOSXPrivate.h +++ b/macosx/tkMacOSXPrivate.h @@ -309,6 +309,7 @@ MODULE_SCOPE int TkMacOSXRegisterServiceWidgetObjCmd(ClientData clientData, MODULE_SCOPE unsigned TkMacOSXAddVirtual(unsigned int keycode); MODULE_SCOPE void TkMacOSXWinNSBounds(TkWindow *winPtr, NSView *view, NSRect *bounds); +MODULE_SCOPE void TkMacOSXDrawAllViews(ClientData clientData); #pragma mark Private Objective-C Classes diff --git a/macosx/tkMacOSXWindowEvent.c b/macosx/tkMacOSXWindowEvent.c index 6c7e9ff..0f58c70 100644 --- a/macosx/tkMacOSXWindowEvent.c +++ b/macosx/tkMacOSXWindowEvent.c @@ -122,7 +122,7 @@ extern NSString *NSWindowDidOrderOffScreenNotification; */ while (Tcl_ServiceEvent(0)) {} - while (Tcl_DoOneEvent(TCL_IDLE_EVENTS|TCL_DONT_WAIT)) {} + while (Tcl_DoOneEvent(TCL_IDLE_EVENTS)) {} /* * NSWindowDidDeminiaturizeNotification is received after @@ -919,32 +919,6 @@ ConfigureRestrictProc( return (eventPtr->type==ConfigureNotify ? TK_PROCESS_EVENT : TK_DEFER_EVENT); } -/* - * If a window gets mapped inside the drawRect method, this will be run as an - * idle task, after drawRect returns, to clean up the mess. - */ - -static void -RedisplayView( - ClientData clientdata) -{ - TKContentView *view = (TKContentView *) clientdata; - - /* - * Make sure that we are not trying to displaying a view that no longer - * exists. Must call [NSApp windows] because [NSApp orderedWindows] excludes - * floating/utility windows and other window panels. - */ - - for (NSWindow *w in [NSApp windows]) { - if ([w contentView] == view) { - [view setTkNeedsDisplay:YES]; - [view setTkDirtyRect:[view bounds]]; - break; - } - } -} - @implementation TKContentView(TKWindowEvent) - (void) addTkDirtyRect: (NSRect) rect @@ -983,21 +957,16 @@ RedisplayView( } [NSApp setIsDrawing: YES]; - -#ifdef TK_MAC_DEBUG_DRAWING - fprintf(stderr, "drawRect: %s\n", NSStringFromRect(rect).UTF8String; -#endif - + [self setTkDirtyRect:NSZeroRect]; [self generateExposeEvents:rect]; + [self setTkNeedsDisplay: NO]; [NSApp setIsDrawing: NO]; if ([self needsRedisplay]) { [self setNeedsRedisplay:NO]; - Tcl_DoWhenIdle(RedisplayView, self); + Tcl_DoWhenIdle(TkMacOSXDrawAllViews, NULL); } - [self clearTkDirtyRect]; - #ifdef TK_MAC_DEBUG_DRAWING fprintf(stderr, "drawRect: done.\n"); #endif @@ -1102,6 +1071,7 @@ RedisplayView( /* * First process all of the Expose events. */ + while (Tcl_ServiceEvent(TCL_IDLE_EVENTS)) {}; oldProc = Tk_RestrictEvents(ExposeRestrictProc, UINT2PTR(serial), &oldArg); while (Tcl_ServiceEvent(TCL_WINDOW_EVENTS)) {}; diff --git a/tests/canvImg.test b/tests/canvImg.test index b60e384..1abea78 100644 --- a/tests/canvImg.test +++ b/tests/canvImg.test @@ -727,12 +727,6 @@ test canvImg-9.1 {DisplayImage procedure} -constraints testImageType -setup { image delete foo } -result {75 150 105 165} -if {[tk windowingsystem] == "aqua" && $tcl_platform(osVersion) > 18} { - # Aqua >= 10.14 will redraw the entire image. - set result_10_1 {{foo display 0 0 30 15}} -} else { - set result_10_1 {{foo display 2 4 6 8}} -} test canvImg-10.1 {TranslateImage procedure} -constraints testImageType -setup { .c delete all update @@ -750,7 +744,7 @@ test canvImg-10.1 {TranslateImage procedure} -constraints testImageType -setup { } -cleanup { .c delete all image delete foo -} -result $result_10_1 +} -result {{foo display 2 4 6 8}} test canvImg-11.1 {TranslateImage procedure} -constraints testImageType -setup { .c delete all diff --git a/tests/image.test b/tests/image.test index da65a66..cac304f 100644 --- a/tests/image.test +++ b/tests/image.test @@ -357,12 +357,6 @@ test image-8.1 {Tk_ImageCmd procedure, "inuse" option} -constraints { catch {destroy .b} } -result [list 0 1] -if {[tk windowingsystem] == "aqua" && $tcl_platform(osVersion) > 18} { - # Aqua >= 10.14 will redraw the entire image in drawRect. - set result_9_1 {{foo display 0 0 30 15}} -} else { - set result_9_1 {{foo display 5 6 7 8}} -} test image-9.1 {Tk_ImageChanged procedure} -constraints testImageType -setup { .c delete all imageCleanup @@ -385,13 +379,8 @@ test image-9.1 {Tk_ImageChanged procedure} -constraints testImageType -setup { } -cleanup { .c delete all imageCleanup -} -result $result_9_1 -if {[tk windowingsystem] == "aqua" && $tcl_platform(osVersion) > 18} { - # Aqua >= 10.14 will redraw the entire image. - set result_9_2 {{foo display 0 0 30 15} {foo display 0 0 30 15}} -} else { - set result_9_2 {{foo display 5 6 25 9} {foo display 0 0 12 14}} -} +} -result {{foo display 5 6 7 8}} + test image-9.2 {Tk_ImageChanged procedure} -constraints testImageType -setup { .c delete all imageCleanup @@ -411,7 +400,7 @@ test image-9.2 {Tk_ImageChanged procedure} -constraints testImageType -setup { } -cleanup { .c delete all imageCleanup -} -result $result_9_2 +} -result {{foo display 5 6 25 9} {foo display 0 0 12 14}} test image-10.1 {Tk_GetImage procedure} -setup { imageCleanup diff --git a/tests/listbox.test b/tests/listbox.test index 14c5c97..8d4ed33 100644 --- a/tests/listbox.test +++ b/tests/listbox.test @@ -2800,13 +2800,13 @@ test listbox-21.16 {ListboxListVarProc, update vertical scrollbar} -setup { test listbox-22.1 {UpdateHScrollbar} -setup { destroy .l } -body { - listbox .l -font $fixed -width 10 -xscrollcommand "record x" set log {} + listbox .l -font $fixed -width 10 -xscrollcommand "record x" pack .l set timeout [after 500 {set log timeout}] vwait log .l insert end "0000000000" - update + update idletasks .l insert end "00000000000000000000" vwait log set log -- cgit v0.12 From 876fc6d65e63ae72fe52d8435ef703efa50fe814 Mon Sep 17 00:00:00 2001 From: marc_culler Date: Wed, 3 Jun 2020 03:23:12 +0000 Subject: Do not draw in the setup proc. Fix the heartbeat so it can wake up Tcl_WaitForEvent. Handle the first drawing of a window. --- macosx/tkMacOSXDraw.c | 22 ++++++------ macosx/tkMacOSXNotify.c | 84 +++++++++++++++++++++++--------------------- macosx/tkMacOSXWindowEvent.c | 21 ++++++++--- 3 files changed, 71 insertions(+), 56 deletions(-) diff --git a/macosx/tkMacOSXDraw.c b/macosx/tkMacOSXDraw.c index 1ec2cfe..6a63449 100644 --- a/macosx/tkMacOSXDraw.c +++ b/macosx/tkMacOSXDraw.c @@ -1658,19 +1658,19 @@ TkMacOSXSetupDrawingContext( } else if (dc.clipRgn) { /* - * Drawing can also fail when we are being called from drawRect but - * the clipping region set by drawRect does not contain the clipping - * region of our drawing context. See bug [2a61eca3a8]. + * Drawing will also fail if we are being called from drawRect but + * the clipping rectangle set by drawRect does not contain the + * clipping region of our drawing context. See bug [2a61eca3a8]. + * If we can't draw all of the clipping region of the drawing + * context then we draw whatever we can, but we also add a dirty + * rectangle so the entire widget will get redrawn in the next + * cycle. */ CGRect currentClip = CGContextGetClipBoundingBox( [NSGraphicsContext currentContext].CGContext); if (!NSContainsRect(currentClip, clipBounds)) { [view addTkDirtyRect:clipBounds]; - // XXXX we should be able to skip drawing but sometimes the clipBounds - // are wrong. - //canDraw = false; - //goto end; } } @@ -1715,10 +1715,10 @@ TkMacOSXSetupDrawingContext( CGRect r; if (!HIShapeIsRectangular(dc.clipRgn) || !CGRectContainsRect( - *HIShapeGetBounds(dc.clipRgn, &r), - CGRectApplyAffineTransform(clipBounds, t))) { - ChkErr(HIShapeReplacePathInCGContext, dc.clipRgn, dc.context); - CGContextEOClip(dc.context); + *HIShapeGetBounds(dc.clipRgn, &r), + CGRectApplyAffineTransform(clipBounds, t))) { + ChkErr(HIShapeReplacePathInCGContext, dc.clipRgn, dc.context); + CGContextEOClip(dc.context); } } if (gc) { diff --git a/macosx/tkMacOSXNotify.c b/macosx/tkMacOSXNotify.c index 7de6bec..8bf5e66 100644 --- a/macosx/tkMacOSXNotify.c +++ b/macosx/tkMacOSXNotify.c @@ -398,12 +398,24 @@ TkMacOSXDrawAllViews( *---------------------------------------------------------------------- */ +#define TICK 100 +static Tcl_TimerToken ticker = NULL; + +static void +Heartbeat( + ClientData clientData) +{ + + if (ticker) { + ticker = Tcl_CreateTimerHandler(TICK, Heartbeat, NULL); + } +} + static void TkMacOSXEventsSetupProc( ClientData clientData, int flags) { - static Bool havePeriodicEvents = NO; NSString *runloopMode = [[NSRunLoop currentRunLoop] currentMode]; /* @@ -412,6 +424,7 @@ TkMacOSXEventsSetupProc( if (flags & TCL_WINDOW_EVENTS && !runloopMode) { static const Tcl_Time zeroBlockTime = { 0, 0 }; + [NSApp _resetAutoreleasePool]; /* @@ -427,26 +440,21 @@ TkMacOSXEventsSetupProc( untilDate:[NSDate distantPast] inMode:GetRunLoopMode(TkMacOSXGetModalSession()) dequeue:NO]; - if (currentEvent) { - if (currentEvent.type > 0) { + if (currentEvent && currentEvent.type > 0) { Tcl_SetMaxBlockTime(&zeroBlockTime); - [NSEvent stopPeriodicEvents]; - havePeriodicEvents = NO; - } - } else if (!havePeriodicEvents){ - - /* - * When the user is not generating events we schedule a "heartbeat" - * event to fire every 0.1 seconds. This helps to make the vwait - * command more responsive when there is no user input, e.g. when - * running the test suite. - */ - - havePeriodicEvents = YES; - [NSEvent startPeriodicEventsAfterDelay:0.0 withPeriod:0.1]; - } - while (Tcl_DoOneEvent(TCL_IDLE_EVENTS)) {}; - TkMacOSXDrawAllViews(NULL); + Tcl_DeleteTimerHandler(ticker); + ticker = NULL; + } else if (ticker == NULL) { + + /* + * When the user is not generating events we schedule a "heartbeat" + * TimerHandler to fire every 200 milliseconds. The handler does + * nothing, but when its timer fires TclWaitForEvent will return, + * causing TkMacOSXCheckProc to be called. + */ + + ticker = Tcl_CreateTimerHandler(TICK, Heartbeat, NULL); + } } } @@ -543,28 +551,24 @@ TkMacOSXEventsCheckProc( */ [NSApp _unlockAutoreleasePool]; - if (eventsFound == 0) { - /* - * We found no events for Tcl in this iteration of the Tcl event - * loop, so it should proceed to servicing idle tasks. We add an - * idle task to the end of the idle queue which will redisplay all - * of our dirty windows. We want this to happen after all other - * idle tasks have run so that all widgets will be configured - * before they are displayed. The drawRect method "borrows" the - * idle queue while drawing views. That is, it sends expose events - * which cause display procs to be posted as idle tasks and then - * runs an inner event loop to processes those idle tasks. We are - * trying to arrange for the idle queue to be empty when it starts - * that process and empty when it finishes. - */ + /* + * Add an idle task to the end of the idle queue which will redisplay + * all of our dirty windows. We want this to happen after all other + * idle tasks have run so that all widgets will be configured before + * they are displayed. The drawRect method "borrows" the idle queue + * while drawing views. That is, it sends expose events which cause + * display procs to be posted as idle tasks and then runs an inner + * event loop to processes those idle tasks. We are trying to arrange + * for the idle queue to be empty when it starts that process and empty + * when it finishes. + */ - int dirtyCount = 0; - TkMacOSXDrawAllViews(&dirtyCount); - if (dirtyCount > 0) { - Tcl_CancelIdleCall(TkMacOSXDrawAllViews, NULL); - Tcl_DoWhenIdle(TkMacOSXDrawAllViews, NULL); - } + int dirtyCount = 0; + TkMacOSXDrawAllViews(&dirtyCount); + if (dirtyCount > 0) { + Tcl_CancelIdleCall(TkMacOSXDrawAllViews, NULL); + Tcl_DoWhenIdle(TkMacOSXDrawAllViews, NULL); } } } diff --git a/macosx/tkMacOSXWindowEvent.c b/macosx/tkMacOSXWindowEvent.c index 0f58c70..d052005 100644 --- a/macosx/tkMacOSXWindowEvent.c +++ b/macosx/tkMacOSXWindowEvent.c @@ -38,6 +38,8 @@ static void DoWindowActivate(ClientData clientData); #pragma mark TKApplication(TKWindowEvent) +extern NSString *NSWindowDidOrderOnScreenNotification; + #ifdef TK_MAC_DEBUG_NOTIFICATIONS extern NSString *NSWindowWillOrderOnScreenNotification; extern NSString *NSWindowDidOrderOnScreenNotification; @@ -208,6 +210,18 @@ extern NSString *NSWindowDidOrderOffScreenNotification; return (winPtr ? NO : YES); } +- (void) windowBecameVisible: (NSNotification *) notification +{ + NSWindow *window = [notification object]; + TkWindow *winPtr = TkMacOSXGetTkWindow(window); + if (winPtr) { + TKContentView *view = [window contentView]; + while(Tcl_DoOneEvent(TCL_IDLE_EVENTS)) {}; + [view setTkDirtyRect:[view bounds]]; + TkMacOSXDrawAllViews(NULL); + } +} + #ifdef TK_MAC_DEBUG_NOTIFICATIONS - (void) windowDragStart: (NSNotification *) notification @@ -227,16 +241,12 @@ extern NSString *NSWindowDidOrderOffScreenNotification; NSWindow *w = [notification object]; TkWindow *winPtr = TkMacOSXGetTkWindow(w); + printf("windowMapped\n"); if (winPtr) { //Tk_MapWindow((Tk_Window) winPtr); } } -- (void) windowBecameVisible: (NSNotification *) notification -{ - TKLog(@"-[%@(%p) %s] %@", [self class], self, _cmd, notification); -} - - (void) windowUnmapped: (NSNotification *) notification { TKLog(@"-[%@(%p) %s] %@", [self class], self, _cmd, notification); @@ -263,6 +273,7 @@ extern NSString *NSWindowDidOrderOffScreenNotification; observe(NSWindowDidResizeNotification, windowBoundsChanged:); observe(NSWindowDidDeminiaturizeNotification, windowExpanded:); observe(NSWindowDidMiniaturizeNotification, windowCollapsed:); + observe(NSWindowDidOrderOnScreenNotification, windowBecameVisible:); #if !(MAC_OS_X_VERSION_MAX_ALLOWED < 1070) observe(NSWindowDidEnterFullScreenNotification, windowEnteredFullScreen:); -- cgit v0.12 From f31664f2a7c475db0fcb646accf6f58d78407da8 Mon Sep 17 00:00:00 2001 From: culler Date: Fri, 5 Jun 2020 18:00:00 +0000 Subject: Fixed a bug in TkpDrawAllViews and added a mechanism to prevent Tcl_WaitForEvent from blocking if there is drawing that needs to be done. --- macosx/tkMacOSXDraw.c | 5 ++--- macosx/tkMacOSXNotify.c | 41 ++++++++++++++++++++++------------------- macosx/tkMacOSXPrivate.h | 2 ++ macosx/tkMacOSXSubwindows.c | 9 +++------ macosx/tkMacOSXWindowEvent.c | 9 +++++---- tests/listbox.test | 21 ++++++++------------- 6 files changed, 42 insertions(+), 45 deletions(-) diff --git a/macosx/tkMacOSXDraw.c b/macosx/tkMacOSXDraw.c index 6a63449..f3d6ba4 100644 --- a/macosx/tkMacOSXDraw.c +++ b/macosx/tkMacOSXDraw.c @@ -176,7 +176,7 @@ TkMacOSXBitmapRepFromDrawableRect( } } else if (TkMacOSXDrawableView(mac_drawable) != NULL) { TKContentView *tkview = (TKContentView *)view; - + /* * Convert Tk top-left to NSView bottom-left coordinates. */ @@ -199,8 +199,7 @@ TkMacOSXBitmapRepFromDrawableRect( [view cacheDisplayInRect:view_rect toBitmapImageRep:bitmap_rep]; } else { TkMacOSXDbgMsg("No CGContext - cannot copy from screen to bitmap."); - [tkview setTkNeedsDisplay:YES]; - [tkview setTkDirtyRect:[tkview bounds]]; + [tkview addTkDirtyRect:[tkview bounds]]; return NULL; } } else { diff --git a/macosx/tkMacOSXNotify.c b/macosx/tkMacOSXNotify.c index 8bf5e66..daa1321 100644 --- a/macosx/tkMacOSXNotify.c +++ b/macosx/tkMacOSXNotify.c @@ -346,7 +346,6 @@ TkMacOSXDrawAllViews( continue; } [view setNeedsDisplayInRect:[view tkDirtyRect]]; - [view setTkDirtyRect:NSZeroRect]; } } else { [window displayIfNeeded]; @@ -374,6 +373,7 @@ TkMacOSXDrawAllViews( } } } + [NSApp setNeedsToDraw:NO]; } /* @@ -392,13 +392,14 @@ TkMacOSXDrawAllViews( * * Side effects: * - * If NSEvents are queued, then the maximum block time will be set to 0 to - * ensure that control returns immediately to Tcl. + * If NSEvents are queued, or if there is any drawing that needs to be + * done, then the maximum block time will be set to 0 to ensure that + * Tcl_WaitForEvent returns immediately. * *---------------------------------------------------------------------- */ -#define TICK 100 +#define TICK 200 static Tcl_TimerToken ticker = NULL; static void @@ -428,11 +429,13 @@ TkMacOSXEventsSetupProc( [NSApp _resetAutoreleasePool]; /* - * Call this with dequeue=NO to see if there are any events. If so, we - * set the block time to 0 and stop the heartbeat. Next Tcl_DoOneEvent - * will call Tcl_WaitForEvent, which will poll instead of waiting since - * the block time is 0. Then it will call check proc to collect the + * After calling this setup proc, Tcl_DoOneEvent will call + * Tcl_WaitForEvent. Then it will call check proc to collect the * events and translate them into XEvents. + * + * If we have any events waiting or if there is any drawing to be done + * we want Tcl_WaitForEvent to return immediately. So we set the block + * time to 0. We also stop the heartbeat, since we won't need it. */ NSEvent *currentEvent = @@ -440,21 +443,21 @@ TkMacOSXEventsSetupProc( untilDate:[NSDate distantPast] inMode:GetRunLoopMode(TkMacOSXGetModalSession()) dequeue:NO]; - if (currentEvent && currentEvent.type > 0) { - Tcl_SetMaxBlockTime(&zeroBlockTime); - Tcl_DeleteTimerHandler(ticker); - ticker = NULL; + if ((currentEvent) || [NSApp needsToDraw] ) { + Tcl_SetMaxBlockTime(&zeroBlockTime); + Tcl_DeleteTimerHandler(ticker); + ticker = NULL; } else if (ticker == NULL) { - /* - * When the user is not generating events we schedule a "heartbeat" - * TimerHandler to fire every 200 milliseconds. The handler does - * nothing, but when its timer fires TclWaitForEvent will return, - * causing TkMacOSXCheckProc to be called. - */ + /* + * When the user is not generating events we schedule a "heartbeat" + * TimerHandler to fire every 200 milliseconds. The handler does + * nothing, but when its timer fires it causes Tcl_WaitForEvent to + * return. This helps avoid hangs when calling vwait. + */ ticker = Tcl_CreateTimerHandler(TICK, Heartbeat, NULL); - } + } } } diff --git a/macosx/tkMacOSXPrivate.h b/macosx/tkMacOSXPrivate.h index 719b0b1..40bbd9c 100644 --- a/macosx/tkMacOSXPrivate.h +++ b/macosx/tkMacOSXPrivate.h @@ -345,11 +345,13 @@ VISIBILITY_HIDDEN int _poolLock; int _macMinorVersion; Bool _isDrawing; + Bool _needsToDraw; #endif } @property int poolLock; @property int macMinorVersion; @property Bool isDrawing; +@property Bool needsToDraw; @end @interface TKApplication(TKInit) diff --git a/macosx/tkMacOSXSubwindows.c b/macosx/tkMacOSXSubwindows.c index c25f600..bf59901 100644 --- a/macosx/tkMacOSXSubwindows.c +++ b/macosx/tkMacOSXSubwindows.c @@ -170,8 +170,7 @@ XMapWindow( TkMacOSXApplyWindowAttributes(winPtr, win); [win setExcludedFromWindowsMenu:NO]; [NSApp activateIgnoringOtherApps:NO]; - [view setTkNeedsDisplay:YES]; - [view setTkDirtyRect: [view bounds]]; + [view addTkDirtyRect: [view bounds]]; if ([win canBecomeKeyWindow]) { [win makeKeyAndOrderFront:NSApp]; } else { @@ -218,8 +217,7 @@ XMapWindow( [[win contentView] setNeedsRedisplay:YES]; } else { TKContentView *view = [win contentView]; - [view setTkNeedsDisplay:YES]; - [view setTkDirtyRect:[view bounds]]; + [view addTkDirtyRect:[view bounds]]; } /* @@ -337,8 +335,7 @@ XUnmapWindow( [[win contentView] setNeedsRedisplay:YES]; } else { TKContentView *view = [win contentView]; - [view setTkNeedsDisplay:YES]; - [view setTkDirtyRect:[view bounds]]; + [view addTkDirtyRect:[view bounds]]; } return Success; } diff --git a/macosx/tkMacOSXWindowEvent.c b/macosx/tkMacOSXWindowEvent.c index d052005..b5e6ee3 100644 --- a/macosx/tkMacOSXWindowEvent.c +++ b/macosx/tkMacOSXWindowEvent.c @@ -217,7 +217,7 @@ extern NSString *NSWindowDidOrderOffScreenNotification; if (winPtr) { TKContentView *view = [window contentView]; while(Tcl_DoOneEvent(TCL_IDLE_EVENTS)) {}; - [view setTkDirtyRect:[view bounds]]; + [view addTkDirtyRect:[view bounds]]; TkMacOSXDrawAllViews(NULL); } } @@ -433,8 +433,7 @@ TkpWillDrawWidget(Tk_Window tkwin) { printf("TkpAppCanDraw: dirtyRect for %s is %s\n", Tk_PathName(tkwin), NSStringFromRect(dirtyRect).UTF8String); - [view setTkNeedsDisplay:YES]; - [view setTkDirtyRect:dirtyRect]; + [view addTkDirtyRect:dirtyRect]; } #endif } else { @@ -936,12 +935,14 @@ ConfigureRestrictProc( { _tkNeedsDisplay = YES; _tkDirtyRect = NSUnionRect(_tkDirtyRect, rect); + [NSApp setNeedsToDraw:YES]; } - (void) clearTkDirtyRect { _tkNeedsDisplay = NO; _tkDirtyRect = NSZeroRect; + [NSApp setNeedsToDraw:NO]; } - (void) drawRect: (NSRect) rect @@ -968,7 +969,7 @@ ConfigureRestrictProc( } [NSApp setIsDrawing: YES]; - [self setTkDirtyRect:NSZeroRect]; + [self clearTkDirtyRect]; [self generateExposeEvents:rect]; [self setTkNeedsDisplay: NO]; [NSApp setIsDrawing: NO]; diff --git a/tests/listbox.test b/tests/listbox.test index 8d4ed33..0917e84 100644 --- a/tests/listbox.test +++ b/tests/listbox.test @@ -2666,7 +2666,7 @@ test listbox-21.9 {ListboxListVarProc, test hscrollbar after listvar mod} -setup listbox .l -font $fixed -width 10 -xscrollcommand "record x" -listvar x set log {} pack .l - set timeout [after 500 {set log timeout}] + set timeout [after 500 {set log timeout}] vwait log lappend x "0000000000" update @@ -2684,7 +2684,7 @@ test listbox-21.10 {ListboxListVarProc, test hscrollbar after listvar mod} -setu listbox .l -font $fixed -width 10 -xscrollcommand "record x" -listvar x set log {} pack .l - set timeout [after 500 {set log timeout}] + set timeout [after 500 {set log timeout}] vwait log lappend x "0000000000" update @@ -2764,7 +2764,7 @@ test listbox-21.15 {ListboxListVarProc, update vertical scrollbar} -setup { update set log {} pack .l - set timeout [after 500 {set log timeout}] + set timeout [after 500 {set log timeout}] vwait log update lappend x a b c d e f @@ -2800,20 +2800,20 @@ test listbox-21.16 {ListboxListVarProc, update vertical scrollbar} -setup { test listbox-22.1 {UpdateHScrollbar} -setup { destroy .l } -body { - set log {} listbox .l -font $fixed -width 10 -xscrollcommand "record x" pack .l - set timeout [after 500 {set log timeout}] - vwait log - .l insert end "0000000000" update idletasks + set log {} + set timeout [after 500 {set log timeout}] + .l insert end "0000000000" + vwait log .l insert end "00000000000000000000" vwait log set log } -cleanup { destroy .l after cancel $timeout -} -result [list {x 0 1} {x 0 1} {x 0 0.5}] +} -result [list {x 0 1} {x 0 0.5}] # ConfigureListboxItem @@ -3221,8 +3221,3 @@ option clear # cleanup cleanupTests return - - - - - -- cgit v0.12 From bcf017e94b644b427d704da23be4bbe164978fff Mon Sep 17 00:00:00 2001 From: culler Date: Sat, 6 Jun 2020 18:53:04 +0000 Subject: A different attempt to make sure new windows are completely drawn. --- macosx/tkMacOSXKeyEvent.c | 3 +-- macosx/tkMacOSXNotify.c | 3 +++ macosx/tkMacOSXWindowEvent.c | 6 +++--- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/macosx/tkMacOSXKeyEvent.c b/macosx/tkMacOSXKeyEvent.c index e0b0094..bff9e26 100644 --- a/macosx/tkMacOSXKeyEvent.c +++ b/macosx/tkMacOSXKeyEvent.c @@ -255,12 +255,11 @@ static NSUInteger textInputModifiers; */ if (type == NSKeyDown && [theEvent isARepeat]) { + xEvent.xany.type = KeyRelease; Tk_QueueWindowEvent(&xEvent, TCL_QUEUE_TAIL); xEvent.xany.type = KeyPress; } - if (xEvent.xany.type == KeyPress) { - } Tk_QueueWindowEvent(&xEvent, TCL_QUEUE_TAIL); return theEvent; } diff --git a/macosx/tkMacOSXNotify.c b/macosx/tkMacOSXNotify.c index daa1321..3433e56 100644 --- a/macosx/tkMacOSXNotify.c +++ b/macosx/tkMacOSXNotify.c @@ -457,6 +457,9 @@ TkMacOSXEventsSetupProc( */ ticker = Tcl_CreateTimerHandler(TICK, Heartbeat, NULL); + Tcl_CancelIdleCall(TkMacOSXDrawAllViews, NULL); + Tcl_DoWhenIdle(TkMacOSXDrawAllViews, NULL); + while (Tcl_DoOneEvent(TCL_IDLE_EVENTS)) {} } } } diff --git a/macosx/tkMacOSXWindowEvent.c b/macosx/tkMacOSXWindowEvent.c index b5e6ee3..debe5b8 100644 --- a/macosx/tkMacOSXWindowEvent.c +++ b/macosx/tkMacOSXWindowEvent.c @@ -42,7 +42,6 @@ extern NSString *NSWindowDidOrderOnScreenNotification; #ifdef TK_MAC_DEBUG_NOTIFICATIONS extern NSString *NSWindowWillOrderOnScreenNotification; -extern NSString *NSWindowDidOrderOnScreenNotification; extern NSString *NSWindowDidOrderOffScreenNotification; #endif @@ -216,9 +215,10 @@ extern NSString *NSWindowDidOrderOffScreenNotification; TkWindow *winPtr = TkMacOSXGetTkWindow(window); if (winPtr) { TKContentView *view = [window contentView]; - while(Tcl_DoOneEvent(TCL_IDLE_EVENTS)) {}; [view addTkDirtyRect:[view bounds]]; - TkMacOSXDrawAllViews(NULL); + Tcl_CancelIdleCall(TkMacOSXDrawAllViews, NULL); + Tcl_DoWhenIdle(TkMacOSXDrawAllViews, NULL); + while (Tcl_DoOneEvent(TCL_IDLE_EVENTS)) {} } } -- cgit v0.12 From 94df92d713ad84ae1e93183be6a9927209783795 Mon Sep 17 00:00:00 2001 From: culler Date: Sat, 6 Jun 2020 21:20:19 +0000 Subject: More attempts to make sure new windows are complete. --- macosx/tkMacOSXWindowEvent.c | 27 ++++++++++++--------------- 1 file changed, 12 insertions(+), 15 deletions(-) diff --git a/macosx/tkMacOSXWindowEvent.c b/macosx/tkMacOSXWindowEvent.c index debe5b8..07965f0 100644 --- a/macosx/tkMacOSXWindowEvent.c +++ b/macosx/tkMacOSXWindowEvent.c @@ -39,9 +39,9 @@ static void DoWindowActivate(ClientData clientData); #pragma mark TKApplication(TKWindowEvent) extern NSString *NSWindowDidOrderOnScreenNotification; +extern NSString *NSWindowWillOrderOnScreenNotification; #ifdef TK_MAC_DEBUG_NOTIFICATIONS -extern NSString *NSWindowWillOrderOnScreenNotification; extern NSString *NSWindowDidOrderOffScreenNotification; #endif @@ -218,6 +218,15 @@ extern NSString *NSWindowDidOrderOffScreenNotification; [view addTkDirtyRect:[view bounds]]; Tcl_CancelIdleCall(TkMacOSXDrawAllViews, NULL); Tcl_DoWhenIdle(TkMacOSXDrawAllViews, NULL); + } +} + +- (void) windowMapped: (NSNotification *) notification +{ + NSWindow *w = [notification object]; + TkWindow *winPtr = TkMacOSXGetTkWindow(w); + + if (winPtr) { while (Tcl_DoOneEvent(TCL_IDLE_EVENTS)) {} } } @@ -235,18 +244,6 @@ extern NSString *NSWindowDidOrderOffScreenNotification; //BOOL start = [[notification name] isEqualToString:NSWindowWillStartLiveResizeNotification]; } -- (void) windowMapped: (NSNotification *) notification -{ - TKLog(@"-[%@(%p) %s] %@", [self class], self, _cmd, notification); - NSWindow *w = [notification object]; - TkWindow *winPtr = TkMacOSXGetTkWindow(w); - - printf("windowMapped\n"); - if (winPtr) { - //Tk_MapWindow((Tk_Window) winPtr); - } -} - - (void) windowUnmapped: (NSNotification *) notification { TKLog(@"-[%@(%p) %s] %@", [self class], self, _cmd, notification); @@ -274,6 +271,8 @@ extern NSString *NSWindowDidOrderOffScreenNotification; observe(NSWindowDidDeminiaturizeNotification, windowExpanded:); observe(NSWindowDidMiniaturizeNotification, windowCollapsed:); observe(NSWindowDidOrderOnScreenNotification, windowBecameVisible:); + observe(NSWindowWillOrderOnScreenNotification, windowMapped:); + observe(NSWindowDidOrderOnScreenNotification, windowBecameVisible:); #if !(MAC_OS_X_VERSION_MAX_ALLOWED < 1070) observe(NSWindowDidEnterFullScreenNotification, windowEnteredFullScreen:); @@ -284,8 +283,6 @@ extern NSString *NSWindowDidOrderOffScreenNotification; observe(NSWindowWillMoveNotification, windowDragStart:); observe(NSWindowWillStartLiveResizeNotification, windowLiveResize:); observe(NSWindowDidEndLiveResizeNotification, windowLiveResize:); - observe(NSWindowWillOrderOnScreenNotification, windowMapped:); - observe(NSWindowDidOrderOnScreenNotification, windowBecameVisible:); observe(NSWindowDidOrderOffScreenNotification, windowUnmapped:); #endif #undef observe -- cgit v0.12 From 8b94c471d7cb1f24b1e22e5c64f90197d220fbe2 Mon Sep 17 00:00:00 2001 From: culler Date: Sun, 7 Jun 2020 22:19:45 +0000 Subject: Fix the Redisplay to make new windows complete. --- macosx/tkMacOSXNotify.c | 13 ++++++------- macosx/tkMacOSXSubwindows.c | 10 ++++------ macosx/tkMacOSXWindowEvent.c | 6 ++---- tests/wm.test | 12 ++++++++---- 4 files changed, 20 insertions(+), 21 deletions(-) diff --git a/macosx/tkMacOSXNotify.c b/macosx/tkMacOSXNotify.c index 3433e56..2d25ce1 100644 --- a/macosx/tkMacOSXNotify.c +++ b/macosx/tkMacOSXNotify.c @@ -368,7 +368,7 @@ TkMacOSXDrawAllViews( * rect, due to attempts to draw outside of drawRect's dirty rect. */ - if ([view tkNeedsDisplay]) { + if ([view needsDisplay]) { [view setNeedsDisplay: NO]; } } @@ -412,6 +412,8 @@ Heartbeat( } } +static const Tcl_Time zeroBlockTime = { 0, 0 }; + static void TkMacOSXEventsSetupProc( ClientData clientData, @@ -424,7 +426,6 @@ TkMacOSXEventsSetupProc( */ if (flags & TCL_WINDOW_EVENTS && !runloopMode) { - static const Tcl_Time zeroBlockTime = { 0, 0 }; [NSApp _resetAutoreleasePool]; @@ -435,7 +436,7 @@ TkMacOSXEventsSetupProc( * * If we have any events waiting or if there is any drawing to be done * we want Tcl_WaitForEvent to return immediately. So we set the block - * time to 0. We also stop the heartbeat, since we won't need it. + * time to 0 and stop the heatbeat. */ NSEvent *currentEvent = @@ -453,13 +454,11 @@ TkMacOSXEventsSetupProc( * When the user is not generating events we schedule a "heartbeat" * TimerHandler to fire every 200 milliseconds. The handler does * nothing, but when its timer fires it causes Tcl_WaitForEvent to - * return. This helps avoid hangs when calling vwait. + * return. This helps avoid hangs when calling vwait during the + * non-regression tests. */ ticker = Tcl_CreateTimerHandler(TICK, Heartbeat, NULL); - Tcl_CancelIdleCall(TkMacOSXDrawAllViews, NULL); - Tcl_DoWhenIdle(TkMacOSXDrawAllViews, NULL); - while (Tcl_DoOneEvent(TCL_IDLE_EVENTS)) {} } } } diff --git a/macosx/tkMacOSXSubwindows.c b/macosx/tkMacOSXSubwindows.c index bf59901..a0f445f 100644 --- a/macosx/tkMacOSXSubwindows.c +++ b/macosx/tkMacOSXSubwindows.c @@ -213,12 +213,11 @@ XMapWindow( TkMacOSXInvalClipRgns((Tk_Window) winPtr->parentPtr); } - if ([NSApp isDrawing]) { - [[win contentView] setNeedsRedisplay:YES]; - } else { + if (![NSApp isDrawing]) { TKContentView *view = [win contentView]; [view addTkDirtyRect:[view bounds]]; } + [[win contentView] setNeedsRedisplay:YES]; /* * Generate VisibilityNotify events for window and all mapped children. @@ -331,12 +330,11 @@ XUnmapWindow( TkMacOSXUpdateClipRgn(parentPtr); } winPtr->flags &= ~TK_MAPPED; - if ([NSApp isDrawing]) { - [[win contentView] setNeedsRedisplay:YES]; - } else { + if (![NSApp isDrawing]) { TKContentView *view = [win contentView]; [view addTkDirtyRect:[view bounds]]; } + [[win contentView] setNeedsRedisplay:YES]; return Success; } diff --git a/macosx/tkMacOSXWindowEvent.c b/macosx/tkMacOSXWindowEvent.c index 07965f0..9edbd69 100644 --- a/macosx/tkMacOSXWindowEvent.c +++ b/macosx/tkMacOSXWindowEvent.c @@ -968,13 +968,11 @@ ConfigureRestrictProc( [NSApp setIsDrawing: YES]; [self clearTkDirtyRect]; [self generateExposeEvents:rect]; - [self setTkNeedsDisplay: NO]; - [NSApp setIsDrawing: NO]; - if ([self needsRedisplay]) { [self setNeedsRedisplay:NO]; - Tcl_DoWhenIdle(TkMacOSXDrawAllViews, NULL); + [self addTkDirtyRect: [self bounds]]; } + [NSApp setIsDrawing:NO]; #ifdef TK_MAC_DEBUG_DRAWING fprintf(stderr, "drawRect: done.\n"); diff --git a/tests/wm.test b/tests/wm.test index 4d0d73b..9e6d8ce 100644 --- a/tests/wm.test +++ b/tests/wm.test @@ -2310,6 +2310,11 @@ test wm-forget-1.4 "pack into unmapped toplevel causes crash" -body { test wm-forget-2 {bug [e9112ef96e] - [wm forget] doesn't completely} -setup { catch {destroy .l .f.b .f} set res {} + if {[tk windowingsystem] == "aqua"} { + proc doUpdate {} {update idletasks} + } else { + proc doUpdate {} {update} + } } -body { label .l -text "Top Dot" frame .f @@ -2317,16 +2322,15 @@ test wm-forget-2 {bug [e9112ef96e] - [wm forget] doesn't completely} -setup { pack .l -side top pack .f.b pack .f -side bottom - update set res [winfo manager .f] pack forget .f - update + doUpdate lappend res [winfo manager .f] wm manage .f - update + doUpdate lappend res [winfo manager .f] wm forget .f - update + doUpdate lappend res [winfo manager .f] } -cleanup { destroy .l .f.b .f -- cgit v0.12 From af7543d7737a8987f2a209471913e6bbf4106b78 Mon Sep 17 00:00:00 2001 From: marc_culler Date: Sun, 12 Jul 2020 20:50:12 +0000 Subject: Process timer events as well as idle events in some of the inner event loops used by Tk --- macosx/tkMacOSXEmbed.c | 4 +--- macosx/tkMacOSXEvent.c | 2 +- macosx/tkMacOSXNotify.c | 2 -- macosx/tkMacOSXWindowEvent.c | 4 ++-- 4 files changed, 4 insertions(+), 8 deletions(-) diff --git a/macosx/tkMacOSXEmbed.c b/macosx/tkMacOSXEmbed.c index 6c4ac1f..e58cdd0 100644 --- a/macosx/tkMacOSXEmbed.c +++ b/macosx/tkMacOSXEmbed.c @@ -1049,9 +1049,7 @@ EmbedGeometryRequest( */ Tk_GeometryRequest((Tk_Window) winPtr, width, height); - while (Tcl_DoOneEvent(TCL_IDLE_EVENTS)) { - /* Empty loop body. */ - } + while (Tcl_DoOneEvent(TCL_IDLE_EVENTS|TCL_TIMER_EVENTS|TCL_DONT_WAIT)) {} if ((winPtr->changes.width != width) || (winPtr->changes.height != height)) { EmbedSendConfigure(containerPtr); diff --git a/macosx/tkMacOSXEvent.c b/macosx/tkMacOSXEvent.c index b9c9b6a..c543b8d 100644 --- a/macosx/tkMacOSXEvent.c +++ b/macosx/tkMacOSXEvent.c @@ -134,7 +134,7 @@ TkMacOSXFlushWindows(void) if (Tk_GetNumMainWindows() == 0) { return; } - while (Tcl_DoOneEvent(TCL_IDLE_EVENTS)){} + while (Tcl_DoOneEvent(TCL_IDLE_EVENTS|TCL_TIMER_EVENTS|TCL_DONT_WAIT)){} for (NSWindow *w in [NSApp orderedWindows]) { [w display]; } diff --git a/macosx/tkMacOSXNotify.c b/macosx/tkMacOSXNotify.c index a4a1125..00db7d6 100644 --- a/macosx/tkMacOSXNotify.c +++ b/macosx/tkMacOSXNotify.c @@ -530,9 +530,7 @@ TkMacOSXEventsCheckProc( * Generate Xevents. */ - int oldServiceMode = Tcl_SetServiceMode(TCL_SERVICE_ALL); NSEvent *processedEvent = [NSApp tkProcessEvent:currentEvent]; - Tcl_SetServiceMode(oldServiceMode); if (processedEvent) { eventsFound++; diff --git a/macosx/tkMacOSXWindowEvent.c b/macosx/tkMacOSXWindowEvent.c index a169a15..2de1550 100644 --- a/macosx/tkMacOSXWindowEvent.c +++ b/macosx/tkMacOSXWindowEvent.c @@ -1078,7 +1078,7 @@ ConfigureRestrictProc( /* * First process all of the Expose events. */ - while (Tcl_ServiceEvent(TCL_IDLE_EVENTS)) {}; + while (Tcl_ServiceEvent(TCL_IDLE_EVENTS|TCL_TIMER_EVENTS|TCL_DONT_WAIT)) {}; oldProc = Tk_RestrictEvents(ExposeRestrictProc, UINT2PTR(serial), &oldArg); while (Tcl_ServiceEvent(TCL_WINDOW_EVENTS)) {}; @@ -1097,7 +1097,7 @@ ConfigureRestrictProc( * that were created when the expose events were processed. */ - while (Tcl_DoOneEvent(TCL_IDLE_EVENTS)) {} + while (Tcl_DoOneEvent(TCL_IDLE_EVENTS|TCL_TIMER_EVENTS|TCL_DONT_WAIT)) {} } } -- cgit v0.12 From 5e62075ec23dc8688b0880787a8509deb0b3d7b1 Mon Sep 17 00:00:00 2001 From: marc_culler Date: Sun, 12 Jul 2020 22:20:04 +0000 Subject: Tweak and untweak a couple of tests with race conditions. --- tests/textDisp.test | 2 +- tests/textWind.test | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/tests/textDisp.test b/tests/textDisp.test index b4891e4..a017dad 100644 --- a/tests/textDisp.test +++ b/tests/textDisp.test @@ -4198,7 +4198,7 @@ test textDisp-33.2 {one line longer than fits in the widget} { .tt debug 1 set tk_textHeightCalc "" .tt insert 1.0 [string repeat "more wrap + " 1] - after 100 ; update idletasks + update idletasks # Nothing should have been recalculated. set tk_textHeightCalc } {} diff --git a/tests/textWind.test b/tests/textWind.test index 938357b..f2daaca 100644 --- a/tests/textWind.test +++ b/tests/textWind.test @@ -751,15 +751,17 @@ test textWind-10.5 {EmbWinLayoutProc procedure, error in creating window} -setup destroy .t.f proc bgerror args { global msg - lappend msg $args + if {$msg == ""} { + lappend msg $args + } } } -body { .t insert 1.0 "Some sample text" + set msg {} .t window create 1.5 -create { frame .t.f frame .t.f.f -width 10 -height 20 -bg $color } - set msg {} update idletasks lappend msg [winfo exists .t.f.f] } -cleanup { -- cgit v0.12 From 1711312fd78e09df1b5f8ee28abab5a0ca2c42c4 Mon Sep 17 00:00:00 2001 From: marc_culler Date: Mon, 13 Jul 2020 14:54:33 +0000 Subject: Do not process timer events in drawRect (Thanks to Nicolas Bats) and remove references to ServiceMode since Tcl_ServiceAll is not being called anymore. --- macosx/tkMacOSXNotify.c | 1 - macosx/tkMacOSXWindowEvent.c | 37 +++++++++++++++---------------------- tests/textDisp.test | 8 +++++--- 3 files changed, 20 insertions(+), 26 deletions(-) diff --git a/macosx/tkMacOSXNotify.c b/macosx/tkMacOSXNotify.c index 00db7d6..367f3b6 100644 --- a/macosx/tkMacOSXNotify.c +++ b/macosx/tkMacOSXNotify.c @@ -261,7 +261,6 @@ Tk_MacOSXSetupTkNotifier(void) Tcl_CreateEventSource(TkMacOSXEventsSetupProc, TkMacOSXEventsCheckProc, NULL); TkCreateExitHandler(TkMacOSXNotifyExitHandler, NULL); - Tcl_SetServiceMode(TCL_SERVICE_ALL); TclMacOSXNotifierAddRunLoopMode(NSEventTrackingRunLoopMode); TclMacOSXNotifierAddRunLoopMode(NSModalPanelRunLoopMode); } diff --git a/macosx/tkMacOSXWindowEvent.c b/macosx/tkMacOSXWindowEvent.c index 2de1550..0563ce6 100644 --- a/macosx/tkMacOSXWindowEvent.c +++ b/macosx/tkMacOSXWindowEvent.c @@ -91,14 +91,11 @@ extern NSString *NSWindowDidOrderOffScreenNotification; height = bounds.size.height - wmPtr->yInParent; flags |= TK_SIZE_CHANGED; } - if (Tcl_GetServiceMode() != TCL_SERVICE_NONE) { - /* - * Propagate geometry changes immediately. - */ - - flags |= TK_MACOSX_HANDLE_EVENT_IMMEDIATELY; - } + /* + * Propagate geometry changes immediately. + */ + flags |= TK_MACOSX_HANDLE_EVENT_IMMEDIATELY; TkGenWMConfigureEvent((Tk_Window) winPtr, x, y, width, height, flags); } @@ -116,24 +113,20 @@ extern NSString *NSWindowDidOrderOffScreenNotification; winPtr->wmInfoPtr->hints.initial_state = TkMacOSXIsWindowZoomed(winPtr) ? ZoomState : NormalState; Tk_MapWindow((Tk_Window) winPtr); - if (Tcl_GetServiceMode() != TCL_SERVICE_NONE) { - /* - * Process all Tk events generated by Tk_MapWindow(). - */ + /* + * Process all Tk events generated by Tk_MapWindow(). + */ - while (Tcl_ServiceEvent(0)) {} - while (Tcl_DoOneEvent(TCL_IDLE_EVENTS)) {} + while (Tcl_ServiceEvent(0)) {} + while (Tcl_DoOneEvent(TCL_IDLE_EVENTS)) {} - /* - * NSWindowDidDeminiaturizeNotification is received after - * NSWindowDidBecomeKeyNotification, so activate manually - */ + /* + * NSWindowDidDeminiaturizeNotification is received after + * NSWindowDidBecomeKeyNotification, so activate manually + */ - GenerateActivateEvents(winPtr, 1); - } else { - Tcl_DoWhenIdle(DoWindowActivate, winPtr); - } + GenerateActivateEvents(winPtr, 1); } } @@ -1097,7 +1090,7 @@ ConfigureRestrictProc( * that were created when the expose events were processed. */ - while (Tcl_DoOneEvent(TCL_IDLE_EVENTS|TCL_TIMER_EVENTS|TCL_DONT_WAIT)) {} + while (Tcl_DoOneEvent(TCL_IDLE_EVENTS)) {} } } diff --git a/tests/textDisp.test b/tests/textDisp.test index a017dad..796fd92 100644 --- a/tests/textDisp.test +++ b/tests/textDisp.test @@ -4196,12 +4196,14 @@ test textDisp-33.2 {one line longer than fits in the widget} { destroy .tt pack [text .tt -wrap char] .tt debug 1 + update idletasks set tk_textHeightCalc "" + set timer [after 700 lappend tk_textHeightCalc "Timed out"] .tt insert 1.0 [string repeat "more wrap + " 1] - update idletasks - # Nothing should have been recalculated. + vwait tk_textHeightCalc + after cancel timer set tk_textHeightCalc -} {} +} {1.0} test textDisp-33.3 {one line longer than fits in the widget} { destroy .tt pack [text .tt -wrap char] -- cgit v0.12 From 4722f9f501efe0141837f64c3c63cc13705396e5 Mon Sep 17 00:00:00 2001 From: marc_culler Date: Tue, 14 Jul 2020 13:26:49 +0000 Subject: Remove duplicate line in tkMacOSXWindowEvent.c --- macosx/tkMacOSXWindowEvent.c | 1 - 1 file changed, 1 deletion(-) diff --git a/macosx/tkMacOSXWindowEvent.c b/macosx/tkMacOSXWindowEvent.c index 0563ce6..2b2f1a0 100644 --- a/macosx/tkMacOSXWindowEvent.c +++ b/macosx/tkMacOSXWindowEvent.c @@ -263,7 +263,6 @@ extern NSString *NSWindowDidOrderOffScreenNotification; observe(NSWindowDidResizeNotification, windowBoundsChanged:); observe(NSWindowDidDeminiaturizeNotification, windowExpanded:); observe(NSWindowDidMiniaturizeNotification, windowCollapsed:); - observe(NSWindowDidOrderOnScreenNotification, windowBecameVisible:); observe(NSWindowWillOrderOnScreenNotification, windowMapped:); observe(NSWindowDidOrderOnScreenNotification, windowBecameVisible:); -- cgit v0.12 From 451fa4203bff3f5e6a0ab5028f900823174b4c83 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Wed, 15 Jul 2020 14:33:41 +0000 Subject: Code simplifications: Don't bother the typedefs 'EventMask' and 'ModMask' for 'unsigned long', since Tk cannot handle more than 32 bits anyway. Simply use 'unsigned' everywhere. --- generic/tkBind.c | 59 +++++++++++++++++++++++------------------------------ generic/tkCanvas.c | 4 ++-- generic/tkEvent.c | 6 +++--- generic/tkInt.h | 2 +- generic/tkPointer.c | 5 +++-- 5 files changed, 35 insertions(+), 41 deletions(-) diff --git a/generic/tkBind.c b/generic/tkBind.c index b3bddc9..bdc1f45 100644 --- a/generic/tkBind.c +++ b/generic/tkBind.c @@ -137,17 +137,10 @@ typedef struct { * this count considers the detail (keySym or button). */ } Event; -/* - * We need a structure providing a list of pattern sequences. - */ - -typedef unsigned EventMask; -typedef unsigned long ModMask; - struct PatSeq; /* forward declaration */ /* We need this array for bookkeeping the last matching modifier mask per pattern. */ -TK_ARRAY_DEFINE(PSModMaskArr, ModMask); +TK_ARRAY_DEFINE(PSModMaskArr, unsigned); typedef struct PSEntry { TK_DLIST_LINKS(PSEntry); /* Makes this struct a double linked list; must be first entry. */ @@ -203,7 +196,7 @@ typedef struct Tk_BindingTable_ { /* Containing the most recent event for every event type. */ PromArr *promArr; /* Contains the promoted pattern sequences. */ Event *curEvent; /* Pointing to most recent event. */ - ModMask curModMask; /* Containing the current modifier mask. */ + unsigned curModMask; /* Containing the current modifier mask. */ LookupTables lookupTables; /* Containing hash tables for fast lookup. */ Tcl_HashTable objectTable; /* Used to map from an object to a list of patterns associated with * that object. Keys are ClientData, values are (PatSeq *). */ @@ -265,7 +258,7 @@ typedef struct { typedef struct { unsigned eventType; /* Type of X event, e.g. ButtonPress. */ unsigned count; /* Multi-event count, e.g. double-clicks, triple-clicks, etc. */ - ModMask modMask; /* Mask of modifiers that must be present (zero means no modifiers + unsigned modMask; /* Mask of modifiers that must be present (zero means no modifiers * are required). */ Info info; /* Additional information that must match event. Normally this is zero, * meaning no additional information must match. For KeyPress and @@ -416,7 +409,7 @@ static Tcl_HashTable nameTable; /* keyArray hashed by keysym name. */ typedef struct { const char *name; /* Name of modifier. */ - ModMask mask; /* Button/modifier mask value, such as Button1Mask. */ + unsigned mask; /* Button/modifier mask value, such as Button1Mask. */ unsigned flags; /* Various flags; see below for definitions. */ } ModInfo; @@ -713,7 +706,7 @@ static void ExpandPercents(TkWindow *winPtr, const char *before, Event *eventPt unsigned scriptCount, Tcl_DString *dsPtr); static PatSeq * FindSequence(Tcl_Interp *interp, LookupTables *lookupTables, ClientData object, const char *eventString, int create, - int allowVirtual, EventMask *maskPtr); + int allowVirtual, unsigned *maskPtr); static void GetAllVirtualEvents(Tcl_Interp *interp, VirtualEventTable *vetPtr); static const char * GetField(const char *p, char *copy, unsigned size); static Tcl_Obj * GetPatternObj(const PatSeq *psPtr); @@ -729,7 +722,7 @@ static PatSeq * MatchPatterns(TkDisplay *dispPtr, Tk_BindingTable bindPtr, PSLi static int NameToWindow(Tcl_Interp *interp, Tk_Window main, Tcl_Obj *objPtr, Tk_Window *tkwinPtr); static unsigned ParseEventDescription(Tcl_Interp *interp, const char **eventStringPtr, - TkPattern *patPtr, EventMask *eventMaskPtr); + TkPattern *patPtr, unsigned *eventMaskPtr); static void DoWarp(ClientData clientData); static PSList * GetLookupForEvent(LookupTables* lookupPtr, const Event *eventPtr, Tcl_Obj *object, int onlyConsiderDetailedEvents); @@ -761,8 +754,8 @@ static int TestNearbyCoords(int lhs, int rhs) { return Abs(lhs - rhs) <= NEARBY_ static int IsSubsetOf( - ModMask lhsMask, /* this is a subset */ - ModMask rhsMask) /* of this bit field? */ + unsigned lhsMask, /* this is a subset */ + unsigned rhsMask) /* of this bit field? */ { return (lhsMask & rhsMask) == lhsMask; } @@ -967,13 +960,13 @@ ResolveModifiers( if (dispPtr->metaModMask) { if (modMask & META_MASK) { - modMask &= ~(ModMask)META_MASK; + modMask &= ~META_MASK; modMask |= dispPtr->metaModMask; } } if (dispPtr->altModMask) { if (modMask & ALT_MASK) { - modMask &= ~(ModMask)ALT_MASK; + modMask &= ~ALT_MASK; modMask |= dispPtr->altModMask; } } @@ -1634,7 +1627,7 @@ Tk_CreateBinding( * existing binding will always be replaced. */ { PatSeq *psPtr; - EventMask eventMask; + unsigned eventMask; char *oldStr; char *newStr; @@ -2727,8 +2720,8 @@ static int CompareModMasks( const PSModMaskArr *fstModMaskArr, const PSModMaskArr *sndModMaskArr, - ModMask fstModMask, - ModMask sndModMask) + unsigned fstModMask, + unsigned sndModMask) { int fstCount = 0; int sndCount = 0; @@ -2752,8 +2745,8 @@ CompareModMasks( assert(PSModMaskArr_Size(fstModMaskArr) == PSModMaskArr_Size(sndModMaskArr)); for (i = PSModMaskArr_Size(fstModMaskArr) - 1; i >= 0; --i) { - ModMask fstModMask = *PSModMaskArr_Get(fstModMaskArr, i); - ModMask sndModMask = *PSModMaskArr_Get(sndModMaskArr, i); + unsigned fstModMask = *PSModMaskArr_Get(fstModMaskArr, i); + unsigned sndModMask = *PSModMaskArr_Get(sndModMaskArr, i); if (IsSubsetOf(fstModMask, sndModMask)) { ++sndCount; } if (IsSubsetOf(sndModMask, fstModMask)) { ++fstCount; } @@ -2786,7 +2779,7 @@ MatchPatterns( PSEntry *psEntry; PatSeq *bestPtr; PatSeq *bestPhysPtr; - ModMask bestModMask; + unsigned bestModMask; const PSModMaskArr *bestModMaskArr = NULL; int i, isModKeyOnly = 0; @@ -2853,8 +2846,8 @@ MatchPatterns( * cannot be done in ParseEventDescription, otherwise this function would * be the better place. */ - ModMask modMask = ResolveModifiers(dispPtr, patPtr->modMask); - ModMask curModMask = ResolveModifiers(dispPtr, bindPtr->curModMask); + unsigned modMask = ResolveModifiers(dispPtr, patPtr->modMask); + unsigned curModMask = ResolveModifiers(dispPtr, bindPtr->curModMask); psEntry->expired = 1; /* remove it from promotion list */ psEntry->keepIt = 0; /* don't keep matching patterns */ @@ -3850,7 +3843,7 @@ HandleEventGenerate( Tk_Window tkwin; Tk_Window tkwin2; TkWindow *mainPtr; - EventMask eventMask; + unsigned eventMask; Tcl_Obj *userDataObj; int synch; int warp; @@ -4622,7 +4615,7 @@ FindSequence( * 1 means create. */ int allowVirtual, /* 0 means that virtual events are not allowed in the sequence. * 1 otherwise. */ - EventMask *maskPtr) /* *maskPtr is filled in with the event types on which this + unsigned *maskPtr) /* *maskPtr is filled in with the event types on which this * pattern sequence depends. */ { unsigned patsBufSize = 1; @@ -4636,8 +4629,8 @@ FindSequence( int isNew; unsigned count; unsigned maxCount = 0; - EventMask eventMask = 0; - ModMask modMask = 0; + unsigned eventMask = 0; + unsigned modMask = 0; PatternTableKey key; assert(lookupTables); @@ -4811,10 +4804,10 @@ ParseEventDescription( const char **eventStringPtr,/* On input, holds a pointer to start of event string. On exit, * gets pointer to rest of string after parsed event. */ TkPattern *patPtr, /* Filled with the pattern parsed from the event string. */ - EventMask *eventMaskPtr) /* Filled with event mask of matched event. */ + unsigned *eventMaskPtr) /* Filled with event mask of matched event. */ { const char *p; - EventMask eventMask = 0; + unsigned eventMask = 0; unsigned count = 1; assert(eventStringPtr); @@ -5127,7 +5120,7 @@ GetPatternObj( assert(patPtr->name); Tcl_AppendPrintfToObj(patternObj, "<<%s>>", patPtr->name); } else { - ModMask modMask; + unsigned modMask; const ModInfo *modPtr; /* @@ -5180,7 +5173,7 @@ GetPatternObj( break; #if PRINT_SHORT_MOTION_SYNTAX case MotionNotify: { - ModMask mask = patPtr->modMask; + unsigned mask = patPtr->modMask; while (mask & ALL_BUTTONS) { unsigned button = ButtonNumberFromState(mask); Tcl_AppendPrintfToObj(patternObj, "-%u", button); diff --git a/generic/tkCanvas.c b/generic/tkCanvas.c index 9f661bc..50a88b4 100644 --- a/generic/tkCanvas.c +++ b/generic/tkCanvas.c @@ -4759,8 +4759,8 @@ CanvasBindProc( ClientData clientData, /* Pointer to canvas structure. */ XEvent *eventPtr) /* Pointer to X event that just happened. */ { - TkCanvas *canvasPtr = clientData; - unsigned long mask; + TkCanvas *canvasPtr = (TkCanvas *)clientData; + unsigned mask; Tcl_Preserve(canvasPtr); diff --git a/generic/tkEvent.c b/generic/tkEvent.c index a2fa293..0994a07 100644 --- a/generic/tkEvent.c +++ b/generic/tkEvent.c @@ -522,13 +522,13 @@ RefreshKeyboardMappingIfNeeded( *---------------------------------------------------------------------- */ -static const unsigned long buttonMasks[] = { +static const unsigned buttonMasks[] = { 0, Button1Mask, Button2Mask, Button3Mask, Button4Mask, Button5Mask }; -unsigned long +unsigned TkGetButtonMask( - unsigned int button) + unsigned button) { return (button > Button5) ? 0 : buttonMasks[button]; } diff --git a/generic/tkInt.h b/generic/tkInt.h index b60ab44..6f40078 100644 --- a/generic/tkInt.h +++ b/generic/tkInt.h @@ -966,7 +966,7 @@ typedef struct TkpClipMask { (Button1Mask|Button2Mask|Button3Mask|Button4Mask|Button5Mask) -MODULE_SCOPE unsigned long TkGetButtonMask(unsigned int); +MODULE_SCOPE unsigned TkGetButtonMask(unsigned); /* * Object types not declared in tkObj.c need to be mentioned here so they can diff --git a/generic/tkPointer.c b/generic/tkPointer.c index 06359a9..c17367a 100644 --- a/generic/tkPointer.c +++ b/generic/tkPointer.c @@ -225,8 +225,9 @@ Tk_UpdatePointer( TkWindow *targetWinPtr; XPoint pos; XEvent event; - int changes = (state ^ tsdPtr->lastState) & ALL_BUTTONS; - int type, b, mask; + unsigned changes = (state ^ tsdPtr->lastState) & ALL_BUTTONS; + int type, b; + unsigned mask; pos.x = x; pos.y = y; -- cgit v0.12 From 4819d3849f45e832a8b26c7906c36f66472ef3b9 Mon Sep 17 00:00:00 2001 From: marc_culler Date: Wed, 15 Jul 2020 20:16:47 +0000 Subject: macOS: remove unneeded code observed in [7ebdd17974], remove tkMacOSXFlushWindows, make XSync do nothing except process timer events. --- generic/ttk/ttkTheme.c | 8 -------- macosx/tkMacOSXDraw.c | 2 +- macosx/tkMacOSXEvent.c | 35 ----------------------------------- macosx/tkMacOSXEvent.h | 4 +++- macosx/tkMacOSXSubwindows.c | 3 +++ macosx/tkMacOSXWindowEvent.c | 36 ++++++------------------------------ macosx/tkMacOSXXStubs.c | 15 +++++++++++++-- tests/listbox.test | 10 +++++----- 8 files changed, 31 insertions(+), 82 deletions(-) diff --git a/generic/ttk/ttkTheme.c b/generic/ttk/ttkTheme.c index 6bf48a3..7bde80e 100644 --- a/generic/ttk/ttkTheme.c +++ b/generic/ttk/ttkTheme.c @@ -15,13 +15,6 @@ #define PKG_ASSOC_KEY "Ttk" -#ifdef MAC_OSX_TK - extern void TkMacOSXFlushWindows(void); - #define UPDATE_WINDOWS() TkMacOSXFlushWindows() -#else - #define UPDATE_WINDOWS() -#endif - /*------------------------------------------------------------------------ * +++ Styles. * @@ -517,7 +510,6 @@ static void ThemeChangedProc(ClientData clientData) Tcl_BackgroundException(pkgPtr->interp, code); } pkgPtr->themeChangePending = 0; - UPDATE_WINDOWS(); } /* diff --git a/macosx/tkMacOSXDraw.c b/macosx/tkMacOSXDraw.c index f3d6ba4..4973bc2 100644 --- a/macosx/tkMacOSXDraw.c +++ b/macosx/tkMacOSXDraw.c @@ -1636,7 +1636,7 @@ TkMacOSXSetupDrawingContext( HIShapeGetBounds(dc.clipRgn, &clipBounds); clipBounds = CGRectApplyAffineTransform(clipBounds, t); } - if (![NSApp isDrawing] || view != [NSView focusView]) { + if (![NSApp isDrawing]) { /* * We can only draw into the view when the current CGContext is diff --git a/macosx/tkMacOSXEvent.c b/macosx/tkMacOSXEvent.c index c543b8d..31a7663 100644 --- a/macosx/tkMacOSXEvent.c +++ b/macosx/tkMacOSXEvent.c @@ -104,43 +104,8 @@ enum { return processedEvent; } @end - #pragma mark - - -/* - *---------------------------------------------------------------------- - * - * TkMacOSXFlushWindows -- - * - * This routine is a stub called by XSync, which is called during the Tk - * update command. The language specification does not require that the - * update command be synchronous but many of the tests implicitly assume - * that it is. It is definitely asynchronous on macOS since many idle - * tasks are run inside of the drawRect method of a window's contentView, - * which will not be called until after this function returns. - * - * Results: - * None. - * - * Side effects: Processes all pending idle events then calls the display - * method of each visible window. - * - *---------------------------------------------------------------------- - */ - -MODULE_SCOPE void -TkMacOSXFlushWindows(void) -{ - if (Tk_GetNumMainWindows() == 0) { - return; - } - while (Tcl_DoOneEvent(TCL_IDLE_EVENTS|TCL_TIMER_EVENTS|TCL_DONT_WAIT)){} - for (NSWindow *w in [NSApp orderedWindows]) { - [w display]; - } -} - /* * Local Variables: * mode: objc diff --git a/macosx/tkMacOSXEvent.h b/macosx/tkMacOSXEvent.h index 46d1585..850e9f6 100644 --- a/macosx/tkMacOSXEvent.h +++ b/macosx/tkMacOSXEvent.h @@ -18,6 +18,8 @@ #include "tkMacOSXInt.h" #endif -MODULE_SCOPE void TkMacOSXFlushWindows(void); +/* + * Currently nothing needs to be declared here. + */ #endif diff --git a/macosx/tkMacOSXSubwindows.c b/macosx/tkMacOSXSubwindows.c index a5fc097..77402a7 100644 --- a/macosx/tkMacOSXSubwindows.c +++ b/macosx/tkMacOSXSubwindows.c @@ -136,6 +136,9 @@ XMapWindow( Display *display, /* Display. */ Window window) /* Window. */ { + if (!window) { + return BadWindow; + } MacDrawable *macWin = (MacDrawable *) window; TkWindow *winPtr = macWin->winPtr; NSWindow *win = TkMacOSXDrawableWindow(window); diff --git a/macosx/tkMacOSXWindowEvent.c b/macosx/tkMacOSXWindowEvent.c index 2b2f1a0..36a489b 100644 --- a/macosx/tkMacOSXWindowEvent.c +++ b/macosx/tkMacOSXWindowEvent.c @@ -34,7 +34,6 @@ static int GenerateUpdates( CGRect *updateBounds, TkWindow *winPtr); static int GenerateActivateEvents(TkWindow *winPtr, int activeFlag); -static void DoWindowActivate(ClientData clientData); #pragma mark TKApplication(TKWindowEvent) @@ -414,7 +413,7 @@ TkpWillDrawWidget(Tk_Window tkwin) { winPtr->privatePtr); result = ([NSApp isDrawing] && view == [NSView focusView]); #if 0 - printf("TkAppCanDraw: %s %d %d \n", Tk_PathName(tkwin), + printf("TkpWillDrawWidget: %s %d %d \n", Tk_PathName(tkwin), [NSApp isDrawing], (view == [NSView focusView])); if (!result) { NSRect dirtyRect; @@ -548,29 +547,6 @@ GenerateActivateEvents( /* *---------------------------------------------------------------------- * - * DoWindowActivate -- - * - * Idle handler that calls GenerateActivateEvents(). - * - * Results: - * None. - * - * Side effects: - * Additional events may be placed on the Tk event queue. - * - *---------------------------------------------------------------------- - */ - -void -DoWindowActivate( - ClientData clientData) -{ - GenerateActivateEvents(clientData, 1); -} - -/* - *---------------------------------------------------------------------- - * * TkMacOSXGenerateFocusEvent -- * * Given a Macintosh window activate event this function generates all @@ -1068,12 +1044,12 @@ ConfigureRestrictProc( serial = LastKnownRequestProcessed(Tk_Display(winPtr)); /* - * First process all of the Expose events. + * Use the ExposeRestrictProc to process only the expose events. This + * will create idle drawing tasks, which we handle before we return. */ - while (Tcl_ServiceEvent(TCL_IDLE_EVENTS|TCL_TIMER_EVENTS|TCL_DONT_WAIT)) {}; oldProc = Tk_RestrictEvents(ExposeRestrictProc, UINT2PTR(serial), &oldArg); - while (Tcl_ServiceEvent(TCL_WINDOW_EVENTS)) {}; + while (Tcl_ServiceEvent(TCL_WINDOW_EVENTS|TCL_DONT_WAIT)) {}; Tk_RestrictEvents(oldProc, oldArg, &oldArg); /* @@ -1085,8 +1061,8 @@ ConfigureRestrictProc( * effect.) * * Fortunately, Tk schedules all drawing to be done while Tcl is idle. - * So we can do the drawing now by processing all of the idle events - * that were created when the expose events were processed. + * So to run any display procs which were scheduled by the expose + * events we process all idle events before returning. */ while (Tcl_DoOneEvent(TCL_IDLE_EVENTS)) {} diff --git a/macosx/tkMacOSXXStubs.c b/macosx/tkMacOSXXStubs.c index 6aeec36..107f712 100644 --- a/macosx/tkMacOSXXStubs.c +++ b/macosx/tkMacOSXXStubs.c @@ -752,7 +752,18 @@ XSync( Display *display, Bool discard) { - TkMacOSXFlushWindows(); + /* + * The main use of XSync is by the update command, which alternates + * between running an event loop to process all events without waiting and + * calling XSync on all displays until no events are left. There is + * nothing for the mac to do with respect to syncing its one display but + * it can (and, during regression testing, frequently does) happen that + * timer events fire during the event loop. Processing those here seems + * to make the update command work in a way that is more consistent with + * its behavior on other platforms. + */ + + while (Tcl_DoOneEvent(TCL_TIMER_EVENTS|TCL_DONT_WAIT)){} display->request++; return 0; } @@ -945,7 +956,7 @@ XSynchronize( Display *display, Bool onoff) { - display->request++; + display->request++; return NULL; } diff --git a/tests/listbox.test b/tests/listbox.test index 0917e84..01cc397 100644 --- a/tests/listbox.test +++ b/tests/listbox.test @@ -2666,7 +2666,7 @@ test listbox-21.9 {ListboxListVarProc, test hscrollbar after listvar mod} -setup listbox .l -font $fixed -width 10 -xscrollcommand "record x" -listvar x set log {} pack .l - set timeout [after 500 {set log timeout}] + set timeout [after 500 {lappend log timeout1}] vwait log lappend x "0000000000" update @@ -2684,7 +2684,7 @@ test listbox-21.10 {ListboxListVarProc, test hscrollbar after listvar mod} -setu listbox .l -font $fixed -width 10 -xscrollcommand "record x" -listvar x set log {} pack .l - set timeout [after 500 {set log timeout}] + set timeout [after 500 {lappend log timeout2}] vwait log lappend x "0000000000" update @@ -2695,7 +2695,7 @@ test listbox-21.10 {ListboxListVarProc, test hscrollbar after listvar mod} -setu set log } -cleanup { destroy .l - after cancel timeout + after cancel $timeout } -result [list {x 0 1} {x 0 1} {x 0 0.5} {x 0 1}] test listbox-21.11 {ListboxListVarProc, bad list} -setup { destroy .l @@ -2764,7 +2764,7 @@ test listbox-21.15 {ListboxListVarProc, update vertical scrollbar} -setup { update set log {} pack .l - set timeout [after 500 {set log timeout}] + set timeout [after 500 {lappend log timeout3}] vwait log update lappend x a b c d e f @@ -2804,7 +2804,7 @@ test listbox-22.1 {UpdateHScrollbar} -setup { pack .l update idletasks set log {} - set timeout [after 500 {set log timeout}] + set timeout [after 500 {lappend log timeout4}] .l insert end "0000000000" vwait log .l insert end "00000000000000000000" -- cgit v0.12 From 3a4dab519f8f01cd8d16d28af150bb2b07894b5f Mon Sep 17 00:00:00 2001 From: marc_culler Date: Wed, 15 Jul 2020 20:57:08 +0000 Subject: More fixes from [7ebdd17974] (thanks Christopher Chavez): remove the needsRedisplay flag, update comments. --- macosx/tkMacOSXDraw.c | 8 ++++---- macosx/tkMacOSXKeyEvent.c | 9 --------- macosx/tkMacOSXPrivate.h | 2 -- macosx/tkMacOSXSubwindows.c | 2 -- macosx/tkMacOSXWindowEvent.c | 4 ---- 5 files changed, 4 insertions(+), 21 deletions(-) diff --git a/macosx/tkMacOSXDraw.c b/macosx/tkMacOSXDraw.c index 4973bc2..4304a3c 100644 --- a/macosx/tkMacOSXDraw.c +++ b/macosx/tkMacOSXDraw.c @@ -1642,13 +1642,13 @@ TkMacOSXSetupDrawingContext( * We can only draw into the view when the current CGContext is * valid and belongs to the view. Validity can only be guaranteed * inside of a view's drawRect or setFrame methods. The isDrawing - * attribute tells us whether we are being called from one of those - * methods. If the CGContext is not valid then we mark our view as - * needing display. + * attribute tells us whether we are being called from drawRect. + * If the CGContext is not valid then we mark our view as needing + * display. */ if (dc.clipRgn) { - [view addTkDirtyRect:clipBounds]; + [view addTkDirtyRect:NSRectFromCGRect(clipBounds)]; } else { [view addTkDirtyRect:[view bounds]]; } diff --git a/macosx/tkMacOSXKeyEvent.c b/macosx/tkMacOSXKeyEvent.c index 9c22820..572e318 100644 --- a/macosx/tkMacOSXKeyEvent.c +++ b/macosx/tkMacOSXKeyEvent.c @@ -268,14 +268,6 @@ static NSUInteger textInputModifiers; @implementation TKContentView --(id)init { - self = [super init]; - if (self) { - _needsRedisplay = NO; - } - return self; -} - /* * Implementation of the NSTextInputClient protocol. */ @@ -551,7 +543,6 @@ static NSUInteger textInputModifiers; } /* End of NSTextInputClient implementation. */ -@synthesize needsRedisplay = _needsRedisplay; @end diff --git a/macosx/tkMacOSXPrivate.h b/macosx/tkMacOSXPrivate.h index a884b57..a77282c 100644 --- a/macosx/tkMacOSXPrivate.h +++ b/macosx/tkMacOSXPrivate.h @@ -422,11 +422,9 @@ VISIBILITY_HIDDEN { @private NSString *privateWorkingText; - Bool _needsRedisplay; Bool _tkNeedsDisplay; NSRect _tkDirtyRect; } -@property Bool needsRedisplay; @property Bool tkNeedsDisplay; @property NSRect tkDirtyRect; @end diff --git a/macosx/tkMacOSXSubwindows.c b/macosx/tkMacOSXSubwindows.c index 77402a7..e6a6e6e 100644 --- a/macosx/tkMacOSXSubwindows.c +++ b/macosx/tkMacOSXSubwindows.c @@ -220,7 +220,6 @@ XMapWindow( TKContentView *view = [win contentView]; [view addTkDirtyRect:[view bounds]]; } - [[win contentView] setNeedsRedisplay:YES]; /* * Generate VisibilityNotify events for window and all mapped children. @@ -337,7 +336,6 @@ XUnmapWindow( TKContentView *view = [win contentView]; [view addTkDirtyRect:[view bounds]]; } - [[win contentView] setNeedsRedisplay:YES]; return Success; } diff --git a/macosx/tkMacOSXWindowEvent.c b/macosx/tkMacOSXWindowEvent.c index 36a489b..5f52ea7 100644 --- a/macosx/tkMacOSXWindowEvent.c +++ b/macosx/tkMacOSXWindowEvent.c @@ -936,10 +936,6 @@ ConfigureRestrictProc( [NSApp setIsDrawing: YES]; [self clearTkDirtyRect]; [self generateExposeEvents:rect]; - if ([self needsRedisplay]) { - [self setNeedsRedisplay:NO]; - [self addTkDirtyRect: [self bounds]]; - } [NSApp setIsDrawing:NO]; #ifdef TK_MAC_DEBUG_DRAWING -- cgit v0.12 From f6c1908879a22fd92cbcd008c9b05bcae14aab7c Mon Sep 17 00:00:00 2001 From: culler Date: Thu, 16 Jul 2020 14:32:06 +0000 Subject: Fix stupid error with isDrawing - thanks Christopher, Nicolas and Kevin. --- generic/tkTest.c | 6 +++--- macosx/tkMacOSXDraw.c | 2 +- macosx/tkMacOSXInt.h | 2 +- macosx/tkMacOSXSubwindows.c | 8 ++++---- macosx/tkMacOSXTest.c | 30 ++++++++++++++++++++++++++---- 5 files changed, 35 insertions(+), 13 deletions(-) diff --git a/generic/tkTest.c b/generic/tkTest.c index a8929b9..e80f488 100644 --- a/generic/tkTest.c +++ b/generic/tkTest.c @@ -31,9 +31,9 @@ #if defined(MAC_OSX_TK) #include "tkMacOSXInt.h" #include "tkScrollbar.h" -#define LOG_DISPLAY TkTestLogDisplay() +#define LOG_DISPLAY(drawable) TkTestLogDisplay(drawable) #else -#define LOG_DISPLAY 1 +#define LOG_DISPLAY(drawable) 1 #endif #ifdef __UNIX__ @@ -1581,7 +1581,7 @@ ImageDisplay( * not just the changed portion. Tests must account for this. */ - if (LOG_DISPLAY) { + if (LOG_DISPLAY(drawable)) { sprintf(buffer, "%s display %d %d %d %d", instPtr->masterPtr->imageName, imageX, imageY, width, height); Tcl_SetVar2(instPtr->masterPtr->interp, instPtr->masterPtr->varName, diff --git a/macosx/tkMacOSXDraw.c b/macosx/tkMacOSXDraw.c index 4304a3c..7d12a4b 100644 --- a/macosx/tkMacOSXDraw.c +++ b/macosx/tkMacOSXDraw.c @@ -1636,7 +1636,7 @@ TkMacOSXSetupDrawingContext( HIShapeGetBounds(dc.clipRgn, &clipBounds); clipBounds = CGRectApplyAffineTransform(clipBounds, t); } - if (![NSApp isDrawing]) { + if (view != [NSView focusView]) { /* * We can only draw into the view when the current CGContext is diff --git a/macosx/tkMacOSXInt.h b/macosx/tkMacOSXInt.h index 58761d5..fbcfffb 100644 --- a/macosx/tkMacOSXInt.h +++ b/macosx/tkMacOSXInt.h @@ -200,7 +200,7 @@ 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 TkTestLogDisplay(void); +MODULE_SCOPE Bool TkTestLogDisplay(Drawable drawable); MODULE_SCOPE Bool TkMacOSXInDarkMode(Tk_Window tkwin); /* diff --git a/macosx/tkMacOSXSubwindows.c b/macosx/tkMacOSXSubwindows.c index e6a6e6e..8bae8fd 100644 --- a/macosx/tkMacOSXSubwindows.c +++ b/macosx/tkMacOSXSubwindows.c @@ -216,8 +216,8 @@ XMapWindow( TkMacOSXInvalClipRgns((Tk_Window) winPtr->parentPtr); } - if (![NSApp isDrawing]) { - TKContentView *view = [win contentView]; + TKContentView *view = [win contentView]; + if (view != [NSView focusView]) { [view addTkDirtyRect:[view bounds]]; } @@ -332,8 +332,8 @@ XUnmapWindow( TkMacOSXUpdateClipRgn(parentPtr); } winPtr->flags &= ~TK_MAPPED; - if (![NSApp isDrawing]) { - TKContentView *view = [win contentView]; + TKContentView *view = [win contentView]; + if (view != [NSView focusView]) { [view addTkDirtyRect:[view bounds]]; } return Success; diff --git a/macosx/tkMacOSXTest.c b/macosx/tkMacOSXTest.c index a5d1d83..39f50e6 100644 --- a/macosx/tkMacOSXTest.c +++ b/macosx/tkMacOSXTest.c @@ -14,6 +14,8 @@ #include "tkMacOSXPrivate.h" #include "tkMacOSXConstants.h" +#include "tkMacOSXWm.h" + /* * Forward declarations of procedures defined later in this file: @@ -108,7 +110,8 @@ DebuggerObjCmd( * first call will usually not occur inside of drawRect. * * Results: - * On OSX 10.14 and later, returns true if and only if called from + * On OSX 10.14 and later, returns true if and only if the NSView of the + * drawable is the current focusView, which can only be the case when * within [NSView drawRect]. On earlier systems returns false if * and only if called from with [NSView drawRect]. * @@ -118,9 +121,28 @@ DebuggerObjCmd( *---------------------------------------------------------------------- */ MODULE_SCOPE Bool -TkTestLogDisplay(void) { - if ([NSApp macOSVersion] >= 101400) { - return [NSApp isDrawing]; +TkTestLogDisplay( + Drawable drawable) +{ + MacDrawable *macWin = (MacDrawable *) drawable; + NSWindow *win = nil; + if (macWin->toplevel && macWin->toplevel->winPtr && + macWin->toplevel->winPtr->wmInfoPtr && + macWin->toplevel->winPtr->wmInfoPtr->window) { + win = macWin->toplevel->winPtr->wmInfoPtr->window; + } else if (macWin->winPtr && macWin->winPtr->wmInfoPtr && + macWin->winPtr->wmInfoPtr->window) { + win = macWin->winPtr->wmInfoPtr->window; + }/* + else if (macWin->toplevel && (macWin->toplevel->flags & TK_EMBEDDED)) { + TkWindow *contWinPtr = TkpGetOtherWindow(macWin->toplevel->winPtr); + if (contWinPtr) { + win = TkMacOSXDrawableWindow((Drawable) contWinPtr->privatePtr); + } + }*/ + if (win && [NSApp macOSVersion] >= 101400) { + TKContentView *view = [win contentView]; + return (view == [NSView focusView]); } else { return ![NSApp isDrawing]; } -- cgit v0.12 From 132c939d5ab36c6a55d7bc9e1692fd981c9a88ca Mon Sep 17 00:00:00 2001 From: culler Date: Fri, 17 Jul 2020 22:14:27 +0000 Subject: Fix the display artifacts in the (unneeded) withdraw-configure-deiconify cycle. --- macosx/tkMacOSXWm.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/macosx/tkMacOSXWm.c b/macosx/tkMacOSXWm.c index 9501c85..dca8686 100644 --- a/macosx/tkMacOSXWm.c +++ b/macosx/tkMacOSXWm.c @@ -3805,10 +3805,6 @@ WmWithdrawCmd( TkpWmSetState(winPtr, WithdrawnState); - NSWindow *win = TkMacOSXDrawableWindow(winPtr->window); - [win orderOut:NSApp]; - [win setExcludedFromWindowsMenu:YES]; - /* * If this window has a transient, the transient must also be withdrawn. */ @@ -6413,6 +6409,7 @@ TkpWmSetState( if (state == WithdrawnState) { Tk_UnmapWindow((Tk_Window) winPtr); } else if (state == IconicState) { + /* * The window always gets unmapped. If we can show the icon version of * the window we also collapse it. @@ -6425,9 +6422,13 @@ TkpWmSetState( Tk_UnmapWindow((Tk_Window) winPtr); } else if (state == NormalState || state == ZoomState) { Tk_MapWindow((Tk_Window) winPtr); - if (macWin && ([macWin styleMask] & NSMiniaturizableWindowMask) && - [macWin isMiniaturized]) { - [macWin deminiaturize:NSApp]; + if (macWin && ([macWin styleMask] & NSMiniaturizableWindowMask)) { + if ([macWin isMiniaturized]) { + [macWin deminiaturize:NSApp]; + } + else { + [macWin orderFront:nil]; + } } TkMacOSXZoomToplevel(macWin, state == NormalState ? inZoomIn : inZoomOut); -- cgit v0.12 From a98e685ef856c63cd31da03cf7463382ad9ceda9 Mon Sep 17 00:00:00 2001 From: fvogel Date: Sun, 19 Jul 2020 17:00:42 +0000 Subject: The semantics of TkpWillDrawWidget was reversed in a previous commit in this branch. Propagate this change to platforms other than macOS. --- unix/tkUnixPort.h | 2 +- win/tkWinPort.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/unix/tkUnixPort.h b/unix/tkUnixPort.h index 491a339..47a0aad 100644 --- a/unix/tkUnixPort.h +++ b/unix/tkUnixPort.h @@ -167,7 +167,7 @@ #define TkpButtonSetDefaults() {} #define TkpDestroyButton(butPtr) {} -#define TkpWillDrawWidget(tkwin) 1 +#define TkpWillDrawWidget(tkwin) 0 #define TkpRedrawWidget(tkwin) #define TkSelUpdateClipboard(a,b) {} #ifndef __CYGWIN__ diff --git a/win/tkWinPort.h b/win/tkWinPort.h index dbde9e1..9829af5 100644 --- a/win/tkWinPort.h +++ b/win/tkWinPort.h @@ -129,7 +129,7 @@ * Other functions not used under Windows */ -#define TkpWillDrawWidget(tkwin) 1 +#define TkpWillDrawWidget(tkwin) 0 #define TkpRedrawWidget(tkwin) #endif /* _WINPORT */ -- cgit v0.12 From 548ba29c1738582ff39f1835e715cc933b8bfd20 Mon Sep 17 00:00:00 2001 From: culler Date: Mon, 20 Jul 2020 17:32:31 +0000 Subject: Apple changed the metrics for Courier New in Big Sur, causing many textWind tests to fail. --- tests/textWind.test | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/tests/textWind.test b/tests/textWind.test index f2daaca..b453feb 100644 --- a/tests/textWind.test +++ b/tests/textWind.test @@ -13,7 +13,11 @@ tcltest::loadTestedCommands deleteWindows -set fixedFont {"Courier New" -12} +if {[tk windowingsystem] eq "aqua"} { + set fixedFont {"Courier" -12} +} else { + set fixedFont {"Courier New" -12} +} set fixedHeight [font metrics $fixedFont -linespace] set fixedWidth [font measure $fixedFont m] set fixedAscent [font metrics $fixedFont -ascent] -- cgit v0.12 From 9f9a5351c3ed97e4a2427e388456f715b95134cd Mon Sep 17 00:00:00 2001 From: culler Date: Mon, 20 Jul 2020 17:59:17 +0000 Subject: For macOS tests, account for the fact that Big Sur has a larger menubar. --- macosx/tkMacOSXTest.c | 37 ++++++++++++++++++++++++++++++++++++- tests/text.test | 2 +- 2 files changed, 37 insertions(+), 2 deletions(-) diff --git a/macosx/tkMacOSXTest.c b/macosx/tkMacOSXTest.c index 39f50e6..0a6f4e8 100644 --- a/macosx/tkMacOSXTest.c +++ b/macosx/tkMacOSXTest.c @@ -29,6 +29,8 @@ static int PressButtonObjCmd (ClientData dummy, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]); static int InjectKeyEventObjCmd (ClientData dummy, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]); +static int MenuBarHeightObjCmd (ClientData dummy, Tcl_Interp *interp, + int objc, Tcl_Obj *const objv[]); /* @@ -61,7 +63,7 @@ TkplatformtestInit( #endif Tcl_CreateObjCommand(interp, "pressbutton", PressButtonObjCmd, NULL, NULL); Tcl_CreateObjCommand(interp, "injectkeyevent", InjectKeyEventObjCmd, NULL, NULL); - + Tcl_CreateObjCommand(interp, "menubarheight", MenuBarHeightObjCmd, NULL, NULL); return TCL_OK; } @@ -98,6 +100,39 @@ DebuggerObjCmd( /* *---------------------------------------------------------------------- * + * MenuBarHeightObjCmd -- + * + * This procedure calls [NSMenu menuBarHeight] and returns the result + * as an integer. Windows can never be placed to overlap the MenuBar, + * so tests need to be aware of its size. + * + * Results: + * A standard Tcl result. + * + * Side effects: + * None. + * + *---------------------------------------------------------------------- + */ + +static int +MenuBarHeightObjCmd( + ClientData clientData, /* Not used. */ + Tcl_Interp *interp, /* Not used. */ + int objc, /* Not used. */ + Tcl_Obj *const objv[]) /* Not used. */ +{ + static int height = 0; + if (height == 0) { + height = (int) [[NSApp mainMenu] menuBarHeight]; + } + Tcl_SetObjResult(interp, Tcl_NewIntObj(height)); + return TCL_OK; +} + +/* + *---------------------------------------------------------------------- + * * TkTestLogDisplay -- * * The test image display procedure calls this to determine whether it diff --git a/tests/text.test b/tests/text.test index 61a54ab..cd4cf50 100644 --- a/tests/text.test +++ b/tests/text.test @@ -3476,7 +3476,7 @@ test text-14.18 {ConfigureText procedure} -constraints fonts -setup { # to the appropriate size. # On macOS, however, there is no way to make the window overlap the menubar. if {[tk windowingsystem] == "aqua"} { - set minY 23 + set minY [expr [menubarheight] + 1] } else { set minY 0 } -- cgit v0.12 From a9de5cde4d9e25fecc883152264797d1e3ee622a Mon Sep 17 00:00:00 2001 From: culler Date: Mon, 20 Jul 2020 19:29:05 +0000 Subject: Aqua: fix unixWm tests broken by the larger menubar in Big Sur --- tests/unixWm.test | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/tests/unixWm.test b/tests/unixWm.test index 28c8159..b6efb42 100644 --- a/tests/unixWm.test +++ b/tests/unixWm.test @@ -46,9 +46,10 @@ proc makeToplevels {} { # larger than the height of the menubar (normally 23 pixels). if {[tk windowingsystem] eq "aqua"} { - set Y0 23 - set Y2 25 - set Y5 28 + set mb [expr [menubarheight] + 1] + set Y0 $mb + set Y2 [expr $mb + 2] + set Y5 [expr $mb + 5] } else { set Y0 0 set Y2 2 @@ -56,7 +57,7 @@ if {[tk windowingsystem] eq "aqua"} { } set i 1 -foreach geom "+23+80 +80+23 +0+$Y0" { +foreach geom "+$Y0+80 +80+$Y0 +0+$Y0" { destroy .t test unixWm-1.$i {initial window position} unix { toplevel .t -width 200 -height 150 @@ -82,7 +83,7 @@ update scan [wm geom .t] %dx%d+%d+%d width height x y set xerr [expr 150-$x] set yerr [expr 150-$y] -foreach geom "+20+80 +80+23 +0+$Y0 -0-0 +0-0 -0+$Y0 -10-5 -10+$Y5 +10-5" { +foreach geom "+20+80 +80+$Y0 +0+$Y0 -0-0 +0-0 -0+$Y0 -10-5 -10+$Y5 +10-5" { test unixWm-2.$i {moving window while mapped} unix { wm geom .t $geom update @@ -94,7 +95,7 @@ foreach geom "+20+80 +80+23 +0+$Y0 -0-0 +0-0 -0+$Y0 -10-5 -10+$Y5 +10-5" { } set i 1 -foreach geom "+20+80 +80+23 +0+$Y0 -0-0 +0-0 -0+$Y0 -10-5 -10+$Y5 +10-5" { +foreach geom "+20+80 +80+$Y0 +0+$Y0 -0-0 +0-0 -0+$Y0 -10-5 -10+$Y5 +10-5" { test unixWm-3.$i {moving window while iconified} unix { wm iconify .t sleep 200 @@ -194,27 +195,27 @@ test unixWm-5.7 {compounded state changes} {unix nonPortable} { destroy .t toplevel .t -width 200 -height 100 -wm geom .t +10+23 +wm geom .t +10+$Y0 wm minsize .t 1 1 update test unixWm-6.1 {size changes} unix { .t config -width 180 -height 150 update wm geom .t -} 180x150+10+23 +} 180x150+10+$Y0 test unixWm-6.2 {size changes} unix { wm geom .t 250x60 .t config -width 170 -height 140 update wm geom .t -} 250x60+10+23 +} 250x60+10+$Y0 test unixWm-6.3 {size changes} unix { wm geom .t 250x60 .t config -width 170 -height 140 wm geom .t {} update wm geom .t -} 170x140+10+23 +} 170x140+10+$Y0 test unixWm-6.4 {size changes} {unix nonPortable userInteraction} { wm minsize .t 1 1 update @@ -1953,13 +1954,13 @@ test unixWm-50.7 {Tk_CoordsToWindow procedure, more basics} unix { test unixWm-50.8 {Tk_CoordsToWindow procedure, more basics} unix { destroy .t toplevel .t -width 400 -height 300 -bg green - wm geom .t +0+0 + wm geom .t +0+30 frame .t.f -width 200 -height 100 -bd 2 -relief raised place .t.f -x 100 -y 100 frame .t.f.f -width 200 -height 100 -bd 2 -relief raised place .t.f.f -x 100 -y 0 update - set x [winfo rooty .t] + set x [winfo rootx .t] set y [expr [winfo rooty .t] + 150] list [winfo containing [expr $x + 50] $y] \ [winfo containing [expr $x + 150] $y] \ -- cgit v0.12 From c160fe8bd880807117acc15040f8f4116ec85418 Mon Sep 17 00:00:00 2001 From: culler Date: Mon, 20 Jul 2020 19:46:37 +0000 Subject: Fix [cf38535396]: Aqua should use pixel-aligned dash pattern for non-Retina displays - patch from Christopher Chavez --- macosx/tkMacOSXDraw.c | 1 + 1 file changed, 1 insertion(+) diff --git a/macosx/tkMacOSXDraw.c b/macosx/tkMacOSXDraw.c index 7d12a4b..68e7ada 100644 --- a/macosx/tkMacOSXDraw.c +++ b/macosx/tkMacOSXDraw.c @@ -1763,6 +1763,7 @@ TkMacOSXSetupDrawingContext( int num = 0; char *p = &gc->dashes; CGFloat dashOffset = gc->dash_offset; + dashOffset -= (gc->line_width % 2) ? 0.5 : 0.0; CGFloat lengths[10]; while (p[num] != '\0' && num < 10) { -- cgit v0.12 From 76864c8a9ccb1c3400b2482b6d3c8f9d0d1101f9 Mon Sep 17 00:00:00 2001 From: culler Date: Tue, 21 Jul 2020 18:36:38 +0000 Subject: Improve image testing on macOS. --- generic/tkTest.c | 64 ++++++++++++++++++++++++++++++++---------------------- tests/canvImg.test | 23 ++++++++++---------- 2 files changed, 49 insertions(+), 38 deletions(-) diff --git a/generic/tkTest.c b/generic/tkTest.c index e80f488..c22e649 100644 --- a/generic/tkTest.c +++ b/generic/tkTest.c @@ -71,6 +71,8 @@ typedef struct TImageInstance { TImageMaster *masterPtr; /* Pointer to master for image. */ XColor *fg; /* Foreground color for drawing in image. */ GC gc; /* Graphics context for drawing in image. */ + Bool displayFailed; /* macOS display attempted out of drawRect. */ + char buffer[200 + TCL_INTEGER_SPACE * 6]; /* message to log on display. */ } TImageInstance; /* @@ -1517,6 +1519,7 @@ ImageGet( instPtr->fg = Tk_GetColor(timPtr->interp, tkwin, "#ff0000"); gcValues.foreground = instPtr->fg->pixel; instPtr->gc = Tk_GetGC(tkwin, GCForeground, &gcValues); + instPtr->displayFailed = False; return instPtr; } @@ -1551,41 +1554,50 @@ ImageDisplay( * imageX and imageY. */ { TImageInstance *instPtr = (TImageInstance *) clientData; - char buffer[200 + TCL_INTEGER_SPACE * 6]; /* * The purpose of the test image type is to track the calls to an image - * display proc and record the parameters passed in each call. On macOS - * a display proc must be run inside of the drawRect method of an NSView - * in order for the graphics operations to have any effect. To deal with + * display proc and record the parameters passed in each call. On macOS a + * display proc must be run inside of the drawRect method of an NSView in + * order for the graphics operations to have any effect. To deal with * this, whenever a display proc is called outside of any drawRect method - * it schedules a redraw of the NSView by calling [view setNeedsDisplay:YES]. - * This will trigger a later call to the view's drawRect method which will - * run the display proc a second time. + * it schedules a redraw of the NSView. * - * This complicates testing, since it can result in more calls to the display - * proc than are expected by the test. It can also result in an inconsistent - * number of calls unless the test waits until the call to drawRect actually - * occurs before validating its results. - * - * In an attempt to work around this, this display proc only logs those - * calls which occur within a drawRect method. This means that tests must - * be written so as to ensure that the drawRect method is run before - * results are validated. In practice it usually suffices to run update - * idletasks (to run the display proc the first time) followed by update - * (to run the display proc in drawRect). - * - * This also has the consequence that the image changed command will log - * different results on Aqua than on other systems, because when the image - * is redisplayed in the drawRect method the entire image will be drawn, - * not just the changed portion. Tests must account for this. + * In an attempt to work around this, each image instance maintains it own + * copy of the log message which gets written on the first call to the + * display proc. This usually means that the message created on macOS is + * the same as that created on other platforms. However it is possible + * for the messages to differ for other reasons, namely differences in + * how damage regions are computed. */ if (LOG_DISPLAY(drawable)) { - sprintf(buffer, "%s display %d %d %d %d", - instPtr->masterPtr->imageName, imageX, imageY, width, height); + if (instPtr->displayFailed == False) { + + /* + * Drawing is possible on the first call to DisplayImage. + * Log the message. + */ + + sprintf(instPtr->buffer, "%s display %d %d %d %d", + instPtr->masterPtr->imageName, imageX, imageY, width, height); + } Tcl_SetVar2(instPtr->masterPtr->interp, instPtr->masterPtr->varName, - NULL, buffer, TCL_GLOBAL_ONLY|TCL_APPEND_VALUE|TCL_LIST_ELEMENT); + NULL, instPtr->buffer, + TCL_GLOBAL_ONLY|TCL_APPEND_VALUE|TCL_LIST_ELEMENT); + instPtr->displayFailed = False; + } else { + + /* + * Drawing is not possible on the first call to DisplayImage. + * Save the message, but do not log it until the actual display. + */ + + if (instPtr->displayFailed == False) { + sprintf(instPtr->buffer, "%s display %d %d %d %d", + instPtr->masterPtr->imageName, imageX, imageY, width, height); + } + instPtr->displayFailed = True; } if (width > (instPtr->masterPtr->width - imageX)) { width = instPtr->masterPtr->width - imageX; diff --git a/tests/canvImg.test b/tests/canvImg.test index 1abea78..b57e21d 100644 --- a/tests/canvImg.test +++ b/tests/canvImg.test @@ -174,7 +174,7 @@ test canvImg-4.2 {ConfigureImage procedure} -constraints testImageType -setup { while {"timed out" ni $y && [lindex $y end 1] ne "display"} { vwait y } - after cancel timer + after cancel $timer list $x $y [.c bbox i1] } -cleanup { .c delete all @@ -739,7 +739,6 @@ test canvImg-10.1 {TranslateImage procedure} -constraints testImageType -setup { foo changed 2 4 6 8 30 15 vwait x after cancel $timer - update return $x } -cleanup { .c delete all @@ -756,7 +755,7 @@ test canvImg-11.1 {TranslateImage procedure} -constraints testImageType -setup { set x {} set timer [after 500 {lappend x "timed out"}] foo changed 2 4 6 8 40 50 - vwait x + vwait x after cancel $timer update return $x @@ -779,17 +778,18 @@ test canvImg-11.2 {ImageChangedProc procedure} -constraints { .c delete all image delete foo } -result {30 75 70 125} -if {[tk windowingsystem] == "aqua" && $tcl_platform(osVersion) > 18} { - # Aqua >= 10.14 will redraw the entire image. +if {[tk windowingsystem] == "aqua"} { +# # For this test only the 20x40 upper left corner of foo2 needs +# # to be redrawn, but Aqua redraws the entire image. set result_11_3 {{foo2 display 0 0 80 60}} -} else { - set result_11_3 {{foo2 display 0 0 20 40}} + } else { + set result_11_3 {{foo2 display 0 0 20 40}} } test canvImg-11.3 {ImageChangedProc procedure} -constraints { testImageType } -setup { .c delete all - update + update idletasks } -body { image create test foo -variable x image create test foo2 -variable z @@ -797,16 +797,15 @@ test canvImg-11.3 {ImageChangedProc procedure} -constraints { foo2 changed 0 0 0 0 80 60 .c create image 50 100 -image foo -tags image -anchor nw .c create image 70 110 -image foo2 -anchor nw - update idletasks set z {} set timer [after 500 {lappend z "timed out"}] - image create test foo -variable x - vwait x + image delete foo + vwait z after cancel $timer return $z } -cleanup { .c delete all - image delete foo foo2 + image delete foo2 } -result $result_11_3 # cleanup -- cgit v0.12 From f8b3a93842b3f805b1a470c0673fe2c1048a32b1 Mon Sep 17 00:00:00 2001 From: culler Date: Wed, 22 Jul 2020 02:09:02 +0000 Subject: Fix some compiler warnings on Sierra. --- macosx/tkMacOSXColor.c | 11 +++++++++++ macosx/tkMacOSXNotify.c | 2 ++ 2 files changed, 13 insertions(+) diff --git a/macosx/tkMacOSXColor.c b/macosx/tkMacOSXColor.c index a0eaa84..fd424cd 100644 --- a/macosx/tkMacOSXColor.c +++ b/macosx/tkMacOSXColor.c @@ -267,6 +267,16 @@ GetEntryFromPixelCode( *---------------------------------------------------------------------- */ +/* + * Apple claims that linkColor is available in 10.10 but the declaration + * does not appear in NSColor.h until later. Declaring it in a category + * appears to be harmless and stops the compiler warnings. + */ + +@interface NSColor(TkColor) +@property(class, strong, readonly) NSColor *linkColor; +@end + static NSColorSpace* sRGB = NULL; static CGFloat windowBackground[4] = {236.0 / 255, 236.0 / 255, 236.0 / 255, 1.0}; @@ -336,6 +346,7 @@ SetCGColorComponents( break; case 2: if ([NSApp macOSVersion] > 100900) { + #if MAC_OS_X_VERSION_MAX_ALLOWED > 1090 color = [[NSColor labelColor] colorUsingColorSpace:sRGB]; #endif diff --git a/macosx/tkMacOSXNotify.c b/macosx/tkMacOSXNotify.c index 367f3b6..83b4695 100644 --- a/macosx/tkMacOSXNotify.c +++ b/macosx/tkMacOSXNotify.c @@ -156,6 +156,7 @@ void DebugPrintQueue(void) * this block should be removed. */ +# if MAC_OSX_VERSION_MAX_ALLOWED >= 101500 if ([theEvent type] == NSAppKitDefined) { static Bool aWindowIsMoving = NO; switch([theEvent subtype]) { @@ -174,6 +175,7 @@ void DebugPrintQueue(void) break; } } +#endif [super sendEvent:theEvent]; [NSApp tkCheckPasteboard]; -- cgit v0.12 From 5297b4a5aa961d555081f871afd899f063b37fcc Mon Sep 17 00:00:00 2001 From: culler Date: Wed, 22 Jul 2020 03:30:07 +0000 Subject: Make image testing work better in the Sierras --- macosx/tkMacOSXTest.c | 30 ++++++++---------------------- 1 file changed, 8 insertions(+), 22 deletions(-) diff --git a/macosx/tkMacOSXTest.c b/macosx/tkMacOSXTest.c index 0a6f4e8..e5dcf5e 100644 --- a/macosx/tkMacOSXTest.c +++ b/macosx/tkMacOSXTest.c @@ -136,19 +136,12 @@ MenuBarHeightObjCmd( * TkTestLogDisplay -- * * The test image display procedure calls this to determine whether it - * should write a log message recording that it has being run. On OSX - * 10.14 and later, only calls to the display procedure which occur inside - * of the drawRect method should be logged, since those are the only ones - * which actually draw anything. On earlier systems the opposite is true. - * The calls from within the drawRect method are redundant, since the - * first time the display procedure is run it will do the drawing and that - * first call will usually not occur inside of drawRect. + * should write a log message recording that it has being run. * * Results: - * On OSX 10.14 and later, returns true if and only if the NSView of the - * drawable is the current focusView, which can only be the case when - * within [NSView drawRect]. On earlier systems returns false if - * and only if called from with [NSView drawRect]. + * Returns true if and only if the NSView of the drawable is the + * current focusView, which on 10.14 and newer systems can only be the + * case when within [NSView drawRect]. * * Side effects: * None @@ -168,18 +161,11 @@ TkTestLogDisplay( } else if (macWin->winPtr && macWin->winPtr->wmInfoPtr && macWin->winPtr->wmInfoPtr->window) { win = macWin->winPtr->wmInfoPtr->window; - }/* - else if (macWin->toplevel && (macWin->toplevel->flags & TK_EMBEDDED)) { - TkWindow *contWinPtr = TkpGetOtherWindow(macWin->toplevel->winPtr); - if (contWinPtr) { - win = TkMacOSXDrawableWindow((Drawable) contWinPtr->privatePtr); - } - }*/ - if (win && [NSApp macOSVersion] >= 101400) { - TKContentView *view = [win contentView]; - return (view == [NSView focusView]); + } + if (win) { + return ([win contentView] == [NSView focusView]); } else { - return ![NSApp isDrawing]; + return True; } } -- cgit v0.12 From 06178b77e52e18e6f3bafc4fee9f4049348b1292 Mon Sep 17 00:00:00 2001 From: culler Date: Wed, 22 Jul 2020 18:30:29 +0000 Subject: Fix Yosemite compiler warnings and bugs in tests revealed by testing on Yosemite. --- macosx/tkMacOSXColor.c | 9 +++++++-- tests/entry.test | 27 ++++++++++++++++----------- tests/spinbox.test | 38 +++++++++++++++++++++++++------------- tests/ttk/spinbox.test | 9 ++++++--- 4 files changed, 54 insertions(+), 29 deletions(-) diff --git a/macosx/tkMacOSXColor.c b/macosx/tkMacOSXColor.c index fd424cd..8e60552 100644 --- a/macosx/tkMacOSXColor.c +++ b/macosx/tkMacOSXColor.c @@ -273,8 +273,13 @@ GetEntryFromPixelCode( * appears to be harmless and stops the compiler warnings. */ + @interface NSColor(TkColor) +#if MAC_OS_X_VERSION_MAX_ALLOWED > 101100 @property(class, strong, readonly) NSColor *linkColor; +#else +@property(strong, readonly) NSColor *linkColor; +#endif @end static NSColorSpace* sRGB = NULL; @@ -389,8 +394,8 @@ SetCGColorComponents( } break; case 9: - if ([NSApp macOSVersion] >= 101000) { -#if MAC_OS_X_VERSION_MAX_ALLOWED >= 101000 + if ([NSApp macOSVersion] >= 101100) { +#if MAC_OS_X_VERSION_MAX_ALLOWED >= 101100 color = [[NSColor linkColor] colorUsingColorSpace:sRGB]; #endif } else { diff --git a/tests/entry.test b/tests/entry.test index f9879a2..8512b3f 100644 --- a/tests/entry.test +++ b/tests/entry.test @@ -12,6 +12,7 @@ eval tcltest::configure $argv tcltest::loadTestedCommands # For xscrollcommand +set scrollInfo {} proc scroll args { global scrollInfo set scrollInfo $args @@ -1671,9 +1672,10 @@ test entry-5.7 {ConfigureEntry procedure} -setup { } -body { .e configure -font {Courier -12} -width 4 -xscrollcommand scroll .e insert end "01234567890" - set timeout [after 500 {set $scrollInfo "timeout"}] - vwait scrollInfo + update idletasks + set timeout [after 500 {set scrollInfo {-1000000 -1000000}}] .e configure -width 5 + vwait scrollInfo format {%.6f %.6f} {*}$scrollInfo } -cleanup { destroy .e @@ -1916,9 +1918,9 @@ test entry-7.1 {InsertChars procedure} -setup { focus .e } -body { .e configure -textvariable contents -xscrollcommand scroll + set timeout [after 500 {set scrollInfo {-1000000 -1000000}}] .e insert 0 abcde .e insert 2 XXX - set timeout [after 500 {set $scrollInfo "timeout"}] vwait scrollInfo list [.e get] $contents [format {%.6f %.6f} {*}$scrollInfo] } -cleanup { @@ -1933,9 +1935,9 @@ test entry-7.2 {InsertChars procedure} -setup { focus .e } -body { .e configure -textvariable contents -xscrollcommand scroll + set timeout [after 500 {set scrollInfo {-1000000 -1000000}}] .e insert 0 abcde .e insert 500 XXX - set timeout [after 500 {set $scrollInfo "timeout"}] vwait scrollInfo list [.e get] $contents [format {%.6f %.6f} {*}$scrollInfo] } -cleanup { @@ -2067,9 +2069,9 @@ test entry-8.1 {DeleteChars procedure} -setup { focus .e } -body { .e configure -textvariable contents -xscrollcommand scroll + set timeout [after 500 {set scrollInfo {-1000000 -1000000}}] .e insert 0 abcde .e delete 2 4 - set timeout [after 500 {set $scrollInfo "timeout"}] vwait scrollInfo list [.e get] $contents [format {%.6f %.6f} {*}$scrollInfo] } -cleanup { @@ -2083,9 +2085,9 @@ test entry-8.2 {DeleteChars procedure} -setup { focus .e } -body { .e configure -textvariable contents -xscrollcommand scroll + set timeout [after 500 {set scrollInfo {-1000000 -1000000}}] .e insert 0 abcde .e delete -2 2 - set timeout [after 500 {set $scrollInfo "timeout"}] vwait scrollInfo list [.e get] $contents [format {%.6f %.6f} {*}$scrollInfo] } -cleanup { @@ -2099,9 +2101,9 @@ test entry-8.3 {DeleteChars procedure} -setup { focus .e } -body { .e configure -textvariable contents -xscrollcommand scroll + set timeout [after 500 {set scrollInfo {-1000000 -1000000}}] .e insert 0 abcde .e delete 3 1000 - set timeout [after 500 {set $scrollInfo "timeout"}] vwait scrollInfo list [.e get] $contents [format {%.6f %.6f} {*}$scrollInfo] } -cleanup { @@ -2937,9 +2939,10 @@ test entry-16.4 {EntryVisibleRange procedure} -body { test entry-17.1 {EntryUpdateScrollbar procedure} -body { entry .e -width 10 -xscrollcommand scroll -font {Courier -12} pack .e + update idletasks + set timeout [after 500 {set scrollInfo {-1000000 -1000000}}] .e delete 0 end .e insert 0 123 - set timeout [after 500 {set $scrollInfo "timeout"}] vwait scrollInfo format {%.6f %.6f} {*}$scrollInfo } -cleanup { @@ -2949,9 +2952,9 @@ test entry-17.1 {EntryUpdateScrollbar procedure} -body { test entry-17.2 {EntryUpdateScrollbar procedure} -body { entry .e -width 10 -xscrollcommand scroll -font {Courier -12} pack .e + set timeout [after 500 {set scrollInfo {-1000000 -1000000}}] .e insert 0 0123456789abcdef .e xview 3 - set timeout [after 500 {set $scrollInfo "timeout"}] vwait scrollInfo format {%.6f %.6f} {*}$scrollInfo } -cleanup { @@ -2961,9 +2964,9 @@ test entry-17.2 {EntryUpdateScrollbar procedure} -body { test entry-17.3 {EntryUpdateScrollbar procedure} -body { entry .e -width 10 -xscrollcommand scroll -font {Courier -12} pack .e + set timeout [after 500 {set scrollInfo {-1000000 -1000000}}] .e insert 0 abcdefghijklmnopqrs .e xview 6 - set timeout [after 500 {set $scrollInfo "timeout"}] vwait scrollInfo format {%.6f %.6f} {*}$scrollInfo } -cleanup { @@ -2976,8 +2979,10 @@ test entry-17.4 {EntryUpdateScrollbar procedure} -setup { set x $msg } } -body { - entry .e -width 5 -xscrollcommand thisisnotacommand + entry .e -width 5 pack .e + update idletasks + .e configure -xscrollcommand thisisnotacommand vwait x list $x $errorInfo } -cleanup { diff --git a/tests/spinbox.test b/tests/spinbox.test index 5d79c8e..3f55d7f 100644 --- a/tests/spinbox.test +++ b/tests/spinbox.test @@ -12,6 +12,7 @@ eval tcltest::configure $argv tcltest::loadTestedCommands # For xscrollcommand +set scrollInfo {} proc scroll args { global scrollInfo set scrollInfo $args @@ -2013,9 +2014,10 @@ test spinbox-5.7 {ConfigureSpinbox procedure} -setup { } -body { .e configure -font {Courier -12} -width 4 -xscrollcommand scroll .e insert end "01234567890" - set timeout [after 500 {set $scrollInfo "timeout"}] - vwait scrollInfo + update idletasks + set timeout [after 500 {set scrollInfo {-1000000 -1000000}}] .e configure -width 5 + vwait scrollInfo format {%.6f %.6f} {*}$scrollInfo } -cleanup { destroy .e @@ -2204,8 +2206,9 @@ test spinbox-7.1 {InsertChars procedure} -setup { } -body { .e configure -textvariable contents -xscrollcommand scroll .e insert 0 abcde + update idletasks + set timeout [after 500 {set scrollInfo {-1000000 -1000000}}] .e insert 2 XXX - set timeout [after 500 {set $scrollInfo "timeout"}] vwait scrollInfo list [.e get] $contents [format {%.6f %.6f} {*}$scrollInfo] } -cleanup { @@ -2221,8 +2224,9 @@ test spinbox-7.2 {InsertChars procedure} -setup { } -body { .e configure -textvariable contents -xscrollcommand scroll .e insert 0 abcde + update idletasks + set timeout [after 500 {set scrollInfo {-1000000 -1000000}}] .e insert 500 XXX - set timeout [after 500 {set $scrollInfo "timeout"}] vwait scrollInfo list [.e get] $contents [format {%.6f %.6f} {*}$scrollInfo] } -cleanup { @@ -2355,8 +2359,9 @@ test spinbox-8.1 {DeleteChars procedure} -setup { } -body { .e configure -textvariable contents -xscrollcommand scroll .e insert 0 abcde + update idletasks + set timeout [after 500 {set scrollInfo {-1000000 -1000000}}] .e delete 2 4 - set timeout [after 500 {set $scrollInfo "timeout"}] vwait scrollInfo list [.e get] $contents [format {%.6f %.6f} {*}$scrollInfo] } -cleanup { @@ -2371,8 +2376,9 @@ test spinbox-8.2 {DeleteChars procedure} -setup { } -body { .e configure -textvariable contents -xscrollcommand scroll .e insert 0 abcde + update idletasks + set timeout [after 500 {set scrollInfo {-1000000 -1000000}}] .e delete -2 2 - set timeout [after 500 {set $scrollInfo "timeout"}] vwait scrollInfo list [.e get] $contents [format {%.6f %.6f} {*}$scrollInfo] } -cleanup { @@ -2387,8 +2393,9 @@ test spinbox-8.3 {DeleteChars procedure} -setup { } -body { .e configure -textvariable contents -xscrollcommand scroll .e insert 0 abcde + update idletasks + set timeout [after 500 {set scrollInfo {-1000000 -1000000}}] .e delete 3 1000 - set timeout [after 500 {set $scrollInfo "timeout"}] vwait scrollInfo list [.e get] $contents [format {%.6f %.6f} {*}$scrollInfo] } -cleanup { @@ -3173,9 +3180,10 @@ test spinbox-16.2 {SpinboxVisibleRange procedure} -body { test spinbox-17.1 {SpinboxUpdateScrollbar procedure} -body { spinbox .e -width 10 -xscrollcommand scroll -font {Courier -12} pack .e + update idletasks + set timeout [after 500 {set scrollInfo {-1000000 -1000000}}] .e delete 0 end .e insert 0 123 - set timeout [after 500 {set $scrollInfo "timeout"}] vwait scrollInfo format {%.6f %.6f} {*}$scrollInfo } -cleanup { @@ -3186,8 +3194,9 @@ test spinbox-17.2 {SpinboxUpdateScrollbar procedure} -body { spinbox .e -width 10 -xscrollcommand scroll -font {Courier -12} pack .e .e insert 0 0123456789abcdef + update idletasks + set timeout [after 500 {set $scrollInfo {-1000000 -1000000}}] .e xview 3 - set timeout [after 500 {set $scrollInfo "timeout"}] vwait scrollInfo format {%.6f %.6f} {*}$scrollInfo } -cleanup { @@ -3197,23 +3206,26 @@ test spinbox-17.2 {SpinboxUpdateScrollbar procedure} -body { test spinbox-17.3 {SpinboxUpdateScrollbar procedure} -body { spinbox .e -width 10 -xscrollcommand scroll -font {Courier -12} pack .e + update idletasks + set timeout [after 500 {set scrollInfo {-1000000 -1000000}}] .e insert 0 abcdefghijklmnopqrs - .e xview 6 - set timeout [after 500 {set $scrollInfo "timeout"}] + .e xview vwait scrollInfo format {%.6f %.6f} {*}$scrollInfo } -cleanup { destroy .e after cancel $timeout -} -result {0.315789 0.842105} +} -result {0.000000 0.526316} test spinbox-17.4 {SpinboxUpdateScrollbar procedure} -setup { proc bgerror msg { global x set x $msg } } -body { - spinbox .e -width 5 -xscrollcommand thisisnotacommand + spinbox .e -width 5 pack .e + update idletasks + .e configure -xscrollcommand thisisnotacommand vwait x list $x $errorInfo } -cleanup { diff --git a/tests/ttk/spinbox.test b/tests/ttk/spinbox.test index 40cb244..b86f053 100644 --- a/tests/ttk/spinbox.test +++ b/tests/ttk/spinbox.test @@ -204,16 +204,19 @@ test spinbox-3.0 "textarea should expand to fill widget" -setup { set ::spinbox_test {} ttk::spinbox .sb -from 0 -to 10 -textvariable SBV } -body { - grid .sb -sticky ew grid columnconfigure . 0 -weight 1 + update idletasks + set timer [after 500 {set ::spinbox_test timedout}] bind . { after idle { wm geometry . "210x80" - after 100 {set ::spinbox_test [.sb identify element 5 5]} + update idletasks + set ::spinbox_test [.sb identify element 25 5] } bind . {} } - after 500 {set ::spinbox_wait 1} ; vwait ::spinbox_wait + grid .sb -sticky ew + vwait ::spinbox_test set ::spinbox_test } -cleanup { destroy .sb -- cgit v0.12 From 8355f067aeedc09f978725b0c5956924ac3542bc Mon Sep 17 00:00:00 2001 From: culler Date: Wed, 22 Jul 2020 20:52:47 +0000 Subject: Fix issues with mapping and unmapping windows revealed by tests on Yosemite. --- macosx/tkMacOSXSubwindows.c | 2 ++ macosx/tkMacOSXWindowEvent.c | 3 +-- macosx/tkMacOSXWm.c | 14 +++----------- tests/pack.test | 19 +++++++++++-------- 4 files changed, 17 insertions(+), 21 deletions(-) diff --git a/macosx/tkMacOSXSubwindows.c b/macosx/tkMacOSXSubwindows.c index 8bae8fd..030830d 100644 --- a/macosx/tkMacOSXSubwindows.c +++ b/macosx/tkMacOSXSubwindows.c @@ -206,6 +206,7 @@ XMapWindow( event.xmap.event = window; event.xmap.override_redirect = winPtr->atts.override_redirect; Tk_QueueWindowEvent(&event, TCL_QUEUE_TAIL); + while (Tcl_DoOneEvent(TCL_IDLE_EVENTS|TCL_WINDOW_EVENTS|TCL_DONT_WAIT)) {} } else { /* @@ -316,6 +317,7 @@ XUnmapWindow( event.xunmap.event = window; event.xunmap.from_configure = false; Tk_QueueWindowEvent(&event, TCL_QUEUE_TAIL); + while (Tcl_DoOneEvent(TCL_IDLE_EVENTS|TCL_WINDOW_EVENTS|TCL_DONT_WAIT)) {} } else { /* * Rebuild the visRgn clip region for the parent so it will be allowed diff --git a/macosx/tkMacOSXWindowEvent.c b/macosx/tkMacOSXWindowEvent.c index 5f52ea7..3f0e52f 100644 --- a/macosx/tkMacOSXWindowEvent.c +++ b/macosx/tkMacOSXWindowEvent.c @@ -117,8 +117,7 @@ extern NSString *NSWindowDidOrderOffScreenNotification; * Process all Tk events generated by Tk_MapWindow(). */ - while (Tcl_ServiceEvent(0)) {} - while (Tcl_DoOneEvent(TCL_IDLE_EVENTS)) {} + while (Tcl_DoOneEvent(TCL_IDLE_EVENTS|TCL_WINDOW_EVENTS|TCL_DONT_WAIT)) {} /* * NSWindowDidDeminiaturizeNotification is received after diff --git a/macosx/tkMacOSXWm.c b/macosx/tkMacOSXWm.c index dca8686..abaf152 100644 --- a/macosx/tkMacOSXWm.c +++ b/macosx/tkMacOSXWm.c @@ -1807,7 +1807,6 @@ WmDeiconifyCmd( Tcl_WrongNumArgs(interp, 2, objv, "window"); return TCL_ERROR; } - if (wmPtr->iconFor != NULL) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "can't deiconify %s: it is an icon for %s", @@ -6422,16 +6421,9 @@ TkpWmSetState( Tk_UnmapWindow((Tk_Window) winPtr); } else if (state == NormalState || state == ZoomState) { Tk_MapWindow((Tk_Window) winPtr); - if (macWin && ([macWin styleMask] & NSMiniaturizableWindowMask)) { - if ([macWin isMiniaturized]) { - [macWin deminiaturize:NSApp]; - } - else { - [macWin orderFront:nil]; - } - } - TkMacOSXZoomToplevel(macWin, state == NormalState ? inZoomIn : - inZoomOut); + [macWin deminiaturize:NSApp]; + [macWin orderFront:NSApp]; + TkMacOSXZoomToplevel(macWin, state == NormalState ? inZoomIn : inZoomOut); } } diff --git a/tests/pack.test b/tests/pack.test index b1c22c7..04e84b9 100644 --- a/tests/pack.test +++ b/tests/pack.test @@ -1554,6 +1554,7 @@ test pack-18.1 {unmap slaves when master unmapped} -constraints { tempNotPc } -setup { eval destroy [winfo child .pack] + update idletasks } -body { # adjust the position of .pack before test to avoid a screen switch @@ -1561,25 +1562,27 @@ test pack-18.1 {unmap slaves when master unmapped} -constraints { # as the screen (screen switch causes scale and other tests to fail). wm geometry .pack +100+100 + update idletasks # On the PC, when the width/height is configured while the window is # unmapped, the changes don't take effect until the window is remapped. # Who knows why? eval destroy [winfo child .pack] + update idletasks frame .pack.a -width 100 -height 50 -relief raised -bd 2 pack .pack.a - update + update idletasks set result [winfo ismapped .pack.a] wm iconify .pack - update + update idletasks lappend result [winfo ismapped .pack.a] .pack.a configure -width 200 -height 75 - update + update idletasks lappend result [winfo width .pack.a ] [winfo height .pack.a] \ [winfo ismapped .pack.a] wm deiconify .pack - update + update idletasks lappend result [winfo ismapped .pack.a] } -result {1 0 200 75 0 1} test pack-18.2 {unmap slaves when master unmapped} -setup { @@ -1595,17 +1598,17 @@ test pack-18.2 {unmap slaves when master unmapped} -setup { frame .pack.b -width 70 -height 30 -relief sunken -bd 2 pack .pack.a pack .pack.b -in .pack.a - update + update idletasks set result [winfo ismapped .pack.b] wm iconify .pack - update + update idletasks lappend result [winfo ismapped .pack.b] .pack.b configure -width 100 -height 30 - update + update idletasks lappend result [winfo width .pack.b ] [winfo height .pack.b] \ [winfo ismapped .pack.b] wm deiconify .pack - update + update idletasks lappend result [winfo ismapped .pack.b] } -result {1 0 100 30 0 1} -- cgit v0.12 From e9fb55d44123ed3f5db96f308e4143e6efa22205 Mon Sep 17 00:00:00 2001 From: culler Date: Wed, 22 Jul 2020 21:31:41 +0000 Subject: More Yosemite fixes. Why did it start to hang in safePrimarySelection-3.1? --- macosx/tkMacOSXWm.c | 4 +++- tests/place.test | 17 +++++++++-------- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/macosx/tkMacOSXWm.c b/macosx/tkMacOSXWm.c index abaf152..3af2ff5 100644 --- a/macosx/tkMacOSXWm.c +++ b/macosx/tkMacOSXWm.c @@ -6870,7 +6870,6 @@ ApplyWindowAttributeFlagChanges( b |= (NSWindowCollectionBehaviorCanJoinAllSpaces | NSWindowCollectionBehaviorFullScreenAuxiliary); } else { - NSSize screenSize = [[macWindow screen] frame].size; b |= NSWindowCollectionBehaviorFullScreenPrimary; /* @@ -6881,7 +6880,10 @@ ApplyWindowAttributeFlagChanges( * to the screen size. (For 10.11 and up, only) */ if ([NSApp macOSVersion] > 101000) { +#if !(MAC_OS_X_VERSION_MAX_ALLOWED > 101000) + NSSize screenSize = [[macWindow screen] frame].size; [macWindow setMaxFullScreenContentSize:screenSize]; +#endif } } } diff --git a/tests/place.test b/tests/place.test index 62e0ed2..56ddde4 100644 --- a/tests/place.test +++ b/tests/place.test @@ -264,34 +264,35 @@ test place-8.1 {MasterStructureProc, mapping and unmapping slaves} -setup { place forget .t.f } -body { place .t.f2 -relx 1.0 -rely 1.0 -anchor sw - update + update idletasks set result [winfo ismapped .t.f2] wm iconify .t - update + update idletasks lappend result [winfo ismapped .t.f2] place .t.f2 -x 40 -y 30 -relx 0 -rely 0 -anchor nw - update + update idletasks lappend result [winfo x .t.f2] [winfo y .t.f2] [winfo ismapped .t.f2] wm deiconify .t - update + update idletasks lappend result [winfo ismapped .t.f2] } -result {1 0 40 30 0 1} test place-8.2 {MasterStructureProc, mapping and unmapping slaves} -setup { place forget .t.f2 place forget .t.f + update idletasks } -body { place .t.f -x 0 -y 0 -width 200 -height 100 place .t.f2 -in .t.f -relx 1.0 -rely 1.0 -anchor sw -width 50 -height 20 - update + update idletasks set result [winfo ismapped .t.f2] wm iconify .t - update + update idletasks lappend result [winfo ismapped .t.f2] place .t.f2 -x 40 -y 30 -relx 0 -rely 0 -anchor nw - update + update idletasks lappend result [winfo x .t.f2] [winfo y .t.f2] [winfo ismapped .t.f2] wm deiconify .t - update + update idletasks lappend result [winfo ismapped .t.f2] } -result {1 0 42 32 0 1} destroy .t -- cgit v0.12 From 7da497b576c4b2fa5bf3660f84e6984d55b376f1 Mon Sep 17 00:00:00 2001 From: culler Date: Thu, 23 Jul 2020 15:22:33 +0000 Subject: The added event loops work to update the mapped flags for packed and placed windows, but they break more than they fix. --- macosx/tkMacOSXSubwindows.c | 2 -- macosx/tkMacOSXWindowEvent.c | 3 ++- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/macosx/tkMacOSXSubwindows.c b/macosx/tkMacOSXSubwindows.c index 030830d..8bae8fd 100644 --- a/macosx/tkMacOSXSubwindows.c +++ b/macosx/tkMacOSXSubwindows.c @@ -206,7 +206,6 @@ XMapWindow( event.xmap.event = window; event.xmap.override_redirect = winPtr->atts.override_redirect; Tk_QueueWindowEvent(&event, TCL_QUEUE_TAIL); - while (Tcl_DoOneEvent(TCL_IDLE_EVENTS|TCL_WINDOW_EVENTS|TCL_DONT_WAIT)) {} } else { /* @@ -317,7 +316,6 @@ XUnmapWindow( event.xunmap.event = window; event.xunmap.from_configure = false; Tk_QueueWindowEvent(&event, TCL_QUEUE_TAIL); - while (Tcl_DoOneEvent(TCL_IDLE_EVENTS|TCL_WINDOW_EVENTS|TCL_DONT_WAIT)) {} } else { /* * Rebuild the visRgn clip region for the parent so it will be allowed diff --git a/macosx/tkMacOSXWindowEvent.c b/macosx/tkMacOSXWindowEvent.c index 3f0e52f..5f52ea7 100644 --- a/macosx/tkMacOSXWindowEvent.c +++ b/macosx/tkMacOSXWindowEvent.c @@ -117,7 +117,8 @@ extern NSString *NSWindowDidOrderOffScreenNotification; * Process all Tk events generated by Tk_MapWindow(). */ - while (Tcl_DoOneEvent(TCL_IDLE_EVENTS|TCL_WINDOW_EVENTS|TCL_DONT_WAIT)) {} + while (Tcl_ServiceEvent(0)) {} + while (Tcl_DoOneEvent(TCL_IDLE_EVENTS)) {} /* * NSWindowDidDeminiaturizeNotification is received after -- cgit v0.12 From 364c3cdadc46755bf53a69063125d5efbe391f0e Mon Sep 17 00:00:00 2001 From: culler Date: Thu, 23 Jul 2020 16:22:02 +0000 Subject: Deal with mapping/unmapping packed and placed subwindows in a benign way. --- macosx/tkMacOSXSubwindows.c | 20 ++++++++++++++++++-- tests/unixWm.test | 42 ++++++++++++------------------------------ 2 files changed, 30 insertions(+), 32 deletions(-) diff --git a/macosx/tkMacOSXSubwindows.c b/macosx/tkMacOSXSubwindows.c index 8bae8fd..a58bab4 100644 --- a/macosx/tkMacOSXSubwindows.c +++ b/macosx/tkMacOSXSubwindows.c @@ -205,7 +205,15 @@ XMapWindow( event.xmap.type = MapNotify; event.xmap.event = window; event.xmap.override_redirect = winPtr->atts.override_redirect; - Tk_QueueWindowEvent(&event, TCL_QUEUE_TAIL); + + /* + * To update the mapped status of packed or placed subwindows + * we handle this event immediately and then process the idle + * events that it generates. + */ + + Tk_HandleEvent(&event); + while (Tcl_DoOneEvent(TCL_IDLE_EVENTS)) {} } else { /* @@ -315,7 +323,15 @@ XUnmapWindow( event.xunmap.window = window; event.xunmap.event = window; event.xunmap.from_configure = false; - Tk_QueueWindowEvent(&event, TCL_QUEUE_TAIL); + + /* + * To update the mapped status of packed or placed subwindows + * we handle this event immediately and then process the idle + * events that it generates. + */ + + Tk_HandleEvent(&event); + while (Tcl_DoOneEvent(TCL_IDLE_EVENTS)) {} } else { /* * Rebuild the visRgn clip region for the parent so it will be allowed diff --git a/tests/unixWm.test b/tests/unixWm.test index b6efb42..bd68511 100644 --- a/tests/unixWm.test +++ b/tests/unixWm.test @@ -19,16 +19,6 @@ proc sleep ms { vwait x } -# The macOS window manager shows an animation when a window is deiconified. -# Tests which check the geometry of a window after deiconifying it should -# wait for the animation to finish. - - proc animationDelay {} { - if {[tk windowingsystem] == "aqua"} { - sleep 250 - } - } - # Procedure to set up a collection of top-level windows proc makeToplevels {} { @@ -98,11 +88,11 @@ set i 1 foreach geom "+20+80 +80+$Y0 +0+$Y0 -0-0 +0-0 -0+$Y0 -10-5 -10+$Y5 +10-5" { test unixWm-3.$i {moving window while iconified} unix { wm iconify .t - sleep 200 + update idletasks wm geom .t $geom - update + update idletasks wm deiconify .t - animationDelay + update idletasks scan [wm geom .t] %dx%d%1s%d%1s%d width height xsign x ysign y format "%s%d%s%d" $xsign [eval expr $x$xsign$xerr] $ysign \ [eval expr $y$ysign$yerr] @@ -114,11 +104,11 @@ set i 1 foreach geom "+20+80 +100+40 +0+$Y0" { test unixWm-4.$i {moving window while withdrawn} unix { wm withdraw .t - sleep 200 + update idletasks wm geom .t $geom - update + update idletasks wm deiconify .t - animationDelay + update idletasks wm geom .t } 100x150$geom incr i @@ -349,7 +339,6 @@ test unixWm-8.8 {icon windows} unix { wm geom .t +0+0 tkwait visibility .t ;# Needed to keep tvtwm happy. wm iconwindow .t .icon - sleep 500 lappend result [winfo ismapped .t] [winfo ismapped .icon] } {1 1 0} test unixWm-8.9 {icon windows} {unix nonPortable} { @@ -421,12 +410,10 @@ test unixWm-9.3 {TkWmMapWindow procedure, iconic windows} unix { toplevel .t -width 100 -height 300 -bg blue wm geom .t +0+0 wm iconify .t - sleep 500 winfo ismapped .t } {0} test unixWm-9.4 {TkWmMapWindow procedure, icon windows} unix { destroy .t - sleep 500 toplevel .t -width 100 -height 50 -bg blue tkwait visibility .t wm iconwindow . .t @@ -1385,12 +1372,13 @@ test unixWm-40.2 {Tk_SetGrid procedure, turning on grid when dimensions already test unixWm-41.1 {ConfigureEvent procedure, internally generated size changes} unix { destroy .t toplevel .t -width 400 -height 150 - wm geometry .t +0+0 tkwait visibility .t + wm geometry .t +0+0 + update idletasks set result {} lappend result [winfo width .t] [winfo height .t] .t configure -width 200 -height 300 - sleep 500 + update idletasks lappend result [winfo width .t] [winfo height .t] } {400 150 200 300} test unixWm-41.2 {ConfigureEvent procedure, menubars} {nonPortable testmenubar} { @@ -1454,11 +1442,11 @@ test unixWm-42.1 {WrapperEventProc procedure, map and unmap events} unix { bind .t {set x "unmapped"} set x {no event} wm iconify .t - animationDelay + update idletasks lappend result $x [winfo ismapped .t] set x {no event} wm deiconify .t - animationDelay + update idletasks lappend result $x [winfo ismapped .t] } {unmapped 0 mapped 1} @@ -1971,7 +1959,6 @@ test unixWm-50.8 {Tk_CoordsToWindow procedure, more basics} unix { test unixWm-50.9 {Tk_CoordsToWindow procedure, unmapped windows} unix { destroy .t destroy .t2 - sleep 500 ;# Give window manager time to catch up. toplevel .t -width 200 -height 200 -bg green wm geometry .t +0+0 tkwait visibility .t @@ -1980,7 +1967,7 @@ test unixWm-50.9 {Tk_CoordsToWindow procedure, unmapped windows} unix { tkwait visibility .t2 set result [list [winfo containing 100 100]] wm iconify .t2 - animationDelay + update idletasks lappend result [winfo containing 100 100] } {.t2 .t} test unixWm-50.10 {Tk_CoordsToWindow procedure, unmapped windows} unix { @@ -2022,7 +2009,6 @@ test unixWm-51.3 {TkWmRestackToplevel procedure, basic tests} {unix nonPortable} set result [winfo containing [winfo rootx .raise1] \ [winfo rooty .raise1]] destroy .raise2 - sleep 500 list $result [winfo containing [winfo rootx .raise1] \ [winfo rooty .raise1]] } {.raise2 .raise1} @@ -2033,7 +2019,6 @@ test unixWm-51.4 {TkWmRestackToplevel procedure, basic tests} {unix nonPortable} lower .raise3 .raise1 set result [winfo containing 100 100] destroy .raise1 - sleep 500 lappend result [winfo containing 100 100] } {.raise1 .raise3} test unixWm-51.5 {TkWmRestackToplevel procedure, basic tests} {unix nonPortable} { @@ -2048,7 +2033,6 @@ test unixWm-51.5 {TkWmRestackToplevel procedure, basic tests} {unix nonPortable} set result [winfo containing [winfo rootx .raise1] \ [winfo rooty .raise1]] destroy .raise1 - sleep 500 list $result [winfo containing [winfo rootx .raise2] \ [winfo rooty .raise2]] } {.raise1 .raise3} @@ -2071,11 +2055,9 @@ test unixWm-51.7 {TkWmRestackToplevel procedure, other window isn't mapped} unix wm geometry $w +0+0 } raise .t .t2 - sleep 2000 update set result [list [winfo containing 100 100]] lower .t3 - sleep 2000 lappend result [winfo containing 100 100] } {.t3 .t} test unixWm-51.8 {TkWmRestackToplevel procedure, overrideredirect windows} unix { -- cgit v0.12 From c4ee254b9c95c505554f58ca85c20f1ede0a1e52 Mon Sep 17 00:00:00 2001 From: culler Date: Thu, 23 Jul 2020 16:56:13 +0000 Subject: All tests pass on Yosemite now. --- macosx/tkMacOSXWm.c | 5 +++++ tests/unixWm.test | 14 ++++++++------ tests/wm.test | 20 +++++++++++--------- 3 files changed, 24 insertions(+), 15 deletions(-) diff --git a/macosx/tkMacOSXWm.c b/macosx/tkMacOSXWm.c index 3af2ff5..90e4a70 100644 --- a/macosx/tkMacOSXWm.c +++ b/macosx/tkMacOSXWm.c @@ -6425,6 +6425,11 @@ TkpWmSetState( [macWin orderFront:NSApp]; TkMacOSXZoomToplevel(macWin, state == NormalState ? inZoomIn : inZoomOut); } + /* + * Make sure windows are updated after the state change. + */ + + while (Tcl_DoOneEvent(TCL_IDLE_EVENTS)){} } /* diff --git a/tests/unixWm.test b/tests/unixWm.test index bd68511..39a68ae 100644 --- a/tests/unixWm.test +++ b/tests/unixWm.test @@ -292,6 +292,7 @@ test unixWm-8.4 {icon windows} unix { destroy .icon toplevel .t -width 100 -height 30 wm geom .t +0+0 + update idletasks set result [wm iconwindow .t] toplevel .icon -width 50 -height 50 -bg red wm iconwindow .t .icon @@ -301,7 +302,7 @@ test unixWm-8.4 {icon windows} unix { update lappend result [winfo ismapped .t] [winfo ismapped .icon] wm iconify .t - update + update idletasks lappend result [winfo ismapped .t] [winfo ismapped .icon] } {.icon icon {} withdrawn 1 0 0 0} test unixWm-8.5 {icon windows} unix { @@ -854,9 +855,9 @@ test unixWm-23.5 {Tk_WmCmd procedure, "iconify" option} unix { destroy .t2 toplevel .t2 wm geom .t2 +0+0 - update + update idletasks wm iconify .t2 - update + update idletasks set result [winfo ismapped .t2] destroy .t2 set result @@ -865,10 +866,10 @@ test unixWm-23.6 {Tk_WmCmd procedure, "iconify" option} unix { destroy .t2 toplevel .t2 wm geom .t2 -0+0 - update + update idletasks set result [winfo ismapped .t2] wm iconify .t2 - update + update idletasks lappend result [winfo ismapped .t2] destroy .t2 set result @@ -1977,9 +1978,10 @@ test unixWm-50.10 {Tk_CoordsToWindow procedure, unmapped windows} unix { frame .t.f -width 150 -height 150 -bd 2 -relief raised place .t.f -x 25 -y 25 tkwait visibility .t.f + update idletasks set result [list [winfo containing 100 100]] place forget .t.f - update + update idletasks lappend result [winfo containing 100 100] } {.t.f .t} deleteWindows diff --git a/tests/wm.test b/tests/wm.test index 9e6d8ce..fac02fe 100644 --- a/tests/wm.test +++ b/tests/wm.test @@ -33,7 +33,9 @@ proc stdWindow {} { # proc raiseDelay {} { - after 100; update + after 100; + update + update idletasks } # How to carry out a small delay while processing events @@ -808,10 +810,10 @@ test wm-iconify-2.4.2 {Misc errors} -constraints !win -setup { test wm-iconify-3.1 {iconify behavior} -body { toplevel .t2 wm geom .t2 -0+0 - update + update idletasks set result [winfo ismapped .t2] wm iconify .t2 - update + update idletasks lappend result [winfo ismapped .t2] } -cleanup { destroy .t2 @@ -1738,11 +1740,11 @@ test wm-transient-4.2 {already mapped transient toplevel toplevel .master raiseDelay wm iconify .master - update + update idletasks toplevel .subject - update + update idletasks wm transient .subject .master - update + update idletasks list [wm state .subject] [winfo ismapped .subject] } -cleanup { deleteWindows @@ -1753,13 +1755,13 @@ test wm-transient-4.3 {iconify/deiconify on the master } -body { toplevel .master toplevel .subject - update + update idletasks wm transient .subject .master wm iconify .master - update + update idletasks lappend results [wm state .subject] [winfo ismapped .subject] wm deiconify .master - update + update idletasks lappend results [wm state .subject] [winfo ismapped .subject] } -cleanup { deleteWindows -- cgit v0.12 From e0db4c3e05bfcb007efd84b383f9f103d1905cc9 Mon Sep 17 00:00:00 2001 From: culler Date: Thu, 23 Jul 2020 17:13:31 +0000 Subject: See if we can speed up textDisp.test --- tests/textDisp.test | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/tests/textDisp.test b/tests/textDisp.test index 796fd92..8e971f3 100644 --- a/tests/textDisp.test +++ b/tests/textDisp.test @@ -3961,12 +3961,12 @@ test textDisp-31.3 {line update index shifting} { .t insert 1.0 "abc\n" .t insert 1.0 "abc\n" lappend res [.t count -ypixels 1.0 end] - update ; after 1000 ; update + update idletasks ; after 100 ; update idletasks lappend res [.t count -ypixels 1.0 end] .t.f configure -height 100 .t delete 1.0 3.0 lappend res [.t count -ypixels 1.0 end] - update ; after 1000 ; update + update idletasks ; after 100 ; update idletasks lappend res [.t count -ypixels 1.0 end] set res } [list [expr {100 + $fixedHeight * 6}] [expr {100 + $fixedHeight * 8}] [expr {$fixedHeight * 9}] [expr {$fixedHeight * 7}] [expr {100 + $fixedHeight * 6}]] @@ -4014,12 +4014,12 @@ test textDisp-31.6 {line update index shifting} { .t insert 1.0 "abc\n" .t insert 1.0 "abc\n" lappend res [.t count -ypixels 1.0 end] - update ; after 1000 ; update + update idletasks ; after 100 ; update idletasks lappend res [.t count -ypixels 1.0 end] textest configure -height 100 .t delete 1.0 3.0 lappend res [.t count -ypixels 1.0 end] - update ; after 1000 ; update + update idletasks ; after 100 ; update idletasks lappend res [.t count -ypixels 1.0 end] set res } [list [expr {100 + $fixedHeight * 6}] [expr {100 + $fixedHeight * 8}] [expr {$fixedHeight * 9}] [expr {$fixedHeight * 7}] [expr {100 + $fixedHeight * 6}]] @@ -4036,11 +4036,11 @@ test textDisp-31.7 {line update index shifting, elided} { .t tag configure elide -elide 1 .t tag add elide 1.3 2.1 lappend res [.t count -ypixels 1.0 end] - update ; after 1000 ; update + update idletasks ; after 100 ; update idletasks lappend res [.t count -ypixels 1.0 end] .t delete 1.0 3.0 lappend res [.t count -ypixels 1.0 end] - update ; after 1000 ; update + update idletasks ; after 100 ; update idletasks lappend res [.t count -ypixels 1.0 end] set res } [list [expr {$fixedHeight * 1}] [expr {$fixedHeight * 3}] [expr {$fixedHeight * 3}] [expr {$fixedHeight * 2}] [expr {$fixedHeight * 1}] [expr {$fixedHeight * 1}]] -- cgit v0.12 From 80385f2de091d03d59900dc2acf17c23beeac2aa Mon Sep 17 00:00:00 2001 From: culler Date: Thu, 23 Jul 2020 17:48:52 +0000 Subject: Fix build on Mavericks. --- macosx/tkMacOSXDraw.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/macosx/tkMacOSXDraw.c b/macosx/tkMacOSXDraw.c index 68e7ada..fd8a1eb 100644 --- a/macosx/tkMacOSXDraw.c +++ b/macosx/tkMacOSXDraw.c @@ -17,7 +17,7 @@ #include "tkMacOSXDebug.h" #include "tkButton.h" -#if MAC_OS_X_VERSION_MIN_REQUIRED >= 101400 +#if MAC_OS_X_VERSION_MAX_ALLOWED >= 101000 #define GET_CGCONTEXT [[NSGraphicsContext currentContext] CGContext] #else #define GET_CGCONTEXT [[NSGraphicsContext currentContext] graphicsPort] @@ -1666,8 +1666,7 @@ TkMacOSXSetupDrawingContext( * cycle. */ - CGRect currentClip = CGContextGetClipBoundingBox( - [NSGraphicsContext currentContext].CGContext); + CGRect currentClip = CGContextGetClipBoundingBox(GET_CGCONTEXT); if (!NSContainsRect(currentClip, clipBounds)) { [view addTkDirtyRect:clipBounds]; } -- cgit v0.12 From 4615f0cfbe56b6b931f06600823609452ceae3f2 Mon Sep 17 00:00:00 2001 From: culler Date: Thu, 23 Jul 2020 18:31:06 +0000 Subject: Adjust listbox-21.9 --- tests/listbox.test | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/tests/listbox.test b/tests/listbox.test index 01cc397..17b6e6b 100644 --- a/tests/listbox.test +++ b/tests/listbox.test @@ -2663,19 +2663,18 @@ test listbox-21.9 {ListboxListVarProc, test hscrollbar after listvar mod} -setup destroy .l } -body { catch {unset x} - listbox .l -font $fixed -width 10 -xscrollcommand "record x" -listvar x set log {} + update idletasks + listbox .l -font $fixed -width 10 -xscrollcommand "record x" -listvar x pack .l - set timeout [after 500 {lappend log timeout1}] - vwait log + update idletasks lappend x "0000000000" - update + update idletasks lappend x "00000000000000000000" - update + update idletasks set log } -cleanup { destroy .l - after cancel $timeout } -result [list {x 0 1} {x 0 1} {x 0 0.5}] test listbox-21.10 {ListboxListVarProc, test hscrollbar after listvar mod} -setup { destroy .l -- cgit v0.12 From 39d44641837b76035b4eff6b6f153ea07720b81f Mon Sep 17 00:00:00 2001 From: culler Date: Thu, 23 Jul 2020 19:14:17 +0000 Subject: Fix the (re)declaration of linkColor so it works on all systems. --- macosx/tkMacOSXColor.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/macosx/tkMacOSXColor.c b/macosx/tkMacOSXColor.c index 8e60552..758c458 100644 --- a/macosx/tkMacOSXColor.c +++ b/macosx/tkMacOSXColor.c @@ -275,11 +275,7 @@ GetEntryFromPixelCode( @interface NSColor(TkColor) -#if MAC_OS_X_VERSION_MAX_ALLOWED > 101100 -@property(class, strong, readonly) NSColor *linkColor; -#else @property(strong, readonly) NSColor *linkColor; -#endif @end static NSColorSpace* sRGB = NULL; -- cgit v0.12 From ef7581bec4c78d6fb07d451dc6da67a333422d83 Mon Sep 17 00:00:00 2001 From: culler Date: Thu, 23 Jul 2020 19:44:17 +0000 Subject: Adjust a couple of textDisp tests for El Capitan --- tests/textDisp.test | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/tests/textDisp.test b/tests/textDisp.test index 8e971f3..b0560d8 100644 --- a/tests/textDisp.test +++ b/tests/textDisp.test @@ -4175,6 +4175,7 @@ test textDisp-32.3 "NULL undisplayProc problems: #1791052" -setup { test textDisp-33.0 {one line longer than fits in the widget} { pack [text .tt -wrap char] + updateText .tt insert 1.0 [string repeat "more wrap + " 300] updateText .tt see 1.0 @@ -4183,6 +4184,7 @@ test textDisp-33.0 {one line longer than fits in the widget} { test textDisp-33.1 {one line longer than fits in the widget} { destroy .tt pack [text .tt -wrap char] + updateText .tt insert 1.0 [string repeat "more wrap + " 300] updateText .tt yview "1.0 +1 displaylines" @@ -4196,12 +4198,12 @@ test textDisp-33.2 {one line longer than fits in the widget} { destroy .tt pack [text .tt -wrap char] .tt debug 1 - update idletasks + updateText set tk_textHeightCalc "" - set timer [after 700 lappend tk_textHeightCalc "Timed out"] + set timer [after 200 lappend tk_textHeightCalc "Timed out"] .tt insert 1.0 [string repeat "more wrap + " 1] vwait tk_textHeightCalc - after cancel timer + after cancel $timer set tk_textHeightCalc } {1.0} test textDisp-33.3 {one line longer than fits in the widget} { -- cgit v0.12 From b00f202e7437c114c8c278c65c2ebe18c7bc85f7 Mon Sep 17 00:00:00 2001 From: fvogel Date: Thu, 23 Jul 2020 19:53:03 +0000 Subject: Commit [4c6a42bd] changed the font used in textWind.test for aqua. It appears we can use 'Courier' instead of 'Courier New' on all three platforms with no failure (tested on Windows Vista and Linux Debian 10). --- tests/textWind.test | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/tests/textWind.test b/tests/textWind.test index b453feb..8edd825 100644 --- a/tests/textWind.test +++ b/tests/textWind.test @@ -13,11 +13,7 @@ tcltest::loadTestedCommands deleteWindows -if {[tk windowingsystem] eq "aqua"} { - set fixedFont {"Courier" -12} -} else { - set fixedFont {"Courier New" -12} -} +set fixedFont {"Courier" -12} set fixedHeight [font metrics $fixedFont -linespace] set fixedWidth [font measure $fixedFont m] set fixedAscent [font metrics $fixedFont -ascent] -- cgit v0.12 From 8ed3b12de30efc4a2770627d32616cd91080a22c Mon Sep 17 00:00:00 2001 From: culler Date: Thu, 23 Jul 2020 20:32:50 +0000 Subject: Another adjustment to listbox-21.9 --- tests/listbox.test | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/tests/listbox.test b/tests/listbox.test index 17b6e6b..84f2d4a 100644 --- a/tests/listbox.test +++ b/tests/listbox.test @@ -2662,11 +2662,10 @@ test listbox-21.8 {ListboxListVarProc, test selection after listvar mod} -setup test listbox-21.9 {ListboxListVarProc, test hscrollbar after listvar mod} -setup { destroy .l } -body { - catch {unset x} - set log {} - update idletasks + set x {} listbox .l -font $fixed -width 10 -xscrollcommand "record x" -listvar x pack .l + set log {} update idletasks lappend x "0000000000" update idletasks @@ -2675,7 +2674,7 @@ test listbox-21.9 {ListboxListVarProc, test hscrollbar after listvar mod} -setup set log } -cleanup { destroy .l -} -result [list {x 0 1} {x 0 1} {x 0 0.5}] +} -result [list {x 0 1} {x 0 0.5}] test listbox-21.10 {ListboxListVarProc, test hscrollbar after listvar mod} -setup { destroy .l } -body { -- cgit v0.12 From 5508426b3e669226e9da1901ce5cda463d3dee96 Mon Sep 17 00:00:00 2001 From: culler Date: Thu, 23 Jul 2020 20:46:21 +0000 Subject: Still fiddling with listbox-21.9 --- tests/listbox.test | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/listbox.test b/tests/listbox.test index 84f2d4a..806bbe0 100644 --- a/tests/listbox.test +++ b/tests/listbox.test @@ -2665,8 +2665,8 @@ test listbox-21.9 {ListboxListVarProc, test hscrollbar after listvar mod} -setup set x {} listbox .l -font $fixed -width 10 -xscrollcommand "record x" -listvar x pack .l - set log {} update idletasks + set log {} lappend x "0000000000" update idletasks lappend x "00000000000000000000" -- cgit v0.12 From 45c939237b9e173457e588379c906a8e82211b78 Mon Sep 17 00:00:00 2001 From: culler Date: Thu, 23 Jul 2020 21:25:10 +0000 Subject: On Sierra the linkColor property must be explicitly declared as a class property. --- macosx/tkMacOSXColor.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/macosx/tkMacOSXColor.c b/macosx/tkMacOSXColor.c index 758c458..51a28c5 100644 --- a/macosx/tkMacOSXColor.c +++ b/macosx/tkMacOSXColor.c @@ -274,9 +274,15 @@ GetEntryFromPixelCode( */ +#if MAC_OS_X_VERSION_MAX_ALLOWED >= 101200 +@interface NSColor(TkColor) +@property(class, strong, readonly) NSColor *linkColor; +@end +#else @interface NSColor(TkColor) @property(strong, readonly) NSColor *linkColor; @end +#endif static NSColorSpace* sRGB = NULL; static CGFloat windowBackground[4] = -- cgit v0.12 From a965e9c43e2e9889b4cb3581bc91221c087a7c25 Mon Sep 17 00:00:00 2001 From: culler Date: Fri, 24 Jul 2020 15:32:53 +0000 Subject: Fix Windows tests which were affected by the Mac changes. --- tests/canvImg.test | 10 ++-------- tests/pack.test | 18 +++++++++++------- tests/place.test | 14 ++++++++++---- tests/textDisp.test | 22 ++++++++++++++++------ 4 files changed, 39 insertions(+), 25 deletions(-) diff --git a/tests/canvImg.test b/tests/canvImg.test index b57e21d..a3524f1 100644 --- a/tests/canvImg.test +++ b/tests/canvImg.test @@ -778,13 +778,7 @@ test canvImg-11.2 {ImageChangedProc procedure} -constraints { .c delete all image delete foo } -result {30 75 70 125} -if {[tk windowingsystem] == "aqua"} { -# # For this test only the 20x40 upper left corner of foo2 needs -# # to be redrawn, but Aqua redraws the entire image. - set result_11_3 {{foo2 display 0 0 80 60}} - } else { - set result_11_3 {{foo2 display 0 0 20 40}} -} + test canvImg-11.3 {ImageChangedProc procedure} -constraints { testImageType } -setup { @@ -806,7 +800,7 @@ test canvImg-11.3 {ImageChangedProc procedure} -constraints { } -cleanup { .c delete all image delete foo2 -} -result $result_11_3 +} -result {{foo2 display 0 0 80 60}} # cleanup imageFinish diff --git a/tests/pack.test b/tests/pack.test index 04e84b9..86fcad2 100644 --- a/tests/pack.test +++ b/tests/pack.test @@ -1549,12 +1549,19 @@ test pack-17.2 {PackLostSlaveProc procedure} -setup { pack info .pack.a } -returnCodes error -result {window ".pack.a" isn't packed} +if {[tk windowingsystem] == "win32"} { + proc packUpdate {} { + update + } +} else { + proc packUpdate {} { + } +} test pack-18.1 {unmap slaves when master unmapped} -constraints { tempNotPc } -setup { eval destroy [winfo child .pack] - update idletasks } -body { # adjust the position of .pack before test to avoid a screen switch @@ -1562,29 +1569,27 @@ test pack-18.1 {unmap slaves when master unmapped} -constraints { # as the screen (screen switch causes scale and other tests to fail). wm geometry .pack +100+100 - update idletasks # On the PC, when the width/height is configured while the window is # unmapped, the changes don't take effect until the window is remapped. # Who knows why? eval destroy [winfo child .pack] - update idletasks frame .pack.a -width 100 -height 50 -relief raised -bd 2 pack .pack.a update idletasks set result [winfo ismapped .pack.a] wm iconify .pack - update idletasks lappend result [winfo ismapped .pack.a] .pack.a configure -width 200 -height 75 update idletasks lappend result [winfo width .pack.a ] [winfo height .pack.a] \ [winfo ismapped .pack.a] wm deiconify .pack - update idletasks + packUpdate lappend result [winfo ismapped .pack.a] } -result {1 0 200 75 0 1} + test pack-18.2 {unmap slaves when master unmapped} -setup { eval destroy [winfo child .pack] } -body { @@ -1601,14 +1606,13 @@ test pack-18.2 {unmap slaves when master unmapped} -setup { update idletasks set result [winfo ismapped .pack.b] wm iconify .pack - update idletasks lappend result [winfo ismapped .pack.b] .pack.b configure -width 100 -height 30 update idletasks lappend result [winfo width .pack.b ] [winfo height .pack.b] \ [winfo ismapped .pack.b] wm deiconify .pack - update idletasks + packUpdate lappend result [winfo ismapped .pack.b] } -result {1 0 100 30 0 1} diff --git a/tests/place.test b/tests/place.test index 56ddde4..0a5e22f 100644 --- a/tests/place.test +++ b/tests/place.test @@ -258,6 +258,14 @@ test place-7.10 {ReconfigurePlacement procedure, computing size} -setup { list [winfo width .t.f2] [winfo height .t.f2] } -result {30 60} +if {[tk windowingsystem] == "win32"} { + proc placeUpdate {} { + update + } +} else { + proc placeUpdate {} { + } +} test place-8.1 {MasterStructureProc, mapping and unmapping slaves} -setup { place forget .t.f2 @@ -267,13 +275,12 @@ test place-8.1 {MasterStructureProc, mapping and unmapping slaves} -setup { update idletasks set result [winfo ismapped .t.f2] wm iconify .t - update idletasks lappend result [winfo ismapped .t.f2] place .t.f2 -x 40 -y 30 -relx 0 -rely 0 -anchor nw update idletasks lappend result [winfo x .t.f2] [winfo y .t.f2] [winfo ismapped .t.f2] wm deiconify .t - update idletasks + placeUpdate lappend result [winfo ismapped .t.f2] } -result {1 0 40 30 0 1} test place-8.2 {MasterStructureProc, mapping and unmapping slaves} -setup { @@ -286,13 +293,12 @@ test place-8.2 {MasterStructureProc, mapping and unmapping slaves} -setup { update idletasks set result [winfo ismapped .t.f2] wm iconify .t - update idletasks lappend result [winfo ismapped .t.f2] place .t.f2 -x 40 -y 30 -relx 0 -rely 0 -anchor nw update idletasks lappend result [winfo x .t.f2] [winfo y .t.f2] [winfo ismapped .t.f2] wm deiconify .t - update idletasks + placeUpdate lappend result [winfo ismapped .t.f2] } -result {1 0 42 32 0 1} destroy .t diff --git a/tests/textDisp.test b/tests/textDisp.test index b0560d8..0881102 100644 --- a/tests/textDisp.test +++ b/tests/textDisp.test @@ -17,10 +17,20 @@ if {[tk windowingsystem] == "aqua"} { proc updateText {} { update idletasks } + proc delay {} { + update idletasks + after 100 + update idletasks + } } else { proc updateText {} { update } + proc delay {} { + update + after 100 + update + } } # The procedure below is used as the scrolling command for the text; @@ -3961,12 +3971,12 @@ test textDisp-31.3 {line update index shifting} { .t insert 1.0 "abc\n" .t insert 1.0 "abc\n" lappend res [.t count -ypixels 1.0 end] - update idletasks ; after 100 ; update idletasks + delay lappend res [.t count -ypixels 1.0 end] .t.f configure -height 100 .t delete 1.0 3.0 lappend res [.t count -ypixels 1.0 end] - update idletasks ; after 100 ; update idletasks + delay lappend res [.t count -ypixels 1.0 end] set res } [list [expr {100 + $fixedHeight * 6}] [expr {100 + $fixedHeight * 8}] [expr {$fixedHeight * 9}] [expr {$fixedHeight * 7}] [expr {100 + $fixedHeight * 6}]] @@ -4014,12 +4024,12 @@ test textDisp-31.6 {line update index shifting} { .t insert 1.0 "abc\n" .t insert 1.0 "abc\n" lappend res [.t count -ypixels 1.0 end] - update idletasks ; after 100 ; update idletasks + delay lappend res [.t count -ypixels 1.0 end] textest configure -height 100 .t delete 1.0 3.0 lappend res [.t count -ypixels 1.0 end] - update idletasks ; after 100 ; update idletasks + delay lappend res [.t count -ypixels 1.0 end] set res } [list [expr {100 + $fixedHeight * 6}] [expr {100 + $fixedHeight * 8}] [expr {$fixedHeight * 9}] [expr {$fixedHeight * 7}] [expr {100 + $fixedHeight * 6}]] @@ -4036,11 +4046,11 @@ test textDisp-31.7 {line update index shifting, elided} { .t tag configure elide -elide 1 .t tag add elide 1.3 2.1 lappend res [.t count -ypixels 1.0 end] - update idletasks ; after 100 ; update idletasks + delay lappend res [.t count -ypixels 1.0 end] .t delete 1.0 3.0 lappend res [.t count -ypixels 1.0 end] - update idletasks ; after 100 ; update idletasks + delay lappend res [.t count -ypixels 1.0 end] set res } [list [expr {$fixedHeight * 1}] [expr {$fixedHeight * 3}] [expr {$fixedHeight * 3}] [expr {$fixedHeight * 2}] [expr {$fixedHeight * 1}] [expr {$fixedHeight * 1}]] -- cgit v0.12 From 9c3c347b22063ccdb5d7dc9d9bdffd69962f7844 Mon Sep 17 00:00:00 2001 From: culler Date: Fri, 24 Jul 2020 21:21:47 +0000 Subject: Fix the build for Snow Leopard. Fix the fontchooser demo. --- library/demos/fontchoose.tcl | 2 +- macosx/tkMacOSXColor.c | 11 +++++------ macosx/tkMacOSXInit.c | 1 + macosx/tkMacOSXKeyEvent.c | 2 ++ 4 files changed, 9 insertions(+), 7 deletions(-) diff --git a/library/demos/fontchoose.tcl b/library/demos/fontchoose.tcl index 8b34377..b93928d 100644 --- a/library/demos/fontchoose.tcl +++ b/library/demos/fontchoose.tcl @@ -57,7 +57,7 @@ grid columnconfigure $f 0 -weight 1 grid rowconfigure $f 0 -weight 1 bind $w { bind %W {} - grid propagate %W.f 0 + grid propagate %W 0 } ## See Code / Dismiss buttons diff --git a/macosx/tkMacOSXColor.c b/macosx/tkMacOSXColor.c index 51a28c5..5a06c39 100644 --- a/macosx/tkMacOSXColor.c +++ b/macosx/tkMacOSXColor.c @@ -273,16 +273,15 @@ GetEntryFromPixelCode( * appears to be harmless and stops the compiler warnings. */ - -#if MAC_OS_X_VERSION_MAX_ALLOWED >= 101200 @interface NSColor(TkColor) +#if MAC_OS_X_VERSION_MAX_ALLOWED > 101200 @property(class, strong, readonly) NSColor *linkColor; -@end -#else -@interface NSColor(TkColor) +#elif MAC_OS_X_VERSION_MAX_ALLOWED > 1080 @property(strong, readonly) NSColor *linkColor; -@end +#else +@property(assign, readonly) NSColor *linkColor; #endif +@end static NSColorSpace* sRGB = NULL; static CGFloat windowBackground[4] = diff --git a/macosx/tkMacOSXInit.c b/macosx/tkMacOSXInit.c index e75a63c..d3c4a0c 100644 --- a/macosx/tkMacOSXInit.c +++ b/macosx/tkMacOSXInit.c @@ -34,6 +34,7 @@ static char scriptPath[PATH_MAX + 1] = ""; @synthesize poolLock = _poolLock; @synthesize macOSVersion = _macOSVersion; @synthesize isDrawing = _isDrawing; +@synthesize needsToDraw = _needsToDraw; @end /* diff --git a/macosx/tkMacOSXKeyEvent.c b/macosx/tkMacOSXKeyEvent.c index 572e318..014caa9 100644 --- a/macosx/tkMacOSXKeyEvent.c +++ b/macosx/tkMacOSXKeyEvent.c @@ -267,6 +267,8 @@ static NSUInteger textInputModifiers; @implementation TKContentView +@synthesize tkDirtyRect = _tkDirtyRect; +@synthesize tkNeedsDisplay = _tkNeedsDisplay;; /* * Implementation of the NSTextInputClient protocol. -- cgit v0.12 From 03090437950d662b8892aaaf5238917c8bcca961 Mon Sep 17 00:00:00 2001 From: culler Date: Sat, 25 Jul 2020 14:15:07 +0000 Subject: Fix the fontchooser demo correctly. --- library/demos/fontchoose.tcl | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/library/demos/fontchoose.tcl b/library/demos/fontchoose.tcl index b93928d..446ed34 100644 --- a/library/demos/fontchoose.tcl +++ b/library/demos/fontchoose.tcl @@ -55,10 +55,6 @@ grid $f.msg $f.vs -sticky news grid $f.font - -sticky e grid columnconfigure $f 0 -weight 1 grid rowconfigure $f 0 -weight 1 -bind $w { - bind %W {} - grid propagate %W 0 -} ## See Code / Dismiss buttons set btns [addSeeDismiss $w.buttons $w] @@ -67,3 +63,5 @@ grid $f -sticky news grid $btns -sticky ew grid columnconfigure $w 0 -weight 1 grid rowconfigure $w 0 -weight 1 +update idletasks +grid propagate $f 0 -- cgit v0.12 From 2c481a8b318d561e9941bd5152601d5957f2b443 Mon Sep 17 00:00:00 2001 From: culler Date: Sat, 25 Jul 2020 14:21:28 +0000 Subject: Remove the race condition from listbox-21.10 the same way as for listbox-21.9 --- tests/listbox.test | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/tests/listbox.test b/tests/listbox.test index 806bbe0..3a6c860 100644 --- a/tests/listbox.test +++ b/tests/listbox.test @@ -2680,21 +2680,19 @@ test listbox-21.10 {ListboxListVarProc, test hscrollbar after listvar mod} -setu } -body { catch {unset x} listbox .l -font $fixed -width 10 -xscrollcommand "record x" -listvar x - set log {} pack .l - set timeout [after 500 {lappend log timeout2}] - vwait log + update idletasks + set log {} lappend x "0000000000" - update + update idletasks lappend x "00000000000000000000" - update + update idletasks set x [list "0000000000"] - update + update idletasks set log } -cleanup { destroy .l - after cancel $timeout -} -result [list {x 0 1} {x 0 1} {x 0 0.5} {x 0 1}] +} -result [list {x 0 1} {x 0 0.5} {x 0 1}] test listbox-21.11 {ListboxListVarProc, bad list} -setup { destroy .l } -body { -- cgit v0.12 From bcbf366541cf894a8abaaea4c684ff551c54981c Mon Sep 17 00:00:00 2001 From: culler Date: Sat, 25 Jul 2020 14:48:23 +0000 Subject: Fix namespace error in console.tcl - Thanks to Adam Kapos for the patch. --- library/console.tcl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/library/console.tcl b/library/console.tcl index 355a43b..6527607 100644 --- a/library/console.tcl +++ b/library/console.tcl @@ -740,9 +740,9 @@ proc ::tk::console::FontchooserToggle {} { } proc ::tk::console::FontchooserVisibility {index} { if {[tk fontchooser configure -visible]} { - .menubar.edit entryconfigure $index -label [msgcat::mc "Hide Fonts"] + .menubar.edit entryconfigure $index -label [::tk::msgcat::mc "Hide Fonts"] } else { - .menubar.edit entryconfigure $index -label [msgcat::mc "Show Fonts"] + .menubar.edit entryconfigure $index -label [::tk::msgcat::mc "Show Fonts"] } } proc ::tk::console::FontchooserFocus {w isFocusIn} { -- cgit v0.12 From a872071b3c86d4de2e5cb8e9a0d6e876064e561d Mon Sep 17 00:00:00 2001 From: culler Date: Wed, 29 Jul 2020 03:11:02 +0000 Subject: Clean up tkMacOSXColor.c so it is not so painful to add new colors. --- macosx/tkMacOSXColor.c | 425 ++++++++++++++--------------------------------- macosx/tkMacOSXDraw.c | 9 +- macosx/tkMacOSXImage.c | 2 +- macosx/tkMacOSXPort.h | 22 +-- macosx/tkMacOSXPrivate.h | 5 +- macosx/tkMacOSXXStubs.c | 4 +- 6 files changed, 139 insertions(+), 328 deletions(-) diff --git a/macosx/tkMacOSXColor.c b/macosx/tkMacOSXColor.c index 5a06c39..8b193b8 100644 --- a/macosx/tkMacOSXColor.c +++ b/macosx/tkMacOSXColor.c @@ -16,217 +16,78 @@ #include "tkMacOSXPrivate.h" #include "tkColor.h" +#include "tkMacOSXColor.h" -/* - * The colorType specifies how the color value should be interpreted. For the - * unique rgbColor entry, the RGB values are generated from the pixel value of - * an XColor. The ttkBackground and semantic types are dynamic, meaning - * that they change when dark mode is enabled on OSX 10.13 and later. - */ - -enum colorType { - clearColor, /* There should be only one of these. */ - rgbColor, /* There should be only one of these. */ - appearance, /* There should be only one of these. */ - HIBrush, /* The value is a HITheme brush color table index. */ - HIText, /* The value is a HITheme text color table index. */ - HIBackground, /* The value is a HITheme background color table index. */ - ttkBackground, /* The value can be used as a parameter.*/ - semantic, /* The value can be used as a parameter.*/ -}; - -/* +static Tcl_HashTable systemColorMap; +static int systemColorMapSize; +SystemColorMapEntry **systemColorIndex; - */ - -struct SystemColorMapEntry { - const char *name; - enum colorType type; - long value; -}; /* unsigned char pixelCode; */ - -/* - * Array of system color definitions: the array index is required to equal the - * color's (pixelCode - MIN_PIXELCODE), i.e. the array order needs to be kept - * in sync with the public pixel code values in tkMacOSXPort.h ! - */ +void initColorTable() +{ + Tcl_InitHashTable(&systemColorMap, TCL_STRING_KEYS); + SystemColorMapEntry *entry; + Tcl_HashSearch search; + Tcl_HashEntry *hPtr; + int newPtr = 0, index = 0; + for (entry = systemColorMapData; entry->name != NULL; entry++) { + hPtr = Tcl_CreateHashEntry(&systemColorMap, entry->name, &newPtr); + if (entry->type == semantic) { + NSString *selector = [[NSString alloc] + initWithCString:entry->macName + encoding:NSUTF8StringEncoding]; + if (![NSColor respondsToSelector: NSSelectorFromString(selector)]) { + continue; + } + [selector retain]; + entry->selector = selector; + } + if (!newPtr) { + index--; + } + entry->index = index++; + Tcl_SetHashValue(hPtr, entry); + } + systemColorMapSize = index; + systemColorIndex = ckalloc(systemColorMapSize * sizeof(SystemColorMapEntry*)); + for (hPtr = Tcl_FirstHashEntry(&systemColorMap, &search); hPtr != NULL; + hPtr = Tcl_NextHashEntry(&search)) { + entry = (SystemColorMapEntry *) Tcl_GetHashValue(hPtr); + systemColorIndex[entry->index] = entry; + } +} -#define MIN_PIXELCODE 30 -static const struct SystemColorMapEntry systemColorMap[] = { - { "Transparent", clearColor, 0 }, /* 30: TRANSPARENT_PIXEL */ - { "Highlight", HIBrush, kThemeBrushPrimaryHighlightColor }, /* 31 */ - { "HighlightSecondary", HIBrush, kThemeBrushSecondaryHighlightColor }, /* 32 */ - { "HighlightText", HIBrush, kThemeBrushBlack }, /* 33 */ - { "HighlightAlternate", HIBrush, kThemeBrushAlternatePrimaryHighlightColor }, /* 34 */ - { "ButtonText", HIText, kThemeTextColorPushButtonActive }, /* 35 */ - { "PrimaryHighlightColor", HIBrush, kThemeBrushPrimaryHighlightColor }, /* 36 */ - { "ButtonFace", HIBrush, kThemeBrushButtonFaceActive }, /* 37 */ - { "SecondaryHighlightColor", HIBrush, kThemeBrushSecondaryHighlightColor }, /* 38 */ - { "ButtonFrame", HIBrush, kThemeBrushButtonFrameActive }, /* 39 */ - { "AlternatePrimaryHighlightColor", HIBrush, kThemeBrushAlternatePrimaryHighlightColor }, /* 40 */ - { "WindowBody", HIBrush, kThemeBrushDocumentWindowBackground }, /* 41 */ - { "SheetBackground", HIBrush, kThemeBrushSheetBackground }, /* 42 */ - { "MenuActive", HIBrush, kThemeBrushMenuBackgroundSelected }, /* 43 */ - { "Black", HIBrush, kThemeBrushBlack }, /* 44 */ - { "MenuActiveText", HIText, kThemeTextColorMenuItemSelected }, /* 45 */ - { "White", HIBrush, kThemeBrushWhite }, /* 46 */ - { "Menu", HIBrush, kThemeBrushMenuBackground }, /* 47 */ - { "DialogBackgroundActive", HIBrush, kThemeBrushDialogBackgroundActive }, /* 48 */ - { "MenuDisabled", HIText, kThemeTextColorMenuItemDisabled }, /* 49 */ - { "DialogBackgroundInactive", HIBrush, kThemeBrushDialogBackgroundInactive }, /* 50 */ - { "MenuText", HIText, kThemeTextColorMenuItemActive }, /* 51 */ - { "AppearanceColor", appearance, 0 }, /* 52: APPEARANCE_PIXEL */ - { "AlertBackgroundActive", HIBrush, kThemeBrushAlertBackgroundActive }, /* 53 */ - { "AlertBackgroundInactive", HIBrush, kThemeBrushAlertBackgroundInactive }, /* 54 */ - { "ModelessDialogBackgroundActive", HIBrush, kThemeBrushModelessDialogBackgroundActive }, /* 55 */ - { "ModelessDialogBackgroundInactive", HIBrush, kThemeBrushModelessDialogBackgroundInactive }, /* 56 */ - { "UtilityWindowBackgroundActive", HIBrush, kThemeBrushUtilityWindowBackgroundActive }, /* 57 */ - { "UtilityWindowBackgroundInactive", HIBrush, kThemeBrushUtilityWindowBackgroundInactive }, /* 58 */ - { "ListViewSortColumnBackground", HIBrush, kThemeBrushListViewSortColumnBackground }, /* 59 */ - { "ListViewBackground", HIBrush, kThemeBrushListViewBackground }, /* 60 */ - { "IconLabelBackground", HIBrush, kThemeBrushIconLabelBackground }, /* 61 */ - { "ListViewSeparator", HIBrush, kThemeBrushListViewSeparator }, /* 62 */ - { "ChasingArrows", HIBrush, kThemeBrushChasingArrows }, /* 63 */ - { "DragHilite", HIBrush, kThemeBrushDragHilite }, /* 64 */ - { "DocumentWindowBackground", HIBrush, kThemeBrushDocumentWindowBackground }, /* 65 */ - { "FinderWindowBackground", HIBrush, kThemeBrushFinderWindowBackground }, /* 66 */ - { "ScrollBarDelimiterActive", HIBrush, kThemeBrushScrollBarDelimiterActive }, /* 67 */ - { "ScrollBarDelimiterInactive", HIBrush, kThemeBrushScrollBarDelimiterInactive }, /* 68 */ - { "FocusHighlight", HIBrush, kThemeBrushFocusHighlight }, /* 69 */ - { "PopupArrowActive", HIBrush, kThemeBrushPopupArrowActive }, /* 70 */ - { "PopupArrowPressed", HIBrush, kThemeBrushPopupArrowPressed }, /* 71 */ - { "PopupArrowInactive", HIBrush, kThemeBrushPopupArrowInactive }, /* 72 */ - { "AppleGuideCoachmark", HIBrush, kThemeBrushAppleGuideCoachmark }, /* 73 */ - { "IconLabelBackgroundSelected", HIBrush, kThemeBrushIconLabelBackgroundSelected }, /* 74 */ - { "StaticAreaFill", HIBrush, kThemeBrushStaticAreaFill }, /* 75 */ - { "ActiveAreaFill", HIBrush, kThemeBrushActiveAreaFill }, /* 76 */ - { "ButtonFrameActive", HIBrush, kThemeBrushButtonFrameActive }, /* 77 */ - { "ButtonFrameInactive", HIBrush, kThemeBrushButtonFrameInactive }, /* 78 */ - { "ButtonFaceActive", HIBrush, kThemeBrushButtonFaceActive }, /* 79 */ - { "ButtonFaceInactive", HIBrush, kThemeBrushButtonFaceInactive }, /* 80 */ - { "ButtonFacePressed", HIBrush, kThemeBrushButtonFacePressed }, /* 81 */ - { "ButtonActiveDarkShadow", HIBrush, kThemeBrushButtonActiveDarkShadow }, /* 82 */ - { "ButtonActiveDarkHighlight", HIBrush, kThemeBrushButtonActiveDarkHighlight }, /* 83 */ - { "ButtonActiveLightShadow", HIBrush, kThemeBrushButtonActiveLightShadow }, /* 84 */ - { "ButtonActiveLightHighlight", HIBrush, kThemeBrushButtonActiveLightHighlight }, /* 85 */ - { "ButtonInactiveDarkShadow", HIBrush, kThemeBrushButtonInactiveDarkShadow }, /* 86 */ - { "ButtonInactiveDarkHighlight", HIBrush, kThemeBrushButtonInactiveDarkHighlight }, /* 87 */ - { "ButtonInactiveLightShadow", HIBrush, kThemeBrushButtonInactiveLightShadow }, /* 88 */ - { "ButtonInactiveLightHighlight", HIBrush, kThemeBrushButtonInactiveLightHighlight }, /* 89 */ - { "ButtonPressedDarkShadow", HIBrush, kThemeBrushButtonPressedDarkShadow }, /* 90 */ - { "ButtonPressedDarkHighlight", HIBrush, kThemeBrushButtonPressedDarkHighlight }, /* 91 */ - { "ButtonPressedLightShadow", HIBrush, kThemeBrushButtonPressedLightShadow }, /* 92 */ - { "ButtonPressedLightHighlight", HIBrush, kThemeBrushButtonPressedLightHighlight }, /* 93 */ - { "BevelActiveLight", HIBrush, kThemeBrushBevelActiveLight }, /* 94 */ - { "BevelActiveDark", HIBrush, kThemeBrushBevelActiveDark }, /* 95 */ - { "BevelInactiveLight", HIBrush, kThemeBrushBevelInactiveLight }, /* 96 */ - { "BevelInactiveDark", HIBrush, kThemeBrushBevelInactiveDark }, /* 97 */ - { "NotificationWindowBackground", HIBrush, kThemeBrushNotificationWindowBackground }, /* 98 */ - { "MovableModalBackground", HIBrush, kThemeBrushMovableModalBackground }, /* 99 */ - { "SheetBackgroundOpaque", HIBrush, kThemeBrushSheetBackgroundOpaque }, /* 100 */ - { "DrawerBackground", HIBrush, kThemeBrushDrawerBackground }, /* 101 */ - { "ToolbarBackground", HIBrush, kThemeBrushToolbarBackground }, /* 102 */ - { "SheetBackgroundTransparent", HIBrush, kThemeBrushSheetBackgroundTransparent }, /* 103 */ - { "MenuBackground", HIBrush, kThemeBrushMenuBackground }, /* 104 */ - { "Pixel", rgbColor, 0 }, /* 105: PIXEL_MAGIC */ - { "MenuBackgroundSelected", HIBrush, kThemeBrushMenuBackgroundSelected }, /* 106 */ - { "ListViewOddRowBackground", HIBrush, kThemeBrushListViewOddRowBackground }, /* 107 */ - { "ListViewEvenRowBackground", HIBrush, kThemeBrushListViewEvenRowBackground }, /* 108 */ - { "ListViewColumnDivider", HIBrush, kThemeBrushListViewColumnDivider }, /* 109 */ - { "BlackText", HIText, kThemeTextColorBlack }, /* 110 */ - { "DialogActiveText", HIText, kThemeTextColorDialogActive }, /* 111 */ - { "DialogInactiveText", HIText, kThemeTextColorDialogInactive }, /* 112 */ - { "AlertActiveText", HIText, kThemeTextColorAlertActive }, /* 113 */ - { "AlertInactiveText", HIText, kThemeTextColorAlertInactive }, /* 114 */ - { "ModelessDialogActiveText", HIText, kThemeTextColorModelessDialogActive }, /* 115 */ - { "ModelessDialogInactiveText", HIText, kThemeTextColorModelessDialogInactive }, /* 116 */ - { "WindowHeaderActiveText", HIText, kThemeTextColorWindowHeaderActive }, /* 117 */ - { "WindowHeaderInactiveText", HIText, kThemeTextColorWindowHeaderInactive }, /* 118 */ - { "PlacardActiveText", HIText, kThemeTextColorPlacardActive }, /* 119 */ - { "PlacardInactiveText", HIText, kThemeTextColorPlacardInactive }, /* 120 */ - { "PlacardPressedText", HIText, kThemeTextColorPlacardPressed }, /* 121 */ - { "PushButtonActiveText", HIText, kThemeTextColorPushButtonActive }, /* 122 */ - { "PushButtonInactiveText", HIText, kThemeTextColorPushButtonInactive }, /* 123 */ - { "PushButtonPressedText", HIText, kThemeTextColorPushButtonPressed }, /* 124 */ - { "BevelButtonActiveText", HIText, kThemeTextColorBevelButtonActive }, /* 125 */ - { "BevelButtonInactiveText", HIText, kThemeTextColorBevelButtonInactive }, /* 126 */ - { "BevelButtonPressedText", HIText, kThemeTextColorBevelButtonPressed }, /* 127 */ - { "PopupButtonActiveText", HIText, kThemeTextColorPopupButtonActive }, /* 128 */ - { "PopupButtonInactiveText", HIText, kThemeTextColorPopupButtonInactive }, /* 129 */ - { "PopupButtonPressedText", HIText, kThemeTextColorPopupButtonPressed }, /* 130 */ - { "IconLabelText", HIText, kThemeTextColorIconLabel }, /* 131 */ - { "ListViewText", HIText, kThemeTextColorListView }, /* 132 */ - { "DocumentWindowTitleActiveText", HIText, kThemeTextColorDocumentWindowTitleActive }, /* 133 */ - { "DocumentWindowTitleInactiveText", HIText, kThemeTextColorDocumentWindowTitleInactive }, /* 134 */ - { "MovableModalWindowTitleActiveText", HIText, kThemeTextColorMovableModalWindowTitleActive }, /* 135 */ - { "MovableModalWindowTitleInactiveText",HIText, kThemeTextColorMovableModalWindowTitleInactive }, /* 136 */ - { "UtilityWindowTitleActiveText", HIText, kThemeTextColorUtilityWindowTitleActive }, /* 137 */ - { "UtilityWindowTitleInactiveText", HIText, kThemeTextColorUtilityWindowTitleInactive }, /* 138 */ - { "PopupWindowTitleActiveText", HIText, kThemeTextColorPopupWindowTitleActive }, /* 139 */ - { "PopupWindowTitleInactiveText", HIText, kThemeTextColorPopupWindowTitleInactive }, /* 140 */ - { "RootMenuActiveText", HIText, kThemeTextColorRootMenuActive }, /* 141 */ - { "RootMenuSelectedText", HIText, kThemeTextColorRootMenuSelected }, /* 142 */ - { "RootMenuDisabledText", HIText, kThemeTextColorRootMenuDisabled }, /* 143 */ - { "MenuItemActiveText", HIText, kThemeTextColorMenuItemActive }, /* 144 */ - { "MenuItemSelectedText", HIText, kThemeTextColorMenuItemSelected }, /* 145 */ - { "MenuItemDisabledText", HIText, kThemeTextColorMenuItemDisabled }, /* 146 */ - { "PopupLabelActiveText", HIText, kThemeTextColorPopupLabelActive }, /* 147 */ - { "PopupLabelInactiveText", HIText, kThemeTextColorPopupLabelInactive }, /* 148 */ - { "TabFrontActiveText", HIText, kThemeTextColorTabFrontActive }, /* 149 */ - { "TabNonFrontActiveText", HIText, kThemeTextColorTabNonFrontActive }, /* 150 */ - { "TabNonFrontPressedText", HIText, kThemeTextColorTabNonFrontPressed }, /* 151 */ - { "TabFrontInactiveText", HIText, kThemeTextColorTabFrontInactive }, /* 152 */ - { "TabNonFrontInactiveText", HIText, kThemeTextColorTabNonFrontInactive }, /* 153 */ - { "IconLabelSelectedText", HIText, kThemeTextColorIconLabelSelected }, /* 154 */ - { "BevelButtonStickyActiveText", HIText, kThemeTextColorBevelButtonStickyActive }, /* 155 */ - { "BevelButtonStickyInactiveText", HIText, kThemeTextColorBevelButtonStickyInactive }, /* 156 */ - { "NotificationText", HIText, kThemeTextColorNotification }, /* 157 */ - { "SystemDetailText", HIText, kThemeTextColorSystemDetail }, /* 158 */ - { "WhiteText", HIText, kThemeTextColorWhite }, /* 159 */ - { "TabPaneBackground", HIBackground, kThemeBackgroundTabPane }, /* 160 */ - { "PlacardBackground", HIBackground, kThemeBackgroundPlacard }, /* 161 */ - { "WindowHeaderBackground", HIBackground, kThemeBackgroundWindowHeader }, /* 162 */ - { "ListViewWindowHeaderBackground", HIBackground, kThemeBackgroundListViewWindowHeader }, /* 163 */ - { "SecondaryGroupBoxBackground", HIBackground, kThemeBackgroundSecondaryGroupBox }, /* 164 */ - { "MetalBackground", HIBackground, kThemeBackgroundMetal }, /* 165 */ +MODULE_SCOPE +unsigned long TkMacOSXRGBPixel( + unsigned int red, + unsigned int green, + unsigned int blue) +{ + MacPixel p; + p.pixel.value = (red >> 8) << 16 | (green >> 8) << 8 | (blue >> 8); + p.pixel.colortype = rgbColor; + return p.ulong; +} - /* - * Colors based on "semantic" NSColors. - */ +MODULE_SCOPE +unsigned long TkMacOSXClearPixel( + void) +{ + MacPixel p; + p.pixel.value = 0; + p.pixel.colortype = clearColor; + return p.ulong; +} - { "WindowBackgroundColor", ttkBackground, 0 }, /* 166 */ - { "WindowBackgroundColor1", ttkBackground, 1 }, /* 167 */ - { "WindowBackgroundColor2", ttkBackground, 2 }, /* 168 */ - { "WindowBackgroundColor3", ttkBackground, 3 }, /* 169 */ - { "WindowBackgroundColor4", ttkBackground, 4 }, /* 170 */ - { "WindowBackgroundColor5", ttkBackground, 5 }, /* 171 */ - { "WindowBackgroundColor6", ttkBackground, 6 }, /* 172 */ - { "WindowBackgroundColor7", ttkBackground, 7 }, /* 173 */ - { "TextColor", semantic, 0 }, /* 174 */ - { "SelectedTextColor", semantic, 1 }, /* 175 */ - { "LabelColor", semantic, 2 }, /* 176 */ - { "ControlTextColor", semantic, 3 }, /* 177 */ - { "DisabledControlTextColor", semantic, 4 }, /* 178 */ - { "SelectedTabTextColor", semantic, 5 }, /* 179 */ - { "TextBackgroundColor", semantic, 6 }, /* 180 */ - { "SelectedTextBackgroundColor", semantic, 7 }, /* 181 */ - { "ControlAccentColor", semantic, 8 }, /* 182 */ - /* Apple's SecondaryLabelColor is the same as their LabelColor so we roll our own. */ - { "SecondaryLabelColor", ttkBackground, 14 }, /* 183 */ - { "LinkColor", semantic, 9 }, /* 184 */ - { NULL, 0, 0 } -}; -#define FIRST_SEMANTIC_COLOR 166 -#define MAX_PIXELCODE 184 /* *---------------------------------------------------------------------- * - * GetEntryFromPixelCode -- + * GetEntryFromPixel -- * * Extract a SystemColorMapEntry from the table. * * Results: + * Returns false if the code is out of bounds. * * Side effects: @@ -236,12 +97,19 @@ static const struct SystemColorMapEntry systemColorMap[] = { */ static bool -GetEntryFromPixelCode( - unsigned char code, - struct SystemColorMapEntry *entry) +GetEntryFromPixel( + unsigned long pixel, + SystemColorMapEntry *entry) { - if (code >= MIN_PIXELCODE && code <= MAX_PIXELCODE) { - *entry = systemColorMap[code - MIN_PIXELCODE]; + MacPixel p; + unsigned int index = 0; //FIX ME + + p.ulong = pixel; + if (p.pixel.colortype != rgbColor) { + index = p.pixel.value; + } + if (index < systemColorMapSize) { + *entry = *systemColorIndex[index]; return true; } else { return false; @@ -268,6 +136,26 @@ GetEntryFromPixelCode( */ /* + * Definitions to prevent compiler warnings about nonexistent properties of NSColor. + */ + +#if MAC_OS_X_VERSION_MAX_ALLOWED >= 101000 + #define LABEL_COLOR labelColor +#else + #define LABEL_COLOR textColor +#endif +#if MAC_OS_X_VERSION_MAX_ALLOWED >= 101200 + #define LINK_COLOR linkColor +#else + #define LINK_COLOR blueColor +#endif +#if MAC_OS_X_VERSION_MAX_ALLOWED >= 101400 + #define CONTROL_ACCENT_COLOR controlAccentColor +#else + #define CONTROL_ACCENT_COLOR colorForControlTint:[NSColor currentControlTint] +#endif + +/* * Apple claims that linkColor is available in 10.10 but the declaration * does not appear in NSColor.h until later. Declaring it in a category * appears to be harmless and stops the compiler warnings. @@ -289,14 +177,15 @@ static CGFloat windowBackground[4] = static OSStatus SetCGColorComponents( - struct SystemColorMapEntry entry, + SystemColorMapEntry entry, unsigned long pixel, CGColorRef *c) { OSStatus err = noErr; NSColor *bgColor, *color = nil; CGFloat rgba[4] = {0, 0, 0, 1}; - + static Bool initialized = 0; + NSString *selector; if (!sRGB) { sRGB = [NSColorSpace sRGBColorSpace]; } @@ -307,7 +196,6 @@ SetCGColorComponents( */ NSAutoreleasePool *pool = [NSAutoreleasePool new]; - switch (entry.type) { case HIBrush: err = ChkErr(HIThemeBrushCreateCGColor, entry.value, c); @@ -343,76 +231,7 @@ SetCGColorComponents( } break; case semantic: - switch (entry.value) { - case 0: - color = [[NSColor textColor] colorUsingColorSpace:sRGB]; - break; - case 1: - color = [[NSColor selectedTextColor] colorUsingColorSpace:sRGB]; - break; - case 2: - if ([NSApp macOSVersion] > 100900) { - -#if MAC_OS_X_VERSION_MAX_ALLOWED > 1090 - color = [[NSColor labelColor] colorUsingColorSpace:sRGB]; -#endif - } else { - color = [[NSColor textColor] colorUsingColorSpace:sRGB]; - } - break; - case 3: - color = [[NSColor controlTextColor] colorUsingColorSpace:sRGB]; - break; - case 4: - color = [[NSColor disabledControlTextColor] - colorUsingColorSpace:sRGB]; - break; - case 5: - if ([NSApp macOSVersion] > 100600) { - color = [[NSColor whiteColor] colorUsingColorSpace:sRGB]; - } else { - color = [[NSColor blackColor] colorUsingColorSpace:sRGB]; - } - break; - case 6: - color = [[NSColor textBackgroundColor] colorUsingColorSpace:sRGB]; - break; - case 7: - color = [[NSColor selectedTextBackgroundColor] - colorUsingColorSpace:sRGB]; - break; - case 8: -#if MAC_OS_X_VERSION_MAX_ALLOWED >= 101400 - if (@available(macOS 14, *)) { - color = [[NSColor controlAccentColor] colorUsingColorSpace:sRGB]; -#else - if(false) { -#endif - } else { - color = [[NSColor - colorForControlTint:[NSColor currentControlTint]] - colorUsingColorSpace: sRGB]; - } - break; - case 9: - if ([NSApp macOSVersion] >= 101100) { -#if MAC_OS_X_VERSION_MAX_ALLOWED >= 101100 - color = [[NSColor linkColor] colorUsingColorSpace:sRGB]; -#endif - } else { - color = [[NSColor blueColor] colorUsingColorSpace:sRGB]; - } - break; - default: - if ([NSApp macOSVersion] >= 101000) { -#if MAC_OS_X_VERSION_MAX_ALLOWED >= 101000 - color = [[NSColor labelColor] colorUsingColorSpace:sRGB]; -#endif - } else { - color = [[NSColor textColor] colorUsingColorSpace:sRGB]; - } - break; - } + color = [[NSColor valueForKey:entry.selector] colorUsingColorSpace:sRGB]; [color getComponents: rgba]; break; case clearColor: @@ -483,7 +302,7 @@ TkMacOSXInDarkMode(Tk_Window tkwin) * TkSetMacColor -- * * Sets the components of a CGColorRef from an XColor pixel value. - * The high order byte of the pixel value is used as an index into + * XXXX The high order byte of the pixel value is used as an index into * the system color table, and then SetCGColorComponents is called * with the table entry and the pixel value. * @@ -505,9 +324,10 @@ TkSetMacColor( { CGColorRef *color = (CGColorRef*)macColor; OSStatus err = -1; - struct SystemColorMapEntry entry; + SystemColorMapEntry entry; - if (GetEntryFromPixelCode((pixel >> 24) & 0xff, &entry)) { + // if (GetEntryFromPixelCode((pixel >> 24) & 0xff, &entry)) { + if (GetEntryFromPixel(pixel, &entry)) { err = ChkErr(SetCGColorComponents, entry, pixel, color); } return (err == noErr); @@ -689,15 +509,14 @@ TkMacOSXSetColorInContext( { OSStatus err = noErr; CGColorRef cgColor = nil; - struct SystemColorMapEntry entry; + SystemColorMapEntry entry; CGRect rect; - int code = (pixel >> 24) & 0xff; HIThemeBackgroundDrawInfo info = {0, kThemeStateActive, 0};; - if (code < FIRST_SEMANTIC_COLOR) { - cgColor = CopyCachedColor(gc, pixel); - } - if (!cgColor && GetEntryFromPixelCode(code, &entry)) { + // if (code < FIRST_SEMANTIC_COLOR) { + // cgColor = CopyCachedColor(gc, pixel); + // } + if (!cgColor && GetEntryFromPixel(pixel, &entry)) { switch (entry.type) { case HIBrush: err = ChkErr(HIThemeSetFill, entry.value, NULL, context, @@ -763,6 +582,13 @@ TkpGetColor( Colormap colormap = tkwin!= None ? Tk_Colormap(tkwin) : None; TkColor *tkColPtr; XColor color; + static Bool initialized = NO; + static NSColorSpace* sRGB = NULL; + if (!initialized) { + initialized = YES; + sRGB = [NSColorSpace sRGBColorSpace]; + initColorTable(); + } /* * Check to see if this is a system color. Otherwise, XParseColor @@ -770,20 +596,18 @@ TkpGetColor( */ if (strncasecmp(name, "system", 6) == 0) { - Tcl_Obj *strPtr = Tcl_NewStringObj(name+6, -1); - int idx, result; - - result = Tcl_GetIndexFromObjStruct(NULL, strPtr, systemColorMap, - sizeof(struct SystemColorMapEntry), NULL, TCL_EXACT, &idx); - Tcl_DecrRefCount(strPtr); - if (result == TCL_OK) { + Tcl_HashEntry *hPtr = NULL; + SystemColorMapEntry *entry; + hPtr = Tcl_FindHashEntry(&systemColorMap, name + 6); + if (hPtr != NULL) { + entry = (SystemColorMapEntry *)Tcl_GetHashValue(hPtr); OSStatus err; CGColorRef c; - unsigned char pixelCode = idx + MIN_PIXELCODE; - struct SystemColorMapEntry entry = systemColorMap[idx]; - - err = ChkErr(SetCGColorComponents, entry, 0, &c); + unsigned char pixelCode = entry->index; + err = ChkErr(SetCGColorComponents, *entry, 0, &c); if (err == noErr) { + MacPixel p; + const size_t n = CGColorGetNumberOfComponents(c); const CGFloat *rgba = CGColorGetComponents(c); @@ -799,10 +623,9 @@ TkpGetColor( default: Tcl_Panic("CGColor with %d components", (int) n); } - color.pixel = ((((((pixelCode << 8) - | ((color.red >> 8) & 0xff)) << 8) - | ((color.green >> 8) & 0xff)) << 8) - | ((color.blue >> 8) & 0xff)); + p.pixel.value = pixelCode; + p.pixel.colortype = entry->type; + color.pixel = p.ulong; CGColorRelease(c); goto validXColor; } @@ -854,7 +677,7 @@ TkpGetColorByValue( tkColPtr->color.red = colorPtr->red; tkColPtr->color.green = colorPtr->green; tkColPtr->color.blue = colorPtr->blue; - tkColPtr->color.pixel = TkpGetPixel(&tkColPtr->color); + tkColPtr->color.pixel = TkpGetPixel(colorPtr); return tkColPtr; } diff --git a/macosx/tkMacOSXDraw.c b/macosx/tkMacOSXDraw.c index fd8a1eb..645b72b 100644 --- a/macosx/tkMacOSXDraw.c +++ b/macosx/tkMacOSXDraw.c @@ -43,6 +43,7 @@ static int cgAntiAliasLimit = 0; static int useThemedToplevel = 0; static int useThemedFrame = 0; +static unsigned long transparentColor; /* * Prototypes for functions used only in this file. @@ -99,6 +100,7 @@ TkMacOSXInitCGDrawing( (char *) &useThemedFrame, TCL_LINK_BOOLEAN) != TCL_OK) { Tcl_ResetResult(interp); } + transparentColor = TkMacOSXClearPixel(); } return TCL_OK; } @@ -545,7 +547,7 @@ TkMacOSXGetNSImageWithBitmap( unsigned long origBackground = gc->background; - gc->background = TRANSPARENT_PIXEL << 24; + gc->background = transparentColor; XSetClipOrigin(display, gc, 0, 0); XCopyPlane(display, bitmap, pixmap, gc, 0, 0, width, height, 0, 0, 1); gc->background = origBackground; @@ -664,17 +666,18 @@ TkMacOSXDrawCGImage( dstBounds = CGRectOffset(dstBounds, macDraw->xOff, macDraw->yOff); if (CGImageIsMask(image)) { if (macDraw->flags & TK_IS_BW_PIXMAP) { + /* * Set fill color to black; background comes from the context, * or is transparent. */ - if (imageBackground != TRANSPARENT_PIXEL << 24) { + if (imageBackground != transparentColor) { CGContextClearRect(context, dstBounds); } CGContextSetRGBFillColor(context, 0.0, 0.0, 0.0, 1.0); } else { - if (imageBackground != TRANSPARENT_PIXEL << 24) { + if (imageBackground != transparentColor) { TkMacOSXSetColorInContext(gc, imageBackground, context); CGContextFillRect(context, dstBounds); } diff --git a/macosx/tkMacOSXImage.c b/macosx/tkMacOSXImage.c index 2e576a5..4691e41 100644 --- a/macosx/tkMacOSXImage.c +++ b/macosx/tkMacOSXImage.c @@ -358,7 +358,7 @@ ImageGetPixel( break; } } - return (PIXEL_MAGIC << 24) | (r << 16) | (g << 8) | b; + return TkMacOSXRGBPixel(r, g, b); } /* diff --git a/macosx/tkMacOSXPort.h b/macosx/tkMacOSXPort.h index 71797b0..b81455c 100644 --- a/macosx/tkMacOSXPort.h +++ b/macosx/tkMacOSXPort.h @@ -161,27 +161,9 @@ #define TK_NO_DOUBLE_BUFFERING 1 /* - * Magic pixel code values for system colors. - * - * NOTE: values must be kept in sync with indices into the - * systemColorMap array in tkMacOSXColor.c ! - */ - -#define TRANSPARENT_PIXEL 30 -#define APPEARANCE_PIXEL 52 -#define PIXEL_MAGIC ((unsigned char) 0x69) - -/* - * The following macro returns the pixel value that corresponds to the - * 16-bit RGB values in the given XColor structure. - * The format is: (PIXEL_MAGIC <<< 24) | (R << 16) | (G << 8) | B - * where each of R, G and B is the high order byte of a 16-bit component. + * Used by xcolor.c */ -#define TkpGetPixel(p) ((((((PIXEL_MAGIC << 8) \ - | (((p)->red >> 8) & 0xff)) << 8) \ - | (((p)->green >> 8) & 0xff)) << 8) \ - | (((p)->blue >> 8) & 0xff)) - +#define TkpGetPixel(p) (TkMacOSXRGBPixel(p->red, p->green, p->blue)) #endif /* _TKMACPORT */ diff --git a/macosx/tkMacOSXPrivate.h b/macosx/tkMacOSXPrivate.h index a77282c..8ba7541 100644 --- a/macosx/tkMacOSXPrivate.h +++ b/macosx/tkMacOSXPrivate.h @@ -150,7 +150,7 @@ typedef union MacKeycode_t { keycode_v v; keycode_x x; } MacKeycode; - + /* * Macros used in tkMacOSXKeyboard.c and tkMacOSXKeyEvent.c. * Note that 0x7f is del and 0xF8FF is the Apple Logo character. @@ -310,6 +310,9 @@ MODULE_SCOPE unsigned TkMacOSXAddVirtual(unsigned int keycode); MODULE_SCOPE void TkMacOSXWinNSBounds(TkWindow *winPtr, NSView *view, NSRect *bounds); MODULE_SCOPE void TkMacOSXDrawAllViews(ClientData clientData); +MODULE_SCOPE unsigned long TkMacOSXRGBPixel(unsigned int red, unsigned int green, + unsigned int blue); +MODULE_SCOPE unsigned long TkMacOSXClearPixel(void); #pragma mark Private Objective-C Classes diff --git a/macosx/tkMacOSXXStubs.c b/macosx/tkMacOSXXStubs.c index 107f712..dc9ea32 100644 --- a/macosx/tkMacOSXXStubs.c +++ b/macosx/tkMacOSXXStubs.c @@ -250,8 +250,8 @@ TkpOpenDisplay( */ screen->root = ROOT_ID; screen->display = display; - screen->black_pixel = 0x00000000 | PIXEL_MAGIC << 24; - screen->white_pixel = 0x00FFFFFF | PIXEL_MAGIC << 24; + screen->black_pixel = 0x00000000; + screen->white_pixel = 0x00FFFFFF; screen->ext_data = (XExtData *) &maxBounds; screen->root_visual = ckalloc(sizeof(Visual)); -- cgit v0.12 From 18690594d7c9f8a57946fc6d838930b09e104754 Mon Sep 17 00:00:00 2001 From: culler Date: Wed, 29 Jul 2020 03:25:00 +0000 Subject: Add the new header file too. --- macosx/tkMacOSXColor.h | 250 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 250 insertions(+) create mode 100644 macosx/tkMacOSXColor.h diff --git a/macosx/tkMacOSXColor.h b/macosx/tkMacOSXColor.h new file mode 100644 index 0000000..a4acc08 --- /dev/null +++ b/macosx/tkMacOSXColor.h @@ -0,0 +1,250 @@ +#ifndef MACOSXCOLOR_H +#define MACOSXCOLOR_H +/* + * The generic Tk code uses the X11 GC type to describe a graphics context. + * (A GC is a pointer to a struct XGCValues). The foreground and background + * colors in a GC are unsigned longs. These are meant to be used as indexes + * into a table of XColors, where an XColor is declared in Xlib.h as: + * typedef struct { + * unsigned long pixel; + * unsigned short red, green, blue; + * char flags; + * char pad; + * } XColor; + * + * The xlib function XParseColor creates XColors from strings. It recognizes + * literal hexadecimal color specifications such as "#RRGGBB" as well as the + * standard X11 color names. When XParseColor creates an XColor it fills in + * all of the fields except for the pixel field, and then passes the XColor + * to TkpGetPixel to get a value to use for the pixel field. Since TkpGetPixel + * is platform specific, each platform is free to choose a value which can + * be used to set the foreground or background color in the platform's graphics + * context. + * + * Tk represents a color by a struct TkColor, which extends the XColor struct. + * Tk provides a mapping from color names to TkColors which extends the mapping + * provided by XParseColor but also allows for platform specific color names. + * By convention, these platform specific color names begin with the string + * "system". The mapping from names to TkColors is implemented by the function + * TkpGetColor defined for the Macintosh in this file. The pixel field in the + * XColor contained in a TkColor will be stored in the X11 graphics context. + * In X11 the pixel field is used as an index into a colormap. On the Mac + * the high order byte of the pixel is used to indicate a color type and + * the low 24 bits are either used as an rgb value (if the type is rgbColor) + * or as an index into a table of color descriptions. + */ + +enum colorType { + rgbColor, /* The 24 bit value is an rgb color. */ + clearColor, /* The unique rgba color with all channels 0. */ + HIBrush, /* A HITheme brush color.*/ + HIText, /* A HITheme text color. */ + HIBackground, /* A HITheme background color. */ + ttkBackground, /* A background color which indicates nesting level.*/ + semantic, /* A semantic NSColor.*/ +}; + +typedef struct xpixel_t { + unsigned value: 24; /* Either RGB or an index into systemColorMap. */ + unsigned colortype: 8; +} xpixel; + +typedef union MacPixel_t { + unsigned long ulong; + xpixel pixel; +} MacPixel; + +/* + * In TkMacOSXColor.c a Tk hash table is constructed from the static data + * below to map system color names to CGColors. + */ + +typedef struct { + const char *name; + enum colorType type; + long value; + char *macName; + NSString *selector; /* Filled in if used. */ + int index; /* Filled in when the hash table is constructed. */ +} SystemColorMapEntry; + +static SystemColorMapEntry systemColorMapData[] = { +{"Pixel", rgbColor, 0 }, /* This must be first. */ +{"Transparent", clearColor, 0 }, + + +{"Highlight", HIBrush, kThemeBrushPrimaryHighlightColor }, +{"HighlightSecondary", HIBrush, kThemeBrushSecondaryHighlightColor }, +{"HighlightText", HIBrush, kThemeBrushBlack }, +{"HighlightAlternate", HIBrush, kThemeBrushAlternatePrimaryHighlightColor }, +{"PrimaryHighlightColor", HIBrush, kThemeBrushPrimaryHighlightColor }, +{"ButtonFace", HIBrush, kThemeBrushButtonFaceActive }, +{"SecondaryHighlightColor", HIBrush, kThemeBrushSecondaryHighlightColor }, +{"ButtonFrame", HIBrush, kThemeBrushButtonFrameActive }, +{"AlternatePrimaryHighlightColor", HIBrush, kThemeBrushAlternatePrimaryHighlightColor }, +{"WindowBody", HIBrush, kThemeBrushDocumentWindowBackground }, +{"SheetBackground", HIBrush, kThemeBrushSheetBackground }, +{"MenuActive", HIBrush, kThemeBrushMenuBackgroundSelected }, +{"Menu", HIBrush, kThemeBrushMenuBackground }, +{"DialogBackgroundInactive", HIBrush, kThemeBrushDialogBackgroundInactive }, +{"DialogBackgroundActive", HIBrush, kThemeBrushDialogBackgroundActive }, +{"AlertBackgroundActive", HIBrush, kThemeBrushAlertBackgroundActive }, +{"AlertBackgroundInactive", HIBrush, kThemeBrushAlertBackgroundInactive }, +{"ModelessDialogBackgroundActive", HIBrush, kThemeBrushModelessDialogBackgroundActive }, +{"ModelessDialogBackgroundInactive", HIBrush, kThemeBrushModelessDialogBackgroundInactive }, +{"UtilityWindowBackgroundActive", HIBrush, kThemeBrushUtilityWindowBackgroundActive }, +{"UtilityWindowBackgroundInactive", HIBrush, kThemeBrushUtilityWindowBackgroundInactive }, +{"ListViewSortColumnBackground", HIBrush, kThemeBrushListViewSortColumnBackground }, +{"ListViewBackground", HIBrush, kThemeBrushListViewBackground }, +{"IconLabelBackground", HIBrush, kThemeBrushIconLabelBackground }, +{"ListViewSeparator", HIBrush, kThemeBrushListViewSeparator }, +{"ChasingArrows", HIBrush, kThemeBrushChasingArrows }, +{"DragHilite", HIBrush, kThemeBrushDragHilite }, +{"DocumentWindowBackground", HIBrush, kThemeBrushDocumentWindowBackground }, +{"FinderWindowBackground", HIBrush, kThemeBrushFinderWindowBackground }, +{"ScrollBarDelimiterActive", HIBrush, kThemeBrushScrollBarDelimiterActive }, +{"ScrollBarDelimiterInactive", HIBrush, kThemeBrushScrollBarDelimiterInactive }, +{"FocusHighlight", HIBrush, kThemeBrushFocusHighlight }, +{"PopupArrowActive", HIBrush, kThemeBrushPopupArrowActive }, +{"PopupArrowPressed", HIBrush, kThemeBrushPopupArrowPressed }, +{"PopupArrowInactive", HIBrush, kThemeBrushPopupArrowInactive }, +{"AppleGuideCoachmark", HIBrush, kThemeBrushAppleGuideCoachmark }, +{"IconLabelBackgroundSelected", HIBrush, kThemeBrushIconLabelBackgroundSelected }, +{"StaticAreaFill", HIBrush, kThemeBrushStaticAreaFill }, +{"ActiveAreaFill", HIBrush, kThemeBrushActiveAreaFill }, +{"ButtonFrameActive", HIBrush, kThemeBrushButtonFrameActive }, +{"ButtonFrameInactive", HIBrush, kThemeBrushButtonFrameInactive }, +{"ButtonFaceActive", HIBrush, kThemeBrushButtonFaceActive }, +{"ButtonFaceInactive", HIBrush, kThemeBrushButtonFaceInactive }, +{"ButtonFacePressed", HIBrush, kThemeBrushButtonFacePressed }, +{"ButtonActiveDarkShadow", HIBrush, kThemeBrushButtonActiveDarkShadow }, +{"ButtonActiveDarkHighlight", HIBrush, kThemeBrushButtonActiveDarkHighlight }, +{"ButtonActiveLightShadow", HIBrush, kThemeBrushButtonActiveLightShadow }, +{"ButtonActiveLightHighlight", HIBrush, kThemeBrushButtonActiveLightHighlight }, +{"ButtonInactiveDarkShadow", HIBrush, kThemeBrushButtonInactiveDarkShadow }, +{"ButtonInactiveDarkHighlight", HIBrush, kThemeBrushButtonInactiveDarkHighlight }, +{"ButtonInactiveLightShadow", HIBrush, kThemeBrushButtonInactiveLightShadow }, +{"ButtonInactiveLightHighlight", HIBrush, kThemeBrushButtonInactiveLightHighlight }, +{"ButtonPressedDarkShadow", HIBrush, kThemeBrushButtonPressedDarkShadow }, +{"ButtonPressedDarkHighlight", HIBrush, kThemeBrushButtonPressedDarkHighlight }, +{"ButtonPressedLightShadow", HIBrush, kThemeBrushButtonPressedLightShadow }, +{"ButtonPressedLightHighlight", HIBrush, kThemeBrushButtonPressedLightHighlight }, +{"BevelActiveLight", HIBrush, kThemeBrushBevelActiveLight }, +{"BevelActiveDark", HIBrush, kThemeBrushBevelActiveDark }, +{"BevelInactiveLight", HIBrush, kThemeBrushBevelInactiveLight }, +{"BevelInactiveDark", HIBrush, kThemeBrushBevelInactiveDark }, +{"NotificationWindowBackground", HIBrush, kThemeBrushNotificationWindowBackground }, +{"MovableModalBackground", HIBrush, kThemeBrushMovableModalBackground }, +{"SheetBackgroundOpaque", HIBrush, kThemeBrushSheetBackgroundOpaque }, +{"DrawerBackground", HIBrush, kThemeBrushDrawerBackground }, +{"ToolbarBackground", HIBrush, kThemeBrushToolbarBackground }, +{"SheetBackgroundTransparent", HIBrush, kThemeBrushSheetBackgroundTransparent }, +{"MenuBackground", HIBrush, kThemeBrushMenuBackground }, +{"MenuBackgroundSelected", HIBrush, kThemeBrushMenuBackgroundSelected }, +{"ListViewOddRowBackground", HIBrush, kThemeBrushListViewOddRowBackground }, +{"ListViewEvenRowBackground", HIBrush, kThemeBrushListViewEvenRowBackground }, +{"ListViewColumnDivider", HIBrush, kThemeBrushListViewColumnDivider }, + + +{"ButtonText", HIText, kThemeTextColorPushButtonActive }, +{"MenuActiveText", HIText, kThemeTextColorMenuItemSelected }, +{"MenuDisabled", HIText, kThemeTextColorMenuItemDisabled }, +{"MenuText", HIText, kThemeTextColorMenuItemActive }, +{"BlackText", HIText, kThemeTextColorBlack }, +{"DialogActiveText", HIText, kThemeTextColorDialogActive }, +{"DialogInactiveText", HIText, kThemeTextColorDialogInactive }, +{"AlertActiveText", HIText, kThemeTextColorAlertActive }, +{"AlertInactiveText", HIText, kThemeTextColorAlertInactive }, +{"ModelessDialogActiveText", HIText, kThemeTextColorModelessDialogActive }, +{"ModelessDialogInactiveText", HIText, kThemeTextColorModelessDialogInactive }, +{"WindowHeaderActiveText", HIText, kThemeTextColorWindowHeaderActive }, +{"WindowHeaderInactiveText", HIText, kThemeTextColorWindowHeaderInactive }, +{"PlacardActiveText", HIText, kThemeTextColorPlacardActive }, +{"PlacardInactiveText", HIText, kThemeTextColorPlacardInactive }, +{"PlacardPressedText", HIText, kThemeTextColorPlacardPressed }, +{"PushButtonActiveText", HIText, kThemeTextColorPushButtonActive }, +{"PushButtonInactiveText", HIText, kThemeTextColorPushButtonInactive }, +{"PushButtonPressedText", HIText, kThemeTextColorPushButtonPressed }, +{"BevelButtonActiveText", HIText, kThemeTextColorBevelButtonActive }, +{"BevelButtonInactiveText", HIText, kThemeTextColorBevelButtonInactive }, +{"BevelButtonPressedText", HIText, kThemeTextColorBevelButtonPressed }, +{"PopupButtonActiveText", HIText, kThemeTextColorPopupButtonActive }, +{"PopupButtonInactiveText", HIText, kThemeTextColorPopupButtonInactive }, +{"PopupButtonPressedText", HIText, kThemeTextColorPopupButtonPressed }, +{"IconLabelText", HIText, kThemeTextColorIconLabel }, +{"ListViewText", HIText, kThemeTextColorListView }, +{"DocumentWindowTitleActiveText", HIText, kThemeTextColorDocumentWindowTitleActive }, +{"DocumentWindowTitleInactiveText", HIText, kThemeTextColorDocumentWindowTitleInactive }, +{"MovableModalWindowTitleActiveText", HIText, kThemeTextColorMovableModalWindowTitleActive }, +{"MovableModalWindowTitleInactiveText", HIText, kThemeTextColorMovableModalWindowTitleInactive }, +{"UtilityWindowTitleActiveText", HIText, kThemeTextColorUtilityWindowTitleActive }, +{"UtilityWindowTitleInactiveText", HIText, kThemeTextColorUtilityWindowTitleInactive }, +{"PopupWindowTitleActiveText", HIText, kThemeTextColorPopupWindowTitleActive }, +{"PopupWindowTitleInactiveText", HIText, kThemeTextColorPopupWindowTitleInactive }, +{"RootMenuActiveText", HIText, kThemeTextColorRootMenuActive }, +{"RootMenuSelectedText", HIText, kThemeTextColorRootMenuSelected }, +{"RootMenuDisabledText", HIText, kThemeTextColorRootMenuDisabled }, +{"MenuItemActiveText", HIText, kThemeTextColorMenuItemActive }, +{"MenuItemSelectedText", HIText, kThemeTextColorMenuItemSelected }, +{"MenuItemDisabledText", HIText, kThemeTextColorMenuItemDisabled }, +{"PopupLabelActiveText", HIText, kThemeTextColorPopupLabelActive }, +{"PopupLabelInactiveText", HIText, kThemeTextColorPopupLabelInactive }, +{"TabFrontActiveText", HIText, kThemeTextColorTabFrontActive }, +{"TabNonFrontActiveText", HIText, kThemeTextColorTabNonFrontActive }, +{"TabNonFrontPressedText", HIText, kThemeTextColorTabNonFrontPressed }, +{"TabFrontInactiveText", HIText, kThemeTextColorTabFrontInactive }, +{"TabNonFrontInactiveText", HIText, kThemeTextColorTabNonFrontInactive }, +{"IconLabelSelectedText", HIText, kThemeTextColorIconLabelSelected }, +{"BevelButtonStickyActiveText", HIText, kThemeTextColorBevelButtonStickyActive }, +{"BevelButtonStickyInactiveText", HIText, kThemeTextColorBevelButtonStickyInactive }, +{"NotificationText", HIText, kThemeTextColorNotification }, +{"SystemDetailText", HIText, kThemeTextColorSystemDetail }, +{"PlacardBackground", HIBackground, kThemeBackgroundPlacard }, +{"WindowHeaderBackground", HIBackground, kThemeBackgroundWindowHeader }, +{"ListViewWindowHeaderBackground", HIBackground, kThemeBackgroundListViewWindowHeader }, +{"MetalBackground", HIBackground, kThemeBackgroundMetal }, + +{"SecondaryGroupBoxBackground", HIBackground, kThemeBackgroundSecondaryGroupBox }, +{"TabPaneBackground", HIBackground, kThemeBackgroundTabPane }, +{"WhiteText", HIText, kThemeTextColorWhite }, +{"Black", HIBrush, kThemeBrushBlack }, +{"White", HIBrush, kThemeBrushWhite }, + + /* + * Dynamic Colors + */ + +{"WindowBackgroundColor", ttkBackground, 0 }, +{"WindowBackgroundColor1", ttkBackground, 1 }, +{"WindowBackgroundColor2", ttkBackground, 2 }, +{"WindowBackgroundColor3", ttkBackground, 3 }, +{"WindowBackgroundColor4", ttkBackground, 4 }, +{"WindowBackgroundColor5", ttkBackground, 5 }, +{"WindowBackgroundColor6", ttkBackground, 6 }, +{"WindowBackgroundColor7", ttkBackground, 7 }, +/* Apple's SecondaryLabelColor is the same as their LabelColor so we roll our own. */ +{"SecondaryLabelColor", ttkBackground, 14 }, + +{"TextColor", semantic, 0, "textColor" }, +{"SelectedTextColor", semantic, 0, "selectedTextColor" }, +{"LabelColor", semantic, 0, "labelColor"}, +{"ControlTextColor", semantic, 0, "controlTextColor" }, +{"DisabledControlTextColor", semantic, 0, "disabledControlTextColor" }, +#if MAC_OS_X_VERSION_MAX_ALLOWED > 1060 +{"SelectedTabTextColor", semantic, 0, "whiteColor" }, +#else +{"SelectedTabTextColor", semantic, 0, "blackColor" }, +#endif +{"TextBackgroundColor", semantic, 0, "textBackgroundColor" }, +{"SelectedTextBackgroundColor", semantic, 0, "selectedTextBackgroundColor" }, +{"ControlAccentColor", semantic, 0, "controlAccentColor" }, +{"LinkColor", semantic, 0, "blueColor" }, +{"LinkColor", semantic, 0, "linkColor" }, +{"PlaceholderTextColor", semantic, 0, "grayColor" }, +{"PlaceholderTextColor", semantic, 0, "placeholderTextColor" }, +{"SeparatorColor", semantic, 0, "grayColor" }, +{"SeparatorColor", semantic, 0, "separatorColor" }, +{NULL, 0, 0 } +}; + +#endif -- cgit v0.12 From 549b6fe77986ec243d198acfdff6f244249c1ba9 Mon Sep 17 00:00:00 2001 From: culler Date: Wed, 29 Jul 2020 03:51:19 +0000 Subject: Remove lines that were commented out. --- macosx/tkMacOSXColor.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/macosx/tkMacOSXColor.c b/macosx/tkMacOSXColor.c index 8b193b8..8e286fa 100644 --- a/macosx/tkMacOSXColor.c +++ b/macosx/tkMacOSXColor.c @@ -102,7 +102,8 @@ GetEntryFromPixel( SystemColorMapEntry *entry) { MacPixel p; - unsigned int index = 0; //FIX ME + // Should make sure this is the rgbColor index, even if the data gets shuffled. + unsigned int index = 0; p.ulong = pixel; if (p.pixel.colortype != rgbColor) { @@ -326,7 +327,6 @@ TkSetMacColor( OSStatus err = -1; SystemColorMapEntry entry; - // if (GetEntryFromPixelCode((pixel >> 24) & 0xff, &entry)) { if (GetEntryFromPixel(pixel, &entry)) { err = ChkErr(SetCGColorComponents, entry, pixel, color); } @@ -513,9 +513,6 @@ TkMacOSXSetColorInContext( CGRect rect; HIThemeBackgroundDrawInfo info = {0, kThemeStateActive, 0};; - // if (code < FIRST_SEMANTIC_COLOR) { - // cgColor = CopyCachedColor(gc, pixel); - // } if (!cgColor && GetEntryFromPixel(pixel, &entry)) { switch (entry.type) { case HIBrush: -- cgit v0.12 From a012b4334ab20bcfd26b43f6f32bca1a1d66b50e Mon Sep 17 00:00:00 2001 From: culler Date: Wed, 29 Jul 2020 14:48:46 +0000 Subject: Fix the hash table logic and some build issues. --- macosx/tkMacOSXColor.c | 81 +++++++++++++++++++++++++++++++++++++++++------- macosx/tkMacOSXPort.h | 3 +- macosx/tkMacOSXPrivate.h | 2 -- 3 files changed, 71 insertions(+), 15 deletions(-) diff --git a/macosx/tkMacOSXColor.c b/macosx/tkMacOSXColor.c index 8e286fa..dd51a66 100644 --- a/macosx/tkMacOSXColor.c +++ b/macosx/tkMacOSXColor.c @@ -25,28 +25,44 @@ SystemColorMapEntry **systemColorIndex; void initColorTable() { Tcl_InitHashTable(&systemColorMap, TCL_STRING_KEYS); - SystemColorMapEntry *entry; + SystemColorMapEntry *entry, *oldEntry; Tcl_HashSearch search; Tcl_HashEntry *hPtr; - int newPtr = 0, index = 0; + int newPtr, index = 0; + + /* + * Build a hash table for looking up a color by its name. + */ + for (entry = systemColorMapData; entry->name != NULL; entry++) { hPtr = Tcl_CreateHashEntry(&systemColorMap, entry->name, &newPtr); if (entry->type == semantic) { NSString *selector = [[NSString alloc] initWithCString:entry->macName encoding:NSUTF8StringEncoding]; + /* + * Ignore this entry if NSColor does not recognize it. + */ + if (![NSColor respondsToSelector: NSSelectorFromString(selector)]) { continue; } [selector retain]; entry->selector = selector; } - if (!newPtr) { - index--; + if (newPtr == 0) { + oldEntry = (SystemColorMapEntry *) Tcl_GetHashValue(hPtr); + entry->index = oldEntry->index; + } else { + entry->index = index++; } - entry->index = index++; Tcl_SetHashValue(hPtr, entry); } + + /* + * Build an array for looking up a color by its index. + */ + systemColorMapSize = index; systemColorIndex = ckalloc(systemColorMapSize * sizeof(SystemColorMapEntry*)); for (hPtr = Tcl_FirstHashEntry(&systemColorMap, &search); hPtr != NULL; @@ -56,18 +72,60 @@ void initColorTable() } } +/* + *---------------------------------------------------------------------- + * + * TkMacOSXRGBPixel -- + * + * Return an unsigned long value suitable for use in the pixel + * field of an XColor with the specified red, green and blue + * intensities. The inputs are cast as unsigned longs but are + * expected to have values representable by an unsigned short + * as used in the XColor struct. These values are divided by + * 256 tp generate a 24-bit RGB pixel value. + * + * This is called by the TkpGetPixel macro, used in xcolor.c. + * + * Results: + * An unsigned long that can be used as the pixel field of an XColor. + * + * Side effects: + * None. + *---------------------------------------------------------------------- + */ MODULE_SCOPE -unsigned long TkMacOSXRGBPixel( - unsigned int red, - unsigned int green, - unsigned int blue) +unsigned long +TkMacOSXRGBPixel( + unsigned long red, + unsigned long green, + unsigned long blue) { MacPixel p; - p.pixel.value = (red >> 8) << 16 | (green >> 8) << 8 | (blue >> 8); p.pixel.colortype = rgbColor; + p.pixel.value = (((red >> 8) & 0xff) << 16) | + (((green >> 8) & 0xff) << 8) | + ((blue >> 8) & 0xff); return p.ulong; } - + +/* + *---------------------------------------------------------------------- + * + * TkMacOSXClearPixel -- + * + * Return the unsigned long value that appears in the pixel + * field of the XColor for systemTransparentColor. + * + * This is used in tkMacOSXImage.c. + * + * Results: + * The unsigned long that appears in the pixel field of the XColor + * for systemTransparentPixel. + * + * Side effects: + * None. + *---------------------------------------------------------------------- + */ MODULE_SCOPE unsigned long TkMacOSXClearPixel( void) @@ -186,7 +244,6 @@ SetCGColorComponents( NSColor *bgColor, *color = nil; CGFloat rgba[4] = {0, 0, 0, 1}; static Bool initialized = 0; - NSString *selector; if (!sRGB) { sRGB = [NSColorSpace sRGBColorSpace]; } diff --git a/macosx/tkMacOSXPort.h b/macosx/tkMacOSXPort.h index b81455c..8d92601 100644 --- a/macosx/tkMacOSXPort.h +++ b/macosx/tkMacOSXPort.h @@ -163,7 +163,8 @@ /* * Used by xcolor.c */ - +MODULE_SCOPE unsigned long TkMacOSXRGBPixel(unsigned long red, unsigned long green, + unsigned long blue); #define TkpGetPixel(p) (TkMacOSXRGBPixel(p->red, p->green, p->blue)) #endif /* _TKMACPORT */ diff --git a/macosx/tkMacOSXPrivate.h b/macosx/tkMacOSXPrivate.h index 8ba7541..ceca8f8 100644 --- a/macosx/tkMacOSXPrivate.h +++ b/macosx/tkMacOSXPrivate.h @@ -310,8 +310,6 @@ MODULE_SCOPE unsigned TkMacOSXAddVirtual(unsigned int keycode); MODULE_SCOPE void TkMacOSXWinNSBounds(TkWindow *winPtr, NSView *view, NSRect *bounds); MODULE_SCOPE void TkMacOSXDrawAllViews(ClientData clientData); -MODULE_SCOPE unsigned long TkMacOSXRGBPixel(unsigned int red, unsigned int green, - unsigned int blue); MODULE_SCOPE unsigned long TkMacOSXClearPixel(void); #pragma mark Private Objective-C Classes -- cgit v0.12 From c640e7311ee1bb1794a76c03caafc60f8e3a461e Mon Sep 17 00:00:00 2001 From: culler Date: Wed, 29 Jul 2020 21:20:42 +0000 Subject: Clean up a few more things. --- macosx/tkMacOSXColor.c | 181 ++++++++++++++++++++++++------------------------- 1 file changed, 88 insertions(+), 93 deletions(-) diff --git a/macosx/tkMacOSXColor.c b/macosx/tkMacOSXColor.c index dd51a66..3e8e065 100644 --- a/macosx/tkMacOSXColor.c +++ b/macosx/tkMacOSXColor.c @@ -146,18 +146,18 @@ unsigned long TkMacOSXClearPixel( * * Results: - * Returns false if the code is out of bounds. + * A pointer to a SystemColorMapEntry, or NULL if the pixel value is + * invalid. * * Side effects: - * None. + * None * *---------------------------------------------------------------------- */ -static bool +SystemColorMapEntry* GetEntryFromPixel( - unsigned long pixel, - SystemColorMapEntry *entry) + unsigned long pixel) { MacPixel p; // Should make sure this is the rgbColor index, even if the data gets shuffled. @@ -168,10 +168,9 @@ GetEntryFromPixel( index = p.pixel.value; } if (index < systemColorMapSize) { - *entry = *systemColorIndex[index]; - return true; + return systemColorIndex[index]; } else { - return false; + return NULL; } } @@ -185,8 +184,13 @@ GetEntryFromPixel( * the color is of type rgbColor. In that case the normalized XColor RGB * values are copied into the CGColorRef. * + * In 64 bit macOS systems there are no HITheme functions which convert + * HIText or HIBackground colors to CGColors. (GetThemeTextColor was + * removed, and it was never possible with backgrounds.) If we get one of + * these we return black. + * * Results: - * OSStatus + * True if the function succeeds, false otherwise. * * Side effects: * None. @@ -194,70 +198,28 @@ GetEntryFromPixel( *---------------------------------------------------------------------- */ -/* - * Definitions to prevent compiler warnings about nonexistent properties of NSColor. - */ - -#if MAC_OS_X_VERSION_MAX_ALLOWED >= 101000 - #define LABEL_COLOR labelColor -#else - #define LABEL_COLOR textColor -#endif -#if MAC_OS_X_VERSION_MAX_ALLOWED >= 101200 - #define LINK_COLOR linkColor -#else - #define LINK_COLOR blueColor -#endif #if MAC_OS_X_VERSION_MAX_ALLOWED >= 101400 #define CONTROL_ACCENT_COLOR controlAccentColor #else #define CONTROL_ACCENT_COLOR colorForControlTint:[NSColor currentControlTint] #endif -/* - * Apple claims that linkColor is available in 10.10 but the declaration - * does not appear in NSColor.h until later. Declaring it in a category - * appears to be harmless and stops the compiler warnings. - */ - -@interface NSColor(TkColor) -#if MAC_OS_X_VERSION_MAX_ALLOWED > 101200 -@property(class, strong, readonly) NSColor *linkColor; -#elif MAC_OS_X_VERSION_MAX_ALLOWED > 1080 -@property(strong, readonly) NSColor *linkColor; -#else -@property(assign, readonly) NSColor *linkColor; -#endif -@end - static NSColorSpace* sRGB = NULL; static CGFloat windowBackground[4] = {236.0 / 255, 236.0 / 255, 236.0 / 255, 1.0}; -static OSStatus -SetCGColorComponents( - SystemColorMapEntry entry, +static void +GetRGBA( + SystemColorMapEntry *entry, unsigned long pixel, - CGColorRef *c) + CGFloat *rgba) { - OSStatus err = noErr; NSColor *bgColor, *color = nil; - CGFloat rgba[4] = {0, 0, 0, 1}; - static Bool initialized = 0; + if (!sRGB) { sRGB = [NSColorSpace sRGBColorSpace]; } - - /* - * This function is called before our autorelease pool is set up, - * so it needs its own pool. - */ - - NSAutoreleasePool *pool = [NSAutoreleasePool new]; - switch (entry.type) { - case HIBrush: - err = ChkErr(HIThemeBrushCreateCGColor, entry.value, c); - return err; + switch (entry->type) { case rgbColor: rgba[0] = ((pixel >> 16) & 0xff) / 255.0; rgba[1] = ((pixel >> 8) & 0xff) / 255.0; @@ -280,36 +242,48 @@ SetCGColorComponents( } if (rgba[0] + rgba[1] + rgba[2] < 1.5) { for (int i=0; i<3; i++) { - rgba[i] += entry.value*8.0 / 255.0; + rgba[i] += entry->value*8.0 / 255.0; } } else { for (int i=0; i<3; i++) { - rgba[i] -= entry.value*8.0 / 255.0; + rgba[i] -= entry->value*8.0 / 255.0; } } break; case semantic: - color = [[NSColor valueForKey:entry.selector] colorUsingColorSpace:sRGB]; + color = [[NSColor valueForKey:entry->selector] colorUsingColorSpace:sRGB]; [color getComponents: rgba]; break; case clearColor: - rgba[3] = 0.0; + rgba[3] = 0; + default: break; + } +} + +static Bool +SetCGColorComponents( + SystemColorMapEntry *entry, + unsigned long pixel, + CGColorRef *c) +{ + CGFloat rgba[4] = {0, 0, 0, 1}; /* - * There are no HITheme functions which convert Text or background colors - * to CGColors. (GetThemeTextColor has been removed, and it was never - * possible with backgrounds.) If we get one of these we return black. + * This function is called before our autorelease pool is set up, + * so it needs its own pool. */ - case HIText: - case HIBackground: - default: - break; + NSAutoreleasePool *pool = [NSAutoreleasePool new]; + + if (entry->type == HIBrush) { + OSStatus err = ChkErr(HIThemeBrushCreateCGColor, entry->value, c); + return err == noErr; } + GetRGBA(entry, pixel, rgba); *c = CGColorCreate(sRGB.CGColorSpace, rgba); [pool drain]; - return err; + return true; } /* @@ -359,14 +333,13 @@ TkMacOSXInDarkMode(Tk_Window tkwin) * * TkSetMacColor -- * - * Sets the components of a CGColorRef from an XColor pixel value. - * XXXX The high order byte of the pixel value is used as an index into - * the system color table, and then SetCGColorComponents is called - * with the table entry and the pixel value. + * Sets the components of a CGColorRef from an XColor pixel value. The + * pixel value is used to look up the color in the system color table, and + * then SetCGColorComponents is called with the table entry and the pixel + * value. * * Results: - * Returns false if the high order byte is not a valid index, true - * otherwise. + * Returns false if the color is not found, true otherwise. * * Side effects: * The variable macColor is set to a new CGColorRef, the caller is @@ -381,13 +354,13 @@ TkSetMacColor( void *macColor) /* CGColorRef to modify. */ { CGColorRef *color = (CGColorRef*)macColor; - OSStatus err = -1; - SystemColorMapEntry entry; + SystemColorMapEntry *entry = GetEntryFromPixel(pixel); - if (GetEntryFromPixel(pixel, &entry)) { - err = ChkErr(SetCGColorComponents, entry, pixel, color); + if (entry) { + return SetCGColorComponents(entry, pixel, color); + } else { + return false; } - return (err == noErr); } /* @@ -566,33 +539,32 @@ TkMacOSXSetColorInContext( { OSStatus err = noErr; CGColorRef cgColor = nil; - SystemColorMapEntry entry; + SystemColorMapEntry *entry = GetEntryFromPixel(pixel); CGRect rect; HIThemeBackgroundDrawInfo info = {0, kThemeStateActive, 0};; - if (!cgColor && GetEntryFromPixel(pixel, &entry)) { - switch (entry.type) { + if (entry) { + switch (entry->type) { case HIBrush: - err = ChkErr(HIThemeSetFill, entry.value, NULL, context, + err = ChkErr(HIThemeSetFill, entry->value, NULL, context, kHIThemeOrientationNormal); if (err == noErr) { - err = ChkErr(HIThemeSetStroke, entry.value, NULL, context, + err = ChkErr(HIThemeSetStroke, entry->value, NULL, context, kHIThemeOrientationNormal); } break; case HIText: - err = ChkErr(HIThemeSetTextFill, entry.value, NULL, context, + err = ChkErr(HIThemeSetTextFill, entry->value, NULL, context, kHIThemeOrientationNormal); break; case HIBackground: - info.kind = entry.value; + info.kind = entry->value; rect = CGContextGetClipBoundingBox(context); err = ChkErr(HIThemeApplyBackground, &rect, &info, context, kHIThemeOrientationNormal); break; default: - err = ChkErr(SetCGColorComponents, entry, pixel, &cgColor); - if (err == noErr) { + if (SetCGColorComponents(entry, pixel, &cgColor)){ SetCachedColor(gc, pixel, cgColor); } break; @@ -608,6 +580,31 @@ TkMacOSXSetColorInContext( } } + +/* + * Recompute the red, green and blue values of an XColor from its pixel value. + * To do this we need to know which window the color is being used in, so we + * can figure out if that window is in dark mode or not. And we will probably + * need to involve drawRect somehow since the correct color values are only + * available when a valid graphics context is available. + */ + +MODULE_SCOPE +void TkMacOSXUpdateXColor( + XColor *color, + Tk_Window tkwin) +{ + MacPixel p; + CGFloat rgba[4] = {0, 0, 0, 1}; + SystemColorMapEntry *entry = GetEntryFromPixel(color->pixel); + + p.ulong = color->pixel; + if (p.pixel.colortype == semantic || p.pixel.colortype == ttkBackground) { + printf("Updating %s in window %s for %s Mode\n", + entry->name, Tk_PathName(tkwin), + TkMacOSXInDarkMode(tkwin) ? "Dark" : "Light"); + } +} /* *---------------------------------------------------------------------- * @@ -655,11 +652,9 @@ TkpGetColor( hPtr = Tcl_FindHashEntry(&systemColorMap, name + 6); if (hPtr != NULL) { entry = (SystemColorMapEntry *)Tcl_GetHashValue(hPtr); - OSStatus err; CGColorRef c; - unsigned char pixelCode = entry->index; - err = ChkErr(SetCGColorComponents, *entry, 0, &c); - if (err == noErr) { + unsigned int pixelCode = entry->index; + if (SetCGColorComponents(entry, 0, &c)) { MacPixel p; const size_t n = CGColorGetNumberOfComponents(c); -- cgit v0.12 From 52a5bc561398bf552709b4ab92c8588d2d66f800 Mon Sep 17 00:00:00 2001 From: culler Date: Thu, 30 Jul 2020 20:32:44 +0000 Subject: Change terminology. Keep separate TkColors for light and dark mode. --- macosx/tkMacOSXColor.c | 62 ++++++++++++++++++++++++++------------------------ macosx/tkMacOSXColor.h | 4 ++-- 2 files changed, 34 insertions(+), 32 deletions(-) diff --git a/macosx/tkMacOSXColor.c b/macosx/tkMacOSXColor.c index 3e8e065..6c43e33 100644 --- a/macosx/tkMacOSXColor.c +++ b/macosx/tkMacOSXColor.c @@ -18,14 +18,14 @@ #include "tkColor.h" #include "tkMacOSXColor.h" -static Tcl_HashTable systemColorMap; -static int systemColorMapSize; -SystemColorMapEntry **systemColorIndex; +static Tcl_HashTable systemColors; +static int numSystemColors; +SystemColorDatum **systemColorIndex; void initColorTable() { - Tcl_InitHashTable(&systemColorMap, TCL_STRING_KEYS); - SystemColorMapEntry *entry, *oldEntry; + Tcl_InitHashTable(&systemColors, TCL_STRING_KEYS); + SystemColorDatum *entry, *oldEntry; Tcl_HashSearch search; Tcl_HashEntry *hPtr; int newPtr, index = 0; @@ -34,8 +34,8 @@ void initColorTable() * Build a hash table for looking up a color by its name. */ - for (entry = systemColorMapData; entry->name != NULL; entry++) { - hPtr = Tcl_CreateHashEntry(&systemColorMap, entry->name, &newPtr); + for (entry = systemColorData; entry->name != NULL; entry++) { + hPtr = Tcl_CreateHashEntry(&systemColors, entry->name, &newPtr); if (entry->type == semantic) { NSString *selector = [[NSString alloc] initWithCString:entry->macName @@ -51,7 +51,7 @@ void initColorTable() entry->selector = selector; } if (newPtr == 0) { - oldEntry = (SystemColorMapEntry *) Tcl_GetHashValue(hPtr); + oldEntry = (SystemColorDatum *) Tcl_GetHashValue(hPtr); entry->index = oldEntry->index; } else { entry->index = index++; @@ -63,11 +63,11 @@ void initColorTable() * Build an array for looking up a color by its index. */ - systemColorMapSize = index; - systemColorIndex = ckalloc(systemColorMapSize * sizeof(SystemColorMapEntry*)); - for (hPtr = Tcl_FirstHashEntry(&systemColorMap, &search); hPtr != NULL; + numSystemColors = index; + systemColorIndex = ckalloc(numSystemColors * sizeof(SystemColorDatum*)); + for (hPtr = Tcl_FirstHashEntry(&systemColors, &search); hPtr != NULL; hPtr = Tcl_NextHashEntry(&search)) { - entry = (SystemColorMapEntry *) Tcl_GetHashValue(hPtr); + entry = (SystemColorDatum *) Tcl_GetHashValue(hPtr); systemColorIndex[entry->index] = entry; } } @@ -142,11 +142,11 @@ unsigned long TkMacOSXClearPixel( * * GetEntryFromPixel -- * - * Extract a SystemColorMapEntry from the table. + * Extract a SystemColorDatum from the table. * * Results: - * A pointer to a SystemColorMapEntry, or NULL if the pixel value is + * A pointer to a SystemColorDatum, or NULL if the pixel value is * invalid. * * Side effects: @@ -155,7 +155,7 @@ unsigned long TkMacOSXClearPixel( *---------------------------------------------------------------------- */ -SystemColorMapEntry* +SystemColorDatum* GetEntryFromPixel( unsigned long pixel) { @@ -167,7 +167,7 @@ GetEntryFromPixel( if (p.pixel.colortype != rgbColor) { index = p.pixel.value; } - if (index < systemColorMapSize) { + if (index < numSystemColors) { return systemColorIndex[index]; } else { return NULL; @@ -210,7 +210,7 @@ static CGFloat windowBackground[4] = static void GetRGBA( - SystemColorMapEntry *entry, + SystemColorDatum *entry, unsigned long pixel, CGFloat *rgba) { @@ -263,7 +263,7 @@ GetRGBA( static Bool SetCGColorComponents( - SystemColorMapEntry *entry, + SystemColorDatum *entry, unsigned long pixel, CGColorRef *c) { @@ -354,7 +354,7 @@ TkSetMacColor( void *macColor) /* CGColorRef to modify. */ { CGColorRef *color = (CGColorRef*)macColor; - SystemColorMapEntry *entry = GetEntryFromPixel(pixel); + SystemColorDatum *entry = GetEntryFromPixel(pixel); if (entry) { return SetCGColorComponents(entry, pixel, color); @@ -539,7 +539,7 @@ TkMacOSXSetColorInContext( { OSStatus err = noErr; CGColorRef cgColor = nil; - SystemColorMapEntry *entry = GetEntryFromPixel(pixel); + SystemColorDatum *entry = GetEntryFromPixel(pixel); CGRect rect; HIThemeBackgroundDrawInfo info = {0, kThemeStateActive, 0};; @@ -595,8 +595,7 @@ void TkMacOSXUpdateXColor( Tk_Window tkwin) { MacPixel p; - CGFloat rgba[4] = {0, 0, 0, 1}; - SystemColorMapEntry *entry = GetEntryFromPixel(color->pixel); + SystemColorDatum *entry = GetEntryFromPixel(color->pixel); p.ulong = color->pixel; if (p.pixel.colortype == semantic || p.pixel.colortype == ttkBackground) { @@ -610,15 +609,18 @@ void TkMacOSXUpdateXColor( * * TkpGetColor -- * - * Allocate a new TkColor for the color with the given name. + * Create a new TkColor for the color with the given name. The colormap + * field is set to 1 if passed a window with a LightAqua appearance or 2 + * if passed a window with a DarkAqua appearance. These will be managed + * separately in the per-display table of TkColors maintained by Tk. This + * function is called by Tk_Color. * * Results: * Returns a newly allocated TkColor, or NULL on failure. * * Side effects: - * May invalidate the colormap cache associated with tkwin upon - * allocating a new colormap entry. Allocates a new TkColor - * structure. + * + * Allocates memory for the TkColor structure. * *---------------------------------------------------------------------- */ @@ -630,7 +632,7 @@ TkpGetColor( * suitable for passing to XParseColor). */ { Display *display = tkwin != None ? Tk_Display(tkwin) : NULL; - Colormap colormap = tkwin!= None ? Tk_Colormap(tkwin) : None; + Colormap colormap = tkwin!= None ? 1 + TkMacOSXInDarkMode(tkwin) : None; TkColor *tkColPtr; XColor color; static Bool initialized = NO; @@ -648,10 +650,10 @@ TkpGetColor( if (strncasecmp(name, "system", 6) == 0) { Tcl_HashEntry *hPtr = NULL; - SystemColorMapEntry *entry; - hPtr = Tcl_FindHashEntry(&systemColorMap, name + 6); + SystemColorDatum *entry; + hPtr = Tcl_FindHashEntry(&systemColors, name + 6); if (hPtr != NULL) { - entry = (SystemColorMapEntry *)Tcl_GetHashValue(hPtr); + entry = (SystemColorDatum *)Tcl_GetHashValue(hPtr); CGColorRef c; unsigned int pixelCode = entry->index; if (SetCGColorComponents(entry, 0, &c)) { diff --git a/macosx/tkMacOSXColor.h b/macosx/tkMacOSXColor.h index a4acc08..7675037 100644 --- a/macosx/tkMacOSXColor.h +++ b/macosx/tkMacOSXColor.h @@ -66,9 +66,9 @@ typedef struct { char *macName; NSString *selector; /* Filled in if used. */ int index; /* Filled in when the hash table is constructed. */ -} SystemColorMapEntry; +} SystemColorDatum; -static SystemColorMapEntry systemColorMapData[] = { +static SystemColorDatum systemColorData[] = { {"Pixel", rgbColor, 0 }, /* This must be first. */ {"Transparent", clearColor, 0 }, -- cgit v0.12 From 41650692a4d8914df2e78b8bb957e16676cb12e8 Mon Sep 17 00:00:00 2001 From: culler Date: Fri, 31 Jul 2020 15:00:49 +0000 Subject: Make winfo rgb work correctly with the light and dark colormaps --- macosx/tkMacOSXColor.c | 95 ++++++++++++++++++++++++++++++++------------------ macosx/tkMacOSXColor.h | 34 +++++++++++++----- 2 files changed, 87 insertions(+), 42 deletions(-) diff --git a/macosx/tkMacOSXColor.c b/macosx/tkMacOSXColor.c index 6c43e33..e67cbf7 100644 --- a/macosx/tkMacOSXColor.c +++ b/macosx/tkMacOSXColor.c @@ -20,7 +20,10 @@ static Tcl_HashTable systemColors; static int numSystemColors; -SystemColorDatum **systemColorIndex; +static int rgbColorIndex; +static SystemColorDatum **systemColorIndex; +static NSAppearance *darkAqua; +static NSAppearance *lightAqua; void initColorTable() { @@ -29,6 +32,8 @@ void initColorTable() Tcl_HashSearch search; Tcl_HashEntry *hPtr; int newPtr, index = 0; + darkAqua = [NSAppearance appearanceNamed:NSAppearanceNameDarkAqua]; + lightAqua = [NSAppearance appearanceNamed:NSAppearanceNameAqua]; /* * Build a hash table for looking up a color by its name. @@ -37,22 +42,19 @@ void initColorTable() for (entry = systemColorData; entry->name != NULL; entry++) { hPtr = Tcl_CreateHashEntry(&systemColors, entry->name, &newPtr); if (entry->type == semantic) { - NSString *selector = [[NSString alloc] + NSString *colorName = [[NSString alloc] initWithCString:entry->macName encoding:NSUTF8StringEncoding]; - /* - * Ignore this entry if NSColor does not recognize it. - */ - - if (![NSColor respondsToSelector: NSSelectorFromString(selector)]) { + SEL colorSelector = NSSelectorFromString(colorName); + if (![NSColor respondsToSelector:colorSelector]) { continue; } - [selector retain]; - entry->selector = selector; + entry->selector = [colorName retain]; } if (newPtr == 0) { oldEntry = (SystemColorDatum *) Tcl_GetHashValue(hPtr); entry->index = oldEntry->index; + [oldEntry->selector release]; } else { entry->index = index++; } @@ -62,7 +64,7 @@ void initColorTable() /* * Build an array for looking up a color by its index. */ - + numSystemColors = index; systemColorIndex = ckalloc(numSystemColors * sizeof(SystemColorDatum*)); for (hPtr = Tcl_FirstHashEntry(&systemColors, &search); hPtr != NULL; @@ -70,6 +72,14 @@ void initColorTable() entry = (SystemColorDatum *) Tcl_GetHashValue(hPtr); systemColorIndex[entry->index] = entry; } + + /* + * Remember the index of the rgbColor entry, + */ + + hPtr = Tcl_FindHashEntry(&systemColors, "Pixel"); + entry = (SystemColorDatum *) Tcl_GetHashValue(hPtr); + rgbColorIndex = entry->index; } /* @@ -160,8 +170,7 @@ GetEntryFromPixel( unsigned long pixel) { MacPixel p; - // Should make sure this is the rgbColor index, even if the data gets shuffled. - unsigned int index = 0; + unsigned int index = rgbColorIndex; p.ulong = pixel; if (p.pixel.colortype != rgbColor) { @@ -214,7 +223,7 @@ GetRGBA( unsigned long pixel, CGFloat *rgba) { - NSColor *bgColor, *color = nil; + NSColor *bgColor, *color; if (!sRGB) { sRGB = [NSColorSpace sRGBColorSpace]; @@ -251,7 +260,7 @@ GetRGBA( } break; case semantic: - color = [[NSColor valueForKey:entry->selector] colorUsingColorSpace:sRGB]; + color = [[NSColor valueForKey:entry->selector] colorUsingColorSpace:sRGB]; [color getComponents: rgba]; break; case clearColor: @@ -308,7 +317,6 @@ TkMacOSXInDarkMode(Tk_Window tkwin) int result = false; #if MAC_OS_X_VERSION_MAX_ALLOWED >= 101400 - static NSAppearanceName darkAqua = @"NSAppearanceNameDarkAqua"; if ([NSApp macOSVersion] >= 101400) { TkWindow *winPtr = (TkWindow*) tkwin; @@ -317,10 +325,9 @@ TkMacOSXInDarkMode(Tk_Window tkwin) view = TkMacOSXDrawableView(winPtr->privatePtr); } if (view) { - result = [view.effectiveAppearance.name isEqualToString:darkAqua]; + result = (view.effectiveAppearance.name == NSAppearanceNameDarkAqua); } else { - result = [[NSAppearance currentAppearance].name - isEqualToString:darkAqua]; + result = ([NSAppearance currentAppearance].name == NSAppearanceNameDarkAqua); } } #endif @@ -631,34 +638,59 @@ TkpGetColor( Tk_Uid name) /* Name of color to be allocated (in form * suitable for passing to XParseColor). */ { - Display *display = tkwin != None ? Tk_Display(tkwin) : NULL; - Colormap colormap = tkwin!= None ? 1 + TkMacOSXInDarkMode(tkwin) : None; + Display *display = NULL; + Colormap colormap = noColormap; TkColor *tkColPtr; XColor color; static Bool initialized = NO; static NSColorSpace* sRGB = NULL; + if (!initialized) { initialized = YES; sRGB = [NSColorSpace sRGBColorSpace]; initColorTable(); } + if (tkwin) { + display = Tk_Display(tkwin); + colormap = TkMacOSXInDarkMode(tkwin) ? darkColormap : lightColormap; + } + /* - * Check to see if this is a system color. Otherwise, XParseColor - * will do all the work. + * Check to see if this is a system color. If not, just call XParseColor. */ if (strncasecmp(name, "system", 6) == 0) { - Tcl_HashEntry *hPtr = NULL; - SystemColorDatum *entry; - hPtr = Tcl_FindHashEntry(&systemColors, name + 6); + Tcl_HashEntry *hPtr = Tcl_FindHashEntry(&systemColors, name + 6); + MacPixel p; + if (hPtr != NULL) { - entry = (SystemColorDatum *)Tcl_GetHashValue(hPtr); + SystemColorDatum *entry = (SystemColorDatum *)Tcl_GetHashValue(hPtr); CGColorRef c; - unsigned int pixelCode = entry->index; - if (SetCGColorComponents(entry, 0, &c)) { - MacPixel p; + p.pixel.colortype = entry->type; + p.pixel.value = entry->index; + color.pixel = p.ulong; + if (entry->type == semantic) { + CGFloat rgba[4]; + NSAppearance *savedAppearance = [NSAppearance currentAppearance]; + switch(colormap) { + case lightColormap: + [NSAppearance setCurrentAppearance:lightAqua]; + break; + case darkColormap: + [NSAppearance setCurrentAppearance:darkAqua]; + break; + default: + break; + } + GetRGBA(entry, p.ulong, rgba); + color.red = rgba[0] * 65535.0; + color.green = rgba[1] * 65535.0; + color.blue = rgba[2] * 65535.0; + [NSAppearance setCurrentAppearance:savedAppearance]; + goto validXColor; + } else if (SetCGColorComponents(entry, 0, &c)) { const size_t n = CGColorGetNumberOfComponents(c); const CGFloat *rgba = CGColorGetComponents(c); @@ -674,16 +706,12 @@ TkpGetColor( default: Tcl_Panic("CGColor with %d components", (int) n); } - p.pixel.value = pixelCode; - p.pixel.colortype = entry->type; - color.pixel = p.ulong; CGColorRelease(c); goto validXColor; } CGColorRelease(c); } } - if (TkParseColor(display, colormap, name, &color) == 0) { return NULL; } @@ -691,7 +719,6 @@ TkpGetColor( validXColor: tkColPtr = ckalloc(sizeof(TkColor)); tkColPtr->color = color; - return tkColPtr; } diff --git a/macosx/tkMacOSXColor.h b/macosx/tkMacOSXColor.h index 7675037..9cbe8a3 100644 --- a/macosx/tkMacOSXColor.h +++ b/macosx/tkMacOSXColor.h @@ -55,6 +55,17 @@ typedef union MacPixel_t { } MacPixel; /* + * We maintain two colormaps, one for the LightAqua appearance and one for the + * DarkAqua appearance. + */ + +enum macColormap { + noColormap, + lightColormap, + darkColormap, +}; + +/* * In TkMacOSXColor.c a Tk hash table is constructed from the static data * below to map system color names to CGColors. */ @@ -62,17 +73,17 @@ typedef union MacPixel_t { typedef struct { const char *name; enum colorType type; - long value; + int value; char *macName; - NSString *selector; /* Filled in if used. */ - int index; /* Filled in when the hash table is constructed. */ + /* Fields below are filled in after or during construction of the hash table. */ + int index; + NSString *selector; } SystemColorDatum; static SystemColorDatum systemColorData[] = { -{"Pixel", rgbColor, 0 }, /* This must be first. */ +{"Pixel", rgbColor, 0 }, {"Transparent", clearColor, 0 }, - {"Highlight", HIBrush, kThemeBrushPrimaryHighlightColor }, {"HighlightSecondary", HIBrush, kThemeBrushSecondaryHighlightColor }, {"HighlightText", HIBrush, kThemeBrushBlack }, @@ -145,9 +156,8 @@ static SystemColorDatum systemColorData[] = { {"ListViewEvenRowBackground", HIBrush, kThemeBrushListViewEvenRowBackground }, {"ListViewColumnDivider", HIBrush, kThemeBrushListViewColumnDivider }, - -{"ButtonText", HIText, kThemeTextColorPushButtonActive }, -{"MenuActiveText", HIText, kThemeTextColorMenuItemSelected }, +{"ButtonText", HIText, kThemeTextColorPushButtonActive }, +{"MenuActiveText", HIText, kThemeTextColorMenuItemSelected }, {"MenuDisabled", HIText, kThemeTextColorMenuItemDisabled }, {"MenuText", HIText, kThemeTextColorMenuItemActive }, {"BlackText", HIText, kThemeTextColorBlack }, @@ -248,3 +258,11 @@ static SystemColorDatum systemColorData[] = { }; #endif +/* + * Local Variables: + * mode: objc + * c-basic-offset: 4 + * fill-column: 79 + * coding: utf-8 + * End: + */ -- cgit v0.12 From ec1fbf2bb9c415c33579658a7a0ebfffcddc19d1 Mon Sep 17 00:00:00 2001 From: culler Date: Fri, 31 Jul 2020 17:09:38 +0000 Subject: Tidying up a few loose ends. --- macosx/tkMacOSXColor.c | 105 +++++++++++++++++++++++++++++++++++-------------- 1 file changed, 76 insertions(+), 29 deletions(-) diff --git a/macosx/tkMacOSXColor.c b/macosx/tkMacOSXColor.c index e67cbf7..e576dd7 100644 --- a/macosx/tkMacOSXColor.c +++ b/macosx/tkMacOSXColor.c @@ -21,9 +21,14 @@ static Tcl_HashTable systemColors; static int numSystemColors; static int rgbColorIndex; +static int controlAccentIndex; +static Bool useFakeAccentColor = NO; static SystemColorDatum **systemColorIndex; static NSAppearance *darkAqua; static NSAppearance *lightAqua; +static NSColorSpace* sRGB = NULL; +static CGFloat windowBackground[4] = + {236.0 / 255, 236.0 / 255, 236.0 / 255, 1.0}; void initColorTable() { @@ -47,7 +52,11 @@ void initColorTable() encoding:NSUTF8StringEncoding]; SEL colorSelector = NSSelectorFromString(colorName); if (![NSColor respondsToSelector:colorSelector]) { - continue; + if ([colorName isEqualToString:@"controlAccentColor"]) { + useFakeAccentColor = YES; + } else { + continue; + } } entry->selector = [colorName retain]; } @@ -74,12 +83,15 @@ void initColorTable() } /* - * Remember the index of the rgbColor entry, + * Remember the indexes of some special entries. */ hPtr = Tcl_FindHashEntry(&systemColors, "Pixel"); entry = (SystemColorDatum *) Tcl_GetHashValue(hPtr); rgbColorIndex = entry->index; + hPtr = Tcl_FindHashEntry(&systemColors, "ControlAccentColor"); + entry = (SystemColorDatum *) Tcl_GetHashValue(hPtr); + controlAccentIndex = entry->index; } /* @@ -155,7 +167,6 @@ unsigned long TkMacOSXClearPixel( * Extract a SystemColorDatum from the table. * * Results: - * A pointer to a SystemColorDatum, or NULL if the pixel value is * invalid. * @@ -183,40 +194,27 @@ GetEntryFromPixel( } } + /* *---------------------------------------------------------------------- * - * SetCGColorComponents -- - * - * Set the components of a CGColorRef from an XColor pixel value and a - * system color map entry. The pixel value is only used in the case where - * the color is of type rgbColor. In that case the normalized XColor RGB - * values are copied into the CGColorRef. + * GetRGB -- * - * In 64 bit macOS systems there are no HITheme functions which convert - * HIText or HIBackground colors to CGColors. (GetThemeTextColor was - * removed, and it was never possible with backgrounds.) If we get one of - * these we return black. + * Given a SystemColorDatum and a pointer to an array of 4 CGFloats, store + * the associated RGBA color values in the array. In the case of the + * RGBColor datum, the unsigned long pixel value containing the RGB values + * must also be provided as the pixel parameter. Otherwise the pixel + * parameter is ignored. * * Results: - * True if the function succeeds, false otherwise. + * None * * Side effects: - * None. + * The array rgba is filled in. * *---------------------------------------------------------------------- */ -#if MAC_OS_X_VERSION_MAX_ALLOWED >= 101400 - #define CONTROL_ACCENT_COLOR controlAccentColor -#else - #define CONTROL_ACCENT_COLOR colorForControlTint:[NSColor currentControlTint] -#endif - -static NSColorSpace* sRGB = NULL; -static CGFloat windowBackground[4] = - {236.0 / 255, 236.0 / 255, 236.0 / 255, 1.0}; - static void GetRGBA( SystemColorDatum *entry, @@ -242,7 +240,7 @@ GetRGBA( */ if ([NSApp macOSVersion] < 101400) { - for (int i=0; i<3; i++) { + for (int i = 0; i < 3; i++) { rgba[i] = windowBackground[i]; } } else { @@ -260,15 +258,65 @@ GetRGBA( } break; case semantic: - color = [[NSColor valueForKey:entry->selector] colorUsingColorSpace:sRGB]; + if (entry->index == controlAccentIndex && useFakeAccentColor) { + color = [NSColor colorForControlTint: [NSColor currentControlTint]]; + } else { + color = [[NSColor valueForKey:entry->selector] colorUsingColorSpace:sRGB]; + } [color getComponents: rgba]; break; case clearColor: rgba[3] = 0; + case HIText: +#ifdef __LP64__ + color = [[NSColor textColor] colorUsingColorSpace:sRGB]; + [color getComponents: rgba]; +#else + { + RGBColor rgb; + err = GetThemeTextColor(kThemeTextColorPushButtonActive, 32, + true, &rgb); + if (err == noErr) { + rgba[0] = (CGFLoat) rgb.red / 65535; + rgba[1] = (CGFLoat) rgb.green / 65535; + rgba[2] = (CGFLoat) rgb.blue / 65535; + } + } +#endif + break; + case HIBackground: + color = [[NSColor windowBackgroundColor] colorUsingColorSpace:sRGB]; + [color getComponents: rgba]; + break; default: break; } } + +/* + *---------------------------------------------------------------------- + * + * SetCGColorComponents -- + * + * Set the components of a CGColorRef from an XColor pixel value and a + * system color map entry. The pixel value is only used in the case where + * the color is of type rgbColor. In that case the normalized XColor RGB + * values are copied into the CGColorRef. + * + * In 64 bit macOS systems there are no HITheme functions which convert + * HIText or HIBackground colors to CGColors. (GetThemeTextColor was + * removed, and it was never possible with backgrounds.) On 64-bit systems + * we replace all HIText colors by systemTextColor and all HIBackground + * colors by systemWindowBackgroundColor. + * + * Results: + * True if the function succeeds, false otherwise. + * + * Side effects: + * None. + * + *---------------------------------------------------------------------- + */ static Bool SetCGColorComponents( @@ -685,10 +733,10 @@ TkpGetColor( break; } GetRGBA(entry, p.ulong, rgba); + [NSAppearance setCurrentAppearance:savedAppearance]; color.red = rgba[0] * 65535.0; color.green = rgba[1] * 65535.0; color.blue = rgba[2] * 65535.0; - [NSAppearance setCurrentAppearance:savedAppearance]; goto validXColor; } else if (SetCGColorComponents(entry, 0, &c)) { const size_t n = CGColorGetNumberOfComponents(c); @@ -709,7 +757,6 @@ TkpGetColor( CGColorRelease(c); goto validXColor; } - CGColorRelease(c); } } if (TkParseColor(display, colormap, name, &color) == 0) { -- cgit v0.12 From 33c01e381216e12ecd1375775ca7ef7cf332b7d5 Mon Sep 17 00:00:00 2001 From: culler Date: Fri, 31 Jul 2020 18:29:50 +0000 Subject: Fix the build for systems without darkAqua. --- macosx/tkMacOSXColor.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/macosx/tkMacOSXColor.c b/macosx/tkMacOSXColor.c index e576dd7..276fa68 100644 --- a/macosx/tkMacOSXColor.c +++ b/macosx/tkMacOSXColor.c @@ -37,7 +37,9 @@ void initColorTable() Tcl_HashSearch search; Tcl_HashEntry *hPtr; int newPtr, index = 0; +#if MAC_OS_X_VERSION_MAX_ALLOWED >= 101400 darkAqua = [NSAppearance appearanceNamed:NSAppearanceNameDarkAqua]; +#endif lightAqua = [NSAppearance appearanceNamed:NSAppearanceNameAqua]; /* @@ -722,6 +724,7 @@ TkpGetColor( if (entry->type == semantic) { CGFloat rgba[4]; NSAppearance *savedAppearance = [NSAppearance currentAppearance]; +#if MAC_OS_X_VERSION_MAX_ALLOWED >= 101400 switch(colormap) { case lightColormap: [NSAppearance setCurrentAppearance:lightAqua]; @@ -732,6 +735,7 @@ TkpGetColor( default: break; } +#endif GetRGBA(entry, p.ulong, rgba); [NSAppearance setCurrentAppearance:savedAppearance]; color.red = rgba[0] * 65535.0; -- cgit v0.12 From f75f4370274d507d9b3488cece85d3e49df019e4 Mon Sep 17 00:00:00 2001 From: culler Date: Fri, 31 Jul 2020 18:44:30 +0000 Subject: Prevent a warning on systems without darkAqua. --- macosx/tkMacOSXColor.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/macosx/tkMacOSXColor.c b/macosx/tkMacOSXColor.c index 276fa68..370e8a5 100644 --- a/macosx/tkMacOSXColor.c +++ b/macosx/tkMacOSXColor.c @@ -24,8 +24,10 @@ static int rgbColorIndex; static int controlAccentIndex; static Bool useFakeAccentColor = NO; static SystemColorDatum **systemColorIndex; -static NSAppearance *darkAqua; static NSAppearance *lightAqua; +#if MAC_OS_X_VERSION_MAX_ALLOWED >= 101400 +static NSAppearance *darkAqua; +#endif static NSColorSpace* sRGB = NULL; static CGFloat windowBackground[4] = {236.0 / 255, 236.0 / 255, 236.0 / 255, 1.0}; -- cgit v0.12 From 76f6c8ed20f1b31eb53111b9ad3363f3998c271c Mon Sep 17 00:00:00 2001 From: culler Date: Fri, 31 Jul 2020 20:34:29 +0000 Subject: Remove an unused function. Deal with colors which are not supported on older systems (10.9) --- macosx/tkMacOSXColor.c | 31 ++++++------------------------- macosx/tkMacOSXColor.h | 8 ++++++++ 2 files changed, 14 insertions(+), 25 deletions(-) diff --git a/macosx/tkMacOSXColor.c b/macosx/tkMacOSXColor.c index 370e8a5..b77adf3 100644 --- a/macosx/tkMacOSXColor.c +++ b/macosx/tkMacOSXColor.c @@ -1,5 +1,5 @@ /* - * tkMacOSXColor.c -- + * TkMacOSXColor.c -- * * This file maintains a database of color values for the Tk * toolkit, in order to avoid round-trips to the server to @@ -59,6 +59,8 @@ void initColorTable() if ([colorName isEqualToString:@"controlAccentColor"]) { useFakeAccentColor = YES; } else { + /* Uncomment to print all unsupported colors: */ + /* printf("Unsupported color %s\n", colorName.UTF8String); */ continue; } } @@ -83,6 +85,9 @@ void initColorTable() for (hPtr = Tcl_FirstHashEntry(&systemColors, &search); hPtr != NULL; hPtr = Tcl_NextHashEntry(&search)) { entry = (SystemColorDatum *) Tcl_GetHashValue(hPtr); + if (entry == NULL) { + Tcl_Panic("Unsupported semantic color with no supported backup!"); + } systemColorIndex[entry->index] = entry; } @@ -639,30 +644,6 @@ TkMacOSXSetColorInContext( } } - -/* - * Recompute the red, green and blue values of an XColor from its pixel value. - * To do this we need to know which window the color is being used in, so we - * can figure out if that window is in dark mode or not. And we will probably - * need to involve drawRect somehow since the correct color values are only - * available when a valid graphics context is available. - */ - -MODULE_SCOPE -void TkMacOSXUpdateXColor( - XColor *color, - Tk_Window tkwin) -{ - MacPixel p; - SystemColorDatum *entry = GetEntryFromPixel(color->pixel); - - p.ulong = color->pixel; - if (p.pixel.colortype == semantic || p.pixel.colortype == ttkBackground) { - printf("Updating %s in window %s for %s Mode\n", - entry->name, Tk_PathName(tkwin), - TkMacOSXInDarkMode(tkwin) ? "Dark" : "Light"); - } -} /* *---------------------------------------------------------------------- * diff --git a/macosx/tkMacOSXColor.h b/macosx/tkMacOSXColor.h index 9cbe8a3..82c88c9 100644 --- a/macosx/tkMacOSXColor.h +++ b/macosx/tkMacOSXColor.h @@ -80,6 +80,13 @@ typedef struct { NSString *selector; } SystemColorDatum; +/* + * WARNING: Semantic colors which are not supported on all systems must be + * preceded by a backup color with the same name which *is* supported. Systems + * which do support the color will replace the backup value when the table is + * constructed. Failing to ensure this will result in a Tcl_Panic abort. + */ + static SystemColorDatum systemColorData[] = { {"Pixel", rgbColor, 0 }, {"Transparent", clearColor, 0 }, @@ -237,6 +244,7 @@ static SystemColorDatum systemColorData[] = { {"TextColor", semantic, 0, "textColor" }, {"SelectedTextColor", semantic, 0, "selectedTextColor" }, +{"LabelColor", semantic, 0, "textColor"}, {"LabelColor", semantic, 0, "labelColor"}, {"ControlTextColor", semantic, 0, "controlTextColor" }, {"DisabledControlTextColor", semantic, 0, "disabledControlTextColor" }, -- cgit v0.12 From e6d961299e585273d99aa80444ad9237449c512a Mon Sep 17 00:00:00 2001 From: culler Date: Fri, 31 Jul 2020 21:10:41 +0000 Subject: Adjust some unixEmbed tests which were failing sporadically. --- tests/unixEmbed.test | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/tests/unixEmbed.test b/tests/unixEmbed.test index 2ebf9c2..428e510 100644 --- a/tests/unixEmbed.test +++ b/tests/unixEmbed.test @@ -1238,13 +1238,12 @@ test unixEmbed-10.1 {geometry propagation in tkUnixWm.c/UpdateGeometryInfo} -con deleteWindows } -body { frame .f1 -container 1 -width 200 -height 50 - update pack .f1 - update + update idletasks toplevel .t1 -use [winfo id .f1] -width 150 -height 80 - update + update idletasks wm geometry .t1 +40+50 - update + update idletasks wm geometry .t1 } -cleanup { deleteWindows @@ -1256,10 +1255,11 @@ test unixEmbed-10.2 {geometry propagation in tkUnixWm.c/UpdateGeometryInfo} -con } -body { frame .f1 -container 1 -width 200 -height 50 pack .f1 + update idletasks toplevel .t1 -use [winfo id .f1] -width 150 -height 80 - update + update idletasks wm geometry .t1 70x300+10+20 - update + update idletasks wm geometry .t1 } -cleanup { deleteWindows -- cgit v0.12 From 0266964e830c47c5a6e12654b8e84378dfe97ca5 Mon Sep 17 00:00:00 2001 From: culler Date: Sat, 1 Aug 2020 16:12:43 +0000 Subject: The colormaps do not fix winfo rgb. Handle that directly. And deal with Big Sur deprecations. --- generic/tkCmds.c | 16 ++++++++++++++++ macosx/tkMacOSXColor.c | 38 ++++++++++++++++++++------------------ macosx/tkMacOSXConstants.h | 4 +++- macosx/tkMacOSXPort.h | 3 +++ macosx/tkMacOSXWindowEvent.c | 7 ------- 5 files changed, 42 insertions(+), 26 deletions(-) diff --git a/generic/tkCmds.c b/generic/tkCmds.c index 7f4c49b..1bc4f8c 100644 --- a/generic/tkCmds.c +++ b/generic/tkCmds.c @@ -1748,7 +1748,23 @@ Tk_WinfoObjCmd( if (TkGetWindowFromObj(interp, tkwin, objv[2], &tkwin) != TCL_OK) { return TCL_ERROR; } +#ifdef TK_HAS_DYNAMIC_COLORS + + /* + * Make sure that the TkColor used for the winfo rgb command is + * destroyed when we are through with it, so we do not get stale RGB + * values next time. + */ + + { + Colormap temp = Tk_Colormap(tkwin); + Tk_Colormap(tkwin) = TK_DYNAMIC_COLORMAP; + colorPtr = Tk_GetColor(interp, tkwin, Tcl_GetString(objv[3])); + Tk_Colormap(tkwin) = temp; + } +#else colorPtr = Tk_GetColor(interp, tkwin, Tcl_GetString(objv[3])); +#endif if (colorPtr == NULL) { return TCL_ERROR; } diff --git a/macosx/tkMacOSXColor.c b/macosx/tkMacOSXColor.c index b77adf3..2a78c97 100644 --- a/macosx/tkMacOSXColor.c +++ b/macosx/tkMacOSXColor.c @@ -24,9 +24,9 @@ static int rgbColorIndex; static int controlAccentIndex; static Bool useFakeAccentColor = NO; static SystemColorDatum **systemColorIndex; -static NSAppearance *lightAqua; #if MAC_OS_X_VERSION_MAX_ALLOWED >= 101400 -static NSAppearance *darkAqua; +static NSAppearance *lightAqua = nil; +static NSAppearance *darkAqua = nil; #endif static NSColorSpace* sRGB = NULL; static CGFloat windowBackground[4] = @@ -41,8 +41,8 @@ void initColorTable() int newPtr, index = 0; #if MAC_OS_X_VERSION_MAX_ALLOWED >= 101400 darkAqua = [NSAppearance appearanceNamed:NSAppearanceNameDarkAqua]; -#endif lightAqua = [NSAppearance appearanceNamed:NSAppearanceNameAqua]; +#endif /* * Build a hash table for looking up a color by its name. @@ -230,7 +230,7 @@ GetRGBA( unsigned long pixel, CGFloat *rgba) { - NSColor *bgColor, *color; + NSColor *bgColor, *color = nil; if (!sRGB) { sRGB = [NSColorSpace sRGBColorSpace]; @@ -268,7 +268,9 @@ GetRGBA( break; case semantic: if (entry->index == controlAccentIndex && useFakeAccentColor) { +#if MAC_OS_X_VERSION_MAX_ALLOWED < 101500 color = [NSColor colorForControlTint: [NSColor currentControlTint]]; +#endif } else { color = [[NSColor valueForKey:entry->selector] colorUsingColorSpace:sRGB]; } @@ -672,9 +674,9 @@ TkpGetColor( * suitable for passing to XParseColor). */ { Display *display = NULL; - Colormap colormap = noColormap; TkColor *tkColPtr; XColor color; + Colormap colormap = tkwin ? Tk_Colormap(tkwin) : noColormap; static Bool initialized = NO; static NSColorSpace* sRGB = NULL; @@ -683,10 +685,8 @@ TkpGetColor( sRGB = [NSColorSpace sRGBColorSpace]; initColorTable(); } - if (tkwin) { display = Tk_Display(tkwin); - colormap = TkMacOSXInDarkMode(tkwin) ? darkColormap : lightColormap; } /* @@ -706,21 +706,22 @@ TkpGetColor( color.pixel = p.ulong; if (entry->type == semantic) { CGFloat rgba[4]; - NSAppearance *savedAppearance = [NSAppearance currentAppearance]; #if MAC_OS_X_VERSION_MAX_ALLOWED >= 101400 - switch(colormap) { - case lightColormap: - [NSAppearance setCurrentAppearance:lightAqua]; - break; - case darkColormap: - [NSAppearance setCurrentAppearance:darkAqua]; - break; - default: - break; + NSAppearance *savedAppearance = [NSAppearance currentAppearance]; + NSAppearance *windowAppearance; + if (TkMacOSXInDarkMode(tkwin)) { + windowAppearance = darkAqua; + colormap = darkColormap; + } else { + windowAppearance = lightAqua; + colormap = lightColormap; } -#endif + [NSAppearance setCurrentAppearance:windowAppearance]; GetRGBA(entry, p.ulong, rgba); [NSAppearance setCurrentAppearance:savedAppearance]; +#else + GetRGBA(entry, p.ulong, rgba); +#endif color.red = rgba[0] * 65535.0; color.green = rgba[1] * 65535.0; color.blue = rgba[2] * 65535.0; @@ -752,6 +753,7 @@ TkpGetColor( validXColor: tkColPtr = ckalloc(sizeof(TkColor)); + tkColPtr->colormap = colormap; tkColPtr->color = color; return tkColPtr; } diff --git a/macosx/tkMacOSXConstants.h b/macosx/tkMacOSXConstants.h index e019ea1..19ffd2c 100644 --- a/macosx/tkMacOSXConstants.h +++ b/macosx/tkMacOSXConstants.h @@ -106,6 +106,8 @@ typedef NSInteger NSModalResponse; #define graphicsContextWithGraphicsPort graphicsContextWithCGContext #endif - +#if MAC_OS_X_VERSION_MIN_REQUIRED >= 110000 +#define NSWindowStyleMaskTexturedBackground 0 #endif +#endif diff --git a/macosx/tkMacOSXPort.h b/macosx/tkMacOSXPort.h index 8d92601..f5c3689 100644 --- a/macosx/tkMacOSXPort.h +++ b/macosx/tkMacOSXPort.h @@ -159,10 +159,13 @@ */ #define TK_NO_DOUBLE_BUFFERING 1 +#define TK_HAS_DYNAMIC_COLORS 1 +#define TK_DYNAMIC_COLORMAP 0x0fffffff /* * Used by xcolor.c */ + MODULE_SCOPE unsigned long TkMacOSXRGBPixel(unsigned long red, unsigned long green, unsigned long blue); #define TkpGetPixel(p) (TkMacOSXRGBPixel(p->red, p->green, p->blue)) diff --git a/macosx/tkMacOSXWindowEvent.c b/macosx/tkMacOSXWindowEvent.c index 5f52ea7..a23a6d7 100644 --- a/macosx/tkMacOSXWindowEvent.c +++ b/macosx/tkMacOSXWindowEvent.c @@ -1137,13 +1137,6 @@ ConfigureRestrictProc( Tk_QueueWindowEvent((XEvent *) &event, TCL_QUEUE_TAIL); } -- (BOOL) isOpaque -{ - NSWindow *w = [self window]; - return (w && (([w styleMask] & NSTexturedBackgroundWindowMask) || - ![w isOpaque]) ? NO : YES); -} - /* * On Catalina this is never called and drawRect clips to the rect that * is passed to it by AppKit. -- cgit v0.12 From 78ff00814bd1260e38a3990c46571c8f5ff94c5d Mon Sep 17 00:00:00 2001 From: culler Date: Sun, 2 Aug 2020 14:13:58 +0000 Subject: Edit comments --- macosx/tkMacOSXColor.c | 77 +++++++++++++++++++++++++++----------------------- 1 file changed, 41 insertions(+), 36 deletions(-) diff --git a/macosx/tkMacOSXColor.c b/macosx/tkMacOSXColor.c index 2a78c97..b4347b8 100644 --- a/macosx/tkMacOSXColor.c +++ b/macosx/tkMacOSXColor.c @@ -9,6 +9,7 @@ * Copyright (c) 1994-1996 Sun Microsystems, Inc. * Copyright 2001-2009, Apple Inc. * Copyright (c) 2006-2009 Daniel A. Steffen + * Copyright (c) 2020 Marc Culler * * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. @@ -47,7 +48,7 @@ void initColorTable() /* * Build a hash table for looking up a color by its name. */ - + for (entry = systemColorData; entry->name != NULL; entry++) { hPtr = Tcl_CreateHashEntry(&systemColors, entry->name, &newPtr); if (entry->type == semantic) { @@ -75,7 +76,7 @@ void initColorTable() } Tcl_SetHashValue(hPtr, entry); } - + /* * Build an array for looking up a color by its index. */ @@ -94,7 +95,7 @@ void initColorTable() /* * Remember the indexes of some special entries. */ - + hPtr = Tcl_FindHashEntry(&systemColors, "Pixel"); entry = (SystemColorDatum *) Tcl_GetHashValue(hPtr); rgbColorIndex = entry->index; @@ -113,7 +114,7 @@ void initColorTable() * intensities. The inputs are cast as unsigned longs but are * expected to have values representable by an unsigned short * as used in the XColor struct. These values are divided by - * 256 tp generate a 24-bit RGB pixel value. + * 256 to generate a 24-bit RGB pixel value. * * This is called by the TkpGetPixel macro, used in xcolor.c. * @@ -173,7 +174,8 @@ unsigned long TkMacOSXClearPixel( * * GetEntryFromPixel -- * - * Extract a SystemColorDatum from the table. + * Look up a SystemColorDatum which describes the XColor with + * the specified value as its pixel field. * * Results: * A pointer to a SystemColorDatum, or NULL if the pixel value is @@ -285,7 +287,7 @@ GetRGBA( #else { RGBColor rgb; - err = GetThemeTextColor(kThemeTextColorPushButtonActive, 32, + err = GetThemeTextColor(kThemeTextColorPushButtonActive, 32, true, &rgb); if (err == noErr) { rgba[0] = (CGFLoat) rgb.red / 65535; @@ -310,9 +312,10 @@ GetRGBA( * SetCGColorComponents -- * * Set the components of a CGColorRef from an XColor pixel value and a - * system color map entry. The pixel value is only used in the case where + * SystemColorDatum. The pixel value is only used in the case where * the color is of type rgbColor. In that case the normalized XColor RGB - * values are copied into the CGColorRef. + * values are copied into the CGColorRef. Otherwise the components are + * computed from the SystemColorDatum. * * In 64 bit macOS systems there are no HITheme functions which convert * HIText or HIBackground colors to CGColors. (GetThemeTextColor was @@ -328,7 +331,7 @@ GetRGBA( * *---------------------------------------------------------------------- */ - + static Bool SetCGColorComponents( SystemColorDatum *entry, @@ -384,7 +387,7 @@ TkMacOSXInDarkMode(Tk_Window tkwin) view = TkMacOSXDrawableView(winPtr->privatePtr); } if (view) { - result = (view.effectiveAppearance.name == NSAppearanceNameDarkAqua); + result = (view.effectiveAppearance.name == NSAppearanceNameDarkAqua); } else { result = ([NSAppearance currentAppearance].name == NSAppearanceNameDarkAqua); } @@ -547,9 +550,10 @@ TkMacOSXCreateCGColor( * TkMacOSXGetNSColor -- * * Creates an autoreleased NSColor from a X style pixel value. + * The return value is nil if the pixel value is invalid. * * Results: - * Returns nil if not a real pixel, NSColor* otherwise. + * A possibly nil pointer to an NSColor. * * Side effects: * None @@ -583,10 +587,9 @@ TkMacOSXGetNSColor( * * TkMacOSXSetColorInContext -- * - * Sets fill and stroke color in the given CG context from an X - * pixel value, or if the pixel code indicates a system color, - * sets the corresponding brush, textColor or background via - * HITheme APIs if available or Appearance mgr APIs. + * Sets the fill and stroke colors in the given CGContext to the CGColor + * which corresponds to the XColor having the specified value for its pixel + * field. * * Results: * None. @@ -651,17 +654,19 @@ TkMacOSXSetColorInContext( * * TkpGetColor -- * - * Create a new TkColor for the color with the given name. The colormap - * field is set to 1 if passed a window with a LightAqua appearance or 2 - * if passed a window with a DarkAqua appearance. These will be managed - * separately in the per-display table of TkColors maintained by Tk. This - * function is called by Tk_Color. + * Create a new TkColor for the color with the given name, for use in the + * specified window. The colormap field is set to lightColormap if the + * window has a LightAqua appearance, or darkColormap if the window has a + * DarkAqua appearance. TkColors with different colormaps are managed + * separately in the per-display table of TkColors maintained by Tk. + * + * This function is called by Tk_GetColor. * * Results: * Returns a newly allocated TkColor, or NULL on failure. * * Side effects: - * + * * Allocates memory for the TkColor structure. * *---------------------------------------------------------------------- @@ -708,7 +713,7 @@ TkpGetColor( CGFloat rgba[4]; #if MAC_OS_X_VERSION_MAX_ALLOWED >= 101400 NSAppearance *savedAppearance = [NSAppearance currentAppearance]; - NSAppearance *windowAppearance; + NSAppearance *windowAppearance; if (TkMacOSXInDarkMode(tkwin)) { windowAppearance = darkAqua; colormap = darkColormap; @@ -721,7 +726,7 @@ TkpGetColor( [NSAppearance setCurrentAppearance:savedAppearance]; #else GetRGBA(entry, p.ulong, rgba); -#endif +#endif color.red = rgba[0] * 65535.0; color.green = rgba[1] * 65535.0; color.blue = rgba[2] * 65535.0; @@ -763,19 +768,19 @@ validXColor: * * TkpGetColorByValue -- * - * Given a desired set of red-green-blue intensities for a color, - * locate a pixel value to use to draw that color in a given - * window. + * Given an pointer to an XColor, construct a TkColor whose red, green and + * blue intensities match those of the XColor as closely as possible. For + * the Macintosh, this means that the colortype bitfield of the pixel + * value will be RGBColor and that the color intensities stored in its + * 24-bit value bitfield are computed from the 16-bit red green and blue + * values in the XColor by dividing by 256. * * Results: - * The return value is a pointer to an TkColor structure that - * indicates the closest red, blue, and green intensities available - * to those specified in colorPtr, and also specifies a pixel - * value to use to draw in that color. + * A pointer to a newly allocated TkColor structure. * * Side effects: * May invalidate the colormap cache for the specified window. - * Allocates a new TkColor structure. + * Allocates memory for a TkColor structure. * *---------------------------------------------------------------------- */ @@ -830,10 +835,11 @@ XCreateColormap( Visual *visual, /* Not used. */ int alloc) /* Not used. */ { - static Colormap index = 1; + static Colormap index = 16; /* - * Just return a new value each time. + * Just return a new value each time, large enough that it will not + * conflict with any value of the macColormap enum. */ return index++; } @@ -855,9 +861,8 @@ XFreeColors( unsigned long planes) /* Number of pixel planes. */ { /* - * The Macintosh version of Tk uses TrueColor. Nothing - * needs to be done to release colors as there really is - * no colormap in the Tk sense. + * Nothing needs to be done to release colors as there really is no + * colormap in the Tk sense. */ return Success; } -- cgit v0.12 From 6adf699f287514c469d4827316e856204f4f84c6 Mon Sep 17 00:00:00 2001 From: culler Date: Mon, 3 Aug 2020 01:28:50 +0000 Subject: Fix [fca13549b6]: TkMacOSXRGBPixel() used incorrectly in ImageGetPixel() --- macosx/tkMacOSXImage.c | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/macosx/tkMacOSXImage.c b/macosx/tkMacOSXImage.c index 4691e41..8a7aac4 100644 --- a/macosx/tkMacOSXImage.c +++ b/macosx/tkMacOSXImage.c @@ -314,7 +314,12 @@ ImageGetPixel( int x, int y) { - unsigned char r = 0, g = 0, b = 0; + unsigned short r = 0, g = 0, b = 0; + + /* + * Compute 8 bit red green and blue values, which are multiplied by 256 and + * ed as inputs to TkMacOSXRGBPixel. + */ if (image && image->data) { unsigned char *srcPtr = ((unsigned char*) image->data) @@ -322,7 +327,7 @@ ImageGetPixel( + (((image->xoffset + x) * image->bits_per_pixel) / NBBY); switch (image->bits_per_pixel) { - case 32: + case 32: /* 8 bits per channel */ r = (*((unsigned int*) srcPtr) >> 16) & 0xff; g = (*((unsigned int*) srcPtr) >> 8) & 0xff; b = (*((unsigned int*) srcPtr) ) & 0xff; @@ -332,12 +337,12 @@ ImageGetPixel( r = srcPtr[1]; g = srcPtr[2]; b = srcPtr[3]; }*/ break; - case 16: + case 16: /* 5 bits per channel */ r = (*((unsigned short*) srcPtr) >> 7) & 0xf8; g = (*((unsigned short*) srcPtr) >> 2) & 0xf8; b = (*((unsigned short*) srcPtr) << 3) & 0xf8; break; - case 8: + case 8: /* 2 bits per channel */ r = (*srcPtr << 2) & 0xc0; g = (*srcPtr << 4) & 0xc0; b = (*srcPtr << 6) & 0xc0; @@ -345,7 +350,7 @@ ImageGetPixel( g |= g >> 2 | g >> 4 | g >> 6; b |= b >> 2 | b >> 4 | b >> 6; break; - case 4: { + case 4: { /* 1 bit per channel */ unsigned char c = (x % 2) ? *srcPtr : (*srcPtr >> 4); r = (c & 0x04) ? 0xff : 0; @@ -353,12 +358,13 @@ ImageGetPixel( b = (c & 0x01) ? 0xff : 0; break; } - case 1: + case 1: /* Black-white bitmap. */ r = g = b = ((*srcPtr) & (0x80 >> (x % 8))) ? 0xff : 0; break; } } - return TkMacOSXRGBPixel(r, g, b); + + return TkMacOSXRGBPixel(r<<8, g<<8, b<<8); } /* -- cgit v0.12 From d67e38a86d79f6df28051611978dcaac8b1be9cc Mon Sep 17 00:00:00 2001 From: culler Date: Mon, 3 Aug 2020 02:16:07 +0000 Subject: Be a little more efficient. --- macosx/tkMacOSXColor.c | 13 ++++++------- macosx/tkMacOSXImage.c | 4 ++-- macosx/tkMacOSXPort.h | 2 +- 3 files changed, 9 insertions(+), 10 deletions(-) diff --git a/macosx/tkMacOSXColor.c b/macosx/tkMacOSXColor.c index b4347b8..ce91520 100644 --- a/macosx/tkMacOSXColor.c +++ b/macosx/tkMacOSXColor.c @@ -112,11 +112,10 @@ void initColorTable() * Return an unsigned long value suitable for use in the pixel * field of an XColor with the specified red, green and blue * intensities. The inputs are cast as unsigned longs but are - * expected to have values representable by an unsigned short - * as used in the XColor struct. These values are divided by - * 256 to generate a 24-bit RGB pixel value. + * expected to have values representable by an unsigned char. * - * This is called by the TkpGetPixel macro, used in xcolor.c. + * This is called in the TkpGetPixel macro, used in xcolor.c, + * and in ImageGetPixel. * * Results: * An unsigned long that can be used as the pixel field of an XColor. @@ -134,9 +133,9 @@ TkMacOSXRGBPixel( { MacPixel p; p.pixel.colortype = rgbColor; - p.pixel.value = (((red >> 8) & 0xff) << 16) | - (((green >> 8) & 0xff) << 8) | - ((blue >> 8) & 0xff); + p.pixel.value = ((red & 0xff) << 16) | + ((green & 0xff) << 8) | + (blue & 0xff); return p.ulong; } diff --git a/macosx/tkMacOSXImage.c b/macosx/tkMacOSXImage.c index 8a7aac4..2967bb0 100644 --- a/macosx/tkMacOSXImage.c +++ b/macosx/tkMacOSXImage.c @@ -314,7 +314,7 @@ ImageGetPixel( int x, int y) { - unsigned short r = 0, g = 0, b = 0; + unsigned char r = 0, g = 0, b = 0; /* * Compute 8 bit red green and blue values, which are multiplied by 256 and @@ -364,7 +364,7 @@ ImageGetPixel( } } - return TkMacOSXRGBPixel(r<<8, g<<8, b<<8); + return TkMacOSXRGBPixel(r, g, b); } /* diff --git a/macosx/tkMacOSXPort.h b/macosx/tkMacOSXPort.h index f5c3689..4347766 100644 --- a/macosx/tkMacOSXPort.h +++ b/macosx/tkMacOSXPort.h @@ -168,6 +168,6 @@ MODULE_SCOPE unsigned long TkMacOSXRGBPixel(unsigned long red, unsigned long green, unsigned long blue); -#define TkpGetPixel(p) (TkMacOSXRGBPixel(p->red, p->green, p->blue)) +#define TkpGetPixel(p) (TkMacOSXRGBPixel(p->red >> 8, p->green >> 8, p->blue >> 8)) #endif /* _TKMACPORT */ -- cgit v0.12 From 2c6e31f7fd99017ab613b39e77357ad91b0be8c7 Mon Sep 17 00:00:00 2001 From: culler Date: Mon, 3 Aug 2020 12:41:10 +0000 Subject: Edit comments. --- macosx/tkMacOSXImage.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/macosx/tkMacOSXImage.c b/macosx/tkMacOSXImage.c index 2967bb0..0e33b23 100644 --- a/macosx/tkMacOSXImage.c +++ b/macosx/tkMacOSXImage.c @@ -300,7 +300,11 @@ DestroyImage( * Get a single pixel from an image. * * Results: - * Returns the 32 bit pixel value. + * The XColor structure contains an unsigned long field named pixel which + * identifies the color. This function returns the unsigned long that + * would be used as the pixel value of an XColor that has the same red + * green and blue components as the XImage pixel at the specified + * location. * * Side effects: * None. @@ -317,8 +321,8 @@ ImageGetPixel( unsigned char r = 0, g = 0, b = 0; /* - * Compute 8 bit red green and blue values, which are multiplied by 256 and - * ed as inputs to TkMacOSXRGBPixel. + * Compute 8 bit red green and blue values, which are passed as inputs to + * TkMacOSXRGBPixel to produce the pixel value. */ if (image && image->data) { -- cgit v0.12 From 35b2870cff97386ce7ea956ee317bec123017d52 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Mon, 3 Aug 2020 17:25:02 +0000 Subject: end-of-line spacing cleanup --- generic/tkCmds.c | 2 +- generic/tkTest.c | 2 +- macosx/tkMacOSXColor.h | 58 ++++++++++++++++++++++----------------------- macosx/tkMacOSXPrivate.h | 2 +- macosx/tkMacOSXSubwindows.c | 4 ++-- 5 files changed, 34 insertions(+), 34 deletions(-) diff --git a/generic/tkCmds.c b/generic/tkCmds.c index 1bc4f8c..89b5254 100644 --- a/generic/tkCmds.c +++ b/generic/tkCmds.c @@ -1755,7 +1755,7 @@ Tk_WinfoObjCmd( * destroyed when we are through with it, so we do not get stale RGB * values next time. */ - + { Colormap temp = Tk_Colormap(tkwin); Tk_Colormap(tkwin) = TK_DYNAMIC_COLORMAP; diff --git a/generic/tkTest.c b/generic/tkTest.c index c22e649..26b3fa5 100644 --- a/generic/tkTest.c +++ b/generic/tkTest.c @@ -1592,7 +1592,7 @@ ImageDisplay( * Drawing is not possible on the first call to DisplayImage. * Save the message, but do not log it until the actual display. */ - + if (instPtr->displayFailed == False) { sprintf(instPtr->buffer, "%s display %d %d %d %d", instPtr->masterPtr->imageName, imageX, imageY, width, height); diff --git a/macosx/tkMacOSXColor.h b/macosx/tkMacOSXColor.h index 82c88c9..89d147d 100644 --- a/macosx/tkMacOSXColor.h +++ b/macosx/tkMacOSXColor.h @@ -6,7 +6,7 @@ * colors in a GC are unsigned longs. These are meant to be used as indexes * into a table of XColors, where an XColor is declared in Xlib.h as: * typedef struct { - * unsigned long pixel; + * unsigned long pixel; * unsigned short red, green, blue; * char flags; * char pad; @@ -48,7 +48,7 @@ typedef struct xpixel_t { unsigned value: 24; /* Either RGB or an index into systemColorMap. */ unsigned colortype: 8; } xpixel; - + typedef union MacPixel_t { unsigned long ulong; xpixel pixel; @@ -64,11 +64,11 @@ enum macColormap { lightColormap, darkColormap, }; - + /* * In TkMacOSXColor.c a Tk hash table is constructed from the static data * below to map system color names to CGColors. - */ + */ typedef struct { const char *name; @@ -96,15 +96,15 @@ static SystemColorDatum systemColorData[] = { {"HighlightText", HIBrush, kThemeBrushBlack }, {"HighlightAlternate", HIBrush, kThemeBrushAlternatePrimaryHighlightColor }, {"PrimaryHighlightColor", HIBrush, kThemeBrushPrimaryHighlightColor }, -{"ButtonFace", HIBrush, kThemeBrushButtonFaceActive }, +{"ButtonFace", HIBrush, kThemeBrushButtonFaceActive }, {"SecondaryHighlightColor", HIBrush, kThemeBrushSecondaryHighlightColor }, -{"ButtonFrame", HIBrush, kThemeBrushButtonFrameActive }, +{"ButtonFrame", HIBrush, kThemeBrushButtonFrameActive }, {"AlternatePrimaryHighlightColor", HIBrush, kThemeBrushAlternatePrimaryHighlightColor }, -{"WindowBody", HIBrush, kThemeBrushDocumentWindowBackground }, +{"WindowBody", HIBrush, kThemeBrushDocumentWindowBackground }, {"SheetBackground", HIBrush, kThemeBrushSheetBackground }, {"MenuActive", HIBrush, kThemeBrushMenuBackgroundSelected }, {"Menu", HIBrush, kThemeBrushMenuBackground }, -{"DialogBackgroundInactive", HIBrush, kThemeBrushDialogBackgroundInactive }, +{"DialogBackgroundInactive", HIBrush, kThemeBrushDialogBackgroundInactive }, {"DialogBackgroundActive", HIBrush, kThemeBrushDialogBackgroundActive }, {"AlertBackgroundActive", HIBrush, kThemeBrushAlertBackgroundActive }, {"AlertBackgroundInactive", HIBrush, kThemeBrushAlertBackgroundInactive }, @@ -113,28 +113,28 @@ static SystemColorDatum systemColorData[] = { {"UtilityWindowBackgroundActive", HIBrush, kThemeBrushUtilityWindowBackgroundActive }, {"UtilityWindowBackgroundInactive", HIBrush, kThemeBrushUtilityWindowBackgroundInactive }, {"ListViewSortColumnBackground", HIBrush, kThemeBrushListViewSortColumnBackground }, -{"ListViewBackground", HIBrush, kThemeBrushListViewBackground }, +{"ListViewBackground", HIBrush, kThemeBrushListViewBackground }, {"IconLabelBackground", HIBrush, kThemeBrushIconLabelBackground }, -{"ListViewSeparator", HIBrush, kThemeBrushListViewSeparator }, +{"ListViewSeparator", HIBrush, kThemeBrushListViewSeparator }, {"ChasingArrows", HIBrush, kThemeBrushChasingArrows }, -{"DragHilite", HIBrush, kThemeBrushDragHilite }, -{"DocumentWindowBackground", HIBrush, kThemeBrushDocumentWindowBackground }, +{"DragHilite", HIBrush, kThemeBrushDragHilite }, +{"DocumentWindowBackground", HIBrush, kThemeBrushDocumentWindowBackground }, {"FinderWindowBackground", HIBrush, kThemeBrushFinderWindowBackground }, -{"ScrollBarDelimiterActive", HIBrush, kThemeBrushScrollBarDelimiterActive }, -{"ScrollBarDelimiterInactive", HIBrush, kThemeBrushScrollBarDelimiterInactive }, +{"ScrollBarDelimiterActive", HIBrush, kThemeBrushScrollBarDelimiterActive }, +{"ScrollBarDelimiterInactive", HIBrush, kThemeBrushScrollBarDelimiterInactive }, {"FocusHighlight", HIBrush, kThemeBrushFocusHighlight }, -{"PopupArrowActive", HIBrush, kThemeBrushPopupArrowActive }, -{"PopupArrowPressed", HIBrush, kThemeBrushPopupArrowPressed }, -{"PopupArrowInactive", HIBrush, kThemeBrushPopupArrowInactive }, -{"AppleGuideCoachmark", HIBrush, kThemeBrushAppleGuideCoachmark }, +{"PopupArrowActive", HIBrush, kThemeBrushPopupArrowActive }, +{"PopupArrowPressed", HIBrush, kThemeBrushPopupArrowPressed }, +{"PopupArrowInactive", HIBrush, kThemeBrushPopupArrowInactive }, +{"AppleGuideCoachmark", HIBrush, kThemeBrushAppleGuideCoachmark }, {"IconLabelBackgroundSelected", HIBrush, kThemeBrushIconLabelBackgroundSelected }, {"StaticAreaFill", HIBrush, kThemeBrushStaticAreaFill }, {"ActiveAreaFill", HIBrush, kThemeBrushActiveAreaFill }, {"ButtonFrameActive", HIBrush, kThemeBrushButtonFrameActive }, -{"ButtonFrameInactive", HIBrush, kThemeBrushButtonFrameInactive }, -{"ButtonFaceActive", HIBrush, kThemeBrushButtonFaceActive }, -{"ButtonFaceInactive", HIBrush, kThemeBrushButtonFaceInactive }, -{"ButtonFacePressed", HIBrush, kThemeBrushButtonFacePressed }, +{"ButtonFrameInactive", HIBrush, kThemeBrushButtonFrameInactive }, +{"ButtonFaceActive", HIBrush, kThemeBrushButtonFaceActive }, +{"ButtonFaceInactive", HIBrush, kThemeBrushButtonFaceInactive }, +{"ButtonFacePressed", HIBrush, kThemeBrushButtonFacePressed }, {"ButtonActiveDarkShadow", HIBrush, kThemeBrushButtonActiveDarkShadow }, {"ButtonActiveDarkHighlight", HIBrush, kThemeBrushButtonActiveDarkHighlight }, {"ButtonActiveLightShadow", HIBrush, kThemeBrushButtonActiveLightShadow }, @@ -163,10 +163,10 @@ static SystemColorDatum systemColorData[] = { {"ListViewEvenRowBackground", HIBrush, kThemeBrushListViewEvenRowBackground }, {"ListViewColumnDivider", HIBrush, kThemeBrushListViewColumnDivider }, -{"ButtonText", HIText, kThemeTextColorPushButtonActive }, -{"MenuActiveText", HIText, kThemeTextColorMenuItemSelected }, -{"MenuDisabled", HIText, kThemeTextColorMenuItemDisabled }, -{"MenuText", HIText, kThemeTextColorMenuItemActive }, +{"ButtonText", HIText, kThemeTextColorPushButtonActive }, +{"MenuActiveText", HIText, kThemeTextColorMenuItemSelected }, +{"MenuDisabled", HIText, kThemeTextColorMenuItemDisabled }, +{"MenuText", HIText, kThemeTextColorMenuItemActive }, {"BlackText", HIText, kThemeTextColorBlack }, {"DialogActiveText", HIText, kThemeTextColorDialogActive }, {"DialogInactiveText", HIText, kThemeTextColorDialogInactive }, @@ -192,8 +192,8 @@ static SystemColorDatum systemColorData[] = { {"ListViewText", HIText, kThemeTextColorListView }, {"DocumentWindowTitleActiveText", HIText, kThemeTextColorDocumentWindowTitleActive }, {"DocumentWindowTitleInactiveText", HIText, kThemeTextColorDocumentWindowTitleInactive }, -{"MovableModalWindowTitleActiveText", HIText, kThemeTextColorMovableModalWindowTitleActive }, -{"MovableModalWindowTitleInactiveText", HIText, kThemeTextColorMovableModalWindowTitleInactive }, +{"MovableModalWindowTitleActiveText", HIText, kThemeTextColorMovableModalWindowTitleActive }, +{"MovableModalWindowTitleInactiveText", HIText, kThemeTextColorMovableModalWindowTitleInactive }, {"UtilityWindowTitleActiveText", HIText, kThemeTextColorUtilityWindowTitleActive }, {"UtilityWindowTitleInactiveText", HIText, kThemeTextColorUtilityWindowTitleInactive }, {"PopupWindowTitleActiveText", HIText, kThemeTextColorPopupWindowTitleActive }, @@ -231,7 +231,7 @@ static SystemColorDatum systemColorData[] = { * Dynamic Colors */ -{"WindowBackgroundColor", ttkBackground, 0 }, +{"WindowBackgroundColor", ttkBackground, 0 }, {"WindowBackgroundColor1", ttkBackground, 1 }, {"WindowBackgroundColor2", ttkBackground, 2 }, {"WindowBackgroundColor3", ttkBackground, 3 }, diff --git a/macosx/tkMacOSXPrivate.h b/macosx/tkMacOSXPrivate.h index ceca8f8..9005d82 100644 --- a/macosx/tkMacOSXPrivate.h +++ b/macosx/tkMacOSXPrivate.h @@ -150,7 +150,7 @@ typedef union MacKeycode_t { keycode_v v; keycode_x x; } MacKeycode; - + /* * Macros used in tkMacOSXKeyboard.c and tkMacOSXKeyEvent.c. * Note that 0x7f is del and 0xF8FF is the Apple Logo character. diff --git a/macosx/tkMacOSXSubwindows.c b/macosx/tkMacOSXSubwindows.c index a58bab4..8b316fa 100644 --- a/macosx/tkMacOSXSubwindows.c +++ b/macosx/tkMacOSXSubwindows.c @@ -211,7 +211,7 @@ XMapWindow( * we handle this event immediately and then process the idle * events that it generates. */ - + Tk_HandleEvent(&event); while (Tcl_DoOneEvent(TCL_IDLE_EVENTS)) {} } else { @@ -329,7 +329,7 @@ XUnmapWindow( * we handle this event immediately and then process the idle * events that it generates. */ - + Tk_HandleEvent(&event); while (Tcl_DoOneEvent(TCL_IDLE_EVENTS)) {} } else { -- cgit v0.12 From c175e28a9285a80c72f2280d08cf3c6440be73a5 Mon Sep 17 00:00:00 2001 From: culler Date: Mon, 3 Aug 2020 20:07:52 +0000 Subject: Add the backgroundLoop from mac_styles, to allow Tk to run while a menu is open. --- macosx/tkMacOSXMenu.c | 70 ++++++++++++++++++++++++++++++++++++++++++++++++ macosx/tkMacOSXNotify.c | 12 ++++++--- macosx/tkMacOSXPrivate.h | 7 +++-- 3 files changed, 84 insertions(+), 5 deletions(-) diff --git a/macosx/tkMacOSXMenu.c b/macosx/tkMacOSXMenu.c index 735f7d2..dceb051 100644 --- a/macosx/tkMacOSXMenu.c +++ b/macosx/tkMacOSXMenu.c @@ -108,6 +108,65 @@ static void MenuSelectEvent(TkMenu *menuPtr); static void RecursivelyClearActiveMenu(TkMenu *menuPtr); static int ModifierCharWidth(Tk_Font tkfont); +#pragma mark TkBackgroundLoop + +/* + * The function TkMacOSXEventsCheckProc (in tkMacOSXNotify.c) is the "check + * proc" for the macOS event source. Its job is to remove NSEvents from the + * default event queue of the NSApplication. It does this by calling the + * method [NSApp nextEventMatchingMask: untilDate: inMode: dequeue:]. As a + * rule, when the untilDate is set to the distant past this method returns + * immediately. An exception to that rule is when the next event is the button + * press on a menu button. In that case, the method starts running a nested + * event loop in the mode NSEventTrackingRunLoopMode which does not return + * until the menu has been dismissed. In Tk 8.6.10 and earlier, this meant + * that the Tk event loop would block in its call to the check proc as long as + * the menu was posted. For example, opening a menu during the Rube Goldberg + * demo would cause the animation to stop. This was also the case for + * menubuttons. + * + * The TKBackground object below works around this problem, and allows a Tk + * event loop to run while a menu is open. It is a subclass of NSThread which + * inserts requests to call [NSApp _runBackgroundLoop] onto the queue + * associated with the NSEventTrackingRunLoopMode. One of these threads gets + * started in the callback [NSApp menuBeginTracking] and cancelled in [NSApp + * menuEndTracking]. + */ + +@interface TKBackgroundLoop: NSThread +@end + +@implementation TKBackgroundLoop +- (void) main +{ + NSArray *modeArray = [NSArray arrayWithObjects: NSEventTrackingRunLoopMode, + nil]; + while(1) { + + /* + * Queue a request to process Tk events during event tracking. + */ + + [NSApp performSelectorOnMainThread:@selector(_runBackgroundLoop) + withObject:nil + waitUntilDone:true + modes:modeArray]; + if (self.cancelled) { + [NSThread exit]; + } + + /* + * Allow the tracked events to be processed too. + */ + + [NSThread sleepForTimeInterval:0.001]; + } +} +@end + +TKBackgroundLoop *backgroundLoop = nil; + + #pragma mark TKMenu /* @@ -395,6 +454,12 @@ static int ModifierCharWidth(Tk_Font tkfont); #ifdef TK_MAC_DEBUG_NOTIFICATIONS TKLog(@"-[%@(%p) %s] %@", [self class], self, _cmd, notification); #endif + if (backgroundLoop) { + [backgroundLoop cancel]; + [backgroundLoop release]; + } + backgroundLoop = [[TKBackgroundLoop alloc] init]; + [backgroundLoop start]; //TkMacOSXClearMenubarActive(); //TkMacOSXPreprocessMenu(); } @@ -404,6 +469,11 @@ static int ModifierCharWidth(Tk_Font tkfont); #ifdef TK_MAC_DEBUG_NOTIFICATIONS TKLog(@"-[%@(%p) %s] %@", [self class], self, _cmd, notification); #endif + if (backgroundLoop) { + [backgroundLoop cancel]; + [backgroundLoop release]; + backgroundLoop = nil; + } if (!inPostMenu) { TkMacOSXClearMenubarActive(); } diff --git a/macosx/tkMacOSXNotify.c b/macosx/tkMacOSXNotify.c index 83b4695..5163e21 100644 --- a/macosx/tkMacOSXNotify.c +++ b/macosx/tkMacOSXNotify.c @@ -176,6 +176,7 @@ void DebugPrintQueue(void) } } #endif + [super sendEvent:theEvent]; [NSApp tkCheckPasteboard]; @@ -185,6 +186,13 @@ void DebugPrintQueue(void) #endif } + +- (void) _runBackgroundLoop +{ + while(Tcl_DoOneEvent(TCL_IDLE_EVENTS|TCL_TIMER_EVENTS|TCL_DONT_WAIT)){ + TkMacOSXDrawAllViews(NULL); + } +} @end #pragma mark - @@ -203,15 +211,13 @@ void DebugPrintQueue(void) *---------------------------------------------------------------------- */ -NSString * +static NSString * GetRunLoopMode(NSModalSession modalSession) { NSString *runLoopMode = nil; if (modalSession) { runLoopMode = NSModalPanelRunLoopMode; - } else if (TkMacOSXGetCapture()) { - runLoopMode = NSEventTrackingRunLoopMode; } if (!runLoopMode) { runLoopMode = [[NSRunLoop currentRunLoop] currentMode]; diff --git a/macosx/tkMacOSXPrivate.h b/macosx/tkMacOSXPrivate.h index 9005d82..6109024 100644 --- a/macosx/tkMacOSXPrivate.h +++ b/macosx/tkMacOSXPrivate.h @@ -304,8 +304,7 @@ MODULE_SCOPE void TkMacOSXDrawSolidBorder(Tk_Window tkwin, GC gc, int inset, int thickness); MODULE_SCOPE int TkMacOSXServices_Init(Tcl_Interp *interp); MODULE_SCOPE int TkMacOSXRegisterServiceWidgetObjCmd(ClientData clientData, - Tcl_Interp *interp, int objc, - Tcl_Obj *const objv[]); + Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]); MODULE_SCOPE unsigned TkMacOSXAddVirtual(unsigned int keycode); MODULE_SCOPE void TkMacOSXWinNSBounds(TkWindow *winPtr, NSView *view, NSRect *bounds); @@ -341,6 +340,8 @@ VISIBILITY_HIDDEN NSArray *_defaultApplicationMenuItems, *_defaultWindowsMenuItems; NSArray *_defaultHelpMenuItems, *_defaultFileMenuItems; NSAutoreleasePool *_mainPool; + NSThread *_backgoundLoop; + #ifdef __i386__ /* The Objective C runtime used on i386 requires this. */ int _poolLock; @@ -348,6 +349,7 @@ VISIBILITY_HIDDEN Bool _isDrawing; Bool _needsToDraw; #endif + } @property int poolLock; @property int macOSVersion; @@ -378,6 +380,7 @@ VISIBILITY_HIDDEN @interface NSApplication(TKNotify) /* We need to declare this hidden method. */ - (void) _modalSession: (NSModalSession) session sendEvent: (NSEvent *) event; +- (void) _runBackgroundLoop; @end @interface TKApplication(TKEvent) - (NSEvent *)tkProcessEvent:(NSEvent *)theEvent; -- cgit v0.12 From 6115c6c774ebf6d95e16b18fd3378d691f26722d Mon Sep 17 00:00:00 2001 From: culler Date: Tue, 4 Aug 2020 11:56:44 +0000 Subject: Address compiler warnings about dark mode when building on new systems with old targets. --- macosx/tkMacOSXColor.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/macosx/tkMacOSXColor.c b/macosx/tkMacOSXColor.c index ce91520..64c9cf2 100644 --- a/macosx/tkMacOSXColor.c +++ b/macosx/tkMacOSXColor.c @@ -40,9 +40,12 @@ void initColorTable() Tcl_HashSearch search; Tcl_HashEntry *hPtr; int newPtr, index = 0; + #if MAC_OS_X_VERSION_MAX_ALLOWED >= 101400 - darkAqua = [NSAppearance appearanceNamed:NSAppearanceNameDarkAqua]; - lightAqua = [NSAppearance appearanceNamed:NSAppearanceNameAqua]; + if (@available(macOS 10.14, *)) { + darkAqua = [NSAppearance appearanceNamed:NSAppearanceNameDarkAqua]; + lightAqua = [NSAppearance appearanceNamed:NSAppearanceNameAqua]; + } #endif /* @@ -378,21 +381,19 @@ TkMacOSXInDarkMode(Tk_Window tkwin) int result = false; #if MAC_OS_X_VERSION_MAX_ALLOWED >= 101400 - - if ([NSApp macOSVersion] >= 101400) { + if (@available(macOS 10.14, *)) { TkWindow *winPtr = (TkWindow*) tkwin; NSView *view = nil; if (winPtr && winPtr->privatePtr) { view = TkMacOSXDrawableView(winPtr->privatePtr); } if (view) { - result = (view.effectiveAppearance.name == NSAppearanceNameDarkAqua); + result = (view.effectiveAppearance == darkAqua); } else { - result = ([NSAppearance currentAppearance].name == NSAppearanceNameDarkAqua); + result = ([NSAppearance currentAppearance] == darkAqua); } } #endif - return result; } -- cgit v0.12 From 2fa48e044573693869cc6412efc1aaf4a51917bd Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Tue, 4 Aug 2020 14:25:37 +0000 Subject: Make TCL_UNUSED() macro usable in Tk 8.6 --- generic/tkInt.h | 23 ++++ macosx/tkMacOSXColor.c | 32 ++--- macosx/tkMacOSXColor.h | 326 ++++++++++++++++++++++++------------------------ macosx/tkMacOSXMenu.c | 14 +-- macosx/tkMacOSXXStubs.c | 283 +++++++++++++++-------------------------- 5 files changed, 312 insertions(+), 366 deletions(-) diff --git a/generic/tkInt.h b/generic/tkInt.h index 6f40078..2f64f99 100644 --- a/generic/tkInt.h +++ b/generic/tkInt.h @@ -59,6 +59,21 @@ # endif #endif +#ifndef JOIN +# define JOIN(a,b) JOIN1(a,b) +# define JOIN1(a,b) a##b +#endif + +#ifndef TCL_UNUSED +# if defined(__cplusplus) +# define TCL_UNUSED(T) T +# elif defined(__GNUC__) && (__GNUC__ > 2) +# define TCL_UNUSED(T) T JOIN(dummy, __LINE__) __attribute__((unused)) +# else +# define TCL_UNUSED(T) T JOIN(dummy, __LINE__) +# endif +#endif + #if defined(_WIN32) && (TCL_MAJOR_VERSION < 9) && (TCL_MINOR_VERSION < 7) # if TCL_UTF_MAX > 3 # define Tcl_WCharToUtfDString(a,b,c) Tcl_WinTCharToUtf((TCHAR *)(a),(b)*sizeof(WCHAR),c) @@ -1041,6 +1056,10 @@ void Tcl_Panic(const char *, ...) __attribute__((analyzer_noreturn)); #include "tkIntDecls.h" +#ifdef __cplusplus +extern "C" { +#endif + /* * Themed widget set init function: */ @@ -1324,6 +1343,10 @@ MODULE_SCOPE int TkOldTestInit(Tcl_Interp *interp); MODULE_SCOPE int TkplatformtestInit(Tcl_Interp *interp); #endif +#ifdef __cplusplus +} +#endif + #endif /* _TKINT */ /* diff --git a/macosx/tkMacOSXColor.c b/macosx/tkMacOSXColor.c index 64c9cf2..89bddb9 100644 --- a/macosx/tkMacOSXColor.c +++ b/macosx/tkMacOSXColor.c @@ -194,7 +194,7 @@ GetEntryFromPixel( unsigned long pixel) { MacPixel p; - unsigned int index = rgbColorIndex; + int index = rgbColorIndex; p.ulong = pixel; if (p.pixel.colortype != rgbColor) { @@ -757,7 +757,7 @@ TkpGetColor( } validXColor: - tkColPtr = ckalloc(sizeof(TkColor)); + tkColPtr = (TkColor *)ckalloc(sizeof(TkColor)); tkColPtr->colormap = colormap; tkColPtr->color = color; return tkColPtr; @@ -787,11 +787,11 @@ validXColor: TkColor * TkpGetColorByValue( - Tk_Window tkwin, /* Window in which color will be used. */ + TCL_UNUSED(Tk_Window), /* Window in which color will be used. */ XColor *colorPtr) /* Red, green, and blue fields indicate * desired color. */ { - TkColor *tkColPtr = ckalloc(sizeof(TkColor)); + TkColor *tkColPtr = (TkColor *)ckalloc(sizeof(TkColor)); tkColPtr->color.red = colorPtr->red; tkColPtr->color.green = colorPtr->green; @@ -820,7 +820,7 @@ TkpGetColorByValue( Status XAllocColor( Display *display, /* Display. */ - Colormap map, /* Not used. */ + TCL_UNUSED(Colormap), /* Not used. */ XColor *colorPtr) /* XColor struct to modify. */ { display->request++; @@ -830,10 +830,10 @@ XAllocColor( Colormap XCreateColormap( - Display *display, /* Display. */ - Window window, /* X window. */ - Visual *visual, /* Not used. */ - int alloc) /* Not used. */ + TCL_UNUSED(Display *), /* Display. */ + TCL_UNUSED(Window), /* X window. */ + TCL_UNUSED(Visual *), /* Not used. */ + TCL_UNUSED(int)) /* Not used. */ { static Colormap index = 16; @@ -846,19 +846,19 @@ XCreateColormap( int XFreeColormap( - Display* display, /* Display. */ - Colormap colormap) /* Colormap. */ + TCL_UNUSED(Display *), /* Display. */ + TCL_UNUSED(Colormap)) /* Colormap. */ { return Success; } int XFreeColors( - Display* display, /* Display. */ - Colormap colormap, /* Colormap. */ - unsigned long* pixels, /* Array of pixels. */ - int npixels, /* Number of pixels. */ - unsigned long planes) /* Number of pixel planes. */ + TCL_UNUSED(Display *), /* Display. */ + TCL_UNUSED(Colormap), /* Colormap. */ + TCL_UNUSED(unsigned long *), /* Array of pixels. */ + TCL_UNUSED(int), /* Number of pixels. */ + TCL_UNUSED(unsigned long)) /* Number of pixel planes. */ { /* * Nothing needs to be done to release colors as there really is no diff --git a/macosx/tkMacOSXColor.h b/macosx/tkMacOSXColor.h index 89d147d..535d15d 100644 --- a/macosx/tkMacOSXColor.h +++ b/macosx/tkMacOSXColor.h @@ -74,7 +74,7 @@ typedef struct { const char *name; enum colorType type; int value; - char *macName; + const char *macName; /* Fields below are filled in after or during construction of the hash table. */ int index; NSString *selector; @@ -88,181 +88,181 @@ typedef struct { */ static SystemColorDatum systemColorData[] = { -{"Pixel", rgbColor, 0 }, -{"Transparent", clearColor, 0 }, +{"Pixel", rgbColor, 0, NULL, 0, NULL }, +{"Transparent", clearColor, 0, NULL, 0, NULL }, -{"Highlight", HIBrush, kThemeBrushPrimaryHighlightColor }, -{"HighlightSecondary", HIBrush, kThemeBrushSecondaryHighlightColor }, -{"HighlightText", HIBrush, kThemeBrushBlack }, -{"HighlightAlternate", HIBrush, kThemeBrushAlternatePrimaryHighlightColor }, -{"PrimaryHighlightColor", HIBrush, kThemeBrushPrimaryHighlightColor }, -{"ButtonFace", HIBrush, kThemeBrushButtonFaceActive }, -{"SecondaryHighlightColor", HIBrush, kThemeBrushSecondaryHighlightColor }, -{"ButtonFrame", HIBrush, kThemeBrushButtonFrameActive }, -{"AlternatePrimaryHighlightColor", HIBrush, kThemeBrushAlternatePrimaryHighlightColor }, -{"WindowBody", HIBrush, kThemeBrushDocumentWindowBackground }, -{"SheetBackground", HIBrush, kThemeBrushSheetBackground }, -{"MenuActive", HIBrush, kThemeBrushMenuBackgroundSelected }, -{"Menu", HIBrush, kThemeBrushMenuBackground }, -{"DialogBackgroundInactive", HIBrush, kThemeBrushDialogBackgroundInactive }, -{"DialogBackgroundActive", HIBrush, kThemeBrushDialogBackgroundActive }, -{"AlertBackgroundActive", HIBrush, kThemeBrushAlertBackgroundActive }, -{"AlertBackgroundInactive", HIBrush, kThemeBrushAlertBackgroundInactive }, -{"ModelessDialogBackgroundActive", HIBrush, kThemeBrushModelessDialogBackgroundActive }, -{"ModelessDialogBackgroundInactive", HIBrush, kThemeBrushModelessDialogBackgroundInactive }, -{"UtilityWindowBackgroundActive", HIBrush, kThemeBrushUtilityWindowBackgroundActive }, -{"UtilityWindowBackgroundInactive", HIBrush, kThemeBrushUtilityWindowBackgroundInactive }, -{"ListViewSortColumnBackground", HIBrush, kThemeBrushListViewSortColumnBackground }, -{"ListViewBackground", HIBrush, kThemeBrushListViewBackground }, -{"IconLabelBackground", HIBrush, kThemeBrushIconLabelBackground }, -{"ListViewSeparator", HIBrush, kThemeBrushListViewSeparator }, -{"ChasingArrows", HIBrush, kThemeBrushChasingArrows }, -{"DragHilite", HIBrush, kThemeBrushDragHilite }, -{"DocumentWindowBackground", HIBrush, kThemeBrushDocumentWindowBackground }, -{"FinderWindowBackground", HIBrush, kThemeBrushFinderWindowBackground }, -{"ScrollBarDelimiterActive", HIBrush, kThemeBrushScrollBarDelimiterActive }, -{"ScrollBarDelimiterInactive", HIBrush, kThemeBrushScrollBarDelimiterInactive }, -{"FocusHighlight", HIBrush, kThemeBrushFocusHighlight }, -{"PopupArrowActive", HIBrush, kThemeBrushPopupArrowActive }, -{"PopupArrowPressed", HIBrush, kThemeBrushPopupArrowPressed }, -{"PopupArrowInactive", HIBrush, kThemeBrushPopupArrowInactive }, -{"AppleGuideCoachmark", HIBrush, kThemeBrushAppleGuideCoachmark }, -{"IconLabelBackgroundSelected", HIBrush, kThemeBrushIconLabelBackgroundSelected }, -{"StaticAreaFill", HIBrush, kThemeBrushStaticAreaFill }, -{"ActiveAreaFill", HIBrush, kThemeBrushActiveAreaFill }, -{"ButtonFrameActive", HIBrush, kThemeBrushButtonFrameActive }, -{"ButtonFrameInactive", HIBrush, kThemeBrushButtonFrameInactive }, -{"ButtonFaceActive", HIBrush, kThemeBrushButtonFaceActive }, -{"ButtonFaceInactive", HIBrush, kThemeBrushButtonFaceInactive }, -{"ButtonFacePressed", HIBrush, kThemeBrushButtonFacePressed }, -{"ButtonActiveDarkShadow", HIBrush, kThemeBrushButtonActiveDarkShadow }, -{"ButtonActiveDarkHighlight", HIBrush, kThemeBrushButtonActiveDarkHighlight }, -{"ButtonActiveLightShadow", HIBrush, kThemeBrushButtonActiveLightShadow }, -{"ButtonActiveLightHighlight", HIBrush, kThemeBrushButtonActiveLightHighlight }, -{"ButtonInactiveDarkShadow", HIBrush, kThemeBrushButtonInactiveDarkShadow }, -{"ButtonInactiveDarkHighlight", HIBrush, kThemeBrushButtonInactiveDarkHighlight }, -{"ButtonInactiveLightShadow", HIBrush, kThemeBrushButtonInactiveLightShadow }, -{"ButtonInactiveLightHighlight", HIBrush, kThemeBrushButtonInactiveLightHighlight }, -{"ButtonPressedDarkShadow", HIBrush, kThemeBrushButtonPressedDarkShadow }, -{"ButtonPressedDarkHighlight", HIBrush, kThemeBrushButtonPressedDarkHighlight }, -{"ButtonPressedLightShadow", HIBrush, kThemeBrushButtonPressedLightShadow }, -{"ButtonPressedLightHighlight", HIBrush, kThemeBrushButtonPressedLightHighlight }, -{"BevelActiveLight", HIBrush, kThemeBrushBevelActiveLight }, -{"BevelActiveDark", HIBrush, kThemeBrushBevelActiveDark }, -{"BevelInactiveLight", HIBrush, kThemeBrushBevelInactiveLight }, -{"BevelInactiveDark", HIBrush, kThemeBrushBevelInactiveDark }, -{"NotificationWindowBackground", HIBrush, kThemeBrushNotificationWindowBackground }, -{"MovableModalBackground", HIBrush, kThemeBrushMovableModalBackground }, -{"SheetBackgroundOpaque", HIBrush, kThemeBrushSheetBackgroundOpaque }, -{"DrawerBackground", HIBrush, kThemeBrushDrawerBackground }, -{"ToolbarBackground", HIBrush, kThemeBrushToolbarBackground }, -{"SheetBackgroundTransparent", HIBrush, kThemeBrushSheetBackgroundTransparent }, -{"MenuBackground", HIBrush, kThemeBrushMenuBackground }, -{"MenuBackgroundSelected", HIBrush, kThemeBrushMenuBackgroundSelected }, -{"ListViewOddRowBackground", HIBrush, kThemeBrushListViewOddRowBackground }, -{"ListViewEvenRowBackground", HIBrush, kThemeBrushListViewEvenRowBackground }, -{"ListViewColumnDivider", HIBrush, kThemeBrushListViewColumnDivider }, +{"Highlight", HIBrush, kThemeBrushPrimaryHighlightColor, NULL, 0, NULL }, +{"HighlightSecondary", HIBrush, kThemeBrushSecondaryHighlightColor, NULL, 0, NULL }, +{"HighlightText", HIBrush, kThemeBrushBlack, NULL, 0, NULL }, +{"HighlightAlternate", HIBrush, kThemeBrushAlternatePrimaryHighlightColor, NULL, 0, NULL }, +{"PrimaryHighlightColor", HIBrush, kThemeBrushPrimaryHighlightColor, NULL, 0, NULL }, +{"ButtonFace", HIBrush, kThemeBrushButtonFaceActive, NULL, 0, NULL }, +{"SecondaryHighlightColor", HIBrush, kThemeBrushSecondaryHighlightColor, NULL, 0, NULL }, +{"ButtonFrame", HIBrush, kThemeBrushButtonFrameActive, NULL, 0, NULL }, +{"AlternatePrimaryHighlightColor", HIBrush, kThemeBrushAlternatePrimaryHighlightColor, NULL, 0, NULL }, +{"WindowBody", HIBrush, kThemeBrushDocumentWindowBackground, NULL, 0, NULL }, +{"SheetBackground", HIBrush, kThemeBrushSheetBackground, NULL, 0, NULL }, +{"MenuActive", HIBrush, kThemeBrushMenuBackgroundSelected, NULL, 0, NULL }, +{"Menu", HIBrush, kThemeBrushMenuBackground, NULL, 0, NULL }, +{"DialogBackgroundInactive", HIBrush, kThemeBrushDialogBackgroundInactive, NULL, 0, NULL }, +{"DialogBackgroundActive", HIBrush, kThemeBrushDialogBackgroundActive, NULL, 0, NULL }, +{"AlertBackgroundActive", HIBrush, kThemeBrushAlertBackgroundActive, NULL, 0, NULL }, +{"AlertBackgroundInactive", HIBrush, kThemeBrushAlertBackgroundInactive, NULL, 0, NULL }, +{"ModelessDialogBackgroundActive", HIBrush, kThemeBrushModelessDialogBackgroundActive, NULL, 0, NULL }, +{"ModelessDialogBackgroundInactive", HIBrush, kThemeBrushModelessDialogBackgroundInactive, NULL, 0, NULL }, +{"UtilityWindowBackgroundActive", HIBrush, kThemeBrushUtilityWindowBackgroundActive, NULL, 0, NULL }, +{"UtilityWindowBackgroundInactive", HIBrush, kThemeBrushUtilityWindowBackgroundInactive, NULL, 0, NULL }, +{"ListViewSortColumnBackground", HIBrush, kThemeBrushListViewSortColumnBackground, NULL, 0, NULL }, +{"ListViewBackground", HIBrush, kThemeBrushListViewBackground, NULL, 0, NULL }, +{"IconLabelBackground", HIBrush, kThemeBrushIconLabelBackground, NULL, 0, NULL }, +{"ListViewSeparator", HIBrush, kThemeBrushListViewSeparator, NULL, 0, NULL }, +{"ChasingArrows", HIBrush, kThemeBrushChasingArrows, NULL, 0, NULL }, +{"DragHilite", HIBrush, kThemeBrushDragHilite, NULL, 0, NULL }, +{"DocumentWindowBackground", HIBrush, kThemeBrushDocumentWindowBackground, NULL, 0, NULL }, +{"FinderWindowBackground", HIBrush, kThemeBrushFinderWindowBackground, NULL, 0, NULL }, +{"ScrollBarDelimiterActive", HIBrush, kThemeBrushScrollBarDelimiterActive, NULL, 0, NULL }, +{"ScrollBarDelimiterInactive", HIBrush, kThemeBrushScrollBarDelimiterInactive, NULL, 0, NULL }, +{"FocusHighlight", HIBrush, kThemeBrushFocusHighlight, NULL, 0, NULL }, +{"PopupArrowActive", HIBrush, kThemeBrushPopupArrowActive, NULL, 0, NULL }, +{"PopupArrowPressed", HIBrush, kThemeBrushPopupArrowPressed, NULL, 0, NULL }, +{"PopupArrowInactive", HIBrush, kThemeBrushPopupArrowInactive, NULL, 0, NULL }, +{"AppleGuideCoachmark", HIBrush, kThemeBrushAppleGuideCoachmark, NULL, 0, NULL }, +{"IconLabelBackgroundSelected", HIBrush, kThemeBrushIconLabelBackgroundSelected, NULL, 0, NULL }, +{"StaticAreaFill", HIBrush, kThemeBrushStaticAreaFill, NULL, 0, NULL }, +{"ActiveAreaFill", HIBrush, kThemeBrushActiveAreaFill, NULL, 0, NULL }, +{"ButtonFrameActive", HIBrush, kThemeBrushButtonFrameActive, NULL, 0, NULL }, +{"ButtonFrameInactive", HIBrush, kThemeBrushButtonFrameInactive, NULL, 0, NULL }, +{"ButtonFaceActive", HIBrush, kThemeBrushButtonFaceActive, NULL, 0, NULL }, +{"ButtonFaceInactive", HIBrush, kThemeBrushButtonFaceInactive, NULL, 0, NULL }, +{"ButtonFacePressed", HIBrush, kThemeBrushButtonFacePressed, NULL, 0, NULL }, +{"ButtonActiveDarkShadow", HIBrush, kThemeBrushButtonActiveDarkShadow, NULL, 0, NULL }, +{"ButtonActiveDarkHighlight", HIBrush, kThemeBrushButtonActiveDarkHighlight, NULL, 0, NULL }, +{"ButtonActiveLightShadow", HIBrush, kThemeBrushButtonActiveLightShadow, NULL, 0, NULL }, +{"ButtonActiveLightHighlight", HIBrush, kThemeBrushButtonActiveLightHighlight, NULL, 0, NULL }, +{"ButtonInactiveDarkShadow", HIBrush, kThemeBrushButtonInactiveDarkShadow, NULL, 0, NULL }, +{"ButtonInactiveDarkHighlight", HIBrush, kThemeBrushButtonInactiveDarkHighlight, NULL, 0, NULL }, +{"ButtonInactiveLightShadow", HIBrush, kThemeBrushButtonInactiveLightShadow, NULL, 0, NULL }, +{"ButtonInactiveLightHighlight", HIBrush, kThemeBrushButtonInactiveLightHighlight, NULL, 0, NULL }, +{"ButtonPressedDarkShadow", HIBrush, kThemeBrushButtonPressedDarkShadow, NULL, 0, NULL }, +{"ButtonPressedDarkHighlight", HIBrush, kThemeBrushButtonPressedDarkHighlight, NULL, 0, NULL }, +{"ButtonPressedLightShadow", HIBrush, kThemeBrushButtonPressedLightShadow, NULL, 0, NULL }, +{"ButtonPressedLightHighlight", HIBrush, kThemeBrushButtonPressedLightHighlight, NULL, 0, NULL }, +{"BevelActiveLight", HIBrush, kThemeBrushBevelActiveLight, NULL, 0, NULL }, +{"BevelActiveDark", HIBrush, kThemeBrushBevelActiveDark, NULL, 0, NULL }, +{"BevelInactiveLight", HIBrush, kThemeBrushBevelInactiveLight, NULL, 0, NULL }, +{"BevelInactiveDark", HIBrush, kThemeBrushBevelInactiveDark, NULL, 0, NULL }, +{"NotificationWindowBackground", HIBrush, kThemeBrushNotificationWindowBackground, NULL, 0, NULL }, +{"MovableModalBackground", HIBrush, kThemeBrushMovableModalBackground, NULL, 0, NULL }, +{"SheetBackgroundOpaque", HIBrush, kThemeBrushSheetBackgroundOpaque, NULL, 0, NULL }, +{"DrawerBackground", HIBrush, kThemeBrushDrawerBackground, NULL, 0, NULL }, +{"ToolbarBackground", HIBrush, kThemeBrushToolbarBackground, NULL, 0, NULL }, +{"SheetBackgroundTransparent", HIBrush, kThemeBrushSheetBackgroundTransparent, NULL, 0, NULL }, +{"MenuBackground", HIBrush, kThemeBrushMenuBackground, NULL, 0, NULL }, +{"MenuBackgroundSelected", HIBrush, kThemeBrushMenuBackgroundSelected, NULL, 0, NULL }, +{"ListViewOddRowBackground", HIBrush, kThemeBrushListViewOddRowBackground, NULL, 0, NULL }, +{"ListViewEvenRowBackground", HIBrush, kThemeBrushListViewEvenRowBackground, NULL, 0, NULL }, +{"ListViewColumnDivider", HIBrush, kThemeBrushListViewColumnDivider, NULL, 0, NULL }, -{"ButtonText", HIText, kThemeTextColorPushButtonActive }, -{"MenuActiveText", HIText, kThemeTextColorMenuItemSelected }, -{"MenuDisabled", HIText, kThemeTextColorMenuItemDisabled }, -{"MenuText", HIText, kThemeTextColorMenuItemActive }, -{"BlackText", HIText, kThemeTextColorBlack }, -{"DialogActiveText", HIText, kThemeTextColorDialogActive }, -{"DialogInactiveText", HIText, kThemeTextColorDialogInactive }, -{"AlertActiveText", HIText, kThemeTextColorAlertActive }, -{"AlertInactiveText", HIText, kThemeTextColorAlertInactive }, -{"ModelessDialogActiveText", HIText, kThemeTextColorModelessDialogActive }, -{"ModelessDialogInactiveText", HIText, kThemeTextColorModelessDialogInactive }, -{"WindowHeaderActiveText", HIText, kThemeTextColorWindowHeaderActive }, -{"WindowHeaderInactiveText", HIText, kThemeTextColorWindowHeaderInactive }, -{"PlacardActiveText", HIText, kThemeTextColorPlacardActive }, -{"PlacardInactiveText", HIText, kThemeTextColorPlacardInactive }, -{"PlacardPressedText", HIText, kThemeTextColorPlacardPressed }, -{"PushButtonActiveText", HIText, kThemeTextColorPushButtonActive }, -{"PushButtonInactiveText", HIText, kThemeTextColorPushButtonInactive }, -{"PushButtonPressedText", HIText, kThemeTextColorPushButtonPressed }, -{"BevelButtonActiveText", HIText, kThemeTextColorBevelButtonActive }, -{"BevelButtonInactiveText", HIText, kThemeTextColorBevelButtonInactive }, -{"BevelButtonPressedText", HIText, kThemeTextColorBevelButtonPressed }, -{"PopupButtonActiveText", HIText, kThemeTextColorPopupButtonActive }, -{"PopupButtonInactiveText", HIText, kThemeTextColorPopupButtonInactive }, -{"PopupButtonPressedText", HIText, kThemeTextColorPopupButtonPressed }, -{"IconLabelText", HIText, kThemeTextColorIconLabel }, -{"ListViewText", HIText, kThemeTextColorListView }, -{"DocumentWindowTitleActiveText", HIText, kThemeTextColorDocumentWindowTitleActive }, -{"DocumentWindowTitleInactiveText", HIText, kThemeTextColorDocumentWindowTitleInactive }, -{"MovableModalWindowTitleActiveText", HIText, kThemeTextColorMovableModalWindowTitleActive }, -{"MovableModalWindowTitleInactiveText", HIText, kThemeTextColorMovableModalWindowTitleInactive }, -{"UtilityWindowTitleActiveText", HIText, kThemeTextColorUtilityWindowTitleActive }, -{"UtilityWindowTitleInactiveText", HIText, kThemeTextColorUtilityWindowTitleInactive }, -{"PopupWindowTitleActiveText", HIText, kThemeTextColorPopupWindowTitleActive }, -{"PopupWindowTitleInactiveText", HIText, kThemeTextColorPopupWindowTitleInactive }, -{"RootMenuActiveText", HIText, kThemeTextColorRootMenuActive }, -{"RootMenuSelectedText", HIText, kThemeTextColorRootMenuSelected }, -{"RootMenuDisabledText", HIText, kThemeTextColorRootMenuDisabled }, -{"MenuItemActiveText", HIText, kThemeTextColorMenuItemActive }, -{"MenuItemSelectedText", HIText, kThemeTextColorMenuItemSelected }, -{"MenuItemDisabledText", HIText, kThemeTextColorMenuItemDisabled }, -{"PopupLabelActiveText", HIText, kThemeTextColorPopupLabelActive }, -{"PopupLabelInactiveText", HIText, kThemeTextColorPopupLabelInactive }, -{"TabFrontActiveText", HIText, kThemeTextColorTabFrontActive }, -{"TabNonFrontActiveText", HIText, kThemeTextColorTabNonFrontActive }, -{"TabNonFrontPressedText", HIText, kThemeTextColorTabNonFrontPressed }, -{"TabFrontInactiveText", HIText, kThemeTextColorTabFrontInactive }, -{"TabNonFrontInactiveText", HIText, kThemeTextColorTabNonFrontInactive }, -{"IconLabelSelectedText", HIText, kThemeTextColorIconLabelSelected }, -{"BevelButtonStickyActiveText", HIText, kThemeTextColorBevelButtonStickyActive }, -{"BevelButtonStickyInactiveText", HIText, kThemeTextColorBevelButtonStickyInactive }, -{"NotificationText", HIText, kThemeTextColorNotification }, -{"SystemDetailText", HIText, kThemeTextColorSystemDetail }, -{"PlacardBackground", HIBackground, kThemeBackgroundPlacard }, -{"WindowHeaderBackground", HIBackground, kThemeBackgroundWindowHeader }, -{"ListViewWindowHeaderBackground", HIBackground, kThemeBackgroundListViewWindowHeader }, -{"MetalBackground", HIBackground, kThemeBackgroundMetal }, +{"ButtonText", HIText, kThemeTextColorPushButtonActive, NULL, 0, NULL }, +{"MenuActiveText", HIText, kThemeTextColorMenuItemSelected, NULL, 0, NULL }, +{"MenuDisabled", HIText, kThemeTextColorMenuItemDisabled, NULL, 0, NULL }, +{"MenuText", HIText, kThemeTextColorMenuItemActive, NULL, 0, NULL }, +{"BlackText", HIText, kThemeTextColorBlack, NULL, 0, NULL }, +{"DialogActiveText", HIText, kThemeTextColorDialogActive, NULL, 0, NULL }, +{"DialogInactiveText", HIText, kThemeTextColorDialogInactive, NULL, 0, NULL }, +{"AlertActiveText", HIText, kThemeTextColorAlertActive, NULL, 0, NULL }, +{"AlertInactiveText", HIText, kThemeTextColorAlertInactive, NULL, 0, NULL }, +{"ModelessDialogActiveText", HIText, kThemeTextColorModelessDialogActive, NULL, 0, NULL }, +{"ModelessDialogInactiveText", HIText, kThemeTextColorModelessDialogInactive, NULL, 0, NULL }, +{"WindowHeaderActiveText", HIText, kThemeTextColorWindowHeaderActive, NULL, 0, NULL }, +{"WindowHeaderInactiveText", HIText, kThemeTextColorWindowHeaderInactive, NULL, 0, NULL }, +{"PlacardActiveText", HIText, kThemeTextColorPlacardActive, NULL, 0, NULL }, +{"PlacardInactiveText", HIText, kThemeTextColorPlacardInactive, NULL, 0, NULL }, +{"PlacardPressedText", HIText, kThemeTextColorPlacardPressed, NULL, 0, NULL }, +{"PushButtonActiveText", HIText, kThemeTextColorPushButtonActive, NULL, 0, NULL }, +{"PushButtonInactiveText", HIText, kThemeTextColorPushButtonInactive, NULL, 0, NULL }, +{"PushButtonPressedText", HIText, kThemeTextColorPushButtonPressed, NULL, 0, NULL }, +{"BevelButtonActiveText", HIText, kThemeTextColorBevelButtonActive, NULL, 0, NULL }, +{"BevelButtonInactiveText", HIText, kThemeTextColorBevelButtonInactive, NULL, 0, NULL }, +{"BevelButtonPressedText", HIText, kThemeTextColorBevelButtonPressed, NULL, 0, NULL }, +{"PopupButtonActiveText", HIText, kThemeTextColorPopupButtonActive, NULL, 0, NULL }, +{"PopupButtonInactiveText", HIText, kThemeTextColorPopupButtonInactive, NULL, 0, NULL }, +{"PopupButtonPressedText", HIText, kThemeTextColorPopupButtonPressed, NULL, 0, NULL }, +{"IconLabelText", HIText, kThemeTextColorIconLabel, NULL, 0, NULL }, +{"ListViewText", HIText, kThemeTextColorListView, NULL, 0, NULL }, +{"DocumentWindowTitleActiveText", HIText, kThemeTextColorDocumentWindowTitleActive, NULL, 0, NULL }, +{"DocumentWindowTitleInactiveText", HIText, kThemeTextColorDocumentWindowTitleInactive, NULL, 0, NULL }, +{"MovableModalWindowTitleActiveText", HIText, kThemeTextColorMovableModalWindowTitleActive, NULL, 0, NULL }, +{"MovableModalWindowTitleInactiveText", HIText, kThemeTextColorMovableModalWindowTitleInactive, NULL, 0, NULL }, +{"UtilityWindowTitleActiveText", HIText, kThemeTextColorUtilityWindowTitleActive, NULL, 0, NULL }, +{"UtilityWindowTitleInactiveText", HIText, kThemeTextColorUtilityWindowTitleInactive, NULL, 0, NULL }, +{"PopupWindowTitleActiveText", HIText, kThemeTextColorPopupWindowTitleActive, NULL, 0, NULL }, +{"PopupWindowTitleInactiveText", HIText, kThemeTextColorPopupWindowTitleInactive, NULL, 0, NULL }, +{"RootMenuActiveText", HIText, kThemeTextColorRootMenuActive, NULL, 0, NULL }, +{"RootMenuSelectedText", HIText, kThemeTextColorRootMenuSelected, NULL, 0, NULL }, +{"RootMenuDisabledText", HIText, kThemeTextColorRootMenuDisabled, NULL, 0, NULL }, +{"MenuItemActiveText", HIText, kThemeTextColorMenuItemActive, NULL, 0, NULL }, +{"MenuItemSelectedText", HIText, kThemeTextColorMenuItemSelected, NULL, 0, NULL }, +{"MenuItemDisabledText", HIText, kThemeTextColorMenuItemDisabled, NULL, 0, NULL }, +{"PopupLabelActiveText", HIText, kThemeTextColorPopupLabelActive, NULL, 0, NULL }, +{"PopupLabelInactiveText", HIText, kThemeTextColorPopupLabelInactive, NULL, 0, NULL }, +{"TabFrontActiveText", HIText, kThemeTextColorTabFrontActive, NULL, 0, NULL }, +{"TabNonFrontActiveText", HIText, kThemeTextColorTabNonFrontActive, NULL, 0, NULL }, +{"TabNonFrontPressedText", HIText, kThemeTextColorTabNonFrontPressed, NULL, 0, NULL }, +{"TabFrontInactiveText", HIText, kThemeTextColorTabFrontInactive, NULL, 0, NULL }, +{"TabNonFrontInactiveText", HIText, kThemeTextColorTabNonFrontInactive, NULL, 0, NULL }, +{"IconLabelSelectedText", HIText, kThemeTextColorIconLabelSelected, NULL, 0, NULL }, +{"BevelButtonStickyActiveText", HIText, kThemeTextColorBevelButtonStickyActive, NULL, 0, NULL }, +{"BevelButtonStickyInactiveText", HIText, kThemeTextColorBevelButtonStickyInactive, NULL, 0, NULL }, +{"NotificationText", HIText, kThemeTextColorNotification, NULL, 0, NULL }, +{"SystemDetailText", HIText, kThemeTextColorSystemDetail, NULL, 0, NULL }, +{"PlacardBackground", HIBackground, kThemeBackgroundPlacard, NULL, 0, NULL }, +{"WindowHeaderBackground", HIBackground, kThemeBackgroundWindowHeader, NULL, 0, NULL }, +{"ListViewWindowHeaderBackground", HIBackground, kThemeBackgroundListViewWindowHeader, NULL, 0, NULL }, +{"MetalBackground", HIBackground, kThemeBackgroundMetal, NULL, 0, NULL }, -{"SecondaryGroupBoxBackground", HIBackground, kThemeBackgroundSecondaryGroupBox }, -{"TabPaneBackground", HIBackground, kThemeBackgroundTabPane }, -{"WhiteText", HIText, kThemeTextColorWhite }, -{"Black", HIBrush, kThemeBrushBlack }, -{"White", HIBrush, kThemeBrushWhite }, +{"SecondaryGroupBoxBackground", HIBackground, kThemeBackgroundSecondaryGroupBox, NULL, 0, NULL }, +{"TabPaneBackground", HIBackground, kThemeBackgroundTabPane, NULL, 0, NULL }, +{"WhiteText", HIText, kThemeTextColorWhite, NULL, 0, NULL }, +{"Black", HIBrush, kThemeBrushBlack, NULL, 0, NULL }, +{"White", HIBrush, kThemeBrushWhite, NULL, 0, NULL }, /* * Dynamic Colors */ -{"WindowBackgroundColor", ttkBackground, 0 }, -{"WindowBackgroundColor1", ttkBackground, 1 }, -{"WindowBackgroundColor2", ttkBackground, 2 }, -{"WindowBackgroundColor3", ttkBackground, 3 }, -{"WindowBackgroundColor4", ttkBackground, 4 }, -{"WindowBackgroundColor5", ttkBackground, 5 }, -{"WindowBackgroundColor6", ttkBackground, 6 }, -{"WindowBackgroundColor7", ttkBackground, 7 }, +{"WindowBackgroundColor", ttkBackground, 0, NULL, 0, NULL }, +{"WindowBackgroundColor1", ttkBackground, 1, NULL, 0, NULL }, +{"WindowBackgroundColor2", ttkBackground, 2, NULL, 0, NULL }, +{"WindowBackgroundColor3", ttkBackground, 3, NULL, 0, NULL }, +{"WindowBackgroundColor4", ttkBackground, 4, NULL, 0, NULL }, +{"WindowBackgroundColor5", ttkBackground, 5, NULL, 0, NULL }, +{"WindowBackgroundColor6", ttkBackground, 6, NULL, 0, NULL }, +{"WindowBackgroundColor7", ttkBackground, 7, NULL, 0, NULL }, /* Apple's SecondaryLabelColor is the same as their LabelColor so we roll our own. */ -{"SecondaryLabelColor", ttkBackground, 14 }, +{"SecondaryLabelColor", ttkBackground, 14, NULL, 0, NULL }, -{"TextColor", semantic, 0, "textColor" }, -{"SelectedTextColor", semantic, 0, "selectedTextColor" }, -{"LabelColor", semantic, 0, "textColor"}, -{"LabelColor", semantic, 0, "labelColor"}, -{"ControlTextColor", semantic, 0, "controlTextColor" }, -{"DisabledControlTextColor", semantic, 0, "disabledControlTextColor" }, +{"TextColor", semantic, 0, "textColor", 0, NULL }, +{"SelectedTextColor", semantic, 0, "selectedTextColor", 0, NULL }, +{"LabelColor", semantic, 0, "textColor", 0, NULL }, +{"LabelColor", semantic, 0, "labelColor", 0, NULL }, +{"ControlTextColor", semantic, 0, "controlTextColor", 0, NULL }, +{"DisabledControlTextColor", semantic, 0, "disabledControlTextColor", 0, NULL }, #if MAC_OS_X_VERSION_MAX_ALLOWED > 1060 -{"SelectedTabTextColor", semantic, 0, "whiteColor" }, +{"SelectedTabTextColor", semantic, 0, "whiteColor", 0, NULL }, #else -{"SelectedTabTextColor", semantic, 0, "blackColor" }, +{"SelectedTabTextColor", semantic, 0, "blackColor", 0, NULL }, #endif -{"TextBackgroundColor", semantic, 0, "textBackgroundColor" }, -{"SelectedTextBackgroundColor", semantic, 0, "selectedTextBackgroundColor" }, -{"ControlAccentColor", semantic, 0, "controlAccentColor" }, -{"LinkColor", semantic, 0, "blueColor" }, -{"LinkColor", semantic, 0, "linkColor" }, -{"PlaceholderTextColor", semantic, 0, "grayColor" }, -{"PlaceholderTextColor", semantic, 0, "placeholderTextColor" }, -{"SeparatorColor", semantic, 0, "grayColor" }, -{"SeparatorColor", semantic, 0, "separatorColor" }, -{NULL, 0, 0 } +{"TextBackgroundColor", semantic, 0, "textBackgroundColor", 0, NULL }, +{"SelectedTextBackgroundColor", semantic, 0, "selectedTextBackgroundColor", 0, NULL }, +{"ControlAccentColor", semantic, 0, "controlAccentColor", 0, NULL }, +{"LinkColor", semantic, 0, "blueColor", 0, NULL }, +{"LinkColor", semantic, 0, "linkColor", 0, NULL }, +{"PlaceholderTextColor", semantic, 0, "grayColor", 0, NULL }, +{"PlaceholderTextColor", semantic, 0, "placeholderTextColor", 0, NULL }, +{"SeparatorColor", semantic, 0, "grayColor", 0, NULL }, +{"SeparatorColor", semantic, 0, "separatorColor", 0, NULL }, +{NULL, 0, 0, NULL, 0, NULL } }; #endif diff --git a/macosx/tkMacOSXMenu.c b/macosx/tkMacOSXMenu.c index dceb051..379e25c 100644 --- a/macosx/tkMacOSXMenu.c +++ b/macosx/tkMacOSXMenu.c @@ -124,7 +124,7 @@ static int ModifierCharWidth(Tk_Font tkfont); * the menu was posted. For example, opening a menu during the Rube Goldberg * demo would cause the animation to stop. This was also the case for * menubuttons. - * + * * The TKBackground object below works around this problem, and allows a Tk * event loop to run while a menu is open. It is a subclass of NSThread which * inserts requests to call [NSApp _runBackgroundLoop] onto the queue @@ -142,25 +142,25 @@ static int ModifierCharWidth(Tk_Font tkfont); NSArray *modeArray = [NSArray arrayWithObjects: NSEventTrackingRunLoopMode, nil]; while(1) { - + /* * Queue a request to process Tk events during event tracking. */ - - [NSApp performSelectorOnMainThread:@selector(_runBackgroundLoop) + + [NSApp performSelectorOnMainThread:@selector(_runBackgroundLoop) withObject:nil - waitUntilDone:true + waitUntilDone:true modes:modeArray]; if (self.cancelled) { [NSThread exit]; } - + /* * Allow the tracked events to be processed too. */ [NSThread sleepForTimeInterval:0.001]; - } + } } @end diff --git a/macosx/tkMacOSXXStubs.c b/macosx/tkMacOSXXStubs.c index dc9ea32..e183ca7 100644 --- a/macosx/tkMacOSXXStubs.c +++ b/macosx/tkMacOSXXStubs.c @@ -201,8 +201,8 @@ TkpOpenDisplay( } } - display = ckalloc(sizeof(Display)); - screen = ckalloc(sizeof(Screen)); + display = (Display *)ckalloc(sizeof(Display)); + screen = (Screen *)ckalloc(sizeof(Screen)); bzero(display, sizeof(Display)); bzero(screen, sizeof(Screen)); @@ -254,7 +254,7 @@ TkpOpenDisplay( screen->white_pixel = 0x00FFFFFF; screen->ext_data = (XExtData *) &maxBounds; - screen->root_visual = ckalloc(sizeof(Visual)); + screen->root_visual = (Visual *)ckalloc(sizeof(Visual)); screen->root_visual->visualid = 0; screen->root_visual->c_class = TrueColor; screen->root_visual->red_mask = 0x00FF0000; @@ -269,7 +269,7 @@ TkpOpenDisplay( TkMacOSXDisplayChanged(display); - gMacDisplay = ckalloc(sizeof(TkDisplay)); + gMacDisplay = (TkDisplay *)ckalloc(sizeof(TkDisplay)); /* * This is the quickest way to make sure that all the *Init flags get @@ -387,7 +387,7 @@ TkClipCleanup( static XID MacXIdAlloc( - Display *display) /* Display for which to allocate. */ + TCL_UNUSED(Display *)) /* Display for which to allocate. */ { static long int cur_id = 100; /* @@ -417,8 +417,8 @@ MacXIdAlloc( static int DefaultErrorHandler( - Display* display, - XErrorEvent* err_evt) + TCL_UNUSED(Display *), + TCL_UNUSED(XErrorEvent *)) { /* * This call should never be called. Tk replaces it with its own error @@ -431,8 +431,8 @@ DefaultErrorHandler( char * XGetAtomName( - Display * display, - Atom atom) + Display *display, + TCL_UNUSED(Atom)) { display->request++; return NULL; @@ -440,7 +440,7 @@ XGetAtomName( XErrorHandler XSetErrorHandler( - XErrorHandler handler) + TCL_UNUSED(XErrorHandler)) { return DefaultErrorHandler; } @@ -448,7 +448,7 @@ XSetErrorHandler( Window XRootWindow( Display *display, - int screen_number) + TCL_UNUSED(int)) { display->request++; return ROOT_ID; @@ -491,14 +491,14 @@ XGetGeometry( int XChangeProperty( - Display* display, - Window w, - Atom property, - Atom type, - int format, - int mode, - _Xconst unsigned char* data, - int nelements) + TCL_UNUSED(Display *), + TCL_UNUSED(Window), + TCL_UNUSED(Atom), + TCL_UNUSED(Atom), + TCL_UNUSED(int), + TCL_UNUSED(int), + TCL_UNUSED(_Xconst unsigned char *), + TCL_UNUSED(int)) { Debugger(); return Success; @@ -506,9 +506,9 @@ XChangeProperty( int XSelectInput( - Display* display, - Window w, - long event_mask) + TCL_UNUSED(Display *), + TCL_UNUSED(Window), + TCL_UNUSED(long)) { Debugger(); return Success; @@ -516,40 +516,16 @@ XSelectInput( int XBell( - Display* display, - int percent) + TCL_UNUSED(Display *), + TCL_UNUSED(int)) { NSBeep(); return Success; } -#if 0 -void -XSetWMNormalHints( - Display* display, - Window w, - XSizeHints* hints) -{ - /* - * Do nothing. Shouldn't even be called. - */ -} - -XSizeHints * -XAllocSizeHints(void) -{ - /* - * Always return NULL. Tk code checks to see if NULL is returned & does - * nothing if it is. - */ - - return NULL; -} -#endif - GContext XGContextFromGC( - GC gc) + TCL_UNUSED(GC)) { /* * TODO: currently a no-op @@ -560,11 +536,11 @@ XGContextFromGC( Status XSendEvent( - Display* display, - Window w, - Bool propagate, - long event_mask, - XEvent* event_send) + TCL_UNUSED(Display *), + TCL_UNUSED(Window), + TCL_UNUSED(Bool), + TCL_UNUSED(long), + TCL_UNUSED(XEvent *)) { Debugger(); return 0; @@ -572,56 +548,31 @@ XSendEvent( int XClearWindow( - Display* display, - Window w) -{ - return Success; -} - -/* -int -XDrawPoint( - Display* display, - Drawable d, - GC gc, - int x, - int y) -{ - return Success; -} - -int -XDrawPoints( - Display* display, - Drawable d, - GC gc, - XPoint* points, - int npoints, - int mode) + TCL_UNUSED(Display *), + TCL_UNUSED(Window)) { return Success; } -*/ int XWarpPointer( - Display* display, - Window src_w, - Window dest_w, - int src_x, - int src_y, - unsigned int src_width, - unsigned int src_height, - int dest_x, - int dest_y) + TCL_UNUSED(Display *), + TCL_UNUSED(Window), + TCL_UNUSED(Window), + TCL_UNUSED(int), + TCL_UNUSED(int), + TCL_UNUSED(unsigned int), + TCL_UNUSED(unsigned int), + TCL_UNUSED(int), + TCL_UNUSED(int)) { return Success; } int XQueryColor( - Display* display, - Colormap colormap, + TCL_UNUSED(Display *), + TCL_UNUSED(Colormap), XColor* def_in_out) { unsigned long p; @@ -642,8 +593,8 @@ XQueryColor( int XQueryColors( - Display* display, - Colormap colormap, + TCL_UNUSED(Display *), + TCL_UNUSED(Colormap), XColor* defs_in_out, int ncolors) { @@ -667,14 +618,13 @@ XQueryColors( } int -XQueryTree(display, w, root_return, parent_return, children_return, - nchildren_return) - Display* display; - Window w; - Window* root_return; - Window* parent_return; - Window** children_return; - unsigned int* nchildren_return; +XQueryTree( + TCL_UNUSED(Display *), + TCL_UNUSED(Window), + TCL_UNUSED(Window *), + TCL_UNUSED(Window *), + TCL_UNUSED(Window **), + TCL_UNUSED(unsigned int *)) { return 0; } @@ -683,17 +633,17 @@ XQueryTree(display, w, root_return, parent_return, children_return, int XGetWindowProperty( Display *display, - Window w, - Atom property, - long long_offset, - long long_length, - Bool delete, - Atom req_type, + TCL_UNUSED(Window), + TCL_UNUSED(Atom), + TCL_UNUSED(long), + TCL_UNUSED(long), + TCL_UNUSED(Bool), + TCL_UNUSED(Atom), Atom *actual_type_return, int *actual_format_return, unsigned long *nitems_return, unsigned long *bytes_after_return, - unsigned char ** prop_return) + TCL_UNUSED(unsigned char **)) { display->request++; *actual_type_return = None; @@ -704,7 +654,7 @@ XGetWindowProperty( int XRefreshKeyboardMapping( - XMappingEvent *x) + TCL_UNUSED(XMappingEvent *)) { /* used by tkXEvent.c */ Debugger(); @@ -714,8 +664,8 @@ XRefreshKeyboardMapping( int XSetIconName( Display* display, - Window w, - const char *icon_name) + TCL_UNUSED(Window), + TCL_UNUSED(const char *)) { /* * This is a no-op, no icon name for Macs. @@ -727,7 +677,7 @@ XSetIconName( int XForceScreenSaver( Display* display, - int mode) + TCL_UNUSED(int)) { /* * This function is just a no-op. It is defined to reset the screen saver. @@ -741,8 +691,8 @@ XForceScreenSaver( void Tk_FreeXId( - Display *display, - XID xid) + TCL_UNUSED(Display *), + TCL_UNUSED(XID)) { /* no-op function needed for stubs implementation. */ } @@ -750,7 +700,7 @@ Tk_FreeXId( int XSync( Display *display, - Bool discard) + TCL_UNUSED(Bool)) { /* * The main use of XSync is by the update command, which alternates @@ -768,33 +718,6 @@ XSync( return 0; } -#if 0 -int -XSetClipRectangles( - Display *d, - GC gc, - int clip_x_origin, - int clip_y_origin, - XRectangle* rectangles, - int n, - int ordering) -{ - TkRegion clipRgn = TkCreateRegion(); - - while (n--) { - XRectangle rect = *rectangles; - - rect.x += clip_x_origin; - rect.y += clip_y_origin; - TkUnionRectWithRegion(&rect, clipRgn, clipRgn); - rectangles++; - } - TkSetRegion(d, gc, clipRgn); - TkDestroyRegion(clipRgn); - return 1; -} -#endif - /* *---------------------------------------------------------------------- * @@ -853,64 +776,64 @@ TkGetServerInfo( int XChangeWindowAttributes( - Display *display, - Window w, - unsigned long value_mask, - XSetWindowAttributes *attributes) + TCL_UNUSED(Display *), + TCL_UNUSED(Window), + TCL_UNUSED(unsigned long), + TCL_UNUSED(XSetWindowAttributes *)) { return Success; } int XSetWindowBackground( - Display *display, - Window window, - unsigned long value) + TCL_UNUSED(Display *), + TCL_UNUSED(Window), + TCL_UNUSED(unsigned long)) { return Success; } int XSetWindowBackgroundPixmap( - Display *display, - Window w, - Pixmap background_pixmap) + TCL_UNUSED(Display *), + TCL_UNUSED(Window), + TCL_UNUSED(Pixmap)) { return Success; } int XSetWindowBorder( - Display *display, - Window w, - unsigned long border_pixel) + TCL_UNUSED(Display *), + TCL_UNUSED(Window), + TCL_UNUSED(unsigned long)) { return Success; } int XSetWindowBorderPixmap( - Display *display, - Window w, - Pixmap border_pixmap) + TCL_UNUSED(Display *), + TCL_UNUSED(Window), + TCL_UNUSED(Pixmap)) { return Success; } int XSetWindowBorderWidth( - Display *display, - Window w, - unsigned int width) + TCL_UNUSED(Display *), + TCL_UNUSED(Window), + TCL_UNUSED(unsigned int)) { return Success; } int XSetWindowColormap( - Display *display, - Window w, - Colormap colormap) + TCL_UNUSED(Display *), + TCL_UNUSED(Window), + TCL_UNUSED(Colormap)) { Debugger(); return Success; @@ -918,25 +841,25 @@ XSetWindowColormap( Status XStringListToTextProperty( - char **list, - int count, - XTextProperty *text_prop_return) + TCL_UNUSED(char **), + TCL_UNUSED(int), + TCL_UNUSED(XTextProperty *)) { Debugger(); - return (Status) 0; + return Success; } void XSetWMClientMachine( - Display *display, - Window w, - XTextProperty *text_prop) + TCL_UNUSED(Display *), + TCL_UNUSED(Window), + TCL_UNUSED(XTextProperty *)) { Debugger(); } XIC -XCreateIC(XIM xim, ...) +XCreateIC(TCL_UNUSED(XIM), ...) { Debugger(); return (XIC) 0; @@ -954,7 +877,7 @@ XVisualIDFromVisual( XAfterFunction XSynchronize( Display *display, - Bool onoff) + TCL_UNUSED(Bool)) { display->request++; return NULL; @@ -963,7 +886,7 @@ XSynchronize( #undef XUngrabServer int XUngrabServer( - Display *display) + TCL_UNUSED(Display *)) { return 0; } @@ -980,7 +903,7 @@ XNoOp( #undef XGrabServer int XGrabServer( - Display *display) + TCL_UNUSED(Display *)) { return 0; } @@ -998,7 +921,7 @@ XFree( #undef XFlush int XFlush( - Display *display) + TCL_UNUSED(Display *)) { return 0; } @@ -1022,7 +945,7 @@ XFlush( const char * TkGetDefaultScreenName( - Tcl_Interp *interp, /* Not used. */ + TCL_UNUSED(Tcl_Interp *), const char *screenName) /* If NULL, use default string. */ { if ((screenName == NULL) || (screenName[0] == '\0')) { @@ -1049,7 +972,7 @@ TkGetDefaultScreenName( long Tk_GetUserInactiveTime( - Display *dpy) + TCL_UNUSED(Display *)) { io_registry_entry_t regEntry; CFMutableDictionaryRef props = NULL; @@ -1115,7 +1038,7 @@ Tk_GetUserInactiveTime( void Tk_ResetUserInactiveTime( - Display *dpy) + TCL_UNUSED(Display *)) { lastInactivityReset = TkpGetMS(); } -- cgit v0.12 From 7510073a3db80f1dd4261ad1f602d4fc719efdb8 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Tue, 4 Aug 2020 14:26:50 +0000 Subject: Minor doc fixes --- doc/GetScroll.3 | 4 ++-- doc/SetOptions.3 | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/doc/GetScroll.3 b/doc/GetScroll.3 index a71986d..2615301 100644 --- a/doc/GetScroll.3 +++ b/doc/GetScroll.3 @@ -25,13 +25,13 @@ int Interpreter to use for error reporting. .AP int objc in Number of Tcl_Obj's in \fIobjv\fR array. -.AP "Tcl_Obj *const" objv[] in +.AP "Tcl_Obj *const *" objv in Argument objects. These represent the entire widget command, of which the first word is typically the widget name and the second word is typically \fBxview\fR or \fByview\fR. .AP int argc in Number of strings in \fIargv\fR array. -.AP "const char" *argv[] in +.AP "const char **" argv in Argument strings. These represent the entire widget command, of which the first word is typically the widget name and the second word is typically \fBxview\fR or \fByview\fR. diff --git a/doc/SetOptions.3 b/doc/SetOptions.3 index ae6e353..2a37de7 100644 --- a/doc/SetOptions.3 +++ b/doc/SetOptions.3 @@ -63,7 +63,7 @@ no window-dependent options, then a NULL value may be supplied for this argument. .AP int objc in Number of values in \fIobjv\fR. -.AP Tcl_Obj "*const objv[]" in +.AP Tcl_Obj "*const *objv" in Command-line arguments for setting configuring options. .AP Tk_SavedOptions *savePtr out If not NULL, the structure pointed to by this argument is filled -- cgit v0.12 From 449cabad4759a1b39036c3ac365942bb60b6a06a Mon Sep 17 00:00:00 2001 From: culler Date: Tue, 4 Aug 2020 15:30:04 +0000 Subject: Update color documentation. --- doc/colors.n | 33 ++++++++++++++++----------------- 1 file changed, 16 insertions(+), 17 deletions(-) diff --git a/doc/colors.n b/doc/colors.n index c1609b9..847dbaa 100644 --- a/doc/colors.n +++ b/doc/colors.n @@ -784,10 +784,11 @@ YellowGreen 154 205 50 .TP \fBMac OS X\fR . -On macOS, the following additional system colors are available. -This first group contains all colors available in the HIToolbox library. -(Note that in some cases the actual color values may depend on the -current Appearance.) +On macOS, the following additional system colors are available. This +first group contains all of the HIBrush colors available in the +HIToolbox library. Note that on macOS 10.14 (Mojave) and later these +colors are unlikely to match the color actually used for the purpose +suggested by the color name. .RS .DS systemActiveAreaFill @@ -928,27 +929,25 @@ systemWindowHeaderInactiveText .DE .RE . -The second group of MacOS colors below are based on Apple's "semantic" -NScolors. On OSX 10.14 (Mojave) and later these colors change value -when Dark Mode is enabled. However, the change is only observable -when the Apple window manager is drawing to the screen. So the -\fBwinfo rgb\fR command will return the color coordinates used in the -standard Aqua mode, even if Dark Mode has been selected in the system -preferences. The numbered systemWindowBackgroundColors are used in -the \fBttk::notebook\fR and \fBttk::labelframe\fR widgets to provide a -contrasting background. Each numbered color constrasts with its -predecessor. +The group of MacOS colors below are based on Apple's "semantic" +NSColors. On OSX 10.14 (Mojave) and later these colors change value +when Dark Mode is enabled. The numbered systemWindowBackgroundColors +are used in the \fBttk::notebook\fR and \fBttk::labelframe\fR widgets +to provide a contrasting background. Each numbered color constrasts +with its predecessor. .RS .DS systemControlAccentColor systemControlTextColor systemDisabledControlTextColor -systemLabelColor +systemLabelColor systemLinkColor -systemSelectedTextBackgroundColor +systemPlaceholderTextColor +systemSelectedTextBackgroundColor systemSelectedTextColor +systemSeparatorColor systemTextBackgroundColor -systemTextColor +systemTextColor systemWindowBackgroundColor systemWindowBackgroundColor1 systemWindowBackgroundColor2 -- cgit v0.12 From da9d597e856d8e25317f1a831f0acdcae3b012b5 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Tue, 4 Aug 2020 21:34:11 +0000 Subject: Rename references to CrtSlave -> CrtAlias. Some more slave -> child changes not affecting the API --- doc/loadTk.n | 14 +- doc/selection.n | 2 +- generic/tkConsole.c | 4 +- generic/tkWindow.c | 32 ++-- library/demos/dialog1.tcl | 14 +- library/safetk.tcl | 80 ++++----- macosx/Tk.xcode/project.pbxproj | 4 +- macosx/Tk.xcodeproj/project.pbxproj | 4 +- tests/constraints.tcl | 2 +- tests/safe.test | 2 +- tests/safePrimarySelection.test | 328 ++++++++++++++++++------------------ 11 files changed, 243 insertions(+), 243 deletions(-) diff --git a/doc/loadTk.n b/doc/loadTk.n index 3673e98..e1c93c8 100644 --- a/doc/loadTk.n +++ b/doc/loadTk.n @@ -11,7 +11,7 @@ .SH NAME safe::loadTk \- Load Tk into a safe interpreter. .SH SYNOPSIS -\fBsafe::loadTk \fIslave\fR ?\fB\-use\fR \fIwindowId\fR? ?\fB\-display\fR \fIdisplayName\fR? +\fBsafe::loadTk \fIchild\fR ?\fB\-use\fR \fIwindowId\fR? ?\fB\-display\fR \fIdisplayName\fR? .BE .SH DESCRIPTION .PP @@ -43,13 +43,13 @@ the \fBSECURITY ISSUES\fR section below for implementation details. Please read the \fBsafe\fR manual page for Tcl to learn about the basic security considerations for Safe Tcl. .PP -\fBsafe::loadTk\fR adds the value of \fBtk_library\fR taken from the master +\fBsafe::loadTk\fR adds the value of \fBtk_library\fR taken from the parent interpreter to the virtual access path of the safe interpreter so that auto-loading will work in the safe interpreter. .PP -Tk initialization is now safe with respect to not trusting the slave's state -for startup. \fBsafe::loadTk\fR registers the slave's name so when the Tk -initialization (\fBTk_SafeInit\fR) is called and in turn calls the master's +Tk initialization is now safe with respect to not trusting the child's state +for startup. \fBsafe::loadTk\fR registers the child's name so when the Tk +initialization (\fBTk_SafeInit\fR) is called and in turn calls the parent's \fBsafe::InitTk\fR it will return the desired \fBargv\fR equivalent (\fB\-use\fR \fIwindowId\fR, correct \fB\-display\fR, etc.) .PP @@ -62,8 +62,8 @@ fatal X error. .SH "SEE ALSO" safe(n), interp(n), library(n), load(n), package(n), source(n), unknown(n) .SH KEYWORDS -alias, auto-loading, auto_mkindex, load, master interpreter, safe -interpreter, slave interpreter, source +alias, auto-loading, auto_mkindex, load, parent interpreter, safe +interpreter, child interpreter, source '\" Local Variables: '\" mode: nroff '\" End: diff --git a/doc/selection.n b/doc/selection.n index ec678fa..6fc23a5 100644 --- a/doc/selection.n +++ b/doc/selection.n @@ -150,7 +150,7 @@ A GUI event, for example \fB<>\fR, can copy the \fBPRIMARY\fR se .PP On X11, the \fBPRIMARY\fR selection is a system-wide feature of the X server, allowing communication between different processes that are X11 clients. .PP -On Windows, the \fBPRIMARY\fR selection is not provided by the system, but only by Tk, and so it is shared only between windows of a master interpreter and its unsafe slave interpreters. It is not shared between interpreters in different processes or different threads. Each master interpreter has a separate \fBPRIMARY\fR selection that is shared only with its unsafe slaves. +On Windows, the \fBPRIMARY\fR selection is not provided by the system, but only by Tk, and so it is shared only between windows of a parent interpreter and its unsafe child interpreters. It is not shared between interpreters in different processes or different threads. Each parent interpreter has a separate \fBPRIMARY\fR selection that is shared only with its unsafe slaves. .PP .SH SECURITY .PP diff --git a/generic/tkConsole.c b/generic/tkConsole.c index e8f5920..701ce77 100644 --- a/generic/tkConsole.c +++ b/generic/tkConsole.c @@ -816,7 +816,7 @@ InterpreterObjCmd( if ((otherInterp == NULL) || Tcl_InterpDeleted(otherInterp)) { Tcl_SetObjResult(interp, Tcl_NewStringObj( - "no active master interp", -1)); + "no active parent interp", -1)); Tcl_SetErrorCode(interp, "TK", "CONSOLE", "NO_INTERP", NULL); return TCL_ERROR; } @@ -939,7 +939,7 @@ ConsoleDeleteProc( * * ConsoleEventProc -- * - * This event function is registered on the main window of the slave + * This event function is registered on the main window of the child * interpreter. If the user or a running script causes the main window to * be destroyed, then we need to inform the console interpreter by * invoking "::tk::ConsoleExit". diff --git a/generic/tkWindow.c b/generic/tkWindow.c index 8ec18e2..a67329c 100644 --- a/generic/tkWindow.c +++ b/generic/tkWindow.c @@ -2969,7 +2969,7 @@ Tk_SafeInit( * Current risks: * * - No CPU time limit, no memory allocation limits, no color limits. - * CPU time limits can be imposed by an unsafe master interpreter. + * CPU time limits can be imposed by an unsafe parent interpreter. * * The actual code called is the same as Tk_Init but Tcl_IsSafe() is * checked at several places to differentiate the two initialisations. @@ -3081,23 +3081,23 @@ Initialize( if (Tcl_IsSafe(interp)) { /* * Get the clearance to start Tk and the "argv" parameters from the - * master. + * parent. */ /* - * Step 1 : find the master and construct the interp name (could be a + * Step 1 : find the parent and construct the interp name (could be a * function if new APIs were ok). We could also construct the path * while walking, but there is no API to get the name of an interp * either. */ - Tcl_Interp *master = interp; + Tcl_Interp *parent = interp; - while (Tcl_IsSafe(master)) { - master = Tcl_GetMaster(master); - if (master == NULL) { + while (Tcl_IsSafe(parent)) { + parent = Tcl_GetMaster(parent); + if (parent == NULL) { Tcl_SetObjResult(interp, Tcl_NewStringObj( - "no controlling master interpreter", -1)); + "no controlling parent interpreter", -1)); Tcl_SetErrorCode(interp, "TK", "SAFE", "NO_MASTER", NULL); return TCL_ERROR; } @@ -3107,35 +3107,35 @@ Initialize( * Construct the name (rewalk...) */ - code = Tcl_GetInterpPath(master, interp); + code = Tcl_GetInterpPath(parent, interp); if (code != TCL_OK) { Tcl_Panic("Tcl_GetInterpPath broken!"); } /* - * Build the command to eval in trusted master. + * Build the command to eval in trusted parent. */ cmd = Tcl_NewListObj(2, NULL); Tcl_ListObjAppendElement(NULL, cmd, Tcl_NewStringObj("::safe::TkInit", -1)); - Tcl_ListObjAppendElement(NULL, cmd, Tcl_GetObjResult(master)); + Tcl_ListObjAppendElement(NULL, cmd, Tcl_GetObjResult(parent)); /* - * Step 2 : Eval in the master. The argument is the *reversed* interp - * path of the slave. + * Step 2 : Eval in the parent. The argument is the *reversed* interp + * path of the child. */ Tcl_IncrRefCount(cmd); - code = Tcl_EvalObjEx(master, cmd, 0); + code = Tcl_EvalObjEx(parent, cmd, 0); Tcl_DecrRefCount(cmd); - Tcl_TransferResult(master, code, interp); + Tcl_TransferResult(parent, code, interp); if (code != TCL_OK) { return code; } /* - * Use the master's result as argv. Note: We don't use the Obj + * Use the parent's result as argv. Note: We don't use the Obj * interfaces to avoid dealing with cross interp refcounting and * changing the code below. */ diff --git a/library/demos/dialog1.tcl b/library/demos/dialog1.tcl index 976e955..66d8c9a 100644 --- a/library/demos/dialog1.tcl +++ b/library/demos/dialog1.tcl @@ -2,16 +2,16 @@ # # This demonstration script creates a dialog box with a local grab. -interp create slave -load {} Tk slave -slave eval { - wm title . slave +interp create child +load {} Tk child +child eval { + wm title . child wm geometry . +700+30 pack [text .t -width 30 -height 10] } after idle {.dialog1.msg configure -wraplength 4i} -set i [tk_dialog .dialog1 "Dialog with local grab" {This is a modal dialog box. It uses Tk's "grab" command to create a "local grab" on the dialog box. The grab prevents any mouse or keyboard events from getting to any other windows in the application until you have answered the dialog by invoking one of the buttons below. However, you can still interact with other applications. For example, you should be able to edit text in the window named "slave" which was created by a slave interpreter.} \ +set i [tk_dialog .dialog1 "Dialog with local grab" {This is a modal dialog box. It uses Tk's "grab" command to create a "local grab" on the dialog box. The grab prevents any mouse or keyboard events from getting to any other windows in the application until you have answered the dialog by invoking one of the buttons below. However, you can still interact with other applications. For example, you should be able to edit text in the window named "child" which was created by a child interpreter.} \ info 0 OK Cancel {Show Code}] switch $i { @@ -20,6 +20,6 @@ switch $i { 2 {showCode .dialog1} } -if {[interp exists slave]} { - interp delete slave +if {[interp exists child]} { + interp delete child } diff --git a/library/safetk.tcl b/library/safetk.tcl index 9f8e25d..841a0b6 100644 --- a/library/safetk.tcl +++ b/library/safetk.tcl @@ -14,9 +14,9 @@ # Note: It is now ok to let untrusted code being executed # between the creation of the interp and the actual loading # of Tk in that interp because the C side Tk_Init will -# now look up the master interp and ask its safe::TkInit +# now look up the parent interp and ask its safe::TkInit # for the actual parameters to use for it's initialization (if allowed), -# not relying on the slave state. +# not relying on the child state. # # We use opt (optional arguments parsing) @@ -29,31 +29,31 @@ namespace eval ::safe { } # -# tkInterpInit : prepare the slave interpreter for tk loading +# tkInterpInit : prepare the child interpreter for tk loading # most of the real job is done by loadTk -# returns the slave name (tkInterpInit does) +# returns the child name (tkInterpInit does) # -proc ::safe::tkInterpInit {slave argv} { +proc ::safe::tkInterpInit {child argv} { global env tk_library # We have to make sure that the tk_library variable is normalized. set tk_library [file normalize $tk_library] # Clear Tk's access for that interp (path). - allowTk $slave $argv + allowTk $child $argv # Ensure tk_library and subdirs (eg, ttk) are on the access path - ::interp eval $slave [list set tk_library [::safe::interpAddToAccessPath $slave $tk_library]] + ::interp eval $child [list set tk_library [::safe::interpAddToAccessPath $child $tk_library]] foreach subdir [::safe::AddSubDirs [list $tk_library]] { - ::safe::interpAddToAccessPath $slave $subdir + ::safe::interpAddToAccessPath $child $subdir } - return $slave + return $child } # tkInterpLoadTk: # Do additional configuration as needed (calling tkInterpInit) -# and actually load Tk into the slave. +# and actually load Tk into the child. # # Either contained in the specified windowId (-use) or # creating a decorated toplevel for it. @@ -62,37 +62,37 @@ proc ::safe::tkInterpInit {slave argv} { proc ::safe::loadTk {} {} ::tcl::OptProc ::safe::loadTk { - {slave -interp "name of the slave interpreter"} + {child -interp "name of the child interpreter"} {-use -windowId {} "window Id to use (new toplevel otherwise)"} {-display -displayName {} "display name to use (current one otherwise)"} } { set displayGiven [::tcl::OptProcArgGiven "-display"] if {!$displayGiven} { # Try to get the current display from "." - # (which might not exist if the master is tk-less) + # (which might not exist if the parent is tk-less) if {[catch {set display [winfo screen .]}]} { if {[info exists ::env(DISPLAY)]} { set display $::env(DISPLAY) } else { - Log $slave "no winfo screen . nor env(DISPLAY)" WARNING + Log $child "no winfo screen . nor env(DISPLAY)" WARNING set display ":0.0" } } } # Get state for access to the cleanupHook. - namespace upvar ::safe S$slave state + namespace upvar ::safe S$child state if {![::tcl::OptProcArgGiven "-use"]} { # create a decorated toplevel - lassign [tkTopLevel $slave $display] w use + lassign [tkTopLevel $child $display] w use - # set our delete hook (slave arg is added by interpDelete) - # to clean up both window related code and tkInit(slave) + # set our delete hook (child arg is added by interpDelete) + # to clean up both window related code and tkInit(child) set state(cleanupHook) [list tkDelete {} $w] } else { - # set our delete hook (slave arg is added by interpDelete) - # to clean up tkInit(slave) + # set our delete hook (child arg is added by interpDelete) + # to clean up tkInit(child) set state(cleanupHook) [list disallowTk] # Let's be nice and also accept tk window names instead of ids @@ -122,12 +122,12 @@ proc ::safe::loadTk {} {} } } - # Prepares the slave for tk with those parameters - tkInterpInit $slave [list "-use" $use "-display" $display] + # Prepares the child for tk with those parameters + tkInterpInit $child [list "-use" $use "-display" $display] - load {} Tk $slave + load {} Tk $child - return $slave + return $child } proc ::safe::TkInit {interpPath} { @@ -149,7 +149,7 @@ proc ::safe::TkInit {interpPath} { # safe::TkInit. # # Arguments: -# interpPath slave interpreter handle +# interpPath child interpreter handle # argv arguments passed to safe::TkInterpInit # # Results: @@ -168,7 +168,7 @@ proc ::safe::allowTk {interpPath argv} { # in safe::TkInit. # # Arguments: -# interpPath slave interpreter handle +# interpPath child interpreter handle # # Results: # none. @@ -188,43 +188,43 @@ proc ::safe::disallowTk {interpPath} { # Clean up the window associated with the interp being deleted. # # Arguments: -# interpPath slave interpreter handle +# interpPath child interpreter handle # # Results: # none. -proc ::safe::tkDelete {W window slave} { +proc ::safe::tkDelete {W window child} { # we are going to be called for each widget... skip untill it's # top level - Log $slave "Called tkDelete $W $window" NOTICE - if {[::interp exists $slave]} { - if {[catch {::safe::interpDelete $slave} msg]} { - Log $slave "Deletion error : $msg" + Log $child "Called tkDelete $W $window" NOTICE + if {[::interp exists $child]} { + if {[catch {::safe::interpDelete $child} msg]} { + Log $child "Deletion error : $msg" } } if {[winfo exists $window]} { - Log $slave "Destroy toplevel $window" NOTICE + Log $child "Destroy toplevel $window" NOTICE destroy $window } - # clean up tkInit(slave) - disallowTk $slave + # clean up tkInit(child) + disallowTk $child return } -proc ::safe::tkTopLevel {slave display} { +proc ::safe::tkTopLevel {child display} { variable tkSafeId incr tkSafeId set w ".safe$tkSafeId" if {[catch {toplevel $w -screen $display -class SafeTk} msg]} { return -code error -errorcode {TK TOPLEVEL SAFE} \ - "Unable to create toplevel for safe slave \"$slave\" ($msg)" + "Unable to create toplevel for safe child \"$child\" ($msg)" } - Log $slave "New toplevel $w" NOTICE + Log $child "New toplevel $w" NOTICE - set msg "Untrusted Tcl applet ($slave)" + set msg "Untrusted Tcl applet ($child)" wm title $w $msg # Control frame (we must create a style for it) @@ -236,7 +236,7 @@ proc ::safe::tkTopLevel {slave display} { # We will destroy the interp when the window is destroyed bindtags $wc [concat Safe$wc [bindtags $wc]] - bind Safe$wc [list ::safe::tkDelete %W $w $slave] + bind Safe$wc [list ::safe::tkDelete %W $w $child] ttk::label $wc.l -text $msg -anchor w @@ -247,7 +247,7 @@ proc ::safe::tkTopLevel {slave display} { # but still have the default background instead of red one from the parent ttk::frame $wc.fb -borderwidth 0 ttk::button $wc.fb.b -text "Delete" \ - -command [list ::safe::tkDelete $w $w $slave] + -command [list ::safe::tkDelete $w $w $child] pack $wc.fb.b -side right -fill both pack $wc.fb -side right -fill both -expand 1 pack $wc.l -side left -fill both -expand 1 -ipady 2 diff --git a/macosx/Tk.xcode/project.pbxproj b/macosx/Tk.xcode/project.pbxproj index 93143f7..c93b15b 100644 --- a/macosx/Tk.xcode/project.pbxproj +++ b/macosx/Tk.xcode/project.pbxproj @@ -1411,7 +1411,7 @@ F96D3E1F08F272A5004A47F5 /* CrtInterp.3 */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = CrtInterp.3; sourceTree = ""; }; F96D3E2008F272A5004A47F5 /* CrtMathFnc.3 */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = CrtMathFnc.3; sourceTree = ""; }; F96D3E2108F272A5004A47F5 /* CrtObjCmd.3 */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = CrtObjCmd.3; sourceTree = ""; }; - F96D3E2208F272A5004A47F5 /* CrtSlave.3 */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = CrtSlave.3; sourceTree = ""; }; + F96D3E2208F272A5004A47F5 /* CrtAlias.3 */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = CrtAlias.3; sourceTree = ""; }; F96D3E2308F272A5004A47F5 /* CrtTimerHdlr.3 */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = CrtTimerHdlr.3; sourceTree = ""; }; F96D3E2408F272A5004A47F5 /* CrtTrace.3 */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = CrtTrace.3; sourceTree = ""; }; F96D3E2508F272A5004A47F5 /* dde.n */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = dde.n; sourceTree = ""; }; @@ -3078,7 +3078,7 @@ F96D3E1F08F272A5004A47F5 /* CrtInterp.3 */, F96D3E2008F272A5004A47F5 /* CrtMathFnc.3 */, F96D3E2108F272A5004A47F5 /* CrtObjCmd.3 */, - F96D3E2208F272A5004A47F5 /* CrtSlave.3 */, + F96D3E2208F272A5004A47F5 /* CrtAlias.3 */, F96D3E2308F272A5004A47F5 /* CrtTimerHdlr.3 */, F96D3E2408F272A5004A47F5 /* CrtTrace.3 */, F96D3E2508F272A5004A47F5 /* dde.n */, diff --git a/macosx/Tk.xcodeproj/project.pbxproj b/macosx/Tk.xcodeproj/project.pbxproj index 53ebe3e..10a9c9a 100644 --- a/macosx/Tk.xcodeproj/project.pbxproj +++ b/macosx/Tk.xcodeproj/project.pbxproj @@ -1411,7 +1411,7 @@ F96D3E1F08F272A5004A47F5 /* CrtInterp.3 */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = CrtInterp.3; sourceTree = ""; }; F96D3E2008F272A5004A47F5 /* CrtMathFnc.3 */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = CrtMathFnc.3; sourceTree = ""; }; F96D3E2108F272A5004A47F5 /* CrtObjCmd.3 */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = CrtObjCmd.3; sourceTree = ""; }; - F96D3E2208F272A5004A47F5 /* CrtSlave.3 */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = CrtSlave.3; sourceTree = ""; }; + F96D3E2208F272A5004A47F5 /* CrtAlias.3 */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = CrtAlias.3; sourceTree = ""; }; F96D3E2308F272A5004A47F5 /* CrtTimerHdlr.3 */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = CrtTimerHdlr.3; sourceTree = ""; }; F96D3E2408F272A5004A47F5 /* CrtTrace.3 */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = CrtTrace.3; sourceTree = ""; }; F96D3E2508F272A5004A47F5 /* dde.n */ = {isa = PBXFileReference; explicitFileType = text.man; fileEncoding = 4; path = dde.n; sourceTree = ""; }; @@ -3078,7 +3078,7 @@ F96D3E1F08F272A5004A47F5 /* CrtInterp.3 */, F96D3E2008F272A5004A47F5 /* CrtMathFnc.3 */, F96D3E2108F272A5004A47F5 /* CrtObjCmd.3 */, - F96D3E2208F272A5004A47F5 /* CrtSlave.3 */, + F96D3E2208F272A5004A47F5 /* CrtAlias.3 */, F96D3E2308F272A5004A47F5 /* CrtTimerHdlr.3 */, F96D3E2408F272A5004A47F5 /* CrtTrace.3 */, F96D3E2508F272A5004A47F5 /* dde.n */, diff --git a/tests/constraints.tcl b/tests/constraints.tcl index c77fb00..ff036f3 100644 --- a/tests/constraints.tcl +++ b/tests/constraints.tcl @@ -37,7 +37,7 @@ namespace eval tk { namespace eval bg { # Manage a background process. - # Replace with slave interp or thread? + # Replace with child interp or thread? namespace import ::tcltest::interpreter namespace import ::tk::test::loadTkCommand namespace export setup cleanup do diff --git a/tests/safe.test b/tests/safe.test index 475d938..97f6688 100644 --- a/tests/safe.test +++ b/tests/safe.test @@ -182,7 +182,7 @@ test safe-4.2 {testing loadTk -use} -setup { destroy $w } -result {} -test safe-5.1 {loading Tk in safe interps without master's clearance} -body { +test safe-5.1 {loading Tk in safe interps without parent's clearance} -body { set i [safe::interpCreate] interp eval $i {load {} Tk} } -cleanup { diff --git a/tests/safePrimarySelection.test b/tests/safePrimarySelection.test index 7cc31f4..e6ef487 100644 --- a/tests/safePrimarySelection.test +++ b/tests/safePrimarySelection.test @@ -16,8 +16,8 @@ tcltest::loadTestedCommands # ------------------------------------------------------------------------------ # - Tests 3.*, 6.* test that the fix for ticket de156e9efe implemented in branch # bug-de156e9efe has been applied and still works. They test that a Safe Base -# slave interpreter cannot write to the PRIMARY selection. -# - The other tests verify that the master interpreter and an unsafe slave CAN +# child interpreter cannot write to the PRIMARY selection. +# - The other tests verify that the parent interpreter and an unsafe child CAN # write to the PRIMARY selection, and therefore that the test scripts # themselves are valid. # - A text, entry, ttk::entry, listbox, spinbox or ttk::spinbox widget can have @@ -38,7 +38,7 @@ namespace eval ::_test_tmp {} # directory without installing Tk. In that case the usual auto_path loading # mechanism cannot work because the tk binary is not where pkgIndex.tcl says # it is. -# - This command is not needed for Safe Base slaves because safe::loadTk does +# - This command is not needed for Safe Base children because safe::loadTk does # something similar and works correctly. # - Based on scripts in winSend.test. # ------------------------------------------------------------------------------ @@ -208,11 +208,11 @@ set ::_test_tmp::script { } } -# Do this once for the master interpreter. +# Do this once for the parent interpreter. eval $::_test_tmp::script -test safePrimarySelection-1.1 {master interpreter, text, no existing selection} -setup { - catch {interp delete slave2} +test safePrimarySelection-1.1 {parent interpreter, text, no existing selection} -setup { + catch {interp delete child2} destroy {*}[winfo children .] ::_test_tmp::clearPrimarySelection } -body { @@ -223,8 +223,8 @@ test safePrimarySelection-1.1 {master interpreter, text, no existing selection} ::_test_tmp::clearPrimarySelection } -result {PAYLOAD} -test safePrimarySelection-1.2 {master interpreter, entry, no existing selection} -setup { - catch {interp delete slave2} +test safePrimarySelection-1.2 {parent interpreter, entry, no existing selection} -setup { + catch {interp delete child2} destroy {*}[winfo children .] ::_test_tmp::clearPrimarySelection } -body { @@ -235,8 +235,8 @@ test safePrimarySelection-1.2 {master interpreter, entry, no existing selection} ::_test_tmp::clearPrimarySelection } -result {PAYLOAD} -test safePrimarySelection-1.3 {master interpreter, ttk::entry, no existing selection} -setup { - catch {interp delete slave2} +test safePrimarySelection-1.3 {parent interpreter, ttk::entry, no existing selection} -setup { + catch {interp delete child2} destroy {*}[winfo children .] ::_test_tmp::clearPrimarySelection } -body { @@ -247,8 +247,8 @@ test safePrimarySelection-1.3 {master interpreter, ttk::entry, no existing selec ::_test_tmp::clearPrimarySelection } -result {PAYLOAD} -test safePrimarySelection-1.4 {master interpreter, listbox, no existing selection} -setup { - catch {interp delete slave2} +test safePrimarySelection-1.4 {parent interpreter, listbox, no existing selection} -setup { + catch {interp delete child2} destroy {*}[winfo children .] ::_test_tmp::clearPrimarySelection } -body { @@ -259,8 +259,8 @@ test safePrimarySelection-1.4 {master interpreter, listbox, no existing selectio ::_test_tmp::clearPrimarySelection } -result {PAYLOAD} -test safePrimarySelection-1.5 {master interpreter, spinbox as entry, no existing selection} -setup { - catch {interp delete slave2} +test safePrimarySelection-1.5 {parent interpreter, spinbox as entry, no existing selection} -setup { + catch {interp delete child2} destroy {*}[winfo children .] ::_test_tmp::clearPrimarySelection } -body { @@ -271,8 +271,8 @@ test safePrimarySelection-1.5 {master interpreter, spinbox as entry, no existing ::_test_tmp::clearPrimarySelection } -result {PAYLOAD} -test safePrimarySelection-1.6 {master interpreter, spinbox spun, no existing selection} -setup { - catch {interp delete slave2} +test safePrimarySelection-1.6 {parent interpreter, spinbox spun, no existing selection} -setup { + catch {interp delete child2} destroy {*}[winfo children .] ::_test_tmp::clearPrimarySelection } -body { @@ -283,8 +283,8 @@ test safePrimarySelection-1.6 {master interpreter, spinbox spun, no existing sel ::_test_tmp::clearPrimarySelection } -result {2} -test safePrimarySelection-1.7 {master interpreter, spinbox spun/selected/spun, no existing selection} -setup { - catch {interp delete slave2} +test safePrimarySelection-1.7 {parent interpreter, spinbox spun/selected/spun, no existing selection} -setup { + catch {interp delete child2} destroy {*}[winfo children .] ::_test_tmp::clearPrimarySelection } -body { @@ -295,8 +295,8 @@ test safePrimarySelection-1.7 {master interpreter, spinbox spun/selected/spun, n ::_test_tmp::clearPrimarySelection } -result {3} -test safePrimarySelection-1.8 {master interpreter, ttk::spinbox as entry, no existing selection} -setup { - catch {interp delete slave2} +test safePrimarySelection-1.8 {parent interpreter, ttk::spinbox as entry, no existing selection} -setup { + catch {interp delete child2} destroy {*}[winfo children .] ::_test_tmp::clearPrimarySelection } -body { @@ -307,8 +307,8 @@ test safePrimarySelection-1.8 {master interpreter, ttk::spinbox as entry, no exi ::_test_tmp::clearPrimarySelection } -result {PAYLOAD} -test safePrimarySelection-1.9 {master interpreter, ttk::spinbox spun, no existing selection} -setup { - catch {interp delete slave2} +test safePrimarySelection-1.9 {parent interpreter, ttk::spinbox spun, no existing selection} -setup { + catch {interp delete child2} destroy {*}[winfo children .] ::_test_tmp::clearPrimarySelection } -body { @@ -319,8 +319,8 @@ test safePrimarySelection-1.9 {master interpreter, ttk::spinbox spun, no existin ::_test_tmp::clearPrimarySelection } -result {2} -test safePrimarySelection-1.10 {master interpreter, ttk::spinbox spun/selected/spun, no existing selection} -setup { - catch {interp delete slave2} +test safePrimarySelection-1.10 {parent interpreter, ttk::spinbox spun/selected/spun, no existing selection} -setup { + catch {interp delete child2} destroy {*}[winfo children .] ::_test_tmp::clearPrimarySelection } -body { @@ -331,12 +331,12 @@ test safePrimarySelection-1.10 {master interpreter, ttk::spinbox spun/selected/s ::_test_tmp::clearPrimarySelection } -result {3} -test safePrimarySelection-2.1 {unsafe slave interpreter, text, no existing selection} -setup { - catch {interp delete slave2} +test safePrimarySelection-2.1 {unsafe child interpreter, text, no existing selection} -setup { + catch {interp delete child2} destroy {*}[winfo children .] ::_test_tmp::clearPrimarySelection } -body { - set int2 slave2 + set int2 child2 ::_test_tmp::unsafeInterp $int2 $int2 eval $::_test_tmp::script $int2 eval ::_test_tmp::tryText @@ -348,12 +348,12 @@ test safePrimarySelection-2.1 {unsafe slave interpreter, text, no existing selec ::_test_tmp::clearPrimarySelection } -result {PAYLOAD} -test safePrimarySelection-2.2 {unsafe slave interpreter, entry, no existing selection} -setup { - catch {interp delete slave2} +test safePrimarySelection-2.2 {unsafe child interpreter, entry, no existing selection} -setup { + catch {interp delete child2} destroy {*}[winfo children .] ::_test_tmp::clearPrimarySelection } -body { - set int2 slave2 + set int2 child2 ::_test_tmp::unsafeInterp $int2 $int2 eval $::_test_tmp::script $int2 eval ::_test_tmp::tryEntry @@ -365,12 +365,12 @@ test safePrimarySelection-2.2 {unsafe slave interpreter, entry, no existing sele ::_test_tmp::clearPrimarySelection } -result {PAYLOAD} -test safePrimarySelection-2.3 {unsafe slave interpreter, ttk::entry, no existing selection} -setup { - catch {interp delete slave2} +test safePrimarySelection-2.3 {unsafe child interpreter, ttk::entry, no existing selection} -setup { + catch {interp delete child2} destroy {*}[winfo children .] ::_test_tmp::clearPrimarySelection } -body { - set int2 slave2 + set int2 child2 ::_test_tmp::unsafeInterp $int2 $int2 eval $::_test_tmp::script $int2 eval ::_test_tmp::tryTtkEntry @@ -382,12 +382,12 @@ test safePrimarySelection-2.3 {unsafe slave interpreter, ttk::entry, no existing ::_test_tmp::clearPrimarySelection } -result {PAYLOAD} -test safePrimarySelection-2.4 {unsafe slave interpreter, listbox, no existing selection} -setup { - catch {interp delete slave2} +test safePrimarySelection-2.4 {unsafe child interpreter, listbox, no existing selection} -setup { + catch {interp delete child2} destroy {*}[winfo children .] ::_test_tmp::clearPrimarySelection } -body { - set int2 slave2 + set int2 child2 ::_test_tmp::unsafeInterp $int2 $int2 eval $::_test_tmp::script $int2 eval ::_test_tmp::tryListbox @@ -399,12 +399,12 @@ test safePrimarySelection-2.4 {unsafe slave interpreter, listbox, no existing se ::_test_tmp::clearPrimarySelection } -result {PAYLOAD} -test safePrimarySelection-2.5 {unsafe slave interpreter, spinbox as entry, no existing selection} -setup { - catch {interp delete slave2} +test safePrimarySelection-2.5 {unsafe child interpreter, spinbox as entry, no existing selection} -setup { + catch {interp delete child2} destroy {*}[winfo children .] ::_test_tmp::clearPrimarySelection } -body { - set int2 slave2 + set int2 child2 ::_test_tmp::unsafeInterp $int2 $int2 eval $::_test_tmp::script $int2 eval ::_test_tmp::trySpinbox 1 @@ -416,12 +416,12 @@ test safePrimarySelection-2.5 {unsafe slave interpreter, spinbox as entry, no ex ::_test_tmp::clearPrimarySelection } -result {PAYLOAD} -test safePrimarySelection-2.6 {unsafe slave interpreter, spinbox spun, no existing selection} -setup { - catch {interp delete slave2} +test safePrimarySelection-2.6 {unsafe child interpreter, spinbox spun, no existing selection} -setup { + catch {interp delete child2} destroy {*}[winfo children .] ::_test_tmp::clearPrimarySelection } -body { - set int2 slave2 + set int2 child2 ::_test_tmp::unsafeInterp $int2 $int2 eval $::_test_tmp::script $int2 eval ::_test_tmp::trySpinbox 2 @@ -433,12 +433,12 @@ test safePrimarySelection-2.6 {unsafe slave interpreter, spinbox spun, no existi ::_test_tmp::clearPrimarySelection } -result {2} -test safePrimarySelection-2.7 {unsafe slave interpreter, spinbox spun/selected/spun, no existing selection} -setup { - catch {interp delete slave2} +test safePrimarySelection-2.7 {unsafe child interpreter, spinbox spun/selected/spun, no existing selection} -setup { + catch {interp delete child2} destroy {*}[winfo children .] ::_test_tmp::clearPrimarySelection } -body { - set int2 slave2 + set int2 child2 ::_test_tmp::unsafeInterp $int2 $int2 eval $::_test_tmp::script $int2 eval ::_test_tmp::trySpinbox 3 @@ -450,12 +450,12 @@ test safePrimarySelection-2.7 {unsafe slave interpreter, spinbox spun/selected/s ::_test_tmp::clearPrimarySelection } -result {3} -test safePrimarySelection-2.8 {unsafe slave interpreter, ttk::spinbox as entry, no existing selection} -setup { - catch {interp delete slave2} +test safePrimarySelection-2.8 {unsafe child interpreter, ttk::spinbox as entry, no existing selection} -setup { + catch {interp delete child2} destroy {*}[winfo children .] ::_test_tmp::clearPrimarySelection } -body { - set int2 slave2 + set int2 child2 ::_test_tmp::unsafeInterp $int2 $int2 eval $::_test_tmp::script $int2 eval ::_test_tmp::tryTtkSpinbox 1 @@ -467,12 +467,12 @@ test safePrimarySelection-2.8 {unsafe slave interpreter, ttk::spinbox as entry, ::_test_tmp::clearPrimarySelection } -result {PAYLOAD} -test safePrimarySelection-2.9 {unsafe slave interpreter, ttk::spinbox spun, no existing selection} -setup { - catch {interp delete slave2} +test safePrimarySelection-2.9 {unsafe child interpreter, ttk::spinbox spun, no existing selection} -setup { + catch {interp delete child2} destroy {*}[winfo children .] ::_test_tmp::clearPrimarySelection } -body { - set int2 slave2 + set int2 child2 ::_test_tmp::unsafeInterp $int2 $int2 eval $::_test_tmp::script $int2 eval ::_test_tmp::tryTtkSpinbox 2 @@ -484,12 +484,12 @@ test safePrimarySelection-2.9 {unsafe slave interpreter, ttk::spinbox spun, no e ::_test_tmp::clearPrimarySelection } -result {2} -test safePrimarySelection-2.10 {unsafe slave interpreter, ttk::spinbox spun/selected/spun, no existing selection} -setup { - catch {interp delete slave2} +test safePrimarySelection-2.10 {unsafe child interpreter, ttk::spinbox spun/selected/spun, no existing selection} -setup { + catch {interp delete child2} destroy {*}[winfo children .] ::_test_tmp::clearPrimarySelection } -body { - set int2 slave2 + set int2 child2 ::_test_tmp::unsafeInterp $int2 $int2 eval $::_test_tmp::script $int2 eval ::_test_tmp::tryTtkSpinbox 3 @@ -501,13 +501,13 @@ test safePrimarySelection-2.10 {unsafe slave interpreter, ttk::spinbox spun/sele ::_test_tmp::clearPrimarySelection } -result {3} -test safePrimarySelection-3.1 {IMPORTANT, safe slave interpreter, text, no existing selection} -setup { - catch {interp delete slave2} +test safePrimarySelection-3.1 {IMPORTANT, safe child interpreter, text, no existing selection} -setup { + catch {interp delete child2} destroy {*}[winfo children .] ::_test_tmp::clearPrimarySelection } -body { set res0 [::_test_tmp::getPrimarySelection] - set int2 slave2 + set int2 child2 ::safe::interpCreate $int2 ::safe::loadTk $int2 $int2 eval $::_test_tmp::script @@ -522,13 +522,13 @@ test safePrimarySelection-3.1 {IMPORTANT, safe slave interpreter, text, no exist ::_test_tmp::clearPrimarySelection } -result {----} -test safePrimarySelection-3.2 {IMPORTANT, safe slave interpreter, entry, no existing selection} -setup { - catch {interp delete slave2} +test safePrimarySelection-3.2 {IMPORTANT, safe child interpreter, entry, no existing selection} -setup { + catch {interp delete child2} destroy {*}[winfo children .] ::_test_tmp::clearPrimarySelection } -body { set res0 [::_test_tmp::getPrimarySelection] - set int2 slave2 + set int2 child2 ::safe::interpCreate $int2 ::safe::loadTk $int2 $int2 eval $::_test_tmp::script @@ -543,13 +543,13 @@ test safePrimarySelection-3.2 {IMPORTANT, safe slave interpreter, entry, no exis ::_test_tmp::clearPrimarySelection } -result {----} -test safePrimarySelection-3.3 {IMPORTANT, safe slave interpreter, ttk::entry, no existing selection} -setup { - catch {interp delete slave2} +test safePrimarySelection-3.3 {IMPORTANT, safe child interpreter, ttk::entry, no existing selection} -setup { + catch {interp delete child2} destroy {*}[winfo children .] ::_test_tmp::clearPrimarySelection } -body { set res0 [::_test_tmp::getPrimarySelection] - set int2 slave2 + set int2 child2 ::safe::interpCreate $int2 ::safe::loadTk $int2 $int2 eval $::_test_tmp::script @@ -564,13 +564,13 @@ test safePrimarySelection-3.3 {IMPORTANT, safe slave interpreter, ttk::entry, no ::_test_tmp::clearPrimarySelection } -result {----} -test safePrimarySelection-3.4 {IMPORTANT, safe slave interpreter, listbox, no existing selection} -setup { - catch {interp delete slave2} +test safePrimarySelection-3.4 {IMPORTANT, safe child interpreter, listbox, no existing selection} -setup { + catch {interp delete child2} destroy {*}[winfo children .] ::_test_tmp::clearPrimarySelection } -body { set res0 [::_test_tmp::getPrimarySelection] - set int2 slave2 + set int2 child2 ::safe::interpCreate $int2 ::safe::loadTk $int2 $int2 eval $::_test_tmp::script @@ -585,13 +585,13 @@ test safePrimarySelection-3.4 {IMPORTANT, safe slave interpreter, listbox, no ex ::_test_tmp::clearPrimarySelection } -result {----} -test safePrimarySelection-3.5 {IMPORTANT, safe slave interpreter, spinbox as entry, no existing selection} -setup { - catch {interp delete slave2} +test safePrimarySelection-3.5 {IMPORTANT, safe child interpreter, spinbox as entry, no existing selection} -setup { + catch {interp delete child2} destroy {*}[winfo children .] ::_test_tmp::clearPrimarySelection } -body { set res0 [::_test_tmp::getPrimarySelection] - set int2 slave2 + set int2 child2 ::safe::interpCreate $int2 ::safe::loadTk $int2 $int2 eval $::_test_tmp::script @@ -606,13 +606,13 @@ test safePrimarySelection-3.5 {IMPORTANT, safe slave interpreter, spinbox as ent ::_test_tmp::clearPrimarySelection } -result {----} -test safePrimarySelection-3.6 {IMPORTANT, safe slave interpreter, spinbox spun, no existing selection} -setup { - catch {interp delete slave2} +test safePrimarySelection-3.6 {IMPORTANT, safe child interpreter, spinbox spun, no existing selection} -setup { + catch {interp delete child2} destroy {*}[winfo children .] ::_test_tmp::clearPrimarySelection } -body { set res0 [::_test_tmp::getPrimarySelection] - set int2 slave2 + set int2 child2 ::safe::interpCreate $int2 ::safe::loadTk $int2 $int2 eval $::_test_tmp::script @@ -627,13 +627,13 @@ test safePrimarySelection-3.6 {IMPORTANT, safe slave interpreter, spinbox spun, ::_test_tmp::clearPrimarySelection } -result {----} -test safePrimarySelection-3.7 {IMPORTANT, safe slave interpreter, spinbox spun/selected/spun, no existing selection} -setup { - catch {interp delete slave2} +test safePrimarySelection-3.7 {IMPORTANT, safe child interpreter, spinbox spun/selected/spun, no existing selection} -setup { + catch {interp delete child2} destroy {*}[winfo children .] ::_test_tmp::clearPrimarySelection } -body { set res0 [::_test_tmp::getPrimarySelection] - set int2 slave2 + set int2 child2 ::safe::interpCreate $int2 ::safe::loadTk $int2 $int2 eval $::_test_tmp::script @@ -648,13 +648,13 @@ test safePrimarySelection-3.7 {IMPORTANT, safe slave interpreter, spinbox spun/s ::_test_tmp::clearPrimarySelection } -result {----} -test safePrimarySelection-3.8 {IMPORTANT, safe slave interpreter, ttk::spinbox as entry, no existing selection} -setup { - catch {interp delete slave2} +test safePrimarySelection-3.8 {IMPORTANT, safe child interpreter, ttk::spinbox as entry, no existing selection} -setup { + catch {interp delete child2} destroy {*}[winfo children .] ::_test_tmp::clearPrimarySelection } -body { set res0 [::_test_tmp::getPrimarySelection] - set int2 slave2 + set int2 child2 ::safe::interpCreate $int2 ::safe::loadTk $int2 $int2 eval $::_test_tmp::script @@ -669,13 +669,13 @@ test safePrimarySelection-3.8 {IMPORTANT, safe slave interpreter, ttk::spinbox a ::_test_tmp::clearPrimarySelection } -result {----} -test safePrimarySelection-3.9 {IMPORTANT, safe slave interpreter, ttk::spinbox spun, no existing selection} -setup { - catch {interp delete slave2} +test safePrimarySelection-3.9 {IMPORTANT, safe child interpreter, ttk::spinbox spun, no existing selection} -setup { + catch {interp delete child2} destroy {*}[winfo children .] ::_test_tmp::clearPrimarySelection } -body { set res0 [::_test_tmp::getPrimarySelection] - set int2 slave2 + set int2 child2 ::safe::interpCreate $int2 ::safe::loadTk $int2 $int2 eval $::_test_tmp::script @@ -690,13 +690,13 @@ test safePrimarySelection-3.9 {IMPORTANT, safe slave interpreter, ttk::spinbox s ::_test_tmp::clearPrimarySelection } -result {----} -test safePrimarySelection-3.10 {IMPORTANT, safe slave interpreter, ttk::spinbox spun/selected/spun, no existing selection} -setup { - catch {interp delete slave2} +test safePrimarySelection-3.10 {IMPORTANT, safe child interpreter, ttk::spinbox spun/selected/spun, no existing selection} -setup { + catch {interp delete child2} destroy {*}[winfo children .] ::_test_tmp::clearPrimarySelection } -body { set res0 [::_test_tmp::getPrimarySelection] - set int2 slave2 + set int2 child2 ::safe::interpCreate $int2 ::safe::loadTk $int2 $int2 eval $::_test_tmp::script @@ -711,8 +711,8 @@ test safePrimarySelection-3.10 {IMPORTANT, safe slave interpreter, ttk::spinbox ::_test_tmp::clearPrimarySelection } -result {----} -test safePrimarySelection-4.1 {master interpreter, text, existing selection} -setup { - catch {interp delete slave2} +test safePrimarySelection-4.1 {parent interpreter, text, existing selection} -setup { + catch {interp delete child2} destroy {*}[winfo children .] ::_test_tmp::setPrimarySelection } -body { @@ -723,8 +723,8 @@ test safePrimarySelection-4.1 {master interpreter, text, existing selection} -se ::_test_tmp::clearPrimarySelection } -result {PAYLOAD} -test safePrimarySelection-4.2 {master interpreter, entry, existing selection} -setup { - catch {interp delete slave2} +test safePrimarySelection-4.2 {parent interpreter, entry, existing selection} -setup { + catch {interp delete child2} destroy {*}[winfo children .] ::_test_tmp::setPrimarySelection } -body { @@ -735,8 +735,8 @@ test safePrimarySelection-4.2 {master interpreter, entry, existing selection} -s ::_test_tmp::clearPrimarySelection } -result {PAYLOAD} -test safePrimarySelection-4.3 {master interpreter, ttk::entry, existing selection} -setup { - catch {interp delete slave2} +test safePrimarySelection-4.3 {parent interpreter, ttk::entry, existing selection} -setup { + catch {interp delete child2} destroy {*}[winfo children .] ::_test_tmp::setPrimarySelection } -body { @@ -747,8 +747,8 @@ test safePrimarySelection-4.3 {master interpreter, ttk::entry, existing selectio ::_test_tmp::clearPrimarySelection } -result {PAYLOAD} -test safePrimarySelection-4.4 {master interpreter, listbox, existing selection} -setup { - catch {interp delete slave2} +test safePrimarySelection-4.4 {parent interpreter, listbox, existing selection} -setup { + catch {interp delete child2} destroy {*}[winfo children .] ::_test_tmp::setPrimarySelection } -body { @@ -759,8 +759,8 @@ test safePrimarySelection-4.4 {master interpreter, listbox, existing selection} ::_test_tmp::clearPrimarySelection } -result {PAYLOAD} -test safePrimarySelection-4.5 {master interpreter, spinbox as entry, existing selection} -setup { - catch {interp delete slave2} +test safePrimarySelection-4.5 {parent interpreter, spinbox as entry, existing selection} -setup { + catch {interp delete child2} destroy {*}[winfo children .] ::_test_tmp::setPrimarySelection } -body { @@ -771,8 +771,8 @@ test safePrimarySelection-4.5 {master interpreter, spinbox as entry, existing se ::_test_tmp::clearPrimarySelection } -result {PAYLOAD} -test safePrimarySelection-4.6 {master interpreter, spinbox spun, existing selection} -setup { - catch {interp delete slave2} +test safePrimarySelection-4.6 {parent interpreter, spinbox spun, existing selection} -setup { + catch {interp delete child2} destroy {*}[winfo children .] ::_test_tmp::setPrimarySelection } -body { @@ -783,8 +783,8 @@ test safePrimarySelection-4.6 {master interpreter, spinbox spun, existing select ::_test_tmp::clearPrimarySelection } -result {2} -test safePrimarySelection-4.7 {master interpreter, spinbox spun/selected/spun, existing selection} -setup { - catch {interp delete slave2} +test safePrimarySelection-4.7 {parent interpreter, spinbox spun/selected/spun, existing selection} -setup { + catch {interp delete child2} destroy {*}[winfo children .] ::_test_tmp::setPrimarySelection } -body { @@ -795,8 +795,8 @@ test safePrimarySelection-4.7 {master interpreter, spinbox spun/selected/spun, e ::_test_tmp::clearPrimarySelection } -result {3} -test safePrimarySelection-4.8 {master interpreter, ttk::spinbox as entry, existing selection} -setup { - catch {interp delete slave2} +test safePrimarySelection-4.8 {parent interpreter, ttk::spinbox as entry, existing selection} -setup { + catch {interp delete child2} destroy {*}[winfo children .] ::_test_tmp::setPrimarySelection } -body { @@ -807,8 +807,8 @@ test safePrimarySelection-4.8 {master interpreter, ttk::spinbox as entry, existi ::_test_tmp::clearPrimarySelection } -result {PAYLOAD} -test safePrimarySelection-4.9 {master interpreter, ttk::spinbox spun, existing selection} -setup { - catch {interp delete slave2} +test safePrimarySelection-4.9 {parent interpreter, ttk::spinbox spun, existing selection} -setup { + catch {interp delete child2} destroy {*}[winfo children .] ::_test_tmp::setPrimarySelection } -body { @@ -819,8 +819,8 @@ test safePrimarySelection-4.9 {master interpreter, ttk::spinbox spun, existing s ::_test_tmp::clearPrimarySelection } -result {2} -test safePrimarySelection-4.10 {master interpreter, ttk::spinbox spun/selected/spun, existing selection} -setup { - catch {interp delete slave2} +test safePrimarySelection-4.10 {parent interpreter, ttk::spinbox spun/selected/spun, existing selection} -setup { + catch {interp delete child2} destroy {*}[winfo children .] ::_test_tmp::setPrimarySelection } -body { @@ -831,12 +831,12 @@ test safePrimarySelection-4.10 {master interpreter, ttk::spinbox spun/selected/s ::_test_tmp::clearPrimarySelection } -result {3} -test safePrimarySelection-5.1 {unsafe slave interpreter, text, existing selection} -setup { - catch {interp delete slave2} +test safePrimarySelection-5.1 {unsafe child interpreter, text, existing selection} -setup { + catch {interp delete child2} destroy {*}[winfo children .] ::_test_tmp::setPrimarySelection } -body { - set int2 slave2 + set int2 child2 ::_test_tmp::unsafeInterp $int2 $int2 eval $::_test_tmp::script $int2 eval ::_test_tmp::tryText @@ -848,12 +848,12 @@ test safePrimarySelection-5.1 {unsafe slave interpreter, text, existing selectio ::_test_tmp::clearPrimarySelection } -result {PAYLOAD} -test safePrimarySelection-5.2 {unsafe slave interpreter, entry, existing selection} -setup { - catch {interp delete slave2} +test safePrimarySelection-5.2 {unsafe child interpreter, entry, existing selection} -setup { + catch {interp delete child2} destroy {*}[winfo children .] ::_test_tmp::setPrimarySelection } -body { - set int2 slave2 + set int2 child2 ::_test_tmp::unsafeInterp $int2 $int2 eval $::_test_tmp::script $int2 eval ::_test_tmp::tryEntry @@ -865,12 +865,12 @@ test safePrimarySelection-5.2 {unsafe slave interpreter, entry, existing selecti ::_test_tmp::clearPrimarySelection } -result {PAYLOAD} -test safePrimarySelection-5.3 {unsafe slave interpreter, ttk::entry, existing selection} -setup { - catch {interp delete slave2} +test safePrimarySelection-5.3 {unsafe child interpreter, ttk::entry, existing selection} -setup { + catch {interp delete child2} destroy {*}[winfo children .] ::_test_tmp::setPrimarySelection } -body { - set int2 slave2 + set int2 child2 ::_test_tmp::unsafeInterp $int2 $int2 eval $::_test_tmp::script $int2 eval ::_test_tmp::tryTtkEntry @@ -882,12 +882,12 @@ test safePrimarySelection-5.3 {unsafe slave interpreter, ttk::entry, existing se ::_test_tmp::clearPrimarySelection } -result {PAYLOAD} -test safePrimarySelection-5.4 {unsafe slave interpreter, listbox, existing selection} -setup { - catch {interp delete slave2} +test safePrimarySelection-5.4 {unsafe child interpreter, listbox, existing selection} -setup { + catch {interp delete child2} destroy {*}[winfo children .] ::_test_tmp::setPrimarySelection } -body { - set int2 slave2 + set int2 child2 ::_test_tmp::unsafeInterp $int2 $int2 eval $::_test_tmp::script $int2 eval ::_test_tmp::tryListbox @@ -899,12 +899,12 @@ test safePrimarySelection-5.4 {unsafe slave interpreter, listbox, existing selec ::_test_tmp::clearPrimarySelection } -result {PAYLOAD} -test safePrimarySelection-5.5 {unsafe slave interpreter, spinbox as entry, existing selection} -setup { - catch {interp delete slave2} +test safePrimarySelection-5.5 {unsafe child interpreter, spinbox as entry, existing selection} -setup { + catch {interp delete child2} destroy {*}[winfo children .] ::_test_tmp::setPrimarySelection } -body { - set int2 slave2 + set int2 child2 ::_test_tmp::unsafeInterp $int2 $int2 eval $::_test_tmp::script $int2 eval ::_test_tmp::trySpinbox 1 @@ -916,12 +916,12 @@ test safePrimarySelection-5.5 {unsafe slave interpreter, spinbox as entry, exist ::_test_tmp::clearPrimarySelection } -result {PAYLOAD} -test safePrimarySelection-5.6 {unsafe slave interpreter, spinbox spun, existing selection} -setup { - catch {interp delete slave2} +test safePrimarySelection-5.6 {unsafe child interpreter, spinbox spun, existing selection} -setup { + catch {interp delete child2} destroy {*}[winfo children .] ::_test_tmp::setPrimarySelection } -body { - set int2 slave2 + set int2 child2 ::_test_tmp::unsafeInterp $int2 $int2 eval $::_test_tmp::script $int2 eval ::_test_tmp::trySpinbox 2 @@ -933,12 +933,12 @@ test safePrimarySelection-5.6 {unsafe slave interpreter, spinbox spun, existing ::_test_tmp::clearPrimarySelection } -result {2} -test safePrimarySelection-5.7 {unsafe slave interpreter, spinbox spun/selected/spun, existing selection} -setup { - catch {interp delete slave2} +test safePrimarySelection-5.7 {unsafe child interpreter, spinbox spun/selected/spun, existing selection} -setup { + catch {interp delete child2} destroy {*}[winfo children .] ::_test_tmp::setPrimarySelection } -body { - set int2 slave2 + set int2 child2 ::_test_tmp::unsafeInterp $int2 $int2 eval $::_test_tmp::script $int2 eval ::_test_tmp::trySpinbox 3 @@ -950,12 +950,12 @@ test safePrimarySelection-5.7 {unsafe slave interpreter, spinbox spun/selected/s ::_test_tmp::clearPrimarySelection } -result {3} -test safePrimarySelection-5.8 {unsafe slave interpreter, ttk::spinbox as entry, existing selection} -setup { - catch {interp delete slave2} +test safePrimarySelection-5.8 {unsafe child interpreter, ttk::spinbox as entry, existing selection} -setup { + catch {interp delete child2} destroy {*}[winfo children .] ::_test_tmp::setPrimarySelection } -body { - set int2 slave2 + set int2 child2 ::_test_tmp::unsafeInterp $int2 $int2 eval $::_test_tmp::script $int2 eval ::_test_tmp::tryTtkSpinbox 1 @@ -967,12 +967,12 @@ test safePrimarySelection-5.8 {unsafe slave interpreter, ttk::spinbox as entry, ::_test_tmp::clearPrimarySelection } -result {PAYLOAD} -test safePrimarySelection-5.9 {unsafe slave interpreter, ttk::spinbox spun, existing selection} -setup { - catch {interp delete slave2} +test safePrimarySelection-5.9 {unsafe child interpreter, ttk::spinbox spun, existing selection} -setup { + catch {interp delete child2} destroy {*}[winfo children .] ::_test_tmp::setPrimarySelection } -body { - set int2 slave2 + set int2 child2 ::_test_tmp::unsafeInterp $int2 $int2 eval $::_test_tmp::script $int2 eval ::_test_tmp::tryTtkSpinbox 2 @@ -984,12 +984,12 @@ test safePrimarySelection-5.9 {unsafe slave interpreter, ttk::spinbox spun, exis ::_test_tmp::clearPrimarySelection } -result {2} -test safePrimarySelection-5.10 {unsafe slave interpreter, ttk::spinbox spun/selected/spun, existing selection} -setup { - catch {interp delete slave2} +test safePrimarySelection-5.10 {unsafe child interpreter, ttk::spinbox spun/selected/spun, existing selection} -setup { + catch {interp delete child2} destroy {*}[winfo children .] ::_test_tmp::setPrimarySelection } -body { - set int2 slave2 + set int2 child2 ::_test_tmp::unsafeInterp $int2 $int2 eval $::_test_tmp::script $int2 eval ::_test_tmp::tryTtkSpinbox 3 @@ -1001,13 +1001,13 @@ test safePrimarySelection-5.10 {unsafe slave interpreter, ttk::spinbox spun/sele ::_test_tmp::clearPrimarySelection } -result {3} -test safePrimarySelection-6.1 {IMPORTANT, safe slave interpreter, text, existing selection} -setup { - catch {interp delete slave2} +test safePrimarySelection-6.1 {IMPORTANT, safe child interpreter, text, existing selection} -setup { + catch {interp delete child2} destroy {*}[winfo children .] ::_test_tmp::setPrimarySelection } -body { set res0 [::_test_tmp::getPrimarySelection] - set int2 slave2 + set int2 child2 ::safe::interpCreate $int2 ::safe::loadTk $int2 $int2 eval $::_test_tmp::script @@ -1022,13 +1022,13 @@ test safePrimarySelection-6.1 {IMPORTANT, safe slave interpreter, text, existing ::_test_tmp::clearPrimarySelection } -result {OLD_VALUE----OLD_VALUE} -test safePrimarySelection-6.2 {IMPORTANT, safe slave interpreter, entry, existing selection} -setup { - catch {interp delete slave2} +test safePrimarySelection-6.2 {IMPORTANT, safe child interpreter, entry, existing selection} -setup { + catch {interp delete child2} destroy {*}[winfo children .] ::_test_tmp::setPrimarySelection } -body { set res0 [::_test_tmp::getPrimarySelection] - set int2 slave2 + set int2 child2 ::safe::interpCreate $int2 ::safe::loadTk $int2 $int2 eval $::_test_tmp::script @@ -1043,13 +1043,13 @@ test safePrimarySelection-6.2 {IMPORTANT, safe slave interpreter, entry, existin ::_test_tmp::clearPrimarySelection } -result {OLD_VALUE----OLD_VALUE} -test safePrimarySelection-6.3 {IMPORTANT, safe slave interpreter, ttk::entry, existing selection} -setup { - catch {interp delete slave2} +test safePrimarySelection-6.3 {IMPORTANT, safe child interpreter, ttk::entry, existing selection} -setup { + catch {interp delete child2} destroy {*}[winfo children .] ::_test_tmp::setPrimarySelection } -body { set res0 [::_test_tmp::getPrimarySelection] - set int2 slave2 + set int2 child2 ::safe::interpCreate $int2 ::safe::loadTk $int2 $int2 eval $::_test_tmp::script @@ -1064,13 +1064,13 @@ test safePrimarySelection-6.3 {IMPORTANT, safe slave interpreter, ttk::entry, ex ::_test_tmp::clearPrimarySelection } -result {OLD_VALUE----OLD_VALUE} -test safePrimarySelection-6.4 {IMPORTANT, safe slave interpreter, listbox, existing selection} -setup { - catch {interp delete slave2} +test safePrimarySelection-6.4 {IMPORTANT, safe child interpreter, listbox, existing selection} -setup { + catch {interp delete child2} destroy {*}[winfo children .] ::_test_tmp::setPrimarySelection } -body { set res0 [::_test_tmp::getPrimarySelection] - set int2 slave2 + set int2 child2 ::safe::interpCreate $int2 ::safe::loadTk $int2 $int2 eval $::_test_tmp::script @@ -1085,13 +1085,13 @@ test safePrimarySelection-6.4 {IMPORTANT, safe slave interpreter, listbox, exist ::_test_tmp::clearPrimarySelection } -result {OLD_VALUE----OLD_VALUE} -test safePrimarySelection-6.5 {IMPORTANT, safe slave interpreter, spinbox as entry, existing selection} -setup { - catch {interp delete slave2} +test safePrimarySelection-6.5 {IMPORTANT, safe child interpreter, spinbox as entry, existing selection} -setup { + catch {interp delete child2} destroy {*}[winfo children .] ::_test_tmp::setPrimarySelection } -body { set res0 [::_test_tmp::getPrimarySelection] - set int2 slave2 + set int2 child2 ::safe::interpCreate $int2 ::safe::loadTk $int2 $int2 eval $::_test_tmp::script @@ -1106,13 +1106,13 @@ test safePrimarySelection-6.5 {IMPORTANT, safe slave interpreter, spinbox as ent ::_test_tmp::clearPrimarySelection } -result {OLD_VALUE----OLD_VALUE} -test safePrimarySelection-6.6 {IMPORTANT, safe slave interpreter, spinbox spun, existing selection} -setup { - catch {interp delete slave2} +test safePrimarySelection-6.6 {IMPORTANT, safe child interpreter, spinbox spun, existing selection} -setup { + catch {interp delete child2} destroy {*}[winfo children .] ::_test_tmp::setPrimarySelection } -body { set res0 [::_test_tmp::getPrimarySelection] - set int2 slave2 + set int2 child2 ::safe::interpCreate $int2 ::safe::loadTk $int2 $int2 eval $::_test_tmp::script @@ -1127,13 +1127,13 @@ test safePrimarySelection-6.6 {IMPORTANT, safe slave interpreter, spinbox spun, ::_test_tmp::clearPrimarySelection } -result {OLD_VALUE----OLD_VALUE} -test safePrimarySelection-6.7 {IMPORTANT, safe slave interpreter, spinbox spun/selected/spun, existing selection} -setup { - catch {interp delete slave2} +test safePrimarySelection-6.7 {IMPORTANT, safe child interpreter, spinbox spun/selected/spun, existing selection} -setup { + catch {interp delete child2} destroy {*}[winfo children .] ::_test_tmp::setPrimarySelection } -body { set res0 [::_test_tmp::getPrimarySelection] - set int2 slave2 + set int2 child2 ::safe::interpCreate $int2 ::safe::loadTk $int2 $int2 eval $::_test_tmp::script @@ -1148,13 +1148,13 @@ test safePrimarySelection-6.7 {IMPORTANT, safe slave interpreter, spinbox spun/s ::_test_tmp::clearPrimarySelection } -result {OLD_VALUE----OLD_VALUE} -test safePrimarySelection-6.8 {IMPORTANT, safe slave interpreter, ttk::spinbox as entry, existing selection} -setup { - catch {interp delete slave2} +test safePrimarySelection-6.8 {IMPORTANT, safe child interpreter, ttk::spinbox as entry, existing selection} -setup { + catch {interp delete child2} destroy {*}[winfo children .] ::_test_tmp::setPrimarySelection } -body { set res0 [::_test_tmp::getPrimarySelection] - set int2 slave2 + set int2 child2 ::safe::interpCreate $int2 ::safe::loadTk $int2 $int2 eval $::_test_tmp::script @@ -1169,13 +1169,13 @@ test safePrimarySelection-6.8 {IMPORTANT, safe slave interpreter, ttk::spinbox a ::_test_tmp::clearPrimarySelection } -result {OLD_VALUE----OLD_VALUE} -test safePrimarySelection-6.9 {IMPORTANT, safe slave interpreter, ttk::spinbox spun, existing selection} -setup { - catch {interp delete slave2} +test safePrimarySelection-6.9 {IMPORTANT, safe child interpreter, ttk::spinbox spun, existing selection} -setup { + catch {interp delete child2} destroy {*}[winfo children .] ::_test_tmp::setPrimarySelection } -body { set res0 [::_test_tmp::getPrimarySelection] - set int2 slave2 + set int2 child2 ::safe::interpCreate $int2 ::safe::loadTk $int2 $int2 eval $::_test_tmp::script @@ -1190,13 +1190,13 @@ test safePrimarySelection-6.9 {IMPORTANT, safe slave interpreter, ttk::spinbox s ::_test_tmp::clearPrimarySelection } -result {OLD_VALUE----OLD_VALUE} -test safePrimarySelection-6.10 {IMPORTANT, safe slave interpreter, ttk::spinbox spun/selected/spun, existing selection} -setup { - catch {interp delete slave2} +test safePrimarySelection-6.10 {IMPORTANT, safe child interpreter, ttk::spinbox spun/selected/spun, existing selection} -setup { + catch {interp delete child2} destroy {*}[winfo children .] ::_test_tmp::setPrimarySelection } -body { set res0 [::_test_tmp::getPrimarySelection] - set int2 slave2 + set int2 child2 ::safe::interpCreate $int2 ::safe::loadTk $int2 $int2 eval $::_test_tmp::script -- cgit v0.12 From 23573be79ad8f44de1fd3445a3ec3ca89b21e3d3 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Thu, 6 Aug 2020 11:20:04 +0000 Subject: Remove function TkMacOSXSetUpClippingRgn(), which does nothing. But keep its stub entry, just in case --- generic/tkEntry.c | 2 +- generic/tkStubInit.c | 8 ++++++++ macosx/tkMacOSXButton.c | 7 ------- macosx/tkMacOSXDraw.c | 24 ------------------------ macosx/tkMacOSXMenubutton.c | 7 ------- macosx/tkMacOSXScale.c | 2 -- 6 files changed, 9 insertions(+), 41 deletions(-) diff --git a/generic/tkEntry.c b/generic/tkEntry.c index 4c6c65f..f225420 100644 --- a/generic/tkEntry.c +++ b/generic/tkEntry.c @@ -1786,7 +1786,7 @@ DisplayEntry( * Draw the selected and unselected portions separately. */ - int selFirst; + TkSizeT selFirst; if (entryPtr->selectFirst + 1 < entryPtr->leftIndex + 1) { selFirst = entryPtr->leftIndex; diff --git a/generic/tkStubInit.c b/generic/tkStubInit.c index 3834134..1fbc7b3 100644 --- a/generic/tkStubInit.c +++ b/generic/tkStubInit.c @@ -43,6 +43,7 @@ MODULE_SCOPE const TkStubs tkStubs; #undef TkWinGetPlatformId #undef TkPutImage #undef XPutImage +#define TkMacOSXSetUpClippingRgn (void (*)(Drawable))(void *)doNothing #if defined(_WIN32) && !defined(TK_NO_DEPRECATED) && TCL_MAJOR_VERSION < 9 # define Tk_TranslateWinEvent TkTranslateWinEvent @@ -71,6 +72,13 @@ static int TkWinGetPlatformId(void) { #define Tk_PhotoPutZoomedBlock_Panic 0 #define Tk_PhotoSetSize_Panic 0 #define Tk_CreateOldPhotoImageFormat 0 +#ifdef MAC_OSX_TK +static void +doNothing(void) +{ + /* dummy implementation, no need to do anything */ +} +#endif #else static void doNothing(void) diff --git a/macosx/tkMacOSXButton.c b/macosx/tkMacOSXButton.c index 7ca8c10..cd428b5 100644 --- a/macosx/tkMacOSXButton.c +++ b/macosx/tkMacOSXButton.c @@ -194,13 +194,6 @@ TkpDisplayButton( } pixmap = (Pixmap) Tk_WindowId(tkwin); - /* - * Set up clipping region. Make sure the we are using the port - * for this button, or we will set the wrong window's clip. - */ - - TkMacOSXSetUpClippingRgn(Tk_WindowId(tkwin)); - if (TkMacOSXComputeButtonDrawParams(butPtr, dpPtr)) { macButtonPtr->useTkText = 0; } else { diff --git a/macosx/tkMacOSXDraw.c b/macosx/tkMacOSXDraw.c index ddcbfd7..71acbbc 100644 --- a/macosx/tkMacOSXDraw.c +++ b/macosx/tkMacOSXDraw.c @@ -1875,30 +1875,6 @@ TkMacOSXGetClipRgn( /* *---------------------------------------------------------------------- * - * TkMacOSXSetUpClippingRgn -- - * - * Set up the clipping region so that drawing only occurs on the specified - * X subwindow. - * - * Results: - * None. - * - * Side effects: - * None. - * - *---------------------------------------------------------------------- - */ - -void -TkMacOSXSetUpClippingRgn( - Drawable drawable) /* Drawable to update. */ -{ - (void)drawable; -} - -/* - *---------------------------------------------------------------------- - * * TkpClipDrawableToRect -- * * Clip all drawing into the drawable d to the given rectangle. If width diff --git a/macosx/tkMacOSXMenubutton.c b/macosx/tkMacOSXMenubutton.c index 438053e..8eed4f0 100644 --- a/macosx/tkMacOSXMenubutton.c +++ b/macosx/tkMacOSXMenubutton.c @@ -181,13 +181,6 @@ TkpDisplayMenuButton( TkMacOSXComputeMenuButtonDrawParams(butPtr, dpPtr); /* - * Set up clipping region. Make sure the we are using the port for this - * button, or we will set the wrong window's clip. - */ - - TkMacOSXSetUpClippingRgn(pixmap); - - /* * Draw the native portion of the buttons. */ diff --git a/macosx/tkMacOSXScale.c b/macosx/tkMacOSXScale.c index a4c2046..80b1bda 100644 --- a/macosx/tkMacOSXScale.c +++ b/macosx/tkMacOSXScale.c @@ -219,7 +219,6 @@ TkpDisplayScale( destPort = TkMacOSXGetDrawablePort(Tk_WindowId(tkwin)); windowRef = TkMacOSXDrawableWindow(Tk_WindowId(tkwin)); portChanged = QDSwapPort(destPort, &savePort); - TkMacOSXSetUpClippingRgn(Tk_WindowId(tkwin)); /* * Create Macintosh control. @@ -416,7 +415,6 @@ MacScaleEventProc( destPort = TkMacOSXGetDrawablePort(Tk_WindowId(macScalePtr->info.tkwin)); portChanged = QDSwapPort(destPort, &savePort); - TkMacOSXSetUpClippingRgn(Tk_WindowId(macScalePtr->info.tkwin)); TkMacOSXWinBounds((TkWindow *) macScalePtr->info.tkwin, &bounds); where.h = eventPtr->xbutton.x + bounds.left; -- cgit v0.12 From c56bbfcace9ceaac2fa36e32d7c9349e7be3e3b5 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Thu, 6 Aug 2020 15:34:21 +0000 Subject: More use of TCL_UNUSED() macro --- macosx/tkMacOSXButton.c | 29 +++++------- macosx/tkMacOSXMenubutton.c | 28 +++++------- macosx/tkMacOSXScale.c | 4 +- macosx/tkMacOSXWm.c | 107 +++++++++++++++++++++----------------------- 4 files changed, 76 insertions(+), 92 deletions(-) diff --git a/macosx/tkMacOSXButton.c b/macosx/tkMacOSXButton.c index 5aa8f7d..9f60b91 100644 --- a/macosx/tkMacOSXButton.c +++ b/macosx/tkMacOSXButton.c @@ -95,6 +95,8 @@ static void PulseDefaultButtonProc(ClientData clientData); const Tk_ClassProcs tkpButtonProcs = { sizeof(Tk_ClassProcs), /* size */ TkButtonWorldChanged, /* worldChangedProc */ + NULL, + NULL }; static int bCount; @@ -143,7 +145,7 @@ TkButton * TkpCreateButton( Tk_Window tkwin) { - MacButton *macButtonPtr = ckalloc(sizeof(MacButton)); + MacButton *macButtonPtr = (MacButton *)ckalloc(sizeof(MacButton)); Tk_CreateEventHandler(tkwin, ActivateMask, ButtonEventProc, macButtonPtr); @@ -192,13 +194,6 @@ TkpDisplayButton( } pixmap = (Pixmap) Tk_WindowId(tkwin); - /* - * Set up clipping region. Make sure the we are using the port - * for this button, or we will set the wrong window's clip. - */ - - TkMacOSXSetUpClippingRgn(Tk_WindowId(tkwin)); - if (TkMacOSXComputeButtonDrawParams(butPtr, dpPtr)) { macButtonPtr->useTkText = 0; } else { @@ -724,7 +719,7 @@ TkpDestroyButton( static void TkMacOSXDrawButton( MacButton *mbPtr, /* Mac button. */ - GC gc, /* The GC we are drawing into - needed for + TCL_UNUSED(GC), /* The GC we are drawing into - needed for * the bevel button */ Pixmap pixmap) /* The pixmap we are drawing into - needed * for the bevel button */ @@ -810,10 +805,10 @@ TkMacOSXDrawButton( static void ButtonBackgroundDrawCB( - const HIRect *btnbounds, + TCL_UNUSED(const HIRect *), MacButton *ptr, - SInt16 depth, - Boolean isColorDev) + TCL_UNUSED(SInt16), + TCL_UNUSED(Boolean)) { MacButton *mbPtr = (MacButton *) ptr; TkButton *butPtr = (TkButton *) mbPtr; @@ -862,12 +857,12 @@ ButtonBackgroundDrawCB( */ static void ButtonContentDrawCB ( - const HIRect * btnbounds, - ThemeButtonKind kind, - const HIThemeButtonDrawInfo *drawinfo, + TCL_UNUSED(const HIRect *), + TCL_UNUSED(ThemeButtonKind), + TCL_UNUSED(const HIThemeButtonDrawInfo *), MacButton *ptr, - SInt16 depth, - Boolean isColorDev) + TCL_UNUSED(SInt16), + TCL_UNUSED(Boolean)) { TkButton *butPtr = (TkButton *) ptr; Tk_Window tkwin = butPtr->tkwin; diff --git a/macosx/tkMacOSXMenubutton.c b/macosx/tkMacOSXMenubutton.c index d1f429e..8eed4f0 100644 --- a/macosx/tkMacOSXMenubutton.c +++ b/macosx/tkMacOSXMenubutton.c @@ -76,6 +76,8 @@ static void DrawMenuButtonImageAndText(TkMenuButton *butPtr); Tk_ClassProcs tkpMenubuttonClass = { sizeof(Tk_ClassProcs), /* size */ TkMenuButtonWorldChanged, /* worldChangedProc */ + NULL, + NULL }; /* @@ -133,7 +135,7 @@ TkMenuButton * TkpCreateMenuButton( Tk_Window tkwin) { - MacMenuButton *mbPtr = (MacMenuButton *) ckalloc(sizeof(MacMenuButton)); + MacMenuButton *mbPtr = (MacMenuButton *)ckalloc(sizeof(MacMenuButton)); Tk_CreateEventHandler(tkwin, ActivateMask, MenuButtonEventProc, mbPtr); mbPtr->flags = FIRST_DRAW; @@ -179,13 +181,6 @@ TkpDisplayMenuButton( TkMacOSXComputeMenuButtonDrawParams(butPtr, dpPtr); /* - * Set up clipping region. Make sure the we are using the port for this - * button, or we will set the wrong window's clip. - */ - - TkMacOSXSetUpClippingRgn(pixmap); - - /* * Draw the native portion of the buttons. */ @@ -222,7 +217,7 @@ TkpDisplayMenuButton( void TkpDestroyMenuButton( - TkMenuButton *mbPtr) + TCL_UNUSED(TkMenuButton *)) { } @@ -544,8 +539,7 @@ DrawMenuButtonImageAndText( static void TkMacOSXDrawMenuButton( MacMenuButton *mbPtr, /* Mac menubutton. */ - GC gc, /* The GC we are drawing into - needed for the bevel - * button */ + TCL_UNUSED(GC), /* The GC we are drawing into - not used */ Pixmap pixmap) /* The pixmap we are drawing into - needed for the * bevel button */ { @@ -625,8 +619,8 @@ TkMacOSXDrawMenuButton( static void MenuButtonBackgroundDrawCB ( MacMenuButton *ptr, - SInt16 depth, - Boolean isColorDev) + TCL_UNUSED(SInt16), + TCL_UNUSED(Boolean)) { TkMenuButton* butPtr = (TkMenuButton *) ptr; Tk_Window tkwin = butPtr->tkwin; @@ -658,11 +652,11 @@ MenuButtonBackgroundDrawCB ( static void MenuButtonContentDrawCB ( - ThemeButtonKind kind, - const HIThemeButtonDrawInfo *drawinfo, + TCL_UNUSED(ThemeButtonKind), + TCL_UNUSED(const HIThemeButtonDrawInfo *), MacMenuButton *ptr, - SInt16 depth, - Boolean isColorDev) + TCL_UNUSED(SInt16), + TCL_UNUSED(Boolean)) { TkMenuButton *butPtr = (TkMenuButton *) ptr; Tk_Window tkwin = butPtr->tkwin; diff --git a/macosx/tkMacOSXScale.c b/macosx/tkMacOSXScale.c index 6ea9f14..80b1bda 100644 --- a/macosx/tkMacOSXScale.c +++ b/macosx/tkMacOSXScale.c @@ -76,7 +76,7 @@ TkScale * TkpCreateScale( Tk_Window tkwin) { - MacScale *macScalePtr = ckalloc(sizeof(MacScale)); + MacScale *macScalePtr = (MacScale *)ckalloc(sizeof(MacScale)); macScalePtr->scaleHandle = NULL; if (scaleActionProc == NULL) { @@ -219,7 +219,6 @@ TkpDisplayScale( destPort = TkMacOSXGetDrawablePort(Tk_WindowId(tkwin)); windowRef = TkMacOSXDrawableWindow(Tk_WindowId(tkwin)); portChanged = QDSwapPort(destPort, &savePort); - TkMacOSXSetUpClippingRgn(Tk_WindowId(tkwin)); /* * Create Macintosh control. @@ -416,7 +415,6 @@ MacScaleEventProc( destPort = TkMacOSXGetDrawablePort(Tk_WindowId(macScalePtr->info.tkwin)); portChanged = QDSwapPort(destPort, &savePort); - TkMacOSXSetUpClippingRgn(Tk_WindowId(macScalePtr->info.tkwin)); TkMacOSXWinBounds((TkWindow *) macScalePtr->info.tkwin, &bounds); where.h = eventPtr->xbutton.x + bounds.left; diff --git a/macosx/tkMacOSXWm.c b/macosx/tkMacOSXWm.c index 90e4a70..cbe6f08 100644 --- a/macosx/tkMacOSXWm.c +++ b/macosx/tkMacOSXWm.c @@ -665,7 +665,7 @@ void TkWmNewWindow( TkWindow *winPtr) /* Newly-created top-level window. */ { - WmInfo *wmPtr = ckalloc(sizeof(WmInfo)); + WmInfo *wmPtr = (WmInfo *)ckalloc(sizeof(WmInfo)); wmPtr->winPtr = winPtr; wmPtr->reparent = None; @@ -1065,7 +1065,7 @@ TkWmDeadWindow( void TkWmSetClass( - TkWindow *winPtr) /* Newly-created top-level window. */ + TCL_UNUSED(TkWindow *)) /* Newly-created top-level window. */ { return; } @@ -1087,7 +1087,6 @@ TkWmSetClass( *---------------------------------------------------------------------- */ -/* ARGSUSED */ int Tk_WmObjCmd( ClientData clientData, /* Main window associated with interpreter. */ @@ -1252,7 +1251,7 @@ Tk_WmObjCmd( static int WmAspectCmd( - Tk_Window tkwin, /* Main window of the application. */ + TCL_UNUSED(Tk_Window), /* Main window of the application. */ TkWindow *winPtr, /* Toplevel to work with */ Tcl_Interp *interp, /* Current interpreter. */ int objc, /* Number of arguments. */ @@ -1520,7 +1519,7 @@ WmGetAttribute( static int WmAttributesCmd( - Tk_Window tkwin, /* Main window of the application. */ + TCL_UNUSED(Tk_Window), /* Main window of the application. */ TkWindow *winPtr, /* Toplevel to work with */ Tcl_Interp *interp, /* Current interpreter. */ int objc, /* Number of arguments. */ @@ -1592,7 +1591,7 @@ WmAttributesCmd( static int WmClientCmd( - Tk_Window tkwin, /* Main window of the application. */ + TCL_UNUSED(Tk_Window), /* Main window of the application. */ TkWindow *winPtr, /* Toplevel to work with */ Tcl_Interp *interp, /* Current interpreter. */ int objc, /* Number of arguments. */ @@ -1624,7 +1623,7 @@ WmClientCmd( if (wmPtr->clientMachine != NULL) { ckfree(wmPtr->clientMachine); } - wmPtr->clientMachine = ckalloc(length + 1); + wmPtr->clientMachine = (char *)ckalloc(length + 1); strcpy(wmPtr->clientMachine, argv3); return TCL_OK; } @@ -1681,7 +1680,7 @@ WmColormapwindowsCmd( != TCL_OK) { return TCL_ERROR; } - cmapList = ckalloc((windowObjc+1) * sizeof(TkWindow*)); + cmapList = (TkWindow **)ckalloc((windowObjc+1) * sizeof(TkWindow*)); for (i = 0; i < windowObjc; i++) { if (TkGetWindowFromObj(interp, tkwin, windowObjv[i], (Tk_Window *) &winPtr2) != TCL_OK) { @@ -1737,7 +1736,7 @@ WmColormapwindowsCmd( static int WmCommandCmd( - Tk_Window tkwin, /* Main window of the application. */ + TCL_UNUSED(Tk_Window), /* Main window of the application. */ TkWindow *winPtr, /* Toplevel to work with */ Tcl_Interp *interp, /* Current interpreter. */ int objc, /* Number of arguments. */ @@ -1794,7 +1793,7 @@ WmCommandCmd( static int WmDeiconifyCmd( - Tk_Window tkwin, /* Main window of the application. */ + TCL_UNUSED(Tk_Window), /* Main window of the application. */ TkWindow *winPtr, /* Toplevel to work with */ Tcl_Interp *interp, /* Current interpreter. */ int objc, /* Number of arguments. */ @@ -1872,7 +1871,7 @@ WmDeiconifyCmd( static int WmFocusmodelCmd( - Tk_Window tkwin, /* Main window of the application. */ + TCL_UNUSED(Tk_Window), /* Main window of the application. */ TkWindow *winPtr, /* Toplevel to work with */ Tcl_Interp *interp, /* Current interpreter. */ int objc, /* Number of arguments. */ @@ -1926,11 +1925,11 @@ WmFocusmodelCmd( static int WmForgetCmd( - Tk_Window tkwin, /* Main window of the application. */ + TCL_UNUSED(Tk_Window), /* Main window of the application. */ TkWindow *winPtr, /* Toplevel or Frame to work with */ - Tcl_Interp *interp, /* Current interpreter. */ - int objc, /* Number of arguments. */ - Tcl_Obj *const objv[]) /* Argument objects. */ + TCL_UNUSED(Tcl_Interp *), /* Current interpreter. */ + TCL_UNUSED(int), /* Number of arguments. */ + TCL_UNUSED(Tcl_Obj *const *)) /* Argument objects. */ { Tk_Window frameWin = (Tk_Window) winPtr; @@ -1992,7 +1991,7 @@ WmForgetCmd( static int WmFrameCmd( - Tk_Window tkwin, /* Main window of the application. */ + TCL_UNUSED(Tk_Window), /* Main window of the application. */ TkWindow *winPtr, /* Toplevel to work with */ Tcl_Interp *interp, /* Current interpreter. */ int objc, /* Number of arguments. */ @@ -2034,7 +2033,7 @@ WmFrameCmd( static int WmGeometryCmd( - Tk_Window tkwin, /* Main window of the application. */ + TCL_UNUSED(Tk_Window), /* Main window of the application. */ TkWindow *winPtr, /* Toplevel to work with */ Tcl_Interp *interp, /* Current interpreter. */ int objc, /* Number of arguments. */ @@ -2105,7 +2104,7 @@ WmGeometryCmd( static int WmGridCmd( - Tk_Window tkwin, /* Main window of the application. */ + TCL_UNUSED(Tk_Window), /* Main window of the application. */ TkWindow *winPtr, /* Toplevel to work with */ Tcl_Interp *interp, /* Current interpreter. */ int objc, /* Number of arguments. */ @@ -2238,7 +2237,7 @@ WmGroupCmd( } wmPtr->hints.window_group = Tk_WindowId(tkwin2); wmPtr->hints.flags |= WindowGroupHint; - wmPtr->leaderName = ckalloc(length + 1); + wmPtr->leaderName = (char *)ckalloc(length + 1); strcpy(wmPtr->leaderName, argv3); } return TCL_OK; @@ -2263,7 +2262,7 @@ WmGroupCmd( static int WmIconbitmapCmd( - Tk_Window tkwin, /* Main window of the application. */ + TCL_UNUSED(Tk_Window), /* Main window of the application. */ TkWindow *winPtr, /* Toplevel to work with */ Tcl_Interp *interp, /* Current interpreter. */ int objc, /* Number of arguments. */ @@ -2332,7 +2331,7 @@ WmIconbitmapCmd( static int WmIconifyCmd( - Tk_Window tkwin, /* Main window of the application. */ + TCL_UNUSED(Tk_Window), /* Main window of the application. */ TkWindow *winPtr, /* Toplevel to work with */ Tcl_Interp *interp, /* Current interpreter. */ int objc, /* Number of arguments. */ @@ -2473,7 +2472,7 @@ WmIconmaskCmd( static int WmIconnameCmd( - Tk_Window tkwin, /* Main window of the application. */ + TCL_UNUSED(Tk_Window), /* Main window of the application. */ TkWindow *winPtr, /* Toplevel to work with */ Tcl_Interp *interp, /* Current interpreter. */ int objc, /* Number of arguments. */ @@ -2498,7 +2497,7 @@ WmIconnameCmd( ckfree(wmPtr->iconName); } argv3 = Tcl_GetStringFromObj(objv[3], &length); - wmPtr->iconName = ckalloc(length + 1); + wmPtr->iconName = (char *)ckalloc(length + 1); strcpy(wmPtr->iconName, argv3); if (!(wmPtr->flags & WM_NEVER_MAPPED)) { XSetIconName(winPtr->display, winPtr->window, wmPtr->iconName); @@ -2615,7 +2614,7 @@ WmIconphotoCmd( static int WmIconpositionCmd( - Tk_Window tkwin, /* Main window of the application. */ + TCL_UNUSED(Tk_Window), /* Main window of the application. */ TkWindow *winPtr, /* Toplevel to work with */ Tcl_Interp *interp, /* Current interpreter. */ int objc, /* Number of arguments. */ @@ -2776,11 +2775,11 @@ WmIconwindowCmd( static int WmManageCmd( - Tk_Window tkwin, /* Main window of the application. */ + TCL_UNUSED(Tk_Window), /* Main window of the application. */ TkWindow *winPtr, /* Toplevel or Frame to work with */ Tcl_Interp *interp, /* Current interpreter. */ - int objc, /* Number of arguments. */ - Tcl_Obj *const objv[]) /* Argument objects. */ + TCL_UNUSED(int), /* Number of arguments. */ + TCL_UNUSED(Tcl_Obj *const *)) /* Argument objects. */ { Tk_Window frameWin = (Tk_Window) winPtr; WmInfo *wmPtr = winPtr->wmInfoPtr; @@ -2840,7 +2839,7 @@ WmManageCmd( static int WmMaxsizeCmd( - Tk_Window tkwin, /* Main window of the application. */ + TCL_UNUSED(Tk_Window), /* Main window of the application. */ TkWindow *winPtr, /* Toplevel to work with */ Tcl_Interp *interp, /* Current interpreter. */ int objc, /* Number of arguments. */ @@ -2894,7 +2893,7 @@ WmMaxsizeCmd( static int WmMinsizeCmd( - Tk_Window tkwin, /* Main window of the application. */ + TCL_UNUSED(Tk_Window), /* Main window of the application. */ TkWindow *winPtr, /* Toplevel to work with */ Tcl_Interp *interp, /* Current interpreter. */ int objc, /* Number of arguments. */ @@ -2948,7 +2947,7 @@ WmMinsizeCmd( static int WmOverrideredirectCmd( - Tk_Window tkwin, /* Main window of the application. */ + TCL_UNUSED(Tk_Window), /* Main window of the application. */ TkWindow *winPtr, /* Toplevel to work with */ Tcl_Interp *interp, /* Current interpreter. */ int objc, /* Number of arguments. */ @@ -2997,7 +2996,7 @@ WmOverrideredirectCmd( static int WmPositionfromCmd( - Tk_Window tkwin, /* Main window of the application. */ + TCL_UNUSED(Tk_Window), /* Main window of the application. */ TkWindow *winPtr, /* Toplevel to work with */ Tcl_Interp *interp, /* Current interpreter. */ int objc, /* Number of arguments. */ @@ -3063,7 +3062,7 @@ WmPositionfromCmd( static int WmProtocolCmd( - Tk_Window tkwin, /* Main window of the application. */ + TCL_UNUSED(Tk_Window), /* Main window of the application. */ TkWindow *winPtr, /* Toplevel to work with */ Tcl_Interp *interp, /* Current interpreter. */ int objc, /* Number of arguments. */ @@ -3134,12 +3133,12 @@ WmProtocolCmd( } cmd = Tcl_GetStringFromObj(objv[4], &cmdLength); if (cmdLength > 0) { - protPtr = ckalloc(sizeof(ProtocolHandler)); + protPtr = (ProtocolHandler *)ckalloc(sizeof(ProtocolHandler)); protPtr->protocol = protocol; protPtr->nextPtr = wmPtr->protPtr; wmPtr->protPtr = protPtr; protPtr->interp = interp; - protPtr->command = ckalloc(cmdLength+1); + protPtr->command = (char *)ckalloc(cmdLength+1); strcpy(protPtr->command, cmd); } return TCL_OK; @@ -3164,7 +3163,7 @@ WmProtocolCmd( static int WmResizableCmd( - Tk_Window tkwin, /* Main window of the application. */ + TCL_UNUSED(Tk_Window), /* Main window of the application. */ TkWindow *winPtr, /* Toplevel to work with */ Tcl_Interp *interp, /* Current interpreter. */ int objc, /* Number of arguments. */ @@ -3241,7 +3240,7 @@ WmResizableCmd( static int WmSizefromCmd( - Tk_Window tkwin, /* Main window of the application. */ + TCL_UNUSED(Tk_Window), /* Main window of the application. */ TkWindow *winPtr, /* Toplevel to work with */ Tcl_Interp *interp, /* Current interpreter. */ int objc, /* Number of arguments. */ @@ -3433,7 +3432,7 @@ WmStackorderCmd( static int WmStateCmd( - Tk_Window tkwin, /* Main window of the application. */ + TCL_UNUSED(Tk_Window), /* Main window of the application. */ TkWindow *winPtr, /* Toplevel to work with */ Tcl_Interp *interp, /* Current interpreter. */ int objc, /* Number of arguments. */ @@ -3553,7 +3552,7 @@ WmStateCmd( static int WmTitleCmd( - Tk_Window tkwin, /* Main window of the application. */ + TCL_UNUSED(Tk_Window), /* Main window of the application. */ TkWindow *winPtr, /* Toplevel to work with */ Tcl_Interp *interp, /* Current interpreter. */ int objc, /* Number of arguments. */ @@ -3681,7 +3680,7 @@ WmTransientCmd( transient != NULL && transient->winPtr != winPtr; transient = transient->nextPtr) {} if (transient == NULL) { - transient = ckalloc(sizeof(Transient)); + transient = (Transient *)ckalloc(sizeof(Transient)); transient->winPtr = winPtr; transient->flags = 0; transient->nextPtr = wmPtr2->transientPtr; @@ -3781,7 +3780,7 @@ RemoveTransient( static int WmWithdrawCmd( - Tk_Window tkwin, /* Main window of the application. */ + TCL_UNUSED(Tk_Window), /* Main window of the application. */ TkWindow *winPtr, /* Toplevel to work with */ Tcl_Interp *interp, /* Current interpreter. */ int objc, /* Number of arguments. */ @@ -4069,10 +4068,9 @@ TopLevelEventProc( *---------------------------------------------------------------------- */ - /* ARGSUSED */ static void TopLevelReqProc( - ClientData dummy, /* Not used. */ + TCL_UNUSED(void *), /* Not used. */ Tk_Window tkwin) /* Information about window. */ { TkWindow *winPtr = (TkWindow *) tkwin; @@ -5095,7 +5093,7 @@ TkWmAddToColormapWindows( * add the toplevel itself as the last element of the list. */ - newPtr = ckalloc((count+2) * sizeof(TkWindow *)); + newPtr = (TkWindow **)ckalloc((count+2) * sizeof(TkWindow *)); if (count > 0) { memcpy(newPtr, oldPtr, count * sizeof(TkWindow *)); } @@ -5207,7 +5205,7 @@ TkWmRemoveFromColormapWindows( void TkGetPointerCoords( - Tk_Window tkwin, /* Toplevel window that identifies screen on + TCL_UNUSED(Tk_Window), /* Toplevel window that identifies screen on * which lookup is to be done. */ int *xPtr, int *yPtr) /* Store pointer coordinates here. */ { @@ -5315,8 +5313,8 @@ TkMacOSXResizable( int TkMacOSXGrowToplevel( - void *whichWindow, - XPoint start) + TCL_UNUSED(void *), + TCL_UNUSED(XPoint)) { return false; } @@ -5533,7 +5531,6 @@ TkMacOSXZoomToplevel( *---------------------------------------------------------------------- */ -/* ARGSUSED */ int TkUnsupported1ObjCmd( ClientData clientData, /* Main window associated with interpreter. */ @@ -5669,14 +5666,14 @@ WmWinStyle( { "altPlain", kAltPlainWindowClass }, { "simple", kSimpleWindowClass }, { "drawer", kDrawerWindowClass }, - { NULL } + { NULL, 0 } }; static const struct StrIntMap compositeAttrMap[] = { { "none", kWindowNoAttributes }, { "standardDocument", kWindowStandardDocumentAttributes }, { "standardFloating", kWindowStandardFloatingAttributes }, { "fullZoom", kWindowFullZoomAttribute }, - { NULL } + { NULL, 0 } }; /* @@ -5713,7 +5710,7 @@ WmWinStyle( { "moveToActiveSpace", tkMoveToActiveSpaceAttribute }, { "nonActivating", tkNonactivatingPanelAttribute }, { "hud", tkHUDWindowAttribute }, - { NULL } + { NULL, 0 } }; int index, i; @@ -6557,10 +6554,10 @@ TkpGetMS(void) int XSetInputFocus( - Display* display, - Window focus, - int revert_to, - Time time) + TCL_UNUSED(Display *), + TCL_UNUSED(Window), + TCL_UNUSED(int), + TCL_UNUSED(Time)) { /* * Don't need to do a thing. Tk manages the focus for us. @@ -6695,7 +6692,7 @@ TkWmStackorderToplevel( NSArray* backToFront = [[macWindows reverseObjectEnumerator] allObjects]; NSInteger windowCount = [macWindows count]; - windows = windowPtr = ckalloc((windowCount + 1) * sizeof(TkWindow *)); + windows = windowPtr = (TkWindow **)ckalloc((windowCount + 1) * sizeof(TkWindow *)); if (windows != NULL) { Tcl_InitHashTable(&table, TCL_ONE_WORD_KEYS); WmStackorderToplevelWrapperMap(parentPtr, parentPtr->display, &table); -- cgit v0.12 From c24b589a6b793f5112cd11f613af9aa7ae10b55f Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Thu, 6 Aug 2020 16:16:16 +0000 Subject: Add stub entry for XLowerWindow() on MacOS (no idea why this was commented out, windows and X11 already had this) More use of TCL_UNUSED() --- generic/tkInt.decls | 3 +++ generic/tkIntXlibDecls.h | 8 +++++--- generic/tkStubInit.c | 2 +- macosx/tkMacOSXBitmap.c | 10 +++++----- macosx/tkMacOSXClipboard.c | 8 ++++---- macosx/tkMacOSXServices.c | 15 +++++++++------ macosx/tkMacOSXSubwindows.c | 19 +++++++++---------- macosx/tkMacOSXTest.c | 17 ++++++++--------- macosx/ttkMacOSXTheme.c | 6 +++--- 9 files changed, 47 insertions(+), 41 deletions(-) diff --git a/generic/tkInt.decls b/generic/tkInt.decls index f6e7ea9..37557f5 100644 --- a/generic/tkInt.decls +++ b/generic/tkInt.decls @@ -1844,6 +1844,9 @@ declare 112 aqua { declare 114 aqua { VisualID XVisualIDFromVisual(Visual *visual) } +declare 129 aqua { + int XLowerWindow(Display *d, Window w) +} declare 137 aqua { int XPutImage(Display *d, Drawable dr, GC gc, XImage *im, int sx, int sy, int dx, int dy, diff --git a/generic/tkIntXlibDecls.h b/generic/tkIntXlibDecls.h index f1b0018..7626d9d 100644 --- a/generic/tkIntXlibDecls.h +++ b/generic/tkIntXlibDecls.h @@ -743,7 +743,8 @@ EXTERN VisualID XVisualIDFromVisual(Visual *visual); /* Slot 126 is reserved */ /* Slot 127 is reserved */ /* Slot 128 is reserved */ -/* Slot 129 is reserved */ +/* 129 */ +EXTERN int XLowerWindow(Display *d, Window w); /* Slot 130 is reserved */ /* Slot 131 is reserved */ /* Slot 132 is reserved */ @@ -1074,7 +1075,7 @@ typedef struct TkIntXlibStubs { void (*reserved126)(void); void (*reserved127)(void); void (*reserved128)(void); - void (*reserved129)(void); + int (*xLowerWindow) (Display *d, Window w); /* 129 */ void (*reserved130)(void); void (*reserved131)(void); void (*reserved132)(void); @@ -1636,7 +1637,8 @@ extern const TkIntXlibStubs *tkIntXlibStubsPtr; /* Slot 126 is reserved */ /* Slot 127 is reserved */ /* Slot 128 is reserved */ -/* Slot 129 is reserved */ +#define XLowerWindow \ + (tkIntXlibStubsPtr->xLowerWindow) /* 129 */ /* Slot 130 is reserved */ /* Slot 131 is reserved */ /* Slot 132 is reserved */ diff --git a/generic/tkStubInit.c b/generic/tkStubInit.c index 4abc637..836f1d1 100644 --- a/generic/tkStubInit.c +++ b/generic/tkStubInit.c @@ -962,7 +962,7 @@ static const TkIntXlibStubs tkIntXlibStubs = { 0, /* 126 */ 0, /* 127 */ 0, /* 128 */ - 0, /* 129 */ + XLowerWindow, /* 129 */ 0, /* 130 */ 0, /* 131 */ 0, /* 132 */ diff --git a/macosx/tkMacOSXBitmap.c b/macosx/tkMacOSXBitmap.c index 2b08235..c1b325a 100644 --- a/macosx/tkMacOSXBitmap.c +++ b/macosx/tkMacOSXBitmap.c @@ -44,7 +44,7 @@ static BuiltInIcon builtInIcons[] = { {"stop", kAlertStopIcon}, {"note", kAlertNoteIcon}, {"caution", kAlertCautionIcon}, - {NULL} + {NULL, 0} }; #define builtInIconSize 32 @@ -100,7 +100,7 @@ TkpDefineNativeBitmaps(void) name = Tk_GetUid(builtInPtr->name); predefHashPtr = Tcl_CreateHashEntry(tablePtr, name, &isNew); if (isNew) { - TkPredefBitmap *predefPtr = ckalloc(sizeof(TkPredefBitmap)); + TkPredefBitmap *predefPtr = (TkPredefBitmap *)ckalloc(sizeof(TkPredefBitmap)); predefPtr->source = UINT2PTR(builtInPtr->iconType); predefPtr->width = builtInIconSize; @@ -343,7 +343,7 @@ TkpGetNativeAppBitmap( int TkMacOSXIconBitmapObjCmd( - ClientData clientData, /* Unused. */ + TCL_UNUSED(void *), Tcl_Interp *interp, /* Current interpreter. */ int objc, /* Number of arguments. */ Tcl_Obj *const objv[]) /* Argument objects. */ @@ -398,7 +398,7 @@ TkMacOSXIconBitmapObjCmd( } } #endif - ib.value = ckalloc(len + 1); + ib.value = (char *)ckalloc(len + 1); strcpy(ib.value, value); if (!iconBitmapTable.buckets) { Tcl_InitHashTable(&iconBitmapTable, TCL_STRING_KEYS); @@ -408,7 +408,7 @@ TkMacOSXIconBitmapObjCmd( iconBitmap = Tcl_GetHashValue(hPtr); ckfree(iconBitmap->value); } else { - iconBitmap = ckalloc(sizeof(IconBitmap)); + iconBitmap = (IconBitmap *)ckalloc(sizeof(IconBitmap)); Tcl_SetHashValue(hPtr, iconBitmap); } *iconBitmap = ib; diff --git a/macosx/tkMacOSXClipboard.c b/macosx/tkMacOSXClipboard.c index be1f16c..bae2b89 100644 --- a/macosx/tkMacOSXClipboard.c +++ b/macosx/tkMacOSXClipboard.c @@ -177,7 +177,7 @@ XSetSelectionOwner( Display *display, /* X Display. */ Atom selection, /* What selection to own. */ Window owner, /* Window to be the owner. */ - Time time) /* The current time? */ + TCL_UNUSED(Time)) /* The current time? */ { TkDisplay *dispPtr = TkGetDisplayList(); @@ -237,8 +237,8 @@ TkMacOSXSelDeadWindow( void TkSelUpdateClipboard( - TkWindow *winPtr, /* Window associated with clipboard. */ - TkClipboardTarget *targetPtr) + TCL_UNUSED(TkWindow *), /* Window associated with clipboard. */ + TCL_UNUSED(TkClipboardTarget *)) /* Info about the content. */ { NSPasteboard *pb = [NSPasteboard generalPasteboard]; @@ -294,7 +294,7 @@ TkSelEventProc( void TkSelPropProc( - XEvent *eventPtr) /* X PropertyChange event. */ + TCL_UNUSED(XEvent *)) /* X PropertyChange event. */ { } diff --git a/macosx/tkMacOSXServices.c b/macosx/tkMacOSXServices.c index 0434f10..59e3439 100644 --- a/macosx/tkMacOSXServices.c +++ b/macosx/tkMacOSXServices.c @@ -20,10 +20,11 @@ static int ServicesEventProc( - Tcl_Event *event, - int flags) + TCL_UNUSED(Tcl_Event *), + TCL_UNUSED(int)) { TkMainInfo *info = TkGetMainInfoList(); + Tcl_GlobalEval(info->interp, "::tk::mac::PerformService"); return 1; } @@ -43,8 +44,8 @@ ServicesEventProc( - (void) provideService:(NSPasteboard *)pboard userData:(NSString *)data error:(NSString **)error; -- (BOOL)writeSelectionToPasteboard:(NSPasteboard *)pboard - types:(NSArray *)types; +- (BOOL) writeSelectionToPasteboard:(NSPasteboard *)pboard + types:(NSArray *)types; @end @@ -104,6 +105,8 @@ ServicesEventProc( NSString *pboardString = nil, *pboardType = nil; NSArray *types = [pboard types]; Tcl_Event *event; + (void)data; + (void)error; /* * Get a string from the private pasteboard and copy it to the general @@ -123,7 +126,7 @@ ServicesEventProc( [generalpasteboard declareTypes:[NSArray arrayWithObjects:pboardType, nil] owner:nil]; [generalpasteboard setString:pboardString forType:pboardType]; - event = ckalloc(sizeof(Tcl_Event)); + event = (Tcl_Event *)ckalloc(sizeof(Tcl_Event)); event->proc = ServicesEventProc; Tcl_QueueEvent((Tcl_Event *)event, TCL_QUEUE_TAIL); } @@ -137,7 +140,7 @@ ServicesEventProc( int TkMacOSXServices_Init( - Tcl_Interp *interp) + TCL_UNUSED(Tcl_Interp *)) { /* * Initialize an instance of TkService and register it with the NSApp. diff --git a/macosx/tkMacOSXSubwindows.c b/macosx/tkMacOSXSubwindows.c index 8b316fa..899832b 100644 --- a/macosx/tkMacOSXSubwindows.c +++ b/macosx/tkMacOSXSubwindows.c @@ -51,7 +51,7 @@ static void NotifyVisibility(TkWindow *winPtr, XEvent *eventPtr); int XDestroyWindow( - Display *display, /* Display. */ + TCL_UNUSED(Display *), /* Display. */ Window window) /* Window. */ { MacDrawable *macWin = (MacDrawable *) window; @@ -633,7 +633,6 @@ XRaiseWindow( return Success; } -#if 0 /* *---------------------------------------------------------------------- * @@ -650,7 +649,7 @@ XRaiseWindow( *---------------------------------------------------------------------- */ -void +int XLowerWindow( Display *display, /* Display. */ Window window) /* Window. */ @@ -661,12 +660,12 @@ XLowerWindow( if (Tk_IsTopLevel(macWin->winPtr) && !Tk_IsEmbedded(macWin->winPtr)) { TkWmRestackToplevel(macWin->winPtr, Below, NULL); } else { - /* + /* * TODO: this should generate damage */ } + return Success; } -#endif /* *---------------------------------------------------------------------- @@ -691,7 +690,7 @@ XConfigureWindow( Display *display, /* Display. */ Window w, /* Window. */ unsigned int value_mask, - XWindowChanges *values) + TCL_UNUSED(XWindowChanges *)) { MacDrawable *macWin = (MacDrawable *) w; TkWindow *winPtr = macWin->winPtr; @@ -999,7 +998,7 @@ TkMacOSXVisableClipRgn( static OSStatus InvalViewRect( int msg, - HIShapeRef rgn, + TCL_UNUSED(HIShapeRef), const CGRect *rect, void *ref) { @@ -1134,7 +1133,7 @@ TkMacOSXDrawable( void * TkMacOSXGetDrawablePort( - Drawable drawable) + TCL_UNUSED(Drawable)) { return NULL; } @@ -1462,7 +1461,7 @@ UpdateOffsets( Pixmap Tk_GetPixmap( Display *display, /* Display for new pixmap (can be null). */ - Drawable d, /* Drawable where pixmap will be used (ignored). */ + TCL_UNUSED(Drawable), /* Drawable where pixmap will be used (ignored). */ int width, /* Dimensions of pixmap. */ int height, int depth) /* Bits per pixel for pixmap. */ @@ -1472,7 +1471,7 @@ Tk_GetPixmap( if (display != NULL) { display->request++; } - macPix = ckalloc(sizeof(MacDrawable)); + macPix = (MacDrawable *)ckalloc(sizeof(MacDrawable)); macPix->winPtr = NULL; macPix->xOff = 0; macPix->yOff = 0; diff --git a/macosx/tkMacOSXTest.c b/macosx/tkMacOSXTest.c index e5dcf5e..c70ecd5 100644 --- a/macosx/tkMacOSXTest.c +++ b/macosx/tkMacOSXTest.c @@ -26,11 +26,11 @@ static int DebuggerObjCmd (ClientData dummy, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]); #endif static int PressButtonObjCmd (ClientData dummy, Tcl_Interp *interp, - int objc, Tcl_Obj *const objv[]); + int objc, Tcl_Obj *const *objv); static int InjectKeyEventObjCmd (ClientData dummy, Tcl_Interp *interp, - int objc, Tcl_Obj *const objv[]); + int objc, Tcl_Obj *const *objv); static int MenuBarHeightObjCmd (ClientData dummy, Tcl_Interp *interp, - int objc, Tcl_Obj *const objv[]); + int objc, Tcl_Obj *const *objv); /* @@ -117,10 +117,10 @@ DebuggerObjCmd( static int MenuBarHeightObjCmd( - ClientData clientData, /* Not used. */ + TCL_UNUSED(void *), /* Not used. */ Tcl_Interp *interp, /* Not used. */ - int objc, /* Not used. */ - Tcl_Obj *const objv[]) /* Not used. */ + TCL_UNUSED(int), /* Not used. */ + TCL_UNUSED(Tcl_Obj *const *)) /* Not used. */ { static int height = 0; if (height == 0) { @@ -188,10 +188,9 @@ TkTestLogDisplay( *---------------------------------------------------------------------- */ - /* ARGSUSED */ static int PressButtonObjCmd( - ClientData clientData, + TCL_UNUSED(void *), Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]) @@ -267,7 +266,7 @@ PressButtonObjCmd( static int InjectKeyEventObjCmd( - ClientData clientData, + TCL_UNUSED(ClientData), Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]) diff --git a/macosx/ttkMacOSXTheme.c b/macosx/ttkMacOSXTheme.c index f1b7b8e..b0be4e9 100644 --- a/macosx/ttkMacOSXTheme.c +++ b/macosx/ttkMacOSXTheme.c @@ -250,7 +250,7 @@ static CGFloat blackRGBA[4] = {0.0, 0.0, 0.0, 1.0}; */ static void GetBackgroundColor( - CGContextRef context, + TCL_UNUSED(CGContextRef), Tk_Window tkwin, int contrast, CGFloat *rgba) @@ -1039,7 +1039,7 @@ static void DrawDarkTab( static void DrawDarkSeparator( CGRect bounds, CGContextRef context, - Tk_Window tkwin) + TCL_UNUSED(Tk_Window)) { static CGFloat fill[4] = {1.0, 1.0, 1.0, 0.3}; NSColorSpace *deviceRGB = [NSColorSpace deviceRGBColorSpace]; @@ -1165,7 +1165,7 @@ static void DrawDarkFrame( static void DrawDarkListHeader( CGRect bounds, CGContextRef context, - Tk_Window tkwin, + TCL_UNUSED(Tk_Window), int state) { NSColorSpace *deviceRGB = [NSColorSpace deviceRGBColorSpace]; -- cgit v0.12 From c28292a3923e7c09df16322a73d4b53eaff74b79 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Tue, 11 Aug 2020 11:40:07 +0000 Subject: Add 3 more stub entries to MacOSX X11 stub table, which win32 already has: XDestroyIC(), XCreatePixmapCursor(), XCreateGlyphCursor() --- generic/tkInt.decls | 12 ++ generic/tkIntXlibDecls.h | 28 ++-- generic/tkStubInit.c | 6 +- win/stubs.c | 224 ++++++++++++++++++++++----- xlib/xgc.c | 382 +++++++++++++++++++++++++++++++++++++++++++---- 5 files changed, 571 insertions(+), 81 deletions(-) diff --git a/generic/tkInt.decls b/generic/tkInt.decls index 37557f5..14ab250 100644 --- a/generic/tkInt.decls +++ b/generic/tkInt.decls @@ -1852,6 +1852,18 @@ declare 137 aqua { int sx, int sy, int dx, int dy, unsigned int w, unsigned int h) } +declare 144 aqua { + void XDestroyIC(XIC xic) +} +declare 145 aqua { + Cursor XCreatePixmapCursor(Display *d, Pixmap p1, Pixmap p2, + XColor *x1, XColor *x2, unsigned int ui1, unsigned int ui2) +} +declare 146 aqua { + Cursor XCreateGlyphCursor(Display *d, Font f1, Font f2, + unsigned int ui1, unsigned int ui2, XColor _Xconst *x1, + XColor _Xconst *x2) +} declare 158 aqua { void TkUnusedStubEntry(void) } diff --git a/generic/tkIntXlibDecls.h b/generic/tkIntXlibDecls.h index 7626d9d..7c5d815 100644 --- a/generic/tkIntXlibDecls.h +++ b/generic/tkIntXlibDecls.h @@ -762,9 +762,16 @@ EXTERN int XPutImage(Display *d, Drawable dr, GC gc, XImage *im, /* Slot 141 is reserved */ /* Slot 142 is reserved */ /* Slot 143 is reserved */ -/* Slot 144 is reserved */ -/* Slot 145 is reserved */ -/* Slot 146 is reserved */ +/* 144 */ +EXTERN void XDestroyIC(XIC xic); +/* 145 */ +EXTERN Cursor XCreatePixmapCursor(Display *d, Pixmap p1, Pixmap p2, + XColor *x1, XColor *x2, unsigned int ui1, + unsigned int ui2); +/* 146 */ +EXTERN Cursor XCreateGlyphCursor(Display *d, Font f1, Font f2, + unsigned int ui1, unsigned int ui2, + XColor _Xconst *x1, XColor _Xconst *x2); /* Slot 147 is reserved */ /* Slot 148 is reserved */ /* Slot 149 is reserved */ @@ -1090,9 +1097,9 @@ typedef struct TkIntXlibStubs { void (*reserved141)(void); void (*reserved142)(void); void (*reserved143)(void); - void (*reserved144)(void); - void (*reserved145)(void); - void (*reserved146)(void); + void (*xDestroyIC) (XIC xic); /* 144 */ + Cursor (*xCreatePixmapCursor) (Display *d, Pixmap p1, Pixmap p2, XColor *x1, XColor *x2, unsigned int ui1, unsigned int ui2); /* 145 */ + Cursor (*xCreateGlyphCursor) (Display *d, Font f1, Font f2, unsigned int ui1, unsigned int ui2, XColor _Xconst *x1, XColor _Xconst *x2); /* 146 */ void (*reserved147)(void); void (*reserved148)(void); void (*reserved149)(void); @@ -1654,9 +1661,12 @@ extern const TkIntXlibStubs *tkIntXlibStubsPtr; /* Slot 141 is reserved */ /* Slot 142 is reserved */ /* Slot 143 is reserved */ -/* Slot 144 is reserved */ -/* Slot 145 is reserved */ -/* Slot 146 is reserved */ +#define XDestroyIC \ + (tkIntXlibStubsPtr->xDestroyIC) /* 144 */ +#define XCreatePixmapCursor \ + (tkIntXlibStubsPtr->xCreatePixmapCursor) /* 145 */ +#define XCreateGlyphCursor \ + (tkIntXlibStubsPtr->xCreateGlyphCursor) /* 146 */ /* Slot 147 is reserved */ /* Slot 148 is reserved */ /* Slot 149 is reserved */ diff --git a/generic/tkStubInit.c b/generic/tkStubInit.c index 836f1d1..ab8b675 100644 --- a/generic/tkStubInit.c +++ b/generic/tkStubInit.c @@ -977,9 +977,9 @@ static const TkIntXlibStubs tkIntXlibStubs = { 0, /* 141 */ 0, /* 142 */ 0, /* 143 */ - 0, /* 144 */ - 0, /* 145 */ - 0, /* 146 */ + XDestroyIC, /* 144 */ + XCreatePixmapCursor, /* 145 */ + XCreateGlyphCursor, /* 146 */ 0, /* 147 */ 0, /* 148 */ 0, /* 149 */ diff --git a/win/stubs.c b/win/stubs.c index 884186c..faeac08 100644 --- a/win/stubs.c +++ b/win/stubs.c @@ -1,4 +1,4 @@ -#include "tk.h" +#include "tkInt.h" /* * Undocumented Xlib internal function @@ -8,6 +8,8 @@ int _XInitImageFuncPtrs( XImage *image) { + (void)image; + return Success; } @@ -21,6 +23,9 @@ XSetWMClientMachine( Window w, XTextProperty *text_prop) { + (void)display; + (void)w; + (void)text_prop; } Status @@ -29,7 +34,11 @@ XStringListToTextProperty( int count, XTextProperty *text_prop_return) { - return (Status) 0; + (void)list; + (void)count; + (void)text_prop_return; + + return Success; } /* @@ -47,54 +56,36 @@ XChangeProperty( _Xconst unsigned char *data, int nelements) { - return Success; -} + (void)display; + (void)w; + (void)property; + (void)type; + (void)format; + (void)mode; + (void)data; + (void)nelements; -Cursor -XCreateGlyphCursor( - Display *display, - Font source_font, - Font mask_font, - unsigned int source_char, - unsigned int mask_char, - XColor _Xconst *foreground_color, - XColor _Xconst *background_color) -{ - return 1; + return Success; } XIC XCreateIC(XIM xim, ...) { + (void)xim; return NULL; } -Cursor -XCreatePixmapCursor( - Display *display, - Pixmap source, - Pixmap mask, - XColor *foreground_color, - XColor *background_color, - unsigned int x, - unsigned int y) -{ - return (Cursor) NULL; -} - int XDeleteProperty( Display *display, Window w, Atom property) { - return Success; -} + (void)display; + (void)w; + (void)property; -void -XDestroyIC( - XIC ic) -{ + return Success; } Bool @@ -102,6 +93,9 @@ XFilterEvent( XEvent *event, Window window) { + (void)event; + (void)window; + return 0; } @@ -110,6 +104,9 @@ XForceScreenSaver( Display *display, int mode) { + (void)display; + (void)mode; + return Success; } @@ -118,6 +115,9 @@ XFreeCursor( Display *display, Cursor cursor) { + (void)display; + (void)cursor; + return Success; } @@ -125,6 +125,8 @@ GContext XGContextFromGC( GC gc) { + (void)gc; + return (GContext) NULL; } @@ -133,6 +135,9 @@ XGetAtomName( Display *display, Atom atom) { + (void)display; + (void)atom; + return NULL; } @@ -142,6 +147,10 @@ XGetWindowAttributes( Window w, XWindowAttributes *window_attributes_return) { + (void)display; + (void)w; + (void)window_attributes_return; + return Success; } @@ -152,7 +161,12 @@ XGetWMColormapWindows( Window **windows_return, int *count_return) { - return (Status) 0; + (void)display; + (void)w; + (void)windows_return; + (void)count_return; + + return Success; } int @@ -161,6 +175,10 @@ XIconifyWindow( Window w, int screen_number) { + (void)display; + (void)w; + (void)screen_number; + return Success; } @@ -170,6 +188,10 @@ XListHosts( int *nhosts_return, Bool *state_return) { + (void)display; + (void)nhosts_return; + (void)state_return; + return NULL; } @@ -181,6 +203,12 @@ XLookupColor( XColor *exact_def_return, XColor *screen_def_return) { + (void)display; + (void)colormap; + (void)color_name; + (void)exact_def_return; + (void)screen_def_return; + return Success; } @@ -189,6 +217,9 @@ XNextEvent( Display *display, XEvent *event_return) { + (void)display; + (void)event_return; + return Success; } @@ -197,6 +228,9 @@ XPutBackEvent( Display *display, XEvent *event) { + (void)display; + (void)event; + return Success; } @@ -207,6 +241,11 @@ XQueryColors( XColor *defs_in_out, int ncolors) { + (void)display; + (void)colormap; + (void)defs_in_out; + (void)ncolors; + return Success; } @@ -219,6 +258,13 @@ XQueryTree( Window **children_return, unsigned int *nchildren_return) { + (void)display; + (void)w; + (void)root_return; + (void)parent_return; + (void)children_return; + (void)nchildren_return; + return Success; } @@ -226,6 +272,8 @@ int XRefreshKeyboardMapping( XMappingEvent *event_map) { + (void)event_map; + return Success; } @@ -234,6 +282,9 @@ XRootWindow( Display *display, int screen_number) { + (void)display; + (void)screen_number; + return (Window) NULL; } @@ -243,6 +294,10 @@ XSelectInput( Window w, long event_mask) { + (void)display; + (void)w; + (void)event_mask; + return Success; } @@ -254,6 +309,12 @@ XSendEvent( long event_mask, XEvent *event_send) { + (void)display; + (void)w; + (void)propagate; + (void)event_mask; + (void)event_send; + return Success; } @@ -264,6 +325,11 @@ XSetCommand( char **argv, int argc) { + (void)display; + (void)w; + (void)argv; + (void)argc; + return Success; } @@ -271,6 +337,8 @@ XErrorHandler XSetErrorHandler( XErrorHandler handler) { + (void)handler; + return NULL; } @@ -280,6 +348,10 @@ XSetIconName( Window w, _Xconst char *icon_name) { + (void)display; + (void)w; + (void)icon_name; + return Success; } @@ -289,6 +361,10 @@ XSetWindowBackground( Window w, unsigned long background_pixel) { + (void)display; + (void)w; + (void)background_pixel; + return Success; } @@ -298,6 +374,10 @@ XSetWindowBackgroundPixmap( Window w, Pixmap background_pixmap) { + (void)display; + (void)w; + (void)background_pixmap; + return Success; } @@ -307,6 +387,10 @@ XSetWindowBorder( Window w, unsigned long border_pixel) { + (void)display; + (void)w; + (void)border_pixel; + return Success; } @@ -316,6 +400,10 @@ XSetWindowBorderPixmap( Window w, Pixmap border_pixmap) { + (void)display; + (void)w; + (void)border_pixmap; + return Success; } @@ -325,6 +413,10 @@ XSetWindowBorderWidth( Window w, unsigned int width) { + (void)display; + (void)w; + (void)width; + return Success; } @@ -334,6 +426,10 @@ XSetWindowColormap( Window w, Colormap colormap) { + (void)display; + (void)w; + (void)colormap; + return Success; } @@ -348,6 +444,15 @@ XTranslateCoordinates( int *dest_y_return, Window *child_return) { + (void)display; + (void)src_w; + (void)dest_w; + (void)src_x; + (void)src_y; + (void)dest_x_return; + (void)dest_y_return; + (void)child_return; + return 0; } @@ -358,6 +463,11 @@ XWindowEvent( long event_mask, XEvent *event_return) { + (void)display; + (void)w; + (void)event_mask; + (void)event_return; + return Success; } @@ -367,6 +477,10 @@ XWithdrawWindow( Window w, int screen_number) { + (void)display; + (void)w; + (void)screen_number; + return Success; } @@ -379,6 +493,13 @@ XmbLookupString( KeySym *keysym_return, Status *status_return) { + (void)ic; + (void)event; + (void)buffer_return; + (void)bytes_buffer; + (void)keysym_return; + (void)status_return; + return Success; } @@ -389,7 +510,7 @@ XGetWindowProperty( Atom property, long long_offset, long long_length, - Bool delete, + Bool del, Atom req_type, Atom *actual_type_return, int *actual_format_return, @@ -397,6 +518,14 @@ XGetWindowProperty( unsigned long *bytes_after_return, unsigned char **prop_return) { + (void)display; + (void)w; + (void)property; + (void)long_offset; + (void)long_length; + (void)del; + (void)req_type; + *actual_type_return = None; *actual_format_return = 0; *nitems_return = 0; @@ -413,6 +542,8 @@ int XFlush( Display *display) { + (void)display; + return 0; } @@ -420,6 +551,8 @@ int XGrabServer( Display *display) { + (void)display; + return 0; } @@ -427,6 +560,8 @@ int XUngrabServer( Display *display) { + (void)display; + return 0; } @@ -453,6 +588,8 @@ XSynchronize( Display *display, Bool onoff) { + (void)onoff; + display->request++; return NULL; } @@ -462,6 +599,8 @@ XSync( Display *display, Bool discard) { + (void)discard; + display->request++; return 0; } @@ -472,3 +611,16 @@ XVisualIDFromVisual( { return visual->visualid; } + +int +XOffsetRegion( + Region rgn, + int dx, + int dy) +{ + (void)rgn; + (void)dx; + (void)dy; + + return 0; +} diff --git a/xlib/xgc.c b/xlib/xgc.c index e2fdf52..013ee63 100644 --- a/xlib/xgc.c +++ b/xlib/xgc.c @@ -51,7 +51,7 @@ static TkpClipMask *AllocClipMask(GC gc) { TkpClipMask *clip_mask = (TkpClipMask*) gc->clip_mask; if (clip_mask == NULL) { - clip_mask = ckalloc(sizeof(TkpClipMask)); + clip_mask = (TkpClipMask *)ckalloc(sizeof(TkpClipMask)); gc->clip_mask = (Pixmap) clip_mask; #ifdef MAC_OSX_TK } else if (clip_mask->type == TKP_CLIP_REGION) { @@ -84,7 +84,7 @@ static void FreeClipMask(GC gc) { TkpReleaseRegion(((TkpClipMask*) gc->clip_mask)->value.region); } #endif - ckfree(gc->clip_mask); + ckfree((char *)gc->clip_mask); gc->clip_mask = None; } } @@ -113,6 +113,7 @@ XCreateGC( XGCValues *values) { GC gp; + (void)d; /* * In order to have room for a dash list, MAX_DASH_LIST_SIZE extra chars @@ -123,7 +124,7 @@ XCreateGC( #define MAX_DASH_LIST_SIZE 10 - gp = ckalloc(sizeof(XGCValues) + MAX_DASH_LIST_SIZE + gcCacheSize); + gp = (GC)ckalloc(sizeof(XGCValues) + MAX_DASH_LIST_SIZE + gcCacheSize); if (!gp) { return NULL; } @@ -144,11 +145,11 @@ XCreateGC( InitField(fill_style, GCFillStyle, FillSolid); InitField(fill_rule, GCFillRule, WindingRule); InitField(arc_mode, GCArcMode, ArcPieSlice); - InitField(tile, GCTile, None); - InitField(stipple, GCStipple, None); + InitField(tile, GCTile, 0); + InitField(stipple, GCStipple, 0); InitField(ts_x_origin, GCTileStipXOrigin, 0); InitField(ts_y_origin, GCTileStipYOrigin, 0); - InitField(font, GCFont, None); + InitField(font, GCFont, 0); InitField(subwindow_mode, GCSubwindowMode, ClipByChildren); InitField(graphics_exposures, GCGraphicsExposures, True); InitField(clip_x_origin, GCClipXOrigin, 0); @@ -268,6 +269,8 @@ int XFreeGC( Display *d, GC gc) { + (void)d; + if (gc != NULL) { FreeClipMask(gc); TkpFreeGCCache(gc); @@ -299,6 +302,8 @@ XSetForeground( GC gc, unsigned long foreground) { + (void)display; + gc->foreground = foreground; return Success; } @@ -309,6 +314,8 @@ XSetBackground( GC gc, unsigned long background) { + (void)display; + gc->background = background; return Success; } @@ -322,6 +329,7 @@ XSetDashes( int n) { char *p = &(gc->dashes); + (void)display; #ifdef TkWinDeleteBrush TkWinDeleteBrush(gc->fgBrush); @@ -344,6 +352,8 @@ XSetFunction( GC gc, int function) { + (void)display; + gc->function = function; return Success; } @@ -354,6 +364,8 @@ XSetFillRule( GC gc, int fill_rule) { + (void)display; + gc->fill_rule = fill_rule; return Success; } @@ -364,6 +376,8 @@ XSetFillStyle( GC gc, int fill_style) { + (void)display; + gc->fill_style = fill_style; return Success; } @@ -374,6 +388,8 @@ XSetTSOrigin( GC gc, int x, int y) { + (void)display; + gc->ts_x_origin = x; gc->ts_y_origin = y; return Success; @@ -385,6 +401,8 @@ XSetFont( GC gc, Font font) { + (void)display; + gc->font = font; return Success; } @@ -395,6 +413,8 @@ XSetArcMode( GC gc, int arc_mode) { + (void)display; + gc->arc_mode = arc_mode; return Success; } @@ -405,6 +425,8 @@ XSetStipple( GC gc, Pixmap stipple) { + (void)display; + gc->stipple = stipple; return Success; } @@ -418,6 +440,8 @@ XSetLineAttributes( int cap_style, int join_style) { + (void)display; + gc->line_width = line_width; gc->line_style = line_style; gc->cap_style = cap_style; @@ -432,6 +456,8 @@ XSetClipOrigin( int clip_x_origin, int clip_y_origin) { + (void)display; + gc->clip_x_origin = clip_x_origin; gc->clip_y_origin = clip_y_origin; return Success; @@ -464,6 +490,8 @@ TkSetRegion( GC gc, TkRegion r) { + (void)display; + if (r == NULL) { Tcl_Panic("must not pass NULL to TkSetRegion for compatibility with X11; use XSetClipMask instead"); } else { @@ -484,6 +512,8 @@ XSetClipMask( GC gc, Pixmap pixmap) { + (void)display; + if (pixmap == None) { FreeClipMask(gc); } else { @@ -542,6 +572,7 @@ XDrawPoints( int mode) { int res = Success; + (void)mode; while (npoints-- > 0) { res = XDrawLine(display, d, gc, @@ -561,6 +592,12 @@ XDrawSegments( XSegment *segments, int nsegments) { + (void)display; + (void)d; + (void)gc; + (void)segments; + (void)nsegments; + return BadDrawable; } #endif @@ -572,6 +609,10 @@ XFetchBuffer( int *nbytes_return, int buffer) { + (void)display; + (void)nbytes_return; + (void)buffer; + return (char *) 0; } @@ -581,7 +622,11 @@ XFetchName( Window w, char **window_name_return) { - return (Status) 0; + (void)display; + (void)w; + (void)window_name_return; + + return Success; } Atom * @@ -590,32 +635,25 @@ XListProperties( Window w, int *num_prop_return) { + (void)display; + (void)w; + (void)num_prop_return; + return (Atom *) 0; } -void +int XMapRaised( Display *display, Window w) { -} + (void)display; + (void)w; -void -XPutImage( - Display *display, - Drawable d, - GC gc, - XImage *image, - int src_x, - int src_y, - int dest_x, - int dest_y, - unsigned int width, - unsigned int height) -{ + return Success; } -void +int XQueryTextExtents( Display *display, XID font_ID, @@ -626,9 +664,19 @@ XQueryTextExtents( int *font_descent_return, XCharStruct *overall_return) { + (void)display; + (void)font_ID; + (void)string; + (void)nchars; + (void)direction_return; + (void)font_ascent_return; + (void)font_descent_return; + (void)overall_return; + + return Success; } -void +int XReparentWindow( Display *display, Window w, @@ -636,29 +684,297 @@ XReparentWindow( int x, int y) { + (void)display; + (void)w; + (void)parent; + (void)x; + (void)y; + + return BadWindow; } -void -XRotateBuffers( +int +XUndefineCursor( Display *display, - int rotate) + Window w) { + (void)display; + (void)w; + + return Success; +} + +XVaNestedList +XVaCreateNestedList( + int unused, ...) +{ + (void)unused; + return NULL; +} + +char * +XSetICValues( + XIC xic, ...) +{ + (void)xic; + return NULL; +} + +char * +XGetICValues( + XIC xic, ...) +{ + (void)xic; + return NULL; } void -XStoreBuffer( +XSetICFocus( + XIC xic) +{ + (void)xic; +} + +Window +XCreateWindow( Display *display, - _Xconst char *bytes, - int nbytes, - int buffer) + Window parent, + int x, + int y, + unsigned int width, + unsigned int height, + unsigned int border_width, + int depth, + unsigned int clazz, + Visual *visual, + unsigned long value_mask, + XSetWindowAttributes *attributes) +{ + (void)display; + (void)parent; + (void)x; + (void)y; + (void)width; + (void)height; + (void)border_width; + (void)depth; + (void)clazz; + (void)visual; + (void)value_mask; + (void)attributes; + + return 0; +} + +int +XPointInRegion( + Region rgn, + int x, + int y) { + (void)rgn; + (void)x; + (void)y; + + return 0; } +int +XUnionRegion( + Region srca, + Region srcb, + Region dr_return) +{ + (void)srca; + (void)srcb; + (void)dr_return; + + return 0; +} + +Region +XPolygonRegion( + XPoint *pts, + int n, + int rule) +{ + (void)pts; + (void)n; + (void)rule; + + return 0; +} +#endif + void -XUndefineCursor( +XDestroyIC( + XIC ic) +{ + (void)ic; +} + +Cursor +XCreatePixmapCursor( Display *display, - Window w) + Pixmap source, + Pixmap mask, + XColor *foreground_color, + XColor *background_color, + unsigned int x, + unsigned int y) +{ + (void)display; + (void)source; + (void)mask; + (void)foreground_color; + (void)background_color; + (void)x; + (void)y; + + return (Cursor) NULL; +} + +Cursor +XCreateGlyphCursor( + Display *display, + Font source_font, + Font mask_font, + unsigned int source_char, + unsigned int mask_char, + XColor _Xconst *foreground_color, + XColor _Xconst *background_color) { + (void)display; + (void)source_font; + (void)mask_font; + (void)source_char; + (void)mask_char; + (void)foreground_color; + (void)background_color; + + return (Cursor) NULL; +} + +#if 0 +XFontSet +XCreateFontSet( + Display *display /* display */, + _Xconst char *base_font_name_list /* base_font_name_list */, + char ***missing_charset_list /* missing_charset_list */, + int *missing_charset_count /* missing_charset_count */, + char **def_string /* def_string */ +) { + (void)display; + (void)base_font_name_list; + (void)missing_charset_list; + (void)missing_charset_count; + (void)def_string; + + return (XFontSet)0; +} + +void +XFreeFontSet( + Display *display, /* display */ + XFontSet fontset /* font_set */ +) { + (void)display; + (void)fontset; +} + +void +XFreeStringList( + char **list /* list */ +) { + (void)list; +} + +Status +XCloseIM( + XIM im /* im */ +) { + (void)im; + + return Success; +} + +Bool +XRegisterIMInstantiateCallback( + Display *dpy /* dpy */, + struct _XrmHashBucketRec *rdb /* rdb */, + char *res_name /* res_name */, + char *res_class /* res_class */, + XIDProc callback /* callback */, + XPointer client_data /* client_data */ +) { + (void)dpy; + (void)rdb; + (void)res_name; + (void)res_class; + (void)callback; + (void)client_data; + + return False; +} + +Bool +XUnregisterIMInstantiateCallback( + Display *dpy /* dpy */, + struct _XrmHashBucketRec *rdb /* rdb */, + char *res_name /* res_name */, + char *res_class /* res_class */, + XIDProc callback /* callback */, + XPointer client_data /* client_data */ +) { + (void)dpy; + (void)rdb; + (void)res_name; + (void)res_class; + (void)callback; + (void)client_data; + + return False; +} + +char * +XSetLocaleModifiers( + const char *modifier_list /* modifier_list */ +) { + (void)modifier_list; + + return NULL; +} + +XIM XOpenIM( + Display *dpy /* dpy */, + struct _XrmHashBucketRec *rdb /* rdb */, + char *res_name /* res_name */, + char *res_class /* res_class */ +) { + (void)dpy; + (void)rdb; + (void)res_name; + (void)res_class; + + return NULL; +} + +char * +XGetIMValues( + XIM im /* im */, ... +) { + (void)im; + + return NULL; +} + +char * +XSetIMValues( + XIM im /* im */, ... +) { + (void)im; + + return NULL; } #endif -- cgit v0.12 From 589d0dde98f21d4046bf3fa2fb4112c90863b8ad Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Wed, 12 Aug 2020 07:24:55 +0000 Subject: Rename (internal) MAASTER_MENU to MAIN_MENU, but keep the original, just to be sure --- generic/tkMenu.c | 40 ++++++++++++++++++++-------------------- generic/tkMenu.h | 13 +++++++------ tests/menu.test | 2 +- unix/tkUnixMenu.c | 4 ++-- win/tkWinMenu.c | 4 ++-- 5 files changed, 32 insertions(+), 31 deletions(-) diff --git a/generic/tkMenu.c b/generic/tkMenu.c index f43bbe0..638139a 100644 --- a/generic/tkMenu.c +++ b/generic/tkMenu.c @@ -39,12 +39,12 @@ * right; they have a Tk window and pathname associated with them; they have a * TkMenu structure and array of entries. However, they are linked with the * original menu that they were cloned from. The reflect the attributes of the - * original, or "master", menu. So if an item is added to a menu, and that + * original, or "main", menu. So if an item is added to a menu, and that * menu has clones, then the item must be added to all of its clones also. * Menus are cloned when a menu is torn-off or when a menu is assigned as a * menubar using the "-menu" option of the toplevel's pathname configure * subcommand. When a clone is destroyed, only the clone is destroyed, but - * when the master menu is destroyed, all clones are also destroyed. This + * when the main menu is destroyed, all clones are also destroyed. This * allows the developer to just deal with one set of menus when creating and * destroying. * @@ -513,7 +513,7 @@ Tk_MenuObjCmd( nextCascadePtr = cascadeListPtr->nextCascadePtr; /* - * If we have a new master menu, and an existing cloned menu + * If we have a new main menu, and an existing cloned menu * points to this menu in a cascade entry, we have to clone the * new menu and point the entry to the clone instead of the menu * we are creating. Otherwise, ConfigureMenuEntry will hook up the @@ -1100,8 +1100,8 @@ DestroyMenuInstance( TkMenu *menuInstancePtr; TkMenuEntry *cascadePtr, *nextCascadePtr; Tcl_Obj *newObjv[2]; - TkMenu *parentMasterMenuPtr; - TkMenuEntry *parentMasterEntryPtr; + TkMenu *parentMainMenuPtr; + TkMenuEntry *parentMainEntryPtr; ThreadSpecificData *tsdPtr = Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); @@ -1110,11 +1110,11 @@ DestroyMenuInstance( * entries need to be told that the menu is going away. We need to clear * the menu ptr field in the menu reference at this point in the code so * that everything else can forget about this menu properly. We also need - * to reset -menu field of all entries that are not master menus back to - * this entry name if this is a master menu pointed to by another master + * to reset -menu field of all entries that are not main menus back to + * this entry name if this is a main menu pointed to by another main * menu. If there is a clone menu that points to this menu, then this menu * is itself a clone, so when this menu goes away, the -menu field of the - * pointing entry must be set back to this menu's master menu name so that + * pointing entry must be set back to this menu's main menu name so that * later if another menu is created the cascade hierarchy can be * maintained. */ @@ -1135,11 +1135,11 @@ DestroyMenuInstance( if (menuPtr->masterMenuPtr != menuPtr) { Tcl_Obj *menuNamePtr = Tcl_NewStringObj("-menu", -1); - parentMasterMenuPtr = cascadePtr->menuPtr->masterMenuPtr; - parentMasterEntryPtr = - parentMasterMenuPtr->entries[cascadePtr->index]; + parentMainMenuPtr = cascadePtr->menuPtr->masterMenuPtr; + parentMainEntryPtr = + parentMainMenuPtr->entries[cascadePtr->index]; newObjv[0] = menuNamePtr; - newObjv[1] = parentMasterEntryPtr->namePtr; + newObjv[1] = parentMainEntryPtr->namePtr; /* * It is possible that the menu info is out of sync, and these @@ -1169,7 +1169,7 @@ DestroyMenuInstance( } } } else if (menuPtr->nextInstancePtr != NULL) { - Tcl_Panic("Attempting to delete master menu when there are still clones"); + Tcl_Panic("Attempting to delete main menu when there are still clones"); } /* @@ -1209,8 +1209,8 @@ DestroyMenuInstance( * * This function is invoked by Tcl_EventuallyFree or Tcl_Release to clean * up the internal structure of a menu at a safe time (when no-one is - * using it anymore). If called on a master instance, destroys all of the - * slave instances. If called on a non-master instance, just destroys + * using it anymore). If called on a main instance, destroys all of the + * instances. If called on a non-main instance, just destroys * that instance. * * Results: @@ -1571,7 +1571,7 @@ ConfigureMenu( * menuTypeName field to tell that this is a menu bar. */ - if (menuListPtr->menuType == MASTER_MENU) { + if (menuListPtr->menuType == MAIN_MENU) { int typeFlag = TK_MAKE_MENU_POPUP; Tk_Window tkwin = menuPtr->tkwin; @@ -1982,7 +1982,7 @@ ConfigureMenuCloneEntries( /* * Cascades are kind of tricky here. This is special case #3 in the - * comment at the top of this file. Basically, if a menu is the master + * comment at the top of this file. Basically, if a menu is the main * menu of a clone chain, and has an entry with a cascade menu, the clones * of the menu will point to clones of the cascade menu. We have to * destroy the clones of the cascades, clone the new cascade menu, and @@ -2416,7 +2416,7 @@ MenuAddOrInsert( * If a menu has cascades, then every instance of the menu has to have * its own parallel cascade structure. So adding an entry to a menu * with clones means that the menu that the entry points to has to be - * cloned for every clone the master menu has. This is special case #2 + * cloned for every clone the main menu has. This is special case #2 * in the comment at the top of this file. */ @@ -2697,7 +2697,7 @@ CloneMenu( Tcl_Obj *menuDupCommandArray[4]; if (newMenuTypePtr == NULL) { - menuType = MASTER_MENU; + menuType = MAIN_MENU; } else { if (Tcl_GetIndexFromObjStruct(menuPtr->interp, newMenuTypePtr, menuTypeStrings, sizeof(char *), "menu type", 0, &menuType) != TCL_OK) { @@ -2752,7 +2752,7 @@ CloneMenu( } /* - * Add the master menu's window to the bind tags for this window after + * Add the main menu's window to the bind tags for this window after * this window's tag. This is so the user can bind to either this * clone (which may not be easy to do) or the entire menu clone * structure. diff --git a/generic/tkMenu.h b/generic/tkMenu.h index a0fa7ab..386b204 100644 --- a/generic/tkMenu.h +++ b/generic/tkMenu.h @@ -185,7 +185,7 @@ typedef struct TkMenuEntry { * the menu. */ /* - * Bookeeping for master menus and cascade menus. + * Bookeeping for main menus and cascade menus. */ struct TkMenuReferences *childMenuRefPtr; @@ -266,7 +266,7 @@ typedef struct TkMenu { int numEntries; /* Number of elements in entries. */ int active; /* Index of active entry. -1 means nothing * active. */ - int menuType; /* MASTER_MENU, TEAROFF_MENU, or MENUBAR. See + int menuType; /* MAIN_MENU, TEAROFF_MENU, or MENUBAR. See * below for definitions. */ Tcl_Obj *menuTypePtr; /* Used to control whether created tkwin is a * toplevel or not. "normal", "menubar", or @@ -354,7 +354,7 @@ typedef struct TkMenu { struct TkMenu *masterMenuPtr; /* A pointer to the original menu for this * clone chain. Points back to this structure - * if this menu is a master menu. */ + * if this menu is a main menu. */ void *reserved1; /* not used any more. */ Tk_Window parentTopLevelPtr;/* If this menu is a menubar, this is the * toplevel that owns the menu. Only @@ -433,7 +433,7 @@ typedef struct TkMenuReferences { * MENU_DELETION_PENDING Non-zero means that we are currently * destroying this menu's internal structures. * This is useful when we are in the middle of - * cleaning this master menu's chain of menus up + * cleaning this main menu's chain of menus up * when TkDestroyMenu was called again on this * menu (via a destroy binding or somesuch). * MENU_WIN_DESTRUCTION_PENDING Non-zero means we are in the middle of @@ -451,15 +451,16 @@ typedef struct TkMenuReferences { #define MENU_PLATFORM_FLAG3 (1 << 28) /* - * Each menu created by the user is a MASTER_MENU. When a menu is torn off, a + * Each menu created by the user is a MAIN_MENU. When a menu is torn off, a * TEAROFF_MENU instance is created. When a menu is assigned to a toplevel as * a menu bar, a MENUBAR instance is created. All instances have the same - * configuration information. If the master instance is deleted, all instances + * configuration information. If the main instance is deleted, all instances * are deleted. If one of the other instances is deleted, only that instance * is deleted. */ #define UNKNOWN_TYPE -1 +#define MAIN_MENU 0 #define MASTER_MENU 0 #define TEAROFF_MENU 1 #define MENUBAR 2 diff --git a/tests/menu.test b/tests/menu.test index a7f5956..6a3c6fe 100644 --- a/tests/menu.test +++ b/tests/menu.test @@ -2052,7 +2052,7 @@ test menu-5.8 {DestroyMenuInstance - multiple clones} -setup { set tearoff2 [tk::TearOffMenu .m1] list [destroy $tearoff1] [destroy .m1] } -returnCodes ok -result {{} {}} -test menu-5.9 {DestroyMenuInstace - master menu} -setup { +test menu-5.9 {DestroyMenuInstace - main menu} -setup { destroy .m1 } -body { menu .m1 diff --git a/unix/tkUnixMenu.c b/unix/tkUnixMenu.c index aa54897..fc8b4f2 100644 --- a/unix/tkUnixMenu.c +++ b/unix/tkUnixMenu.c @@ -1057,7 +1057,7 @@ GetTearoffEntryGeometry( int *widthPtr, /* The resulting width */ int *heightPtr) /* The resulting height */ { - if (menuPtr->menuType != MASTER_MENU) { + if (menuPtr->menuType != MAIN_MENU) { *heightPtr = 0; *widthPtr = 0; } else { @@ -1281,7 +1281,7 @@ DrawTearoffEntry( int segmentWidth, maxX; Tk_3DBorder border; - if (menuPtr->menuType != MASTER_MENU) { + if (menuPtr->menuType != MAIN_MENU) { return; } diff --git a/win/tkWinMenu.c b/win/tkWinMenu.c index 6c55164..67894c7 100644 --- a/win/tkWinMenu.c +++ b/win/tkWinMenu.c @@ -1689,7 +1689,7 @@ GetTearoffEntryGeometry( (void)mePtr; (void)tkfont; - if (menuPtr->menuType != MASTER_MENU) { + if (menuPtr->menuType != MAIN_MENU) { *heightPtr = 0; } else { *heightPtr = fmPtr->linespace; @@ -2597,7 +2597,7 @@ DrawTearoffEntry( (void)tkfont; (void)fmPtr; - if (menuPtr->menuType != MASTER_MENU) { + if (menuPtr->menuType != MAIN_MENU) { return; } -- cgit v0.12 From f558e5ec4e15ff534f53df5f46c85c6f80a552c6 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Wed, 12 Aug 2020 14:07:30 +0000 Subject: .travis.yml update for newer tags --- .travis.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index 9c8a9dc..cc9f339 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,4 +1,3 @@ -sudo: required language: c addons: apt: @@ -17,8 +16,7 @@ addons: - tcl-tk casks: - xquartz - update: true -matrix: +jobs: include: # Testing on Linux with various compilers - name: "Linux/GCC/Shared" -- cgit v0.12 From 230306c11427bcefce870aa2c4f9e896ea76245b Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Thu, 13 Aug 2020 09:59:28 +0000 Subject: testcase cleanup --- tests/entry.test | 188 ++++++++++---------- tests/listbox.test | 126 +++++++------- tests/spinbox.test | 454 ++++++++++++++++++++++++------------------------- tests/ttk/entry.test | 10 +- tests/ttk/spinbox.test | 6 +- 5 files changed, 392 insertions(+), 392 deletions(-) diff --git a/tests/entry.test b/tests/entry.test index 8512b3f..2f09f92 100644 --- a/tests/entry.test +++ b/tests/entry.test @@ -17,7 +17,7 @@ proc scroll args { global scrollInfo set scrollInfo $args } -# For trace variable +# For trace variable proc override args { global x set x 12345 @@ -70,7 +70,7 @@ test entry-1.3 {configuration option: "bd" for entry} -setup { .e cget -bd } -cleanup { destroy .e -} -result {4} +} -result 4 test entry-1.4 {configuration option: "bd" for entry} -setup { entry .e -borderwidth 2 -highlightthickness 2 -font {Helvetica -12 bold} pack .e @@ -107,10 +107,10 @@ test entry-1.7 {configuration option: "borderwidth" for entry} -setup { update } -body { .e configure -borderwidth 1.3 - .e cget -borderwidth + .e cget -borderwidth } -cleanup { destroy .e -} -result {1} +} -result 1 test entry-1.8 {configuration option: "borderwidth" for entry} -setup { entry .e -borderwidth 2 -highlightthickness 2 -font {Helvetica -12 bold} pack .e @@ -190,7 +190,7 @@ test entry-1.15 {configuration option: "exportselection" for entry} -setup { .e cget -exportselection } -cleanup { destroy .e -} -result {1} +} -result 1 test entry-1.16 {configuration option: "exportselection" for entry} -setup { entry .e -borderwidth 2 -highlightthickness 2 -font {Helvetica -12 bold} pack .e @@ -310,7 +310,7 @@ test entry-1.27 {configuration option: "highlightthickness" for entry} -setup { .e cget -highlightthickness } -cleanup { destroy .e -} -result {6} +} -result 6 test entry-1.28 {configuration option: "highlightthickness" for entry} -setup { entry .e -borderwidth 2 -font {Helvetica -12 bold} pack .e @@ -320,7 +320,7 @@ test entry-1.28 {configuration option: "highlightthickness" for entry} -setup { .e cget -highlightthickness } -cleanup { destroy .e -} -result {0} +} -result 0 test entry-1.29 {configuration option: "highlightthickness" for entry} -setup { entry .e -borderwidth 2 -highlightthickness 2 -font {Helvetica -12 bold} pack .e @@ -360,7 +360,7 @@ test entry-1.32 {configuration option: "insertborderwidth" for entry} -setup { .e cget -insertborderwidth } -cleanup { destroy .e -} -result {1} +} -result 1 test entry-1.33 {configuration option: "insertborderwidth" for entry} -setup { entry .e -borderwidth 2 -highlightthickness 2 -font {Helvetica -12 bold} pack .e @@ -380,7 +380,7 @@ test entry-1.34 {configuration option: "insertofftime" for entry} -setup { .e cget -insertofftime } -cleanup { destroy .e -} -result {100} +} -result 100 test entry-1.35 {configuration option: "insertofftime" for entry} -setup { entry .e -borderwidth 2 -highlightthickness 2 -font {Helvetica -12 bold} pack .e @@ -400,7 +400,7 @@ test entry-1.36 {configuration option: "insertontime" for entry} -setup { .e cget -insertontime } -cleanup { destroy .e -} -result {100} +} -result 100 test entry-1.37 {configuration option: "insertontime" for entry} -setup { entry .e -borderwidth 2 -highlightthickness 2 -font {Helvetica -12 bold} pack .e @@ -513,7 +513,7 @@ test entry-1.47 {configuration option: "selectborderwidth" for entry} -setup { .e cget -selectborderwidth } -cleanup { destroy .e -} -result {1} +} -result 1 test entry-1.48 {configuration option: "selectborderwidth" for entry} -setup { entry .e -borderwidth 2 -highlightthickness 2 -font {Helvetica -12 bold} pack .e @@ -606,7 +606,7 @@ test entry-1.56 {configuration option: "width" for entry} -setup { .e cget -width } -cleanup { destroy .e -} -result {402} +} -result 402 test entry-1.57 {configuration option: "width" for entry} -setup { entry .e -borderwidth 2 -highlightthickness 2 -font {Helvetica -12 bold} pack .e @@ -800,7 +800,7 @@ test entry-3.14 {EntryWidgetCmd procedure, "cget" widget command} -setup { .e cget -bd } -cleanup { destroy .e -} -result {4} +} -result 4 test entry-3.15 {EntryWidgetCmd procedure, "configure" widget command} -setup { entry .e pack .e @@ -809,7 +809,7 @@ test entry-3.15 {EntryWidgetCmd procedure, "configure" widget command} -setup { llength [.e configure] } -cleanup { destroy .e -} -result {36} +} -result 36 test entry-3.16 {EntryWidgetCmd procedure, "configure" widget command} -setup { entry .e } -body { @@ -825,7 +825,7 @@ test entry-3.17 {EntryWidgetCmd procedure, "configure" widget command} -setup { lindex [.e configure -bd] 4 } -cleanup { destroy .e -} -result {4} +} -result 4 test entry-3.18 {EntryWidgetCmd procedure, "delete" widget command} -setup { entry .e } -body { @@ -864,7 +864,7 @@ test entry-3.22 {EntryWidgetCmd procedure, "delete" widget command} -setup { .e get } -cleanup { destroy .e -} -result {014567890} +} -result 014567890 test entry-3.23 {EntryWidgetCmd procedure, "delete" widget command} -setup { entry .e } -body { @@ -873,7 +873,7 @@ test entry-3.23 {EntryWidgetCmd procedure, "delete" widget command} -setup { .e get } -cleanup { destroy .e -} -result {0123457890} +} -result 0123457890 test entry-3.24 {EntryWidgetCmd procedure, "delete" widget command} -setup { entry .e pack .e @@ -905,7 +905,7 @@ test entry-3.25 {EntryWidgetCmd procedure, "delete" widget command} -setup { .e get } -cleanup { destroy .e -} -result {01234567890} +} -result 01234567890 test entry-3.26 {EntryWidgetCmd procedure, "delete" widget command} -setup { entry .e pack .e @@ -918,7 +918,7 @@ test entry-3.26 {EntryWidgetCmd procedure, "delete" widget command} -setup { .e get } -cleanup { destroy .e -} -result {01234567890} +} -result 01234567890 test entry-3.26a {EntryWidgetCmd procedure, "delete" widget command} -setup { entry .e pack .e @@ -931,7 +931,7 @@ test entry-3.26a {EntryWidgetCmd procedure, "delete" widget command} -setup { .e get } -cleanup { destroy .e -} -result {01234567890} +} -result 01234567890 test entry-3.27 {EntryWidgetCmd procedure, "get" widget command} -setup { entry .e } -body { @@ -961,7 +961,7 @@ test entry-3.30 {EntryWidgetCmd procedure, "icursor" widget command} -setup { .e index insert } -cleanup { destroy .e -} -result {4} +} -result 4 test entry-3.31 {EntryWidgetCmd procedure, "index" widget command} -setup { entry .e } -body { @@ -1047,7 +1047,7 @@ test entry-3.40 {EntryWidgetCmd procedure, "insert" widget command} -setup { .e get } -cleanup { destroy .e -} -result {01234567890} +} -result 01234567890 test entry-3.40a {EntryWidgetCmd procedure, "insert" widget command} -setup { entry .e pack .e @@ -1060,7 +1060,7 @@ test entry-3.40a {EntryWidgetCmd procedure, "insert" widget command} -setup { .e get } -cleanup { destroy .e -} -result {01234567890} +} -result 01234567890 test entry-3.41 {EntryWidgetCmd procedure, "insert" widget command} -setup { entry .e } -body { @@ -1120,7 +1120,7 @@ test entry-3.46 {EntryWidgetCmd procedure, "scan" widget command} -constraints { .e index @0 } -cleanup { destroy .e -} -result {2} +} -result 2 test entry-3.47 {EntryWidgetCmd procedure, "select" widget command} -setup { entry .e } -body { @@ -1189,7 +1189,7 @@ test entry-3.52 {EntryWidgetCmd procedure, "selection present" widget command} - .e selection present } -cleanup { destroy .e -} -result {1} +} -result 1 test entry-3.53 {EntryWidgetCmd procedure, "selection present" widget command} -setup { entry .e pack .e @@ -1202,7 +1202,7 @@ test entry-3.53 {EntryWidgetCmd procedure, "selection present" widget command} - .e selection present } -cleanup { destroy .e -} -result {1} +} -result 1 test entry-3.54 {EntryWidgetCmd procedure, "selection present" widget command} -setup { entry .e pack .e @@ -1215,7 +1215,7 @@ test entry-3.54 {EntryWidgetCmd procedure, "selection present" widget command} - .e selection present } -cleanup { destroy .e -} -result {0} +} -result 0 test entry-3.55 {EntryWidgetCmd procedure, "selection adjust" widget command} -setup { entry .e } -body { @@ -1243,7 +1243,7 @@ test entry-3.57 {EntryWidgetCmd procedure, "selection adjust" widget command} -s selection get } -cleanup { destroy .e -} -result {123} +} -result 123 test entry-3.58 {EntryWidgetCmd procedure, "selection adjust" widget command} -setup { entry .e pack .e @@ -1257,7 +1257,7 @@ test entry-3.58 {EntryWidgetCmd procedure, "selection adjust" widget command} -s selection get } -cleanup { destroy .e -} -result {234} +} -result 234 test entry-3.59 {EntryWidgetCmd procedure, "selection from" widget command} -setup { entry .e } -body { @@ -1471,7 +1471,7 @@ test entry-3.75 {EntryWidgetCmd procedure, "xview" widget command} -setup { .e index @0 } -cleanup { destroy .e -} -result {32} +} -result 32 test entry-3.76 {EntryWidgetCmd procedure, "xview" widget command} -setup { entry .e -font {Courier -12} -borderwidth 2 -highlightthickness 2 pack .e @@ -1485,7 +1485,7 @@ test entry-3.76 {EntryWidgetCmd procedure, "xview" widget command} -setup { .e index @0 } -cleanup { destroy .e -} -result {29} +} -result 29 test entry-3.77 {EntryWidgetCmd procedure, "xview" widget command} -setup { entry .e -font {Courier -12} -borderwidth 2 -highlightthickness 2 pack .e @@ -1517,11 +1517,11 @@ test entry-3.79 {EntryWidgetCmd procedure, "xview" widget command} -setup { .e insert end "runs off the end of the window quite a bit." .e xview 0 update - .e xview -4 + .e xview -1 .e index @0 } -cleanup { destroy .e -} -result {0} +} -result 0 test entry-3.80 {EntryWidgetCmd procedure, "xview" widget command} -setup { entry .e -font {Courier -12} -borderwidth 2 -highlightthickness 2 pack .e @@ -1533,7 +1533,7 @@ test entry-3.80 {EntryWidgetCmd procedure, "xview" widget command} -setup { .e index @0 } -cleanup { destroy .e -} -result {73} +} -result 73 test entry-3.86 {EntryWidgetCmd procedure, "xview" widget command} -setup { entry .e -font {Courier -12} -borderwidth 2 -highlightthickness 2 pack .e @@ -1584,7 +1584,7 @@ test entry-5.1 {ConfigureEntry procedure, -textvariable} -body { .e get } -cleanup { destroy .e -} -result {12345} +} -result 12345 test entry-5.2 {ConfigureEntry procedure, -textvariable} -body { set x 12345 entry .e -textvariable x @@ -1601,7 +1601,7 @@ test entry-5.3 {ConfigureEntry procedure, -textvariable} -setup { } -body { .e insert 0 "Some text" .e configure -textvariable x - return $x + set x } -cleanup { destroy .e } -result {Some text} @@ -1636,7 +1636,7 @@ test entry-5.5 {ConfigureEntry procedure} -setup { lappend x [selection get] .e1 configure -exportselection 1 lappend x [selection get] - return $x + set x } -cleanup { destroy .e1 .e2 } -result {{This is so} {This is so} 1234} @@ -1791,7 +1791,7 @@ test entry-6.4 {EntryComputeGeometry procedure} -setup { .e index @0 } -cleanup { destroy .e -} -result {6} +} -result 6 test entry-6.5 {EntryComputeGeometry procedure} -setup { entry .e -highlightthickness 2 pack .e @@ -1803,7 +1803,7 @@ test entry-6.5 {EntryComputeGeometry procedure} -setup { .e index @0 } -cleanup { destroy .e -} -result {6} +} -result 6 test entry-6.6 {EntryComputeGeometry procedure} -constraints { fonts } -setup { @@ -2011,7 +2011,7 @@ test entry-7.7 {InsertChars procedure} -setup { .e index insert } -cleanup { destroy .e -} -result {7} +} -result 7 test entry-7.8 {InsertChars procedure} -setup { entry .e -width 10 -font {Courier -12} -highlightthickness 2 -bd 2 pack .e @@ -2022,7 +2022,7 @@ test entry-7.8 {InsertChars procedure} -setup { .e index insert } -cleanup { destroy .e -} -result {4} +} -result 4 test entry-7.9 {InsertChars procedure} -setup { entry .e -width 10 -font {Courier -12} -highlightthickness 2 -bd 2 pack .e @@ -2034,7 +2034,7 @@ test entry-7.9 {InsertChars procedure} -setup { .e index @0 } -cleanup { destroy .e -} -result {7} +} -result 7 test entry-7.10 {InsertChars procedure} -setup { entry .e -width 10 -font {Courier -12} -highlightthickness 2 -bd 2 pack .e @@ -2046,7 +2046,7 @@ test entry-7.10 {InsertChars procedure} -setup { .e index @0 } -cleanup { destroy .e -} -result {4} +} -result 4 test entry-7.11 {InsertChars procedure} -constraints { fonts @@ -2060,7 +2060,7 @@ test entry-7.11 {InsertChars procedure} -constraints { winfo reqwidth .e } -cleanup { destroy .e -} -result {59} +} -result 59 test entry-8.1 {DeleteChars procedure} -setup { unset -nocomplain contents @@ -2087,7 +2087,7 @@ test entry-8.2 {DeleteChars procedure} -setup { .e configure -textvariable contents -xscrollcommand scroll set timeout [after 500 {set scrollInfo {-1000000 -1000000}}] .e insert 0 abcde - .e delete -2 2 + .e delete -1 2 vwait scrollInfo list [.e get] $contents [format {%.6f %.6f} {*}$scrollInfo] } -cleanup { @@ -2245,7 +2245,7 @@ test entry-8.12 {DeleteChars procedure} -setup { .e index insert } -cleanup { destroy .e -} -result {1} +} -result 1 test entry-8.13 {DeleteChars procedure} -setup { entry .e -width 10 -font {Courier -12} -highlightthickness 2 -bd 2 pack .e @@ -2258,7 +2258,7 @@ test entry-8.13 {DeleteChars procedure} -setup { .e index insert } -cleanup { destroy .e -} -result {1} +} -result 1 test entry-8.14 {DeleteChars procedure} -setup { entry .e -width 10 -font {Courier -12} -highlightthickness 2 -bd 2 pack .e @@ -2271,7 +2271,7 @@ test entry-8.14 {DeleteChars procedure} -setup { .e index insert } -cleanup { destroy .e -} -result {4} +} -result 4 test entry-8.15 {DeleteChars procedure} -setup { entry .e -width 10 -font {Courier -12} -highlightthickness 2 -bd 2 pack .e @@ -2284,7 +2284,7 @@ test entry-8.15 {DeleteChars procedure} -setup { .e index @0 } -cleanup { destroy .e -} -result {1} +} -result 1 test entry-8.16 {DeleteChars procedure} -setup { entry .e -width 10 -font {Courier -12} -highlightthickness 2 -bd 2 pack .e @@ -2297,7 +2297,7 @@ test entry-8.16 {DeleteChars procedure} -setup { .e index @0 } -cleanup { destroy .e -} -result {1} +} -result 1 test entry-8.17 {DeleteChars procedure} -setup { entry .e -width 10 -font {Courier -12} -highlightthickness 2 -bd 2 pack .e @@ -2310,7 +2310,7 @@ test entry-8.17 {DeleteChars procedure} -setup { .e index @0 } -cleanup { destroy .e -} -result {4} +} -result 4 test entry-8.18 {DeleteChars procedure} -setup { entry .e -width 0 -font {Courier -12} -highlightthickness 2 -bd 2 pack .e @@ -2322,7 +2322,7 @@ test entry-8.18 {DeleteChars procedure} -setup { winfo reqwidth .e } -cleanup { destroy .e -} -result {31} +} -result 31 test entry-9.1 {EntryValueChanged procedure} -setup { unset -nocomplain x @@ -2403,7 +2403,7 @@ test entry-10.5 {EntrySetValue procedure, updating display position} -setup { .e index @0 } -cleanup { destroy .e -} -result {0} +} -result 0 test entry-10.6 {EntrySetValue procedure, updating display position} -setup { unset -nocomplain x entry .e -highlightthickness 2 -bd 2 @@ -2419,7 +2419,7 @@ test entry-10.6 {EntrySetValue procedure, updating display position} -setup { .e index @0 } -cleanup { destroy .e -} -result {10} +} -result 10 test entry-10.7 {EntrySetValue procedure, updating insertion cursor} -setup { unset -nocomplain x entry .e -highlightthickness 2 -bd 2 @@ -2434,7 +2434,7 @@ test entry-10.7 {EntrySetValue procedure, updating insertion cursor} -setup { .e index insert } -cleanup { destroy .e -} -result {3} +} -result 3 test entry-10.8 {EntrySetValue procedure, updating insertion cursor} -setup { unset -nocomplain x entry .e -highlightthickness 2 -bd 2 @@ -2448,7 +2448,7 @@ test entry-10.8 {EntrySetValue procedure, updating insertion cursor} -setup { .e index insert } -cleanup { destroy .e -} -result {5} +} -result 5 test entry-11.1 {EntryEventProc procedure} -setup { entry .e -highlightthickness 2 -bd 2 -font {Helvetica -12} @@ -2492,7 +2492,7 @@ test entry-13.1 {GetEntryIndex procedure} -setup { .e index end } -cleanup { destroy .e -} -result {21} +} -result 21 test entry-13.2 {GetEntryIndex procedure} -body { entry .e .e index abogus @@ -2511,7 +2511,7 @@ test entry-13.3 {GetEntryIndex procedure} -setup { .e index anchor } -cleanup { destroy .e -} -result {1} +} -result 1 test entry-13.4 {GetEntryIndex procedure} -setup { entry .e -font {Courier -12} -width 5 -bd 2 -relief sunken pack .e @@ -2524,7 +2524,7 @@ test entry-13.4 {GetEntryIndex procedure} -setup { .e index anchor } -cleanup { destroy .e -} -result {4} +} -result 4 test entry-13.5 {GetEntryIndex procedure} -setup { entry .e -font {Courier -12} -width 5 -bd 2 -relief sunken pack .e @@ -2538,7 +2538,7 @@ test entry-13.5 {GetEntryIndex procedure} -setup { .e index anchor } -cleanup { destroy .e -} -result {15} +} -result 15 test entry-13.6 {GetEntryIndex procedure} -setup { entry .e } -body { @@ -2557,7 +2557,7 @@ test entry-13.7 {GetEntryIndex procedure} -setup { .e index insert } -cleanup { destroy .e -} -result {2} +} -result 2 test entry-13.8 {GetEntryIndex procedure} -setup { entry .e } -body { @@ -2622,7 +2622,7 @@ test entry-13.11 {GetEntryIndex procedure} -constraints aquaOrWin32 -body { .e index sel.first } -cleanup { destroy .e -} -result {1} +} -result 1 test entry-13.12 {GetEntryIndex procedure} -constraints x11 -body { # Previous settings: @@ -2736,7 +2736,7 @@ test entry-13.16 {GetEntryIndex procedure} -constraints fonts -body { .e index @4 } -cleanup { destroy .e -} -result {4} +} -result 4 test entry-13.17 {GetEntryIndex procedure} -constraints fonts -body { entry .e -width 5 -relief sunken -highlightthickness 2 -bd 2\ -font {Courier -12} @@ -2747,7 +2747,7 @@ test entry-13.17 {GetEntryIndex procedure} -constraints fonts -body { .e index @11 } -cleanup { destroy .e -} -result {4} +} -result 4 test entry-13.18 {GetEntryIndex procedure} -constraints fonts -body { entry .e -width 5 -relief sunken -highlightthickness 2 -bd 2\ -font {Courier -12} @@ -2758,7 +2758,7 @@ test entry-13.18 {GetEntryIndex procedure} -constraints fonts -body { .e index @12 } -cleanup { destroy .e -} -result {5} +} -result 5 test entry-13.19 {GetEntryIndex procedure} -constraints fonts -body { entry .e -width 5 -relief sunken -highlightthickness 2 -bd 2\ -font {Courier -12} @@ -2769,7 +2769,7 @@ test entry-13.19 {GetEntryIndex procedure} -constraints fonts -body { .e index @[expr {[winfo width .e] - 6}] } -cleanup { destroy .e -} -result {8} +} -result 8 test entry-13.20 {GetEntryIndex procedure} -constraints fonts -body { entry .e -width 5 -relief sunken -highlightthickness 2 -bd 2\ -font {Courier -12} @@ -2780,7 +2780,7 @@ test entry-13.20 {GetEntryIndex procedure} -constraints fonts -body { .e index @[expr {[winfo width .e] - 5}] } -cleanup { destroy .e -} -result {9} +} -result 9 test entry-13.21 {GetEntryIndex procedure} -body { entry .e -width 5 -relief sunken -highlightthickness 2 -bd 2\ -font {Courier -12} @@ -2791,7 +2791,7 @@ test entry-13.21 {GetEntryIndex procedure} -body { .e index @1000 } -cleanup { destroy .e -} -result {9} +} -result 9 test entry-13.22 {GetEntryIndex procedure} -setup { entry .e pack .e @@ -2808,10 +2808,10 @@ test entry-13.23 {GetEntryIndex procedure} -body { .e insert 0 012345678901234567890 .e xview 4 update - .e index -10 + .e index -1 } -cleanup { destroy .e -} -result {0} +} -result 0 test entry-13.24 {GetEntryIndex procedure} -body { entry .e -width 5 -relief sunken -highlightthickness 2 -bd 2\ -font {Courier -12} @@ -2822,7 +2822,7 @@ test entry-13.24 {GetEntryIndex procedure} -body { .e index 12 } -cleanup { destroy .e -} -result {12} +} -result 12 test entry-13.25 {GetEntryIndex procedure} -body { entry .e -width 5 -relief sunken -highlightthickness 2 -bd 2\ -font {Courier -12} @@ -2833,7 +2833,7 @@ test entry-13.25 {GetEntryIndex procedure} -body { .e index 49 } -cleanup { destroy .e -} -result {21} +} -result 21 test entry-13.26 {GetEntryIndex procedure} -constraints fonts -body { entry .e -highlightthickness 2 -bd 2 -font {Helvetica -12} selection clear .e @@ -2880,7 +2880,7 @@ test entry-14.3 {EntryFetchSelection procedure} -setup { string compare [selection get] $x } -cleanup { destroy .e -} -result {0} +} -result 0 test entry-15.1 {EntryLostSelection} -body { entry .e @@ -3003,7 +3003,7 @@ test entry-18.1 {Entry widget vs hiding} -setup { set res1 [list [winfo children .] [interp hidden]] set res2 [list {} $l] expr {$res1 == $res2} -} -result {1} +} -result 1 ## ## Entry widget VALIDATION tests @@ -3025,7 +3025,7 @@ test entry-19.1 {entry widget validation} -setup { -background red -foreground white pack .e .e insert 0 a - return $::vVals + set ::vVals } -cleanup { destroy .e } -result {.e 1 0 a {} a all key} @@ -3057,7 +3057,7 @@ test entry-19.3 {entry widget validation} -setup { pack .e .e insert 0 ab ;# previous settings .e insert end c - return $::vVals + set ::vVals } -cleanup { destroy .e } -result {.e 1 2 abc ab c all key} @@ -3089,7 +3089,7 @@ test entry-19.5 {entry widget validation} -setup { pack .e .e insert 0 a123bc ;# previous settings .e delete 2 - return $::vVals + set ::vVals } -cleanup { destroy .e } -result {.e 0 2 a13bc a123bc 2 all key} @@ -3106,7 +3106,7 @@ test entry-19.6 {entry widget validation} -setup { .e insert 0 a13bc ;# previous settings .e configure -validate key .e delete 1 3 - return $::vVals + set ::vVals } -cleanup { destroy .e } -result {.e 0 1 abc a13bc 13 key key} @@ -3123,7 +3123,7 @@ test entry-19.7 {entry widget validation} -setup { .e insert end abc ;# previous settings set ::vVals {} .e insert end d - return $::vVals + set ::vVals } -cleanup { destroy .e } -result {} @@ -3142,7 +3142,7 @@ test entry-19.8 {entry widget validation} -setup { focus -force .e # update necessary to process FocusIn event update - return $::vVals + set ::vVals } -cleanup { destroy .e } -result {.e -1 -1 abcd abcd {} focus focusin} @@ -3163,7 +3163,7 @@ test entry-19.9 {entry widget validation} -setup { focus -force . # update necessary to process FocusOut event update - return $::vVals + set ::vVals } -cleanup { destroy .e } -result {.e -1 -1 abcd abcd {} focus focusout} @@ -3181,7 +3181,7 @@ test entry-19.10 {entry widget validation} -setup { focus -force .e # update necessary to process FocusIn event update - return $::vVals + set ::vVals } -cleanup { destroy .e } -result {.e -1 -1 abcd abcd {} all focusin} @@ -3202,7 +3202,7 @@ test entry-19.11 {entry widget validation} -setup { focus -force . # update necessary to process FocusOut event update - return $::vVals + set ::vVals } -cleanup { destroy .e } -result {.e -1 -1 abcd abcd {} all focusout} @@ -3220,7 +3220,7 @@ test entry-19.12 {entry widget validation} -setup { focus -force .e # update necessary to process FocusIn event update - return $::vVals + set ::vVals } -cleanup { destroy .e } -result {.e -1 -1 abcd abcd {} focusin focusin} @@ -3239,7 +3239,7 @@ test entry-19.13 {entry widget validation} -setup { focus -force . # update necessary to process FocusOut event update - return $::vVals + set ::vVals } -cleanup { destroy .e } -result {} @@ -3258,7 +3258,7 @@ test entry-19.14 {entry widget validation} -setup { focus -force .e # update necessary to process FocusIn event update - return $::vVals + set ::vVals } -cleanup { destroy .e } -result {} @@ -3280,7 +3280,7 @@ test entry-19.15 {entry widget validation} -setup { focus -force . # update necessary to process FocusOut event update - return $::vVals + set ::vVals } -cleanup { destroy .e } -result {.e -1 -1 abcd abcd {} focusout focusout} @@ -3422,7 +3422,7 @@ test entry-20.1 {widget deletion while active} -body { winfo exists .e } -cleanup { destroy .e -} -result {0} +} -result 0 test entry-20.2 {widget deletion while active} -body { entry .e -validate all \ @@ -3432,7 +3432,7 @@ test entry-20.2 {widget deletion while active} -body { winfo exists .e } -cleanup { destroy .e -} -result {0} +} -result 0 test entry-20.3 {widget deletion while active} -body { entry .e -validate all \ @@ -3441,7 +3441,7 @@ test entry-20.3 {widget deletion while active} -body { winfo exists .e } -cleanup { destroy .e -} -result {0} +} -result 0 test entry-20.4 {widget deletion while active} -body { entry .e -validate all \ @@ -3451,7 +3451,7 @@ test entry-20.4 {widget deletion while active} -body { winfo exists .e } -cleanup { destroy .e -} -result {0} +} -result 0 test entry-20.5 {widget deletion while active} -body { entry .e -validatecommand { destroy .e ; return 0 } @@ -3459,7 +3459,7 @@ test entry-20.5 {widget deletion while active} -body { winfo exists .e } -cleanup { destroy .e -} -result {0} +} -result 0 test entry-20.6 {widget deletion while active} -body { pack [entry .e] @@ -3469,7 +3469,7 @@ test entry-20.6 {widget deletion while active} -body { winfo exists .e } -cleanup { destroy .e -} -result {0} +} -result 0 test entry-20.7 {widget deletion with textvariable active} -body { # SF bugs 607390 and 617446 @@ -3481,7 +3481,7 @@ test entry-20.7 {widget deletion with textvariable active} -body { winfo exists .e } -cleanup { destroy .e -} -result {0} +} -result 0 test entry-21.1 {selection present while disabled, bug 637828} -body { diff --git a/tests/listbox.test b/tests/listbox.test index 3a6c860..42dc327 100644 --- a/tests/listbox.test +++ b/tests/listbox.test @@ -376,15 +376,15 @@ test listbox-3.5 {ListboxWidgetCmd procedure, "activate" option} -body { test listbox-3.6 {ListboxWidgetCmd procedure, "activate" option} -body { .l activate -1 .l index active -} -result {0} +} -result 0 test listbox-3.7 {ListboxWidgetCmd procedure, "activate" option} -body { .l activate 30 .l index active -} -result {17} +} -result 17 test listbox-3.8 {ListboxWidgetCmd procedure, "activate" option} -body { .l activate end .l index active -} -result {17} +} -result 17 test listbox-3.9 {ListboxWidgetCmd procedure, "bbox" option} -body { .l bbox } -returnCodes error -result {wrong # args: should be ".l bbox index"} @@ -508,7 +508,7 @@ test listbox-3.18b {ListboxWidgetCmd procedure, "bbox" option, justified, non-de } -cleanup { destroy .top.l .top unset -nocomplain lres res -} -result {1} +} -result 1 test listbox-3.19 {ListboxWidgetCmd procedure, "cget" option} -body { .l cget } -returnCodes error -result {wrong # args: should be ".l cget option"} @@ -520,10 +520,10 @@ test listbox-3.21 {ListboxWidgetCmd procedure, "cget" option} -body { } -returnCodes error -result {unknown option "-gorp"} test listbox-3.22 {ListboxWidgetCmd procedure, "cget" option} -body { .l cget -setgrid -} -result {0} +} -result 0 test listbox-3.23 {ListboxWidgetCmd procedure, "configure" option} -body { llength [.l configure] -} -result {28} +} -result 28 test listbox-3.24 {ListboxWidgetCmd procedure, "configure" option} -body { .l configure -gorp } -returnCodes error -result {unknown option "-gorp"} @@ -587,7 +587,7 @@ test listbox-3.36 {ListboxWidgetCmd procedure, "delete" option} -setup { } -body { listbox .l2 .l2 insert 0 el0 el1 el2 el3 el4 el5 el6 el7 - .l2 delete -3 2 + .l2 delete -1 2 .l2 get 0 end } -cleanup { destroy .l2 @@ -597,7 +597,7 @@ test listbox-3.37 {ListboxWidgetCmd procedure, "delete" option} -setup { } -body { listbox .l2 .l2 insert 0 el0 el1 el2 el3 el4 el5 el6 el7 - .l2 delete -3 -1 + .l2 delete -1 -1 .l2 get 0 end } -cleanup { destroy .l2 @@ -684,10 +684,10 @@ test listbox-3.49 {ListboxWidgetCmd procedure, "get" option} -body { .l get -1 } -result {} test listbox-3.50 {ListboxWidgetCmd procedure, "get" option} -body { - .l get -2 -1 + .l get -1 -1 } -result {} test listbox-3.51 {ListboxWidgetCmd procedure, "get" option} -body { - .l get -2 3 + .l get -1 3 } -result {el0 el1 el2 el3} test listbox-3.52 {ListboxWidgetCmd procedure, "get" option} -body { .l get 12 end @@ -783,7 +783,7 @@ test listbox-3.72 {ListboxWidgetCmd procedure, "nearest" option} -body { test listbox-3.73 {ListboxWidgetCmd procedure, "nearest" option} -body { .l yview 3 .l nearest 1000 -} -result {7} +} -result 7 test listbox-3.74 {ListboxWidgetCmd procedure, "scan" option} -body { .l scan a b } -returnCodes error -result {wrong # args: should be ".l scan mark|dragto x y"} @@ -830,52 +830,52 @@ test listbox-3.83 {ListboxWidgetCmd procedure, "see" option} -body { .l yview 7 .l see 7 .l index @0,0 -} -result {7} +} -result 7 test listbox-3.84 {ListboxWidgetCmd procedure, "see" option} -body { .l yview 7 .l see 11 .l index @0,0 -} -result {7} +} -result 7 test listbox-3.85 {ListboxWidgetCmd procedure, "see" option} -body { .l yview 7 .l see 6 .l index @0,0 -} -result {6} +} -result 6 test listbox-3.86 {ListboxWidgetCmd procedure, "see" option} -body { .l yview 7 .l see 5 .l index @0,0 -} -result {3} +} -result 3 test listbox-3.87 {ListboxWidgetCmd procedure, "see" option} -body { .l yview 7 .l see 12 .l index @0,0 -} -result {8} +} -result 8 test listbox-3.88 {ListboxWidgetCmd procedure, "see" option} -body { .l yview 7 .l see 13 .l index @0,0 -} -result {11} +} -result 11 test listbox-3.89 {ListboxWidgetCmd procedure, "see" option} -body { .l yview 7 .l see -1 .l index @0,0 -} -result {0} +} -result 0 test listbox-3.90 {ListboxWidgetCmd procedure, "see" option} -body { .l yview 7 .l see end .l index @0,0 -} -result {13} +} -result 13 test listbox-3.91 {ListboxWidgetCmd procedure, "see" option} -body { .l yview 7 .l see 322 .l index @0,0 -} -result {13} +} -result 13 test listbox-3.92 {ListboxWidgetCmd procedure, "see" option, partial last line} -body { mkPartial .partial.l see 4 .partial.l index @0,0 -} -result {1} +} -result 1 test listbox-3.93 {ListboxWidgetCmd procedure, "selection" option} -body { .l select a } -returnCodes error -result {wrong # args: should be ".l selection option index ?index?"} @@ -898,15 +898,15 @@ test listbox-3.98 {ListboxWidgetCmd procedure, "selection" option} -body { test listbox-3.99 {ListboxWidgetCmd procedure, "selection" option} -body { .l selection anchor -1 .l index anchor -} -result {0} +} -result 0 test listbox-3.100 {ListboxWidgetCmd procedure, "selection" option} -body { .l selection anchor end .l index anchor -} -result {17} +} -result 17 test listbox-3.101 {ListboxWidgetCmd procedure, "selection" option} -body { .l selection anchor 44 .l index anchor -} -result {17} +} -result 17 test listbox-3.102 {ListboxWidgetCmd procedure, "selection" option} -body { .l selection clear 0 end .l selection set 2 8 @@ -926,16 +926,16 @@ test listbox-3.104 {ListboxWidgetCmd procedure, "selection" option} -body { test listbox-3.105 {ListboxWidgetCmd procedure, "selection" option} -body { .l selection set 0 end .l selection includes -1 -} -result {0} +} -result 0 test listbox-3.106 {ListboxWidgetCmd procedure, "selection" option} -body { .l selection clear 0 end .l selection set end .l selection includes end -} -result {1} +} -result 1 test listbox-3.107 {ListboxWidgetCmd procedure, "selection" option} -body { .l selection set 0 end .l selection includes 44 -} -result {0} +} -result 0 test listbox-3.108 {ListboxWidgetCmd procedure, "selection" option} -setup { destroy .l2 } -body { @@ -943,7 +943,7 @@ test listbox-3.108 {ListboxWidgetCmd procedure, "selection" option} -setup { .l2 selection includes 0 } -cleanup { destroy .l2 -} -result {0} +} -result 0 test listbox-3.109 {ListboxWidgetCmd procedure, "selection" option} -body { .l selection clear 0 end .l selection set 2 @@ -965,7 +965,7 @@ test listbox-3.112 {ListboxWidgetCmd procedure, "size" option} -body { } -returnCodes error -result {wrong # args: should be ".l size"} test listbox-3.113 {ListboxWidgetCmd procedure, "size" option} -body { .l size -} -result {18} +} -result 18 test listbox-3.114 {ListboxWidgetCmd procedure, "xview" option} -setup { destroy .l2 } -body { @@ -1242,7 +1242,7 @@ test listbox-4.2 {ConfigureListbox procedure} -setup { .l cget -highlightthickness } -cleanup { deleteWindows -} -result {0} +} -result 0 test listbox-4.3 {ConfigureListbox procedure} -setup { deleteWindows destroy .l @@ -1573,14 +1573,14 @@ test listbox-6.2 {InsertEls procedure} -body { .l selection anchor 2 .l insert 2 A B .l index anchor -} -result {4} +} -result 4 test listbox-6.3 {InsertEls procedure} -body { .l delete 0 end .l insert 0 a b c d e f g h i j .l selection anchor 2 .l insert 3 A B .l index anchor -} -result {2} +} -result 2 test listbox-6.4 {InsertEls procedure} -body { .l delete 0 end .l insert 0 a b c d e f g h i j @@ -1588,7 +1588,7 @@ test listbox-6.4 {InsertEls procedure} -body { update .l insert 2 A B .l index @0,0 -} -result {5} +} -result 5 test listbox-6.5 {InsertEls procedure} -body { .l delete 0 end .l insert 0 a b c d e f g h i j @@ -1596,31 +1596,31 @@ test listbox-6.5 {InsertEls procedure} -body { update .l insert 3 A B .l index @0,0 -} -result {3} +} -result 3 test listbox-6.6 {InsertEls procedure} -body { .l delete 0 end .l insert 0 a b c d e f g h i j .l activate 5 .l insert 5 A B .l index active -} -result {7} +} -result 7 test listbox-6.7 {InsertEls procedure} -body { .l delete 0 end .l insert 0 a b c d e f g h i j .l activate 5 .l insert 6 A B .l index active -} -result {5} +} -result 5 test listbox-6.8 {InsertEls procedure} -body { .l delete 0 end .l insert 0 a b c .l index active -} -result {2} +} -result 2 test listbox-6.9 {InsertEls procedure} -body { .l delete 0 end .l insert 0 .l index active -} -result {0} +} -result 0 test listbox-6.10 {InsertEls procedure} -body { .l delete 0 end .l insert 0 a b "two words" c d e f g h i j @@ -1728,28 +1728,28 @@ test listbox-7.5 {DeleteEls procedure} -body { .l selection anchor 2 .l delete 0 1 .l index anchor -} -result {0} +} -result 0 test listbox-7.6 {DeleteEls procedure} -body { .l delete 0 end .l insert 0 a b c d e f g h i j .l selection anchor 2 .l delete 2 .l index anchor -} -result {2} +} -result 2 test listbox-7.7 {DeleteEls procedure} -body { .l delete 0 end .l insert 0 a b c d e f g h i j .l selection anchor 4 .l delete 2 5 .l index anchor -} -result {2} +} -result 2 test listbox-7.8 {DeleteEls procedure} -body { .l delete 0 end .l insert 0 a b c d e f g h i j .l selection anchor 3 .l delete 4 5 .l index anchor -} -result {3} +} -result 3 test listbox-7.9 {DeleteEls procedure} -body { .l delete 0 end .l insert 0 a b c d e f g h i j @@ -1757,7 +1757,7 @@ test listbox-7.9 {DeleteEls procedure} -body { update .l delete 1 2 .l index @0,0 -} -result {1} +} -result 1 test listbox-7.10 {DeleteEls procedure} -body { .l delete 0 end .l insert 0 a b c d e f g h i j @@ -1765,7 +1765,7 @@ test listbox-7.10 {DeleteEls procedure} -body { update .l delete 3 4 .l index @0,0 -} -result {3} +} -result 3 test listbox-7.11 {DeleteEls procedure} -body { .l delete 0 end .l insert 0 a b c d e f g h i j @@ -1773,7 +1773,7 @@ test listbox-7.11 {DeleteEls procedure} -body { update .l delete 4 6 .l index @0,0 -} -result {3} +} -result 3 test listbox-7.12 {DeleteEls procedure} -body { .l delete 0 end .l insert 0 a b c d e f g h i j @@ -1781,42 +1781,42 @@ test listbox-7.12 {DeleteEls procedure} -body { update .l delete 3 end .l index @0,0 -} -result {1} +} -result 1 test listbox-7.13 {DeleteEls procedure, updating view with partial last line} -body { mkPartial .partial.l yview 8 update .partial.l delete 10 13 .partial.l index @0,0 -} -result {7} +} -result 7 test listbox-7.14 {DeleteEls procedure} -body { .l delete 0 end .l insert 0 a b c d e f g h i j .l activate 6 .l delete 3 4 .l index active -} -result {4} +} -result 4 test listbox-7.15 {DeleteEls procedure} -body { .l delete 0 end .l insert 0 a b c d e f g h i j .l activate 6 .l delete 5 7 .l index active -} -result {5} +} -result 5 test listbox-7.16 {DeleteEls procedure} -body { .l delete 0 end .l insert 0 a b c d e f g h i j .l activate 6 .l delete 5 end .l index active -} -result {4} +} -result 4 test listbox-7.17 {DeleteEls procedure} -body { .l delete 0 end .l insert 0 a b c d e f g h i j .l activate 6 .l delete 0 end .l index active -} -result {0} +} -result 0 test listbox-7.18 {DeleteEls procedure} -body { .l delete 0 end .l insert 0 a b c "two words" d e f g h i j @@ -1987,7 +1987,7 @@ test listbox-10.5 {GetListboxIndex procedure} -setup { .l index end } -cleanup { destroy .l -} -result {12} +} -result 12 test listbox-10.6 {GetListboxIndex procedure} -setup { destroy .l } -body { @@ -2102,7 +2102,7 @@ test listbox-10.16 {GetListboxIndex procedure} -setup { .l index 3 } -cleanup { destroy .l -} -result {3} +} -result 3 test listbox-10.17 {GetListboxIndex procedure} -setup { destroy .l } -body { @@ -2112,7 +2112,7 @@ test listbox-10.17 {GetListboxIndex procedure} -setup { .l index 20 } -cleanup { destroy .l -} -result {20} +} -result 20 test listbox-10.18 {GetListboxIndex procedure} -setup { destroy .l } -body { @@ -2129,10 +2129,10 @@ test listbox-10.19 {GetListboxIndex procedure} -setup { pack [listbox .l] .l insert 0 el0 el1 el2 el3 el4 el5 el6 el7 el8 el9 el10 el11 update - .l index -2 + .l index -1 } -cleanup { destroy .l -} -result -2 +} -result -1 test listbox-10.20 {GetListboxIndex procedure} -setup { destroy .l } -body { @@ -2226,7 +2226,7 @@ test listbox-11.6 {ChangeListboxView procedure, partial last line} -body { .partial.l index @0,0 } -cleanup { destroy .l -} -result {11} +} -result 11 # Listbox used in 12.* tests @@ -2314,7 +2314,7 @@ test listbox-13.3 {ListboxScanTo procedure} -constraints { test listbox-14.1 {NearestListboxElement procedure, partial last line} -body { mkPartial .partial.l nearest [winfo height .partial.l] -} -result {4} +} -result 4 # Listbox used in 14.* tests destroy .l listbox .l -font $fixed -width 20 -height 10 @@ -2326,7 +2326,7 @@ test listbox-14.2 {NearestListboxElement procedure} -constraints { fonts } -body { .l index @50,0 -} -result {4} +} -result 4 test listbox-14.3 {NearestListboxElement procedure} -constraints { fonts } -body { @@ -2336,7 +2336,7 @@ test listbox-14.4 {NearestListboxElement procedure} -constraints { fonts } -body { .l index @50,200 -} -result {13} +} -result 13 # Listbox used in 15.* 16.* and 17.* tests @@ -2378,7 +2378,7 @@ test listbox-15.4 {ListboxSelect procedure, boundary conditions for indices} -bo .l delete 0 end .l insert 0 a b c d e f .l select clear 0 end - .l select set -2 -1 + .l select set -1 -1 .l curselection } -result {} test listbox-15.5 {ListboxSelect procedure, boundary conditions for indices} -body { @@ -2415,7 +2415,7 @@ test listbox-15.9 {ListboxSelect procedure, boundary conditions for indices} -bo .l select clear 0 end .l select set end 30 .l curselection -} -result {5} +} -result 5 test listbox-15.10 {ListboxSelect procedure, boundary conditions for indices} -body { .l delete 0 end .l insert 0 a b c d e f @@ -2451,7 +2451,7 @@ test listbox-16.3 {ListboxFetchSelection procedure, retrieve in several parts} - string compare 1$long\n2$long\n3$long\n4$long\n5$long $sel } -cleanup { catch {unset long sel} -} -result {0} +} -result 0 test listbox-17.1 {ListboxLostSelection procedure} -setup { diff --git a/tests/spinbox.test b/tests/spinbox.test index 3f55d7f..8d19a7e 100644 --- a/tests/spinbox.test +++ b/tests/spinbox.test @@ -17,7 +17,7 @@ proc scroll args { global scrollInfo set scrollInfo $args } -# For trace variable +# For trace variable proc override args { global x set x 12345 @@ -94,7 +94,7 @@ test spinbox-1.5 {configuration option: "bd"} -setup { .e cget -bd } -cleanup { destroy .e -} -result {4} +} -result 4 test spinbox-1.6 {configuration option: "bd" for spinbox} -setup { spinbox .e -borderwidth 2 -highlightthickness 2 -font {Helvetica -12} \ -relief sunken @@ -138,7 +138,7 @@ test spinbox-1.9 {configuration option: "borderwidth"} -setup { .e cget -borderwidth } -cleanup { destroy .e -} -result {1} +} -result 1 test spinbox-1.10 {configuration option: "borderwidth" for spinbox} -setup { spinbox .e -borderwidth 2 -highlightthickness 2 -font {Helvetica -12} \ -relief sunken @@ -282,7 +282,7 @@ test spinbox-1.22 {configuration option: "exportselection"} -setup { .e cget -exportselection } -cleanup { destroy .e -} -result {1} +} -result 1 test spinbox-1.23 {configuration option: "exportselection" for spinbox} -setup { spinbox .e -borderwidth 2 -highlightthickness 2 -font {Helvetica -12} \ -relief sunken @@ -458,7 +458,7 @@ test spinbox-1.38 {configuration option: "highlightthickness"} -setup { .e cget -highlightthickness } -cleanup { destroy .e -} -result {6} +} -result 6 test spinbox-1.39 {configuration option: "highlightthickness" for spinbox} -setup { spinbox .e -borderwidth 2 -highlightthickness 2 -font {Helvetica -12} \ -relief sunken @@ -480,7 +480,7 @@ test spinbox-1.40 {configuration option: "highlightthickness"} -setup { .e cget -highlightthickness } -cleanup { destroy .e -} -result {0} +} -result 0 test spinbox-1.41 {configuration option: "increment"} -setup { spinbox .e -borderwidth 2 -highlightthickness 2 -font {Helvetica -12} \ @@ -536,7 +536,7 @@ test spinbox-1.45 {configuration option: "insertborderwidth"} -setup { .e cget -insertborderwidth } -cleanup { destroy .e -} -result {1} +} -result 1 test spinbox-1.46 {configuration option: "insertborderwidth" for spinbox} -setup { spinbox .e -borderwidth 2 -highlightthickness 2 -font {Helvetica -12} \ -relief sunken @@ -558,7 +558,7 @@ test spinbox-1.47 {configuration option: "insertofftime"} -setup { .e cget -insertofftime } -cleanup { destroy .e -} -result {100} +} -result 100 test spinbox-1.48 {configuration option: "insertofftime" for spinbox} -setup { spinbox .e -borderwidth 2 -highlightthickness 2 -font {Helvetica -12} \ -relief sunken @@ -580,7 +580,7 @@ test spinbox-1.49 {configuration option: "insertontime"} -setup { .e cget -insertontime } -cleanup { destroy .e -} -result {100} +} -result 100 test spinbox-1.50 {configuration option: "insertontime" for spinbox} -setup { spinbox .e -borderwidth 2 -highlightthickness 2 -font {Helvetica -12} \ -relief sunken @@ -692,7 +692,7 @@ test spinbox-1.59 {configuration option: "repeatdelay"} -setup { .e cget -repeatdelay } -cleanup { destroy .e -} -result {500} +} -result 500 test spinbox-1.60 {configuration option: "repeatdelay" for spinbox} -setup { spinbox .e -borderwidth 2 -highlightthickness 2 -font {Helvetica -12} \ -relief sunken @@ -758,7 +758,7 @@ test spinbox-1.65 {configuration option: "selectborderwidth"} -setup { .e cget -selectborderwidth } -cleanup { destroy .e -} -result {1} +} -result 1 test spinbox-1.66 {configuration option: "selectborderwidth" for spinbox} -setup { spinbox .e -borderwidth 2 -highlightthickness 2 -font {Helvetica -12} \ -relief sunken @@ -938,7 +938,7 @@ test spinbox-1.81 {configuration option: "width"} -setup { .e cget -width } -cleanup { destroy .e -} -result {402} +} -result 402 test spinbox-1.82 {configuration option: "width" for spinbox} -setup { spinbox .e -borderwidth 2 -highlightthickness 2 -font {Helvetica -12} \ -relief sunken @@ -960,7 +960,7 @@ test spinbox-1.83 {configuration option: "wrap"} -setup { .e cget -wrap } -cleanup { destroy .e -} -result {1} +} -result 1 test spinbox-1.84 {configuration option: "wrap" for spinbox} -setup { spinbox .e -borderwidth 2 -highlightthickness 2 -font {Helvetica -12} \ -relief sunken @@ -1018,7 +1018,7 @@ test spinbox-2.5 {Tk_SpinboxCmd procedure} -body { test spinbox-3.1 {SpinboxWidgetCmd procedure} -setup { - spinbox .e + spinbox .e pack .e update } -body { @@ -1027,7 +1027,7 @@ test spinbox-3.1 {SpinboxWidgetCmd procedure} -setup { destroy .e } -returnCodes error -result {wrong # args: should be ".e option ?arg ...?"} test spinbox-3.2 {SpinboxWidgetCmd procedure, "bbox" widget command} -setup { - spinbox .e -font {Courier -12} -borderwidth 2 -highlightthickness 2 + spinbox .e -font {Courier -12} -borderwidth 2 -highlightthickness 2 pack .e update } -body { @@ -1036,7 +1036,7 @@ test spinbox-3.2 {SpinboxWidgetCmd procedure, "bbox" widget command} -setup { destroy .e } -returnCodes error -result {wrong # args: should be ".e bbox index"} test spinbox-3.3 {SpinboxWidgetCmd procedure, "bbox" widget command} -setup { - spinbox .e -font {Courier -12} -borderwidth 2 -highlightthickness 2 + spinbox .e -font {Courier -12} -borderwidth 2 -highlightthickness 2 pack .e update } -body { @@ -1045,7 +1045,7 @@ test spinbox-3.3 {SpinboxWidgetCmd procedure, "bbox" widget command} -setup { destroy .e } -returnCodes error -result {wrong # args: should be ".e bbox index"} test spinbox-3.4 {SpinboxWidgetCmd procedure, "bbox" widget command} -setup { - spinbox .e + spinbox .e pack .e update } -body { @@ -1054,7 +1054,7 @@ test spinbox-3.4 {SpinboxWidgetCmd procedure, "bbox" widget command} -setup { destroy .e } -returnCodes error -result {bad spinbox index "bogus"} test spinbox-3.5 {SpinboxWidgetCmd procedure, "bbox" widget command} -setup { - spinbox .e -font {Courier -12} -borderwidth 2 -highlightthickness 2 + spinbox .e -font {Courier -12} -borderwidth 2 -highlightthickness 2 pack .e update } -body { @@ -1063,7 +1063,7 @@ test spinbox-3.5 {SpinboxWidgetCmd procedure, "bbox" widget command} -setup { destroy .e } -result [list 5 5 0 $cy] -# Oryginaly the result was count using measurements +# Oryginaly the result was count using measurements # and metrics. It was changed to less verbose solution - the result is the one # that passes fonts constraint (this concerns tests 3.6, 3.7, 3.8, 3.10) test spinbox-3.6 {SpinboxWidgetCmd procedure, "bbox" widget command} -constraints { @@ -1082,7 +1082,7 @@ test spinbox-3.6 {SpinboxWidgetCmd procedure, "bbox" widget command} -constraint test spinbox-3.7 {SpinboxWidgetCmd procedure, "bbox" widget command} -constraints { fonts } -setup { - spinbox .e -font {Courier -12} -borderwidth 2 -highlightthickness 2 + spinbox .e -font {Courier -12} -borderwidth 2 -highlightthickness 2 pack .e update } -body { @@ -1095,7 +1095,7 @@ test spinbox-3.7 {SpinboxWidgetCmd procedure, "bbox" widget command} -constraint test spinbox-3.8 {SpinboxWidgetCmd procedure, "bbox" widget command} -constraints { fonts } -setup { - spinbox .e -font {Courier -12} -borderwidth 2 -highlightthickness 2 + spinbox .e -font {Courier -12} -borderwidth 2 -highlightthickness 2 pack .e update } -body { @@ -1106,7 +1106,7 @@ test spinbox-3.8 {SpinboxWidgetCmd procedure, "bbox" widget command} -constraint destroy .e } -result {31 5 7 13} test spinbox-3.9 {SpinboxWidgetCmd procedure, "bbox" widget command} -setup { - spinbox .e -font {Courier -12} -borderwidth 2 -highlightthickness 2 + spinbox .e -font {Courier -12} -borderwidth 2 -highlightthickness 2 pack .e update } -body { @@ -1118,7 +1118,7 @@ test spinbox-3.9 {SpinboxWidgetCmd procedure, "bbox" widget command} -setup { test spinbox-3.10 {SpinboxWidgetCmd procedure, "bbox" widget command} -constraints { fonts } -setup { - spinbox .e -font {Courier -12} -borderwidth 2 -highlightthickness 2 + spinbox .e -font {Courier -12} -borderwidth 2 -highlightthickness 2 pack .e update } -body { @@ -1128,82 +1128,82 @@ test spinbox-3.10 {SpinboxWidgetCmd procedure, "bbox" widget command} -constrain destroy .e } -result {{5 5 7 13} {12 5 7 13} {75 5 12 13} {122 5 7 13}} test spinbox-3.11 {SpinboxWidgetCmd procedure, "cget" widget command} -setup { - spinbox .e + spinbox .e } -body { .e cget } -cleanup { destroy .e } -returnCodes error -result {wrong # args: should be ".e cget option"} test spinbox-3.12 {SpinboxWidgetCmd procedure, "cget" widget command} -setup { - spinbox .e + spinbox .e } -body { .e cget a b } -cleanup { destroy .e } -returnCodes error -result {wrong # args: should be ".e cget option"} test spinbox-3.13 {SpinboxWidgetCmd procedure, "cget" widget command} -setup { - spinbox .e + spinbox .e } -body { .e cget -gorp } -cleanup { destroy .e } -returnCodes error -result {unknown option "-gorp"} test spinbox-3.14 {SpinboxWidgetCmd procedure, "cget" widget command} -setup { - spinbox .e + spinbox .e } -body { .e configure -bd 4 .e cget -bd } -cleanup { destroy .e -} -result {4} +} -result 4 test spinbox-3.15 {SpinboxWidgetCmd procedure, "configure" widget command} -setup { - spinbox .e + spinbox .e pack .e update } -body { llength [.e configure] } -cleanup { destroy .e -} -result {49} +} -result 49 test spinbox-3.16 {SpinboxWidgetCmd procedure, "configure" widget command} -setup { - spinbox .e + spinbox .e } -body { .e configure -foo } -cleanup { destroy .e } -returnCodes error -result {unknown option "-foo"} test spinbox-3.17 {SpinboxWidgetCmd procedure, "configure" widget command} -setup { - spinbox .e + spinbox .e } -body { .e configure -bd 4 .e configure -bg #ffffff lindex [.e configure -bd] 4 } -cleanup { destroy .e -} -result {4} +} -result 4 test spinbox-3.18 {SpinboxWidgetCmd procedure, "delete" widget command} -setup { - spinbox .e + spinbox .e } -body { .e delete } -cleanup { destroy .e } -returnCodes error -result {wrong # args: should be ".e delete firstIndex ?lastIndex?"} test spinbox-3.19 {SpinboxWidgetCmd procedure, "delete" widget command} -setup { - spinbox .e + spinbox .e } -body { .e delete a b c } -cleanup { destroy .e } -returnCodes error -result {wrong # args: should be ".e delete firstIndex ?lastIndex?"} test spinbox-3.20 {SpinboxWidgetCmd procedure, "delete" widget command} -setup { - spinbox .e + spinbox .e } -body { .e delete foo } -cleanup { destroy .e } -returnCodes error -result {bad spinbox index "foo"} test spinbox-3.21 {SpinboxWidgetCmd procedure, "delete" widget command} -setup { - spinbox .e + spinbox .e } -body { .e delete 0 bar } -cleanup { @@ -1212,27 +1212,27 @@ test spinbox-3.21 {SpinboxWidgetCmd procedure, "delete" widget command} -setup { test spinbox-3.22 {SpinboxWidgetCmd procedure, "delete" widget command} -setup { spinbox .e pack .e - update + update } -body { .e insert end "01234567890" .e delete 2 4 .e get } -cleanup { destroy .e -} -result {014567890} +} -result 014567890 test spinbox-3.23 {SpinboxWidgetCmd procedure, "delete" widget command} -setup { - spinbox .e + spinbox .e } -body { .e insert end "01234567890" .e delete 6 .e get } -cleanup { destroy .e -} -result {0123457890} +} -result 0123457890 test spinbox-3.24 {SpinboxWidgetCmd procedure, "delete" widget command} -setup { spinbox .e pack .e - update + update set x {} } -body { # UTF @@ -1253,18 +1253,18 @@ test spinbox-3.24 {SpinboxWidgetCmd procedure, "delete" widget command} -setup { test spinbox-3.25 {SpinboxWidgetCmd procedure, "delete" widget command} -setup { spinbox .e pack .e - update + update } -body { .e insert end "01234567890" .e delete 6 5 .e get } -cleanup { destroy .e -} -result {01234567890} +} -result 01234567890 test spinbox-3.26 {SpinboxWidgetCmd procedure, "delete" widget command} -setup { spinbox .e pack .e - update + update } -body { .e insert end "01234567890" .e configure -state disabled @@ -1273,11 +1273,11 @@ test spinbox-3.26 {SpinboxWidgetCmd procedure, "delete" widget command} -setup { .e get } -cleanup { destroy .e -} -result {01234567890} +} -result 01234567890 test spinbox-3.26.1 {SpinboxWidgetCmd procedure, "delete" widget command} -setup { spinbox .e pack .e - update + update } -body { .e insert end "01234567890" .e configure -state readonly @@ -1286,53 +1286,53 @@ test spinbox-3.26.1 {SpinboxWidgetCmd procedure, "delete" widget command} -setup .e get } -cleanup { destroy .e -} -result {01234567890} +} -result 01234567890 test spinbox-3.27 {SpinboxWidgetCmd procedure, "get" widget command} -setup { - spinbox .e + spinbox .e } -body { .e get foo } -cleanup { destroy .e } -returnCodes error -result {wrong # args: should be ".e get"} test spinbox-3.28 {SpinboxWidgetCmd procedure, "icursor" widget command} -setup { - spinbox .e + spinbox .e } -body { .e icursor } -cleanup { destroy .e } -returnCodes error -result {wrong # args: should be ".e icursor pos"} test spinbox-3.29 {SpinboxWidgetCmd procedure, "icursor" widget command} -setup { - spinbox .e + spinbox .e } -body { .e icursor foo } -cleanup { destroy .e } -returnCodes error -result {bad spinbox index "foo"} test spinbox-3.30 {SpinboxWidgetCmd procedure, "icursor" widget command} -setup { - spinbox .e + spinbox .e } -body { .e insert end "01234567890" .e icursor 4 .e index insert } -cleanup { destroy .e -} -result {4} +} -result 4 test spinbox-3.31 {SpinboxWidgetCmd procedure, "index" widget command} -setup { - spinbox .e + spinbox .e } -body { .e in } -cleanup { destroy .e } -returnCodes error -result {ambiguous option "in": must be bbox, cget, configure, delete, get, icursor, identify, index, insert, invoke, scan, selection, set, validate, or xview} test spinbox-3.32 {SpinboxWidgetCmd procedure, "index" widget command} -setup { - spinbox .e + spinbox .e } -body { .e index } -cleanup { destroy .e } -returnCodes error -result {wrong # args: should be ".e index string"} test spinbox-3.33 {SpinboxWidgetCmd procedure, "index" widget command} -setup { - spinbox .e + spinbox .e } -body { .e index foo } -cleanup { @@ -1341,7 +1341,7 @@ test spinbox-3.33 {SpinboxWidgetCmd procedure, "index" widget command} -setup { test spinbox-3.34 {SpinboxWidgetCmd procedure, "index" widget command} -setup { spinbox .e pack .e - update + update } -body { .e index 0 } -cleanup { @@ -1350,7 +1350,7 @@ test spinbox-3.34 {SpinboxWidgetCmd procedure, "index" widget command} -setup { test spinbox-3.35 {SpinboxWidgetCmd procedure, "index" widget command} -setup { spinbox .e pack .e - update + update } -body { # UTF .e insert 0 abc\u4e4e\u0153def @@ -1359,21 +1359,21 @@ test spinbox-3.35 {SpinboxWidgetCmd procedure, "index" widget command} -setup { destroy .e } -result {3 4 8} test spinbox-3.36 {SpinboxWidgetCmd procedure, "insert" widget command} -setup { - spinbox .e + spinbox .e } -body { .e insert a } -cleanup { destroy .e } -returnCodes error -result {wrong # args: should be ".e insert index text"} test spinbox-3.37 {SpinboxWidgetCmd procedure, "insert" widget command} -setup { - spinbox .e + spinbox .e } -body { .e insert a b c } -cleanup { destroy .e } -returnCodes error -result {wrong # args: should be ".e insert index text"} test spinbox-3.38 {SpinboxWidgetCmd procedure, "insert" widget command} -setup { - spinbox .e + spinbox .e } -body { .e insert foo Text } -cleanup { @@ -1382,7 +1382,7 @@ test spinbox-3.38 {SpinboxWidgetCmd procedure, "insert" widget command} -setup { test spinbox-3.39 {SpinboxWidgetCmd procedure, "insert" widget command} -setup { spinbox .e pack .e - update + update } -body { .e insert end "01234567890" .e insert 3 xxx @@ -1393,7 +1393,7 @@ test spinbox-3.39 {SpinboxWidgetCmd procedure, "insert" widget command} -setup { test spinbox-3.40 {SpinboxWidgetCmd procedure, "insert" widget command} -setup { spinbox .e pack .e - update + update } -body { .e insert end "01234567890" .e configure -state disabled @@ -1402,11 +1402,11 @@ test spinbox-3.40 {SpinboxWidgetCmd procedure, "insert" widget command} -setup { .e get } -cleanup { destroy .e -} -result {01234567890} +} -result 01234567890 test spinbox-3.40.1 {SpinboxWidgetCmd procedure, "insert" widget command} -setup { spinbox .e pack .e - update + update } -body { .e insert end "01234567890" .e configure -state readonly @@ -1415,16 +1415,16 @@ test spinbox-3.40.1 {SpinboxWidgetCmd procedure, "insert" widget command} -setup .e get } -cleanup { destroy .e -} -result {01234567890} +} -result 01234567890 test spinbox-3.41 {SpinboxWidgetCmd procedure, "insert" widget command} -setup { - spinbox .e + spinbox .e } -body { .e insert a b c } -cleanup { destroy .e } -returnCodes error -result {wrong # args: should be ".e insert index text"} test spinbox-3.42 {SpinboxWidgetCmd procedure, "scan" widget command} -setup { - spinbox .e + spinbox .e pack .e update } -body { @@ -1435,7 +1435,7 @@ test spinbox-3.42 {SpinboxWidgetCmd procedure, "scan" widget command} -setup { test spinbox-3.43 {SpinboxWidgetCmd procedure, "scan" widget command} -setup { spinbox .e pack .e - update + update } -body { .e scan a b c } -cleanup { @@ -1444,7 +1444,7 @@ test spinbox-3.43 {SpinboxWidgetCmd procedure, "scan" widget command} -setup { test spinbox-3.44 {SpinboxWidgetCmd procedure, "scan" widget command} -setup { spinbox .e pack .e - update + update } -body { .e scan foobar 20 } -cleanup { @@ -1453,7 +1453,7 @@ test spinbox-3.44 {SpinboxWidgetCmd procedure, "scan" widget command} -setup { test spinbox-3.45 {SpinboxWidgetCmd procedure, "scan" widget command} -setup { spinbox .e pack .e - update + update } -body { .e scan mark 20.1 } -cleanup { @@ -1464,7 +1464,7 @@ test spinbox-3.45 {SpinboxWidgetCmd procedure, "scan" widget command} -setup { test spinbox-3.46 {SpinboxWidgetCmd procedure, "scan" widget command} -constraints { fonts } -setup { - spinbox .e -font {Helvetica -12} -borderwidth 2 -highlightthickness 2 + spinbox .e -font {Helvetica -12} -borderwidth 2 -highlightthickness 2 pack .e update } -body { @@ -1475,16 +1475,16 @@ test spinbox-3.46 {SpinboxWidgetCmd procedure, "scan" widget command} -constrain .e index @0 } -cleanup { destroy .e -} -result {2} +} -result 2 test spinbox-3.47 {SpinboxWidgetCmd procedure, "select" widget command} -setup { - spinbox .e + spinbox .e } -body { .e select } -cleanup { destroy .e } -returnCodes error -result {wrong # args: should be ".e selection option ?index?"} test spinbox-3.48 {SpinboxWidgetCmd procedure, "select" widget command} -setup { - spinbox .e + spinbox .e } -body { .e select foo } -cleanup { @@ -1492,28 +1492,28 @@ test spinbox-3.48 {SpinboxWidgetCmd procedure, "select" widget command} -setup { } -returnCodes error -result {bad selection option "foo": must be adjust, clear, element, from, present, range, or to} test spinbox-3.49 {SpinboxWidgetCmd procedure, "select clear" widget command} -setup { - spinbox .e + spinbox .e } -body { .e select clear gorp } -cleanup { destroy .e } -returnCodes error -result {wrong # args: should be ".e selection clear"} test spinbox-3.50 {SpinboxWidgetCmd procedure, "select clear" widget command} -setup { - spinbox .e + spinbox .e } -body { .e insert end "0123456789" .e select from 1 .e select to 4 update .e select clear - selection get + selection get } -cleanup { destroy .e } -returnCodes error -result {PRIMARY selection doesn't exist or form "STRING" not defined} test spinbox-3.50.1 {SpinboxWidgetCmd procedure, "select clear" widget command} -setup { spinbox .e pack .e - update + update } -body { .e insert end "0123456789" .e select from 1 @@ -1527,7 +1527,7 @@ test spinbox-3.50.1 {SpinboxWidgetCmd procedure, "select clear" widget command} } -result {.e} test spinbox-3.51 {SpinboxWidgetCmd procedure, "selection present" widget command} -setup { - spinbox .e + spinbox .e } -body { .e selection present foo } -cleanup { @@ -1536,7 +1536,7 @@ test spinbox-3.51 {SpinboxWidgetCmd procedure, "selection present" widget comman test spinbox-3.52 {SpinboxWidgetCmd procedure, "selection present" widget command} -setup { spinbox .e pack .e - update + update } -body { .e insert end 0123456789 .e select from 3 @@ -1544,11 +1544,11 @@ test spinbox-3.52 {SpinboxWidgetCmd procedure, "selection present" widget comman .e selection present } -cleanup { destroy .e -} -result {1} +} -result 1 test spinbox-3.53 {SpinboxWidgetCmd procedure, "selection present" widget command} -setup { spinbox .e pack .e - update + update } -body { .e insert end 0123456789 .e select from 3 @@ -1557,11 +1557,11 @@ test spinbox-3.53 {SpinboxWidgetCmd procedure, "selection present" widget comman .e selection present } -cleanup { destroy .e -} -result {1} +} -result 1 test spinbox-3.54 {SpinboxWidgetCmd procedure, "selection present" widget command} -setup { spinbox .e pack .e - update + update } -body { .e insert end 0123456789 .e select from 3 @@ -1570,7 +1570,7 @@ test spinbox-3.54 {SpinboxWidgetCmd procedure, "selection present" widget comman .e selection present } -cleanup { destroy .e -} -result {0} +} -result 0 test spinbox-3.55 {SpinboxWidgetCmd procedure, "selection adjust" widget command} -setup { spinbox .e } -body { @@ -1598,7 +1598,7 @@ test spinbox-3.57 {SpinboxWidgetCmd procedure, "selection adjust" widget command selection get } -cleanup { destroy .e -} -result {123} +} -result 123 test spinbox-3.58 {SpinboxWidgetCmd procedure, "selection adjust" widget command} -setup { spinbox .e pack .e @@ -1612,7 +1612,7 @@ test spinbox-3.58 {SpinboxWidgetCmd procedure, "selection adjust" widget command selection get } -cleanup { destroy .e -} -result {234} +} -result 234 test spinbox-3.59 {SpinboxWidgetCmd procedure, "selection from" widget command} -setup { spinbox .e } -body { @@ -1700,7 +1700,7 @@ test spinbox-3.64.2 {SpinboxWidgetCmd procedure, "selection" widget command} -se } -result {2 4} test spinbox-3.65 {SpinboxWidgetCmd procedure, "xview" widget command} -setup { - spinbox .e -font {Courier -12} -borderwidth 2 -highlightthickness 2 + spinbox .e -font {Courier -12} -borderwidth 2 -highlightthickness 2 pack .e update } -body { @@ -1712,7 +1712,7 @@ test spinbox-3.65 {SpinboxWidgetCmd procedure, "xview" widget command} -setup { destroy .e } -result {0.053763 0.268817} test spinbox-3.66 {SpinboxWidgetCmd procedure, "xview" widget command} -setup { - spinbox .e -font {Courier -12} -borderwidth 2 -highlightthickness 2 + spinbox .e -font {Courier -12} -borderwidth 2 -highlightthickness 2 pack .e update } -body { @@ -1721,7 +1721,7 @@ test spinbox-3.66 {SpinboxWidgetCmd procedure, "xview" widget command} -setup { destroy .e } -returnCodes error -result {bad spinbox index "gorp"} test spinbox-3.67 {SpinboxWidgetCmd procedure, "xview" widget command} -setup { - spinbox .e -font {Courier -12} -borderwidth 2 -highlightthickness 2 + spinbox .e -font {Courier -12} -borderwidth 2 -highlightthickness 2 pack .e update } -body { @@ -1735,7 +1735,7 @@ test spinbox-3.67 {SpinboxWidgetCmd procedure, "xview" widget command} -setup { destroy .e } -result {0.107527 0.322581} test spinbox-3.68 {SpinboxWidgetCmd procedure, "xview" widget command} -setup { - spinbox .e -font {Courier -12} -borderwidth 2 -highlightthickness 2 + spinbox .e -font {Courier -12} -borderwidth 2 -highlightthickness 2 pack .e update } -body { @@ -1744,7 +1744,7 @@ test spinbox-3.68 {SpinboxWidgetCmd procedure, "xview" widget command} -setup { destroy .e } -returnCodes error -result {wrong # args: should be ".e xview moveto fraction"} test spinbox-3.69 {SpinboxWidgetCmd procedure, "xview" widget command} -setup { - spinbox .e -font {Courier -12} -borderwidth 2 -highlightthickness 2 + spinbox .e -font {Courier -12} -borderwidth 2 -highlightthickness 2 pack .e update } -body { @@ -1753,7 +1753,7 @@ test spinbox-3.69 {SpinboxWidgetCmd procedure, "xview" widget command} -setup { destroy .e } -returnCodes error -result {expected floating-point number but got "foo"} test spinbox-3.70 {SpinboxWidgetCmd procedure, "xview" widget command} -setup { - spinbox .e -font {Courier -12} -borderwidth 2 -highlightthickness 2 + spinbox .e -font {Courier -12} -borderwidth 2 -highlightthickness 2 pack .e update } -body { @@ -1765,7 +1765,7 @@ test spinbox-3.70 {SpinboxWidgetCmd procedure, "xview" widget command} -setup { destroy .e } -result {0.505376 0.720430} test spinbox-3.71 {SpinboxWidgetCmd procedure, "xview" widget command} -setup { - spinbox .e -font {Courier -12} -borderwidth 2 -highlightthickness 2 + spinbox .e -font {Courier -12} -borderwidth 2 -highlightthickness 2 pack .e update } -body { @@ -1776,7 +1776,7 @@ test spinbox-3.71 {SpinboxWidgetCmd procedure, "xview" widget command} -setup { destroy .e } -returnCodes error -result {wrong # args: should be ".e xview scroll number units|pages"} test spinbox-3.72 {SpinboxWidgetCmd procedure, "xview" widget command} -setup { - spinbox .e -font {Courier -12} -borderwidth 2 -highlightthickness 2 + spinbox .e -font {Courier -12} -borderwidth 2 -highlightthickness 2 pack .e } -body { .e insert end "This is quite a long text string, so long that it " @@ -1787,7 +1787,7 @@ test spinbox-3.72 {SpinboxWidgetCmd procedure, "xview" widget command} -setup { destroy .e } -returnCodes error -result {expected integer but got "gorp"} test spinbox-3.73 {SpinboxWidgetCmd procedure, "xview" widget command} -setup { - spinbox .e -font {Courier -12} -borderwidth 2 -highlightthickness 2 + spinbox .e -font {Courier -12} -borderwidth 2 -highlightthickness 2 pack .e } -body { .e insert end "This is quite a long text string, so long that it " @@ -1800,7 +1800,7 @@ test spinbox-3.73 {SpinboxWidgetCmd procedure, "xview" widget command} -setup { destroy .e } -result {0.193548 0.408602} test spinbox-3.74 {SpinboxWidgetCmd procedure, "xview" widget command} -setup { - spinbox .e -font {Courier -12} -borderwidth 2 -highlightthickness 2 + spinbox .e -font {Courier -12} -borderwidth 2 -highlightthickness 2 pack .e update } -body { @@ -1814,7 +1814,7 @@ test spinbox-3.74 {SpinboxWidgetCmd procedure, "xview" widget command} -setup { destroy .e } -result {0.397849 0.612903} test spinbox-3.75 {SpinboxWidgetCmd procedure, "xview" widget command} -setup { - spinbox .e -font {Courier -12} -borderwidth 2 -highlightthickness 2 + spinbox .e -font {Courier -12} -borderwidth 2 -highlightthickness 2 pack .e } -body { .e insert end "This is quite a long text string, so long that it " @@ -1822,13 +1822,13 @@ test spinbox-3.75 {SpinboxWidgetCmd procedure, "xview" widget command} -setup { update .e xview 30 update - .e xview scroll 2 units + .e xview scroll 2 units .e index @0 } -cleanup { destroy .e -} -result {32} +} -result 32 test spinbox-3.76 {SpinboxWidgetCmd procedure, "xview" widget command} -setup { - spinbox .e -font {Courier -12} -borderwidth 2 -highlightthickness 2 + spinbox .e -font {Courier -12} -borderwidth 2 -highlightthickness 2 pack .e } -body { .e insert end "This is quite a long text string, so long that it " @@ -1836,13 +1836,13 @@ test spinbox-3.76 {SpinboxWidgetCmd procedure, "xview" widget command} -setup { update .e xview 30 update - .e xview scroll -1 units + .e xview scroll -1 units .e index @0 } -cleanup { destroy .e -} -result {29} +} -result 29 test spinbox-3.77 {SpinboxWidgetCmd procedure, "xview" widget command} -setup { - spinbox .e -font {Courier -12} -borderwidth 2 -highlightthickness 2 + spinbox .e -font {Courier -12} -borderwidth 2 -highlightthickness 2 pack .e } -body { .e insert end "This is quite a long text string, so long that it " @@ -1853,7 +1853,7 @@ test spinbox-3.77 {SpinboxWidgetCmd procedure, "xview" widget command} -setup { destroy .e } -returnCodes error -result {bad argument "foobars": must be units or pages} test spinbox-3.78 {SpinboxWidgetCmd procedure, "xview" widget command} -setup { - spinbox .e -font {Courier -12} -borderwidth 2 -highlightthickness 2 + spinbox .e -font {Courier -12} -borderwidth 2 -highlightthickness 2 pack .e } -body { .e insert end "This is quite a long text string, so long that it " @@ -1864,7 +1864,7 @@ test spinbox-3.78 {SpinboxWidgetCmd procedure, "xview" widget command} -setup { destroy .e } -returnCodes error -result {unknown option "eat": must be moveto or scroll} test spinbox-3.79 {SpinboxWidgetCmd procedure, "xview" widget command} -setup { - spinbox .e -font {Courier -12} -borderwidth 2 -highlightthickness 2 + spinbox .e -font {Courier -12} -borderwidth 2 -highlightthickness 2 pack .e update } -body { @@ -1872,13 +1872,13 @@ test spinbox-3.79 {SpinboxWidgetCmd procedure, "xview" widget command} -setup { .e insert end "runs off the end of the window quite a bit." .e xview 0 update - .e xview -4 + .e xview -1 .e index @0 } -cleanup { destroy .e -} -result {0} +} -result 0 test spinbox-3.80 {SpinboxWidgetCmd procedure, "xview" widget command} -setup { - spinbox .e -font {Courier -12} -borderwidth 2 -highlightthickness 2 + spinbox .e -font {Courier -12} -borderwidth 2 -highlightthickness 2 pack .e } -body { .e insert end "This is quite a long text string, so long that it " @@ -1888,9 +1888,9 @@ test spinbox-3.80 {SpinboxWidgetCmd procedure, "xview" widget command} -setup { .e index @0 } -cleanup { destroy .e -} -result {73} +} -result 73 test spinbox-3.81 {SpinboxWidgetCmd procedure, "xview" widget command} -setup { - spinbox .e -font {Courier -12} -borderwidth 2 -highlightthickness 2 + spinbox .e -font {Courier -12} -borderwidth 2 -highlightthickness 2 pack .e } -body { .e insert end "This is quite a long text string, so long that it " @@ -1912,7 +1912,7 @@ test spinbox-3.81 {SpinboxWidgetCmd procedure, "xview" widget command} -setup { } -result {0.095745 0.106383 0.117021} test spinbox-3.82 {SpinboxWidgetCmd procedure} -setup { - spinbox .e -font {Courier -12} -borderwidth 2 -highlightthickness 2 + spinbox .e -font {Courier -12} -borderwidth 2 -highlightthickness 2 pack .e update } -body { @@ -1927,7 +1927,7 @@ test spinbox-5.1 {ConfigureSpinbox procedure, -textvariable} -body { .e get } -cleanup { destroy .e -} -result {12345} +} -result 12345 test spinbox-5.2 {ConfigureSpinbox procedure, -textvariable} -body { set x 12345 spinbox .e -textvariable x @@ -1983,14 +1983,14 @@ test spinbox-5.5 {ConfigureSpinbox procedure} -setup { destroy .e1 .e2 } -result {{This is so} {This is so} 1234} test spinbox-5.6 {ConfigureSpinbox procedure} -setup { - spinbox .e + spinbox .e pack .e } -body { .e insert end "0123456789" .e select from 1 .e select to 5 .e configure -exportselection 0 - selection get + selection get } -cleanup { destroy .e } -returnCodes error -result {PRIMARY selection doesn't exist or form "STRING" not defined} @@ -2002,14 +2002,14 @@ test spinbox-5.6.1 {ConfigureSpinbox procedure} -setup { .e select from 1 .e select to 5 .e configure -exportselection 0 - catch {selection get} + catch {selection get} list [.e index sel.first] [.e index sel.last] } -cleanup { destroy .e } -result {1 5} test spinbox-5.7 {ConfigureSpinbox procedure} -setup { - spinbox .e -font {Helvetica -12} -borderwidth 2 -highlightthickness 2 + spinbox .e -font {Helvetica -12} -borderwidth 2 -highlightthickness 2 pack .e } -body { .e configure -font {Courier -12} -width 4 -xscrollcommand scroll @@ -2027,7 +2027,7 @@ test spinbox-5.7 {ConfigureSpinbox procedure} -setup { test spinbox-5.8 {ConfigureSpinbox procedure} -constraints { fonts } -setup { - spinbox .e -borderwidth 2 -highlightthickness 2 + spinbox .e -borderwidth 2 -highlightthickness 2 pack .e } -body { .e configure -width 0 -font {Helvetica -12} @@ -2082,7 +2082,7 @@ test spinbox-5.11 {ConfigureSpinbox procedure} -setup { test spinbox-6.1 {SpinboxComputeGeometry procedure} -constraints { fonts } -setup { - spinbox .e + spinbox .e pack .e } -body { .e configure -font {Courier -12} -bd 2 -relief raised -width 20 -highlightthickness 3 @@ -2095,7 +2095,7 @@ test spinbox-6.1 {SpinboxComputeGeometry procedure} -constraints { test spinbox-6.2 {SpinboxComputeGeometry procedure} -constraints { fonts } -setup { - spinbox .e + spinbox .e pack .e } -body { .e configure -font {Courier -12} -bd 2 -relief raised -width 20 -justify center \ @@ -2109,7 +2109,7 @@ test spinbox-6.2 {SpinboxComputeGeometry procedure} -constraints { test spinbox-6.3 {SpinboxComputeGeometry procedure} -constraints { fonts } -setup { - spinbox .e + spinbox .e pack .e } -body { .e configure -font {Courier -12} -bd 2 -relief raised -width 20 -justify right \ @@ -2121,7 +2121,7 @@ test spinbox-6.3 {SpinboxComputeGeometry procedure} -constraints { destroy .e } -result {3 4} test spinbox-6.4 {SpinboxComputeGeometry procedure} -setup { - spinbox .e + spinbox .e pack .e } -body { .e configure -font {Courier -12} -bd 2 -relief raised -width 5 @@ -2131,26 +2131,26 @@ test spinbox-6.4 {SpinboxComputeGeometry procedure} -setup { .e index @0 } -cleanup { destroy .e -} -result {6} +} -result 6 test spinbox-6.5 {SpinboxComputeGeometry procedure} -setup { spinbox .e -highlightthickness 2 pack .e } -body { - .e configure -font {Courier -12} -bd 2 -relief raised -width 5 + .e configure -font {Courier -12} -bd 2 -relief raised -width 5 .e insert end "01234567890" update .e xview 7 .e index @0 } -cleanup { destroy .e -} -result {6} +} -result 6 test spinbox-6.6 {SpinboxComputeGeometry procedure} -constraints { fonts } -setup { spinbox .e -highlightthickness 2 pack .e } -body { - .e configure -font {Courier -12} -bd 2 -relief raised -width 10 + .e configure -font {Courier -12} -bd 2 -relief raised -width 10 .e insert end "01234\t67890" update .e xview 3 @@ -2190,7 +2190,7 @@ test spinbox-6.9 {SpinboxComputeGeometry procedure} -constraints { spinbox .e -highlightthickness 2 pack .e } -body { - .e configure -font {Helvetica -24} -bd 3 -relief raised -width 0 + .e configure -font {Helvetica -24} -bd 3 -relief raised -width 0 update list [winfo reqwidth .e] [winfo reqheight .e] } -cleanup { @@ -2199,7 +2199,7 @@ test spinbox-6.9 {SpinboxComputeGeometry procedure} -constraints { test spinbox-7.1 {InsertChars procedure} -setup { - unset -nocomplain contents + unset -nocomplain contents spinbox .e -width 10 -font {Courier -12} -highlightthickness 2 -bd 2 pack .e focus .e @@ -2217,8 +2217,8 @@ test spinbox-7.1 {InsertChars procedure} -setup { } -result {abXXXcde abXXXcde {0.000000 1.000000}} test spinbox-7.2 {InsertChars procedure} -setup { - unset -nocomplain contents - spinbox .e -width 10 -font {Courier -12} -highlightthickness 2 -bd 2 + unset -nocomplain contents + spinbox .e -width 10 -font {Courier -12} -highlightthickness 2 -bd 2 pack .e focus .e } -body { @@ -2290,7 +2290,7 @@ test spinbox-7.6 {InsertChars procedure} -setup { destroy .e } -result {2 6 2 5} test spinbox-7.7 {InsertChars procedure} -setup { - spinbox .e -width 10 -font {Courier -12} -highlightthickness 2 -bd 2 + spinbox .e -width 10 -font {Courier -12} -highlightthickness 2 -bd 2 pack .e } -body { .e configure -xscrollcommand scroll @@ -2300,9 +2300,9 @@ test spinbox-7.7 {InsertChars procedure} -setup { .e index insert } -cleanup { destroy .e -} -result {7} +} -result 7 test spinbox-7.8 {InsertChars procedure} -setup { - spinbox .e -width 10 -font {Courier -12} -highlightthickness 2 -bd 2 + spinbox .e -width 10 -font {Courier -12} -highlightthickness 2 -bd 2 pack .e } -body { .e insert 0 0123456789 @@ -2311,9 +2311,9 @@ test spinbox-7.8 {InsertChars procedure} -setup { .e index insert } -cleanup { destroy .e -} -result {4} +} -result 4 test spinbox-7.9 {InsertChars procedure} -setup { - spinbox .e -width 10 -font {Courier -12} -highlightthickness 2 -bd 2 + spinbox .e -width 10 -font {Courier -12} -highlightthickness 2 -bd 2 pack .e } -body { .e insert 0 "This is a very long string" @@ -2323,9 +2323,9 @@ test spinbox-7.9 {InsertChars procedure} -setup { .e index @0 } -cleanup { destroy .e -} -result {7} +} -result 7 test spinbox-7.10 {InsertChars procedure} -setup { - spinbox .e -width 10 -font {Courier -12} -highlightthickness 2 -bd 2 + spinbox .e -width 10 -font {Courier -12} -highlightthickness 2 -bd 2 pack .e } -body { .e insert 0 "This is a very long string" @@ -2335,12 +2335,12 @@ test spinbox-7.10 {InsertChars procedure} -setup { .e index @0 } -cleanup { destroy .e -} -result {4} +} -result 4 test spinbox-7.11 {InsertChars procedure} -constraints { fonts } -setup { - spinbox .e -width 0 -font {Courier -12} -highlightthickness 2 -bd 2 + spinbox .e -width 0 -font {Courier -12} -highlightthickness 2 -bd 2 pack .e } -body { .e insert 0 "xyzzy" @@ -2349,11 +2349,11 @@ test spinbox-7.11 {InsertChars procedure} -constraints { winfo reqwidth .e } -cleanup { destroy .e -} -result {70} +} -result 70 test spinbox-8.1 {DeleteChars procedure} -setup { - unset -nocomplain contents - spinbox .e -width 10 -font {Courier -12} -highlightthickness 2 -bd 2 + unset -nocomplain contents + spinbox .e -width 10 -font {Courier -12} -highlightthickness 2 -bd 2 pack .e focus .e } -body { @@ -2369,8 +2369,8 @@ test spinbox-8.1 {DeleteChars procedure} -setup { after cancel $timeout } -result {abe abe {0.000000 1.000000}} test spinbox-8.2 {DeleteChars procedure} -setup { - unset -nocomplain contents - spinbox .e -width 10 -font {Courier -12} -highlightthickness 2 -bd 2 + unset -nocomplain contents + spinbox .e -width 10 -font {Courier -12} -highlightthickness 2 -bd 2 pack .e focus .e } -body { @@ -2378,7 +2378,7 @@ test spinbox-8.2 {DeleteChars procedure} -setup { .e insert 0 abcde update idletasks set timeout [after 500 {set scrollInfo {-1000000 -1000000}}] - .e delete -2 2 + .e delete -1 2 vwait scrollInfo list [.e get] $contents [format {%.6f %.6f} {*}$scrollInfo] } -cleanup { @@ -2386,8 +2386,8 @@ test spinbox-8.2 {DeleteChars procedure} -setup { after cancel $timeout } -result {cde cde {0.000000 1.000000}} test spinbox-8.3 {DeleteChars procedure} -setup { - unset -nocomplain contents - spinbox .e -width 10 -font {Courier -12} -highlightthickness 2 -bd 2 + unset -nocomplain contents + spinbox .e -width 10 -font {Courier -12} -highlightthickness 2 -bd 2 pack .e focus .e } -body { @@ -2403,7 +2403,7 @@ test spinbox-8.3 {DeleteChars procedure} -setup { after cancel $timeout } -result {abc abc {0.000000 1.000000}} test spinbox-8.4 {DeleteChars procedure} -setup { - spinbox .e -width 10 -font {Courier -12} -highlightthickness 2 -bd 2 + spinbox .e -width 10 -font {Courier -12} -highlightthickness 2 -bd 2 pack .e focus .e } -body { @@ -2419,7 +2419,7 @@ test spinbox-8.4 {DeleteChars procedure} -setup { destroy .e } -result {1 6 1 5} test spinbox-8.5 {DeleteChars procedure} -setup { - spinbox .e -width 10 -font {Courier -12} -highlightthickness 2 -bd 2 + spinbox .e -width 10 -font {Courier -12} -highlightthickness 2 -bd 2 pack .e focus .e } -body { @@ -2435,7 +2435,7 @@ test spinbox-8.5 {DeleteChars procedure} -setup { destroy .e } -result {1 5 1 4} test spinbox-8.6 {DeleteChars procedure} -setup { - spinbox .e -width 10 -font {Courier -12} -highlightthickness 2 -bd 2 + spinbox .e -width 10 -font {Courier -12} -highlightthickness 2 -bd 2 pack .e focus .e } -body { @@ -2451,7 +2451,7 @@ test spinbox-8.6 {DeleteChars procedure} -setup { destroy .e } -result {1 2 1 5} test spinbox-8.7 {DeleteChars procedure} -setup { - spinbox .e -width 10 -font {Courier -12} -highlightthickness 2 -bd 2 + spinbox .e -width 10 -font {Courier -12} -highlightthickness 2 -bd 2 pack .e focus .e } -body { @@ -2465,7 +2465,7 @@ test spinbox-8.7 {DeleteChars procedure} -setup { destroy .e } -returnCodes error -result {selection isn't in widget .e} test spinbox-8.8 {DeleteChars procedure} -setup { - spinbox .e -width 10 -font {Courier -12} -highlightthickness 2 -bd 2 + spinbox .e -width 10 -font {Courier -12} -highlightthickness 2 -bd 2 pack .e focus .e } -body { @@ -2481,7 +2481,7 @@ test spinbox-8.8 {DeleteChars procedure} -setup { destroy .e } -result {3 4 3 8} test spinbox-8.9 {DeleteChars procedure} -setup { - spinbox .e -width 10 -font {Courier -12} -highlightthickness 2 -bd 2 + spinbox .e -width 10 -font {Courier -12} -highlightthickness 2 -bd 2 pack .e } -body { .e insert 0 0123456789abcde @@ -2494,7 +2494,7 @@ test spinbox-8.9 {DeleteChars procedure} -setup { destroy .e } -returnCodes error -result {selection isn't in widget .e} test spinbox-8.10 {DeleteChars procedure} -setup { - spinbox .e -width 10 -font {Courier -12} -highlightthickness 2 -bd 2 + spinbox .e -width 10 -font {Courier -12} -highlightthickness 2 -bd 2 pack .e focus .e } -body { @@ -2510,7 +2510,7 @@ test spinbox-8.10 {DeleteChars procedure} -setup { destroy .e } -result {3 5 5 8} test spinbox-8.11 {DeleteChars procedure} -setup { - spinbox .e -width 10 -font {Courier -12} -highlightthickness 2 -bd 2 + spinbox .e -width 10 -font {Courier -12} -highlightthickness 2 -bd 2 pack .e focus .e } -body { @@ -2526,7 +2526,7 @@ test spinbox-8.11 {DeleteChars procedure} -setup { destroy .e } -result {3 8 4 8} test spinbox-8.12 {DeleteChars procedure} -setup { - spinbox .e -width 10 -font {Courier -12} -highlightthickness 2 -bd 2 + spinbox .e -width 10 -font {Courier -12} -highlightthickness 2 -bd 2 pack .e focus .e } -body { @@ -2537,9 +2537,9 @@ test spinbox-8.12 {DeleteChars procedure} -setup { .e index insert } -cleanup { destroy .e -} -result {1} +} -result 1 test spinbox-8.13 {DeleteChars procedure} -setup { - spinbox .e -width 10 -font {Courier -12} -highlightthickness 2 -bd 2 + spinbox .e -width 10 -font {Courier -12} -highlightthickness 2 -bd 2 pack .e focus .e } -body { @@ -2550,9 +2550,9 @@ test spinbox-8.13 {DeleteChars procedure} -setup { .e index insert } -cleanup { destroy .e -} -result {1} +} -result 1 test spinbox-8.14 {DeleteChars procedure} -setup { - spinbox .e -width 10 -font {Courier -12} -highlightthickness 2 -bd 2 + spinbox .e -width 10 -font {Courier -12} -highlightthickness 2 -bd 2 pack .e focus .e } -body { @@ -2563,9 +2563,9 @@ test spinbox-8.14 {DeleteChars procedure} -setup { .e index insert } -cleanup { destroy .e -} -result {4} +} -result 4 test spinbox-8.15 {DeleteChars procedure} -setup { - spinbox .e -width 10 -font {Courier -12} -highlightthickness 2 -bd 2 + spinbox .e -width 10 -font {Courier -12} -highlightthickness 2 -bd 2 pack .e focus .e } -body { @@ -2576,9 +2576,9 @@ test spinbox-8.15 {DeleteChars procedure} -setup { .e index @0 } -cleanup { destroy .e -} -result {1} +} -result 1 test spinbox-8.16 {DeleteChars procedure} -setup { - spinbox .e -width 10 -font {Courier -12} -highlightthickness 2 -bd 2 + spinbox .e -width 10 -font {Courier -12} -highlightthickness 2 -bd 2 pack .e focus .e } -body { @@ -2589,9 +2589,9 @@ test spinbox-8.16 {DeleteChars procedure} -setup { .e index @0 } -cleanup { destroy .e -} -result {1} +} -result 1 test spinbox-8.17 {DeleteChars procedure} -setup { - spinbox .e -width 10 -font {Courier -12} -highlightthickness 2 -bd 2 + spinbox .e -width 10 -font {Courier -12} -highlightthickness 2 -bd 2 pack .e focus .e } -body { @@ -2602,9 +2602,9 @@ test spinbox-8.17 {DeleteChars procedure} -setup { .e index @0 } -cleanup { destroy .e -} -result {4} +} -result 4 test spinbox-8.18 {DeleteChars procedure} -setup { - spinbox .e -width 0 -font {Courier -12} -highlightthickness 2 -bd 2 + spinbox .e -width 0 -font {Courier -12} -highlightthickness 2 -bd 2 pack .e focus .e } -body { @@ -2614,7 +2614,7 @@ test spinbox-8.18 {DeleteChars procedure} -setup { winfo reqwidth .e } -cleanup { destroy .e -} -result {42} +} -result 42 test spinbox-9.1 {SpinboxValueChanged procedure} -setup { unset -nocomplain x @@ -2634,7 +2634,7 @@ test spinbox-10.1 {SpinboxSetValue procedure} -constraints fonts -body { set y ab spinbox .e -font {Helvetica -12} -highlightthickness 2 -bd 2 -width 0 pack .e - .e configure -textvariable x + .e configure -textvariable x .e configure -textvariable y update list [.e get] [winfo reqwidth .e] @@ -2643,7 +2643,7 @@ test spinbox-10.1 {SpinboxSetValue procedure} -constraints fonts -body { } -result {ab 35} test spinbox-10.2 {SpinboxSetValue procedure, updating selection} -setup { unset -nocomplain x - spinbox .e -font {Helvetica -12} -highlightthickness 2 -bd 2 + spinbox .e -font {Helvetica -12} -highlightthickness 2 -bd 2 pack .e } -body { .e configure -textvariable x @@ -2656,7 +2656,7 @@ test spinbox-10.2 {SpinboxSetValue procedure, updating selection} -setup { } -returnCodes error -result {selection isn't in widget .e} test spinbox-10.3 {SpinboxSetValue procedure, updating selection} -setup { unset -nocomplain x - spinbox .e -font {Helvetica -12} -highlightthickness 2 -bd 2 + spinbox .e -font {Helvetica -12} -highlightthickness 2 -bd 2 pack .e } -body { .e configure -textvariable x @@ -2669,7 +2669,7 @@ test spinbox-10.3 {SpinboxSetValue procedure, updating selection} -setup { } -result {4 7} test spinbox-10.4 {SpinboxSetValue procedure, updating selection} -setup { unset -nocomplain x - spinbox .e -font {Helvetica -12} -highlightthickness 2 -bd 2 + spinbox .e -font {Helvetica -12} -highlightthickness 2 -bd 2 pack .e } -body { .e configure -textvariable x @@ -2682,7 +2682,7 @@ test spinbox-10.4 {SpinboxSetValue procedure, updating selection} -setup { } -result {4 10} test spinbox-10.5 {SpinboxSetValue procedure, updating display position} -setup { unset -nocomplain x - spinbox .e -highlightthickness 2 -bd 2 + spinbox .e -highlightthickness 2 -bd 2 pack .e } -body { .e configure -width 10 -font {Courier -12} -textvariable x @@ -2694,10 +2694,10 @@ test spinbox-10.5 {SpinboxSetValue procedure, updating display position} -setup .e index @0 } -cleanup { destroy .e -} -result {0} +} -result 0 test spinbox-10.6 {SpinboxSetValue procedure, updating display position} -setup { unset -nocomplain x - spinbox .e -highlightthickness 2 -bd 2 + spinbox .e -highlightthickness 2 -bd 2 pack .e } -body { .e configure -width 10 -font {Courier -12} -textvariable x @@ -2710,10 +2710,10 @@ test spinbox-10.6 {SpinboxSetValue procedure, updating display position} -setup .e index @0 } -cleanup { destroy .e -} -result {10} +} -result 10 test spinbox-10.7 {SpinboxSetValue procedure, updating insertion cursor} -setup { unset -nocomplain x - spinbox .e -highlightthickness 2 -bd 2 + spinbox .e -highlightthickness 2 -bd 2 pack .e update } -body { @@ -2725,10 +2725,10 @@ test spinbox-10.7 {SpinboxSetValue procedure, updating insertion cursor} -setup .e index insert } -cleanup { destroy .e -} -result {3} +} -result 3 test spinbox-10.8 {SpinboxSetValue procedure, updating insertion cursor} -setup { unset -nocomplain x - spinbox .e -highlightthickness 2 -bd 2 + spinbox .e -highlightthickness 2 -bd 2 pack .e } -body { .e configure -width 10 -font {Courier -12} -textvariable x @@ -2739,7 +2739,7 @@ test spinbox-10.8 {SpinboxSetValue procedure, updating insertion cursor} -setup .e index insert } -cleanup { destroy .e -} -result {5} +} -result 5 test spinbox-11.1 {SpinboxEventProc procedure} -setup { spinbox .e -highlightthickness 2 -bd 2 -font {Helvetica -12} @@ -2783,9 +2783,9 @@ test spinbox-13.1 {GetSpinboxIndex procedure} -setup { .e index end } -cleanup { destroy .e -} -result {21} +} -result 21 test spinbox-13.2 {GetSpinboxIndex procedure} -body { - spinbox .e + spinbox .e .e index abogus } -cleanup { destroy .e @@ -2802,7 +2802,7 @@ test spinbox-13.3 {GetSpinboxIndex procedure} -setup { .e index anchor } -cleanup { destroy .e -} -result {1} +} -result 1 test spinbox-13.4 {GetSpinboxIndex procedure} -setup { spinbox .e -font {Courier -12} -width 5 -bd 2 -relief sunken pack .e @@ -2815,7 +2815,7 @@ test spinbox-13.4 {GetSpinboxIndex procedure} -setup { .e index anchor } -cleanup { destroy .e -} -result {4} +} -result 4 test spinbox-13.5 {GetSpinboxIndex procedure} -setup { spinbox .e -font {Courier -12} -width 5 -bd 2 -relief sunken pack .e @@ -2829,7 +2829,7 @@ test spinbox-13.5 {GetSpinboxIndex procedure} -setup { .e index anchor } -cleanup { destroy .e -} -result {15} +} -result 15 test spinbox-13.6 {GetSpinboxIndex procedure} -setup { spinbox .e } -body { @@ -2848,7 +2848,7 @@ test spinbox-13.7 {GetSpinboxIndex procedure} -setup { .e index insert } -cleanup { destroy .e -} -result {2} +} -result 2 test spinbox-13.8 {GetSpinboxIndex procedure} -setup { spinbox .e } -body { @@ -2871,7 +2871,7 @@ test spinbox-13.9 {GetSpinboxIndex procedure} -setup { } -result {1 6} test spinbox-13.10 {GetSpinboxIndex procedure} -constraints x11 -body { -# On unix, when selection is cleared, spinbox widget's internal +# On unix, when selection is cleared, spinbox widget's internal # selection range is reset. # Previous settings: spinbox .e -font {Courier -12} -width 5 -bd 2 -relief sunken @@ -2891,7 +2891,7 @@ test spinbox-13.10 {GetSpinboxIndex procedure} -constraints x11 -body { test spinbox-13.11 {GetSpinboxIndex procedure} -constraints aquaOrWin32 -body { # On mac and pc, when selection is cleared, spinbox widget remembers -# last selected range. When selection ownership is restored to +# last selected range. When selection ownership is restored to # spinbox, the old range will be rehighlighted. # Previous settings: spinbox .e -font {Courier -12} -width 5 -bd 2 -relief sunken @@ -2908,7 +2908,7 @@ test spinbox-13.11 {GetSpinboxIndex procedure} -constraints aquaOrWin32 -body { .e index sel.first } -cleanup { destroy .e -} -result {1} +} -result 1 test spinbox-13.12 {GetSpinboxIndex procedure} -constraints x11 -body { # Previous settings: @@ -2963,7 +2963,7 @@ test spinbox-13.13 {GetSpinboxIndex procedure} -constraints win -body { test spinbox-13.14 {GetSpinboxIndex procedure} -constraints win -body { # On mac and pc, when selection is cleared, spinbox widget remembers -# last selected range. When selection ownership is restored to +# last selected range. When selection ownership is restored to # spinbox, the old range will be rehighlighted. # Previous settings: spinbox .e -font {Courier -12} -width 5 -bd 2 -relief sunken @@ -2976,14 +2976,14 @@ test spinbox-13.14 {GetSpinboxIndex procedure} -constraints win -body { list [.e index sel.first] [.e index sel.last] # Testing: selection clear .e - selection get + selection get } -cleanup { destroy .e } -returnCodes error -match glob -result {*} test spinbox-13.14.1 {GetSpinboxIndex procedure} -constraints win -body { # On mac and pc, when selection is cleared, spinbox widget remembers -# last selected range. When selection ownership is restored to +# last selected range. When selection ownership is restored to # spinbox, the old range will be rehighlighted. # Previous settings: spinbox .e -font {Courier -12} -width 5 -bd 2 -relief sunken @@ -2995,9 +2995,9 @@ test spinbox-13.14.1 {GetSpinboxIndex procedure} -constraints win -body { .e select to 6 list [.e index sel.first] [.e index sel.last] # Testing: - selection clear .e - catch {selection get} - .e index sbogus + selection clear .e + catch {selection get} + .e index sbogus } -cleanup { destroy .e } -returnCodes error -match glob -result {*} @@ -3012,7 +3012,7 @@ test spinbox-13.15 {GetSpinboxIndex procedure} -body { test spinbox-13.16 {GetSpinboxIndex procedure} -constraints fonts -body { spinbox .e -width 5 -relief sunken -highlightthickness 2 -bd 2 \ - -font {Courier -12} + -font {Courier -12} pack .e .e insert 0 012345678901234567890 .e xview 4 @@ -3020,10 +3020,10 @@ test spinbox-13.16 {GetSpinboxIndex procedure} -constraints fonts -body { .e index @4 } -cleanup { destroy .e -} -result {4} +} -result 4 test spinbox-13.17 {GetSpinboxIndex procedure} -constraints fonts -body { spinbox .e -width 5 -relief sunken -highlightthickness 2 -bd 2 \ - -font {Courier -12} + -font {Courier -12} pack .e .e insert 0 012345678901234567890 .e xview 4 @@ -3031,10 +3031,10 @@ test spinbox-13.17 {GetSpinboxIndex procedure} -constraints fonts -body { .e index @11 } -cleanup { destroy .e -} -result {4} +} -result 4 test spinbox-13.18 {GetSpinboxIndex procedure} -constraints fonts -body { spinbox .e -width 5 -relief sunken -highlightthickness 2 -bd 2 \ - -font {Courier -12} + -font {Courier -12} pack .e .e insert 0 012345678901234567890 .e xview 4 @@ -3042,10 +3042,10 @@ test spinbox-13.18 {GetSpinboxIndex procedure} -constraints fonts -body { .e index @12 } -cleanup { destroy .e -} -result {5} +} -result 5 test spinbox-13.19 {GetSpinboxIndex procedure} -constraints fonts -body { spinbox .e -width 5 -relief sunken -highlightthickness 2 -bd 2 \ - -font {Courier -12} + -font {Courier -12} pack .e .e insert 0 012345678901234567890 .e xview 4 @@ -3053,10 +3053,10 @@ test spinbox-13.19 {GetSpinboxIndex procedure} -constraints fonts -body { .e index @[expr {[winfo width .e] - 6-11}] } -cleanup { destroy .e -} -result {8} +} -result 8 test spinbox-13.20 {GetSpinboxIndex procedure} -constraints fonts -body { spinbox .e -width 5 -relief sunken -highlightthickness 2 -bd 2 \ - -font {Courier -12} + -font {Courier -12} pack .e .e insert 0 012345678901234567890 .e xview 4 @@ -3064,10 +3064,10 @@ test spinbox-13.20 {GetSpinboxIndex procedure} -constraints fonts -body { .e index @[expr {[winfo width .e] - 5}] } -cleanup { destroy .e -} -result {9} +} -result 9 test spinbox-13.21 {GetSpinboxIndex procedure} -body { spinbox .e -width 5 -relief sunken -highlightthickness 2 -bd 2 \ - -font {Courier -12} + -font {Courier -12} pack .e .e insert 0 012345678901234567890 .e xview 4 @@ -3075,9 +3075,9 @@ test spinbox-13.21 {GetSpinboxIndex procedure} -body { .e index @1000 } -cleanup { destroy .e -} -result {9} +} -result 9 test spinbox-13.22 {GetSpinboxIndex procedure} -setup { - spinbox .e + spinbox .e pack .e update } -body { @@ -3087,18 +3087,18 @@ test spinbox-13.22 {GetSpinboxIndex procedure} -setup { } -returnCodes error -result {bad spinbox index "1xyz"} test spinbox-13.23 {GetSpinboxIndex procedure} -body { spinbox .e -width 5 -relief sunken -highlightthickness 2 -bd 2 \ - -font {Courier -12} + -font {Courier -12} pack .e .e insert 0 012345678901234567890 .e xview 4 update - .e index -10 + .e index -1 } -cleanup { destroy .e -} -result {0} +} -result 0 test spinbox-13.24 {GetSpinboxIndex procedure} -body { spinbox .e -width 5 -relief sunken -highlightthickness 2 -bd 2 \ - -font {Courier -12} + -font {Courier -12} pack .e .e insert 0 012345678901234567890 .e xview 4 @@ -3106,10 +3106,10 @@ test spinbox-13.24 {GetSpinboxIndex procedure} -body { .e index 12 } -cleanup { destroy .e -} -result {12} +} -result 12 test spinbox-13.25 {GetSpinboxIndex procedure} -body { spinbox .e -width 5 -relief sunken -highlightthickness 2 -bd 2 \ - -font {Courier -12} + -font {Courier -12} pack .e .e insert 0 012345678901234567890 .e xview 4 @@ -3117,7 +3117,7 @@ test spinbox-13.25 {GetSpinboxIndex procedure} -body { .e index 49 } -cleanup { destroy .e -} -result {21} +} -result 21 # XXX Still need to write tests for SpinboxScanTo and SpinboxSelectTo. @@ -3137,13 +3137,13 @@ test spinbox-14.3 {SpinboxFetchSelection procedure} -setup { } } -body { spinbox .e - .e insert end $x + .e insert end $x .e select from 0 .e select to end string compare [selection get] $x } -cleanup { destroy .e -} -result {0} +} -result 0 test spinbox-15.1 {SpinboxLostSelection} -body { spinbox .e @@ -3164,7 +3164,7 @@ test spinbox-16.1 {SpinboxVisibleRange procedure} -constraints fonts -body { spinbox .e -width 10 -font {Helvetica -12} pack .e update - .e insert 0 "............................." + .e insert 0 "............................." format {%.6f %.6f} {*}[.e xview] } -cleanup { destroy .e @@ -3209,7 +3209,7 @@ test spinbox-17.3 {SpinboxUpdateScrollbar procedure} -body { update idletasks set timeout [after 500 {set scrollInfo {-1000000 -1000000}}] .e insert 0 abcdefghijklmnopqrs - .e xview + .e xview vwait scrollInfo format {%.6f %.6f} {*}$scrollInfo } -cleanup { @@ -3246,7 +3246,7 @@ test spinbox-18.1 {Spinbox widget vs hiding} -setup { set res1 [list [winfo children .] [interp hidden]] set res2 [list {} $l] expr {$res1 == $res2} -} -result {1} +} -result 1 ## ## Spinbox widget VALIDATION tests @@ -3600,7 +3600,7 @@ test spinbox-19.19 {spinbox widget validation} -setup { -background red -foreground white pack .e set ::e nextdata ;# previous settings - + .e configure -validatecommand [list doval2 %W %d %i %P %s %S %v %V] .e validate list [.e cget -validate] [.e get] $::vVals @@ -3625,7 +3625,7 @@ test spinbox-19.20 {spinbox widget validation} -setup { set ::e nextdata ;# previous settings .e configure -validatecommand [list doval2 %W %d %i %P %s %S %v %V] ;# prev .e validate ;# previous settings - + .e configure -validate all set ::e testdata list [.e cget -validate] [.e get] $::e $::vVals @@ -3807,7 +3807,7 @@ test spinbox-22.1 {spinbox config, -from changes SF bug 559078} -body { set val } -cleanup { destroy .e -} -result {5} +} -result 5 test spinbox-22.2 {spinbox config, -from changes SF bug 559078} -body { set val 5 spinbox .e -from 1 -to 10 -textvariable val @@ -3815,7 +3815,7 @@ test spinbox-22.2 {spinbox config, -from changes SF bug 559078} -body { set val } -cleanup { destroy .e -} -result {5} +} -result 5 test spinbox-22.3 {spinbox config, -from changes SF bug 559078} -body { set val 5 spinbox .e -from 3 -to 10 -textvariable val @@ -3823,7 +3823,7 @@ test spinbox-22.3 {spinbox config, -from changes SF bug 559078} -body { set val } -cleanup { destroy .e -} -result {6} +} -result 6 test spinbox-23.1 {selection present while disabled, bug 637828} -body { spinbox .e diff --git a/tests/ttk/entry.test b/tests/ttk/entry.test index 2e5f43c..d5bcf45 100644 --- a/tests/ttk/entry.test +++ b/tests/ttk/entry.test @@ -84,7 +84,7 @@ test entry-2.1.1 "Create entry before scrollbar - scrollbar catches up" -body { -expand false -fill x update ; # no error lappend res [expr [lindex [.tsb get] 1] < 1] ; # scrollbar did update -} -result {1} -cleanup {destroy .te .tsb} +} -result 1 -cleanup {destroy .te .tsb} test entry-2.2 "Initial scroll position" -body { ttk::entry .e -font fixed -width 5 -xscrollcommand scroll @@ -128,28 +128,28 @@ test entry-3.3 "xview" -body { .e insert end abcdefghijklmnopqrstuvwxyz .e xview end set result [.e index @0] -} -result {7} +} -result 7 test entry-3.4 "xview" -body { .e delete 0 end; .e insert end abcdefghijklmnopqrstuvwxyz .e xview moveto 1.0 set result [.e index @0] -} -result {7} +} -result 7 test entry-3.5 "xview" -body { .e delete 0 end; .e insert end abcdefghijklmnopqrstuvwxyz .e xview scroll 5 units set result [.e index @0] -} -result {5} +} -result 5 test entry-3.6 "xview" -body { .e delete 0 end; .e insert end [string repeat abcdefghijklmnopqrstuvwxyz 5] .e xview scroll 2 pages set result [.e index @0] -} -result {40} +} -result 40 test entry-3.last "Series 3 cleanup" -body { destroy .e diff --git a/tests/ttk/spinbox.test b/tests/ttk/spinbox.test index b86f053..4bdabee 100644 --- a/tests/ttk/spinbox.test +++ b/tests/ttk/spinbox.test @@ -148,7 +148,7 @@ test spinbox-1.8.4 "-validate option: " -setup { set ::spinbox_test } -cleanup { destroy .sb -} -result {50} +} -result 50 test spinbox-2.0 "current command -- unset should be 0" -constraints nyi -setup { @@ -316,7 +316,7 @@ test spinbox-nostomp-3 "don't stomp on -variable (configure; -from/to)" -body { test spinbox-nostomp-4 "don't stomp on -variable (configure; -values)" -body { set SBV Apr - ttk::spinbox .sb + ttk::spinbox .sb .sb configure -textvariable SBV -values {Jan Feb Mar Apr May Jun Jul Aug} list $SBV [.sb get] } -cleanup { @@ -341,7 +341,7 @@ test spinbox-dieoctaldie-1 "Cope with leading zeros" -body { event generate .sb <>; lappend result $secs set result -} -result [list 07 08 09 10 11 10 09 08 07] -cleanup { +} -result [list 07 08 09 10 11 10 09 08 07] -cleanup { destroy .sb unset secs } -- cgit v0.12