From 8313aaf2d2c39dd94d04766a10a0207c682790e2 Mon Sep 17 00:00:00 2001 From: fvogel Date: Sat, 7 Jan 2017 15:49:04 +0000 Subject: Patch from chw for [7a838c38a1]: X11 bind event ring buffer and GraphicsExpose/NoExpose --- generic/tkBind.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/generic/tkBind.c b/generic/tkBind.c index d3fdc96..525e13e 100644 --- a/generic/tkBind.c +++ b/generic/tkBind.c @@ -1260,6 +1260,16 @@ Tk_BindEvent( } } + /* + * Ignore event types which are not in flagArray. Most notably, + * NoExpose events can fill the ring buffer and disturb (thus + * masking out) event sequences of interest. + */ + + if ((eventPtr->type >= TK_LASTEVENT) || !flagArray[eventPtr->type]) { + return; + } + dispPtr = ((TkWindow *) tkwin)->dispPtr; bindInfoPtr = winPtr->mainPtr->bindInfo; -- cgit v0.12 From 16a463a4eb33a7d69b47b2b4ae6203876db04b09 Mon Sep 17 00:00:00 2001 From: fvogel Date: Mon, 9 Jan 2017 13:42:46 +0000 Subject: Better comment explaining why some events are ignored. --- generic/tkBind.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/generic/tkBind.c b/generic/tkBind.c index 525e13e..567c51f 100644 --- a/generic/tkBind.c +++ b/generic/tkBind.c @@ -1261,9 +1261,9 @@ Tk_BindEvent( } /* - * Ignore event types which are not in flagArray. Most notably, - * NoExpose events can fill the ring buffer and disturb (thus - * masking out) event sequences of interest. + * Ignore event types which are not in flagArray and all zeroes there. + * Most notably, NoExpose events can fill the ring buffer and disturb + * (thus masking out) event sequences of interest. */ if ((eventPtr->type >= TK_LASTEVENT) || !flagArray[eventPtr->type]) { -- cgit v0.12 From 5947e3261525f012e16d814aca14fa42a498a5ce Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Tue, 10 Jan 2017 16:02:10 +0000 Subject: More internal use of size_t. Add test-case imgPhoto-4.74, which shows error-handling when there are two values on the command line not connected to options. --- generic/tkImgPhoto.c | 44 ++++++++++++++++++++++++++------------------ tests/imgPhoto.test | 7 +++++++ 2 files changed, 33 insertions(+), 18 deletions(-) diff --git a/generic/tkImgPhoto.c b/generic/tkImgPhoto.c index 3e03f3d..4ee9f69 100644 --- a/generic/tkImgPhoto.c +++ b/generic/tkImgPhoto.c @@ -409,7 +409,8 @@ ImgPhotoCmd( Tk_PhotoImageBlock block; Tk_Window tkwin; Tk_PhotoImageFormat *imageFormat; - int imageWidth, imageHeight, matched, length, oldformat = 0; + size_t length; + int imageWidth, imageHeight, matched, oldformat = 0; Tcl_Channel chan; Tk_PhotoHandle srcHandle; ThreadSpecificData *tsdPtr = @@ -446,12 +447,13 @@ ImgPhotoCmd( Tcl_WrongNumArgs(interp, 2, objv, "option"); return TCL_ERROR; } - arg = Tcl_GetStringFromObj(objv[2], &length); - if (strncmp(arg,"-data", (unsigned) length) == 0) { + arg = Tcl_GetString(objv[2]); + length = objv[2]->length; + if (strncmp(arg,"-data", length) == 0) { if (masterPtr->dataString) { Tcl_SetObjResult(interp, masterPtr->dataString); } - } else if (strncmp(arg,"-format", (unsigned) length) == 0) { + } else if (strncmp(arg,"-format", length) == 0) { if (masterPtr->format) { Tcl_SetObjResult(interp, masterPtr->format); } @@ -495,9 +497,10 @@ ImgPhotoCmd( return TCL_OK; } else if (objc == 3) { - const char *arg = Tcl_GetStringFromObj(objv[2], &length); + const char *arg = Tcl_GetString(objv[2]); - if (length > 1 && !strncmp(arg, "-data", (unsigned) length)) { + length = objv[2]->length; + if (length > 1 && !strncmp(arg, "-data", length)) { Tcl_AppendResult(interp, "-data {} {} {}", NULL); if (masterPtr->dataString) { /* @@ -511,7 +514,7 @@ ImgPhotoCmd( } return TCL_OK; } else if (length > 1 && - !strncmp(arg, "-format", (unsigned) length)) { + !strncmp(arg, "-format", length)) { Tcl_AppendResult(interp, "-format {} {} {}", NULL); if (masterPtr->format) { /* @@ -1489,7 +1492,8 @@ ParseSubcommandOptions( * TK_PHOTO_COMPOSITE_* constants. */ NULL }; - int index, c, bit, currentBit, length; + size_t length; + int index, c, bit, currentBit; int values[4], numValues, maxValues, argIndex; const char *option, *expandedOption, *needed; const char *const *listPtr; @@ -1501,7 +1505,8 @@ ParseSubcommandOptions( * optPtr->name. */ - expandedOption = option = Tcl_GetStringFromObj(objv[index], &length); + expandedOption = option = Tcl_GetString(objv[index]); + length = objv[index]->length; if (option[0] != '-') { if (optPtr->name == NULL) { optPtr->name = objv[index]; @@ -1519,7 +1524,7 @@ ParseSubcommandOptions( currentBit = 1; for (listPtr = optionNames; *listPtr != NULL; ++listPtr) { if ((c == *listPtr[0]) - && (strncmp(option, *listPtr, (size_t) length) == 0)) { + && (strncmp(option, *listPtr, length) == 0)) { expandedOption = *listPtr; if (bit != 0) { goto unknownOrAmbiguousOption; @@ -1765,7 +1770,8 @@ ImgPhotoConfigureMaster( const char *oldFileString, *oldPaletteString; Tcl_Obj *oldData, *data = NULL, *oldFormat, *format = NULL; Tcl_Obj *tempdata, *tempformat; - int length, i, j, result, imageWidth, imageHeight, oldformat; + size_t length; + int i, j, result, imageWidth, imageHeight, oldformat; double oldGamma; Tcl_Channel chan; Tk_PhotoImageFormat *imageFormat; @@ -1773,10 +1779,11 @@ ImgPhotoConfigureMaster( args = ckalloc((objc + 1) * sizeof(char *)); for (i = 0, j = 0; i < objc; i++,j++) { - args[j] = Tcl_GetStringFromObj(objv[i], &length); + args[j] = Tcl_GetString(objv[i]); + length = objv[i]->length; if ((length > 1) && (args[j][0] == '-')) { if ((args[j][1] == 'd') && - !strncmp(args[j], "-data", (size_t) length)) { + !strncmp(args[j], "-data", length)) { if (++i < objc) { data = objv[i]; j--; @@ -1789,7 +1796,7 @@ ImgPhotoConfigureMaster( return TCL_ERROR; } } else if ((args[j][1] == 'f') && - !strncmp(args[j], "-format", (size_t) length)) { + !strncmp(args[j], "-format", length)) { if (++i < objc) { format = objv[i]; j--; @@ -1852,9 +1859,10 @@ ImgPhotoConfigureMaster( * Force into ByteArray format, which most (all) image handlers will * use anyway. Empty length means ignore the -data option. */ + int bytesize; - (void) Tcl_GetByteArrayFromObj(data, &length); - if (length) { + (void) Tcl_GetByteArrayFromObj(data, &bytesize); + if (bytesize) { Tcl_IncrRefCount(data); } else { data = NULL; @@ -1870,8 +1878,8 @@ ImgPhotoConfigureMaster( * object. */ - (void) Tcl_GetStringFromObj(format, &length); - if (length) { + (void) Tcl_GetString(format); + if (format->length) { Tcl_IncrRefCount(format); } else { format = NULL; diff --git a/tests/imgPhoto.test b/tests/imgPhoto.test index e85f512..db23fea 100644 --- a/tests/imgPhoto.test +++ b/tests/imgPhoto.test @@ -797,6 +797,13 @@ test imgPhoto-4.73 {ImgPhotoCmd procedure: copy with -compositingrule} -setup { } -cleanup { image delete photo1 photo2 } -result {0,2 1,1 2,0} +test imgPhoto-4.74 {ImgPhotoCmd procedure: put option error handling} -setup { + image create photo photo1 +} -body { + photo1 put {{white}} -to 10 10 20 20 {{white}} +} -cleanup { + image delete photo1 +} -returnCodes 1 -result {wrong # args: should be "photo1 put data ?-option value ...?"} test imgPhoto-5.1 {ImgPhotoGet/Free procedures, shared instances} -constraints { hasTeapotPhoto -- cgit v0.12 From 225f01858954fb5bc8b0f1304167d52e7249d22d Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Wed, 11 Jan 2017 10:51:15 +0000 Subject: Alternative proposed solution for [d4fb4e80d220e46e588f310291fd7a4205e8cd67|d4fb4e80d2], with test-case. --- generic/tkImgPhoto.c | 6 +++++- tests/imgPhoto.test | 10 ++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/generic/tkImgPhoto.c b/generic/tkImgPhoto.c index 4ee9f69..1bd0142 100644 --- a/generic/tkImgPhoto.c +++ b/generic/tkImgPhoto.c @@ -1540,7 +1540,11 @@ ParseSubcommandOptions( */ if (!(allowedOptions & bit)) { - goto unknownOrAmbiguousOption; + if (optPtr->name != NULL) { + goto unknownOrAmbiguousOption; + } + optPtr->name = objv[index]; + continue; } /* diff --git a/tests/imgPhoto.test b/tests/imgPhoto.test index db23fea..e93dab4 100644 --- a/tests/imgPhoto.test +++ b/tests/imgPhoto.test @@ -804,6 +804,16 @@ test imgPhoto-4.74 {ImgPhotoCmd procedure: put option error handling} -setup { } -cleanup { image delete photo1 } -returnCodes 1 -result {wrong # args: should be "photo1 put data ?-option value ...?"} +test imgPhoto-4.75 { read command: filename starting with '-'} -constraints { + hasTeapotPhoto +} -body { + file copy -force $teapotPhotoFile -teapotPhotoFile + image create photo photo1 + photo1 read -teapotPhotoFile +} -cleanup { + image delete photo1 + file delete ./-teapotPhotoFile +} -result {} test imgPhoto-5.1 {ImgPhotoGet/Free procedures, shared instances} -constraints { hasTeapotPhoto -- cgit v0.12 From 6a0d791579f271fd69868f377393a2e02ab5e82d Mon Sep 17 00:00:00 2001 From: fvogel Date: Sat, 14 Jan 2017 14:32:30 +0000 Subject: Partially fix [fab5fed65e]: OS X - lots of textDisp failures (spurious 'borders' and indices in tk_textRedraw). This commit fixes the spurious indices part of the bug report. --- macosx/tkMacOSXDraw.c | 6 ------ 1 file changed, 6 deletions(-) diff --git a/macosx/tkMacOSXDraw.c b/macosx/tkMacOSXDraw.c index 474ed41..09a6b4e 100644 --- a/macosx/tkMacOSXDraw.c +++ b/macosx/tkMacOSXDraw.c @@ -1527,12 +1527,6 @@ TkScrollWindow( srcRect = CGRectMake(x, y, width, height); dstRect = CGRectOffset(srcRect, dx, dy); - /* Expand the rectangles slightly to avoid degeneracies. */ - srcRect.origin.y -= 1; - srcRect.size.height += 2; - dstRect.origin.y += 1; - dstRect.size.height -= 2; - /* Compute the damage. */ dmgRgn = HIShapeCreateMutableWithRect(&srcRect); extraRgn = HIShapeCreateWithRect(&dstRect); -- cgit v0.12 From 32a7d700a16f886e7d863c0189979b4c89837001 Mon Sep 17 00:00:00 2001 From: fvogel Date: Sun, 15 Jan 2017 22:01:02 +0000 Subject: Partially fix [fab5fed65e]: OS X - lots of textDisp failures (spurious 'borders' and indices in tk_textRedraw). This commit fixes the 'borders' part of the bug report. --- macosx/tkMacOSXWindowEvent.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/macosx/tkMacOSXWindowEvent.c b/macosx/tkMacOSXWindowEvent.c index a669a8a..4672586 100644 --- a/macosx/tkMacOSXWindowEvent.c +++ b/macosx/tkMacOSXWindowEvent.c @@ -357,8 +357,8 @@ GenerateUpdates( event.xany.window = Tk_WindowId(winPtr); event.xany.display = Tk_Display(winPtr); event.type = Expose; - event.xexpose.x = damageBounds.origin.x - bounds.origin.x; - event.xexpose.y = damageBounds.origin.y - bounds.origin.y; + event.xexpose.x = damageBounds.origin.x; + event.xexpose.y = damageBounds.origin.y; event.xexpose.width = damageBounds.size.width; event.xexpose.height = damageBounds.size.height; event.xexpose.count = 0; -- cgit v0.12 From 886747e926ca6149ad730cbd07c59aa716f46435 Mon Sep 17 00:00:00 2001 From: fvogel Date: Sun, 15 Jan 2017 22:29:53 +0000 Subject: Remove obsolete comments. The line they comment was kicked out of the code in [946e946700]. Also, add a small optimization to avoid double invalidation of the damaged region. Indeed the detailed analysis of ticket [fab5fed65e] showed that on OS X the damaged region is invalidated twice: - once through the processing of the Expose event (on OS X the Appkit is not used to draw the widget, Tk is used instead, see comments in tkMacOSXWindowEvent.c around line 770) - a second time because DisplayText() calls TextInvalidateRegion() after TkScrollWindow() --- generic/tkTextDisp.c | 3 ++- macosx/tkMacOSXDraw.c | 3 --- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/generic/tkTextDisp.c b/generic/tkTextDisp.c index 1be26c4..c271b4b 100644 --- a/generic/tkTextDisp.c +++ b/generic/tkTextDisp.c @@ -4299,8 +4299,9 @@ DisplayText( if (TkScrollWindow(textPtr->tkwin, dInfoPtr->scrollGC, dInfoPtr->x, oldY, dInfoPtr->maxX-dInfoPtr->x, height, 0, y-oldY, damageRgn)) { +#ifndef MAC_OSX_TK TextInvalidateRegion(textPtr, damageRgn); - +#endif } numCopies++; TkDestroyRegion(damageRgn); diff --git a/macosx/tkMacOSXDraw.c b/macosx/tkMacOSXDraw.c index 09a6b4e..5ca8bfe 100644 --- a/macosx/tkMacOSXDraw.c +++ b/macosx/tkMacOSXDraw.c @@ -1565,9 +1565,6 @@ TkScrollWindow( int oldMode = Tcl_SetServiceMode(TCL_SERVICE_NONE); [view generateExposeEvents:dmgRgn childrenOnly:1]; Tcl_SetServiceMode(oldMode); - - /* Belt and suspenders: make the AppKit request a redraw - when it gets control again. */ } } else { dmgRgn = HIShapeCreateEmpty(); -- cgit v0.12 From c558898981a43637a64c17a40fd816ae41991961 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Wed, 18 Jan 2017 12:44:22 +0000 Subject: Change more refCount checks to the form "(...refCount-- <= 1)", so no separate decrement and compare is necessary. This allows (in the future) the same code to work when refCount becomes unsigned (which at least doubles the range). No functional change. --- generic/tkImgPhInstance.c | 3 +-- generic/tkText.c | 12 ++++-------- generic/tkTextDisp.c | 9 ++++----- generic/tkTextIndex.c | 2 +- generic/tkTextTag.c | 5 ++--- generic/tkWindow.c | 3 +-- 6 files changed, 13 insertions(+), 21 deletions(-) diff --git a/generic/tkImgPhInstance.c b/generic/tkImgPhInstance.c index bd152f2..98aaeab 100644 --- a/generic/tkImgPhInstance.c +++ b/generic/tkImgPhInstance.c @@ -721,8 +721,7 @@ TkImgPhotoFree( PhotoInstance *instancePtr = clientData; ColorTable *colorPtr; - instancePtr->refCount -= 1; - if (instancePtr->refCount > 0) { + if (instancePtr->refCount-- > 1) { return; } diff --git a/generic/tkText.c b/generic/tkText.c index 412a7f2..6ff1db9 100644 --- a/generic/tkText.c +++ b/generic/tkText.c @@ -1570,8 +1570,7 @@ TextWidgetObjCmd( } done: - textPtr->refCount--; - if (textPtr->refCount == 0) { + if (textPtr->refCount-- <= 1) { ckfree(textPtr); } return result; @@ -1964,9 +1963,7 @@ DestroyText( * portion of the text widget. */ - sharedTextPtr->refCount--; - - if (sharedTextPtr->refCount > 0) { + if (sharedTextPtr->refCount-- > 1) { TkBTreeRemoveClient(sharedTextPtr->tree, textPtr); /* @@ -2042,13 +2039,12 @@ DestroyText( } textPtr->tkwin = NULL; - textPtr->refCount--; Tcl_DeleteCommandFromToken(textPtr->interp, textPtr->widgetCmd); if (textPtr->afterSyncCmd){ Tcl_DecrRefCount(textPtr->afterSyncCmd); textPtr->afterSyncCmd = NULL; } - if (textPtr->refCount == 0) { + if (textPtr->refCount-- <= 1) { ckfree(textPtr); } } @@ -5526,7 +5522,7 @@ RunAfterSyncCmd( * The widget has been deleted. Don't do anything. */ - if (--textPtr->refCount == 0) { + if (textPtr->refCount-- <= 1) { ckfree((char *) textPtr); } return; diff --git a/generic/tkTextDisp.c b/generic/tkTextDisp.c index 1be26c4..704d47d 100644 --- a/generic/tkTextDisp.c +++ b/generic/tkTextDisp.c @@ -3005,7 +3005,7 @@ AsyncUpdateLineMetrics( * The widget has been deleted, or is not mapped. Don't do anything. */ - if (--textPtr->refCount == 0) { + if (textPtr->refCount-- <= 1) { ckfree(textPtr); } return; @@ -3080,8 +3080,7 @@ AsyncUpdateLineMetrics( GenerateWidgetViewSyncEvent(textPtr, 1); - textPtr->refCount--; - if (textPtr->refCount == 0) { + if (textPtr->refCount-- <= 1) { ckfree(textPtr); } return; @@ -4163,7 +4162,7 @@ DisplayText( textPtr->refCount++; dInfoPtr->flags &= ~REPICK_NEEDED; TkTextPickCurrent(textPtr, &textPtr->pickEvent); - if (--textPtr->refCount == 0) { + if (textPtr->refCount-- <= 1) { ckfree(textPtr); goto end; } @@ -6752,7 +6751,7 @@ AsyncUpdateYScrollbar( GetYView(textPtr->interp, textPtr, 1); } - if (--textPtr->refCount == 0) { + if (textPtr->refCount-- <= 1) { ckfree(textPtr); } } diff --git a/generic/tkTextIndex.c b/generic/tkTextIndex.c index d227bd8..faa1afd 100644 --- a/generic/tkTextIndex.c +++ b/generic/tkTextIndex.c @@ -87,7 +87,7 @@ FreeTextIndexInternalRep( TkTextIndex *indexPtr = GET_TEXTINDEX(indexObjPtr); if (indexPtr->textPtr != NULL) { - if (--indexPtr->textPtr->refCount == 0) { + if (indexPtr->textPtr->refCount-- <= 1) { /* * The text widget has been deleted and we need to free it now. */ diff --git a/generic/tkTextTag.c b/generic/tkTextTag.c index dd3127d..d9329f5 100644 --- a/generic/tkTextTag.c +++ b/generic/tkTextTag.c @@ -1258,8 +1258,7 @@ TkTextFreeTag( if (textPtr != tagPtr->textPtr) { Tcl_Panic("Tag being deleted from wrong widget"); } - textPtr->refCount--; - if (textPtr->refCount == 0) { + if (textPtr->refCount-- <= 1) { ckfree(textPtr); } tagPtr->textPtr = NULL; @@ -1522,7 +1521,7 @@ TkTextBindProc( } done: - if (--textPtr->refCount == 0) { + if (textPtr->refCount-- <= 1) { ckfree(textPtr); } } diff --git a/generic/tkWindow.c b/generic/tkWindow.c index 5855b7c..20b4f20 100644 --- a/generic/tkWindow.c +++ b/generic/tkWindow.c @@ -1479,8 +1479,7 @@ Tk_DestroyWindow( winPtr->mainPtr->deletionEpoch++; } - winPtr->mainPtr->refCount--; - if (winPtr->mainPtr->refCount == 0) { + if (winPtr->mainPtr->refCount-- <= 1) { register const TkCmd *cmdPtr; /* -- cgit v0.12 From 5442c2a77a9c025b2245d42dbae20829f03be9bc Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Wed, 18 Jan 2017 12:45:33 +0000 Subject: Use the win32 Wide API in some more places. And some simplifications, since we no longer support win95/98/ME --- win/tkWinClipboard.c | 11 +---------- win/tkWinFont.c | 41 ++++++++++++++++------------------------- win/tkWinMenu.c | 46 ++++++++++++++++++++++------------------------ 3 files changed, 39 insertions(+), 59 deletions(-) diff --git a/win/tkWinClipboard.c b/win/tkWinClipboard.c index 200883f..929070b 100644 --- a/win/tkWinClipboard.c +++ b/win/tkWinClipboard.c @@ -414,16 +414,7 @@ UpdateClipboard( OpenClipboard(hwnd); EmptyClipboard(); - /* - * CF_UNICODETEXT is only supported on NT, but it it is prefered when - * possible. - */ - - if (TkWinGetPlatformId() != VER_PLATFORM_WIN32_WINDOWS) { - SetClipboardData(CF_UNICODETEXT, NULL); - } else { - SetClipboardData(CF_TEXT, NULL); - } + SetClipboardData(CF_UNICODETEXT, NULL); CloseClipboard(); TkWinUpdatingClipboard(FALSE); } diff --git a/win/tkWinFont.c b/win/tkWinFont.c index 860451b..ea8a7a2 100644 --- a/win/tkWinFont.c +++ b/win/tkWinFont.c @@ -262,16 +262,7 @@ void TkpFontPkgInit( TkMainInfo *mainPtr) /* The application being created. */ { - if (TkWinGetPlatformId() == VER_PLATFORM_WIN32_NT) { - /* - * If running NT, then we will be calling some Unicode functions - * explictly. So, even if the Tcl system encoding isn't Unicode, make - * sure we convert to/from the Unicode char set. - */ - - systemEncoding = TkWinGetUnicodeEncoding(); - } - + systemEncoding = TkWinGetUnicodeEncoding(); TkWinSetupSystemFonts(mainPtr); } @@ -760,14 +751,14 @@ TkpGetFontAttrsForChar( * character */ FontFamily *familyPtr = thisSubFontPtr->familyPtr; HFONT oldfont; /* Saved font from the device context */ - TEXTMETRICA tm; /* Font metrics of the selected subfont */ + TEXTMETRIC tm; /* Font metrics of the selected subfont */ /* * Get the font attributes. */ oldfont = SelectObject(hdc, thisSubFontPtr->hFont0); - GetTextMetricsA(hdc, &tm); + GetTextMetrics(hdc, &tm); SelectObject(hdc, oldfont); ReleaseDC(fontPtr->hwnd, hdc); faPtr->family = familyPtr->faceName; @@ -1118,7 +1109,7 @@ Tk_DrawChars( HBRUSH oldBrush, stipple; HBITMAP oldBitmap, bitmap; HDC dcMem; - TEXTMETRICA tm; + TEXTMETRIC tm; SIZE size; if (twdPtr->type != TWD_BITMAP) { @@ -1145,7 +1136,7 @@ Tk_DrawChars( */ GetTextExtentPointA(dcMem, source, numBytes, &size); - GetTextMetricsA(dcMem, &tm); + GetTextMetrics(dcMem, &tm); size.cx -= tm.tmOverhang; bitmap = CreateCompatibleBitmap(dc, size.cx, size.cy); oldBitmap = SelectObject(dcMem, bitmap); @@ -1184,7 +1175,7 @@ Tk_DrawChars( } else { HBITMAP oldBitmap, bitmap; HDC dcMem; - TEXTMETRICA tm; + TEXTMETRIC tm; SIZE size; dcMem = CreateCompatibleDC(dc); @@ -1199,7 +1190,7 @@ Tk_DrawChars( */ GetTextExtentPointA(dcMem, source, numBytes, &size); - GetTextMetricsA(dcMem, &tm); + GetTextMetrics(dcMem, &tm); size.cx -= tm.tmOverhang; bitmap = CreateCompatibleBitmap(dc, size.cx, size.cy); oldBitmap = SelectObject(dcMem, bitmap); @@ -1266,7 +1257,7 @@ TkDrawAngledChars( HBRUSH oldBrush, stipple; HBITMAP oldBitmap, bitmap; HDC dcMem; - TEXTMETRICA tm; + TEXTMETRIC tm; SIZE size; if (twdPtr->type != TWD_BITMAP) { @@ -1293,7 +1284,7 @@ TkDrawAngledChars( */ GetTextExtentPointA(dcMem, source, numBytes, &size); - GetTextMetricsA(dcMem, &tm); + GetTextMetrics(dcMem, &tm); size.cx -= tm.tmOverhang; bitmap = CreateCompatibleBitmap(dc, size.cx, size.cy); oldBitmap = SelectObject(dcMem, bitmap); @@ -1332,7 +1323,7 @@ TkDrawAngledChars( } else { HBITMAP oldBitmap, bitmap; HDC dcMem; - TEXTMETRICA tm; + TEXTMETRIC tm; SIZE size; dcMem = CreateCompatibleDC(dc); @@ -1347,7 +1338,7 @@ TkDrawAngledChars( */ GetTextExtentPointA(dcMem, source, numBytes, &size); - GetTextMetricsA(dcMem, &tm); + GetTextMetrics(dcMem, &tm); size.cx -= tm.tmOverhang; bitmap = CreateCompatibleBitmap(dc, size.cx, size.cy); oldBitmap = SelectObject(dcMem, bitmap); @@ -1454,11 +1445,11 @@ MultiFontTextOut( Tcl_DString runString; const char *p, *end, *next; SubFont *lastSubFontPtr, *thisSubFontPtr; - TEXTMETRICA tm; + TEXTMETRIC tm; lastSubFontPtr = &fontPtr->subFontArray[0]; oldFont = SelectFont(hdc, fontPtr, lastSubFontPtr, angle); - GetTextMetricsA(hdc, &tm); + GetTextMetrics(hdc, &tm); end = source + numBytes; for (p = source; p < end; ) { @@ -1482,7 +1473,7 @@ MultiFontTextOut( lastSubFontPtr = thisSubFontPtr; source = p; SelectFont(hdc, fontPtr, lastSubFontPtr, angle); - GetTextMetricsA(hdc, &tm); + GetTextMetrics(hdc, &tm); } p = next; } @@ -1560,7 +1551,7 @@ InitFont( HDC hdc; HWND hwnd; HFONT oldFont; - TEXTMETRICA tm; + TEXTMETRIC tm; Window window; TkFontMetrics *fmPtr; Tcl_Encoding encoding; @@ -1573,7 +1564,7 @@ InitFont( hdc = GetDC(hwnd); oldFont = SelectObject(hdc, hFont); - GetTextMetricsA(hdc, &tm); + GetTextMetrics(hdc, &tm); /* * On any version NT, there may fonts with international names. Use the diff --git a/win/tkWinMenu.c b/win/tkWinMenu.c index 8e14669..3cf7c10 100644 --- a/win/tkWinMenu.c +++ b/win/tkWinMenu.c @@ -900,7 +900,7 @@ TkWinMenuProc( LRESULT lResult; if (!TkWinHandleMenuEvent(&hwnd, &message, &wParam, &lParam, &lResult)) { - lResult = DefWindowProcA(hwnd, message, wParam, lParam); + lResult = DefWindowProc(hwnd, message, wParam, lParam); } return lResult; } @@ -999,7 +999,7 @@ TkWinEmbeddedMenuProc( } default: - lResult = DefWindowProcA(hwnd, message, wParam, lParam); + lResult = DefWindowProc(hwnd, message, wParam, lParam); break; } return lResult; @@ -2036,33 +2036,33 @@ TkWinMenuKeyObjCmd( if (eventPtr->type == KeyPress) { switch (keySym) { case XK_Alt_L: - scanCode = MapVirtualKeyA(VK_LMENU, 0); - CallWindowProcA(DefWindowProcA, Tk_GetHWND(Tk_WindowId(tkwin)), + scanCode = MapVirtualKey(VK_LMENU, 0); + CallWindowProc(DefWindowProc, Tk_GetHWND(Tk_WindowId(tkwin)), WM_SYSKEYDOWN, VK_MENU, (int) (scanCode << 16) | (1 << 29)); break; case XK_Alt_R: - scanCode = MapVirtualKeyA(VK_RMENU, 0); - CallWindowProcA(DefWindowProcA, Tk_GetHWND(Tk_WindowId(tkwin)), + scanCode = MapVirtualKey(VK_RMENU, 0); + CallWindowProc(DefWindowProc, Tk_GetHWND(Tk_WindowId(tkwin)), WM_SYSKEYDOWN, VK_MENU, (int) (scanCode << 16) | (1 << 29) | (1 << 24)); break; case XK_F10: - scanCode = MapVirtualKeyA(VK_F10, 0); - CallWindowProcA(DefWindowProcA, Tk_GetHWND(Tk_WindowId(tkwin)), + scanCode = MapVirtualKey(VK_F10, 0); + CallWindowProc(DefWindowProc, Tk_GetHWND(Tk_WindowId(tkwin)), WM_SYSKEYDOWN, VK_F10, (int) (scanCode << 16)); break; default: virtualKey = XKeysymToKeycode(winPtr->display, keySym); - scanCode = MapVirtualKeyA(virtualKey, 0); + scanCode = MapVirtualKey(virtualKey, 0); if (0 != scanCode) { XKeyEvent xkey = eventPtr->xkey; - CallWindowProcA(DefWindowProcA, Tk_GetHWND(Tk_WindowId(tkwin)), + CallWindowProc(DefWindowProc, Tk_GetHWND(Tk_WindowId(tkwin)), WM_SYSKEYDOWN, virtualKey, (int) ((scanCode << 16) | (1 << 29))); if (xkey.nbytes > 0) { for (i = 0; i < xkey.nbytes; i++) { - CallWindowProcA(DefWindowProcA, + CallWindowProc(DefWindowProc, Tk_GetHWND(Tk_WindowId(tkwin)), WM_SYSCHAR, xkey.trans_chars[i], (int) ((scanCode << 16) | (1 << 29))); @@ -2073,28 +2073,28 @@ TkWinMenuKeyObjCmd( } else if (eventPtr->type == KeyRelease) { switch (keySym) { case XK_Alt_L: - scanCode = MapVirtualKeyA(VK_LMENU, 0); - CallWindowProcA(DefWindowProcA, Tk_GetHWND(Tk_WindowId(tkwin)), + scanCode = MapVirtualKey(VK_LMENU, 0); + CallWindowProc(DefWindowProc, Tk_GetHWND(Tk_WindowId(tkwin)), WM_SYSKEYUP, VK_MENU, (int) (scanCode << 16) | (1 << 29) | (1 << 30) | (1 << 31)); break; case XK_Alt_R: - scanCode = MapVirtualKeyA(VK_RMENU, 0); - CallWindowProcA(DefWindowProcA, Tk_GetHWND(Tk_WindowId(tkwin)), + scanCode = MapVirtualKey(VK_RMENU, 0); + CallWindowProc(DefWindowProc, Tk_GetHWND(Tk_WindowId(tkwin)), WM_SYSKEYUP, VK_MENU, (int) (scanCode << 16) | (1 << 24) | (0x111 << 29) | (1 << 30) | (1 << 31)); break; case XK_F10: - scanCode = MapVirtualKeyA(VK_F10, 0); - CallWindowProcA(DefWindowProcA, Tk_GetHWND(Tk_WindowId(tkwin)), + scanCode = MapVirtualKey(VK_F10, 0); + CallWindowProc(DefWindowProc, Tk_GetHWND(Tk_WindowId(tkwin)), WM_SYSKEYUP, VK_F10, (int) (scanCode << 16) | (1 << 30) | (1 << 31)); break; default: virtualKey = XKeysymToKeycode(winPtr->display, keySym); - scanCode = MapVirtualKeyA(virtualKey, 0); + scanCode = MapVirtualKey(virtualKey, 0); if (0 != scanCode) { - CallWindowProcA(DefWindowProcA, Tk_GetHWND(Tk_WindowId(tkwin)), + CallWindowProc(DefWindowProc, Tk_GetHWND(Tk_WindowId(tkwin)), WM_SYSKEYUP, virtualKey, (int) ((scanCode << 16) | (1 << 29) | (1 << 30) | (1 << 31))); } @@ -3199,7 +3199,7 @@ SetDefaults( HDC scratchDC; int bold = 0; int italic = 0; - TEXTMETRICA tm; + TEXTMETRIC tm; int pointSize; HFONT menuFont; /* See: [Bug #3239768] tk8.4.19 (and later) WIN32 menu font support */ @@ -3239,7 +3239,7 @@ SetDefaults( &nc.metrics, 0); menuFont = CreateFontIndirect(&nc.metrics.lfMenuFont); SelectObject(scratchDC, menuFont); - GetTextMetricsA(scratchDC, &tm); + GetTextMetrics(scratchDC, &tm); GetTextFaceA(scratchDC, LF_FACESIZE, faceName); pointSize = MulDiv(tm.tmHeight - tm.tmInternalLeading, 72, GetDeviceCaps(scratchDC, LOGPIXELSY)); @@ -3295,9 +3295,7 @@ SetDefaults( */ showMenuAccelerators = TRUE; - if (TkWinGetPlatformId() == VER_PLATFORM_WIN32_NT) { - SystemParametersInfoA(SPI_GETKEYBOARDCUES, 0, &showMenuAccelerators, 0); - } + SystemParametersInfo(SPI_GETKEYBOARDCUES, 0, &showMenuAccelerators, 0); } /* -- cgit v0.12 From 0742c300b49248cdf4e360ac99c629081a106f79 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Fri, 20 Jan 2017 15:51:20 +0000 Subject: Typo in Dutch translation. Use copyright sign directly in *.msg files (and widget demo). --- library/demos/en.msg | 2 +- library/demos/nl.msg | 4 ++-- library/demos/widget | 8 ++++---- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/library/demos/en.msg b/library/demos/en.msg index d4783fe..05d4a64 100644 --- a/library/demos/en.msg +++ b/library/demos/en.msg @@ -18,7 +18,7 @@ ::msgcat::mcset en "Demo code: %s" ::msgcat::mcset en "About Widget Demo" ::msgcat::mcset en "Tk widget demonstration application" -::msgcat::mcset en "Copyright (c) %s" "Copyright \u00a9 %s" +::msgcat::mcset en "Copyright © %s" ::msgcat::mcset en " @@title Tk Widget Demonstrations diff --git a/library/demos/nl.msg b/library/demos/nl.msg index b17ceaa..cd52630 100644 --- a/library/demos/nl.msg +++ b/library/demos/nl.msg @@ -18,9 +18,9 @@ ::msgcat::mcset nl "Demo code: %s" "Code van Demo %s" ::msgcat::mcset nl "About Widget Demo" "Over deze demonstratie" ::msgcat::mcset nl "Tk widget demonstration" "Demonstratie van Tk widgets" -::msgcat::mcset nl "Copyright (c) %s" "Copyright (c) %s" +::msgcat::mcset nl "Copyright © %s" -::msgcat::mcset nl "Tk Widget Demonstrations" "Demostratie van Tk widgets" +::msgcat::mcset nl "Tk Widget Demonstrations" "Demonstratie van Tk widgets" ::msgcat::mcset nl "This application provides a front end for several short scripts" \ "Dit programma is een schil rond enkele korte scripts waarmee" ::msgcat::mcset nl "that demonstrate what you can do with Tk widgets. Each of the" \ diff --git a/library/demos/widget b/library/demos/widget index 162497e..052c160 100644 --- a/library/demos/widget +++ b/library/demos/widget @@ -723,10 +723,10 @@ proc PrintTextWin32 {filename} { proc tkAboutDialog {} { tk_messageBox -icon info -type ok -title [mc "About Widget Demo"] \ -message [mc "Tk widget demonstration application"] -detail \ -"[mc {Copyright (c) %s} {1996-1997 Sun Microsystems, Inc.}] -[mc {Copyright (c) %s} {1997-2000 Ajuba Solutions, Inc.}] -[mc {Copyright (c) %s} {2001-2007 Donal K. Fellows}] -[mc {Copyright (c) %s} {2002-2007 Daniel A. Steffen}]" +"[mc \"Copyright\ \u00a9\ %s\" {1996-1997 Sun Microsystems, Inc.}] +[mc \"Copyright\ \u00a9\ %s\" {1997-2000 Ajuba Solutions, Inc.}] +[mc \"Copyright\ \u00a9\ %s\" {2001-2007 Donal K. Fellows}] +[mc \"Copyright\ \u00a9\ %s\" {2002-2007 Daniel A. Steffen}]" } # Local Variables: -- cgit v0.12 From 3fb089ed701dcab661c4b34a2ea70bef7d5d9516 Mon Sep 17 00:00:00 2001 From: fvogel Date: Sat, 21 Jan 2017 13:06:08 +0000 Subject: Fix [ed22529c92]: Spinbox validation is turned off when validate function returns false --- doc/spinbox.n | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/doc/spinbox.n b/doc/spinbox.n index 330bb17..acf06d6 100644 --- a/doc/spinbox.n +++ b/doc/spinbox.n @@ -217,15 +217,19 @@ were editing the spinbox widget from). It is also recommended to not set an associated \fB\-textvariable\fR during validation, as that can cause the spinbox widget to become out of sync with the \fB\-textvariable\fR. .PP -Also, the \fBvalidate\fR option will set itself to \fBnone\fR when the -spinbox value gets changed because of adjustment of \fBfrom\fR or \fBto\fR -and the \fBvalidateCommand\fR returns false. For instance +Also, the \fB-validate\fR option will set itself to \fBnone\fR when the +spinbox value gets changed because of adjustment of \fB-from\fR or \fB-to\fR +and the \fB-validatecommand\fR returns false. For instance .CS \fIspinbox pathName \-from 1 \-to 10 \-validate all \-vcmd {return 0}\fR .CE -will in fact set the \fBvalidate\fR option to \fBnone\fR because the default -value for the spinbox gets changed (due to the \fBfrom\fR and \fBto\fR +will in fact set the \fB-validate\fR option to \fBnone\fR because the default +value for the spinbox gets changed (due to the \fB-from\fR and \fB-to\fR options) to a value not accepted by the validation script. +.PP +Moreover, forced validation is performed when invoking any spinbutton of +the spinbox. If the validation script returns false in this situation, +then the \fB-validate\fR option will be automatically set to \fBnone\fR. .SH "WIDGET COMMAND" .PP The \fBspinbox\fR command creates a new Tcl command whose -- cgit v0.12 From dabee7102b4e83ddd4784375631348c6b1ed0e11 Mon Sep 17 00:00:00 2001 From: fvogel Date: Sun, 22 Jan 2017 09:05:57 +0000 Subject: Fix [89a638af38]: OS X - textDisp-15.8 fails --- tests/textDisp.test | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tests/textDisp.test b/tests/textDisp.test index d3de2d8..8342c46 100644 --- a/tests/textDisp.test +++ b/tests/textDisp.test @@ -1952,13 +1952,15 @@ test textDisp-15.8 {Scrolling near end of window} { .tf.f.t insert end "\nLine $i" } update ; after 1000 ; update + set refind [.tf.f.t index @0,[winfo height .tf.f.t]] # Should scroll and should not crash! .tf.f.t yview scroll 1 unit # Check that it has scrolled - set res [.tf.f.t index @0,[expr [winfo height .tf.f.t] - 15]] + set newind [.tf.f.t index @0,[winfo height .tf.f.t]] + set res [.tf.f.t compare $newind > $refind] destroy .tf set res -} {12.0} +} {1} .t configure -wrap char .t delete 1.0 end -- cgit v0.12 From ebb2c5a3dbf48abcc99a56379e0924f43c594285 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Mon, 23 Jan 2017 09:45:18 +0000 Subject: Remove superfloeus double-quite in widget's "about" dialog. --- library/demos/widget | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/library/demos/widget b/library/demos/widget index 052c160..88d55c6 100644 --- a/library/demos/widget +++ b/library/demos/widget @@ -723,10 +723,10 @@ proc PrintTextWin32 {filename} { proc tkAboutDialog {} { tk_messageBox -icon info -type ok -title [mc "About Widget Demo"] \ -message [mc "Tk widget demonstration application"] -detail \ -"[mc \"Copyright\ \u00a9\ %s\" {1996-1997 Sun Microsystems, Inc.}] -[mc \"Copyright\ \u00a9\ %s\" {1997-2000 Ajuba Solutions, Inc.}] -[mc \"Copyright\ \u00a9\ %s\" {2001-2007 Donal K. Fellows}] -[mc \"Copyright\ \u00a9\ %s\" {2002-2007 Daniel A. Steffen}]" +"[mc "Copyright \u00a9 %s" {1996-1997 Sun Microsystems, Inc.}] +[mc "Copyright \u00a9 %s" {1997-2000 Ajuba Solutions, Inc.}] +[mc "Copyright \u00a9 %s" {2001-2007 Donal K. Fellows}] +[mc "Copyright \u00a9 %s" {2002-2007 Daniel A. Steffen}]" } # Local Variables: -- cgit v0.12 From 66e41a71e3b7254f83641c7a1d512bfa94c45d40 Mon Sep 17 00:00:00 2001 From: pspjuth Date: Wed, 25 Jan 2017 22:05:51 +0000 Subject: Fix [140ea8ab38]: Long text lines are not drawn on Windows. --- win/tkWinFont.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/win/tkWinFont.c b/win/tkWinFont.c index f209716..1292772 100644 --- a/win/tkWinFont.c +++ b/win/tkWinFont.c @@ -1307,7 +1307,15 @@ MultiFontTextOut( for (p = source; p < end; ) { next = p + Tcl_UtfToUniChar(p, &ch); thisSubFontPtr = FindSubFontForChar(fontPtr, ch, &lastSubFontPtr); - if (thisSubFontPtr != lastSubFontPtr) { + + /* + * The drawing API has a limit of 32767 pixels in one go. + * To avoid spending time on a rare case we do not measure each char, + * instead we limit to drawing chunks of 200 bytes since that works + * well in practice. + */ + + if ((thisSubFontPtr != lastSubFontPtr) || (p-source > 200)) { if (p > source) { familyPtr = lastSubFontPtr->familyPtr; Tcl_UtfToExternalDString(familyPtr->encoding, source, -- cgit v0.12