diff options
-rw-r--r-- | generic/tkTest.c | 64 | ||||
-rw-r--r-- | library/demos/fontchoose.tcl | 6 | ||||
-rw-r--r-- | macosx/tkMacOSXColor.c | 21 | ||||
-rw-r--r-- | macosx/tkMacOSXDraw.c | 5 | ||||
-rw-r--r-- | macosx/tkMacOSXInit.c | 1 | ||||
-rw-r--r-- | macosx/tkMacOSXKeyEvent.c | 2 | ||||
-rw-r--r-- | macosx/tkMacOSXNotify.c | 2 | ||||
-rw-r--r-- | macosx/tkMacOSXSubwindows.c | 20 | ||||
-rw-r--r-- | macosx/tkMacOSXTest.c | 30 | ||||
-rw-r--r-- | macosx/tkMacOSXWm.c | 23 | ||||
-rw-r--r-- | tests/canvImg.test | 23 | ||||
-rw-r--r-- | tests/entry.test | 27 | ||||
-rw-r--r-- | tests/listbox.test | 28 | ||||
-rw-r--r-- | tests/pack.test | 24 | ||||
-rw-r--r-- | tests/place.test | 23 | ||||
-rw-r--r-- | tests/spinbox.test | 38 | ||||
-rw-r--r-- | tests/textDisp.test | 30 | ||||
-rw-r--r-- | tests/ttk/spinbox.test | 9 | ||||
-rw-r--r-- | tests/unixWm.test | 56 | ||||
-rw-r--r-- | tests/wm.test | 20 |
20 files changed, 253 insertions, 199 deletions
diff --git a/generic/tkTest.c b/generic/tkTest.c index 978d1c1..b104f13 100644 --- a/generic/tkTest.c +++ b/generic/tkTest.c @@ -78,6 +78,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; /* @@ -1526,6 +1528,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; } @@ -1560,41 +1563,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/library/demos/fontchoose.tcl b/library/demos/fontchoose.tcl index 8b34377..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 <Visibility> { - bind %W <Visibility> {} - grid propagate %W.f 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 diff --git a/macosx/tkMacOSXColor.c b/macosx/tkMacOSXColor.c index 0931d7d..af708b1 100644 --- a/macosx/tkMacOSXColor.c +++ b/macosx/tkMacOSXColor.c @@ -267,6 +267,22 @@ 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) +#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}; @@ -336,6 +352,7 @@ SetCGColorComponents( break; case 2: if ([NSApp macOSVersion] > 100900) { + #if MAC_OS_X_VERSION_MAX_ALLOWED > 1090 color = [[NSColor labelColor] colorUsingColorSpace:sRGB]; #endif @@ -378,8 +395,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/macosx/tkMacOSXDraw.c b/macosx/tkMacOSXDraw.c index 6c72e0a..b6a834f 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] @@ -1652,8 +1652,7 @@ TkMacOSXSetupDrawingContext( * cycle. */ - CGRect currentClip = CGContextGetClipBoundingBox( - [NSGraphicsContext currentContext].CGContext); + CGRect currentClip = CGContextGetClipBoundingBox(GET_CGCONTEXT); if (!NSContainsRect(currentClip, clipBounds)) { [view addTkDirtyRect:clipBounds]; } diff --git a/macosx/tkMacOSXInit.c b/macosx/tkMacOSXInit.c index 61a2980..74c17a7 100644 --- a/macosx/tkMacOSXInit.c +++ b/macosx/tkMacOSXInit.c @@ -41,6 +41,7 @@ static int TkMacOSXGetAppPathCmd(ClientData cd, Tcl_Interp *ip, @synthesize poolLock = _poolLock; @synthesize macOSVersion = _macOSVersion; @synthesize isDrawing = _isDrawing; +@synthesize needsToDraw = _needsToDraw; @end /* diff --git a/macosx/tkMacOSXKeyEvent.c b/macosx/tkMacOSXKeyEvent.c index 3ddc779..69bc40f 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. diff --git a/macosx/tkMacOSXNotify.c b/macosx/tkMacOSXNotify.c index 3cc1724..848f7a3 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]; diff --git a/macosx/tkMacOSXSubwindows.c b/macosx/tkMacOSXSubwindows.c index c631486..51eba68 100644 --- a/macosx/tkMacOSXSubwindows.c +++ b/macosx/tkMacOSXSubwindows.c @@ -206,7 +206,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 { /* @@ -316,7 +324,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/macosx/tkMacOSXTest.c b/macosx/tkMacOSXTest.c index 33055ee..5bbcde0 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; } } diff --git a/macosx/tkMacOSXWm.c b/macosx/tkMacOSXWm.c index 4651c2d..725342e 100644 --- a/macosx/tkMacOSXWm.c +++ b/macosx/tkMacOSXWm.c @@ -1806,7 +1806,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", @@ -6421,17 +6420,15 @@ 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); } + /* + * Make sure windows are updated after the state change. + */ + + while (Tcl_DoOneEvent(TCL_IDLE_EVENTS)){} } /* @@ -6877,7 +6874,6 @@ ApplyWindowAttributeFlagChanges( b |= (NSWindowCollectionBehaviorCanJoinAllSpaces | NSWindowCollectionBehaviorFullScreenAuxiliary); } else { - NSSize screenSize = [[macWindow screen] frame].size; b |= NSWindowCollectionBehaviorFullScreenPrimary; /* @@ -6888,7 +6884,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/canvImg.test b/tests/canvImg.test index 0e0b47a..a6e9517 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,12 @@ 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. - 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 { .c delete all - update + update idletasks } -body { image create test foo -variable x image create test foo2 -variable z @@ -797,17 +791,16 @@ 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 -} -result $result_11_3 + image delete foo2 +} -result {{foo2 display 0 0 80 60}} # cleanup imageFinish diff --git a/tests/entry.test b/tests/entry.test index 8a4a457..9045822 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 @@ -1688,9 +1689,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 @@ -1933,9 +1935,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 { @@ -1950,9 +1952,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 { @@ -2084,9 +2086,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 { @@ -2100,9 +2102,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 { @@ -2116,9 +2118,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 { @@ -2964,9 +2966,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 { @@ -2976,9 +2979,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 { @@ -2988,9 +2991,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 { @@ -3003,8 +3006,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/listbox.test b/tests/listbox.test index bf592b1..0107326 100644 --- a/tests/listbox.test +++ b/tests/listbox.test @@ -2662,41 +2662,37 @@ 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 x {} listbox .l -font $fixed -width 10 -xscrollcommand "record x" -listvar x - set log {} pack .l - set timeout [after 500 {lappend log timeout1}] - vwait log + update idletasks + set log {} 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}] +} -result [list {x 0 1} {x 0 0.5}] test listbox-21.10 {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 {} 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 { diff --git a/tests/pack.test b/tests/pack.test index c65727e..3ca2253 100644 --- a/tests/pack.test +++ b/tests/pack.test @@ -1532,6 +1532,15 @@ 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 { @@ -1550,19 +1559,19 @@ test pack-18.1 {unmap slaves when master unmapped} -constraints { eval destroy [winfo child .pack] 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 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 + 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 { @@ -1575,17 +1584,16 @@ 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 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 + 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 975732a..041daa6 100644 --- a/tests/place.test +++ b/tests/place.test @@ -258,40 +258,47 @@ 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 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 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 + placeUpdate 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 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 + placeUpdate lappend result [winfo ismapped .t.f2] } -result {1 0 42 32 0 1} destroy .t diff --git a/tests/spinbox.test b/tests/spinbox.test index 7a00627..a9649a3 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 @@ -2219,8 +2221,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 { @@ -2236,8 +2239,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 { @@ -2370,8 +2374,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 { @@ -2386,8 +2391,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 { @@ -2402,8 +2408,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 { @@ -3203,9 +3210,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 { @@ -3216,8 +3224,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 { @@ -3227,23 +3236,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/textDisp.test b/tests/textDisp.test index 7e02838..d1b13ee 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; @@ -3969,12 +3979,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 + 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 ; after 1000 ; update + 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}]] @@ -4022,12 +4032,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 + 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 ; after 1000 ; update + 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}]] @@ -4044,11 +4054,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 + delay 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 + 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}]] @@ -4183,6 +4193,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 @@ -4191,6 +4202,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" @@ -4204,12 +4216,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} { diff --git a/tests/ttk/spinbox.test b/tests/ttk/spinbox.test index 2573e57..4bdabee 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 . <Map> { 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 . <Map> {} } - after 500 {set ::spinbox_wait 1} ; vwait ::spinbox_wait + grid .sb -sticky ew + vwait ::spinbox_test set ::spinbox_test } -cleanup { destroy .sb diff --git a/tests/unixWm.test b/tests/unixWm.test index b6efb42..39a68ae 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 @@ -302,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 @@ -311,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 { @@ -349,7 +340,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 +411,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 @@ -867,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 @@ -878,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 @@ -1385,12 +1373,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 +1443,11 @@ test unixWm-42.1 {WrapperEventProc procedure, map and unmap events} unix { bind .t <Unmap> {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 +1960,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 +1968,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 { @@ -1990,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 @@ -2022,7 +2011,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 +2021,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 +2035,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 +2057,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 { diff --git a/tests/wm.test b/tests/wm.test index 310e2db..99ba84a 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 |