From 75a78d19b6bc075bdad415daaba87bc6f6a27ecf Mon Sep 17 00:00:00 2001 From: fvogel Date: Sun, 14 Apr 2019 19:49:22 +0000 Subject: Ticket [c8ccd1899c]. Make the guard code in proc ::tk::TextUpDownLine work as intended when moving the cursor downwards. Also, fix the bug in the index returned by the displayline modifier: the first displayed index shall be returned when the index calculated by the displayline modifier would be before the start of the displayed text. --- generic/tkTextIndex.c | 13 ++++++++++--- library/text.tcl | 2 +- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/generic/tkTextIndex.c b/generic/tkTextIndex.c index 582e1a8..4991801 100644 --- a/generic/tkTextIndex.c +++ b/generic/tkTextIndex.c @@ -1298,7 +1298,8 @@ ForwBack( if (forward) { TkTextFindDisplayLineEnd(textPtr, indexPtr, 1, &xOffset); while (count-- > 0) { - /* + + /* * Go to the end of the line, then forward one char/byte * to get to the beginning of the next line. */ @@ -1310,17 +1311,23 @@ ForwBack( } else { TkTextFindDisplayLineEnd(textPtr, indexPtr, 0, &xOffset); while (count-- > 0) { + TkTextIndex indexPtr2; + /* * Go to the beginning of the line, then backward one * char/byte to get to the end of the previous line. */ TkTextFindDisplayLineEnd(textPtr, indexPtr, 0, NULL); - TkTextIndexBackChars(textPtr, indexPtr, 1, indexPtr, + TkTextIndexBackChars(textPtr, indexPtr, 1, &indexPtr2, COUNT_DISPLAY_INDICES); + if (!TkTextIndexCmp(indexPtr, &indexPtr2)) { + xOffset = 0; + } + *indexPtr = indexPtr2; } - TkTextFindDisplayLineEnd(textPtr, indexPtr, 0, NULL); } + TkTextFindDisplayLineEnd(textPtr, indexPtr, 0, NULL); /* * This call assumes indexPtr is the beginning of a display line diff --git a/library/text.tcl b/library/text.tcl index 468696b..822f8e6 100644 --- a/library/text.tcl +++ b/library/text.tcl @@ -912,7 +912,7 @@ proc ::tk::TextUpDownLine {w n} { set lines [$w count -displaylines $Priv(textPosOrig) $i] set new [$w index \ "$Priv(textPosOrig) + [expr {$lines + $n}] displaylines"] - if {[$w compare $new == end] \ + if {[$w compare $new == "end - 1 display char"] \ || [$w compare $new == "insert display linestart"]} { set new $i } -- cgit v0.12 From 8550afdcfc409d1fa37e7d64832bceca4be6a9b0 Mon Sep 17 00:00:00 2001 From: fvogel Date: Sun, 14 Apr 2019 19:55:33 +0000 Subject: Remove the guard code in proc ::tk::TextUpDownLine in order to get the behavior requested in [c8ccd1899c] --- library/text.tcl | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/library/text.tcl b/library/text.tcl index 822f8e6..e07bb62 100644 --- a/library/text.tcl +++ b/library/text.tcl @@ -891,11 +891,10 @@ proc ::tk::TextInsert {w s} { # ::tk::TextUpDownLine -- # Returns the index of the character one display line above or below the -# insertion cursor. There are two tricky things here. First, we want to -# maintain the original x position across repeated operations, even though -# some lines that will get passed through don't have enough characters to -# cover the original column. Second, don't try to scroll past the -# beginning or end of the text. +# insertion cursor. There is a tricky thing here: we want to maintain the +# original x position across repeated operations, even though some lines +# that will get passed through don't have enough characters to cover the +# original column. # # Arguments: # w - The text window in which the cursor is to move. @@ -912,10 +911,6 @@ proc ::tk::TextUpDownLine {w n} { set lines [$w count -displaylines $Priv(textPosOrig) $i] set new [$w index \ "$Priv(textPosOrig) + [expr {$lines + $n}] displaylines"] - if {[$w compare $new == "end - 1 display char"] \ - || [$w compare $new == "insert display linestart"]} { - set new $i - } set Priv(prevPos) $new return $new } -- cgit v0.12 From 147e6b910599a2694c45a672ca9a06e8864f78ad Mon Sep 17 00:00:00 2001 From: fvogel Date: Sun, 14 Apr 2019 20:14:41 +0000 Subject: Add test textIndex-19.12.1 checking for regressions regarding the '1.5 - n displaylines' fix [4384effe] --- tests/textIndex.test | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tests/textIndex.test b/tests/textIndex.test index 7d44516..b2ab842 100644 --- a/tests/textIndex.test +++ b/tests/textIndex.test @@ -803,6 +803,10 @@ test textIndex-19.12 {Display lines} { .t index "2.40 -1displaylines" } {2.20} +test textIndex-19.12.1 {Display lines} { + .t index "2.50 - 100 displaylines" +} {1.0} + test textIndex-19.13 {Display lines} { destroy {*}[pack slaves .] text .txt -height 1 -wrap word -yscroll ".sbar set" -width 400 -- cgit v0.12 From 73929d05526216cfc46aa8ac2e9c3d679b811070 Mon Sep 17 00:00:00 2001 From: fvogel Date: Sun, 14 Apr 2019 20:23:22 +0000 Subject: Since we are here, also add test textIndex-19.12.2 checking for past end of text results in '+ n displaylines' calculations. This one does does not fail in core-8-6-branch (contrary to textIndex-19.12.1). Note to self: in revised_text the test should check 'end' instead of 'end - 1 c'. --- tests/textIndex.test | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tests/textIndex.test b/tests/textIndex.test index b2ab842..612ade1 100644 --- a/tests/textIndex.test +++ b/tests/textIndex.test @@ -807,6 +807,10 @@ test textIndex-19.12.1 {Display lines} { .t index "2.50 - 100 displaylines" } {1.0} +test textIndex-19.12.2 {Display lines} { + .t compare [.t index "2.50 + 100 displaylines"] == "end - 1 c" +} {1} + test textIndex-19.13 {Display lines} { destroy {*}[pack slaves .] text .txt -height 1 -wrap word -yscroll ".sbar set" -width 400 -- cgit v0.12 From d1f06f650ffed3d63ed1c6951d8ebefbbd221e89 Mon Sep 17 00:00:00 2001 From: fvogel Date: Fri, 19 Apr 2019 14:07:19 +0000 Subject: Document what's happening with this bugfix and optimize (exit the while loop early). --- generic/tkTextIndex.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/generic/tkTextIndex.c b/generic/tkTextIndex.c index 4991801..41573ad 100644 --- a/generic/tkTextIndex.c +++ b/generic/tkTextIndex.c @@ -1321,8 +1321,16 @@ ForwBack( TkTextFindDisplayLineEnd(textPtr, indexPtr, 0, NULL); TkTextIndexBackChars(textPtr, indexPtr, 1, &indexPtr2, COUNT_DISPLAY_INDICES); + + /* + * If we couldn't go to the previous line, then we wanted + to go before the start of the text: arrange for returning + the first index of the first display line. + */ + if (!TkTextIndexCmp(indexPtr, &indexPtr2)) { xOffset = 0; + break; } *indexPtr = indexPtr2; } -- cgit v0.12 From b3ef648e509b5a9efb6924efcdefa797cdf01a4c Mon Sep 17 00:00:00 2001 From: fvogel Date: Sat, 11 May 2019 10:59:54 +0000 Subject: Reset ::tk::Priv(textPosOrig) when hitting the start or end of displayed text, so that when moving back the cursor does not jump in the middle of the line. --- library/text.tcl | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/library/text.tcl b/library/text.tcl index e07bb62..d3b49d8 100644 --- a/library/text.tcl +++ b/library/text.tcl @@ -912,6 +912,10 @@ proc ::tk::TextUpDownLine {w n} { set new [$w index \ "$Priv(textPosOrig) + [expr {$lines + $n}] displaylines"] set Priv(prevPos) $new + if {[$w compare $new == "end display lineend"] \ + || [$w compare $new == "insert display linestart"]} { + set Priv(textPosOrig) $new + } return $new } -- cgit v0.12 From 34f90a3dbaa4f1e3331554f7e2c59742b720079b Mon Sep 17 00:00:00 2001 From: fvogel Date: Sat, 11 May 2019 15:34:41 +0000 Subject: Revert irrelevant blank changes --- generic/tkTextIndex.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/generic/tkTextIndex.c b/generic/tkTextIndex.c index 41573ad..848996e 100644 --- a/generic/tkTextIndex.c +++ b/generic/tkTextIndex.c @@ -1299,7 +1299,7 @@ ForwBack( TkTextFindDisplayLineEnd(textPtr, indexPtr, 1, &xOffset); while (count-- > 0) { - /* + /* * Go to the end of the line, then forward one char/byte * to get to the beginning of the next line. */ -- cgit v0.12 From 9eaf1ac422fac0fe4410f3f5576e76c353e7bd41 Mon Sep 17 00:00:00 2001 From: oehhar Date: Wed, 22 May 2019 20:19:56 +0000 Subject: TIP545: remove image photo svg option "-unit" --- generic/tkImgSVGnano.c | 20 ++++---------------- tests/imgSVGnano.test | 7 +------ 2 files changed, 5 insertions(+), 22 deletions(-) diff --git a/generic/tkImgSVGnano.c b/generic/tkImgSVGnano.c index f86c45e..da28d9b 100644 --- a/generic/tkImgSVGnano.c +++ b/generic/tkImgSVGnano.c @@ -30,8 +30,6 @@ /* Additional parameters to nsvgRasterize() */ typedef struct { - double x; - double y; double scale; } RastOpts; @@ -324,14 +322,13 @@ ParseSVGWithOptions( Tcl_Obj **objv = NULL; int objc = 0; double dpi = 96.0; - char unit[3], *p; char *inputCopy = NULL; NSVGimage *nsvgImage; static const char *const fmtOptions[] = { - "-dpi", "-scale", "-unit", NULL + "-dpi", "-scale", NULL }; enum fmtOptions { - OPT_DPI, OPT_SCALE, OPT_UNIT + OPT_DPI, OPT_SCALE }; /* @@ -352,8 +349,6 @@ ParseSVGWithOptions( * Process elements of format specification as a list. */ - strcpy(unit, "px"); - ropts->x = ropts->y = 0.0; ropts->scale = 1.0; if ((formatObj != NULL) && Tcl_ListObjGetElements(interp, formatObj, &objc, &objv) != TCL_OK) { @@ -411,17 +406,10 @@ ParseSVGWithOptions( goto error; } break; - case OPT_UNIT: - p = Tcl_GetString(objv[0]); - if ((p != NULL) && (p[0])) { - strncpy(unit, p, 3); - unit[2] = '\0'; - } - break; } } - nsvgImage = nsvgParse(inputCopy, unit, (float) dpi); + nsvgImage = nsvgParse(inputCopy, "px", (float) dpi); if (nsvgImage == NULL) { Tcl_SetObjResult(interp, Tcl_NewStringObj("cannot parse SVG image", -1)); Tcl_SetErrorCode(interp, "TK", "IMAGE", "SVG", "PARSE_ERROR", NULL); @@ -486,7 +474,7 @@ RasterizeSVG( Tcl_SetErrorCode(interp, "TK", "IMAGE", "SVG", "OUT_OF_MEMORY", NULL); goto cleanRAST; } - nsvgRasterize(rast, nsvgImage, (float) ropts->x, (float) ropts->y, + nsvgRasterize(rast, nsvgImage, 0, 0, (float) ropts->scale, imgData, w, h, w * 4); /* transfer the data to a photo block */ svgblock.pixelPtr = imgData; diff --git a/tests/imgSVGnano.test b/tests/imgSVGnano.test index a7470df..7ac9066 100644 --- a/tests/imgSVGnano.test +++ b/tests/imgSVGnano.test @@ -61,11 +61,6 @@ test imgSVGnano-1.4 {image options} -setup { } -body { image create photo foo -data $data(plus) foo configure -format {svg -scale 2} - foo configure -format {svg -unit pt} - foo configure -format {svg -unit mm} - foo configure -format {svg -unit cm} - foo configure -format {svg -unit in} - foo configure -format {svg -unit px} foo configure -format {svg -dpi 600} list [image width foo] [image height foo] } -cleanup { @@ -84,7 +79,7 @@ test imgSVGnano-2.3 {using bad option} -body { foo configure -format {svg 1.0} } -cleanup { rename foo "" -} -returnCodes error -result {bad option "1.0": must be -dpi, -scale, or -unit} +} -returnCodes error -result {bad option "1.0": must be -dpi or -scale} };# end of namespace svgnano -- cgit v0.12 From 8f9a049f972693966361e82b11cb4a85b9d52c56 Mon Sep 17 00:00:00 2001 From: oehhar Date: Fri, 7 Jun 2019 18:26:29 +0000 Subject: Implement -scaletowidth/height, output very small scale images as 1x1 images. --- generic/tkImgSVGnano.c | 178 ++++++++++++++++++++++++++++++++++++++++++++----- tests/imgSVGnano.test | 57 +++++++++++++++- 2 files changed, 217 insertions(+), 18 deletions(-) diff --git a/generic/tkImgSVGnano.c b/generic/tkImgSVGnano.c index da28d9b..3f1f7e4 100644 --- a/generic/tkImgSVGnano.c +++ b/generic/tkImgSVGnano.c @@ -31,6 +31,8 @@ typedef struct { double scale; + int scaleToHeight; + int scaleToWidth; } RastOpts; /* @@ -40,6 +42,10 @@ typedef struct { */ typedef struct { + /* A poiner to remember if it is the same svn image (data) + * It is a Tcl_Channel if image created by -file option + * or a Tcl_Obj, if image is created with the -data option + */ ClientData dataOrChan; Tcl_DString formatString; NSVGimage *nsvgImage; @@ -66,6 +72,8 @@ static int RasterizeSVG(Tcl_Interp *interp, Tk_PhotoHandle imageHandle, NSVGimage *nsvgImage, int destX, int destY, int width, int height, int srcX, int srcY, RastOpts *ropts); +static double GetScaleFromParameters(NSVGimage *nsvgImage, + RastOpts *ropts, int *widthPtr, int *heightPtr); static NSVGcache * GetCachePtr(Tcl_Interp *interp); static int CacheSVG(Tcl_Interp *interp, ClientData dataOrChan, Tcl_Obj *formatObj, NSVGimage *nsvgImage, @@ -132,12 +140,11 @@ FileMatchSVG( nsvgImage = ParseSVGWithOptions(interp, data, length, formatObj, &ropts); Tcl_DecrRefCount(dataObj); if (nsvgImage != NULL) { - *widthPtr = (int) ceil(nsvgImage->width * ropts.scale); - *heightPtr = (int) ceil(nsvgImage->height * ropts.scale); - if ((*widthPtr <= 0) || (*heightPtr <= 0)) { - nsvgDelete(nsvgImage); - return 0; - } + GetScaleFromParameters( + nsvgImage, + &ropts, + widthPtr, + heightPtr); if (!CacheSVG(interp, chan, formatObj, nsvgImage, &ropts)) { nsvgDelete(nsvgImage); } @@ -237,12 +244,11 @@ StringMatchSVG( data = Tcl_GetStringFromObj(dataObj, &length); nsvgImage = ParseSVGWithOptions(interp, data, length, formatObj, &ropts); if (nsvgImage != NULL) { - *widthPtr = (int) ceil(nsvgImage->width * ropts.scale); - *heightPtr = (int) ceil(nsvgImage->height * ropts.scale); - if ((*widthPtr <= 0) || (*heightPtr <= 0)) { - nsvgDelete(nsvgImage); - return 0; - } + GetScaleFromParameters( + nsvgImage, + &ropts, + widthPtr, + heightPtr); if (!CacheSVG(interp, dataObj, formatObj, nsvgImage, &ropts)) { nsvgDelete(nsvgImage); } @@ -324,11 +330,12 @@ ParseSVGWithOptions( double dpi = 96.0; char *inputCopy = NULL; NSVGimage *nsvgImage; + int parameterScaleSeen = 0; static const char *const fmtOptions[] = { - "-dpi", "-scale", NULL + "-dpi", "-scale", "-scaletoheight", "-scaletowidth", NULL }; enum fmtOptions { - OPT_DPI, OPT_SCALE + OPT_DPI, OPT_SCALE, OPT_SCALE_TO_HEIGHT, OPT_SCALE_TO_WIDTH }; /* @@ -350,6 +357,8 @@ ParseSVGWithOptions( */ ropts->scale = 1.0; + ropts->scaleToHeight = 0; + ropts->scaleToWidth = 0; if ((formatObj != NULL) && Tcl_ListObjGetElements(interp, formatObj, &objc, &objv) != TCL_OK) { goto error; @@ -380,6 +389,26 @@ ParseSVGWithOptions( objc--; objv++; + /* + * check that only one scale option is given + */ + switch ((enum fmtOptions) optIndex) { + case OPT_SCALE: + case OPT_SCALE_TO_HEIGHT: + case OPT_SCALE_TO_WIDTH: + if ( parameterScaleSeen ) { + Tcl_SetObjResult(interp, Tcl_NewStringObj( + "only one of -scale, -scaletoheight, -scaletowidth may be given", -1)); + Tcl_SetErrorCode(interp, "TK", "IMAGE", "SVG", "BAD_SCALE", + NULL); + goto error; + } + parameterScaleSeen = 1; + } + + /* + * Decode parameters + */ switch ((enum fmtOptions) optIndex) { case OPT_DPI: if (Tcl_GetDoubleFromObj(interp, objv[0], &dpi) == TCL_ERROR) { @@ -406,6 +435,32 @@ ParseSVGWithOptions( goto error; } break; + case OPT_SCALE_TO_HEIGHT: + if (Tcl_GetIntFromObj(interp, objv[0], &ropts->scaleToHeight) == + TCL_ERROR) { + goto error; + } + if (ropts->scaleToHeight <= 0) { + Tcl_SetObjResult(interp, Tcl_NewStringObj( + "-scaletoheight value must be positive", -1)); + Tcl_SetErrorCode(interp, "TK", "IMAGE", "SVG", "BAD_SCALE", + NULL); + goto error; + } + break; + case OPT_SCALE_TO_WIDTH: + if (Tcl_GetIntFromObj(interp, objv[0], &ropts->scaleToWidth) == + TCL_ERROR) { + goto error; + } + if (ropts->scaleToWidth <= 0) { + Tcl_SetObjResult(interp, Tcl_NewStringObj( + "-scaletowidth value must be positive", -1)); + Tcl_SetErrorCode(interp, "TK", "IMAGE", "SVG", "BAD_SCALE", + NULL); + goto error; + } + break; } } @@ -458,9 +513,14 @@ RasterizeSVG( NSVGrasterizer *rast; unsigned char *imgData; Tk_PhotoImageBlock svgblock; + double scale; + + scale = GetScaleFromParameters( + nsvgImage, + ropts, + &w, + &h); - w = (int) ceil(nsvgImage->width * ropts->scale); - h = (int) ceil(nsvgImage->height * ropts->scale); rast = nsvgCreateRasterizer(); if (rast == NULL) { Tcl_SetObjResult(interp, Tcl_NewStringObj("cannot initialize rasterizer", -1)); @@ -475,7 +535,7 @@ RasterizeSVG( goto cleanRAST; } nsvgRasterize(rast, nsvgImage, 0, 0, - (float) ropts->scale, imgData, w, h, w * 4); + (float) scale, imgData, w, h, w * 4); /* transfer the data to a photo block */ svgblock.pixelPtr = imgData; svgblock.width = w; @@ -512,6 +572,90 @@ cleanAST: /* *---------------------------------------------------------------------- * + * GetScaleFromParameters -- + * + * Get the scale value from the already parsed parameters -scale, + * -scaletoheight and -scaletowidth. + * + * The image width and height is also returned. + * Both are greater or equal to 1. + * + * Results: + * The evaluated or configured scale value or 0.0 on failure + * + * Side effects: + * height and width is set to heightPtr and widthPtr. + * + *---------------------------------------------------------------------- + */ + +static double +GetScaleFromParameters( + NSVGimage *nsvgImage, + RastOpts *ropts, + int *widthPtr, + int *heightPtr) +{ + double scale; + int width, height; + /* + * To avoid division by 0, check for positive image size + */ + if ((nsvgImage->width == 0.0) || (nsvgImage->height == 0.0)) { + /* + * Image width or height is zero. + * This might be due to a small image with a very high dpi value. + * Set image size to 1x1 pixel, which is the minimum + * This is more sensible than throwing an error. + */ + width = 1; + height = 1; + scale = 1.0; + } else if (ropts->scaleToHeight > 0) { + /* + * Fix height + */ + height = ropts->scaleToHeight; + scale = height / nsvgImage->height; + width = (int) ceil(nsvgImage->width * scale); + } else if (ropts->scaleToWidth > 0) { + /* + * Fix width + */ + width = ropts->scaleToWidth; + scale = width / nsvgImage->width; + height = (int) ceil(nsvgImage->height * scale); + } else { + /* + * Scale factor + */ + scale = ropts->scale; + width = (int) ceil(nsvgImage->width * scale); + height = (int) ceil(nsvgImage->height * scale); + } + /* + * Set width or height to minimum 1 pixel. + * This is the minimum. + * It is more sensible to scale to the minimum than output an + * error on very small scales. + */ + if (width <= 0) { + width = 1; + } + if (height <= 0) { + height = 1; + } + /* + * Output the found values + */ + *heightPtr = height; + *widthPtr = width; + return scale; +} + +/* + *---------------------------------------------------------------------- + * * GetCachePtr -- * * This function is called to get the per interpreter used diff --git a/tests/imgSVGnano.test b/tests/imgSVGnano.test index 7ac9066..7b39f3e 100644 --- a/tests/imgSVGnano.test +++ b/tests/imgSVGnano.test @@ -79,7 +79,62 @@ test imgSVGnano-2.3 {using bad option} -body { foo configure -format {svg 1.0} } -cleanup { rename foo "" -} -returnCodes error -result {bad option "1.0": must be -dpi or -scale} +} -returnCodes error -result {bad option "1.0": must be -dpi, -scale, -scaletoheight, or -scaletowidth} + +# -scaletoheight and -scaletowidth options +test imgSVGnano-3.1 {multiple scale options} -body { + image create photo foo -format "svg -scale 1 -scaletowidth 20"\ + -data $data(bad) +} -returnCodes error -result {only one of -scale, -scaletoheight, -scaletowidth may be given} + +test imgSVGnano-3.2 {no number parameter to -scaletowidth} -body { + image create photo foo -format "svg -scaletowidth invalid"\ + -data $data(plus) +} -returnCodes error -result {expected integer but got "invalid"} + +test imgSVGnano-3.3 {no number parameter to -scaletoheight} -body { + image create photo foo -format "svg -scaletoheight invalid"\ + -data $data(plus) +} -returnCodes error -result {expected integer but got "invalid"} + +test imgSVGnano-3.4 {zero parameter to -scaletowidth} -body { + image create photo foo -format "svg -scaletowidth 0"\ + -data $data(plus) +} -returnCodes error -result {-scaletowidth value must be positive} + +test imgSVGnano-3.5 {zero parameter to -scaletowidth} -body { + image create photo foo -format "svg -scaletoheight 0"\ + -data $data(plus) +} -returnCodes error -result {-scaletoheight value must be positive} + +test imgSVGnano-3.6 {no number parameter to -scaletoheight} -body { + image create photo foo -format "svg -scale 1 -scaletoheight invalid"\ + -data $data(plus) +} -returnCodes error -result {only one of -scale, -scaletoheight, -scaletowidth may be given} + +test imgSVGnano-3.7 {Option -scaletowidth} -body { + image create photo foo -format "svg -scaletowidth 20"\ + -data $data(plus) + image width foo +} -cleanup { + rename foo "" +} -result {20} + +test imgSVGnano-3.8 {Option -scaletoheight} -body { + image create photo foo -format "svg -scaletoheight 20"\ + -data $data(plus) + image height foo +} -cleanup { + rename foo "" +} -result {20} + +test imgSVGnano-3.9 {Very small scale gives 1x1 image} -body { + image create photo foo -format "svg -scale 0.000001"\ + -data $data(plus) + image height foo +} -cleanup { + rename foo "" +} -result {1} };# end of namespace svgnano -- cgit v0.12 From b77cb993f609086a6764307b39099bfdc9920945 Mon Sep 17 00:00:00 2001 From: oehhar Date: Sun, 9 Jun 2019 12:51:50 +0000 Subject: svgnano return width or height of 0 is an error and is true for some png images. --- generic/tkImgSVGnano.c | 75 +++++++++++++++++++++++++++----------------------- 1 file changed, 41 insertions(+), 34 deletions(-) diff --git a/generic/tkImgSVGnano.c b/generic/tkImgSVGnano.c index 3f1f7e4..6242d30 100644 --- a/generic/tkImgSVGnano.c +++ b/generic/tkImgSVGnano.c @@ -139,18 +139,26 @@ FileMatchSVG( data = Tcl_GetStringFromObj(dataObj, &length); nsvgImage = ParseSVGWithOptions(interp, data, length, formatObj, &ropts); Tcl_DecrRefCount(dataObj); - if (nsvgImage != NULL) { - GetScaleFromParameters( - nsvgImage, - &ropts, - widthPtr, - heightPtr); - if (!CacheSVG(interp, chan, formatObj, nsvgImage, &ropts)) { - nsvgDelete(nsvgImage); - } - return 1; + if (nsvgImage == NULL) { + return 0; } - return 0; + /* + * Width and Height equal zero is an svgnano error case and must be errored + * out. Valid png images give width and height 0 as result + */ + if ((nsvgImage->width <= 0.0) || (nsvgImage->height <= 0.0)) { + nsvgDelete(nsvgImage); + return 0; + } + GetScaleFromParameters( + nsvgImage, + &ropts, + widthPtr, + heightPtr); + if (!CacheSVG(interp, chan, formatObj, nsvgImage, &ropts)) { + nsvgDelete(nsvgImage); + } + return 1; } /* @@ -243,18 +251,26 @@ StringMatchSVG( CleanCache(interp); data = Tcl_GetStringFromObj(dataObj, &length); nsvgImage = ParseSVGWithOptions(interp, data, length, formatObj, &ropts); - if (nsvgImage != NULL) { - GetScaleFromParameters( - nsvgImage, - &ropts, - widthPtr, - heightPtr); - if (!CacheSVG(interp, dataObj, formatObj, nsvgImage, &ropts)) { - nsvgDelete(nsvgImage); - } - return 1; + if (nsvgImage == NULL) { + return 0; } - return 0; + /* + * Width and Height equal zero is an svgnano error case and must be errored + * out. Valid png images give width and height 0 as result + */ + if ((nsvgImage->width <= 0.0) || (nsvgImage->height <= 0.0)) { + nsvgDelete(nsvgImage); + return 0; + } + GetScaleFromParameters( + nsvgImage, + &ropts, + widthPtr, + heightPtr); + if (!CacheSVG(interp, dataObj, formatObj, nsvgImage, &ropts)) { + nsvgDelete(nsvgImage); + } + return 1; } /* @@ -599,19 +615,10 @@ GetScaleFromParameters( double scale; int width, height; /* - * To avoid division by 0, check for positive image size + * nsvgImage->width and nsvgImage->height are greater than 0. + * Equal to 0 is an svgnano error case. */ - if ((nsvgImage->width == 0.0) || (nsvgImage->height == 0.0)) { - /* - * Image width or height is zero. - * This might be due to a small image with a very high dpi value. - * Set image size to 1x1 pixel, which is the minimum - * This is more sensible than throwing an error. - */ - width = 1; - height = 1; - scale = 1.0; - } else if (ropts->scaleToHeight > 0) { + if (ropts->scaleToHeight > 0) { /* * Fix height */ -- cgit v0.12 From 5e6d237cf90c41cd630dd23727ca47ef9e18e62c Mon Sep 17 00:00:00 2001 From: fvogel Date: Mon, 10 Jun 2019 11:53:27 +0000 Subject: Minor changes in the new tests --- tests/imgSVGnano.test | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/tests/imgSVGnano.test b/tests/imgSVGnano.test index 7b39f3e..a3bdcbf 100644 --- a/tests/imgSVGnano.test +++ b/tests/imgSVGnano.test @@ -102,15 +102,15 @@ test imgSVGnano-3.4 {zero parameter to -scaletowidth} -body { -data $data(plus) } -returnCodes error -result {-scaletowidth value must be positive} -test imgSVGnano-3.5 {zero parameter to -scaletowidth} -body { +test imgSVGnano-3.5 {zero parameter to -scaletoheight} -body { image create photo foo -format "svg -scaletoheight 0"\ -data $data(plus) } -returnCodes error -result {-scaletoheight value must be positive} test imgSVGnano-3.6 {no number parameter to -scaletoheight} -body { - image create photo foo -format "svg -scale 1 -scaletoheight invalid"\ + image create photo foo -format "svg -scaletoheight invalid"\ -data $data(plus) -} -returnCodes error -result {only one of -scale, -scaletoheight, -scaletowidth may be given} +} -returnCodes error -result {expected integer but got "invalid"} test imgSVGnano-3.7 {Option -scaletowidth} -body { image create photo foo -format "svg -scaletowidth 20"\ @@ -131,10 +131,10 @@ test imgSVGnano-3.8 {Option -scaletoheight} -body { test imgSVGnano-3.9 {Very small scale gives 1x1 image} -body { image create photo foo -format "svg -scale 0.000001"\ -data $data(plus) - image height foo + list [image width foo] [image height foo] } -cleanup { rename foo "" -} -result {1} +} -result {1 1} };# end of namespace svgnano -- cgit v0.12 From b226034dbfd6109d17ec0fc8f941f88c00aa3c37 Mon Sep 17 00:00:00 2001 From: fvogel Date: Mon, 10 Jun 2019 12:10:57 +0000 Subject: Update documentation to reflect content of TIP #545 --- doc/photo.n | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/doc/photo.n b/doc/photo.n index 2f6076e..2673985 100644 --- a/doc/photo.n +++ b/doc/photo.n @@ -552,19 +552,20 @@ background on which the image is displayed to show through. This usually also has the effect of desaturating the image. The \fIalphaValue\fR must be between 0.0 and 1.0. .TP -\fBsvg \-dpi\fI dpiValue\fB \-scale\fI scaleValue\fB \-unit\fI unitValue\fR +\fBsvg \-dpi\fI dpiValue\fB \-scale\fI scaleValue\fB \-scaletowidth \fI width\fB \-scaletoheight\fI height\fR . \fIdpiValue\fR is used in conversion between given coordinates and screen resolution. The value must be greater than 0 and the default value is 96. \fIscaleValue\fR is used to scale the resulting image. The value must be greater than 0 and the default value is 1. -\fIunitValue\fR is the unit of all coordinates in the SVG data. -Available units are px (default, coordinates in pixel), pt (1/72 inch), -pc (12 pt), mm , cm and in. +\fIwidth\fR and \fIheight\fR are the width or height that the image +will be adjusted to. Only one parameter among \fB\-scale\fR, +\fB\-scaletowidth\fR and \fB\-scaletoheight\fR can be given at a time +and the aspect ratio of the original image is always preserved. The svg format supports a wide range of SVG features, but the full SVG standard is not available, for instance the 'text' feature -is missing and silently ignores when reading the SVG data. +is missing and silently ignored when reading the SVG data. The supported SVG features are: . .RS -- cgit v0.12 From 0adcce9da922f58202c0b076d36914dcd290c420 Mon Sep 17 00:00:00 2001 From: fvogel Date: Mon, 10 Jun 2019 12:22:23 +0000 Subject: Fix code style a bit, and comments --- generic/tkImgSVGnano.c | 22 +++++++--------------- 1 file changed, 7 insertions(+), 15 deletions(-) diff --git a/generic/tkImgSVGnano.c b/generic/tkImgSVGnano.c index 6242d30..ae9da9f 100644 --- a/generic/tkImgSVGnano.c +++ b/generic/tkImgSVGnano.c @@ -262,11 +262,7 @@ StringMatchSVG( nsvgDelete(nsvgImage); return 0; } - GetScaleFromParameters( - nsvgImage, - &ropts, - widthPtr, - heightPtr); + GetScaleFromParameters(nsvgImage, &ropts, widthPtr, heightPtr); if (!CacheSVG(interp, dataObj, formatObj, nsvgImage, &ropts)) { nsvgDelete(nsvgImage); } @@ -531,11 +527,7 @@ RasterizeSVG( Tk_PhotoImageBlock svgblock; double scale; - scale = GetScaleFromParameters( - nsvgImage, - ropts, - &w, - &h); + scale = GetScaleFromParameters(nsvgImage, ropts, &w, &h); rast = nsvgCreateRasterizer(); if (rast == NULL) { @@ -594,13 +586,13 @@ cleanAST: * -scaletoheight and -scaletowidth. * * The image width and height is also returned. - * Both are greater or equal to 1. + * Both are greater than or equal to 1. * * Results: - * The evaluated or configured scale value or 0.0 on failure + * The evaluated or configured scale value, or 0.0 on failure * * Side effects: - * height and width is set to heightPtr and widthPtr. + * heightPtr and widthPtr are set to height and width of the image. * *---------------------------------------------------------------------- */ @@ -620,14 +612,14 @@ GetScaleFromParameters( */ if (ropts->scaleToHeight > 0) { /* - * Fix height + * Fixed height */ height = ropts->scaleToHeight; scale = height / nsvgImage->height; width = (int) ceil(nsvgImage->width * scale); } else if (ropts->scaleToWidth > 0) { /* - * Fix width + * Fixed width */ width = ropts->scaleToWidth; scale = width / nsvgImage->width; -- cgit v0.12 From dc8652e4584c5d38db87555343e97c675a3caa27 Mon Sep 17 00:00:00 2001 From: fvogel Date: Wed, 12 Jun 2019 22:23:54 +0000 Subject: Remove wrong forcing of image size to 1x1 when it was read from the data or disk to be 0x0 (which indicates the image could not be parsed in that format). Handling for images 0x0 in size must be kept because Tk bases its error detection for the format on this feature. --- generic/tkImgSVGnano.c | 83 +++++++++++++++++--------------------------------- 1 file changed, 28 insertions(+), 55 deletions(-) diff --git a/generic/tkImgSVGnano.c b/generic/tkImgSVGnano.c index ae9da9f..bf47053 100644 --- a/generic/tkImgSVGnano.c +++ b/generic/tkImgSVGnano.c @@ -139,26 +139,18 @@ FileMatchSVG( data = Tcl_GetStringFromObj(dataObj, &length); nsvgImage = ParseSVGWithOptions(interp, data, length, formatObj, &ropts); Tcl_DecrRefCount(dataObj); - if (nsvgImage == NULL) { - return 0; - } - /* - * Width and Height equal zero is an svgnano error case and must be errored - * out. Valid png images give width and height 0 as result - */ - if ((nsvgImage->width <= 0.0) || (nsvgImage->height <= 0.0)) { - nsvgDelete(nsvgImage); - return 0; - } - GetScaleFromParameters( - nsvgImage, - &ropts, - widthPtr, - heightPtr); - if (!CacheSVG(interp, chan, formatObj, nsvgImage, &ropts)) { - nsvgDelete(nsvgImage); + if (nsvgImage != NULL) { + GetScaleFromParameters(nsvgImage, &ropts, widthPtr, heightPtr); + if ((*widthPtr <= 0.0) || (*heightPtr <= 0.0)) { + nsvgDelete(nsvgImage); + return 0; + } + if (!CacheSVG(interp, chan, formatObj, nsvgImage, &ropts)) { + nsvgDelete(nsvgImage); + } + return 1; } - return 1; + return 0; } /* @@ -251,22 +243,18 @@ StringMatchSVG( CleanCache(interp); data = Tcl_GetStringFromObj(dataObj, &length); nsvgImage = ParseSVGWithOptions(interp, data, length, formatObj, &ropts); - if (nsvgImage == NULL) { - return 0; - } - /* - * Width and Height equal zero is an svgnano error case and must be errored - * out. Valid png images give width and height 0 as result - */ - if ((nsvgImage->width <= 0.0) || (nsvgImage->height <= 0.0)) { - nsvgDelete(nsvgImage); - return 0; - } - GetScaleFromParameters(nsvgImage, &ropts, widthPtr, heightPtr); - if (!CacheSVG(interp, dataObj, formatObj, nsvgImage, &ropts)) { - nsvgDelete(nsvgImage); + if (nsvgImage != NULL) { + GetScaleFromParameters(nsvgImage, &ropts, widthPtr, heightPtr); + if ((*widthPtr <= 0.0) || (*heightPtr <= 0.0)) { + nsvgDelete(nsvgImage); + return 0; + } + if (!CacheSVG(interp, dataObj, formatObj, nsvgImage, &ropts)) { + nsvgDelete(nsvgImage); + } + return 1; } - return 1; + return 0; } /* @@ -586,7 +574,6 @@ cleanAST: * -scaletoheight and -scaletowidth. * * The image width and height is also returned. - * Both are greater than or equal to 1. * * Results: * The evaluated or configured scale value, or 0.0 on failure @@ -606,11 +593,11 @@ GetScaleFromParameters( { double scale; int width, height; - /* - * nsvgImage->width and nsvgImage->height are greater than 0. - * Equal to 0 is an svgnano error case. - */ - if (ropts->scaleToHeight > 0) { + + if ((nsvgImage->width == 0.0) || (nsvgImage->height == 0.0)) { + width = height = 0; + scale = 1.0; + } else if (ropts->scaleToHeight > 0) { /* * Fixed height */ @@ -632,21 +619,7 @@ GetScaleFromParameters( width = (int) ceil(nsvgImage->width * scale); height = (int) ceil(nsvgImage->height * scale); } - /* - * Set width or height to minimum 1 pixel. - * This is the minimum. - * It is more sensible to scale to the minimum than output an - * error on very small scales. - */ - if (width <= 0) { - width = 1; - } - if (height <= 0) { - height = 1; - } - /* - * Output the found values - */ + *heightPtr = height; *widthPtr = width; return scale; -- cgit v0.12 From 972db41befadc17a6d88853f55720ac0f172582b Mon Sep 17 00:00:00 2001 From: oehhar Date: Fri, 14 Jun 2019 16:46:21 +0000 Subject: Tests for svg file --- tests/imgSVGnano.test | 61 ++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 60 insertions(+), 1 deletion(-) diff --git a/tests/imgSVGnano.test b/tests/imgSVGnano.test index a3bdcbf..1f1c8c1 100644 --- a/tests/imgSVGnano.test +++ b/tests/imgSVGnano.test @@ -27,6 +27,9 @@ namespace eval svgnano { "> } + tcltest::makeFile $data(plus) plus.svg + set data(plusFilePath) [file join [tcltest::configure -tmpdir] plus.svg] + test imgSVGnano-1.1 {reading simple image} -setup { catch {rename foo ""} } -body { @@ -67,7 +70,6 @@ test imgSVGnano-1.4 {image options} -setup { rename foo "" } -result {100 100} - test imgSVGnano-2.1 {reading a bad image} -body { image create photo foo -format svg -data $data(bad) } -returnCodes error -result {couldn't recognize image data} @@ -136,6 +138,63 @@ test imgSVGnano-3.9 {Very small scale gives 1x1 image} -body { rename foo "" } -result {1 1} +test imgSVGnano-3.10 {change from -scaletoheight to -scale} -body { + set res {} + image create photo foo -format "svg -scaletoheight 16"\ + -data $data(plus) + lappend res [image width foo] [image height foo] + foo configure -format "svg -scale 2" + lappend res [image width foo] [image height foo] +} -cleanup { + rename foo "" + unset res +} -result {16 16 200 200} + +# svg file access +test imgSVGnano-4.1 {reading simple image from file} -setup { + catch {rename foo ""} +} -body { + image create photo foo -file $data(plusFilePath) + list [image width foo] [image height foo] +} -cleanup { + rename foo "" +} -result {100 100} + +test imgSVGnano-4.2 {simple image with options} -setup { + catch {rename foo ""} +} -body { + image create photo foo -file $data(plusFilePath) -format {svg -dpi 100 -scale 3} + list [image width foo] [image height foo] +} -cleanup { + rename foo "" +} -result {300 300} + +test imgSVGnano-4.3 {reread file on configure -scale} -setup { + catch {rename foo ""} + set res {} +} -body { + image create photo foo -file $data(plusFilePath) + lappend res [image width foo] [image height foo] + foo configure -format "svg -scale 2" + lappend res [image width foo] [image height foo] +} -cleanup { + rename foo "" + unset res +} -result {100 100 200 200} + + +test imgSVGnano-4.4 {error on file not accessible on reread due to configure} -setup { + catch {rename foo ""} + tcltest::makeFile $data(plus) tmpplus.svg + image create photo foo -file [file join [tcltest::configure -tmpdir] tmpplus.svg] + tcltest::removeFile tmpplus.svg +} -body { + foo configure -format "svg -scale 2" +} -cleanup { + rename foo "" + tcltest::removeFile tmpplus.svg +} -returnCodes error -match glob -result {couldn't open "*/tmpplus.svg": no such file or directory} + };# end of namespace svgnano namespace delete svgnano -- cgit v0.12 From ed20571d50e43ed0f2849f1846e2c93daee0146c Mon Sep 17 00:00:00 2001 From: oehhar Date: Sun, 16 Jun 2019 16:57:27 +0000 Subject: Do small scale to 1x1 test also for file source, renumber tests. --- tests/imgSVGnano.test | 68 ++++++++++++++++++++++++++++++--------------------- 1 file changed, 40 insertions(+), 28 deletions(-) diff --git a/tests/imgSVGnano.test b/tests/imgSVGnano.test index 1f1c8c1..f2ad233 100644 --- a/tests/imgSVGnano.test +++ b/tests/imgSVGnano.test @@ -30,6 +30,9 @@ namespace eval svgnano { tcltest::makeFile $data(plus) plus.svg set data(plusFilePath) [file join [tcltest::configure -tmpdir] plus.svg] + tcltest::makeFile $data(bad) bad.svg + set data(badFilePath) [file join [tcltest::configure -tmpdir] bad.svg] + test imgSVGnano-1.1 {reading simple image} -setup { catch {rename foo ""} } -body { @@ -69,6 +72,37 @@ test imgSVGnano-1.4 {image options} -setup { } -cleanup { rename foo "" } -result {100 100} +test imgSVGnano-1.5 {reading simple image from file} -setup { + catch {rename foo ""} +} -body { + image create photo foo -file $data(plusFilePath) + list [image width foo] [image height foo] +} -cleanup { + rename foo "" +} -result {100 100} + +test imgSVGnano-1.6 {simple image with options} -setup { + catch {rename foo ""} +} -body { + image create photo foo -file $data(plusFilePath) -format {svg -dpi 100 -scale 3} + list [image width foo] [image height foo] +} -cleanup { + rename foo "" +} -result {300 300} +test imgSVGnano-1.7 {Very small scale gives 1x1 image} -body { + image create photo foo -format "svg -scale 0.000001"\ + -data $data(plus) + list [image width foo] [image height foo] +} -cleanup { + rename foo "" +} -result {1 1} +test imgSVGnano-1.8 {Very small scale gives 1x1 image from file} -body { + image create photo foo -format "svg -scale 0.000001"\ + -file $data(plusFilePath) + list [image width foo] [image height foo] +} -cleanup { + rename foo "" +} -result {1 1} test imgSVGnano-2.1 {reading a bad image} -body { image create photo foo -format svg -data $data(bad) @@ -82,6 +116,10 @@ test imgSVGnano-2.3 {using bad option} -body { } -cleanup { rename foo "" } -returnCodes error -result {bad option "1.0": must be -dpi, -scale, -scaletoheight, or -scaletowidth} +test imgSVGnano-2.4 {reading a bad image from file} -body { + image create photo foo -format svg -file $data(badFilePath) +} -returnCodes error -match glob\ + -result {couldn't recognize data in image file "*/win/bad.svg"} # -scaletoheight and -scaletowidth options test imgSVGnano-3.1 {multiple scale options} -body { @@ -130,14 +168,6 @@ test imgSVGnano-3.8 {Option -scaletoheight} -body { rename foo "" } -result {20} -test imgSVGnano-3.9 {Very small scale gives 1x1 image} -body { - image create photo foo -format "svg -scale 0.000001"\ - -data $data(plus) - list [image width foo] [image height foo] -} -cleanup { - rename foo "" -} -result {1 1} - test imgSVGnano-3.10 {change from -scaletoheight to -scale} -body { set res {} image create photo foo -format "svg -scaletoheight 16"\ @@ -151,25 +181,7 @@ test imgSVGnano-3.10 {change from -scaletoheight to -scale} -body { } -result {16 16 200 200} # svg file access -test imgSVGnano-4.1 {reading simple image from file} -setup { - catch {rename foo ""} -} -body { - image create photo foo -file $data(plusFilePath) - list [image width foo] [image height foo] -} -cleanup { - rename foo "" -} -result {100 100} - -test imgSVGnano-4.2 {simple image with options} -setup { - catch {rename foo ""} -} -body { - image create photo foo -file $data(plusFilePath) -format {svg -dpi 100 -scale 3} - list [image width foo] [image height foo] -} -cleanup { - rename foo "" -} -result {300 300} - -test imgSVGnano-4.3 {reread file on configure -scale} -setup { +test imgSVGnano-4.1 {reread file on configure -scale} -setup { catch {rename foo ""} set res {} } -body { @@ -183,7 +195,7 @@ test imgSVGnano-4.3 {reread file on configure -scale} -setup { } -result {100 100 200 200} -test imgSVGnano-4.4 {error on file not accessible on reread due to configure} -setup { +test imgSVGnano-4.2 {error on file not accessible on reread due to configure} -setup { catch {rename foo ""} tcltest::makeFile $data(plus) tmpplus.svg image create photo foo -file [file join [tcltest::configure -tmpdir] tmpplus.svg] -- cgit v0.12 From b621725f924df41080e34e4f39c7b7876074f1ba Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Sun, 4 Aug 2019 19:14:45 +0000 Subject: It turns out that is actually not needed on Win32 --- win/tkWinPort.h | 1 - 1 file changed, 1 deletion(-) diff --git a/win/tkWinPort.h b/win/tkWinPort.h index 74cac15..254f44e 100644 --- a/win/tkWinPort.h +++ b/win/tkWinPort.h @@ -64,7 +64,6 @@ typedef _TCHAR TCHAR; #endif -#include #include #include #include -- cgit v0.12 From 77587d48dfa24f29cf65de67ac0abc7f8baa86cd Mon Sep 17 00:00:00 2001 From: Kevin Walzer Date: Fri, 9 Aug 2019 12:19:28 +0000 Subject: Tweak display of spinboxes on macOS; thanks to Christopher Chavez for patch --- generic/tkEntry.c | 24 ++++++++++-------------- macosx/tkMacOSXEntry.c | 23 ++++++++++++----------- 2 files changed, 22 insertions(+), 25 deletions(-) diff --git a/generic/tkEntry.c b/generic/tkEntry.c index a7bc5a0..0dfacd7 100644 --- a/generic/tkEntry.c +++ b/generic/tkEntry.c @@ -1513,17 +1513,15 @@ EntryWorldChanged( * * TkpDrawEntryBorderAndFocus -- * - * This function redraws the border of an entry widget. It overrides the - * generic border drawing code if the entry widget parameters are such - * that the native widget drawing is a good fit. This version just - * returns 0, so platforms that don't do special native drawing don't - * have to implement it. + * Stub function for Tk on platforms other than Aqua + * (Windows and X11), which do not draw native entry borders. + * See macosx/tkMacOSXEntry.c for function definition in Tk Aqua. * * Results: - * 1 if it has drawn the border, 0 if not. + * Returns 0. * * Side effects: - * May draw the entry border into pixmap. + * None. * *-------------------------------------------------------------- */ @@ -1542,17 +1540,15 @@ TkpDrawEntryBorderAndFocus( * * TkpDrawSpinboxButtons -- * - * This function redraws the buttons of an spinbox widget. It overrides - * the generic button drawing code if the spinbox widget parameters are - * such that the native widget drawing is a good fit. This version just - * returns 0, so platforms that don't do special native drawing don't - * have to implement it. + * Stub function for Tk on platforms other than Aqua + * (Windows and X11), which do not draw native spinbox buttons. + * See macosx/tkMacOSXEntry.c for function definition in Tk Aqua. * * Results: - * 1 if it has drawn the border, 0 if not. + * Returns 0. * * Side effects: - * May draw the entry border into pixmap. + * None. * *-------------------------------------------------------------- */ diff --git a/macosx/tkMacOSXEntry.c b/macosx/tkMacOSXEntry.c index a1c5d60..7915f6f 100644 --- a/macosx/tkMacOSXEntry.c +++ b/macosx/tkMacOSXEntry.c @@ -124,16 +124,17 @@ TkpDrawEntryBorderAndFocus( int incDecWidth; /* - * Temporarily change the width of the widget so that the same code can - * be used for drawing the Entry portion of the Spinbox as is used to - * draw an ordinary Entry. The width must be restored before - * returning. + * If native spinbox buttons are going to be drawn, then temporarily + * change the width of the widget so that the same code can be used + * for drawing the Entry portion of the Spinbox as is used to draw + * an ordinary Entry. The width must be restored before returning. */ oldWidth = Tk_Width(tkwin); - ComputeIncDecParameters(Tk_Height(tkwin) - 2 * MAC_OSX_FOCUS_WIDTH, - &incDecWidth); - Tk_Width(tkwin) -= incDecWidth + 1; + if (ComputeIncDecParameters(Tk_Height(tkwin) - 2 * MAC_OSX_FOCUS_WIDTH, + &incDecWidth) != 0) { + Tk_Width(tkwin) -= incDecWidth + 1; + } } /* @@ -186,10 +187,10 @@ TkpDrawEntryBorderAndFocus( * have to implement it. * * Results: - * 1 if it has drawn the border, 0 if not. + * 1 if it has drawn the buttons, 0 if not. * * Side effects: - * May draw the entry border into pixmap. + * May draw the buttons into pixmap. * *-------------------------------------------------------------- */ @@ -258,9 +259,9 @@ TkpDrawSpinboxButtons( */ bgGC = Tk_GCForColor(sbPtr->entry.highlightBgColorPtr, d); - rects[0].x = bounds.origin.x; + rects[0].x = Tk_Width(tkwin) - incDecWidth - 1; rects[0].y = 0; - rects[0].width = Tk_Width(tkwin); + rects[0].width = incDecWidth + 1; rects[0].height = Tk_Height(tkwin); XFillRectangles(Tk_Display(tkwin), d, bgGC, rects, 1); -- cgit v0.12 From 4ebe61f87e43bc4477641121cdd51a52b70dd775 Mon Sep 17 00:00:00 2001 From: fvogel Date: Sun, 11 Aug 2019 18:11:18 +0000 Subject: Fix typo in a comment in tkWinFont.c. Thanks to C. Chavez --- win/tkWinFont.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/win/tkWinFont.c b/win/tkWinFont.c index 63ddff4..ad7738f 100644 --- a/win/tkWinFont.c +++ b/win/tkWinFont.c @@ -2178,7 +2178,7 @@ FontMapInsert( * None. * * Side effects: - * Mempry allocated. + * Memory allocated. * *------------------------------------------------------------------------- */ -- cgit v0.12 From 6e359bd331f0d8c53f8c10cebc13784f866b6968 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Tue, 13 Aug 2019 07:32:07 +0000 Subject: Use "unsigned long" as type for "mask" variables containing X11 button-masks consistantly. Code cleanup. --- generic/tkCanvas.c | 4 ++-- generic/tkEvent.c | 2 +- generic/tkInt.h | 2 +- generic/tkTextTag.c | 2 +- generic/ttk/ttkTreeview.c | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/generic/tkCanvas.c b/generic/tkCanvas.c index ab648a1..5b4d19b 100644 --- a/generic/tkCanvas.c +++ b/generic/tkCanvas.c @@ -1027,7 +1027,7 @@ CanvasWidgetCmd( result = TCL_ERROR; goto done; } - if (mask & (unsigned) ~(ButtonMotionMask|Button1MotionMask + if (mask & ~(unsigned long)(ButtonMotionMask|Button1MotionMask |Button2MotionMask|Button3MotionMask|Button4MotionMask |Button5MotionMask|ButtonPressMask|ButtonReleaseMask |EnterWindowMask|LeaveWindowMask|KeyPressMask @@ -4747,7 +4747,7 @@ CanvasBindProc( XEvent *eventPtr) /* Pointer to X event that just happened. */ { TkCanvas *canvasPtr = clientData; - int mask; + unsigned long mask; Tcl_Preserve(canvasPtr); diff --git a/generic/tkEvent.c b/generic/tkEvent.c index 753a31b..f5ef1f8 100644 --- a/generic/tkEvent.c +++ b/generic/tkEvent.c @@ -540,7 +540,7 @@ static const int buttonMasks[] = { 0, Button1Mask, Button2Mask, Button3Mask, Button4Mask, Button5Mask }; -int +unsigned long TkGetButtonMask( unsigned int button) { diff --git a/generic/tkInt.h b/generic/tkInt.h index 124a8f5..a4f2be4 100644 --- a/generic/tkInt.h +++ b/generic/tkInt.h @@ -940,7 +940,7 @@ typedef struct TkpClipMask { (Button1Mask|Button2Mask|Button3Mask|Button4Mask|Button5Mask) -MODULE_SCOPE int TkGetButtonMask(unsigned int); +MODULE_SCOPE unsigned long TkGetButtonMask(unsigned int); /* * Object types not declared in tkObj.c need to be mentioned here so they can diff --git a/generic/tkTextTag.c b/generic/tkTextTag.c index 5cb08ec..6fa115d 100644 --- a/generic/tkTextTag.c +++ b/generic/tkTextTag.c @@ -292,7 +292,7 @@ TkTextTagCmd( if (mask == 0) { return TCL_ERROR; } - if (mask & (unsigned) ~(ButtonMotionMask|Button1MotionMask + if (mask & ~(unsigned long)(ButtonMotionMask|Button1MotionMask |Button2MotionMask|Button3MotionMask|Button4MotionMask |Button5MotionMask|ButtonPressMask|ButtonReleaseMask |EnterWindowMask|LeaveWindowMask|KeyPressMask diff --git a/generic/ttk/ttkTreeview.c b/generic/ttk/ttkTreeview.c index cda98a0..3674ae5 100644 --- a/generic/ttk/ttkTreeview.c +++ b/generic/ttk/ttkTreeview.c @@ -923,7 +923,7 @@ static void DragColumn(Treeview *tv, int i, int delta) static TreeItem *IdentifyItem(Treeview *tv, int y); /*forward*/ -static const unsigned int TreeviewBindEventMask = +static const unsigned long TreeviewBindEventMask = KeyPressMask|KeyReleaseMask | ButtonPressMask|ButtonReleaseMask | PointerMotionMask|ButtonMotionMask -- cgit v0.12 From bef7988898bd03e82851459cd2b320a1ceb7c4ef Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Tue, 13 Aug 2019 08:33:53 +0000 Subject: Fix indenting in bind.test (taken from TIP #532 branch) --- tests/bind.test | 811 ++++++++++++++++++++++++++++---------------------------- 1 file changed, 406 insertions(+), 405 deletions(-) diff --git a/tests/bind.test b/tests/bind.test index 981ba32..9cbc15b 100644 --- a/tests/bind.test +++ b/tests/bind.test @@ -22,7 +22,7 @@ foreach event [bind Test] { bind Test $event {} } foreach event [bind all] { - bind all $event {} + bind all $event {} } proc unsetBindings {} { @@ -90,10 +90,10 @@ test bind-1.7 {bind command} -body { } -result {test script more text} test bind-1.8 {bind command} -body { - bind .t {test script} + bind .t {test script} } -returnCodes error -result {bad event type or keysym "gorp"} test bind-1.9 {bind command} -body { - catch {bind .t {test script}} + catch {bind .t {test script}} bind .t } -result {} test bind-1.10 {bind command} -body { @@ -154,10 +154,10 @@ test bind-2.8 {bindtags command} -body { test bind-2.9 {bindtags command} -body { frame .t.f bindtags .t.f {a b c} - bindtags .t.f "\{" + bindtags .t.f "\{" } -cleanup { destroy .t.f -} -returnCodes error -result {unmatched open brace in list} +} -returnCodes error -result {unmatched open brace in list} test bind-2.10 {bindtags command} -body { frame .t.f bindtags .t.f {a b c} @@ -169,10 +169,10 @@ test bind-2.10 {bindtags command} -body { test bind-2.11 {bindtags command} -body { frame .t.f bindtags .t.f {a b c} - bindtags .t.f "a .gorp b" + bindtags .t.f "a .gorp b" } -cleanup { destroy .t.f -} -returnCodes ok +} -returnCodes ok test bind-2.12 {bindtags command} -body { frame .t.f bindtags .t.f {a b c} @@ -212,7 +212,7 @@ test bind-4.1 {TkBindEventProc procedure} -setup { bind {a b} {lappend x "%W enter {a b}"} bind .t {lappend x "%W enter .t"} bind .t.f {lappend x "%W enter .t.f"} - + event generate .t.f return $x } -cleanup { @@ -232,9 +232,9 @@ test bind-4.2 {TkBindEventProc procedure} -setup { bind {a b} {lappend x "%W enter {a b}"} bind .t {lappend x "%W enter .t"} bind .t.f {lappend x "%W enter .t.f"} - + bindtags .t.f {.t.f {a b} xyz} - event generate .t.f + event generate .t.f return $x } -cleanup { destroy .t.f @@ -248,7 +248,7 @@ test bind-4.3 {TkBindEventProc procedure} -body { bind xyz {lappend x "%W enter xyz"} bind {a b} {lappend x "%W enter {a b}"} bind .t {lappend x "%W enter .t"} - + event generate .t return $x } -cleanup { @@ -268,7 +268,7 @@ test bind-4.4 {TkBindEventProc procedure} -setup { bind xyz {lappend x "%W enter xyz"} bind {a b} {lappend x "%W enter {a b}"} bind .t {lappend x "%W enter .t"} - + bindtags .t.f {.t.f .t.f2 .t.f3} bind .t.f {lappend x "%W enter .t.f"} bind .t.f3 {lappend x "%W enter .t.f3"} @@ -292,7 +292,7 @@ test bind-4.5 {TkBindEventProc procedure} -setup { bind {a b} {lappend x "%W enter {a b}"} bind .t {lappend x "%W enter .t"} bindtags .t.f {a b c d e f g h i j k l m n o p q r s t u v w x y z} - + event generate .t.f } -cleanup { destroy .t.f @@ -355,11 +355,11 @@ test bind-9.2 {Tk_DeleteBinding procedure} -setup { } -body { frame .t.f -class Test -width 150 -height 100 foreach i {a b c d} { - bind .t.f $i "binding for $i" + bind .t.f $i "binding for $i" } foreach i {b d a c} { - bind .t.f $i {} - lappend result [lsort [bind .t.f]] + bind .t.f $i {} + lappend result [lsort [bind .t.f]] } return $result } -cleanup { @@ -370,11 +370,11 @@ test bind-9.3 {Tk_DeleteBinding procedure} -setup { } -body { frame .t.f -class Test -width 150 -height 100 foreach i {<1> } { - bind .t.f $i "binding for $i" + bind .t.f $i "binding for $i" } foreach i { <1> } { - bind .t.f $i {} - lappend result [lsort [bind .t.f]] + bind .t.f $i {} + lappend result [lsort [bind .t.f]] } return $result } -cleanup { @@ -396,27 +396,27 @@ test bind-10.2 {Tk_GetBinding procedure} -body { } -result {Test} test bind-11.1 {Tk_GetAllBindings procedure} -body { - frame .t.f + frame .t.f foreach i "! a \\\{ ~ <> " { - bind .t.f $i Test + bind .t.f $i Test } lsort [bind .t.f] } -cleanup { destroy .t.f } -result {! <> a \{ ~} test bind-11.2 {Tk_GetAllBindings procedure} -body { - frame .t.f + frame .t.f foreach i " <1>" { - bind .t.f $i Test + bind .t.f $i Test } lsort [bind .t.f] } -cleanup { destroy .t.f } -result { } test bind-11.3 {Tk_GetAllBindings procedure} -body { - frame .t.f + frame .t.f foreach i " abcd ab" { - bind .t.f $i Test + bind .t.f $i Test } lsort [bind .t.f] } -cleanup { @@ -431,7 +431,7 @@ test bind-12.1 {Tk_DeleteAllBindings procedure} -body { test bind-12.2 {Tk_DeleteAllBindings procedure} -body { frame .t.f -class Test -width 150 -height 100 foreach i "a b c " { - bind .t.f $i x + bind .t.f $i x } destroy .t.f } -result {} @@ -448,7 +448,7 @@ test bind-13.1 {Tk_BindEvent procedure} -setup { bind Test : {lappend x "%W %K Test :"} bind all _ {lappend x "%W %K all _"} bind .t.f : {lappend x "%W %K .t.f :"} - + event generate .t.f event generate .t.f event generate .t.f @@ -471,7 +471,7 @@ test bind-13.2 {Tk_BindEvent procedure} -setup { bind Test {lappend x "%W %K Test press any"; break} bind all {continue; lappend x "%W %K all press any"} bind .t.f : {lappend x "%W %K .t.f pressed colon"} - + event generate .t.f return $x } -cleanup { @@ -527,11 +527,11 @@ test bind-13.5 {Tk_BindEvent procedure} -body { frame .t.g -gorp foo } -cleanup { bind all {} -} -returnCodes error -result {unknown option "-gorp"} +} -returnCodes error -result {unknown option "-gorp"} test bind-13.6 {Tk_BindEvent procedure} -body { bind all {lappend x "%W destroyed"} set x {} - catch {frame .t.g -gorp foo} + catch {frame .t.g -gorp foo} return $x } -cleanup { bind all {} @@ -612,10 +612,10 @@ test bind-13.11 {Tk_BindEvent procedure: collapse Motions} -setup { set x {} } -body { bind .t.f "lappend x Motion%#(%x,%y)" - event generate .t.f -serial 100 -x 100 -y 200 -when tail + event generate .t.f -serial 100 -x 100 -y 200 -when tail update event generate .t.f -serial 101 -x 200 -y 300 -when tail - event generate .t.f -serial 102 -x 300 -y 400 -when tail + event generate .t.f -serial 102 -x 300 -y 400 -when tail update return $x } -cleanup { @@ -629,10 +629,10 @@ test bind-13.12 {Tk_BindEvent procedure: collapse repeating modifiers} -setup { } -body { bind .t.f "lappend x %K%#" bind .t.f "lappend x %K%#" - event generate .t.f -serial 100 -when tail - event generate .t.f -serial 101 -when tail - event generate .t.f -serial 102 -when tail - event generate .t.f -serial 103 -when tail + event generate .t.f -serial 100 -when tail + event generate .t.f -serial 101 -when tail + event generate .t.f -serial 102 -when tail + event generate .t.f -serial 103 -when tail update } -cleanup { destroy .t.f @@ -868,7 +868,7 @@ test bind-13.27 {Tk_BindEvent procedure: no detail virtual pattern list} -setup set x {} } -body { bind .t.f {set x Button-2} - event generate .t.f + event generate .t.f return $x } -cleanup { destroy .t.f @@ -948,7 +948,7 @@ test bind-13.33 {Tk_BindEvent procedure: many C bindings cause realloc} -setup { set x {} } -body { bindtags .t.f {a b c d e f g h i j k l m n o p} - foreach p [bindtags .t.f] { + foreach p [bindtags .t.f] { bind $p <1> "lappend x $p" } event generate .t.f <1> @@ -1032,7 +1032,7 @@ test bind-13.43 {Tk_BindEvent procedure: break in script} -setup { } -result {b1} test bind-13.45 {Tk_BindEvent procedure: error in script} -setup { proc bgerror msg { - global x + global x lappend x $msg } frame .t.f -class Test -width 150 -height 100 @@ -1221,7 +1221,7 @@ test bind-15.11 {MatchPatterns procedure, modifier checks} -setup { } -cleanup { destroy .t.f } -result {0} -test bind-15.12 {MatchPatterns procedure, ignore modifier presses and releases} -constraints { +test bind-15.12 {MatchPatterns procedure, ignore modifier presses and releases} -constraints { nonPortable } -setup { frame .t.f -class Test -width 150 -height 100 @@ -1262,7 +1262,7 @@ test bind-15.14 {MatchPatterns procedure, checking "nearby"} -setup { } -body { bind .t.f {set x 1} set x 0 - event generate .t.f + event generate .t.f event generate .t.f event generate .t.f -x 30 -y 40 event generate .t.f -x 31 -y 39 @@ -1279,7 +1279,7 @@ test bind-15.15 {MatchPatterns procedure, checking "nearby"} -setup { } -body { bind .t.f {set x 1} set x 0 - event generate .t.f + event generate .t.f event generate .t.f event generate .t.f -x 30 -y 40 event generate .t.f -x 29 -y 41 @@ -1296,7 +1296,7 @@ test bind-15.16 {MatchPatterns procedure, checking "nearby"} -setup { } -body { bind .t.f {set x 1} set x 0 - event generate .t.f + event generate .t.f event generate .t.f event generate .t.f -x 30 -y 40 event generate .t.f -x 40 -y 40 @@ -1313,7 +1313,7 @@ test bind-15.17 {MatchPatterns procedure, checking "nearby"} -setup { } -body { bind .t.f {set x 1} set x 0 - event generate .t.f + event generate .t.f event generate .t.f event generate .t.f -x 30 -y 40 event generate .t.f -x 20 -y 40 @@ -1330,7 +1330,7 @@ test bind-15.18 {MatchPatterns procedure, checking "nearby"} -setup { } -body { bind .t.f {set x 1} set x 0 - event generate .t.f + event generate .t.f event generate .t.f event generate .t.f -x 30 -y 40 event generate .t.f -x 30 -y 30 @@ -1347,7 +1347,7 @@ test bind-15.19 {MatchPatterns procedure, checking "nearby"} -setup { } -body { bind .t.f {set x 1} set x 0 - event generate .t.f + event generate .t.f event generate .t.f event generate .t.f -x 30 -y 40 event generate .t.f -x 30 -y 50 @@ -1364,7 +1364,7 @@ test bind-15.20 {MatchPatterns procedure, checking "nearby"} -setup { } -body { bind .t.f {set x 1} set x 0 - event generate .t.f + event generate .t.f event generate .t.f event generate .t.f -time 300 event generate .t.f -time 700 @@ -1381,7 +1381,7 @@ test bind-15.21 {MatchPatterns procedure, checking "nearby"} -setup { } -body { bind .t.f {set x 1} set x 0 - event generate .t.f + event generate .t.f event generate .t.f event generate .t.f -time 300 event generate .t.f -time 900 @@ -2049,7 +2049,7 @@ test bind-16.34 {ExpandPercents procedure} -setup { destroy .t.f } -result {781 632} test bind-16.35 {ExpandPercents procedure} -constraints { - nonPortable + nonPortable } -setup { frame .t.f -class Test -width 150 -height 100 pack .t.f @@ -2275,7 +2275,7 @@ test bind-17.6 {event command: add with error} -body { event add <> abc <1> } -cleanup { event delete <> -} -returnCodes error -result {bad event type or keysym "xyz"} +} -returnCodes error -result {bad event type or keysym "xyz"} test bind-17.7 {event command: add with error} -body { event delete <> catch {event add <> abc <1>} @@ -2368,7 +2368,7 @@ test bind-18.1 {CreateVirtualEvent procedure: GetVirtualEventUid} -body { test bind-18.2 {CreateVirtualEvent procedure: FindSequence} -body { event add <> } -returnCodes error -result {bad event type or keysym "Ctrl"} -test bind-18.3 {CreateVirtualEvent procedure: new physical} -body { +test bind-18.3 {CreateVirtualEvent procedure: new physical} -body { event delete <> event add <> event info <> @@ -2377,7 +2377,7 @@ test bind-18.3 {CreateVirtualEvent procedure: new physical} -body { } -result {} test bind-18.4 {CreateVirtualEvent procedure: duplicate physical} -body { event delete <> - event add <> + event add <> event add <> event info <> } -cleanup { @@ -2448,13 +2448,13 @@ test bind-19.7 {DeleteVirtualEvent procedure: owns 1, delete all} -body { foreach p [event info] {event delete $p} event add <> event delete <> - event info + event info } -result {} test bind-19.8 {DeleteVirtualEvent procedure: owns 1, delete 1} -body { foreach p [event info] {event delete $p} event add <> event delete <> - event info + event info } -result {} test bind-19.9 {DeleteVirtualEvent procedure: owns many, delete all} -body { foreach p [event info] {event delete $p} @@ -2506,7 +2506,7 @@ test bind-19.12 {DeleteVirtualEvent procedure: owned by 1, first in chain} -setu event generate .t.f event generate .t.f event generate .t.f - event delete <> + event delete <> event generate .t.f event generate .t.f event generate .t.f @@ -2573,7 +2573,7 @@ test bind-19.14 {DeleteVirtualEvent procedure: owned by 1, last in chain} -setup event generate .t.f event generate .t.f event generate .t.f - event delete <> + event delete <> event generate .t.f event generate .t.f event generate .t.f @@ -2609,7 +2609,7 @@ test bind-19.15 {DeleteVirtualEvent procedure: owned by many, first} -setup { event generate .t.g event generate .t.h event generate .t.h - event delete <> + event delete <> event generate .t.f event generate .t.f event generate .t.g @@ -2681,7 +2681,7 @@ test bind-19.17 {DeleteVirtualEvent procedure: owned by many, last} -setup { event generate .t.g event generate .t.h event generate .t.h - event delete <> + event delete <> event generate .t.f event generate .t.f event generate .t.g @@ -3418,7 +3418,7 @@ test bind-22.55 {HandleEventGenerate: options -override xyz} -setup { set x {} } -body { bind .t.f "lappend x %o" - event generate .t.f -override xyz + event generate .t.f -override xyz } -cleanup { destroy .t.f } -returnCodes error -result {expected boolean value but got "xyz"} @@ -3431,7 +3431,7 @@ test bind-22.56 {HandleEventGenerate: options -override 1} -setup { set x {} } -body { bind .t.f "lappend x %o" - event generate .t.f -override 1 + event generate .t.f -override 1 return $x } -cleanup { destroy .t.f @@ -3445,7 +3445,7 @@ test bind-22.57 {HandleEventGenerate: options -override 1} -setup { set x {} } -body { bind .t.f "lappend x %o" - event generate .t.f -override 1 + event generate .t.f -override 1 return $x } -cleanup { destroy .t.f @@ -3459,7 +3459,7 @@ test bind-22.58 {HandleEventGenerate: options -override 1} -setup { set x {} } -body { bind .t.f "lappend x %o" - event generate .t.f -override 1 + event generate .t.f -override 1 return $x } -cleanup { destroy .t.f @@ -3473,7 +3473,7 @@ test bind-22.59 {HandleEventGenerate: options -override 1} -setup { set x {} } -body { bind .t.f "lappend x %k" - event generate .t.f -override 1 + event generate .t.f -override 1 } -cleanup { destroy .t.f } -returnCodes error -result { event doesn't accept "-override" option} @@ -3486,7 +3486,7 @@ test bind-22.60 {HandleEventGenerate: options -place xyz} -setup { set x {} } -body { bind .t.f "lappend x %p" - event generate .t.f -place xyz + event generate .t.f -place xyz } -cleanup { destroy .t.f } -returnCodes error -result {bad -place value "xyz": must be PlaceOnTop, or PlaceOnBottom} @@ -3499,7 +3499,7 @@ test bind-22.61 {HandleEventGenerate: options -place PlaceOnTop} -se set x {} } -body { bind .t.f "lappend x %p" - event generate .t.f -place PlaceOnTop + event generate .t.f -place PlaceOnTop return $x } -cleanup { destroy .t.f @@ -3513,7 +3513,7 @@ test bind-22.62 {HandleEventGenerate: options -place PlaceOnTop} -setup { set x {} } -body { bind .t.f "lappend x %k" - event generate .t.f -place PlaceOnTop + event generate .t.f -place PlaceOnTop } -cleanup { destroy .t.f } -returnCodes error -result { event doesn't accept "-place" option} @@ -3526,7 +3526,7 @@ test bind-22.63 {HandleEventGenerate: options -root .xyz} -setup { set x {} } -body { bind .t.f "lappend x %R" - event generate .t.f -root .xyz + event generate .t.f -root .xyz } -cleanup { destroy .t.f } -returnCodes error -result {bad window path name ".xyz"} @@ -3539,7 +3539,7 @@ test bind-22.64 {HandleEventGenerate: options -root .t} -setup { set x {} } -body { bind .t.f "lappend x %R" - event generate .t.f -root .t + event generate .t.f -root .t expr {[winfo id .t] eq $x} } -cleanup { destroy .t.f @@ -3553,7 +3553,7 @@ test bind-22.65 {HandleEventGenerate: options -root xyz} -setup { set x {} } -body { bind .t.f "lappend x %R" - event generate .t.f -root xyz + event generate .t.f -root xyz } -cleanup { destroy .t.f } -returnCodes error -result {bad window name/identifier "xyz"} @@ -3566,7 +3566,7 @@ test bind-22.66 {HandleEventGenerate: options -root [winfo id .t]} -setup set x {} } -body { bind .t.f "lappend x %R" - event generate .t.f -root [winfo id .t] + event generate .t.f -root [winfo id .t] expr {[winfo id .t] eq $x} } -cleanup { destroy .t.f @@ -3580,7 +3580,7 @@ test bind-22.67 {HandleEventGenerate: options