From 27a040ee30d124a3a52982919209e14905fd1f5b Mon Sep 17 00:00:00 2001 From: dkf Date: Thu, 8 Nov 2012 13:28:49 +0000 Subject: Changes from Simon Geard to act as baseline implementation of TIP #415. --- doc/canvas.n | 29 ++++++++++++-- generic/tkCanvArc.c | 107 +++++++++++++++++++++++++++++++++++++++++++++++----- tests/canvas.test | 6 ++- 3 files changed, 127 insertions(+), 15 deletions(-) diff --git a/doc/canvas.n b/doc/canvas.n index 9eb0ec0..e334e68 100644 --- a/doc/canvas.n +++ b/doc/canvas.n @@ -1314,8 +1314,8 @@ arc's region. .PP Items of type \fBarc\fR appear on the display as arc-shaped regions. An arc is a section of an oval delimited by two angles (specified -by the \fB\-start\fR and \fB\-extent\fR options) and displayed in -one of several ways (specified by the \fB\-style\fR option). +by either the \fB\-start\fR and \fB\-extent\fR options or the \fB\-height\fR option) +and displayed in one of several ways (specified by the \fB\-style\fR option). Arcs are created with widget commands of the following form: .CS \fIpathName \fBcreate arc \fIx1 y1 x2 y2 \fR?\fIoption value ...\fR? @@ -1323,7 +1323,9 @@ Arcs are created with widget commands of the following form: .CE The arguments \fIx1\fR, \fIy1\fR, \fIx2\fR, and \fIy2\fR or \fIcoordList\fR give the coordinates of two diagonally opposite corners of a -rectangular region enclosing the oval that defines the arc. +rectangular region enclosing the oval that defines the arc (except when +\fB\-height\fR is specified - see below). +. After the coordinates there may be any number of \fIoption\fR\-\fIvalue\fR pairs, each of which sets one of the configuration options for the item. These same \fIoption\fR\-\fIvalue\fR pairs may be @@ -1364,6 +1366,27 @@ arc. \fIDegrees\fR is given in units of degrees measured counter-clockwise from the 3-o'clock position; it may be either positive or negative. .TP +\fB\-height \fIdistance\fR +Provides a shortcut for creating a circular arc segment by defining the +distance of the mid-point of the arc from its chord. When this option +is used the coordinates are interpreted as the start and end coordinates +of the chord, and the options \fB\-start\fR and \fB-extent\fR are ignored. +The value of \fIdistance\fR has the following meaning: +.CS + +\fIdistance\fR > 0 creates a clockwise arc +\fIdistance\fR < 0 creates an counter-clockwise arc +\fIdistance\fR = 0 creates an arc as if this option had not been specified + +If you want the arc to have a specific radius, r, use the formula + +\fIdistance\fR = r +- sqrt(r**2 - (chordLength/2)**2) + +choosing the minus sign for the minor arc and the plus sign for the major arc. + +Note that \fBitemcget -height\fR always returns 0 so that introspection code can be kept simple. +.CE +.TP \fB\-style \fItype\fR Specifies how to draw the arc. If \fItype\fR is \fBpieslice\fR (the default) then the arc's region is defined by a section diff --git a/generic/tkCanvArc.c b/generic/tkCanvArc.c index 4e4c582..dfa0671 100644 --- a/generic/tkCanvArc.c +++ b/generic/tkCanvArc.c @@ -62,6 +62,10 @@ typedef struct ArcItem { * start (see ComputeArcOutline). */ double center2[2]; /* Coordinates of center of arc outline at * start+extent (see ComputeArcOutline). */ + + double height; /* Distance from the arc's chord to its mid-point */ + double startPoint[2]; /* Start point of arc used when specifying height */ + double endPoint[2]; /* End point of arc used when specifying height */ } ArcItem; /* @@ -140,6 +144,8 @@ static const Tk_ConfigSpec configSpecs[] = { "90", Tk_Offset(ArcItem, extent), TK_CONFIG_DONT_SET_DEFAULT, NULL}, {TK_CONFIG_COLOR, "-fill", NULL, NULL, NULL, Tk_Offset(ArcItem, fillColor), TK_CONFIG_NULL_OK, NULL}, + {TK_CONFIG_DOUBLE, "-height", NULL, NULL, + 0, Tk_Offset(ArcItem, height), TK_CONFIG_DONT_SET_DEFAULT, NULL}, {TK_CONFIG_CUSTOM, "-offset", NULL, NULL, "0,0", Tk_Offset(ArcItem, tsoffset), TK_CONFIG_DONT_SET_DEFAULT, &offsetOption}, @@ -175,6 +181,7 @@ static void ComputeArcBbox(Tk_Canvas canvas, ArcItem *arcPtr); static int ConfigureArc(Tcl_Interp *interp, Tk_Canvas canvas, Tk_Item *itemPtr, int objc, Tcl_Obj *const objv[], int flags); +static void ComputeArcFromHeight(ArcItem *arcPtr); static int CreateArc(Tcl_Interp *interp, Tk_Canvas canvas, struct Tk_Item *itemPtr, int objc, Tcl_Obj *const objv[]); @@ -291,7 +298,9 @@ CreateArc( arcPtr->disabledFillStipple = None; arcPtr->style = PIESLICE_STYLE; arcPtr->fillGC = None; + arcPtr->height = 0; + /* * Process the arguments to fill in the item record. */ @@ -374,6 +383,16 @@ ArcCoords( &arcPtr->bbox[3]) != TCL_OK)) { return TCL_ERROR; } + + /* + * Store bbox as start and end points so they can be used + * if either radius or height is specified. + */ + arcPtr->startPoint[0] = arcPtr->bbox[0]; + arcPtr->startPoint[1] = arcPtr->bbox[1]; + arcPtr->endPoint[0] = arcPtr->bbox[2]; + arcPtr->endPoint[1] = arcPtr->bbox[3]; + ComputeArcBbox(canvas, arcPtr); } else { Tcl_SetObjResult(interp, Tcl_ObjPrintf( @@ -447,6 +466,23 @@ ConfigureArc( itemPtr->redraw_flags &= ~TK_ITEM_STATE_DEPENDANT; } + /* + * If either the height is provided then the start and extent will be + * overridden. + */ + if (arcPtr->height != 0) { + ComputeArcFromHeight(arcPtr); + ComputeArcBbox(canvas, arcPtr); + } + + i = (int) (arcPtr->start/360.0); + arcPtr->start -= i*360.0; + if (arcPtr->start < 0) { + arcPtr->start += 360.0; + } + i = (int) (arcPtr->extent/360.0); + arcPtr->extent -= i*360.0; + tsoffset = &arcPtr->outline.tsoffset; flags = tsoffset->flags; if (flags & TK_OFFSET_LEFT) { @@ -463,15 +499,7 @@ ConfigureArc( } else if (flags & TK_OFFSET_BOTTOM) { tsoffset->yoffset = (int) (arcPtr->bbox[2] + 0.5); } - - i = (int) (arcPtr->start/360.0); - arcPtr->start -= i*360.0; - if (arcPtr->start < 0) { - arcPtr->start += 360.0; - } - i = (int) (arcPtr->extent/360.0); - arcPtr->extent -= i*360.0; - + mask = Tk_ConfigOutlineGC(&gcValues, canvas, itemPtr, &(arcPtr->outline)); if (mask) { gcValues.cap_style = CapButt; @@ -509,7 +537,7 @@ ConfigureArc( if (arcPtr->disabledFillStipple!=None) { stipple = arcPtr->disabledFillStipple; } - } + } if (arcPtr->style == ARC_STYLE) { newGC = None; @@ -559,6 +587,65 @@ ConfigureArc( /* *-------------------------------------------------------------- * + * ComputeArcFromHeight -- + * + * This function calculates the arc parameters given + * start-point, end-point and height (!= 0). + * + * Results: + * None. + * + * Side effects: + * The height parameter is set to 0 on exit. + * + *-------------------------------------------------------------- + */ + +static void +ComputeArcFromHeight( + ArcItem* arcPtr) +{ + double chordLen, chordDir[2], chordCen[2], arcCen[2], d, radToDeg, radius; + + /* The chord */ + chordLen = hypot(arcPtr->endPoint[1]-arcPtr->startPoint[1], arcPtr->startPoint[0]-arcPtr->endPoint[0]); + chordDir[0] = (arcPtr->endPoint[0]-arcPtr->startPoint[0])/chordLen; + chordDir[1] = (arcPtr->endPoint[1]-arcPtr->startPoint[1])/chordLen; + chordCen[0] = (arcPtr->startPoint[0]+arcPtr->endPoint[0])/2; + chordCen[1] = (arcPtr->startPoint[1]+arcPtr->endPoint[1])/2; + + /* Calculate the radius (assumes height != 0) */ + radius = (4*pow(arcPtr->height,2) + pow(chordLen,2))/(8*arcPtr->height); + + /* The arc centre */ + d = radius - arcPtr->height; + arcCen[0] = chordCen[0] - d*chordDir[1]; + arcCen[1] = chordCen[1] + d*chordDir[0]; + + /* The arc start and span. Angles are negated because the coordinate system is left-handed */ + radToDeg = 45/atan(1); + arcPtr->start = atan2(arcCen[1]-arcPtr->startPoint[1],arcPtr->startPoint[0]-arcCen[0])*radToDeg; + arcPtr->extent = -2*asin(chordLen/(2*radius))*radToDeg; + + /* Handle spans > 180 */ + if (fabs(2*arcPtr->height) > chordLen) { + arcPtr->extent = arcPtr->extent > 0 ? (360 - arcPtr->extent) : -(360+arcPtr->extent); + } + + /* Create the bounding box */ + arcPtr->bbox[0] = arcCen[0]-radius; + arcPtr->bbox[1] = arcCen[1]-radius; + arcPtr->bbox[2] = arcCen[0]+radius; + arcPtr->bbox[3] = arcCen[1]+radius; + + /* Set the height to 0 so that itemcget -height returns 0 */ + arcPtr->height = 0; + +} + +/* + *-------------------------------------------------------------- + * * DeleteArc -- * * This function is called to clean up the data structure associated with diff --git a/tests/canvas.test b/tests/canvas.test index 2b0da48..5b6c0e4 100644 --- a/tests/canvas.test +++ b/tests/canvas.test @@ -340,8 +340,10 @@ test canvas-8.1 {canvas arc bbox} -setup { set coordBox [.c bbox arc2] .c create arc 300 10 500 210 -start 10 -extent 50 -style pieslice -tags arc3 set pieBox [.c bbox arc3] - list $arcBox $coordBox $pieBox -} -result {{48 21 100 94} {248 21 300 94} {398 21 500 112}} + .c create arc 100 200 300 200 -height [expr {(1-0.5*sqrt(3))*200}] -style arc -tags arc4 + set arcSegBox [.c bbox arc4] + list $arcBox $coordBox $pieBox $arcSegBox +} -result {{48 21 100 94} {248 21 300 94} {398 21 500 112} {98 171 302 202}} test canvas-9.1 {canvas id creation and deletion} -setup { catch {destroy .c} -- cgit v0.12 From 8e057979ccfa4ba776bb204f8454c074015fd108 Mon Sep 17 00:00:00 2001 From: fvogel Date: Wed, 21 Sep 2016 06:32:55 +0000 Subject: (Modernized) patch from egavilan to fix [2863003fff] and [d6b95ce492] - tk frame does not shrink to 0 height if last children unpacked. A virtual event is sent when the pack or grid geometry manager leaves a parent without any slaves --- generic/tkGrid.c | 8 +++++--- generic/tkPack.c | 6 +++++- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/generic/tkGrid.c b/generic/tkGrid.c index 2a88b76..a4b4125 100644 --- a/generic/tkGrid.c +++ b/generic/tkGrid.c @@ -1733,12 +1733,14 @@ ArrangeGrid( /* * If the master has no slaves anymore, then don't do anything at all: - * just leave the master's size as-is. Otherwise there is no way to - * "relinquish" control over the master so another geometry manager can - * take over. + * just leave the master's size as-is, but signal the master with the + * <> virtual event. + * Otherwise there is no way to "relinquish" control over the master + * so another geometry manager can take over. */ if (masterPtr->slavePtr == NULL) { + TkSendVirtualEvent(masterPtr->tkwin, "GeometryManager", NULL); return; } diff --git a/generic/tkPack.c b/generic/tkPack.c index 88a4b2d..d46d64c 100644 --- a/generic/tkPack.c +++ b/generic/tkPack.c @@ -600,10 +600,14 @@ ArrangePacking( /* * If the master has no slaves anymore, then don't do anything at all: - * just leave the master's size as-is. + * just leave the master's size as-is, but signal the master with the + * <> virtual event. + * Otherwise there is no way to "relinquish" control over the master + * so another geometry manager can take over. */ if (masterPtr->slavePtr == NULL) { + TkSendVirtualEvent(masterPtr->tkwin, "GeometryManager", NULL); return; } -- cgit v0.12 From 8b8dbcbbe2e4f29804db7248549b4df355ff5b6a Mon Sep 17 00:00:00 2001 From: culler Date: Wed, 15 Aug 2018 19:17:20 +0000 Subject: Fix bug [b947864419]: Also account for changes to the clipboard made by other apps --- macosx/tkMacOSXClipboard.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/macosx/tkMacOSXClipboard.c b/macosx/tkMacOSXClipboard.c index 07a8419..01e36ef 100644 --- a/macosx/tkMacOSXClipboard.c +++ b/macosx/tkMacOSXClipboard.c @@ -67,13 +67,11 @@ static Tk_Window clipboardOwner = NULL; - (void) tkCheckPasteboard { - if (clipboardOwner && [[NSPasteboard generalPasteboard] changeCount] != - changeCount) { + if ([[NSPasteboard generalPasteboard] changeCount] != changeCount) { TkDisplay *dispPtr = TkGetDisplayList(); - if (dispPtr) { + if (dispPtr && clipboardOwner) { XEvent event; - event.xany.type = SelectionClear; event.xany.serial = NextRequest(Tk_Display(clipboardOwner)); event.xany.send_event = False; @@ -125,8 +123,10 @@ TkSelGetSelection( int result = TCL_ERROR; TkDisplay *dispPtr = ((TkWindow *) tkwin)->dispPtr; - if (dispPtr && selection == dispPtr->clipboardAtom && (target == XA_STRING - || target == dispPtr->utf8Atom)) { + int haveExternalClip = ([[NSPasteboard generalPasteboard] changeCount] != changeCount); + if (dispPtr && (haveExternalClip || dispPtr->clipboardActive) + && selection == dispPtr->clipboardAtom + && (target == XA_STRING || target == dispPtr->utf8Atom)) { NSString *string = nil; NSPasteboard *pb = [NSPasteboard generalPasteboard]; NSString *type = [pb availableTypeFromArray:[NSArray arrayWithObject: @@ -176,7 +176,6 @@ XSetSelectionOwner( clipboardOwner = owner ? Tk_IdToWindow(display, owner) : NULL; if (!dispPtr->clipboardActive) { NSPasteboard *pb = [NSPasteboard generalPasteboard]; - changeCount = [pb declareTypes:[NSArray array] owner:NSApp]; } } -- cgit v0.12 From 35d97ae85b24bae1ad81598a36d0fd3721e196a8 Mon Sep 17 00:00:00 2001 From: culler Date: Wed, 15 Aug 2018 19:51:12 +0000 Subject: Reverted a pointless change in tkCheckPasteboard. --- macosx/tkMacOSXClipboard.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/macosx/tkMacOSXClipboard.c b/macosx/tkMacOSXClipboard.c index 01e36ef..809cb1b 100644 --- a/macosx/tkMacOSXClipboard.c +++ b/macosx/tkMacOSXClipboard.c @@ -67,10 +67,11 @@ static Tk_Window clipboardOwner = NULL; - (void) tkCheckPasteboard { - if ([[NSPasteboard generalPasteboard] changeCount] != changeCount) { + if (clipboardOwner && [[NSPasteboard generalPasteboard] changeCount] != + changeCount) { TkDisplay *dispPtr = TkGetDisplayList(); - if (dispPtr && clipboardOwner) { + if (dispPtr) { XEvent event; event.xany.type = SelectionClear; event.xany.serial = NextRequest(Tk_Display(clipboardOwner)); -- cgit v0.12 From db9a5834c283e4cb27033aefd0c4475a47381a96 Mon Sep 17 00:00:00 2001 From: culler Date: Sun, 19 Aug 2018 20:50:47 +0000 Subject: Removed the call to TkSuspendClipboard when the app is deactivated. --- macosx/tkMacOSXClipboard.c | 3 +-- macosx/tkMacOSXWindowEvent.c | 1 - 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/macosx/tkMacOSXClipboard.c b/macosx/tkMacOSXClipboard.c index 809cb1b..4bd39ae 100644 --- a/macosx/tkMacOSXClipboard.c +++ b/macosx/tkMacOSXClipboard.c @@ -70,7 +70,6 @@ static Tk_Window clipboardOwner = NULL; if (clipboardOwner && [[NSPasteboard generalPasteboard] changeCount] != changeCount) { TkDisplay *dispPtr = TkGetDisplayList(); - if (dispPtr) { XEvent event; event.xany.type = SelectionClear; @@ -300,7 +299,7 @@ TkSelPropProc( * None. * * Side effects: - * The local scrap is moved to the global scrap. + * The value of changeCount is synchronized. * *---------------------------------------------------------------------- */ diff --git a/macosx/tkMacOSXWindowEvent.c b/macosx/tkMacOSXWindowEvent.c index bbfe5b7..2596776 100644 --- a/macosx/tkMacOSXWindowEvent.c +++ b/macosx/tkMacOSXWindowEvent.c @@ -256,7 +256,6 @@ extern NSString *NSWindowDidOrderOffScreenNotification; #ifdef TK_MAC_DEBUG_NOTIFICATIONS TKLog(@"-[%@(%p) %s] %@", [self class], self, _cmd, notification); #endif - TkSuspendClipboard(); } - (void) applicationShowHide: (NSNotification *) notification -- cgit v0.12 From c2935b47f69334f3fba794a401ba3fb591d6f5eb Mon Sep 17 00:00:00 2001 From: fvogel Date: Sun, 9 Sep 2018 16:04:21 +0000 Subject: Fix [719ae3991b]: ttk scrollbar-1.[23] tests fail (regression) --- macosx/tkMacOSXScrlbr.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/macosx/tkMacOSXScrlbr.c b/macosx/tkMacOSXScrlbr.c index a8018a5..cb57a9b 100644 --- a/macosx/tkMacOSXScrlbr.c +++ b/macosx/tkMacOSXScrlbr.c @@ -282,11 +282,12 @@ TkpComputeScrollbarGeometry( Tk_GeometryRequest(scrollPtr->tkwin, scrollPtr->width + 2*scrollPtr->inset, 2*(scrollPtr->arrowLength + scrollPtr->borderWidth - + scrollPtr->inset)); + + scrollPtr->inset) + metrics.minThumbHeight); } else { Tk_GeometryRequest(scrollPtr->tkwin, 2*(scrollPtr->arrowLength + scrollPtr->borderWidth - + scrollPtr->inset), scrollPtr->width + 2*scrollPtr->inset); + + scrollPtr->inset) + metrics.minThumbHeight, + scrollPtr->width + 2*scrollPtr->inset); } Tk_SetInternalBorder(scrollPtr->tkwin, scrollPtr->inset); } -- cgit v0.12 From 33fbb40b45f7662f1c959f330873d33faaf77105 Mon Sep 17 00:00:00 2001 From: oehhar Date: Sat, 22 Sep 2018 19:10:12 +0000 Subject: Update to implement TIP518 event name change --- generic/tkGrid.c | 8 ++++---- generic/tkPack.c | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/generic/tkGrid.c b/generic/tkGrid.c index a4b4125..3f685af 100644 --- a/generic/tkGrid.c +++ b/generic/tkGrid.c @@ -1732,15 +1732,15 @@ ArrangeGrid( masterPtr->flags &= ~REQUESTED_RELAYOUT; /* - * If the master has no slaves anymore, then don't do anything at all: - * just leave the master's size as-is, but signal the master with the - * <> virtual event. + * If the master has no slaves anymore, then don't change the master size. * Otherwise there is no way to "relinquish" control over the master * so another geometry manager can take over. + * Send event to "NoManagedChilds" to inform about no managed grid but + * not resized. */ if (masterPtr->slavePtr == NULL) { - TkSendVirtualEvent(masterPtr->tkwin, "GeometryManager", NULL); + TkSendVirtualEvent(masterPtr->tkwin, "NoManagedChilds", NULL); return; } diff --git a/generic/tkPack.c b/generic/tkPack.c index d46d64c..3bc9103 100644 --- a/generic/tkPack.c +++ b/generic/tkPack.c @@ -599,15 +599,15 @@ ArrangePacking( masterPtr->flags &= ~REQUESTED_REPACK; /* - * If the master has no slaves anymore, then don't do anything at all: - * just leave the master's size as-is, but signal the master with the - * <> virtual event. + * If the master has no slaves anymore, then leave the master's size as-is. * Otherwise there is no way to "relinquish" control over the master * so another geometry manager can take over. + * Send event to "NoManagedChilds" to inform about no managed grid but + * not resized. */ if (masterPtr->slavePtr == NULL) { - TkSendVirtualEvent(masterPtr->tkwin, "GeometryManager", NULL); + TkSendVirtualEvent(masterPtr->tkwin, "NoManagedChilds", NULL); return; } -- cgit v0.12 From dbae6fd8e676c40daac803ac99de1368c9d229a8 Mon Sep 17 00:00:00 2001 From: oehhar Date: Sat, 22 Sep 2018 20:31:07 +0000 Subject: Use the event name of the TIP: NoManagedChild --- generic/tkGrid.c | 4 ++-- generic/tkPack.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/generic/tkGrid.c b/generic/tkGrid.c index 3f685af..6c0f5b1 100644 --- a/generic/tkGrid.c +++ b/generic/tkGrid.c @@ -1735,12 +1735,12 @@ ArrangeGrid( * If the master has no slaves anymore, then don't change the master size. * Otherwise there is no way to "relinquish" control over the master * so another geometry manager can take over. - * Send event to "NoManagedChilds" to inform about no managed grid but + * Send event to "NoManagedChild" to inform about no managed grid but * not resized. */ if (masterPtr->slavePtr == NULL) { - TkSendVirtualEvent(masterPtr->tkwin, "NoManagedChilds", NULL); + TkSendVirtualEvent(masterPtr->tkwin, "NoManagedChild", NULL); return; } diff --git a/generic/tkPack.c b/generic/tkPack.c index 3bc9103..7f165d1 100644 --- a/generic/tkPack.c +++ b/generic/tkPack.c @@ -602,12 +602,12 @@ ArrangePacking( * If the master has no slaves anymore, then leave the master's size as-is. * Otherwise there is no way to "relinquish" control over the master * so another geometry manager can take over. - * Send event to "NoManagedChilds" to inform about no managed grid but + * Send event to "NoManagedChild" to inform about no managed grid but * not resized. */ if (masterPtr->slavePtr == NULL) { - TkSendVirtualEvent(masterPtr->tkwin, "NoManagedChilds", NULL); + TkSendVirtualEvent(masterPtr->tkwin, "NoManagedChild", NULL); return; } -- cgit v0.12 From 18d837b6fa55ac5268e747b828ce4e3fa78a51ea Mon Sep 17 00:00:00 2001 From: fvogel Date: Sun, 23 Sep 2018 19:57:19 +0000 Subject: Fix [874dca4873]: scrollbar-10.[12] fail on macOS --- tests/scrollbar.test | 32 ++++++++++++++++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) diff --git a/tests/scrollbar.test b/tests/scrollbar.test index bd14067..910c4ea 100644 --- a/tests/scrollbar.test +++ b/tests/scrollbar.test @@ -632,7 +632,7 @@ test scrollbar-9.1 {scrollbar widget vs hidden commands} { list [winfo children .] [interp hidden] } [list {} $l] -test scrollbar-10.1 { event on scrollbar} -constraints {win|unix} -setup { +test scrollbar-10.1.1 { event on scrollbar} -constraints {notAqua} -setup { destroy .t .s } -body { pack [text .t -yscrollcommand {.s set}] -side left @@ -646,8 +646,22 @@ test scrollbar-10.1 { event on scrollbar} -constraints {win|unix} -s } -cleanup { destroy .t .s } -result {5.0} +test scrollbar-10.1.2 { event on scrollbar} -constraints {aqua} -setup { + destroy .t .s +} -body { + pack [text .t -yscrollcommand {.s set}] -side left + for {set i 1} {$i < 100} {incr i} {.t insert end "Line $i\n"} + pack [scrollbar .s -command {.t yview}] -fill y -expand 1 -side left + update + focus -force .s + event generate .s -delta -1 + after 200 {set eventprocessed 1} ; vwait eventprocessed + .t index @0,0 +} -cleanup { + destroy .t .s +} -result {5.0} -test scrollbar-10.2 { event on scrollbar} -constraints {win|unix} -setup { +test scrollbar-10.2.1 { event on scrollbar} -constraints {notAqua} -setup { destroy .t .s } -body { pack [text .t -xscrollcommand {.s set} -wrap none] -side top @@ -661,6 +675,20 @@ test scrollbar-10.2 { event on scrollbar} -constraints {win|unix} -s } -cleanup { destroy .t .s } -result {1.4} +test scrollbar-10.2.2 { event on scrollbar} -constraints {aqua} -setup { + destroy .t .s +} -body { + pack [text .t -xscrollcommand {.s set} -wrap none] -side top + for {set i 1} {$i < 100} {incr i} {.t insert end "Char $i "} + pack [scrollbar .s -command {.t xview} -orient horizontal] -fill x -expand 1 -side top + update + focus -force .s + event generate .s -delta -1 + after 200 {set eventprocessed 1} ; vwait eventprocessed + .t index @0,0 +} -cleanup { + destroy .t .s +} -result {1.4} test scrollbar-11.1 {bug fix: [011706ec42] Scrollbar unsafe wrt widget destruction} -body { proc destroy_scrollbar {} { -- cgit v0.12 From 92f92ea4339a5946f1fd60897bed4d43ddfe68dc Mon Sep 17 00:00:00 2001 From: fvogel Date: Sun, 23 Sep 2018 20:05:19 +0000 Subject: Ooops, the delta needs to be -4, not -1, in order to scroll down/right four lines/chars. --- tests/scrollbar.test | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/scrollbar.test b/tests/scrollbar.test index 910c4ea..e4fdc0e 100644 --- a/tests/scrollbar.test +++ b/tests/scrollbar.test @@ -654,7 +654,7 @@ test scrollbar-10.1.2 { event on scrollbar} -constraints {aqua} -set pack [scrollbar .s -command {.t yview}] -fill y -expand 1 -side left update focus -force .s - event generate .s -delta -1 + event generate .s -delta -4 after 200 {set eventprocessed 1} ; vwait eventprocessed .t index @0,0 } -cleanup { @@ -683,7 +683,7 @@ test scrollbar-10.2.2 { event on scrollbar} -constraints {aqua} -set pack [scrollbar .s -command {.t xview} -orient horizontal] -fill x -expand 1 -side top update focus -force .s - event generate .s -delta -1 + event generate .s -delta -4 after 200 {set eventprocessed 1} ; vwait eventprocessed .t index @0,0 } -cleanup { -- cgit v0.12 -- cgit v0.12 From 0ce97290a9b89ab6698de34194b7a4dfc64255ee Mon Sep 17 00:00:00 2001 From: fvogel Date: Mon, 24 Sep 2018 19:59:29 +0000 Subject: Fix [050d1ea747]: scrollbar-3.50, 6.11, 6.12, 6.25, 6.39 tests fail on macOS --- macosx/tkMacOSXScrlbr.c | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/macosx/tkMacOSXScrlbr.c b/macosx/tkMacOSXScrlbr.c index a8018a5..1bfbe11 100644 --- a/macosx/tkMacOSXScrlbr.c +++ b/macosx/tkMacOSXScrlbr.c @@ -381,25 +381,20 @@ TkpScrollbarPosition( * has to do is re-draw itself. */ - int length, fieldlength, width, tmp; + int length, width, tmp; register const int inset = scrollPtr->inset; - register const int arrowSize = scrollPtr->arrowLength + inset; if (scrollPtr->vertical) { length = Tk_Height(scrollPtr->tkwin); - fieldlength = length - 2 * arrowSize; width = Tk_Width(scrollPtr->tkwin); } else { tmp = x; x = y; y = tmp; length = Tk_Width(scrollPtr->tkwin); - fieldlength = length - 2 * arrowSize; width = Tk_Height(scrollPtr->tkwin); } - fieldlength = fieldlength < 0 ? 0 : fieldlength; - if (x=width-inset || y=length-inset) { return OUTSIDE; } @@ -409,19 +404,19 @@ TkpScrollbarPosition( * TkpDisplayScrollbar. Be sure to keep the two consistent. */ + if (y < inset + scrollPtr->arrowLength) { + return TOP_ARROW; + } if (y < scrollPtr->sliderFirst) { return TOP_GAP; } - if (y < scrollPtr->sliderLast) { + if (y < scrollPtr->sliderLast){ return SLIDER; } - if (y < fieldlength){ - return BOTTOM_GAP; - } - if (y < fieldlength + arrowSize) { - return TOP_ARROW; + if (y >= length - (scrollPtr->arrowLength + inset)) { + return BOTTOM_ARROW; } - return BOTTOM_ARROW; + return BOTTOM_GAP; } -- cgit v0.12 From f63bb1144e5843b991583fa4768e4c6eb67f51d4 Mon Sep 17 00:00:00 2001 From: fvogel Date: Tue, 25 Sep 2018 19:13:43 +0000 Subject: Fix [f792b457eb]: scrollbar-3.26, 3.27, 3.28, 3.35 tests fail on macOS. The fix consists in using the Linux code for the testmetrics command on macOS, instead of returning the width of the scrollbar (for both cxvscroll and cyvscroll requests). --- generic/tkTest.c | 33 +++++---------------------------- tests/scrollbar.test | 2 +- 2 files changed, 6 insertions(+), 29 deletions(-) diff --git a/generic/tkTest.c b/generic/tkTest.c index 1fa461e..2dbd877 100644 --- a/generic/tkTest.c +++ b/generic/tkTest.c @@ -168,7 +168,7 @@ static int TestmenubarObjCmd(ClientData dummy, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]); #endif -#if defined(_WIN32) || defined(MAC_OSX_TK) +#if defined(_WIN32) static int TestmetricsObjCmd(ClientData dummy, Tcl_Interp *interp, int objc, Tcl_Obj * const objv[]); @@ -266,17 +266,17 @@ Tktest_Init( Tcl_CreateObjCommand(interp, "testtext", TkpTesttextCmd, (ClientData) Tk_MainWindow(interp), NULL); -#if defined(_WIN32) || defined(MAC_OSX_TK) +#if defined(_WIN32) Tcl_CreateObjCommand(interp, "testmetrics", TestmetricsObjCmd, (ClientData) Tk_MainWindow(interp), NULL); -#elif !defined(__CYGWIN__) +#elif !defined(__CYGWIN__) && !defined(MAC_OSX_TK) Tcl_CreateObjCommand(interp, "testmenubar", TestmenubarObjCmd, (ClientData) Tk_MainWindow(interp), NULL); Tcl_CreateObjCommand(interp, "testsend", TkpTestsendCmd, (ClientData) Tk_MainWindow(interp), NULL); Tcl_CreateObjCommand(interp, "testwrapper", TestwrapperObjCmd, (ClientData) Tk_MainWindow(interp), NULL); -#endif /* _WIN32 || MAC_OSX_TK */ +#endif /* _WIN32 */ /* * Create test image type. @@ -1764,7 +1764,7 @@ TestmenubarObjCmd( *---------------------------------------------------------------------- */ -#if defined(_WIN32) || defined(MAC_OSX_TK) +#if defined(_WIN32) static int TestmetricsObjCmd( ClientData clientData, /* Main window for application. */ @@ -1775,38 +1775,15 @@ TestmetricsObjCmd( char buf[TCL_INTEGER_SPACE]; int val; -#ifdef _WIN32 if (objc < 2) { Tcl_WrongNumArgs(interp, 1, objv, "option ?arg ...?"); return TCL_ERROR; } -#else - Tk_Window tkwin = (Tk_Window) clientData; - TkWindow *winPtr; - - if (objc != 3) { - Tcl_WrongNumArgs(interp, 1, objv, "option window"); - return TCL_ERROR; - } - - winPtr = (TkWindow *) Tk_NameToWindow(interp, Tcl_GetString(objv[2]), tkwin); - if (winPtr == NULL) { - return TCL_ERROR; - } -#endif if (strcmp(Tcl_GetString(objv[1]), "cyvscroll") == 0) { -#ifdef _WIN32 val = GetSystemMetrics(SM_CYVSCROLL); -#else - val = ((TkScrollbar *) winPtr->instanceData)->width; -#endif } else if (strcmp(Tcl_GetString(objv[1]), "cxhscroll") == 0) { -#ifdef _WIN32 val = GetSystemMetrics(SM_CXHSCROLL); -#else - val = ((TkScrollbar *) winPtr->instanceData)->width; -#endif } else { Tcl_AppendResult(interp, "bad option \"", Tcl_GetString(objv[1]), "\": must be cxhscroll or cyvscroll", NULL); diff --git a/tests/scrollbar.test b/tests/scrollbar.test index bd14067..e590bb9 100644 --- a/tests/scrollbar.test +++ b/tests/scrollbar.test @@ -283,7 +283,7 @@ test scrollbar-3.41 {ScrollbarWidgetCmd procedure, "fraction" option} { if {[testConstraint testmetrics]} { place configure .t.s -width [expr 2*[testmetrics cxhscroll .t.s]+1] } else { - place configure .t.s -width [expr [winfo reqwidth .t.s] - 4] + place configure .t.s -width [expr [winfo height .t.s] - 2*([.t.s cget -highlightthickness] + [.t.s cget -bd] + 1)] } update test scrollbar-3.42 {ScrollbarWidgetCmd procedure, "fraction" option} { -- cgit v0.12 From 709edca30dc6e42ba27c08f19e97b3fe8e27206c Mon Sep 17 00:00:00 2001 From: fvogel Date: Mon, 8 Oct 2018 19:49:21 +0000 Subject: Fix [ca403f799b]: ttk::treeview border drawn incorrectly --- generic/ttk/ttkTreeview.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/generic/ttk/ttkTreeview.c b/generic/ttk/ttkTreeview.c index d957ad2..bef84f3 100644 --- a/generic/ttk/ttkTreeview.c +++ b/generic/ttk/ttkTreeview.c @@ -1825,7 +1825,7 @@ static int DrawSubtree( static int DrawForest( Treeview *tv, TreeItem *item, Drawable d, int depth, int row) { - while (item && row <= tv->tree.yscroll.last) { + while (item && row < tv->tree.yscroll.last) { row = DrawSubtree(tv, item, d, depth, row); item = item->next; } -- cgit v0.12 From 3e1603e12c9cd922b8e76d9d3083e93af3ec181f Mon Sep 17 00:00:00 2001 From: dgp Date: Tue, 9 Oct 2018 20:05:30 +0000 Subject: Bump version numbers for release. --- README | 2 +- generic/tk.h | 4 +-- library/tk.tcl | 2 +- unix/configure | 78 +++++-------------------------------------------------- unix/configure.in | 2 +- unix/tk.spec | 2 +- win/configure | 2 +- win/configure.in | 2 +- 8 files changed, 15 insertions(+), 79 deletions(-) diff --git a/README b/README index a26667c..597194a 100644 --- a/README +++ b/README @@ -1,5 +1,5 @@ README: Tk - This is the Tk 8.6.8 source distribution. + This is the Tk 8.6.9 source distribution. http://sourceforge.net/projects/tcl/files/Tcl/ You can get any source release of Tk from the URL above. diff --git a/generic/tk.h b/generic/tk.h index 87150e9..48f0015 100644 --- a/generic/tk.h +++ b/generic/tk.h @@ -75,10 +75,10 @@ extern "C" { #define TK_MAJOR_VERSION 8 #define TK_MINOR_VERSION 6 #define TK_RELEASE_LEVEL TCL_FINAL_RELEASE -#define TK_RELEASE_SERIAL 8 +#define TK_RELEASE_SERIAL 9 #define TK_VERSION "8.6" -#define TK_PATCH_LEVEL "8.6.8" +#define TK_PATCH_LEVEL "8.6.9" /* * A special definition used to allow this header file to be included from diff --git a/library/tk.tcl b/library/tk.tcl index d2f7b65..61d1354 100644 --- a/library/tk.tcl +++ b/library/tk.tcl @@ -11,7 +11,7 @@ # this file, and for a DISCLAIMER OF ALL WARRANTIES. # Verify that we have Tk binary and script components from the same release -package require -exact Tk 8.6.8 +package require -exact Tk 8.6.9 # Create a ::tk namespace namespace eval ::tk { diff --git a/unix/configure b/unix/configure index 1259c92..7b963db 100755 --- a/unix/configure +++ b/unix/configure @@ -1338,7 +1338,7 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu TK_VERSION=8.6 TK_MAJOR_VERSION=8 TK_MINOR_VERSION=6 -TK_PATCH_LEVEL=".8" +TK_PATCH_LEVEL=".9" VERSION=${TK_VERSION} LOCALES="cs da de el en en_gb eo es fr hu it nl pl pt ru sv" @@ -7465,70 +7465,6 @@ _ACEOF fi - echo "$as_me:$LINENO: checking for DIR64" >&5 -echo $ECHO_N "checking for DIR64... $ECHO_C" >&6 -if test "${tcl_cv_DIR64+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -#include -#include -int -main () -{ -struct dirent64 *p; DIR64 d = opendir64("."); - p = readdir64(d); rewinddir64(d); closedir64(d); - ; - return 0; -} -_ACEOF -rm -f conftest.$ac_objext -if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 - (eval $ac_compile) 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" - || test ! -s conftest.err' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - tcl_cv_DIR64=yes -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - -tcl_cv_DIR64=no -fi -rm -f conftest.err conftest.$ac_objext conftest.$ac_ext -fi -echo "$as_me:$LINENO: result: $tcl_cv_DIR64" >&5 -echo "${ECHO_T}$tcl_cv_DIR64" >&6 - if test "x${tcl_cv_DIR64}" = "xyes" ; then - -cat >>confdefs.h <<\_ACEOF -#define HAVE_DIR64 1 -_ACEOF - - fi - echo "$as_me:$LINENO: checking for struct stat64" >&5 echo $ECHO_N "checking for struct stat64... $ECHO_C" >&6 if test "${tcl_cv_struct_stat64+set}" = set; then @@ -9710,7 +9646,7 @@ ac_x_header_dirs=' /usr/openwin/share/include' if test "$ac_x_includes" = no; then - # Guess where to find include files, by looking for Xlib.h. + # Guess where to find include files, by looking for Intrinsic.h. # First, try using that file with no special directory specified. cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ @@ -9718,7 +9654,7 @@ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ -#include +#include _ACEOF if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 @@ -9745,7 +9681,7 @@ else sed 's/^/| /' conftest.$ac_ext >&5 for ac_dir in $ac_x_header_dirs; do - if test -r "$ac_dir/X11/Xlib.h"; then + if test -r "$ac_dir/X11/Intrinsic.h"; then ac_x_includes=$ac_dir break fi @@ -9759,18 +9695,18 @@ if test "$ac_x_libraries" = no; then # See if we find them without any special options. # Don't add to $LIBS permanently. ac_save_LIBS=$LIBS - LIBS="-lX11 $LIBS" + LIBS="-lXt $LIBS" cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ -#include +#include int main () { -XrmInitialize () +XtMalloc (0) ; return 0; } diff --git a/unix/configure.in b/unix/configure.in index a2ed566..a63322f 100644 --- a/unix/configure.in +++ b/unix/configure.in @@ -25,7 +25,7 @@ m4_ifdef([SC_USE_CONFIG_HEADERS], [ TK_VERSION=8.6 TK_MAJOR_VERSION=8 TK_MINOR_VERSION=6 -TK_PATCH_LEVEL=".8" +TK_PATCH_LEVEL=".9" VERSION=${TK_VERSION} LOCALES="cs da de el en en_gb eo es fr hu it nl pl pt ru sv" diff --git a/unix/tk.spec b/unix/tk.spec index 24019d4..159c533 100644 --- a/unix/tk.spec +++ b/unix/tk.spec @@ -4,7 +4,7 @@ Name: tk Summary: Tk graphical toolkit for the Tcl scripting language. -Version: 8.6.8 +Version: 8.6.9 Release: 2 License: BSD Group: Development/Languages diff --git a/win/configure b/win/configure index 15d509e..203d702 100755 --- a/win/configure +++ b/win/configure @@ -1312,7 +1312,7 @@ SHELL=/bin/sh TK_VERSION=8.6 TK_MAJOR_VERSION=8 TK_MINOR_VERSION=6 -TK_PATCH_LEVEL=".8" +TK_PATCH_LEVEL=".9" VER=$TK_MAJOR_VERSION$TK_MINOR_VERSION #------------------------------------------------------------------------ diff --git a/win/configure.in b/win/configure.in index 5ec7c35..167fd3d 100644 --- a/win/configure.in +++ b/win/configure.in @@ -14,7 +14,7 @@ SHELL=/bin/sh TK_VERSION=8.6 TK_MAJOR_VERSION=8 TK_MINOR_VERSION=6 -TK_PATCH_LEVEL=".8" +TK_PATCH_LEVEL=".9" VER=$TK_MAJOR_VERSION$TK_MINOR_VERSION #------------------------------------------------------------------------ -- cgit v0.12 From b918265fbf97ec7faea3b296fc03165adda18d5c Mon Sep 17 00:00:00 2001 From: dgp Date: Thu, 11 Oct 2018 19:27:16 +0000 Subject: URL updates; changes file WIP --- ChangeLog | 2 +- README | 6 +++--- changes | 35 +++++++++++++++++++++++++++++++++++ 3 files changed, 39 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index 94cabc1..2c1ca70 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,6 +1,6 @@ A NOTE ON THE CHANGELOG: Starting in early 2011, Tk source code has been under the management of -fossil, hosted at http://core.tcl.tk/tk/ . Fossil presents a "Timeline" +fossil, hosted at http://core.tcl-lang.org/tk/ . Fossil presents a "Timeline" view of changes made that is superior in every way to a hand edited log file. Because of this, many Tk developers are now out of the habit of maintaining this log file. You may still find useful things in it, but the Timeline is diff --git a/README b/README index 597194a..0c41c9c 100644 --- a/README +++ b/README @@ -12,7 +12,7 @@ toolkit implemented with the Tcl scripting language. For details on features, incompatibilities, and potential problems with this release, see the Tcl/Tk 8.6 Web page at - http://www.tcl.tk/software/tcltk/8.6.html + http://www.tcl-lang.org/software/tcltk/8.6.html or refer to the "changes" file in this directory, which contains a historical record of all changes to Tk. @@ -21,11 +21,11 @@ Tk is maintained, enhanced, and distributed freely by the Tcl community. Source code development and tracking of bug reports and feature requests takes place at: - http://core.tcl.tk/tk/ + http://core.tcl-lang.org/tk/ with the Tcl Developer Xchange at: - http://www.tcl.tk/ + http://www.tcl-lang.org/ Tk is a freely available open source package. You can do virtually anything you like with it, such as modifying it, redistributing it, diff --git a/changes b/changes index 0f82e7f..ab2954f 100644 --- a/changes +++ b/changes @@ -7495,3 +7495,38 @@ Tk Cocoa 2.0: More drawing internals refinements (culler,walzer) 2017-12-18 (bug)[b77626] Make [tk busy -cursor] silent no-op on macOS (vogel) --- Released 8.6.8, December 22, 2017 --- http://core.tcl.tk/tk/ for details + +2017-12-31 (bug)[aa7679] crash using window after master destroyed (vogel) + +2017-12-31 (bug)[6525e1] encoding leak in tkMacOSXProcessFiles (werner) + +2018-01-07 (bug)[925262] New option -state for ttk::scale (vogel) + +2018-01-07 (bug)[fa8de7] Crash [ttk::checkbutton .x -variable {}] (werner) + +2018-01-16 (bug)[382712] Crash in [event generate . ] (werner) + +2018-01-19 (bug)[657c38] Crash in menu destroy with checkbutton entry (werner) + +2018-01-25 (bug)[de156e] Deny PRIMARY selection access in safe interps (nash) + +2018-01-28 (bug)[b68710] Fixes in [text] bindings (nash) + +2018-01-28 (bug)[e20d5c] Stop failures of textTag-18.1 (vogel) + + + + + + + + + + + + + + + + +- Released 8.6.9, October 17, 2018 - http://core.tcl-lang.org/tk/ for details - -- cgit v0.12 From 114e0f85da55b2dfb11407cf23d13d16c4567ebd Mon Sep 17 00:00:00 2001 From: fvogel Date: Thu, 11 Oct 2018 19:57:44 +0000 Subject: Add non regression test cases for [4b555aca34]: text search -all hangs and eats all memory --- tests/text.test | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/tests/text.test b/tests/text.test index c656446..6dc6999 100644 --- a/tests/text.test +++ b/tests/text.test @@ -5873,6 +5873,32 @@ test text-22.225 {TextSearchCmd, strict limits} -body { } -cleanup { destroy .t } -result {} +test text-22.226 {TextSearchCmd, search for the empty string} -body { + pack [text .t] + .t search "" 1.0 +} -cleanup { + destroy .t +} -result {1.0} +test text-22.227 {TextSearchCmd, search for the empty string} -body { + pack [text .t] + .t insert end "Searching for the\nempty string!" + .t search "" 2.5 +} -cleanup { + destroy .t +} -result {2.5} +test text-22.228 {TextSearchCmd, search all empty strings} -body { + pack [text .t] + .t search -all "" 1.0 +} -cleanup { + destroy .t +} -result {1.0} +test text-22.228 {TextSearchCmd, search all empty strings} -body { + pack [text .t] + .t insert end "Searching for the\nempty string!" + .t search -all "" 2.5 +} -cleanup { + destroy .t +} -result {2.5} test text-23.1 {TkTextGetTabs procedure} -setup { -- cgit v0.12 From 39b70555a69bfdb82be51d1c51f13e1b109a01a4 Mon Sep 17 00:00:00 2001 From: fvogel Date: Thu, 11 Oct 2018 20:00:40 +0000 Subject: Fix [4b555aca34]: text search -all hangs and eats all memory --- generic/tkText.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/generic/tkText.c b/generic/tkText.c index d43bef6..6c52624 100644 --- a/generic/tkText.c +++ b/generic/tkText.c @@ -6070,8 +6070,8 @@ SearchCore( matchOffset = p - startOfLine; if (searchSpecPtr->all && - !searchSpecPtr->foundMatchProc(lineNum, searchSpecPtr, - lineInfo, theLine, matchOffset, matchLength)) { + (!searchSpecPtr->foundMatchProc(lineNum, searchSpecPtr, + lineInfo, theLine, matchOffset, matchLength) || (matchLength == 0)) ) { /* * We reached the end of the search. */ -- cgit v0.12 From 8b28c1a5c732ff290238e401b096151a8b1cf82a Mon Sep 17 00:00:00 2001 From: dgp Date: Sun, 14 Oct 2018 22:47:38 +0000 Subject: Update changes --- changes | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/changes b/changes index ab2954f..c460a96 100644 --- a/changes +++ b/changes @@ -7514,19 +7514,50 @@ Tk Cocoa 2.0: More drawing internals refinements (culler,walzer) 2018-01-28 (bug)[e20d5c] Stop failures of textTag-18.1 (vogel) +2018-02-04 (bug)[5d991b] Fortify var traces against deleted vars (vogel) +2018-02-10 (bug)[1821174] Stop RenderBadPicture X error (werner) +2018-02-11 (bug)[502e74] Stop X errors on untrusted connections (werner) +2018-03-07 (bug)[71b131] Regression in Tk_DrawChars() (werner,cramer) +2018-04-03 (bug)[59fccb] menu flaws when empty menubar clicked (vogel,mcdonald) +2018-04-28 (bug)[7423f9] improved legacy support for [tk_setPalette] (bll) +2018-04-30 (bug)[6d5042] enable [tk inactive] on Mac OSX (culler) +2018-05-03 (bug)[75d38f] fix touchpad scroll of listbox on win notebook (vogel) +2018-06-16 (bug)[de01e2] Crash in [$text replace] (vogel) +2018-07-04 (bug)[6ca257] Fix [wm resizable] on Mac OSX (culler) +2018-07-04 (bug)[135696] Crash in [wm transient] (culler) +2018-07-04 (bug)[309b42] Improve ttk high-contrast-mode support (lemburg,vogel) +2018-07-17 (bug)[1088825] fix frame-2.17,3.9,3.10 on Mac (vogel) +2018-07-27 (bug)[fabed1] GIF photo support for "deferred clear code" (vogel) +2018-08-08 (feature) Modern full-screen support on Mac OSX (walzer) + +2018-08-12 (bug)[1875c1] scrollbar on Mac OSX (walzer) + +2018-08-14 (bug)[1ba71a] KeyRelease events on Mac OSX(walzer) + +2018-09-02 (bug)[3441086] error message in layout-2 (vogel) + +2018-09-07 (bug)[05bd7f] vista theme for combobox (vogel) + +2018-09-08 (bug)[382712] crash in KeyPress event handling (vogel,werner) + +2018-09-08 (bug)[6fcaaa] insertion cursor visibility in ttk::entry (nemethi) + +2018-09-30 (bug)[822923] cascade menu indicator color (mcdonald) + +2018-10-06 (bug)[9658bc] borderwidth calculations on menu items (vogel) - Released 8.6.9, October 17, 2018 - http://core.tcl-lang.org/tk/ for details - -- cgit v0.12 From d7bb194757834cfa8a4b7c659588cdddea2a599f Mon Sep 17 00:00:00 2001 From: fvogel Date: Mon, 15 Oct 2018 14:24:58 +0000 Subject: Backout the previously proposed fix [80286abf05], and add more tests. --- generic/tkText.c | 4 ++-- tests/text.test | 63 ++++++++++++++++++++++++++++++++++++++++++++++++++------ 2 files changed, 59 insertions(+), 8 deletions(-) diff --git a/generic/tkText.c b/generic/tkText.c index 6c52624..d43bef6 100644 --- a/generic/tkText.c +++ b/generic/tkText.c @@ -6070,8 +6070,8 @@ SearchCore( matchOffset = p - startOfLine; if (searchSpecPtr->all && - (!searchSpecPtr->foundMatchProc(lineNum, searchSpecPtr, - lineInfo, theLine, matchOffset, matchLength) || (matchLength == 0)) ) { + !searchSpecPtr->foundMatchProc(lineNum, searchSpecPtr, + lineInfo, theLine, matchOffset, matchLength)) { /* * We reached the end of the search. */ diff --git a/tests/text.test b/tests/text.test index 6dc6999..b7071db 100644 --- a/tests/text.test +++ b/tests/text.test @@ -5873,33 +5873,84 @@ test text-22.225 {TextSearchCmd, strict limits} -body { } -cleanup { destroy .t } -result {} -test text-22.226 {TextSearchCmd, search for the empty string} -body { +test text-22.226 {TextSearchCmd, exact search for the empty string} -body { pack [text .t] .t search "" 1.0 } -cleanup { destroy .t } -result {1.0} -test text-22.227 {TextSearchCmd, search for the empty string} -body { +test text-22.227 {TextSearchCmd, exact search for the empty string} -body { pack [text .t] .t insert end "Searching for the\nempty string!" .t search "" 2.5 } -cleanup { destroy .t } -result {2.5} -test text-22.228 {TextSearchCmd, search all empty strings} -body { +test text-22.228 {TextSearchCmd, exact search all empty strings} -body { pack [text .t] .t search -all "" 1.0 } -cleanup { destroy .t } -result {1.0} -test text-22.228 {TextSearchCmd, search all empty strings} -body { +test text-22.229 {TextSearchCmd, exact search all empty strings} -body { pack [text .t] .t insert end "Searching for the\nempty string!" - .t search -all "" 2.5 + .t search -all "" 2.5 2.8 +} -cleanup { + destroy .t +} -result {2.5 2.6 2.7} +test text-22.230 {TextSearchCmd, exact search all empty strings, with overlap} -body { + pack [text .t] + .t search -all -overlap "" 1.0 +} -cleanup { + destroy .t +} -result {1.0} +test text-22.231 {TextSearchCmd, exact search all empty strings, with overlap} -body { + pack [text .t] + .t insert end "Searching for the\nempty string!" + .t search -all -overlap "" 2.5 2.8 +} -cleanup { + destroy .t +} -result {2.5 2.6 2.7} +test text-22.232 {TextSearchCmd, regexp search for the empty string} -body { + pack [text .t] + .t search -regexp "" 1.0 +} -cleanup { + destroy .t +} -result {1.0} +test text-22.233 {TextSearchCmd, regexp search for the empty string} -body { + pack [text .t] + .t insert end "Searching for the\nempty string!" + .t search -regexp "" 2.5 } -cleanup { destroy .t } -result {2.5} - +test text-22.234 {TextSearchCmd, regexp search all empty strings} -body { + pack [text .t] + .t search -all -regexp "" 1.0 +} -cleanup { + destroy .t +} -result {1.0} +test text-22.235 {TextSearchCmd, regexp search all empty strings} -body { + pack [text .t] + .t insert end "Searching for the\nempty string!" + .t search -all -regexp "" 2.5 2.8 +} -cleanup { + destroy .t +} -result {2.5 2.6 2.7} +test text-22.236 {TextSearchCmd, regexp search all empty strings, with overlap} -body { + pack [text .t] + .t search -all -regexp -overlap "" 1.0 +} -cleanup { + destroy .t +} -result {1.0} +test text-22.237 {TextSearchCmd, regexp search all empty strings, with overlap} -body { + pack [text .t] + .t insert end "Searching for the\nempty string!" + .t search -all -regexp -overlap "" 2.5 2.8 +} -cleanup { + destroy .t +} -result {2.5 2.6 2.7} test text-23.1 {TkTextGetTabs procedure} -setup { text .t -highlightthickness 0 -bd 0 -relief flat -padx 0 -width 100 -- cgit v0.12 From aa465523c0ebc89db903ffa95723a74a3b4e096a Mon Sep 17 00:00:00 2001 From: fvogel Date: Mon, 15 Oct 2018 14:26:50 +0000 Subject: Another proposed fix for [4b555aca34]: text search -all hangs and eats all memory. --- generic/tkText.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/generic/tkText.c b/generic/tkText.c index d43bef6..715e3c0 100644 --- a/generic/tkText.c +++ b/generic/tkText.c @@ -5749,11 +5749,16 @@ SearchCore( /* * We only need to set the matchLength once for exact searches, and we * do it here. It is also used below as the actual pattern length, so - * it has dual purpose. + * it has dual purpose. Warning: to properly advance between matches + * the matchLength can't be zero (which would happen when searching + * for an empty string). */ pattern = Tcl_GetString(patObj); matchLength = patObj->length; + if (matchLength == 0) { + matchLength = 1; + } nl = strchr(pattern, '\n'); /* -- cgit v0.12 From f7b70960c710c207bfcb64456cab0aa0e2dcbe1b Mon Sep 17 00:00:00 2001 From: fvogel Date: Mon, 15 Oct 2018 18:48:48 +0000 Subject: Revert the second fix proposal, and add more tests (covering backwards searches). Note that text-22.228 and text-22.229 currently hang. --- generic/tkText.c | 3 - tests/text.test | 198 +++++++++++++++++++++++++++++++++++++++++++++---------- 2 files changed, 162 insertions(+), 39 deletions(-) diff --git a/generic/tkText.c b/generic/tkText.c index 715e3c0..e49693e 100644 --- a/generic/tkText.c +++ b/generic/tkText.c @@ -5756,9 +5756,6 @@ SearchCore( pattern = Tcl_GetString(patObj); matchLength = patObj->length; - if (matchLength == 0) { - matchLength = 1; - } nl = strchr(pattern, '\n'); /* diff --git a/tests/text.test b/tests/text.test index b7071db..6ce1b8e 100644 --- a/tests/text.test +++ b/tests/text.test @@ -5874,83 +5874,209 @@ test text-22.225 {TextSearchCmd, strict limits} -body { destroy .t } -result {} test text-22.226 {TextSearchCmd, exact search for the empty string} -body { - pack [text .t] - .t search "" 1.0 + text .t + set res [.t search -count C "" 1.0] + lappend res $C } -cleanup { destroy .t -} -result {1.0} + unset -nocomplain res C +} -result {1.0 0} test text-22.227 {TextSearchCmd, exact search for the empty string} -body { - pack [text .t] + text .t .t insert end "Searching for the\nempty string!" - .t search "" 2.5 + set res [.t search -count C "" 2.5] + lappend res $C } -cleanup { destroy .t -} -result {2.5} + unset -nocomplain res C +} -result {2.5 0} test text-22.228 {TextSearchCmd, exact search all empty strings} -body { - pack [text .t] - .t search -all "" 1.0 + text .t + set res [.t search -count C -all "" 1.0] + lappend res $C } -cleanup { destroy .t -} -result {1.0} + unset -nocomplain res C +} -result {1.0 0} test text-22.229 {TextSearchCmd, exact search all empty strings} -body { - pack [text .t] + text .t .t insert end "Searching for the\nempty string!" - .t search -all "" 2.5 2.8 + -all "" 2.5 2.8] + lappend res $C } -cleanup { destroy .t -} -result {2.5 2.6 2.7} + unset -nocomplain res C +} -result {2.5 2.6 2.7 {0 0 0}} test text-22.230 {TextSearchCmd, exact search all empty strings, with overlap} -body { - pack [text .t] - .t search -all -overlap "" 1.0 + text .t + set res [.t search -count C -all -overlap "" 1.0] + lappend res $C } -cleanup { destroy .t -} -result {1.0} + unset -nocomplain res C +} -result {1.0 0} test text-22.231 {TextSearchCmd, exact search all empty strings, with overlap} -body { - pack [text .t] + text .t .t insert end "Searching for the\nempty string!" - .t search -all -overlap "" 2.5 2.8 + set res [.t search -count C -all -overlap "" 2.5 2.8] + lappend res $C } -cleanup { destroy .t -} -result {2.5 2.6 2.7} + unset -nocomplain res C +} -result {2.5 2.6 2.7 {0 0 0}} test text-22.232 {TextSearchCmd, regexp search for the empty string} -body { - pack [text .t] - .t search -regexp "" 1.0 + text .t + set res [.t search -count C -regexp "" 1.0] + lappend res $C } -cleanup { destroy .t -} -result {1.0} + unset -nocomplain res C +} -result {1.0 0} test text-22.233 {TextSearchCmd, regexp search for the empty string} -body { - pack [text .t] + text .t .t insert end "Searching for the\nempty string!" - .t search -regexp "" 2.5 + set res [.t search -count C -regexp "" 2.5] + lappend res $C } -cleanup { destroy .t -} -result {2.5} + unset -nocomplain res C +} -result {2.5 0} test text-22.234 {TextSearchCmd, regexp search all empty strings} -body { - pack [text .t] - .t search -all -regexp "" 1.0 + text .t + set res [.t search -count C -all -regexp "" 1.0] + lappend res $C } -cleanup { destroy .t -} -result {1.0} + unset -nocomplain res C +} -result {1.0 0} test text-22.235 {TextSearchCmd, regexp search all empty strings} -body { - pack [text .t] + text .t .t insert end "Searching for the\nempty string!" - .t search -all -regexp "" 2.5 2.8 + set res [.t search -count C -all -regexp "" 2.5 2.8] + lappend res $C } -cleanup { destroy .t -} -result {2.5 2.6 2.7} + unset -nocomplain res C +} -result {2.5 2.6 2.7 {0 0 0}} test text-22.236 {TextSearchCmd, regexp search all empty strings, with overlap} -body { - pack [text .t] - .t search -all -regexp -overlap "" 1.0 + text .t + set res [.t search -count C -all -regexp -overlap "" 1.0] + lappend res $C } -cleanup { destroy .t -} -result {1.0} + unset -nocomplain res C +} -result {1.0 0} test text-22.237 {TextSearchCmd, regexp search all empty strings, with overlap} -body { - pack [text .t] + text .t + .t insert end "Searching for the\nempty string!" + set res [.t search -count C -all -regexp -overlap "" 2.5 2.8] + lappend res $C +} -cleanup { + destroy .t + unset -nocomplain res C +} -result {2.5 2.6 2.7 {0 0 0}} +test text-22.238 {TextSearchCmd, exact backwards search for the empty string} -body { + text .t + set res [.t search -count C -backwards "" 1.0] + lappend res $C +} -cleanup { + destroy .t + unset -nocomplain res C +} -result {1.0 0} +test text-22.239 {TextSearchCmd, exact backwards search for the empty string} -body { + text .t + .t insert end "Searching for the\nempty string!" + set res [.t search -count C -backwards "" 2.5] + lappend res $C +} -cleanup { + destroy .t + unset -nocomplain res C +} -result {2.5 0} +test text-22.240 {TextSearchCmd, exact backwards search all empty strings} -body { + text .t + set res [.t search -count C -backwards -all "" 1.0] + lappend res $C +} -cleanup { + destroy .t + unset -nocomplain res C +} -result {1.0 0} +test text-22.241 {TextSearchCmd, exact backwards search all empty strings} -body { + text .t + .t insert end "Searching for the\nempty string!" + set res [.t search -count C -backwards -all "" 2.5 2.8] + lappend res $C +} -cleanup { + destroy .t + unset -nocomplain res C +} -result {2.5 2.6 2.7 {0 0 0}} +test text-22.242 {TextSearchCmd, exact backwards search all empty strings, with overlap} -body { + text .t + set res [.t search -count C -backwards -all -overlap "" 1.0] + lappend res $C +} -cleanup { + destroy .t + unset -nocomplain res C +} -result {1.0 0} +test text-22.243 {TextSearchCmd, exact backwards search all empty strings, with overlap} -body { + text .t + .t insert end "Searching for the\nempty string!" + set res [.t search -count C -backwards -all -overlap "" 2.5 2.8] + lappend res $C +} -cleanup { + destroy .t + unset -nocomplain res C +} -result {2.5 2.6 2.7 {0 0 0}} +test text-22.244 {TextSearchCmd, regexp backwards search for the empty string} -body { + text .t + set res [.t search -count C -backwards -regexp "" 1.0] + lappend res $C +} -cleanup { + destroy .t + unset -nocomplain res C +} -result {1.0 0} +test text-22.245 {TextSearchCmd, regexpbackwards search for the empty string} -body { + text .t + .t insert end "Searching for the\nempty string!" + set res [.t search -count C -backwards -regexp "" 2.5] + lappend res $C +} -cleanup { + destroy .t + unset -nocomplain res C +} -result {2.4 0} +test text-22.246 {TextSearchCmd, regexp backwards search all empty strings} -body { + text .t + set res [.t search -count C -backwards -all -regexp "" 1.0] + lappend res $C +} -cleanup { + destroy .t + unset -nocomplain res C +} -result {1.0 0} +test text-22.247 {TextSearchCmd, regexp backwards search all empty strings} -body { + text .t + .t insert end "Searching for the\nempty string!" + set res [.t search -count C -backwards -all -regexp "" 2.5 2.0] + lappend res $C +} -cleanup { + destroy .t + unset -nocomplain res C +} -result {2.4 2.3 2.2 2.1 2.0 {0 0 0 0 0}} +test text-22.248 {TextSearchCmd, regexp backwards search all empty strings, with overlap} -body { + text .t + set res [.t search -count C -backwards -all -regexp -overlap "" 1.0] + lappend res $C +} -cleanup { + destroy .t + unset -nocomplain res C +} -result {1.0 0} +test text-22.249 {TextSearchCmd, regexp backwards search all empty strings, with overlap} -body { + text .t .t insert end "Searching for the\nempty string!" - .t search -all -regexp -overlap "" 2.5 2.8 + set res [.t search -count C -backwards -all -regexp -overlap "" 2.5 2.0] + lappend res $C } -cleanup { destroy .t -} -result {2.5 2.6 2.7} + unset -nocomplain res C +} -result {2.4 2.3 2.2 2.1 2.0 {0 0 0 0 0}} test text-23.1 {TkTextGetTabs procedure} -setup { text .t -highlightthickness 0 -bd 0 -relief flat -padx 0 -width 100 -- cgit v0.12 From ed64ae0c1ce560ecea8dddefe9feb8d6f527e676 Mon Sep 17 00:00:00 2001 From: fvogel Date: Mon, 15 Oct 2018 18:58:49 +0000 Subject: Third fix proposal for [4b555aca34]: text search -all hangs and eats all memory. (And fix test text-22.229) --- generic/tkText.c | 3 ++- tests/text.test | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/generic/tkText.c b/generic/tkText.c index e49693e..7dfd048 100644 --- a/generic/tkText.c +++ b/generic/tkText.c @@ -6090,7 +6090,8 @@ SearchCore( alreadySearchOffset -= matchLength; } } else { - firstOffset = p - startOfLine + matchLength; + firstOffset = (matchLength == 0) ? p - startOfLine + 1 + : p - startOfLine + matchLength; if (firstOffset >= lastOffset) { /* * Now, we have to be careful not to find diff --git a/tests/text.test b/tests/text.test index 6ce1b8e..f99ccfc 100644 --- a/tests/text.test +++ b/tests/text.test @@ -5901,7 +5901,7 @@ test text-22.228 {TextSearchCmd, exact search all empty strings} -body { test text-22.229 {TextSearchCmd, exact search all empty strings} -body { text .t .t insert end "Searching for the\nempty string!" - -all "" 2.5 2.8] + set res [.t search -count C -all "" 2.5 2.8] lappend res $C } -cleanup { destroy .t -- cgit v0.12 From 2b4cf979544782a230fd93cb3baa3352056e73f5 Mon Sep 17 00:00:00 2001 From: fvogel Date: Mon, 15 Oct 2018 19:03:27 +0000 Subject: Remove comment I forgot to revert previously. --- generic/tkText.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/generic/tkText.c b/generic/tkText.c index 7dfd048..b92c925 100644 --- a/generic/tkText.c +++ b/generic/tkText.c @@ -5749,9 +5749,7 @@ SearchCore( /* * We only need to set the matchLength once for exact searches, and we * do it here. It is also used below as the actual pattern length, so - * it has dual purpose. Warning: to properly advance between matches - * the matchLength can't be zero (which would happen when searching - * for an empty string). + * it has dual purpose. */ pattern = Tcl_GetString(patObj); -- cgit v0.12 From 1f235ac4e155b3efbbe36ac949e2bbe83879bd94 Mon Sep 17 00:00:00 2001 From: culler Date: Tue, 16 Oct 2018 15:53:17 +0000 Subject: Fix bug 09e18e42d7: Tk does not display on macOS 10.14 --- macosx/tkMacOSXWindowEvent.c | 53 ++++++++++++++++++++------------------------ macosx/tkMacOSXWm.c | 3 +-- 2 files changed, 25 insertions(+), 31 deletions(-) diff --git a/macosx/tkMacOSXWindowEvent.c b/macosx/tkMacOSXWindowEvent.c index bbfe5b7..cc337b1 100644 --- a/macosx/tkMacOSXWindowEvent.c +++ b/macosx/tkMacOSXWindowEvent.c @@ -813,17 +813,7 @@ ConfigureRestrictProc( r.origin.y = height - (r.origin.y + r.size.height); HIShapeUnionWithRect(drawShape, &r); } - if (CFRunLoopGetMain() == CFRunLoopGetCurrent()) { - [self generateExposeEvents:(HIShapeRef)drawShape]; - } else { - [self performSelectorOnMainThread:@selector(generateExposeEvents:) - withObject:(id)drawShape waitUntilDone:NO - modes:[NSArray arrayWithObjects:NSRunLoopCommonModes, - - NSEventTrackingRunLoopMode, NSModalPanelRunLoopMode, - nil]]; - } - + [self generateExposeEvents:(HIShapeRef)drawShape]; CFRelease(drawShape); } @@ -845,11 +835,6 @@ ConfigureRestrictProc( */ [NSApp _lockAutoreleasePool]; - /* - * Try to prevent flickers and flashes. - */ - NSDisableScreenUpdates(); - /* Disable Tk drawing until the window has been completely configured.*/ TkMacOSXSetDrawingEnabled(winPtr, 0); @@ -857,7 +842,6 @@ ConfigureRestrictProc( TkGenWMConfigureEvent(tkwin, Tk_X(tkwin), Tk_Y(tkwin), width, height, TK_SIZE_CHANGED | TK_MACOSX_HANDLE_EVENT_IMMEDIATELY); oldProc = Tk_RestrictEvents(ConfigureRestrictProc, NULL, &oldArg); - while (Tk_DoOneEvent(TK_X_EVENTS|TK_DONT_WAIT)) {} Tk_RestrictEvents(oldProc, oldArg, &oldArg); /* Now that Tk has configured all subwindows we can create the clip regions. */ @@ -869,16 +853,14 @@ ConfigureRestrictProc( HIRect bounds = NSRectToCGRect([self bounds]); HIShapeRef shape = HIShapeCreateWithRect(&bounds); [self generateExposeEvents: shape]; - while (Tk_DoOneEvent(TK_ALL_EVENTS|TK_DONT_WAIT)) {} - [w displayIfNeeded]; - NSEnableScreenUpdates(); + while (Tk_DoOneEvent(TK_X_EVENTS|TK_DONT_WAIT)) {} [NSApp _unlockAutoreleasePool]; } } /* * As insurance against bugs that might cause layout glitches during a live - * resize, we redraw the window one more time at the end of the resize + * resize, we mark the window as needing display at the end of the resize * operation. */ @@ -887,13 +869,13 @@ ConfigureRestrictProc( HIRect bounds = NSRectToCGRect([self bounds]); HIShapeRef shape = HIShapeCreateWithRect(&bounds); [super viewDidEndLiveResize]; - [self generateExposeEvents: shape]; + [self displayIfNeeded]; } -/* Core method of this class: generates expose events for redrawing. If the - * Tcl_ServiceMode is set to TCL_SERVICE_ALL then the expose events will be - * immediately removed from the Tcl event loop and processed. Typically, they - * should be queued, however. +/* Core method of this class: generates expose events for redrawing. The + * expose events are immediately removed from the Tcl event loop and processed. + * This causes drawing procedures to be scheduled as idle events. Then all + * pending idle events are processed so the drawing will actually take place. */ - (void) generateExposeEvents: (HIShapeRef) shape { @@ -912,13 +894,26 @@ ConfigureRestrictProc( serial = LastKnownRequestProcessed(Tk_Display(winPtr)); updatesNeeded = GenerateUpdates(shape, &updateBounds, winPtr); - /* Process the Expose events if the service mode is TCL_SERVICE_ALL */ - if (updatesNeeded && Tcl_GetServiceMode() == TCL_SERVICE_ALL) { + if (updatesNeeded) { + /* Process all of the Expose events.*/ ClientData oldArg; Tk_RestrictProc *oldProc = Tk_RestrictEvents(ExposeRestrictProc, UINT2PTR(serial), &oldArg); - while (Tcl_ServiceEvent(TCL_WINDOW_EVENTS)) {} + while (Tcl_ServiceEvent(TCL_WINDOW_EVENTS)) {}; Tk_RestrictEvents(oldProc, oldArg, &oldArg); + + /* Starting with OSX 10.14, which uses Core Animation to draw windows, + * all drawing must be done within the drawRect method. (The CGContext + * which draws to the backing CALayer is created by the NSView before + * calling drawRect, and destroyed when drawRect returns. Drawing done + * with the current CGContext outside of the drawRect method has no + * effect.) + * + * Fortunately, Tk schedules all drawing to be done while Tcl is idle. + * So we can do the drawing by processing all of the idle events that + * were created when the expose events were processed. + */ + while (Tcl_DoOneEvent(TCL_IDLE_EVENTS)) {} } } diff --git a/macosx/tkMacOSXWm.c b/macosx/tkMacOSXWm.c index a0fda96..cf0ee7a 100644 --- a/macosx/tkMacOSXWm.c +++ b/macosx/tkMacOSXWm.c @@ -5646,7 +5646,6 @@ TkMacOSXMakeRealWindowExist( } TKContentView *contentView = [[TKContentView alloc] initWithFrame:NSZeroRect]; - [window setColorSpace:[NSColorSpace deviceRGBColorSpace]]; [window setContentView:contentView]; [contentView release]; [window setDelegate:NSApp]; @@ -5659,7 +5658,7 @@ TkMacOSXMakeRealWindowExist( if ((styleMask & (NSTexturedBackgroundWindowMask|NSHUDWindowMask)) && !(styleMask & NSDocModalWindowMask)) { /* - * Workaround for [Bug 2824538]: Texured windows are draggable + * Workaround for [Bug 2824538]: Textured windows are draggable * from opaque content. */ [window setMovableByWindowBackground:NO]; -- cgit v0.12 From 9dd1ecf775ca98d0b14666163def8d3571c4e71c Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Tue, 16 Oct 2018 19:40:17 +0000 Subject: Change char *recordPtr to void *recordPtr in Tk_SetOptions() and friends. This is 100% upwards compatible, and equivalent to TIP #494 done in Tcl. With this, a ton of (char *) type casts can be eliminated --- doc/SetOptions.3 | 2 +- generic/tk.decls | 18 ++++++++--------- generic/tk.h | 2 +- generic/tkBusy.c | 8 ++++---- generic/tkButton.c | 8 ++++---- generic/tkConfig.c | 10 +++++----- generic/tkDecls.h | 36 +++++++++++++++++----------------- generic/tkEntry.c | 14 +++++++------- generic/tkFrame.c | 8 ++++---- generic/tkListbox.c | 14 +++++++------- generic/tkMenu.c | 20 +++++++++---------- generic/tkMenubutton.c | 8 ++++---- generic/tkMessage.c | 8 ++++---- generic/tkPanedWindow.c | 20 +++++++++---------- generic/tkPlace.c | 4 ++-- generic/tkScale.c | 8 ++++---- generic/tkSquare.c | 12 ++++++------ generic/tkStyle.c | 8 ++++---- generic/tkTest.c | 46 ++++++++++++++++++++++---------------------- generic/tkText.c | 8 ++++---- generic/tkTextImage.c | 6 +++--- generic/tkTextTag.c | 6 +++--- generic/tkTextWind.c | 6 +++--- generic/ttk/ttkNotebook.c | 2 +- generic/ttk/ttkPanedwindow.c | 2 +- generic/ttk/ttkTheme.c | 8 ++++---- generic/ttk/ttkThemeInt.h | 4 ++-- generic/ttk/ttkTreeview.c | 6 +++--- 28 files changed, 151 insertions(+), 151 deletions(-) diff --git a/doc/SetOptions.3 b/doc/SetOptions.3 index 581b1e6..4323f95 100644 --- a/doc/SetOptions.3 +++ b/doc/SetOptions.3 @@ -52,7 +52,7 @@ pointed to by this argument must exist for the lifetime of the Tk_OptionTable. .AP Tk_OptionTable optionTable in Token for an option table. Must have been returned by a previous call to \fBTk_CreateOptionTable\fR. -.AP char *recordPtr in/out +.AP void *recordPtr in/out Points to structure in which values of configuration options are stored; fields of this record are modified by procedures such as \fBTk_SetOptions\fR and read by procedures such as \fBTk_GetOptionValue\fR. diff --git a/generic/tk.decls b/generic/tk.decls index 2cd7136..b435782 100644 --- a/generic/tk.decls +++ b/generic/tk.decls @@ -744,7 +744,7 @@ declare 194 { void Tk_FreeColorFromObj(Tk_Window tkwin, Tcl_Obj *objPtr) } declare 195 { - void Tk_FreeConfigOptions(char *recordPtr, Tk_OptionTable optionToken, + void Tk_FreeConfigOptions(void *recordPtr, Tk_OptionTable optionToken, Tk_Window tkwin) } declare 196 { @@ -774,11 +774,11 @@ declare 203 { } declare 204 { Tcl_Obj *Tk_GetOptionInfo(Tcl_Interp *interp, - char *recordPtr, Tk_OptionTable optionTable, + void *recordPtr, Tk_OptionTable optionTable, Tcl_Obj *namePtr, Tk_Window tkwin) } declare 205 { - Tcl_Obj *Tk_GetOptionValue(Tcl_Interp *interp, char *recordPtr, + Tcl_Obj *Tk_GetOptionValue(Tcl_Interp *interp, void *recordPtr, Tk_OptionTable optionTable, Tcl_Obj *namePtr, Tk_Window tkwin) } declare 206 { @@ -802,7 +802,7 @@ declare 210 { int objc, Tcl_Obj *const objv[], double *dblPtr, int *intPtr) } declare 211 { - int Tk_InitOptions(Tcl_Interp *interp, char *recordPtr, + int Tk_InitOptions(Tcl_Interp *interp, void *recordPtr, Tk_OptionTable optionToken, Tk_Window tkwin) } declare 212 { @@ -813,7 +813,7 @@ declare 213 { void Tk_RestoreSavedOptions(Tk_SavedOptions *savePtr) } declare 214 { - int Tk_SetOptions(Tcl_Interp *interp, char *recordPtr, + int Tk_SetOptions(Tcl_Interp *interp, void *recordPtr, Tk_OptionTable optionTable, int objc, Tcl_Obj *const objv[], Tk_Window tkwin, Tk_SavedOptions *savePtr, int *maskPtr) @@ -1001,22 +1001,22 @@ declare 260 { } declare 261 { void Tk_GetElementSize(Tk_Style style, Tk_StyledElement element, - char *recordPtr, Tk_Window tkwin, int width, int height, + void *recordPtr, Tk_Window tkwin, int width, int height, int inner, int *widthPtr, int *heightPtr) } declare 262 { void Tk_GetElementBox(Tk_Style style, Tk_StyledElement element, - char *recordPtr, Tk_Window tkwin, int x, int y, int width, + void *recordPtr, Tk_Window tkwin, int x, int y, int width, int height, int inner, int *xPtr, int *yPtr, int *widthPtr, int *heightPtr) } declare 263 { int Tk_GetElementBorderWidth(Tk_Style style, Tk_StyledElement element, - char *recordPtr, Tk_Window tkwin) + void *recordPtr, Tk_Window tkwin) } declare 264 { void Tk_DrawElement(Tk_Style style, Tk_StyledElement element, - char *recordPtr, Tk_Window tkwin, Drawable d, int x, int y, + void *recordPtr, Tk_Window tkwin, Drawable d, int x, int y, int width, int height, int state) } diff --git a/generic/tk.h b/generic/tk.h index a0affbc..adc9672 100644 --- a/generic/tk.h +++ b/generic/tk.h @@ -311,7 +311,7 @@ typedef struct Tk_SavedOption { #endif typedef struct Tk_SavedOptions { - char *recordPtr; /* The data structure in which to restore + void *recordPtr; /* The data structure in which to restore * configuration options. */ Tk_Window tkwin; /* Window associated with recordPtr; needed to * restore certain options. */ diff --git a/generic/tkBusy.c b/generic/tkBusy.c index aabf7a4..8b8db66 100644 --- a/generic/tkBusy.c +++ b/generic/tkBusy.c @@ -571,7 +571,7 @@ CreateBusy( busyPtr->cursor = None; Tk_SetClass(tkBusy, "Busy"); busyPtr->optionTable = Tk_CreateOptionTable(interp, busyOptionSpecs); - if (Tk_InitOptions(interp, (char *) busyPtr, busyPtr->optionTable, + if (Tk_InitOptions(interp, busyPtr, busyPtr->optionTable, tkBusy) != TCL_OK) { Tk_DestroyWindow(tkBusy); return NULL; @@ -638,7 +638,7 @@ ConfigureBusy( { Tk_Cursor oldCursor = busyPtr->cursor; - if (Tk_SetOptions(interp, (char *) busyPtr, busyPtr->optionTable, objc, + if (Tk_SetOptions(interp, busyPtr, busyPtr->optionTable, objc, objv, busyPtr->tkBusy, NULL, NULL) != TCL_OK) { return TCL_ERROR; } @@ -850,7 +850,7 @@ Tk_BusyObjCmd( return TCL_ERROR; } Tcl_Preserve(busyPtr); - objPtr = Tk_GetOptionValue(interp, (char *) busyPtr, + objPtr = Tk_GetOptionValue(interp, busyPtr, busyPtr->optionTable, objv[3], busyPtr->tkBusy); if (objPtr == NULL) { result = TCL_ERROR; @@ -871,7 +871,7 @@ Tk_BusyObjCmd( } Tcl_Preserve(busyPtr); if (objc <= 4) { - objPtr = Tk_GetOptionInfo(interp, (char *) busyPtr, + objPtr = Tk_GetOptionInfo(interp, busyPtr, busyPtr->optionTable, (objc == 4) ? objv[3] : NULL, busyPtr->tkBusy); if (objPtr == NULL) { diff --git a/generic/tkButton.c b/generic/tkButton.c index fc2c7ec..ddc267d 100644 --- a/generic/tkButton.c +++ b/generic/tkButton.c @@ -749,7 +749,7 @@ ButtonCreate( ExposureMask|StructureNotifyMask|FocusChangeMask, ButtonEventProc, butPtr); - if (Tk_InitOptions(interp, (char *) butPtr, optionTable, tkwin) + if (Tk_InitOptions(interp, butPtr, optionTable, tkwin) != TCL_OK) { Tk_DestroyWindow(butPtr->tkwin); return TCL_ERROR; @@ -810,7 +810,7 @@ ButtonWidgetObjCmd( Tcl_WrongNumArgs(interp, 1, objv, "cget option"); goto error; } - objPtr = Tk_GetOptionValue(interp, (char *) butPtr, + objPtr = Tk_GetOptionValue(interp, butPtr, butPtr->optionTable, objv[2], butPtr->tkwin); if (objPtr == NULL) { goto error; @@ -820,7 +820,7 @@ ButtonWidgetObjCmd( case COMMAND_CONFIGURE: if (objc <= 3) { - objPtr = Tk_GetOptionInfo(interp, (char *) butPtr, + objPtr = Tk_GetOptionInfo(interp, butPtr, butPtr->optionTable, (objc == 3) ? objv[2] : NULL, butPtr->tkwin); if (objPtr == NULL) { @@ -1068,7 +1068,7 @@ ConfigureButton( * First pass: set options to new values. */ - if (Tk_SetOptions(interp, (char *) butPtr, + if (Tk_SetOptions(interp, butPtr, butPtr->optionTable, objc, objv, butPtr->tkwin, &savedOptions, NULL) != TCL_OK) { continue; diff --git a/generic/tkConfig.c b/generic/tkConfig.c index d0802f3..e8e85cd 100644 --- a/generic/tkConfig.c +++ b/generic/tkConfig.c @@ -381,7 +381,7 @@ int Tk_InitOptions( Tcl_Interp *interp, /* Interpreter for error reporting. NULL means * don't leave an error message. */ - char *recordPtr, /* Pointer to the record to configure. Note: + void *recordPtr, /* Pointer to the record to configure. Note: * the caller should have properly initialized * the record with NULL pointers for each * option value. */ @@ -1222,7 +1222,7 @@ int Tk_SetOptions( Tcl_Interp *interp, /* Interpreter for error reporting. If NULL, * then no error message is returned.*/ - char *recordPtr, /* The record to configure. */ + void *recordPtr, /* The record to configure. */ Tk_OptionTable optionTable, /* Describes valid options. */ int objc, /* The number of elements in objv. */ Tcl_Obj *const objv[], /* Contains one or more name-value pairs. */ @@ -1527,7 +1527,7 @@ Tk_FreeSavedOptions( /* ARGSUSED */ void Tk_FreeConfigOptions( - char *recordPtr, /* Record whose fields contain current values + void *recordPtr, /* Record whose fields contain current values * for options. */ Tk_OptionTable optionTable, /* Describes legal options. */ Tk_Window tkwin) /* Window associated with recordPtr; needed @@ -1713,7 +1713,7 @@ Tcl_Obj * Tk_GetOptionInfo( Tcl_Interp *interp, /* Interpreter for error reporting. If NULL, * then no error message is created. */ - char *recordPtr, /* Record whose fields contain current values + void *recordPtr, /* Record whose fields contain current values * for options. */ Tk_OptionTable optionTable, /* Describes all the legal options. */ Tcl_Obj *namePtr, /* If non-NULL, the string value selects a @@ -2001,7 +2001,7 @@ Tk_GetOptionValue( Tcl_Interp *interp, /* Interpreter for error reporting. If NULL * then no messages are provided for * errors. */ - char *recordPtr, /* Record whose fields contain current values + void *recordPtr, /* Record whose fields contain current values * for options. */ Tk_OptionTable optionTable, /* Describes legal options. */ Tcl_Obj *namePtr, /* Gives the command-line name for the option diff --git a/generic/tkDecls.h b/generic/tkDecls.h index 3b4677e..6666c2d 100644 --- a/generic/tkDecls.h +++ b/generic/tkDecls.h @@ -632,7 +632,7 @@ EXTERN void Tk_FreeBitmapFromObj(Tk_Window tkwin, /* 194 */ EXTERN void Tk_FreeColorFromObj(Tk_Window tkwin, Tcl_Obj *objPtr); /* 195 */ -EXTERN void Tk_FreeConfigOptions(char *recordPtr, +EXTERN void Tk_FreeConfigOptions(void *recordPtr, Tk_OptionTable optionToken, Tk_Window tkwin); /* 196 */ EXTERN void Tk_FreeSavedOptions(Tk_SavedOptions *savePtr); @@ -654,12 +654,12 @@ EXTERN XColor * Tk_GetColorFromObj(Tk_Window tkwin, Tcl_Obj *objPtr); /* 203 */ EXTERN Tk_Cursor Tk_GetCursorFromObj(Tk_Window tkwin, Tcl_Obj *objPtr); /* 204 */ -EXTERN Tcl_Obj * Tk_GetOptionInfo(Tcl_Interp *interp, char *recordPtr, +EXTERN Tcl_Obj * Tk_GetOptionInfo(Tcl_Interp *interp, void *recordPtr, Tk_OptionTable optionTable, Tcl_Obj *namePtr, Tk_Window tkwin); /* 205 */ EXTERN Tcl_Obj * Tk_GetOptionValue(Tcl_Interp *interp, - char *recordPtr, Tk_OptionTable optionTable, + void *recordPtr, Tk_OptionTable optionTable, Tcl_Obj *namePtr, Tk_Window tkwin); /* 206 */ EXTERN int Tk_GetJustifyFromObj(Tcl_Interp *interp, @@ -679,7 +679,7 @@ EXTERN int Tk_GetScrollInfoObj(Tcl_Interp *interp, int objc, Tcl_Obj *const objv[], double *dblPtr, int *intPtr); /* 211 */ -EXTERN int Tk_InitOptions(Tcl_Interp *interp, char *recordPtr, +EXTERN int Tk_InitOptions(Tcl_Interp *interp, void *recordPtr, Tk_OptionTable optionToken, Tk_Window tkwin); /* 212 */ EXTERN void Tk_MainEx(int argc, char **argv, @@ -688,7 +688,7 @@ EXTERN void Tk_MainEx(int argc, char **argv, /* 213 */ EXTERN void Tk_RestoreSavedOptions(Tk_SavedOptions *savePtr); /* 214 */ -EXTERN int Tk_SetOptions(Tcl_Interp *interp, char *recordPtr, +EXTERN int Tk_SetOptions(Tcl_Interp *interp, void *recordPtr, Tk_OptionTable optionTable, int objc, Tcl_Obj *const objv[], Tk_Window tkwin, Tk_SavedOptions *savePtr, int *maskPtr); @@ -832,22 +832,22 @@ EXTERN Tk_StyledElement Tk_GetStyledElement(Tk_Style style, int elementId, Tk_OptionTable optionTable); /* 261 */ EXTERN void Tk_GetElementSize(Tk_Style style, - Tk_StyledElement element, char *recordPtr, + Tk_StyledElement element, void *recordPtr, Tk_Window tkwin, int width, int height, int inner, int *widthPtr, int *heightPtr); /* 262 */ EXTERN void Tk_GetElementBox(Tk_Style style, - Tk_StyledElement element, char *recordPtr, + Tk_StyledElement element, void *recordPtr, Tk_Window tkwin, int x, int y, int width, int height, int inner, int *xPtr, int *yPtr, int *widthPtr, int *heightPtr); /* 263 */ EXTERN int Tk_GetElementBorderWidth(Tk_Style style, - Tk_StyledElement element, char *recordPtr, + Tk_StyledElement element, void *recordPtr, Tk_Window tkwin); /* 264 */ EXTERN void Tk_DrawElement(Tk_Style style, - Tk_StyledElement element, char *recordPtr, + Tk_StyledElement element, void *recordPtr, Tk_Window tkwin, Drawable d, int x, int y, int width, int height, int state); /* 265 */ @@ -1085,7 +1085,7 @@ typedef struct TkStubs { void (*tk_Free3DBorderFromObj) (Tk_Window tkwin, Tcl_Obj *objPtr); /* 192 */ void (*tk_FreeBitmapFromObj) (Tk_Window tkwin, Tcl_Obj *objPtr); /* 193 */ void (*tk_FreeColorFromObj) (Tk_Window tkwin, Tcl_Obj *objPtr); /* 194 */ - void (*tk_FreeConfigOptions) (char *recordPtr, Tk_OptionTable optionToken, Tk_Window tkwin); /* 195 */ + void (*tk_FreeConfigOptions) (void *recordPtr, Tk_OptionTable optionToken, Tk_Window tkwin); /* 195 */ void (*tk_FreeSavedOptions) (Tk_SavedOptions *savePtr); /* 196 */ void (*tk_FreeCursorFromObj) (Tk_Window tkwin, Tcl_Obj *objPtr); /* 197 */ void (*tk_FreeFontFromObj) (Tk_Window tkwin, Tcl_Obj *objPtr); /* 198 */ @@ -1094,17 +1094,17 @@ typedef struct TkStubs { Pixmap (*tk_GetBitmapFromObj) (Tk_Window tkwin, Tcl_Obj *objPtr); /* 201 */ XColor * (*tk_GetColorFromObj) (Tk_Window tkwin, Tcl_Obj *objPtr); /* 202 */ Tk_Cursor (*tk_GetCursorFromObj) (Tk_Window tkwin, Tcl_Obj *objPtr); /* 203 */ - Tcl_Obj * (*tk_GetOptionInfo) (Tcl_Interp *interp, char *recordPtr, Tk_OptionTable optionTable, Tcl_Obj *namePtr, Tk_Window tkwin); /* 204 */ - Tcl_Obj * (*tk_GetOptionValue) (Tcl_Interp *interp, char *recordPtr, Tk_OptionTable optionTable, Tcl_Obj *namePtr, Tk_Window tkwin); /* 205 */ + Tcl_Obj * (*tk_GetOptionInfo) (Tcl_Interp *interp, void *recordPtr, Tk_OptionTable optionTable, Tcl_Obj *namePtr, Tk_Window tkwin); /* 204 */ + Tcl_Obj * (*tk_GetOptionValue) (Tcl_Interp *interp, void *recordPtr, Tk_OptionTable optionTable, Tcl_Obj *namePtr, Tk_Window tkwin); /* 205 */ int (*tk_GetJustifyFromObj) (Tcl_Interp *interp, Tcl_Obj *objPtr, Tk_Justify *justifyPtr); /* 206 */ int (*tk_GetMMFromObj) (Tcl_Interp *interp, Tk_Window tkwin, Tcl_Obj *objPtr, double *doublePtr); /* 207 */ int (*tk_GetPixelsFromObj) (Tcl_Interp *interp, Tk_Window tkwin, Tcl_Obj *objPtr, int *intPtr); /* 208 */ int (*tk_GetReliefFromObj) (Tcl_Interp *interp, Tcl_Obj *objPtr, int *resultPtr); /* 209 */ int (*tk_GetScrollInfoObj) (Tcl_Interp *interp, int objc, Tcl_Obj *const objv[], double *dblPtr, int *intPtr); /* 210 */ - int (*tk_InitOptions) (Tcl_Interp *interp, char *recordPtr, Tk_OptionTable optionToken, Tk_Window tkwin); /* 211 */ + int (*tk_InitOptions) (Tcl_Interp *interp, void *recordPtr, Tk_OptionTable optionToken, Tk_Window tkwin); /* 211 */ void (*tk_MainEx) (int argc, char **argv, Tcl_AppInitProc *appInitProc, Tcl_Interp *interp); /* 212 */ void (*tk_RestoreSavedOptions) (Tk_SavedOptions *savePtr); /* 213 */ - int (*tk_SetOptions) (Tcl_Interp *interp, char *recordPtr, Tk_OptionTable optionTable, int objc, Tcl_Obj *const objv[], Tk_Window tkwin, Tk_SavedOptions *savePtr, int *maskPtr); /* 214 */ + int (*tk_SetOptions) (Tcl_Interp *interp, void *recordPtr, Tk_OptionTable optionTable, int objc, Tcl_Obj *const objv[], Tk_Window tkwin, Tk_SavedOptions *savePtr, int *maskPtr); /* 214 */ void (*tk_InitConsoleChannels) (Tcl_Interp *interp); /* 215 */ int (*tk_CreateConsoleWindow) (Tcl_Interp *interp); /* 216 */ void (*tk_CreateSmoothMethod) (Tcl_Interp *interp, const Tk_SmoothMethod *method); /* 217 */ @@ -1151,10 +1151,10 @@ typedef struct TkStubs { Tk_Style (*tk_GetStyleFromObj) (Tcl_Obj *objPtr); /* 258 */ void (*tk_FreeStyleFromObj) (Tcl_Obj *objPtr); /* 259 */ Tk_StyledElement (*tk_GetStyledElement) (Tk_Style style, int elementId, Tk_OptionTable optionTable); /* 260 */ - void (*tk_GetElementSize) (Tk_Style style, Tk_StyledElement element, char *recordPtr, Tk_Window tkwin, int width, int height, int inner, int *widthPtr, int *heightPtr); /* 261 */ - void (*tk_GetElementBox) (Tk_Style style, Tk_StyledElement element, char *recordPtr, Tk_Window tkwin, int x, int y, int width, int height, int inner, int *xPtr, int *yPtr, int *widthPtr, int *heightPtr); /* 262 */ - int (*tk_GetElementBorderWidth) (Tk_Style style, Tk_StyledElement element, char *recordPtr, Tk_Window tkwin); /* 263 */ - void (*tk_DrawElement) (Tk_Style style, Tk_StyledElement element, char *recordPtr, Tk_Window tkwin, Drawable d, int x, int y, int width, int height, int state); /* 264 */ + void (*tk_GetElementSize) (Tk_Style style, Tk_StyledElement element, void *recordPtr, Tk_Window tkwin, int width, int height, int inner, int *widthPtr, int *heightPtr); /* 261 */ + void (*tk_GetElementBox) (Tk_Style style, Tk_StyledElement element, void *recordPtr, Tk_Window tkwin, int x, int y, int width, int height, int inner, int *xPtr, int *yPtr, int *widthPtr, int *heightPtr); /* 262 */ + int (*tk_GetElementBorderWidth) (Tk_Style style, Tk_StyledElement element, void *recordPtr, Tk_Window tkwin); /* 263 */ + void (*tk_DrawElement) (Tk_Style style, Tk_StyledElement element, void *recordPtr, Tk_Window tkwin, Drawable d, int x, int y, int width, int height, int state); /* 264 */ int (*tk_PhotoExpand) (Tcl_Interp *interp, Tk_PhotoHandle handle, int width, int height); /* 265 */ int (*tk_PhotoPutBlock) (Tcl_Interp *interp, Tk_PhotoHandle handle, Tk_PhotoImageBlock *blockPtr, int x, int y, int width, int height, int compRule); /* 266 */ int (*tk_PhotoPutZoomedBlock) (Tcl_Interp *interp, Tk_PhotoHandle handle, Tk_PhotoImageBlock *blockPtr, int x, int y, int width, int height, int zoomX, int zoomY, int subsampleX, int subsampleY, int compRule); /* 267 */ diff --git a/generic/tkEntry.c b/generic/tkEntry.c index 600bc44..6a969bf 100644 --- a/generic/tkEntry.c +++ b/generic/tkEntry.c @@ -566,7 +566,7 @@ Tk_EntryObjCmd( Tk_CreateSelHandler(entryPtr->tkwin, XA_PRIMARY, XA_STRING, EntryFetchSelection, entryPtr, XA_STRING); - if ((Tk_InitOptions(interp, (char *) entryPtr, optionTable, tkwin) + if ((Tk_InitOptions(interp, entryPtr, optionTable, tkwin) != TCL_OK) || (ConfigureEntry(interp, entryPtr, objc-2, objv+2) != TCL_OK)) { Tk_DestroyWindow(entryPtr->tkwin); @@ -654,7 +654,7 @@ EntryWidgetObjCmd( goto error; } - objPtr = Tk_GetOptionValue(interp, (char *) entryPtr, + objPtr = Tk_GetOptionValue(interp, entryPtr, entryPtr->optionTable, objv[2], entryPtr->tkwin); if (objPtr == NULL) { goto error; @@ -664,7 +664,7 @@ EntryWidgetObjCmd( case COMMAND_CONFIGURE: if (objc <= 3) { - objPtr = Tk_GetOptionInfo(interp, (char *) entryPtr, + objPtr = Tk_GetOptionInfo(interp, entryPtr, entryPtr->optionTable, (objc == 3) ? objv[2] : NULL, entryPtr->tkwin); @@ -1151,7 +1151,7 @@ ConfigureEntry( * First pass: set options to new values. */ - if (Tk_SetOptions(interp, (char *) entryPtr, + if (Tk_SetOptions(interp, entryPtr, entryPtr->optionTable, objc, objv, entryPtr->tkwin, &savedOptions, NULL) != TCL_OK) { continue; @@ -3759,7 +3759,7 @@ Tk_SpinboxObjCmd( Tk_CreateSelHandler(entryPtr->tkwin, XA_PRIMARY, XA_STRING, EntryFetchSelection, entryPtr, XA_STRING); - if (Tk_InitOptions(interp, (char *) sbPtr, optionTable, tkwin) + if (Tk_InitOptions(interp, sbPtr, optionTable, tkwin) != TCL_OK) { Tk_DestroyWindow(entryPtr->tkwin); return TCL_ERROR; @@ -3854,7 +3854,7 @@ SpinboxWidgetObjCmd( goto error; } - objPtr = Tk_GetOptionValue(interp, (char *) entryPtr, + objPtr = Tk_GetOptionValue(interp, entryPtr, entryPtr->optionTable, objv[2], entryPtr->tkwin); if (objPtr == NULL) { goto error; @@ -3864,7 +3864,7 @@ SpinboxWidgetObjCmd( case SB_CMD_CONFIGURE: if (objc <= 3) { - objPtr = Tk_GetOptionInfo(interp, (char *) entryPtr, + objPtr = Tk_GetOptionInfo(interp, entryPtr, entryPtr->optionTable, (objc == 3) ? objv[2] : NULL, entryPtr->tkwin); if (objPtr == NULL) { diff --git a/generic/tkFrame.c b/generic/tkFrame.c index 1ed3268..53c019c 100644 --- a/generic/tkFrame.c +++ b/generic/tkFrame.c @@ -683,7 +683,7 @@ CreateFrame( mask |= ActivateMask; } Tk_CreateEventHandler(newWin, mask, FrameEventProc, framePtr); - if ((Tk_InitOptions(interp, (char *) framePtr, optionTable, newWin) + if ((Tk_InitOptions(interp, framePtr, optionTable, newWin) != TCL_OK) || (ConfigureFrame(interp, framePtr, objc-2, objv+2) != TCL_OK)) { goto error; @@ -764,7 +764,7 @@ FrameWidgetObjCmd( result = TCL_ERROR; goto done; } - objPtr = Tk_GetOptionValue(interp, (char *) framePtr, + objPtr = Tk_GetOptionValue(interp, framePtr, framePtr->optionTable, objv[2], framePtr->tkwin); if (objPtr == NULL) { result = TCL_ERROR; @@ -774,7 +774,7 @@ FrameWidgetObjCmd( break; case FRAME_CONFIGURE: if (objc <= 3) { - objPtr = Tk_GetOptionInfo(interp, (char *) framePtr, + objPtr = Tk_GetOptionInfo(interp, framePtr, framePtr->optionTable, (objc == 3) ? objv[2] : NULL, framePtr->tkwin); if (objPtr == NULL) { @@ -962,7 +962,7 @@ ConfigureFrame( if (framePtr->type == TYPE_LABELFRAME) { oldWindow = labelframePtr->labelWin; } - if (Tk_SetOptions(interp, (char *) framePtr, + if (Tk_SetOptions(interp, framePtr, framePtr->optionTable, objc, objv, framePtr->tkwin, &savedOptions, NULL) != TCL_OK) { if (oldMenuName != NULL) { diff --git a/generic/tkListbox.c b/generic/tkListbox.c index 0fe8e43..b3b8ce7 100644 --- a/generic/tkListbox.c +++ b/generic/tkListbox.c @@ -567,7 +567,7 @@ Tk_ListboxObjCmd( ListboxEventProc, listPtr); Tk_CreateSelHandler(listPtr->tkwin, XA_PRIMARY, XA_STRING, ListboxFetchSelection, listPtr, XA_STRING); - if (Tk_InitOptions(interp, (char *)listPtr, + if (Tk_InitOptions(interp, listPtr, optionTables->listboxOptionTable, tkwin) != TCL_OK) { Tk_DestroyWindow(listPtr->tkwin); return TCL_ERROR; @@ -682,7 +682,7 @@ ListboxWidgetObjCmd( break; } - objPtr = Tk_GetOptionValue(interp, (char *) listPtr, + objPtr = Tk_GetOptionValue(interp, listPtr, listPtr->optionTable, objv[2], listPtr->tkwin); if (objPtr == NULL) { result = TCL_ERROR; @@ -694,7 +694,7 @@ ListboxWidgetObjCmd( case COMMAND_CONFIGURE: if (objc <= 3) { - objPtr = Tk_GetOptionInfo(interp, (char *) listPtr, + objPtr = Tk_GetOptionInfo(interp, listPtr, listPtr->optionTable, (objc == 3) ? objv[2] : NULL, listPtr->tkwin); if (objPtr == NULL) { @@ -926,7 +926,7 @@ ListboxWidgetObjCmd( attrPtr = ListboxGetItemAttributes(interp, listPtr, index); if (objc <= 4) { - objPtr = Tk_GetOptionInfo(interp, (char *) attrPtr, + objPtr = Tk_GetOptionInfo(interp, attrPtr, listPtr->itemAttrOptionTable, (objc == 4) ? objv[3] : NULL, listPtr->tkwin); if (objPtr == NULL) { @@ -1416,7 +1416,7 @@ ListboxGetItemAttributes( attrs->selBorder = NULL; attrs->fgColor = NULL; attrs->selFgColor = NULL; - Tk_InitOptions(interp, (char *)attrs, listPtr->itemAttrOptionTable, + Tk_InitOptions(interp, attrs, listPtr->itemAttrOptionTable, listPtr->tkwin); Tcl_SetHashValue(entry, attrs); } else { @@ -1579,7 +1579,7 @@ ConfigureListbox( * First pass: set options to new values. */ - if (Tk_SetOptions(interp, (char *) listPtr, + if (Tk_SetOptions(interp, listPtr, listPtr->optionTable, objc, objv, listPtr->tkwin, &savedOptions, NULL) != TCL_OK) { continue; @@ -1725,7 +1725,7 @@ ConfigureListboxItem( { Tk_SavedOptions savedOptions; - if (Tk_SetOptions(interp, (char *)attrs, + if (Tk_SetOptions(interp, attrs, listPtr->itemAttrOptionTable, objc, objv, listPtr->tkwin, &savedOptions, NULL) != TCL_OK) { Tk_RestoreSavedOptions(&savedOptions); diff --git a/generic/tkMenu.c b/generic/tkMenu.c index 7d986a5..14d89cd 100644 --- a/generic/tkMenu.c +++ b/generic/tkMenu.c @@ -468,7 +468,7 @@ Tk_MenuObjCmd( Tk_CreateEventHandler(newWin, ExposureMask|StructureNotifyMask|ActivateMask, TkMenuEventProc, menuPtr); - if (Tk_InitOptions(interp, (char *) menuPtr, + if (Tk_InitOptions(interp, menuPtr, tsdPtr->menuOptionTable, menuPtr->tkwin) != TCL_OK) { Tk_DestroyWindow(menuPtr->tkwin); @@ -675,7 +675,7 @@ MenuWidgetObjCmd( Tcl_WrongNumArgs(interp, 2, objv, "option"); goto error; } - resultPtr = Tk_GetOptionValue(interp, (char *) menuPtr, + resultPtr = Tk_GetOptionValue(interp, menuPtr, tsdPtr->menuOptionTable, objv[2], menuPtr->tkwin); if (resultPtr == NULL) { @@ -695,7 +695,7 @@ MenuWidgetObjCmd( Tcl_Obj *resultPtr; if (objc == 2) { - resultPtr = Tk_GetOptionInfo(interp, (char *) menuPtr, + resultPtr = Tk_GetOptionInfo(interp, menuPtr, tsdPtr->menuOptionTable, NULL, menuPtr->tkwin); if (resultPtr == NULL) { @@ -705,7 +705,7 @@ MenuWidgetObjCmd( Tcl_SetObjResult(interp, resultPtr); } } else if (objc == 3) { - resultPtr = Tk_GetOptionInfo(interp, (char *) menuPtr, + resultPtr = Tk_GetOptionInfo(interp, menuPtr, tsdPtr->menuOptionTable, objv[2], menuPtr->tkwin); if (resultPtr == NULL) { @@ -779,7 +779,7 @@ MenuWidgetObjCmd( } mePtr = menuPtr->entries[index]; Tcl_Preserve(mePtr); - resultPtr = Tk_GetOptionValue(interp, (char *) mePtr, + resultPtr = Tk_GetOptionValue(interp, mePtr, mePtr->optionTable, objv[3], menuPtr->tkwin); Tcl_Release(mePtr); if (resultPtr == NULL) { @@ -805,7 +805,7 @@ MenuWidgetObjCmd( mePtr = menuPtr->entries[index]; Tcl_Preserve(mePtr); if (objc == 3) { - resultPtr = Tk_GetOptionInfo(interp, (char *) mePtr, + resultPtr = Tk_GetOptionInfo(interp, mePtr, mePtr->optionTable, NULL, menuPtr->tkwin); if (resultPtr == NULL) { result = TCL_ERROR; @@ -814,7 +814,7 @@ MenuWidgetObjCmd( Tcl_SetObjResult(interp, resultPtr); } } else if (objc == 4) { - resultPtr = Tk_GetOptionInfo(interp, (char *) mePtr, + resultPtr = Tk_GetOptionInfo(interp, mePtr, mePtr->optionTable, objv[3], menuPtr->tkwin); if (resultPtr == NULL) { result = TCL_ERROR; @@ -1531,7 +1531,7 @@ ConfigureMenu( for (menuListPtr = menuPtr->masterMenuPtr; menuListPtr != NULL; menuListPtr = menuListPtr->nextInstancePtr) { menuListPtr->errorStructPtr = ckalloc(sizeof(Tk_SavedOptions)); - result = Tk_SetOptions(interp, (char *) menuListPtr, + result = Tk_SetOptions(interp, menuListPtr, tsdPtr->menuOptionTable, objc, objv, menuListPtr->tkwin, menuListPtr->errorStructPtr, NULL); if (result != TCL_OK) { @@ -1927,7 +1927,7 @@ ConfigureMenuEntry( result = TCL_OK; if (menuPtr->tkwin != NULL) { - if (Tk_SetOptions(menuPtr->interp, (char *) mePtr, + if (Tk_SetOptions(menuPtr->interp, mePtr, mePtr->optionTable, objc, objv, menuPtr->tkwin, &errorStruct, NULL) != TCL_OK) { return TCL_ERROR; @@ -2301,7 +2301,7 @@ MenuNewEntry( mePtr->entryFlags = 0; mePtr->index = index; mePtr->nextCascadePtr = NULL; - if (Tk_InitOptions(menuPtr->interp, (char *) mePtr, + if (Tk_InitOptions(menuPtr->interp, mePtr, mePtr->optionTable, menuPtr->tkwin) != TCL_OK) { ckfree(mePtr); return NULL; diff --git a/generic/tkMenubutton.c b/generic/tkMenubutton.c index 2c1676c..125fe72 100644 --- a/generic/tkMenubutton.c +++ b/generic/tkMenubutton.c @@ -308,7 +308,7 @@ Tk_MenubuttonObjCmd( ExposureMask|StructureNotifyMask|FocusChangeMask, MenuButtonEventProc, mbPtr); - if (Tk_InitOptions(interp, (char *) mbPtr, optionTable, tkwin) != TCL_OK) { + if (Tk_InitOptions(interp, mbPtr, optionTable, tkwin) != TCL_OK) { Tk_DestroyWindow(mbPtr->tkwin); return TCL_ERROR; } @@ -369,7 +369,7 @@ MenuButtonWidgetObjCmd( goto error; } - objPtr = Tk_GetOptionValue(interp, (char *) mbPtr, + objPtr = Tk_GetOptionValue(interp, mbPtr, mbPtr->optionTable, objv[2], mbPtr->tkwin); if (objPtr == NULL) { goto error; @@ -379,7 +379,7 @@ MenuButtonWidgetObjCmd( case COMMAND_CONFIGURE: if (objc <= 3) { - objPtr = Tk_GetOptionInfo(interp, (char *) mbPtr, + objPtr = Tk_GetOptionInfo(interp, mbPtr, mbPtr->optionTable, (objc == 3) ? objv[2] : NULL, mbPtr->tkwin); if (objPtr == NULL) { @@ -524,7 +524,7 @@ ConfigureMenuButton( * First pass: set options to new values. */ - if (Tk_SetOptions(interp, (char *) mbPtr, + if (Tk_SetOptions(interp, mbPtr, mbPtr->optionTable, objc, objv, mbPtr->tkwin, &savedOptions, NULL) != TCL_OK) { continue; diff --git a/generic/tkMessage.c b/generic/tkMessage.c index d6853e5..c009fe7 100644 --- a/generic/tkMessage.c +++ b/generic/tkMessage.c @@ -267,7 +267,7 @@ Tk_MessageObjCmd( Tk_CreateEventHandler(msgPtr->tkwin, ExposureMask|StructureNotifyMask|FocusChangeMask, MessageEventProc, msgPtr); - if (Tk_InitOptions(interp, (char *)msgPtr, optionTable, tkwin) != TCL_OK) { + if (Tk_InitOptions(interp, msgPtr, optionTable, tkwin) != TCL_OK) { Tk_DestroyWindow(msgPtr->tkwin); return TCL_ERROR; } @@ -331,7 +331,7 @@ MessageWidgetObjCmd( Tcl_WrongNumArgs(interp, 2, objv, "option"); result = TCL_ERROR; } else { - objPtr = Tk_GetOptionValue(interp, (char *) msgPtr, + objPtr = Tk_GetOptionValue(interp, msgPtr, msgPtr->optionTable, objv[2], msgPtr->tkwin); if (objPtr == NULL) { result = TCL_ERROR; @@ -343,7 +343,7 @@ MessageWidgetObjCmd( break; case MESSAGE_CONFIGURE: if (objc <= 3) { - objPtr = Tk_GetOptionInfo(interp, (char *) msgPtr, + objPtr = Tk_GetOptionInfo(interp, msgPtr, msgPtr->optionTable, (objc == 3) ? objv[2] : NULL, msgPtr->tkwin); if (objPtr == NULL) { @@ -455,7 +455,7 @@ ConfigureMessage( MessageTextVarProc, msgPtr); } - if (Tk_SetOptions(interp, (char *) msgPtr, msgPtr->optionTable, objc, objv, + if (Tk_SetOptions(interp, msgPtr, msgPtr->optionTable, objc, objv, msgPtr->tkwin, &savedOptions, NULL) != TCL_OK) { Tk_RestoreSavedOptions(&savedOptions); return TCL_ERROR; diff --git a/generic/tkPanedWindow.c b/generic/tkPanedWindow.c index dafadb0..6fd60e9 100644 --- a/generic/tkPanedWindow.c +++ b/generic/tkPanedWindow.c @@ -459,7 +459,7 @@ Tk_PanedWindowObjCmd( Tcl_Preserve(pwPtr->tkwin); - if (Tk_InitOptions(interp, (char *) pwPtr, pwOpts->pwOptions, + if (Tk_InitOptions(interp, pwPtr, pwOpts->pwOptions, tkwin) != TCL_OK) { Tk_DestroyWindow(pwPtr->tkwin); return TCL_ERROR; @@ -578,7 +578,7 @@ PanedWindowWidgetObjCmd( result = TCL_ERROR; break; } - resultObj = Tk_GetOptionValue(interp, (char *) pwPtr, + resultObj = Tk_GetOptionValue(interp, pwPtr, pwPtr->optionTable, objv[2], pwPtr->tkwin); if (resultObj == NULL) { result = TCL_ERROR; @@ -590,7 +590,7 @@ PanedWindowWidgetObjCmd( case PW_CONFIGURE: resultObj = NULL; if (objc <= 3) { - resultObj = Tk_GetOptionInfo(interp, (char *) pwPtr, + resultObj = Tk_GetOptionInfo(interp, pwPtr, pwPtr->optionTable, (objc == 3) ? objv[2] : NULL, pwPtr->tkwin); if (resultObj == NULL) { @@ -669,7 +669,7 @@ PanedWindowWidgetObjCmd( for (i = 0; i < pwPtr->numSlaves; i++) { if (pwPtr->slaves[i]->tkwin == tkwin) { resultObj = Tk_GetOptionValue(interp, - (char *) pwPtr->slaves[i], pwPtr->slaveOpts, + pwPtr->slaves[i], pwPtr->slaveOpts, objv[3], tkwin); } } @@ -709,7 +709,7 @@ PanedWindowWidgetObjCmd( for (i = 0; i < pwPtr->numSlaves; i++) { if (pwPtr->slaves[i]->tkwin == tkwin) { resultObj = Tk_GetOptionInfo(interp, - (char *) pwPtr->slaves[i], pwPtr->slaveOpts, + pwPtr->slaves[i], pwPtr->slaveOpts, (objc == 4) ? objv[3] : NULL, pwPtr->tkwin); if (resultObj == NULL) { @@ -848,7 +848,7 @@ ConfigureSlaves( */ memset((void *)&options, 0, sizeof(Slave)); - if (Tk_SetOptions(interp, (char *) &options, pwPtr->slaveOpts, + if (Tk_SetOptions(interp, &options, pwPtr->slaveOpts, objc - firstOptionArg, objv + firstOptionArg, pwPtr->tkwin, NULL, NULL) != TCL_OK) { return TCL_ERROR; @@ -925,7 +925,7 @@ ConfigureSlaves( found = 0; for (j = 0; j < pwPtr->numSlaves; j++) { if (pwPtr->slaves[j] != NULL && pwPtr->slaves[j]->tkwin == tkwin) { - Tk_SetOptions(interp, (char *) pwPtr->slaves[j], + Tk_SetOptions(interp, pwPtr->slaves[j], pwPtr->slaveOpts, objc - firstOptionArg, objv + firstOptionArg, pwPtr->tkwin, NULL, NULL); if (pwPtr->slaves[j]->minSize < 0) { @@ -972,9 +972,9 @@ ConfigureSlaves( slavePtr = ckalloc(sizeof(Slave)); memset(slavePtr, 0, sizeof(Slave)); - Tk_InitOptions(interp, (char *)slavePtr, pwPtr->slaveOpts, + Tk_InitOptions(interp, slavePtr, pwPtr->slaveOpts, pwPtr->tkwin); - Tk_SetOptions(interp, (char *)slavePtr, pwPtr->slaveOpts, + Tk_SetOptions(interp, slavePtr, pwPtr->slaveOpts, objc - firstOptionArg, objv + firstOptionArg, pwPtr->tkwin, NULL, NULL); slavePtr->tkwin = tkwin; @@ -1249,7 +1249,7 @@ ConfigurePanedWindow( Tk_SavedOptions savedOptions; int typemask = 0; - if (Tk_SetOptions(interp, (char *) pwPtr, pwPtr->optionTable, objc, objv, + if (Tk_SetOptions(interp, pwPtr, pwPtr->optionTable, objc, objv, pwPtr->tkwin, &savedOptions, &typemask) != TCL_OK) { Tk_RestoreSavedOptions(&savedOptions); return TCL_ERROR; diff --git a/generic/tkPlace.c b/generic/tkPlace.c index 9fa406a..e627794 100644 --- a/generic/tkPlace.c +++ b/generic/tkPlace.c @@ -290,7 +290,7 @@ Tk_PlaceObjCmd( if (slavePtr == NULL) { return TCL_OK; } - objPtr = Tk_GetOptionInfo(interp, (char *) slavePtr, optionTable, + objPtr = Tk_GetOptionInfo(interp, slavePtr, optionTable, (objc == 4) ? objv[3] : NULL, tkwin); if (objPtr == NULL) { return TCL_ERROR; @@ -628,7 +628,7 @@ ConfigureSlave( slavePtr = CreateSlave(tkwin, table); - if (Tk_SetOptions(interp, (char *) slavePtr, table, objc, objv, + if (Tk_SetOptions(interp, slavePtr, table, objc, objv, slavePtr->tkwin, &savedOptions, &mask) != TCL_OK) { goto error; } diff --git a/generic/tkScale.c b/generic/tkScale.c index 5733c8a..8b016a2 100644 --- a/generic/tkScale.c +++ b/generic/tkScale.c @@ -300,7 +300,7 @@ Tk_ScaleObjCmd( ExposureMask|StructureNotifyMask|FocusChangeMask, ScaleEventProc, scalePtr); - if ((Tk_InitOptions(interp, (char *) scalePtr, optionTable, tkwin) + if ((Tk_InitOptions(interp, scalePtr, optionTable, tkwin) != TCL_OK) || (ConfigureScale(interp, scalePtr, objc - 2, objv + 2) != TCL_OK)) { Tk_DestroyWindow(scalePtr->tkwin); @@ -363,7 +363,7 @@ ScaleWidgetObjCmd( Tcl_WrongNumArgs(interp, 1, objv, "cget option"); goto error; } - objPtr = Tk_GetOptionValue(interp, (char *) scalePtr, + objPtr = Tk_GetOptionValue(interp, scalePtr, scalePtr->optionTable, objv[2], scalePtr->tkwin); if (objPtr == NULL) { goto error; @@ -372,7 +372,7 @@ ScaleWidgetObjCmd( break; case COMMAND_CONFIGURE: if (objc <= 3) { - objPtr = Tk_GetOptionInfo(interp, (char *) scalePtr, + objPtr = Tk_GetOptionInfo(interp, scalePtr, scalePtr->optionTable, (objc == 3) ? objv[2] : NULL, scalePtr->tkwin); if (objPtr == NULL) { @@ -582,7 +582,7 @@ ConfigureScale( * First pass: set options to new values. */ - if (Tk_SetOptions(interp, (char *) scalePtr, + if (Tk_SetOptions(interp, scalePtr, scalePtr->optionTable, objc, objv, scalePtr->tkwin, &savedOptions, NULL) != TCL_OK) { continue; diff --git a/generic/tkSquare.c b/generic/tkSquare.c index 36d2d6e..2a64dbb 100644 --- a/generic/tkSquare.c +++ b/generic/tkSquare.c @@ -172,7 +172,7 @@ SquareObjCmd( squarePtr->gc = None; squarePtr->optionTable = optionTable; - if (Tk_InitOptions(interp, (char *) squarePtr, optionTable, tkwin) + if (Tk_InitOptions(interp, squarePtr, optionTable, tkwin) != TCL_OK) { Tk_DestroyWindow(squarePtr->tkwin); ckfree(squarePtr); @@ -181,7 +181,7 @@ SquareObjCmd( Tk_CreateEventHandler(squarePtr->tkwin, ExposureMask|StructureNotifyMask, SquareObjEventProc, squarePtr); - if (Tk_SetOptions(interp, (char *) squarePtr, optionTable, objc - 2, + if (Tk_SetOptions(interp, squarePtr, optionTable, objc - 2, objv + 2, tkwin, NULL, NULL) != TCL_OK) { goto error; } @@ -250,7 +250,7 @@ SquareWidgetObjCmd( Tcl_WrongNumArgs(interp, 2, objv, "option"); goto error; } - resultObjPtr = Tk_GetOptionValue(interp, (char *) squarePtr, + resultObjPtr = Tk_GetOptionValue(interp, squarePtr, squarePtr->optionTable, objv[2], squarePtr->tkwin); if (resultObjPtr == NULL) { result = TCL_ERROR; @@ -261,19 +261,19 @@ SquareWidgetObjCmd( case SQUARE_CONFIGURE: resultObjPtr = NULL; if (objc == 2) { - resultObjPtr = Tk_GetOptionInfo(interp, (char *) squarePtr, + resultObjPtr = Tk_GetOptionInfo(interp, squarePtr, squarePtr->optionTable, NULL, squarePtr->tkwin); if (resultObjPtr == NULL) { result = TCL_ERROR; } } else if (objc == 3) { - resultObjPtr = Tk_GetOptionInfo(interp, (char *) squarePtr, + resultObjPtr = Tk_GetOptionInfo(interp, squarePtr, squarePtr->optionTable, objv[2], squarePtr->tkwin); if (resultObjPtr == NULL) { result = TCL_ERROR; } } else { - result = Tk_SetOptions(interp, (char *) squarePtr, + result = Tk_SetOptions(interp, squarePtr, squarePtr->optionTable, objc - 2, objv + 2, squarePtr->tkwin, NULL, NULL); if (result == TCL_OK) { diff --git a/generic/tkStyle.c b/generic/tkStyle.c index 10d2104..508a2c4 100644 --- a/generic/tkStyle.c +++ b/generic/tkStyle.c @@ -1076,7 +1076,7 @@ Tk_GetElementSize( Tk_Style style, /* The widget style. */ Tk_StyledElement element, /* The styled element, previously returned by * Tk_GetStyledElement. */ - char *recordPtr, /* The widget record. */ + void *recordPtr, /* The widget record. */ Tk_Window tkwin, /* The widget window. */ int width, int height, /* Requested size. */ int inner, /* If TRUE, compute the outer size according @@ -1117,7 +1117,7 @@ Tk_GetElementBox( Tk_Style style, /* The widget style. */ Tk_StyledElement element, /* The styled element, previously returned by * Tk_GetStyledElement. */ - char *recordPtr, /* The widget record. */ + void *recordPtr, /* The widget record. */ Tk_Window tkwin, /* The widget window. */ int x, int y, /* Top left corner of available area. */ int width, int height, /* Size of available area. */ @@ -1159,7 +1159,7 @@ Tk_GetElementBorderWidth( Tk_Style style, /* The widget style. */ Tk_StyledElement element, /* The styled element, previously returned by * Tk_GetStyledElement. */ - char *recordPtr, /* The widget record. */ + void *recordPtr, /* The widget record. */ Tk_Window tkwin) /* The widget window. */ { Style *stylePtr = (Style *) style; @@ -1190,7 +1190,7 @@ Tk_DrawElement( Tk_Style style, /* The widget style. */ Tk_StyledElement element, /* The styled element, previously returned by * Tk_GetStyledElement. */ - char *recordPtr, /* The widget record. */ + void *recordPtr, /* The widget record. */ Tk_Window tkwin, /* The widget window. */ Drawable d, /* Where to draw element. */ int x, int y, /* Top left corner of element. */ diff --git a/generic/tkTest.c b/generic/tkTest.c index e439cdc..effdcbe 100644 --- a/generic/tkTest.c +++ b/generic/tkTest.c @@ -675,7 +675,7 @@ TestobjconfigObjCmd( recordPtr->mmPtr = NULL; recordPtr->stringTablePtr = NULL; recordPtr->customPtr = NULL; - result = Tk_InitOptions(interp, (char *) recordPtr, optionTable, + result = Tk_InitOptions(interp, recordPtr, optionTable, tkwin); if (result == TCL_OK) { recordPtr->header.widgetCmd = Tcl_CreateObjCommand(interp, @@ -683,7 +683,7 @@ TestobjconfigObjCmd( (ClientData) recordPtr, TrivialCmdDeletedProc); Tk_CreateEventHandler(tkwin, StructureNotifyMask, TrivialEventProc, (ClientData) recordPtr); - result = Tk_SetOptions(interp, (char *) recordPtr, optionTable, + result = Tk_SetOptions(interp, recordPtr, optionTable, objc-3, objv+3, tkwin, NULL, NULL); if (result != TCL_OK) { Tk_DestroyWindow(tkwin); @@ -718,12 +718,12 @@ TestobjconfigObjCmd( recordPtr->header.tkwin = tkwin; recordPtr->base1ObjPtr = recordPtr->base2ObjPtr = NULL; recordPtr->extension3ObjPtr = recordPtr->extension4ObjPtr = NULL; - result = Tk_InitOptions(interp, (char *)recordPtr, optionTable, tkwin); + result = Tk_InitOptions(interp, recordPtr, optionTable, tkwin); if (result == TCL_OK) { - result = Tk_SetOptions(interp, (char *) recordPtr, optionTable, + result = Tk_SetOptions(interp, recordPtr, optionTable, objc-3, objv+3, tkwin, NULL, NULL); if (result != TCL_OK) { - Tk_FreeConfigOptions((char *) recordPtr, optionTable, tkwin); + Tk_FreeConfigOptions(recordPtr, optionTable, tkwin); } } if (result == TCL_OK) { @@ -772,9 +772,9 @@ TestobjconfigObjCmd( recordPtr->base1ObjPtr = recordPtr->base2ObjPtr = NULL; recordPtr->extension3ObjPtr = recordPtr->extension4ObjPtr = NULL; recordPtr->extension5ObjPtr = NULL; - result = Tk_InitOptions(interp, (char *)recordPtr, optionTable, tkwin); + result = Tk_InitOptions(interp, recordPtr, optionTable, tkwin); if (result == TCL_OK) { - result = Tk_SetOptions(interp, (char *) recordPtr, optionTable, + result = Tk_SetOptions(interp, recordPtr, optionTable, objc-3, objv+3, tkwin, NULL, NULL); if (result != TCL_OK) { Tk_FreeConfigOptions((char *) recordPtr, optionTable, tkwin); @@ -806,7 +806,7 @@ TestobjconfigObjCmd( widgetRecord.intPtr = NULL; optionTable = Tk_CreateOptionTable(interp, errorSpecs); tables[index] = optionTable; - return Tk_InitOptions(interp, (char *) &widgetRecord, optionTable, + return Tk_InitOptions(interp, &widgetRecord, optionTable, (Tk_Window) NULL); } @@ -954,7 +954,7 @@ TestobjconfigObjCmd( recordPtr->mm = 0.0; recordPtr->tkwin = NULL; recordPtr->custom = NULL; - result = Tk_InitOptions(interp, (char *) recordPtr, optionTable, + result = Tk_InitOptions(interp, recordPtr, optionTable, tkwin); if (result == TCL_OK) { recordPtr->header.widgetCmd = Tcl_CreateObjCommand(interp, @@ -962,7 +962,7 @@ TestobjconfigObjCmd( recordPtr, TrivialCmdDeletedProc); Tk_CreateEventHandler(tkwin, StructureNotifyMask, TrivialEventProc, recordPtr); - result = Tk_SetOptions(interp, (char *) recordPtr, optionTable, + result = Tk_SetOptions(interp, recordPtr, optionTable, objc - 3, objv + 3, tkwin, NULL, NULL); if (result != TCL_OK) { Tk_DestroyWindow(tkwin); @@ -1015,10 +1015,10 @@ TestobjconfigObjCmd( recordPtr->one = recordPtr->two = recordPtr->three = NULL; recordPtr->four = recordPtr->five = NULL; Tcl_SetObjResult(interp, objv[2]); - result = Tk_InitOptions(interp, (char *) recordPtr, + result = Tk_InitOptions(interp, recordPtr, recordPtr->header.optionTable, (Tk_Window) NULL); if (result == TCL_OK) { - result = Tk_SetOptions(interp, (char *) recordPtr, + result = Tk_SetOptions(interp, recordPtr, recordPtr->header.optionTable, objc - 3, objv + 3, (Tk_Window) NULL, NULL, NULL); if (result == TCL_OK) { @@ -1026,7 +1026,7 @@ TestobjconfigObjCmd( Tcl_GetString(objv[2]), TrivialConfigObjCmd, (ClientData) recordPtr, TrivialCmdDeletedProc); } else { - Tk_FreeConfigOptions((char *) recordPtr, + Tk_FreeConfigOptions(recordPtr, recordPtr->header.optionTable, (Tk_Window) NULL); } } @@ -1055,8 +1055,8 @@ TestobjconfigObjCmd( Tk_SetClass(tkwin, "Config"); optionTable = Tk_CreateOptionTable(interp, errorSpecs); tables[index] = optionTable; - Tk_InitOptions(interp, (char *) &record, optionTable, tkwin); - if (Tk_SetOptions(interp, (char *) &record, optionTable, 1, + Tk_InitOptions(interp, &record, optionTable, tkwin); + if (Tk_SetOptions(interp, &record, optionTable, 1, &newObjPtr, tkwin, NULL, NULL) != TCL_OK) { result = TCL_ERROR; } @@ -1093,10 +1093,10 @@ TestobjconfigObjCmd( recordPtr->header.tkwin = tkwin; recordPtr->windowPtr = NULL; - result = Tk_InitOptions(interp, (char *) recordPtr, + result = Tk_InitOptions(interp, recordPtr, recordPtr->header.optionTable, tkwin); if (result == TCL_OK) { - result = Tk_SetOptions(interp, (char *) recordPtr, + result = Tk_SetOptions(interp, recordPtr, recordPtr->header.optionTable, objc - 3, objv + 3, tkwin, NULL, NULL); if (result == TCL_OK) { @@ -1107,7 +1107,7 @@ TestobjconfigObjCmd( TrivialEventProc, recordPtr); Tcl_SetObjResult(interp, objv[2]); } else { - Tk_FreeConfigOptions((char *) recordPtr, + Tk_FreeConfigOptions(recordPtr, recordPtr->header.optionTable, tkwin); } } @@ -1178,7 +1178,7 @@ TrivialConfigObjCmd( result = TCL_ERROR; goto done; } - resultObjPtr = Tk_GetOptionValue(interp, (char *) clientData, + resultObjPtr = Tk_GetOptionValue(interp, clientData, headerPtr->optionTable, objv[2], tkwin); if (resultObjPtr != NULL) { Tcl_SetObjResult(interp, resultObjPtr); @@ -1189,7 +1189,7 @@ TrivialConfigObjCmd( break; case CONFIGURE: if (objc == 2) { - resultObjPtr = Tk_GetOptionInfo(interp, (char *) clientData, + resultObjPtr = Tk_GetOptionInfo(interp, clientData, headerPtr->optionTable, NULL, tkwin); if (resultObjPtr == NULL) { result = TCL_ERROR; @@ -1197,7 +1197,7 @@ TrivialConfigObjCmd( Tcl_SetObjResult(interp, resultObjPtr); } } else if (objc == 3) { - resultObjPtr = Tk_GetOptionInfo(interp, (char *) clientData, + resultObjPtr = Tk_GetOptionInfo(interp, clientData, headerPtr->optionTable, objv[2], tkwin); if (resultObjPtr == NULL) { result = TCL_ERROR; @@ -1205,7 +1205,7 @@ TrivialConfigObjCmd( Tcl_SetObjResult(interp, resultObjPtr); } } else { - result = Tk_SetOptions(interp, (char *) clientData, + result = Tk_SetOptions(interp, clientData, headerPtr->optionTable, objc - 2, objv + 2, tkwin, NULL, &mask); if (result == TCL_OK) { @@ -1214,7 +1214,7 @@ TrivialConfigObjCmd( } break; case CSAVE: - result = Tk_SetOptions(interp, (char *) clientData, + result = Tk_SetOptions(interp, clientData, headerPtr->optionTable, objc - 2, objv + 2, tkwin, &saved, &mask); Tk_FreeSavedOptions(&saved); diff --git a/generic/tkText.c b/generic/tkText.c index 11f44f1..81551f6 100644 --- a/generic/tkText.c +++ b/generic/tkText.c @@ -661,7 +661,7 @@ CreateWidget( Tk_CreateSelHandler(textPtr->tkwin, XA_PRIMARY, XA_STRING, TextFetchSelection, textPtr, XA_STRING); - if (Tk_InitOptions(interp, (char *) textPtr, optionTable, textPtr->tkwin) + if (Tk_InitOptions(interp, textPtr, optionTable, textPtr->tkwin) != TCL_OK) { Tk_DestroyWindow(textPtr->tkwin); return TCL_ERROR; @@ -764,7 +764,7 @@ TextWidgetObjCmd( result = TCL_ERROR; goto done; } else { - Tcl_Obj *objPtr = Tk_GetOptionValue(interp, (char *) textPtr, + Tcl_Obj *objPtr = Tk_GetOptionValue(interp, textPtr, textPtr->optionTable, objv[2], textPtr->tkwin); if (objPtr == NULL) { @@ -827,7 +827,7 @@ TextWidgetObjCmd( } case TEXT_CONFIGURE: if (objc <= 3) { - Tcl_Obj *objPtr = Tk_GetOptionInfo(interp, (char *) textPtr, + Tcl_Obj *objPtr = Tk_GetOptionInfo(interp, textPtr, textPtr->optionTable, ((objc == 3) ? objv[2] : NULL), textPtr->tkwin); @@ -6829,7 +6829,7 @@ SetLineStartEnd( TkText *textPtr = (TkText *) recordPtr; if (internalOffset >= 0) { - internalPtr = recordPtr + internalOffset; + internalPtr = (char *)recordPtr + internalOffset; } else { internalPtr = NULL; } diff --git a/generic/tkTextImage.c b/generic/tkTextImage.c index d261a2c..defda56 100644 --- a/generic/tkTextImage.c +++ b/generic/tkTextImage.c @@ -161,7 +161,7 @@ TkTextImageCmd( Tcl_SetErrorCode(interp, "TK", "TEXT", "NO_IMAGE", NULL); return TCL_ERROR; } - objPtr = Tk_GetOptionValue(interp, (char *) &eiPtr->body.ei, + objPtr = Tk_GetOptionValue(interp, &eiPtr->body.ei, eiPtr->body.ei.optionTable, objv[4], textPtr->tkwin); if (objPtr == NULL) { return TCL_ERROR; @@ -188,7 +188,7 @@ TkTextImageCmd( } if (objc <= 5) { Tcl_Obj *objPtr = Tk_GetOptionInfo(interp, - (char *) &eiPtr->body.ei, eiPtr->body.ei.optionTable, + &eiPtr->body.ei, eiPtr->body.ei.optionTable, (objc == 5) ? objv[4] : NULL, textPtr->tkwin); if (objPtr == NULL) { @@ -337,7 +337,7 @@ EmbImageConfigure( int conflict = 0; /* True if we have a name conflict */ size_t len; /* length of image name */ - if (Tk_SetOptions(textPtr->interp, (char *) &eiPtr->body.ei, + if (Tk_SetOptions(textPtr->interp, &eiPtr->body.ei, eiPtr->body.ei.optionTable, objc, objv, textPtr->tkwin, NULL, NULL) != TCL_OK) { return TCL_ERROR; diff --git a/generic/tkTextTag.c b/generic/tkTextTag.c index d76f770..0a749c4 100644 --- a/generic/tkTextTag.c +++ b/generic/tkTextTag.c @@ -343,7 +343,7 @@ TkTextTagCmd( if (tagPtr == NULL) { return TCL_ERROR; } - objPtr = Tk_GetOptionValue(interp, (char *) tagPtr, + objPtr = Tk_GetOptionValue(interp, tagPtr, tagPtr->optionTable, objv[4], textPtr->tkwin); if (objPtr == NULL) { return TCL_ERROR; @@ -362,7 +362,7 @@ TkTextTagCmd( } tagPtr = TkTextCreateTag(textPtr, Tcl_GetString(objv[3]), &newTag); if (objc <= 5) { - Tcl_Obj *objPtr = Tk_GetOptionInfo(interp, (char *) tagPtr, + Tcl_Obj *objPtr = Tk_GetOptionInfo(interp, tagPtr, tagPtr->optionTable, (objc == 5) ? objv[4] : NULL, textPtr->tkwin); @@ -374,7 +374,7 @@ TkTextTagCmd( } else { int result = TCL_OK; - if (Tk_SetOptions(interp, (char *) tagPtr, tagPtr->optionTable, + if (Tk_SetOptions(interp, tagPtr, tagPtr->optionTable, objc-4, objv+4, textPtr->tkwin, NULL, NULL) != TCL_OK) { return TCL_ERROR; } diff --git a/generic/tkTextWind.c b/generic/tkTextWind.c index d6f848f..79ed1a1 100644 --- a/generic/tkTextWind.c +++ b/generic/tkTextWind.c @@ -191,7 +191,7 @@ TkTextWindowCmd( ewPtr->body.ew.tkwin = NULL; } - objPtr = Tk_GetOptionValue(interp, (char *) &ewPtr->body.ew, + objPtr = Tk_GetOptionValue(interp, &ewPtr->body.ew, ewPtr->body.ew.optionTable, objv[4], textPtr->tkwin); if (objPtr == NULL) { return TCL_ERROR; @@ -233,7 +233,7 @@ TkTextWindowCmd( ewPtr->body.ew.tkwin = NULL; } - objPtr = Tk_GetOptionInfo(interp, (char *) &ewPtr->body.ew, + objPtr = Tk_GetOptionInfo(interp, &ewPtr->body.ew, ewPtr->body.ew.optionTable, (objc == 5) ? objv[4] : NULL, textPtr->tkwin); if (objPtr == NULL) { @@ -403,7 +403,7 @@ EmbWinConfigure( } oldWindow = ewPtr->body.ew.tkwin; - if (Tk_SetOptions(textPtr->interp, (char *) &ewPtr->body.ew, + if (Tk_SetOptions(textPtr->interp, &ewPtr->body.ew, ewPtr->body.ew.optionTable, objc, objv, textPtr->tkwin, NULL, NULL) != TCL_OK) { return TCL_ERROR; diff --git a/generic/ttk/ttkNotebook.c b/generic/ttk/ttkNotebook.c index d2ee50c..0625af8 100644 --- a/generic/ttk/ttkNotebook.c +++ b/generic/ttk/ttkNotebook.c @@ -217,7 +217,7 @@ static int ConfigureTab( Tk_SavedOptions savedOptions; int mask = 0; - if (Tk_SetOptions(interp, (ClientData)tab, nb->notebook.paneOptionTable, + if (Tk_SetOptions(interp, tab, nb->notebook.paneOptionTable, objc, objv, slaveWindow, &savedOptions, &mask) != TCL_OK) { return TCL_ERROR; diff --git a/generic/ttk/ttkPanedwindow.c b/generic/ttk/ttkPanedwindow.c index 1c99a0b..8f8094e 100644 --- a/generic/ttk/ttkPanedwindow.c +++ b/generic/ttk/ttkPanedwindow.c @@ -147,7 +147,7 @@ static int ConfigurePane( Tk_SavedOptions savedOptions; int mask = 0; - if (Tk_SetOptions(interp, (void*)pane, pw->paned.paneOptionTable, + if (Tk_SetOptions(interp, pane, pw->paned.paneOptionTable, objc, objv, slaveWindow, &savedOptions, &mask) != TCL_OK) { return TCL_ERROR; diff --git a/generic/ttk/ttkTheme.c b/generic/ttk/ttkTheme.c index 595effd..6ff76c2 100644 --- a/generic/ttk/ttkTheme.c +++ b/generic/ttk/ttkTheme.c @@ -970,12 +970,12 @@ static int InitializeElementRecord( Ttk_ElementClass *eclass, /* Element instance to initialize */ Ttk_Style style, /* Style table */ - char *widgetRecord, /* Source of widget option values */ + void *widgetRecord, /* Source of widget option values */ Tk_OptionTable optionTable, /* Option table describing widget record */ Tk_Window tkwin, /* Corresponding window */ Ttk_State state) /* Widget or element state */ { - char *elementRecord = eclass->elementRecord; + void *elementRecord = eclass->elementRecord; OptionMap optionMap = GetOptionMap(eclass,optionTable); int nResources = eclass->nResources; Ttk_ResourceCache cache = style->cache; @@ -1064,7 +1064,7 @@ void Ttk_ElementSize( Ttk_ElementClass *eclass, /* Element to query */ Ttk_Style style, /* Style settings */ - char *recordPtr, /* The widget record. */ + void *recordPtr, /* The widget record. */ Tk_OptionTable optionTable, /* Description of widget record */ Tk_Window tkwin, /* The widget window. */ Ttk_State state, /* Current widget state */ @@ -1094,7 +1094,7 @@ void Ttk_DrawElement( Ttk_ElementClass *eclass, /* Element instance */ Ttk_Style style, /* Style settings */ - char *recordPtr, /* The widget record. */ + void *recordPtr, /* The widget record. */ Tk_OptionTable optionTable, /* Description of option table */ Tk_Window tkwin, /* The widget window. */ Drawable d, /* Where to draw element. */ diff --git a/generic/ttk/ttkThemeInt.h b/generic/ttk/ttkThemeInt.h index 3aaada8..25a5fdf 100644 --- a/generic/ttk/ttkThemeInt.h +++ b/generic/ttk/ttkThemeInt.h @@ -15,11 +15,11 @@ MODULE_SCOPE Ttk_ElementClass *Ttk_GetElement(Ttk_Theme, const char *name); MODULE_SCOPE const char *Ttk_ElementClassName(Ttk_ElementClass *); MODULE_SCOPE void Ttk_ElementSize( - Ttk_ElementClass *, Ttk_Style, char *recordPtr, Tk_OptionTable, + Ttk_ElementClass *, Ttk_Style, void *recordPtr, Tk_OptionTable, Tk_Window tkwin, Ttk_State state, int *widthPtr, int *heightPtr, Ttk_Padding*); MODULE_SCOPE void Ttk_DrawElement( - Ttk_ElementClass *, Ttk_Style, char *recordPtr, Tk_OptionTable, + Ttk_ElementClass *, Ttk_Style, void *recordPtr, Tk_OptionTable, Tk_Window tkwin, Drawable d, Ttk_Box b, Ttk_State state); MODULE_SCOPE Tcl_Obj *Ttk_QueryStyle( diff --git a/generic/ttk/ttkTreeview.c b/generic/ttk/ttkTreeview.c index a09ff84..8d16b19 100644 --- a/generic/ttk/ttkTreeview.c +++ b/generic/ttk/ttkTreeview.c @@ -1129,7 +1129,7 @@ static int ConfigureItem( Ttk_ImageSpec *newImageSpec = NULL; Ttk_TagSet newTagSet = NULL; - if (Tk_SetOptions(interp, (ClientData)item, tv->tree.itemOptionTable, + if (Tk_SetOptions(interp, item, tv->tree.itemOptionTable, objc, objv, tv->core.tkwin, &savedOptions, &mask) != TCL_OK) { @@ -1209,7 +1209,7 @@ static int ConfigureColumn( Tk_SavedOptions savedOptions; int mask; - if (Tk_SetOptions(interp, (ClientData)column, + if (Tk_SetOptions(interp, column, tv->tree.columnOptionTable, objc, objv, tv->core.tkwin, &savedOptions,&mask) != TCL_OK) { @@ -1255,7 +1255,7 @@ static int ConfigureHeading( Tk_SavedOptions savedOptions; int mask; - if (Tk_SetOptions(interp, (ClientData)column, + if (Tk_SetOptions(interp, column, tv->tree.headingOptionTable, objc, objv, tv->core.tkwin, &savedOptions,&mask) != TCL_OK) { -- cgit v0.12 From bd30da1ca711d3314a2e3840dc814d0e917c5c89 Mon Sep 17 00:00:00 2001 From: fvogel Date: Tue, 16 Oct 2018 20:54:11 +0000 Subject: Add text-22.250 exercising backwards search with -all and matching at start of line. This test currently hangs. --- tests/text.test | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/tests/text.test b/tests/text.test index f99ccfc..58c0400 100644 --- a/tests/text.test +++ b/tests/text.test @@ -6077,6 +6077,15 @@ test text-22.249 {TextSearchCmd, regexp backwards search all empty strings, with destroy .t unset -nocomplain res C } -result {2.4 2.3 2.2 2.1 2.0 {0 0 0 0 0}} +test text-22.250 {TextSearchCmd, backwards search all matching at start of line} -body { + text .t + .t insert end "abc" + set res [.t search -backwards -all b end] ; # works + lappend res [.t search -backwards a end] ; # works + lappend res [.t search -backwards -all a end] ; # used to hang +} -cleanup { + destroy .t +} -result {1.1 1.0} test text-23.1 {TkTextGetTabs procedure} -setup { text .t -highlightthickness 0 -bd 0 -relief flat -padx 0 -width 100 -- cgit v0.12 From 2eb57cb5163bee4eeb2eaf045701d75d740523c7 Mon Sep 17 00:00:00 2001 From: fvogel Date: Tue, 16 Oct 2018 21:00:44 +0000 Subject: Simplify patch for forward search a litle bit --- generic/tkText.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/generic/tkText.c b/generic/tkText.c index b92c925..6e09ce6 100644 --- a/generic/tkText.c +++ b/generic/tkText.c @@ -6088,8 +6088,8 @@ SearchCore( alreadySearchOffset -= matchLength; } } else { - firstOffset = (matchLength == 0) ? p - startOfLine + 1 - : p - startOfLine + matchLength; + firstOffset = matchLength ? p - startOfLine + matchLength + : p - startOfLine + 1; if (firstOffset >= lastOffset) { /* * Now, we have to be careful not to find -- cgit v0.12 From 3da23be2cedeef3e4349ee110f183ed9dca40486 Mon Sep 17 00:00:00 2001 From: fvogel Date: Tue, 16 Oct 2018 21:16:47 +0000 Subject: Fix backwards search, thanks to Koen Danckaert --- generic/tkText.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/generic/tkText.c b/generic/tkText.c index 6e09ce6..4c536a2 100644 --- a/generic/tkText.c +++ b/generic/tkText.c @@ -5823,7 +5823,7 @@ SearchCore( firstOffset = 0; } - if (alreadySearchOffset != -1) { + if (alreadySearchOffset >= 0) { if (searchSpecPtr->backwards) { if (alreadySearchOffset < lastOffset) { lastOffset = alreadySearchOffset; @@ -5912,17 +5912,17 @@ SearchCore( * match. */ - const char c = pattern[0]; + const char c = matchLength ? pattern[0] : '\0'; - if (alreadySearchOffset != -1) { + if (alreadySearchOffset >= 0) { p = startOfLine + alreadySearchOffset; alreadySearchOffset = -1; } else { p = startOfLine + lastOffset -1; } while (p >= startOfLine + firstOffset) { - if (p[0] == c && !strncmp(p, pattern, - (size_t) matchLength)) { + if (matchLength == 0 || (p[0] == c && !strncmp( + p, pattern, (size_t) matchLength))) { goto backwardsMatch; } p--; @@ -6085,7 +6085,10 @@ SearchCore( if (firstNewLine != -1) { break; } else { - alreadySearchOffset -= matchLength; + alreadySearchOffset -= (matchLength ? matchLength : 1); + if (alreadySearchOffset < 0) { + break; + } } } else { firstOffset = matchLength ? p - startOfLine + matchLength -- cgit v0.12 From 1d96da7c532192b76e47d17e4e72a11d7adaa3c2 Mon Sep 17 00:00:00 2001 From: fvogel Date: Tue, 16 Oct 2018 21:20:03 +0000 Subject: Fix tests expected results for backwards search. All tests do pass at this point. --- tests/text.test | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/tests/text.test b/tests/text.test index 58c0400..6155802 100644 --- a/tests/text.test +++ b/tests/text.test @@ -5991,7 +5991,7 @@ test text-22.239 {TextSearchCmd, exact backwards search for the empty string} -b } -cleanup { destroy .t unset -nocomplain res C -} -result {2.5 0} +} -result {2.4 0} test text-22.240 {TextSearchCmd, exact backwards search all empty strings} -body { text .t set res [.t search -count C -backwards -all "" 1.0] @@ -6003,12 +6003,12 @@ test text-22.240 {TextSearchCmd, exact backwards search all empty strings} -body test text-22.241 {TextSearchCmd, exact backwards search all empty strings} -body { text .t .t insert end "Searching for the\nempty string!" - set res [.t search -count C -backwards -all "" 2.5 2.8] + set res [.t search -count C -backwards -all "" 2.5 2.0] lappend res $C } -cleanup { destroy .t unset -nocomplain res C -} -result {2.5 2.6 2.7 {0 0 0}} +} -result {2.4 2.3 2.2 2.1 2.0 {0 0 0 0 0}} test text-22.242 {TextSearchCmd, exact backwards search all empty strings, with overlap} -body { text .t set res [.t search -count C -backwards -all -overlap "" 1.0] @@ -6020,12 +6020,12 @@ test text-22.242 {TextSearchCmd, exact backwards search all empty strings, with test text-22.243 {TextSearchCmd, exact backwards search all empty strings, with overlap} -body { text .t .t insert end "Searching for the\nempty string!" - set res [.t search -count C -backwards -all -overlap "" 2.5 2.8] + set res [.t search -count C -backwards -all -overlap "" 2.5 2.0] lappend res $C } -cleanup { destroy .t unset -nocomplain res C -} -result {2.5 2.6 2.7 {0 0 0}} +} -result {2.4 2.3 2.2 2.1 2.0 {0 0 0 0 0}} test text-22.244 {TextSearchCmd, regexp backwards search for the empty string} -body { text .t set res [.t search -count C -backwards -regexp "" 1.0] @@ -6085,7 +6085,7 @@ test text-22.250 {TextSearchCmd, backwards search all matching at start of line} lappend res [.t search -backwards -all a end] ; # used to hang } -cleanup { destroy .t -} -result {1.1 1.0} +} -result {1.1 1.0 1.0} test text-23.1 {TkTextGetTabs procedure} -setup { text .t -highlightthickness 0 -bd 0 -relief flat -padx 0 -width 100 -- cgit v0.12 From b3d0333c9f6dfac63a960f8a2d0b1ca836e46136 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Tue, 16 Oct 2018 21:26:09 +0000 Subject: Another round of (internal) int|long -> size_t replacements, at least when compiling against Tcl 9.0 headers. --- generic/tkInt.h | 6 +++++- generic/tkObj.c | 6 +++++- generic/tkText.c | 2 +- generic/tkText.h | 14 ++++++++++---- generic/tkTextBTree.c | 4 ++-- generic/tkTextDisp.c | 13 ++++++------- generic/tkTextIndex.c | 6 +++--- 7 files changed, 32 insertions(+), 19 deletions(-) diff --git a/generic/tkInt.h b/generic/tkInt.h index 849781f..c5231ea 100644 --- a/generic/tkInt.h +++ b/generic/tkInt.h @@ -597,7 +597,11 @@ typedef struct TkMainInfo { Tcl_HashTable nameTable; /* Hash table mapping path names to TkWindow * structs for all windows related to this * main window. Managed by tkWindow.c. */ - long deletionEpoch; /* Incremented by window deletions. */ +#if TCL_MAJOR_VERSION > 8 + size_t deletionEpoch; /* Incremented by window deletions. */ +#else + long deletionEpoch; +#endif Tk_BindingTable bindingTable; /* Used in conjunction with "bind" command to * bind events to Tcl commands. */ diff --git a/generic/tkObj.c b/generic/tkObj.c index 1355aad..b857d98 100644 --- a/generic/tkObj.c +++ b/generic/tkObj.c @@ -73,8 +73,12 @@ typedef struct MMRep { typedef struct WindowRep { Tk_Window tkwin; /* Cached window; NULL if not found. */ TkMainInfo *mainPtr; /* MainWindow associated with tkwin. */ - long epoch; /* Value of mainPtr->deletionEpoch at last +#if TCL_MAJOR_VERSION > 8 + size_t epoch; /* Value of mainPtr->deletionEpoch at last * successful lookup. */ +#else + long epoch; +#endif } WindowRep; /* diff --git a/generic/tkText.c b/generic/tkText.c index 81551f6..8225e3d 100644 --- a/generic/tkText.c +++ b/generic/tkText.c @@ -5076,7 +5076,7 @@ DumpSegment( Tcl_DecrRefCount(tuple); return 0; } else { - int oldStateEpoch = TkBTreeEpoch(textPtr->sharedTextPtr->tree); + TkSizeT oldStateEpoch = TkBTreeEpoch(textPtr->sharedTextPtr->tree); Tcl_DString buf; int code; diff --git a/generic/tkText.h b/generic/tkText.h index 430c96b..44e2ad9 100644 --- a/generic/tkText.h +++ b/generic/tkText.h @@ -532,8 +532,14 @@ typedef enum { * that are peers. */ +#if TCL_MAJOR_VERSION > 8 +#define TkSizeT size_t +#else +#define TkSizeT int +#endif + typedef struct TkSharedText { - int refCount; /* Reference count this shared object. */ + TkSizeT refCount; /* Reference count this shared object. */ TkTextBTree tree; /* B-tree representation of text and tags for * widget. */ Tcl_HashTable tagTable; /* Hash table that maps from tag names to @@ -562,7 +568,7 @@ typedef struct TkSharedText { * exist, so the table hasn't been created. * Each "object" used for this table is the * name of a tag. */ - int stateEpoch; /* This is incremented each time the B-tree's + TkSizeT stateEpoch; /* This is incremented each time the B-tree's * contents change structurally, or when the * start/end limits change, and means that any * cached TkTextIndex objects are no longer @@ -783,7 +789,7 @@ typedef struct TkText { * definitions. */ Tk_OptionTable optionTable; /* Token representing the configuration * specifications. */ - int refCount; /* Number of cached TkTextIndex objects + TkSizeT refCount; /* Number of cached TkTextIndex objects * refering to us. */ int insertCursorType; /* 0 = standard insertion cursor, 1 = block * cursor. */ @@ -1009,7 +1015,7 @@ MODULE_SCOPE void TkBTreeRemoveClient(TkTextBTree tree, MODULE_SCOPE void TkBTreeDestroy(TkTextBTree tree); MODULE_SCOPE void TkBTreeDeleteIndexRange(TkTextBTree tree, TkTextIndex *index1Ptr, TkTextIndex *index2Ptr); -MODULE_SCOPE int TkBTreeEpoch(TkTextBTree tree); +MODULE_SCOPE TkSizeT TkBTreeEpoch(TkTextBTree tree); MODULE_SCOPE TkTextLine *TkBTreeFindLine(TkTextBTree tree, const TkText *textPtr, int line); MODULE_SCOPE TkTextLine *TkBTreeFindPixelLine(TkTextBTree tree, diff --git a/generic/tkTextBTree.c b/generic/tkTextBTree.c index 1ae04ea..66fa140 100644 --- a/generic/tkTextBTree.c +++ b/generic/tkTextBTree.c @@ -105,7 +105,7 @@ typedef struct BTree { int clients; /* Number of clients of this B-tree. */ int pixelReferences; /* Number of clients of this B-tree which care * about pixel heights. */ - int stateEpoch; /* Updated each time any aspect of the B-tree + TkSizeT stateEpoch; /* Updated each time any aspect of the B-tree * changes. */ TkSharedText *sharedTextPtr;/* Used to find tagTable in consistency * checking code, and to access list of all @@ -501,7 +501,7 @@ TkBTreeDestroy( *---------------------------------------------------------------------- */ -int +TkSizeT TkBTreeEpoch( TkTextBTree tree) /* Tree to get epoch for. */ { diff --git a/generic/tkTextDisp.c b/generic/tkTextDisp.c index 965f1a4..9f0d7e0 100644 --- a/generic/tkTextDisp.c +++ b/generic/tkTextDisp.c @@ -162,7 +162,7 @@ typedef struct StyleValues { */ typedef struct TextStyle { - int refCount; /* Number of times this structure is + TkSizeT refCount; /* Number of times this structure is * referenced in Chunks. */ GC bgGC; /* Graphics context for background. None means * use widget background. */ @@ -400,7 +400,7 @@ typedef struct TextDInfo { * to so far... */ int metricPixelHeight; /* ...and this is for the height calculation * so far...*/ - int metricEpoch; /* ...and this for the epoch of the partial + TkSizeT metricEpoch; /* ...and this for the epoch of the partial * calculation so it can be cancelled if * things change once more. This field will be * -1 if there is no long-line calculation in @@ -1052,8 +1052,7 @@ FreeStyle( register TextStyle *stylePtr) /* Information about style to free. */ { - stylePtr->refCount--; - if (stylePtr->refCount == 0) { + if (stylePtr->refCount-- <= 1) { if (stylePtr->bgGC != None) { Tk_FreeGC(textPtr->display, stylePtr->bgGC); } @@ -3044,7 +3043,7 @@ AsyncUpdateLineMetrics( * and we've reached the last line, then we're done. */ - if (dInfoPtr->metricEpoch == -1 + if (dInfoPtr->metricEpoch == TCL_AUTO_LENGTH && lineNum == dInfoPtr->lastMetricUpdateLine) { /* * We have looped over all lines, so we're done. We must release our @@ -3194,7 +3193,7 @@ TkTextUpdateLineMetrics( * then we can't be done. */ - if (textPtr->dInfoPtr->metricEpoch == -1 && lineNum == endLine) { + if (textPtr->dInfoPtr->metricEpoch == TCL_AUTO_LENGTH && lineNum == endLine) { /* * We have looped over all lines, so we're done. */ @@ -6258,7 +6257,7 @@ TkTextPendingsync( TextDInfo *dInfoPtr = textPtr->dInfoPtr; return ( - ((dInfoPtr->metricEpoch == -1) && + ((dInfoPtr->metricEpoch == TCL_AUTO_LENGTH) && (dInfoPtr->lastMetricUpdateLine == dInfoPtr->currentMetricUpdateLine)) ? 0 : 1); } diff --git a/generic/tkTextIndex.c b/generic/tkTextIndex.c index bfef403..2870c07 100644 --- a/generic/tkTextIndex.c +++ b/generic/tkTextIndex.c @@ -64,7 +64,7 @@ static void UpdateStringOfTextIndex(Tcl_Obj *objPtr); #define SET_TEXTINDEX(objPtr, indexPtr) \ ((objPtr)->internalRep.twoPtrValue.ptr1 = (void *) (indexPtr)) #define SET_INDEXEPOCH(objPtr, epoch) \ - ((objPtr)->internalRep.twoPtrValue.ptr2 = INT2PTR(epoch)) + ((objPtr)->internalRep.twoPtrValue.ptr2 = (void *) (size_t) (epoch)) /* * Define the 'textindex' object type, which Tk uses to represent indices in @@ -104,7 +104,7 @@ DupTextIndexInternalRep( Tcl_Obj *srcPtr, /* TextIndex obj with internal rep to copy. */ Tcl_Obj *copyPtr) /* TextIndex obj with internal rep to set. */ { - int epoch; + TkSizeT epoch; TkTextIndex *dupIndexPtr, *indexPtr; dupIndexPtr = ckalloc(sizeof(TkTextIndex)); @@ -206,7 +206,7 @@ TkTextGetIndexFromObj( int cache; if (objPtr->typePtr == &tkTextIndexType) { - int epoch; + TkSizeT epoch; indexPtr = GET_TEXTINDEX(objPtr); epoch = GET_INDEXEPOCH(objPtr); -- cgit v0.12 From 8841b646e07e5bc99dc02ce7fe0485fef8cbed70 Mon Sep 17 00:00:00 2001 From: culler Date: Wed, 17 Oct 2018 01:49:44 +0000 Subject: Add a configure notify to make sure all subwindows get displayed. Tweak live resize. Code cleanup. --- macosx/tkMacOSXSubwindows.c | 20 ++++++++++- macosx/tkMacOSXWindowEvent.c | 79 +++++++++++++++++++++++++++----------------- 2 files changed, 67 insertions(+), 32 deletions(-) diff --git a/macosx/tkMacOSXSubwindows.c b/macosx/tkMacOSXSubwindows.c index 3d5e986..0f9214f 100644 --- a/macosx/tkMacOSXSubwindows.c +++ b/macosx/tkMacOSXSubwindows.c @@ -205,6 +205,13 @@ XMapWindow( event.xvisibility.type = VisibilityNotify; event.xvisibility.state = VisibilityUnobscured; NotifyVisibility(macWin->winPtr, &event); + + /* + * Make sure that subwindows get displayed. + */ + + GenerateConfigureNotify(macWin->winPtr, 1); + } /* @@ -295,10 +302,12 @@ XUnmapWindow( event.xunmap.from_configure = false; Tk_QueueWindowEvent(&event, TCL_QUEUE_TAIL); } else { + /* * Rebuild the visRgn clip region for the parent so it will be allowed * to draw in the space from which this subwindow was removed. */ + if (parentPtr && parentPtr->privatePtr->visRgn) { TkMacOSXInvalidateViewRegion(TkMacOSXDrawableView(parentPtr->privatePtr), parentPtr->privatePtr->visRgn); @@ -380,10 +389,12 @@ XMoveResizeWindow( if (Tk_IsTopLevel(macWin->winPtr) && !Tk_IsEmbedded(macWin->winPtr)) { NSWindow *w = macWin->winPtr->wmInfoPtr->window; if (w) { + /* We explicitly convert everything to doubles so we don't get * surprised (again) by what happens when you do arithmetic with * unsigned ints. */ + CGFloat X = (CGFloat)x; CGFloat Y = (CGFloat)y; CGFloat Width = (CGFloat)width; @@ -470,6 +481,7 @@ MoveResizeWindow( if (contWinPtr) { macParent = contWinPtr->privatePtr; } else { + /* * Here we should handle out of process embedding. At this point, * we are assuming that the changes.x,y is not maintained, if you @@ -478,6 +490,7 @@ MoveResizeWindow( */ } } else { + /* * TODO: update all xOff & yOffs */ @@ -569,6 +582,7 @@ XRaiseWindow( if (Tk_IsTopLevel(macWin->winPtr) && !Tk_IsEmbedded(macWin->winPtr)) { TkWmRestackToplevel(macWin->winPtr, Above, NULL); } else { + /* * TODO: this should generate damage */ @@ -603,7 +617,8 @@ XLowerWindow( if (Tk_IsTopLevel(macWin->winPtr) && !Tk_IsEmbedded(macWin->winPtr)) { TkWmRestackToplevel(macWin->winPtr, Below, NULL); } else { - /* + + /* * TODO: this should generate damage */ } @@ -874,6 +889,7 @@ TkMacOSXUpdateClipRgn( } CFRelease(rgn); } else { + /* * An unmapped window has empty clip regions to prevent any * (erroneous) drawing into it or its children from becoming @@ -1134,6 +1150,7 @@ void * TkMacOSXGetRootControl( Drawable drawable) { + /* * will probably need to fix this up for embedding */ @@ -1314,6 +1331,7 @@ UpdateOffsets( TkWindow *childPtr; if (winPtr->privatePtr == NULL) { + /* * We haven't called Tk_MakeWindowExist for this window yet. The offset * information will be postponed and calulated at that time. (This will diff --git a/macosx/tkMacOSXWindowEvent.c b/macosx/tkMacOSXWindowEvent.c index cc337b1..eef0856 100644 --- a/macosx/tkMacOSXWindowEvent.c +++ b/macosx/tkMacOSXWindowEvent.c @@ -69,11 +69,6 @@ extern NSString *NSWindowDidOrderOffScreenNotification; #endif BOOL movedOnly = [[notification name] isEqualToString:NSWindowDidMoveNotification]; - - if (movedOnly) { - /* constraining to screen after move not needed with AppKit */ - } - NSWindow *w = [notification object]; TkWindow *winPtr = TkMacOSXGetTkWindow(w); @@ -96,6 +91,7 @@ extern NSString *NSWindowDidOrderOffScreenNotification; flags |= TK_SIZE_CHANGED; } if (Tcl_GetServiceMode() != TCL_SERVICE_NONE) { + /* * Propagate geometry changes immediately. */ @@ -119,6 +115,7 @@ extern NSString *NSWindowDidOrderOffScreenNotification; TkMacOSXIsWindowZoomed(winPtr) ? ZoomState : NormalState; Tk_MapWindow((Tk_Window) winPtr); if (Tcl_GetServiceMode() != TCL_SERVICE_NONE) { + /* * Process all Tk events generated by Tk_MapWindow(). */ @@ -299,7 +296,7 @@ extern NSString *NSWindowDidOrderOffScreenNotification; * GenerateUpdates -- * * Given a Macintosh update region and a Tk window this function geneates - * a X Expose event for the window if it is within the update region. The + * an X Expose event for the window if it meets the update region. The * function will then recursivly have each damaged window generate Expose * events for its child windows. * @@ -579,10 +576,12 @@ TkGenWMConfigureEvent( if ((flags & TK_SIZE_CHANGED) && !(wmPtr->flags & WM_SYNC_PENDING) && ((width != Tk_Width(tkwin)) || (height != Tk_Height(tkwin)))) { if ((wmPtr->width == -1) && (width == winPtr->reqWidth)) { + /* * Don't set external width, since the user didn't change it * from what the widgets asked for. */ + } else if (wmPtr->gridWin != NULL) { wmPtr->width = wmPtr->reqGridWidth + (width - winPtr->reqWidth)/wmPtr->widthInc; @@ -594,10 +593,12 @@ TkGenWMConfigureEvent( } if ((wmPtr->height == -1) && (height == winPtr->reqHeight)) { + /* * Don't set external height, since the user didn't change it * from what the widgets asked for. */ + } else if (wmPtr->gridWin != NULL) { wmPtr->height = wmPtr->reqGridHeight + (height - winPtr->reqHeight)/wmPtr->heightInc; @@ -829,54 +830,56 @@ ConfigureRestrictProc( ClientData oldArg; Tk_RestrictProc *oldProc; - /* This can be called from outside the Tk event loop. + /* + * This can be called from outside the Tk event loop. * Since it calls Tcl_DoOneEvent, we need to make sure we * don't clobber the AutoreleasePool set up by the caller. */ + [NSApp _lockAutoreleasePool]; - /* Disable Tk drawing until the window has been completely configured.*/ + /* + * Disable Tk drawing until the window has been completely configured. + */ + TkMacOSXSetDrawingEnabled(winPtr, 0); - /* Generate and handle a ConfigureNotify event for the new size.*/ + /* + * Generate and handle a ConfigureNotify event for the new size. + */ + TkGenWMConfigureEvent(tkwin, Tk_X(tkwin), Tk_Y(tkwin), width, height, TK_SIZE_CHANGED | TK_MACOSX_HANDLE_EVENT_IMMEDIATELY); oldProc = Tk_RestrictEvents(ConfigureRestrictProc, NULL, &oldArg); Tk_RestrictEvents(oldProc, oldArg, &oldArg); - /* Now that Tk has configured all subwindows we can create the clip regions. */ + /* + * Now that Tk has configured all subwindows, create the clip regions. + */ + TkMacOSXSetDrawingEnabled(winPtr, 1); TkMacOSXInvalClipRgns(tkwin); TkMacOSXUpdateClipRgn(winPtr); - /* Finally, generate and process expose events to redraw the window. */ + /* + * Finally, generate and process expose events to redraw the window. + */ + HIRect bounds = NSRectToCGRect([self bounds]); HIShapeRef shape = HIShapeCreateWithRect(&bounds); [self generateExposeEvents: shape]; - while (Tk_DoOneEvent(TK_X_EVENTS|TK_DONT_WAIT)) {} + [w displayIfNeeded]; [NSApp _unlockAutoreleasePool]; } } /* - * As insurance against bugs that might cause layout glitches during a live - * resize, we mark the window as needing display at the end of the resize - * operation. - */ - -- (void)viewDidEndLiveResize -{ - HIRect bounds = NSRectToCGRect([self bounds]); - HIShapeRef shape = HIShapeCreateWithRect(&bounds); - [super viewDidEndLiveResize]; - [self displayIfNeeded]; -} - -/* Core method of this class: generates expose events for redrawing. The + * Core method of this class: generates expose events for redrawing. The * expose events are immediately removed from the Tcl event loop and processed. * This causes drawing procedures to be scheduled as idle events. Then all * pending idle events are processed so the drawing will actually take place. */ + - (void) generateExposeEvents: (HIShapeRef) shape { unsigned long serial; @@ -888,21 +891,33 @@ ConfigureRestrictProc( return; } - /* Generate Tk Expose events. */ + /* + * Generate Tk Expose events. + */ + HIShapeGetBounds(shape, &updateBounds); - /* All of these events will share the same serial number. */ + + /* + * All of these events will share the same serial number. + */ + serial = LastKnownRequestProcessed(Tk_Display(winPtr)); updatesNeeded = GenerateUpdates(shape, &updateBounds, winPtr); if (updatesNeeded) { - /* Process all of the Expose events.*/ + + /* + * First process all of the Expose events. + */ + ClientData oldArg; Tk_RestrictProc *oldProc = Tk_RestrictEvents(ExposeRestrictProc, UINT2PTR(serial), &oldArg); while (Tcl_ServiceEvent(TCL_WINDOW_EVENTS)) {}; Tk_RestrictEvents(oldProc, oldArg, &oldArg); - - /* Starting with OSX 10.14, which uses Core Animation to draw windows, + + /* + * Starting with OSX 10.14, which uses Core Animation to draw windows, * all drawing must be done within the drawRect method. (The CGContext * which draws to the backing CALayer is created by the NSView before * calling drawRect, and destroyed when drawRect returns. Drawing done @@ -913,6 +928,7 @@ ConfigureRestrictProc( * So we can do the drawing by processing all of the idle events that * were created when the expose events were processed. */ + while (Tcl_DoOneEvent(TCL_IDLE_EVENTS)) {} } } @@ -921,6 +937,7 @@ ConfigureRestrictProc( * This is no-op on 10.7 and up because Apple has removed this widget, * but we are leaving it here for backwards compatibility. */ + - (void) tkToolbarButton: (id) sender { #ifdef TK_MAC_DEBUG_EVENTS -- cgit v0.12 From f451994afc3dc024b32cd6f6148473b0abe78f89 Mon Sep 17 00:00:00 2001 From: fvogel Date: Wed, 17 Oct 2018 06:39:20 +0000 Subject: Take into account that the scrollbars on macOS later than 10.6 (Snow Leopard) have no arrows. Scrollbar tests will now fail again (I'll fix them), but interactive testing should now show perfect behavior on macOS. --- macosx/tkMacOSXScrlbr.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/macosx/tkMacOSXScrlbr.c b/macosx/tkMacOSXScrlbr.c index 65dc099..2fb9454 100644 --- a/macosx/tkMacOSXScrlbr.c +++ b/macosx/tkMacOSXScrlbr.c @@ -231,17 +231,18 @@ TkpComputeScrollbarGeometry( * Using code from tkUnixScrlbr.c because Unix scroll bindings are * driving the display at the script level. All the Mac scrollbar * has to do is re-draw itself. + * There is a difference with Unix however: on macOS later than 10.6 + * (Snow Leopard) the scrollbars have no arrows at all. This is + * handled by having scrollPtr->arrowLength set to zero. */ - int width, fieldLength; + int fieldLength; if (scrollPtr->highlightWidth < 0) { scrollPtr->highlightWidth = 0; } scrollPtr->inset = scrollPtr->highlightWidth + scrollPtr->borderWidth; - width = (scrollPtr->vertical) ? Tk_Width(scrollPtr->tkwin) - : Tk_Height(scrollPtr->tkwin); - scrollPtr->arrowLength = width - 2*scrollPtr->inset + 1; + scrollPtr->arrowLength = 0; fieldLength = (scrollPtr->vertical ? Tk_Height(scrollPtr->tkwin) : Tk_Width(scrollPtr->tkwin)) - 2*(scrollPtr->arrowLength + scrollPtr->inset); -- cgit v0.12 From 1f1b9f6c815c9597f01d8d86661e427b85ab258a Mon Sep 17 00:00:00 2001 From: Kevin Walzer Date: Wed, 17 Oct 2018 11:14:48 +0000 Subject: Revert accidental commit/mingling of scroll branch code --- generic/tkTest.c | 33 ++++++++++++++++++++++++++++----- macosx/tkMacOSXScrlbr.c | 26 +++++++++++++++----------- tests/scrollbar.test | 34 +++------------------------------- 3 files changed, 46 insertions(+), 47 deletions(-) diff --git a/generic/tkTest.c b/generic/tkTest.c index 2dbd877..1fa461e 100644 --- a/generic/tkTest.c +++ b/generic/tkTest.c @@ -168,7 +168,7 @@ static int TestmenubarObjCmd(ClientData dummy, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]); #endif -#if defined(_WIN32) +#if defined(_WIN32) || defined(MAC_OSX_TK) static int TestmetricsObjCmd(ClientData dummy, Tcl_Interp *interp, int objc, Tcl_Obj * const objv[]); @@ -266,17 +266,17 @@ Tktest_Init( Tcl_CreateObjCommand(interp, "testtext", TkpTesttextCmd, (ClientData) Tk_MainWindow(interp), NULL); -#if defined(_WIN32) +#if defined(_WIN32) || defined(MAC_OSX_TK) Tcl_CreateObjCommand(interp, "testmetrics", TestmetricsObjCmd, (ClientData) Tk_MainWindow(interp), NULL); -#elif !defined(__CYGWIN__) && !defined(MAC_OSX_TK) +#elif !defined(__CYGWIN__) Tcl_CreateObjCommand(interp, "testmenubar", TestmenubarObjCmd, (ClientData) Tk_MainWindow(interp), NULL); Tcl_CreateObjCommand(interp, "testsend", TkpTestsendCmd, (ClientData) Tk_MainWindow(interp), NULL); Tcl_CreateObjCommand(interp, "testwrapper", TestwrapperObjCmd, (ClientData) Tk_MainWindow(interp), NULL); -#endif /* _WIN32 */ +#endif /* _WIN32 || MAC_OSX_TK */ /* * Create test image type. @@ -1764,7 +1764,7 @@ TestmenubarObjCmd( *---------------------------------------------------------------------- */ -#if defined(_WIN32) +#if defined(_WIN32) || defined(MAC_OSX_TK) static int TestmetricsObjCmd( ClientData clientData, /* Main window for application. */ @@ -1775,15 +1775,38 @@ TestmetricsObjCmd( char buf[TCL_INTEGER_SPACE]; int val; +#ifdef _WIN32 if (objc < 2) { Tcl_WrongNumArgs(interp, 1, objv, "option ?arg ...?"); return TCL_ERROR; } +#else + Tk_Window tkwin = (Tk_Window) clientData; + TkWindow *winPtr; + + if (objc != 3) { + Tcl_WrongNumArgs(interp, 1, objv, "option window"); + return TCL_ERROR; + } + + winPtr = (TkWindow *) Tk_NameToWindow(interp, Tcl_GetString(objv[2]), tkwin); + if (winPtr == NULL) { + return TCL_ERROR; + } +#endif if (strcmp(Tcl_GetString(objv[1]), "cyvscroll") == 0) { +#ifdef _WIN32 val = GetSystemMetrics(SM_CYVSCROLL); +#else + val = ((TkScrollbar *) winPtr->instanceData)->width; +#endif } else if (strcmp(Tcl_GetString(objv[1]), "cxhscroll") == 0) { +#ifdef _WIN32 val = GetSystemMetrics(SM_CXHSCROLL); +#else + val = ((TkScrollbar *) winPtr->instanceData)->width; +#endif } else { Tcl_AppendResult(interp, "bad option \"", Tcl_GetString(objv[1]), "\": must be cxhscroll or cyvscroll", NULL); diff --git a/macosx/tkMacOSXScrlbr.c b/macosx/tkMacOSXScrlbr.c index 65dc099..a8018a5 100644 --- a/macosx/tkMacOSXScrlbr.c +++ b/macosx/tkMacOSXScrlbr.c @@ -282,12 +282,11 @@ TkpComputeScrollbarGeometry( Tk_GeometryRequest(scrollPtr->tkwin, scrollPtr->width + 2*scrollPtr->inset, 2*(scrollPtr->arrowLength + scrollPtr->borderWidth - + scrollPtr->inset) + metrics.minThumbHeight); + + scrollPtr->inset)); } else { Tk_GeometryRequest(scrollPtr->tkwin, 2*(scrollPtr->arrowLength + scrollPtr->borderWidth - + scrollPtr->inset) + metrics.minThumbHeight, - scrollPtr->width + 2*scrollPtr->inset); + + scrollPtr->inset), scrollPtr->width + 2*scrollPtr->inset); } Tk_SetInternalBorder(scrollPtr->tkwin, scrollPtr->inset); } @@ -382,20 +381,25 @@ TkpScrollbarPosition( * has to do is re-draw itself. */ - int length, width, tmp; + int length, fieldlength, width, tmp; register const int inset = scrollPtr->inset; + register const int arrowSize = scrollPtr->arrowLength + inset; if (scrollPtr->vertical) { length = Tk_Height(scrollPtr->tkwin); + fieldlength = length - 2 * arrowSize; width = Tk_Width(scrollPtr->tkwin); } else { tmp = x; x = y; y = tmp; length = Tk_Width(scrollPtr->tkwin); + fieldlength = length - 2 * arrowSize; width = Tk_Height(scrollPtr->tkwin); } + fieldlength = fieldlength < 0 ? 0 : fieldlength; + if (x=width-inset || y=length-inset) { return OUTSIDE; } @@ -405,19 +409,19 @@ TkpScrollbarPosition( * TkpDisplayScrollbar. Be sure to keep the two consistent. */ - if (y < inset + scrollPtr->arrowLength) { - return TOP_ARROW; - } if (y < scrollPtr->sliderFirst) { return TOP_GAP; } - if (y < scrollPtr->sliderLast){ + if (y < scrollPtr->sliderLast) { return SLIDER; } - if (y >= length - (scrollPtr->arrowLength + inset)) { - return BOTTOM_ARROW; + if (y < fieldlength){ + return BOTTOM_GAP; + } + if (y < fieldlength + arrowSize) { + return TOP_ARROW; } - return BOTTOM_GAP; + return BOTTOM_ARROW; } diff --git a/tests/scrollbar.test b/tests/scrollbar.test index 6f00e78..bd14067 100644 --- a/tests/scrollbar.test +++ b/tests/scrollbar.test @@ -283,7 +283,7 @@ test scrollbar-3.41 {ScrollbarWidgetCmd procedure, "fraction" option} { if {[testConstraint testmetrics]} { place configure .t.s -width [expr 2*[testmetrics cxhscroll .t.s]+1] } else { - place configure .t.s -width [expr [winfo height .t.s] - 2*([.t.s cget -highlightthickness] + [.t.s cget -bd] + 1)] + place configure .t.s -width [expr [winfo reqwidth .t.s] - 4] } update test scrollbar-3.42 {ScrollbarWidgetCmd procedure, "fraction" option} { @@ -632,7 +632,7 @@ test scrollbar-9.1 {scrollbar widget vs hidden commands} { list [winfo children .] [interp hidden] } [list {} $l] -test scrollbar-10.1.1 { event on scrollbar} -constraints {notAqua} -setup { +test scrollbar-10.1 { event on scrollbar} -constraints {win|unix} -setup { destroy .t .s } -body { pack [text .t -yscrollcommand {.s set}] -side left @@ -646,22 +646,8 @@ test scrollbar-10.1.1 { event on scrollbar} -constraints {notAqua} - } -cleanup { destroy .t .s } -result {5.0} -test scrollbar-10.1.2 { event on scrollbar} -constraints {aqua} -setup { - destroy .t .s -} -body { - pack [text .t -yscrollcommand {.s set}] -side left - for {set i 1} {$i < 100} {incr i} {.t insert end "Line $i\n"} - pack [scrollbar .s -command {.t yview}] -fill y -expand 1 -side left - update - focus -force .s - event generate .s -delta -4 - after 200 {set eventprocessed 1} ; vwait eventprocessed - .t index @0,0 -} -cleanup { - destroy .t .s -} -result {5.0} -test scrollbar-10.2.1 { event on scrollbar} -constraints {notAqua} -setup { +test scrollbar-10.2 { event on scrollbar} -constraints {win|unix} -setup { destroy .t .s } -body { pack [text .t -xscrollcommand {.s set} -wrap none] -side top @@ -675,20 +661,6 @@ test scrollbar-10.2.1 { event on scrollbar} -constraints {notAqua} - } -cleanup { destroy .t .s } -result {1.4} -test scrollbar-10.2.2 { event on scrollbar} -constraints {aqua} -setup { - destroy .t .s -} -body { - pack [text .t -xscrollcommand {.s set} -wrap none] -side top - for {set i 1} {$i < 100} {incr i} {.t insert end "Char $i "} - pack [scrollbar .s -command {.t xview} -orient horizontal] -fill x -expand 1 -side top - update - focus -force .s - event generate .s -delta -4 - after 200 {set eventprocessed 1} ; vwait eventprocessed - .t index @0,0 -} -cleanup { - destroy .t .s -} -result {1.4} test scrollbar-11.1 {bug fix: [011706ec42] Scrollbar unsafe wrt widget destruction} -body { proc destroy_scrollbar {} { -- cgit v0.12 From 8a67081a897939cfc0d90a2854185262aeda55db Mon Sep 17 00:00:00 2001 From: Kevin Walzer Date: Wed, 17 Oct 2018 11:27:23 +0000 Subject: Update README with new virtual events for appearance changes --- macosx/README | 3 +++ 1 file changed, 3 insertions(+) diff --git a/macosx/README b/macosx/README index bcd5dce..2e2ef2a 100644 --- a/macosx/README +++ b/macosx/README @@ -561,3 +561,6 @@ source and destination rectangles for the scrolling. The embedded windows are redrawn within the DisplayText function by some conditional code which is only used for macOS. +5.0 Virtual events on 10.14 +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +10.14 supports system appearance changes, and has added a "Dark Mode" that casts all window frames and menus as black. Tk 8.6.9 has added two virtual events, <> and <>, to allow you to update your Tk app's appearance when the system appearance changes. Just bind your appearance-updating code to these virtual events and you will see it triggered when the system appearance toggles between dark and light. -- cgit v0.12 From 96f72107e2831afdd716e15403295e3123bb08c9 Mon Sep 17 00:00:00 2001 From: Kevin Walzer Date: Wed, 17 Oct 2018 12:16:43 +0000 Subject: Remove conditional compilation of apperance change calls per suggestion from Marc Culler --- macosx/tkMacOSXWindowEvent.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/macosx/tkMacOSXWindowEvent.c b/macosx/tkMacOSXWindowEvent.c index 5ff8393..94cfc4d 100644 --- a/macosx/tkMacOSXWindowEvent.c +++ b/macosx/tkMacOSXWindowEvent.c @@ -940,8 +940,6 @@ ConfigureRestrictProc( /* These two methods allow Tk to register a virtual event for when the apperance changes on 10.14. */ -#if MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_14 - - (void) updateAppearanceEvent { NSString *osxMode = [[NSUserDefaults standardUserDefaults] stringForKey:@"AppleInterfaceStyle"]; @@ -975,7 +973,6 @@ ConfigureRestrictProc( } } -#endif /* * This is no-op on 10.7 and up because Apple has removed this widget, -- cgit v0.12 From e7731e4600744d26de039bd3fa5bbcbe68ca3e76 Mon Sep 17 00:00:00 2001 From: Kevin Walzer Date: Wed, 17 Oct 2018 12:25:17 +0000 Subject: Restore viewDidChangeEffectiveAppearance method deleted by mistake --- macosx/tkMacOSXWindowEvent.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/macosx/tkMacOSXWindowEvent.c b/macosx/tkMacOSXWindowEvent.c index 94cfc4d..06b1793 100644 --- a/macosx/tkMacOSXWindowEvent.c +++ b/macosx/tkMacOSXWindowEvent.c @@ -940,6 +940,11 @@ ConfigureRestrictProc( /* These two methods allow Tk to register a virtual event for when the apperance changes on 10.14. */ +- (void) viewDidChangeEffectiveAppearance +{ + [self updateAppearanceEvent]; +} + - (void) updateAppearanceEvent { NSString *osxMode = [[NSUserDefaults standardUserDefaults] stringForKey:@"AppleInterfaceStyle"]; -- cgit v0.12 From 124bda43f73ed5838701672ff1c627d54a87ffa5 Mon Sep 17 00:00:00 2001 From: culler Date: Wed, 17 Oct 2018 13:05:28 +0000 Subject: Fix typos, formatting, compiler warnings. --- macosx/README | 11 +++++++++-- macosx/tkMacOSXConstants.h | 1 + macosx/tkMacOSXPrivate.h | 2 -- macosx/tkMacOSXWindowEvent.c | 8 +++++--- macosx/tkMacOSXWm.c | 6 ++---- 5 files changed, 17 insertions(+), 11 deletions(-) diff --git a/macosx/README b/macosx/README index 2e2ef2a..d4c0675 100644 --- a/macosx/README +++ b/macosx/README @@ -562,5 +562,12 @@ windows are redrawn within the DisplayText function by some conditional code which is only used for macOS. 5.0 Virtual events on 10.14 -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -10.14 supports system appearance changes, and has added a "Dark Mode" that casts all window frames and menus as black. Tk 8.6.9 has added two virtual events, <> and <>, to allow you to update your Tk app's appearance when the system appearance changes. Just bind your appearance-updating code to these virtual events and you will see it triggered when the system appearance toggles between dark and light. +~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +10.14 supports system appearance changes, and has added a "Dark Mode" +that casts all window frames and menus as black. Tk 8.6.9 has added +two virtual events, <> and <>, to allow you to +update your Tk app's appearance when the system appearance +changes. Just bind your appearance-updating code to these virtual +events and you will see it triggered when the system appearance +toggles between dark and light. diff --git a/macosx/tkMacOSXConstants.h b/macosx/tkMacOSXConstants.h index 95983dd..bb2206e 100644 --- a/macosx/tkMacOSXConstants.h +++ b/macosx/tkMacOSXConstants.h @@ -90,6 +90,7 @@ #define NSUnifiedTitleAndToolbarWindowMask NSWindowStyleMaskUnifiedTitleAndToolbar #define NSMiniaturizableWindowMask NSWindowStyleMaskMiniaturizable #define NSBorderlessWindowMask NSWindowStyleMaskBorderless +#define NSFullScreenWindowMask NSWindowStyleMaskFullScreen #endif #endif diff --git a/macosx/tkMacOSXPrivate.h b/macosx/tkMacOSXPrivate.h index c998022..206d9cc 100644 --- a/macosx/tkMacOSXPrivate.h +++ b/macosx/tkMacOSXPrivate.h @@ -330,8 +330,6 @@ VISIBILITY_HIDDEN @interface TKContentView(TKWindowEvent) - (void) drawRect: (NSRect) rect; - (void) generateExposeEvents: (HIShapeRef) shape; -- (void) viewDidEndLiveResize; -- (void) viewDidChangeEffectiveAppearance; - (void) updateAppearanceEvent; - (void) tkToolbarButton: (id) sender; - (BOOL) isOpaque; diff --git a/macosx/tkMacOSXWindowEvent.c b/macosx/tkMacOSXWindowEvent.c index 94cfc4d..1337e87 100644 --- a/macosx/tkMacOSXWindowEvent.c +++ b/macosx/tkMacOSXWindowEvent.c @@ -938,7 +938,10 @@ ConfigureRestrictProc( } -/* These two methods allow Tk to register a virtual event for when the apperance changes on 10.14. */ +/* + * These two methods allow Tk to register a virtual event which fires when the + * appearance changes on 10.14. + */ - (void) updateAppearanceEvent { @@ -966,14 +969,13 @@ ConfigureRestrictProc( Tk_QueueWindowEvent((XEvent *) &event, TCL_QUEUE_TAIL); return; } - if (osxMode = @"Dark") { + if ([osxMode isEqual:@"Dark"]) { event.name = Tk_GetUid("DarkAqua"); Tk_QueueWindowEvent((XEvent *) &event, TCL_QUEUE_TAIL); return; } } - /* * This is no-op on 10.7 and up because Apple has removed this widget, * but we are leaving it here for backwards compatibility. diff --git a/macosx/tkMacOSXWm.c b/macosx/tkMacOSXWm.c index cf0ee7a..55a6633 100644 --- a/macosx/tkMacOSXWm.c +++ b/macosx/tkMacOSXWm.c @@ -399,8 +399,7 @@ NSStatusItem *exitFullScreen; - (void)toggleFullScreen:(id)sender { TkWindow *winPtr = TkMacOSXGetTkWindow(self); - Tk_Window tkwin = (TkWindow*)winPtr; - Tcl_Interp *interp = Tk_Interp(tkwin); + Tcl_Interp *interp = Tk_Interp((Tk_Window)winPtr); if (([self styleMask] & NSFullScreenWindowMask) == NSFullScreenWindowMask) { TkMacOSXMakeFullscreen(winPtr, self, 0, interp); @@ -412,8 +411,7 @@ NSStatusItem *exitFullScreen; -(void)restoreOldScreen:(id)sender { TkWindow *winPtr = TkMacOSXGetTkWindow(self); - Tk_Window tkwin = (TkWindow*)winPtr; - Tcl_Interp *interp = Tk_Interp(tkwin); + Tcl_Interp *interp = Tk_Interp((Tk_Window)winPtr); TkMacOSXMakeFullscreen(winPtr, self, 0, interp); [[NSStatusBar systemStatusBar] removeStatusItem: exitFullScreen]; -- cgit v0.12 From b5f5881d41e3d53e9c4770eba27d85ef65c87c03 Mon Sep 17 00:00:00 2001 From: culler Date: Wed, 17 Oct 2018 13:24:41 +0000 Subject: Restoring declaration of viewDidChangeEffectiveAppearance. --- macosx/tkMacOSXPrivate.h | 1 + 1 file changed, 1 insertion(+) diff --git a/macosx/tkMacOSXPrivate.h b/macosx/tkMacOSXPrivate.h index 206d9cc..28597dd 100644 --- a/macosx/tkMacOSXPrivate.h +++ b/macosx/tkMacOSXPrivate.h @@ -330,6 +330,7 @@ VISIBILITY_HIDDEN @interface TKContentView(TKWindowEvent) - (void) drawRect: (NSRect) rect; - (void) generateExposeEvents: (HIShapeRef) shape; +- (void) viewDidChangeEffectiveAppearance; - (void) updateAppearanceEvent; - (void) tkToolbarButton: (id) sender; - (BOOL) isOpaque; -- cgit v0.12 From 70385d2f5041501defd7445e9e56eff43b95341b Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Wed, 17 Oct 2018 19:49:30 +0000 Subject: One more round of int -> size_t improvements (inspired by TIP #494, but then for Tk). --- generic/tk3d.h | 4 ++-- generic/tkColor.c | 10 ++++------ generic/tkColor.h | 4 ++-- generic/tkCursor.c | 10 ++++------ generic/tkError.c | 9 ++++----- generic/tkFont.c | 10 ++++------ generic/tkFont.h | 4 ++-- generic/tkInt.h | 14 +++++++++++--- generic/tkText.h | 10 ++++++---- generic/ttk/ttkTheme.c | 2 +- generic/ttk/ttkTheme.h | 10 +++++++++- 11 files changed, 49 insertions(+), 38 deletions(-) diff --git a/generic/tk3d.h b/generic/tk3d.h index 891e927..f574de7 100644 --- a/generic/tk3d.h +++ b/generic/tk3d.h @@ -28,7 +28,7 @@ typedef struct TkBorder { * the border will be used. */ Colormap colormap; /* Colormap out of which pixels are * allocated. */ - int resourceRefCount; /* Number of active uses of this color (each + TkSizeT resourceRefCount; /* Number of active uses of this color (each * active use corresponds to a call to * Tk_Alloc3DBorderFromObj or Tk_Get3DBorder). * If this count is 0, then this structure is @@ -37,7 +37,7 @@ typedef struct TkBorder { * because there are objects referring to it. * The structure is freed when objRefCount and * resourceRefCount are both 0. */ - int objRefCount; /* The number of Tcl objects that reference + TkSizeT objRefCount; /* The number of Tcl objects that reference * this structure. */ XColor *bgColorPtr; /* Background color (intensity between * lightColorPtr and darkColorPtr). */ diff --git a/generic/tkColor.c b/generic/tkColor.c index 9abb448..9d5e157 100644 --- a/generic/tkColor.c +++ b/generic/tkColor.c @@ -480,8 +480,7 @@ Tk_FreeColor( Tcl_Panic("Tk_FreeColor called with bogus color"); } - tkColPtr->resourceRefCount--; - if (tkColPtr->resourceRefCount > 0) { + if (tkColPtr->resourceRefCount-- > 1) { return; } @@ -587,8 +586,7 @@ FreeColorObj( TkColor *tkColPtr = objPtr->internalRep.twoPtrValue.ptr1; if (tkColPtr != NULL) { - tkColPtr->objRefCount--; - if ((tkColPtr->objRefCount == 0) + if ((tkColPtr->objRefCount-- <= 1) && (tkColPtr->resourceRefCount == 0)) { ckfree(tkColPtr); } @@ -820,9 +818,9 @@ TkDebugColor( Tcl_Obj *objPtr = Tcl_NewObj(); Tcl_ListObjAppendElement(NULL, objPtr, - Tcl_NewIntObj(tkColPtr->resourceRefCount)); + Tcl_NewWideIntObj(tkColPtr->resourceRefCount)); Tcl_ListObjAppendElement(NULL, objPtr, - Tcl_NewIntObj(tkColPtr->objRefCount)); + Tcl_NewWideIntObj(tkColPtr->objRefCount)); Tcl_ListObjAppendElement(NULL, resultPtr, objPtr); } } diff --git a/generic/tkColor.h b/generic/tkColor.h index 05ef295..d5bde9d 100644 --- a/generic/tkColor.h +++ b/generic/tkColor.h @@ -38,7 +38,7 @@ typedef struct TkColor { Colormap colormap; /* Colormap from which this entry was * allocated. */ Visual *visual; /* Visual associated with colormap. */ - int resourceRefCount; /* Number of active uses of this color (each + TkSizeT resourceRefCount; /* Number of active uses of this color (each * active use corresponds to a call to * Tk_AllocColorFromObj or Tk_GetColor). If * this count is 0, then this TkColor @@ -48,7 +48,7 @@ typedef struct TkColor { * referring to it. The structure is freed * when resourceRefCount and objRefCount are * both 0. */ - int objRefCount; /* The number of Tcl objects that reference + TkSizeT objRefCount; /* The number of Tcl objects that reference * this structure. */ int type; /* TK_COLOR_BY_NAME or TK_COLOR_BY_VALUE. */ Tcl_HashEntry *hashPtr; /* Pointer to hash table entry for this diff --git a/generic/tkCursor.c b/generic/tkCursor.c index 6b2d5f4..e337b37 100644 --- a/generic/tkCursor.c +++ b/generic/tkCursor.c @@ -463,8 +463,7 @@ FreeCursor( { TkCursor *prevPtr; - cursorPtr->resourceRefCount--; - if (cursorPtr->resourceRefCount > 0) { + if (cursorPtr->resourceRefCount-- > 1) { return; } @@ -590,8 +589,7 @@ FreeCursorObj( TkCursor *cursorPtr = objPtr->internalRep.twoPtrValue.ptr1; if (cursorPtr != NULL) { - cursorPtr->objRefCount--; - if ((cursorPtr->objRefCount == 0) + if ((cursorPtr->objRefCount-- <= 1) && (cursorPtr->resourceRefCount == 0)) { ckfree(cursorPtr); } @@ -864,9 +862,9 @@ TkDebugCursor( for ( ; (cursorPtr != NULL); cursorPtr = cursorPtr->nextPtr) { objPtr = Tcl_NewObj(); Tcl_ListObjAppendElement(NULL, objPtr, - Tcl_NewIntObj(cursorPtr->resourceRefCount)); + Tcl_NewWideIntObj(cursorPtr->resourceRefCount)); Tcl_ListObjAppendElement(NULL, objPtr, - Tcl_NewIntObj(cursorPtr->objRefCount)); + Tcl_NewWideIntObj(cursorPtr->objRefCount)); Tcl_ListObjAppendElement(NULL, resultPtr, objPtr); } } diff --git a/generic/tkError.c b/generic/tkError.c index 277d7f0..5aa6d88 100644 --- a/generic/tkError.c +++ b/generic/tkError.c @@ -164,11 +164,10 @@ Tk_DeleteErrorHandler( * there are many handlers that stay around forever). */ - dispPtr->deleteCount += 1; - if (dispPtr->deleteCount >= 10) { + if (dispPtr->deleteCount++ >= 9) { TkErrorHandler *prevPtr; TkErrorHandler *nextPtr; - int lastSerial = LastKnownRequestProcessed(dispPtr->display); + unsigned long lastSerial = LastKnownRequestProcessed(dispPtr->display); /* * Last chance to catch errors for this handler: if no event/error @@ -176,7 +175,7 @@ Tk_DeleteErrorHandler( * we need a round trip with the X server now. */ - if (errorPtr->lastRequest > (unsigned long) lastSerial) { + if (errorPtr->lastRequest > lastSerial) { XSync(dispPtr->display, False); } dispPtr->deleteCount = 0; @@ -184,7 +183,7 @@ Tk_DeleteErrorHandler( for (prevPtr = NULL; errorPtr != NULL; errorPtr = nextPtr) { nextPtr = errorPtr->nextPtr; if ((errorPtr->lastRequest != (unsigned long) -1) - && (errorPtr->lastRequest <= (unsigned long) lastSerial)) { + && (errorPtr->lastRequest <= lastSerial)) { if (prevPtr == NULL) { dispPtr->errorPtr = nextPtr; } else { diff --git a/generic/tkFont.c b/generic/tkFont.c index 9f2fa11..c0ff7d0 100644 --- a/generic/tkFont.c +++ b/generic/tkFont.c @@ -1424,8 +1424,7 @@ Tk_FreeFont( if (fontPtr == NULL) { return; } - fontPtr->resourceRefCount--; - if (fontPtr->resourceRefCount > 0) { + if (fontPtr->resourceRefCount-- > 1) { return; } if (fontPtr->namedHashPtr != NULL) { @@ -1522,8 +1521,7 @@ FreeFontObj( TkFont *fontPtr = objPtr->internalRep.twoPtrValue.ptr1; if (fontPtr != NULL) { - fontPtr->objRefCount--; - if ((fontPtr->resourceRefCount == 0) && (fontPtr->objRefCount == 0)) { + if ((fontPtr->objRefCount-- <= 1) && (fontPtr->resourceRefCount == 0)) { ckfree(fontPtr); } objPtr->internalRep.twoPtrValue.ptr1 = NULL; @@ -4206,9 +4204,9 @@ TkDebugFont( for ( ; (fontPtr != NULL); fontPtr = fontPtr->nextPtr) { objPtr = Tcl_NewObj(); Tcl_ListObjAppendElement(NULL, objPtr, - Tcl_NewIntObj(fontPtr->resourceRefCount)); + Tcl_NewWideIntObj(fontPtr->resourceRefCount)); Tcl_ListObjAppendElement(NULL, objPtr, - Tcl_NewIntObj(fontPtr->objRefCount)); + Tcl_NewWideIntObj(fontPtr->objRefCount)); Tcl_ListObjAppendElement(NULL, resultPtr, objPtr); } } diff --git a/generic/tkFont.h b/generic/tkFont.h index de479bf..50f79d2 100644 --- a/generic/tkFont.h +++ b/generic/tkFont.h @@ -85,7 +85,7 @@ typedef struct TkFont { * Fields used and maintained exclusively by generic code. */ - int resourceRefCount; /* Number of active uses of this font (each + TkSizeT resourceRefCount; /* Number of active uses of this font (each * active use corresponds to a call to * Tk_AllocFontFromTable or Tk_GetFont). If * this count is 0, then this TkFont structure @@ -95,7 +95,7 @@ typedef struct TkFont { * The structure is freed when * resourceRefCount and objRefCount are both * 0. */ - int objRefCount; /* The number of Tcl objects that reference + TkSizeT objRefCount; /* The number of Tcl objects that reference * this structure. */ Tcl_HashEntry *cacheHashPtr;/* Entry in font cache for this structure, * used when deleting it. */ diff --git a/generic/tkInt.h b/generic/tkInt.h index c5231ea..f903490 100644 --- a/generic/tkInt.h +++ b/generic/tkInt.h @@ -58,6 +58,14 @@ # endif #endif +#ifndef TkSizeT +# if TCL_MAJOR_VERSION > 8 +# define TkSizeT size_t +# else +# define TkSizeT int +# endif +#endif + /* * Macros used to cast between pointers and integers (e.g. when storing an int * in ClientData), on 64-bit architectures they avoid gcc warning about "cast @@ -110,7 +118,7 @@ typedef struct TkCursor { Tk_Cursor cursor; /* System specific identifier for cursor. */ Display *display; /* Display containing cursor. Needed for * disposal and retrieval of cursors. */ - int resourceRefCount; /* Number of active uses of this cursor (each + TkSizeT resourceRefCount; /* Number of active uses of this cursor (each * active use corresponds to a call to * Tk_AllocPreserveFromObj or Tk_Preserve). If * this count is 0, then this structure is no @@ -119,7 +127,7 @@ typedef struct TkCursor { * there are objects referring to it. The * structure is freed when resourceRefCount * and objRefCount are both 0. */ - int objRefCount; /* Number of Tcl objects that reference this + TkSizeT objRefCount; /* Number of Tcl objects that reference this * structure.. */ Tcl_HashTable *otherTable; /* Second table (other than idTable) used to * index this entry. */ @@ -269,7 +277,7 @@ typedef struct TkDisplay { /* First in list of error handlers for this * display. NULL means no handlers exist at * present. */ - int deleteCount; /* Counts # of handlers deleted since last + TkSizeT deleteCount; /* Counts # of handlers deleted since last * time inactive handlers were garbage- * collected. When this number gets big, * handlers get cleaned up. */ diff --git a/generic/tkText.h b/generic/tkText.h index 44e2ad9..5e84fd5 100644 --- a/generic/tkText.h +++ b/generic/tkText.h @@ -532,10 +532,12 @@ typedef enum { * that are peers. */ -#if TCL_MAJOR_VERSION > 8 -#define TkSizeT size_t -#else -#define TkSizeT int +#ifndef TkSizeT +# if TCL_MAJOR_VERSION > 8 +# define TkSizeT size_t +# else +# define TkSizeT int +# endif #endif typedef struct TkSharedText { diff --git a/generic/ttk/ttkTheme.c b/generic/ttk/ttkTheme.c index 6ff76c2..2c65764 100644 --- a/generic/ttk/ttkTheme.c +++ b/generic/ttk/ttkTheme.c @@ -984,7 +984,7 @@ int InitializeElementRecord( int i; for (i=0; ioffset); + ((char *)elementRecord + elementOption->offset); const char *optionName = elementOption->optionName; Tcl_Obj *dynamicSetting = Ttk_StyleMap(style, optionName, state); Tcl_Obj *widgetValue = 0; diff --git a/generic/ttk/ttkTheme.h b/generic/ttk/ttkTheme.h index 9251dea..f087ce3 100644 --- a/generic/ttk/ttkTheme.h +++ b/generic/ttk/ttkTheme.h @@ -234,11 +234,19 @@ typedef void (Ttk_ElementSizeProc)(void *clientData, void *elementRecord, typedef void (Ttk_ElementDrawProc)(void *clientData, void *elementRecord, Tk_Window tkwin, Drawable d, Ttk_Box b, Ttk_State state); +#ifndef TkSizeT +# if TCL_MAJOR_VERSION > 8 +# define TkSizeT size_t +# else +# define TkSizeT int +# endif +#endif + typedef struct Ttk_ElementOptionSpec { const char *optionName; /* Command-line name of the widget option */ Tk_OptionType type; /* Accepted option types */ - int offset; /* Offset of Tcl_Obj* field in element record */ + TkSizeT offset; /* Offset of Tcl_Obj* field in element record */ const char *defaultValue; /* Default value to used if resource missing */ } Ttk_ElementOptionSpec; -- cgit v0.12 From c650f722da03d87c52824306cefeb20c03ebb8b4 Mon Sep 17 00:00:00 2001 From: fvogel Date: Wed, 17 Oct 2018 20:19:16 +0000 Subject: Add comments clarifying otherwise tacit assumptions. --- tests/scrollbar.test | 1 + unix/tkUnixScrlbr.c | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/tests/scrollbar.test b/tests/scrollbar.test index 6f00e78..dcfc711 100644 --- a/tests/scrollbar.test +++ b/tests/scrollbar.test @@ -24,6 +24,7 @@ proc getTroughSize {w} { return [expr [winfo width $w] - 2*[testmetrics cxhscroll $w]] } } else { + # Calculations here assume that the arrow area is a square. if [string match v* [$w cget -orient]] { return [expr [winfo height $w] \ - ([winfo width $w] \ diff --git a/unix/tkUnixScrlbr.c b/unix/tkUnixScrlbr.c index 0507211..2446c3f 100644 --- a/unix/tkUnixScrlbr.c +++ b/unix/tkUnixScrlbr.c @@ -289,6 +289,11 @@ TkpComputeScrollbarGeometry( scrollPtr->inset = scrollPtr->highlightWidth + scrollPtr->borderWidth; width = (scrollPtr->vertical) ? Tk_Width(scrollPtr->tkwin) : Tk_Height(scrollPtr->tkwin); + + /* + * Next line assumes that the arrow area is a square. + */ + scrollPtr->arrowLength = width - 2*scrollPtr->inset + 1; fieldLength = (scrollPtr->vertical ? Tk_Height(scrollPtr->tkwin) : Tk_Width(scrollPtr->tkwin)) -- cgit v0.12 From 03c56f10fafb50a75786d320f859aca952f9d123 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Wed, 17 Oct 2018 22:08:47 +0000 Subject: Missing type-casts. This only compiles on gcc, not on MSVC (e.g.) --- generic/tkConfig.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/generic/tkConfig.c b/generic/tkConfig.c index e8e85cd..46300d3 100644 --- a/generic/tkConfig.c +++ b/generic/tkConfig.c @@ -585,7 +585,7 @@ DoObjConfig( specPtr = optionPtr->specPtr; if (specPtr->objOffset != TCL_AUTO_LENGTH) { - slotPtrPtr = (Tcl_Obj **) (recordPtr + specPtr->objOffset); + slotPtrPtr = (Tcl_Obj **) ((char *)recordPtr + specPtr->objOffset); oldPtr = *slotPtrPtr; } else { slotPtrPtr = NULL; @@ -598,7 +598,7 @@ DoObjConfig( */ if (specPtr->internalOffset != TCL_AUTO_LENGTH) { - internalPtr = recordPtr + specPtr->internalOffset; + internalPtr = (char *)recordPtr + specPtr->internalOffset; } else { internalPtr = NULL; } @@ -1345,7 +1345,7 @@ Tk_RestoreSavedOptions( Tcl_Obj *newPtr; /* New object value of option, which we * replace with old value and free. Taken from * record. */ - char *internalPtr; /* Points to internal value of option in + void *internalPtr; /* Points to internal value of option in * record. */ const Tk_OptionSpec *specPtr; @@ -1370,12 +1370,12 @@ Tk_RestoreSavedOptions( */ if (specPtr->objOffset != TCL_AUTO_LENGTH) { - newPtr = *((Tcl_Obj **) (savePtr->recordPtr + specPtr->objOffset)); + newPtr = *((Tcl_Obj **) ((char *)savePtr->recordPtr + specPtr->objOffset)); } else { newPtr = NULL; } if (specPtr->internalOffset != TCL_AUTO_LENGTH) { - internalPtr = savePtr->recordPtr + specPtr->internalOffset; + internalPtr = (char *)savePtr->recordPtr + specPtr->internalOffset; } else { internalPtr = NULL; } @@ -1391,7 +1391,7 @@ Tk_RestoreSavedOptions( */ if (specPtr->objOffset != TCL_AUTO_LENGTH) { - *((Tcl_Obj **) (savePtr->recordPtr + specPtr->objOffset)) + *((Tcl_Obj **) ((char *)savePtr->recordPtr + specPtr->objOffset)) = savePtr->items[i].valuePtr; } if (specPtr->internalOffset != TCL_AUTO_LENGTH) { @@ -1549,14 +1549,14 @@ Tk_FreeConfigOptions( continue; } if (specPtr->objOffset != TCL_AUTO_LENGTH) { - oldPtrPtr = (Tcl_Obj **) (recordPtr + specPtr->objOffset); + oldPtrPtr = (Tcl_Obj **) ((char *)recordPtr + specPtr->objOffset); oldPtr = *oldPtrPtr; *oldPtrPtr = NULL; } else { oldPtr = NULL; } if (specPtr->internalOffset != TCL_AUTO_LENGTH) { - oldInternalPtr = recordPtr + specPtr->internalOffset; + oldInternalPtr = (char *)recordPtr + specPtr->internalOffset; } else { oldInternalPtr = NULL; } @@ -1825,7 +1825,7 @@ GetConfigList( Tcl_ListObjAppendElement(NULL, listPtr, elementPtr); if (optionPtr->specPtr->objOffset != TCL_AUTO_LENGTH) { - elementPtr = *((Tcl_Obj **) (recordPtr + elementPtr = *((Tcl_Obj **) ((char *)recordPtr + optionPtr->specPtr->objOffset)); if (elementPtr == NULL) { elementPtr = Tcl_NewObj(); @@ -1870,7 +1870,7 @@ GetObjectForOption( void *internalPtr; /* Points to internal value of option in * record. */ - internalPtr = recordPtr + optionPtr->specPtr->internalOffset; + internalPtr = (char *)recordPtr + optionPtr->specPtr->internalOffset; objPtr = NULL; switch (optionPtr->specPtr->type) { case TK_OPTION_BOOLEAN: @@ -2020,7 +2020,7 @@ Tk_GetOptionValue( optionPtr = optionPtr->extra.synonymPtr; } if (optionPtr->specPtr->objOffset != TCL_AUTO_LENGTH) { - resultPtr = *((Tcl_Obj **) (recordPtr+optionPtr->specPtr->objOffset)); + resultPtr = *((Tcl_Obj **) ((char *)recordPtr+optionPtr->specPtr->objOffset)); if (resultPtr == NULL) { /* * This option has a null value and is represented by a null -- cgit v0.12 From 461604826c89bd975a0d783c86a554e2974fce75 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Wed, 17 Oct 2018 22:24:22 +0000 Subject: =?UTF-8?q?One=20more=20missing=20type-cast=20(thanks,=20Fran?= =?UTF-8?q?=C3=A7ois!?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- generic/ttk/ttkTheme.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/generic/ttk/ttkTheme.c b/generic/ttk/ttkTheme.c index 2c65764..f98cc26 100644 --- a/generic/ttk/ttkTheme.c +++ b/generic/ttk/ttkTheme.c @@ -992,7 +992,7 @@ int InitializeElementRecord( if (optionMap[i]) { widgetValue = *(Tcl_Obj **) - (widgetRecord + optionMap[i]->objOffset); + ((char *)widgetRecord + optionMap[i]->objOffset); } if (widgetValue) { -- cgit v0.12 From 60f8872bd363431470f9d9a16b5fca3debd5318e Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Wed, 17 Oct 2018 22:30:59 +0000 Subject: Add warning -Wpointer-arith, so we detect things that MSVC cannot handle --- unix/configure | 2 +- unix/tcl.m4 | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/unix/configure b/unix/configure index 0cd3958..4eaf075 100755 --- a/unix/configure +++ b/unix/configure @@ -4274,7 +4274,7 @@ fi if test "$GCC" = yes; then : CFLAGS_OPTIMIZE=-O2 - CFLAGS_WARNING="-Wall -Wwrite-strings -Wsign-compare -Wdeclaration-after-statement" + CFLAGS_WARNING="-Wall -Wwrite-strings -Wsign-compare -Wdeclaration-after-statement -Wpointer-arith" else diff --git a/unix/tcl.m4 b/unix/tcl.m4 index b77387a..e27cc2c 100644 --- a/unix/tcl.m4 +++ b/unix/tcl.m4 @@ -986,7 +986,7 @@ AC_DEFUN([SC_CONFIG_CFLAGS], [ CFLAGS_DEBUG=-g AS_IF([test "$GCC" = yes], [ CFLAGS_OPTIMIZE=-O2 - CFLAGS_WARNING="-Wall -Wwrite-strings -Wsign-compare -Wdeclaration-after-statement" + CFLAGS_WARNING="-Wall -Wwrite-strings -Wsign-compare -Wdeclaration-after-statement -Wpointer-arith" ], [ CFLAGS_OPTIMIZE=-O CFLAGS_WARNING="" -- cgit v0.12 From 27b3337d4b5ea22889681562e41c2008f31eda87 Mon Sep 17 00:00:00 2001 From: Kevin Walzer Date: Thu, 18 Oct 2018 11:41:26 +0000 Subject: Restore some missing changes stripped out in in merge of Mac scroll code --- macosx/tkMacOSXScrlbr.c | 36 ++++++++++++++++++++---------------- 1 file changed, 20 insertions(+), 16 deletions(-) diff --git a/macosx/tkMacOSXScrlbr.c b/macosx/tkMacOSXScrlbr.c index f7f9489..00b0d84 100644 --- a/macosx/tkMacOSXScrlbr.c +++ b/macosx/tkMacOSXScrlbr.c @@ -279,15 +279,16 @@ TkpComputeScrollbarGeometry( * window, if any). Then arrange for the window to be redisplayed. */ - if (scrollPtr->vertical) { + if (scrollPtr->vertical) { Tk_GeometryRequest(scrollPtr->tkwin, scrollPtr->width + 2*scrollPtr->inset, 2*(scrollPtr->arrowLength + scrollPtr->borderWidth - + scrollPtr->inset)); + + scrollPtr->inset) + metrics.minThumbHeight); } else { Tk_GeometryRequest(scrollPtr->tkwin, 2*(scrollPtr->arrowLength + scrollPtr->borderWidth - + scrollPtr->inset), scrollPtr->width + 2*scrollPtr->inset); + + scrollPtr->inset) + metrics.minThumbHeight, + scrollPtr->width + 2*scrollPtr->inset); } Tk_SetInternalBorder(scrollPtr->tkwin, scrollPtr->inset); } @@ -376,30 +377,30 @@ TkpScrollbarPosition( int x, int y) /* Coordinates within scrollPtr's window. */ { - /* + /* * Using code from tkUnixScrlbr.c because Unix scroll bindings are * driving the display at the script level. All the Mac scrollbar * has to do is re-draw itself. */ - int length, fieldlength, width, tmp; + int length, width, tmp; register const int inset = scrollPtr->inset; - register const int arrowSize = scrollPtr->arrowLength + inset; + if (scrollPtr->vertical) { length = Tk_Height(scrollPtr->tkwin); - fieldlength = length - 2 * arrowSize; + width = Tk_Width(scrollPtr->tkwin); } else { tmp = x; x = y; y = tmp; length = Tk_Width(scrollPtr->tkwin); - fieldlength = length - 2 * arrowSize; + width = Tk_Height(scrollPtr->tkwin); } - fieldlength = fieldlength < 0 ? 0 : fieldlength; + if (x=width-inset || y=length-inset) { return OUTSIDE; @@ -410,19 +411,22 @@ TkpScrollbarPosition( * TkpDisplayScrollbar. Be sure to keep the two consistent. */ + if (y < inset + scrollPtr->arrowLength) { + return TOP_ARROW; + } if (y < scrollPtr->sliderFirst) { return TOP_GAP; } - if (y < scrollPtr->sliderLast) { + if (y < scrollPtr->sliderLast){ return SLIDER; } - if (y < fieldlength){ - return BOTTOM_GAP; - } - if (y < fieldlength + arrowSize) { - return TOP_ARROW; + if (y >= length - (scrollPtr->arrowLength + inset)) { + return BOTTOM_ARROW; } - return BOTTOM_ARROW; + + + + return BOTTOM_GAP; } -- cgit v0.12 From 55efec56a93c297c587dbfc0aad4b20e6b73e9d5 Mon Sep 17 00:00:00 2001 From: Kevin Walzer Date: Thu, 18 Oct 2018 11:42:49 +0000 Subject: Restore some missing changes stripd out in in merge of Mac scroll code --- macosx/tkMacOSXScrlbr.c | 40 ++++++++++++++++++++++------------------ 1 file changed, 22 insertions(+), 18 deletions(-) diff --git a/macosx/tkMacOSXScrlbr.c b/macosx/tkMacOSXScrlbr.c index d21638d..76f5b1e 100644 --- a/macosx/tkMacOSXScrlbr.c +++ b/macosx/tkMacOSXScrlbr.c @@ -68,7 +68,7 @@ typedef struct ScrollbarMetrics { static ScrollbarMetrics metrics = { - (15, 54, 26, 14, 14, kControlSizeNormal), /* kThemeScrollBarMedium */ + 15, 54, 26, 14, 14, kControlSizeNormal /* kThemeScrollBarMedium */ }; HIThemeTrackDrawInfo info = { @@ -279,15 +279,16 @@ TkpComputeScrollbarGeometry( * window, if any). Then arrange for the window to be redisplayed. */ - if (scrollPtr->vertical) { + if (scrollPtr->vertical) { Tk_GeometryRequest(scrollPtr->tkwin, scrollPtr->width + 2*scrollPtr->inset, 2*(scrollPtr->arrowLength + scrollPtr->borderWidth - + scrollPtr->inset)); + + scrollPtr->inset) + metrics.minThumbHeight); } else { Tk_GeometryRequest(scrollPtr->tkwin, 2*(scrollPtr->arrowLength + scrollPtr->borderWidth - + scrollPtr->inset), scrollPtr->width + 2*scrollPtr->inset); + + scrollPtr->inset) + metrics.minThumbHeight, + scrollPtr->width + 2*scrollPtr->inset); } Tk_SetInternalBorder(scrollPtr->tkwin, scrollPtr->inset); } @@ -376,30 +377,30 @@ TkpScrollbarPosition( int x, int y) /* Coordinates within scrollPtr's window. */ { - /* + /* * Using code from tkUnixScrlbr.c because Unix scroll bindings are * driving the display at the script level. All the Mac scrollbar * has to do is re-draw itself. */ - int length, fieldlength, width, tmp; + int length, width, tmp; register const int inset = scrollPtr->inset; - register const int arrowSize = scrollPtr->arrowLength + inset; + if (scrollPtr->vertical) { length = Tk_Height(scrollPtr->tkwin); - fieldlength = length - 2 * arrowSize; + width = Tk_Width(scrollPtr->tkwin); } else { tmp = x; x = y; y = tmp; length = Tk_Width(scrollPtr->tkwin); - fieldlength = length - 2 * arrowSize; + width = Tk_Height(scrollPtr->tkwin); } - fieldlength = fieldlength < 0 ? 0 : fieldlength; + if (x=width-inset || y=length-inset) { return OUTSIDE; @@ -410,19 +411,22 @@ TkpScrollbarPosition( * TkpDisplayScrollbar. Be sure to keep the two consistent. */ + if (y < inset + scrollPtr->arrowLength) { + return TOP_ARROW; + } if (y < scrollPtr->sliderFirst) { return TOP_GAP; } - if (y < scrollPtr->sliderLast) { + if (y < scrollPtr->sliderLast){ return SLIDER; } - if (y < fieldlength){ - return BOTTOM_GAP; - } - if (y < fieldlength + arrowSize) { - return TOP_ARROW; + if (y >= length - (scrollPtr->arrowLength + inset)) { + return BOTTOM_ARROW; } - return BOTTOM_ARROW; + + + + return BOTTOM_GAP; } @@ -481,7 +485,7 @@ UpdateControlValues( } else { info.attributes |= kThemeTrackHorizontal; } - + /* * Given the Tk parameters for the fractions of the start and end of the * thumb, the following calculation determines the location for the -- cgit v0.12 From b0730dbdfcc00d4086484b72998e7877277788cf Mon Sep 17 00:00:00 2001 From: culler Date: Thu, 18 Oct 2018 15:51:54 +0000 Subject: Removed all traces of the TkSuspendClipboard stub. --- generic/tkInt.decls | 6 +++--- generic/tkIntPlatDecls.h | 8 +++----- generic/tkStubInit.c | 2 +- macosx/tkMacOSXClipboard.c | 22 ---------------------- macosx/tkMacOSXWindowEvent.c | 3 +++ 5 files changed, 10 insertions(+), 31 deletions(-) diff --git a/generic/tkInt.decls b/generic/tkInt.decls index a13d8d7..d0b7678 100644 --- a/generic/tkInt.decls +++ b/generic/tkInt.decls @@ -983,9 +983,9 @@ declare 38 aqua { declare 39 aqua { void TkSetWMName(TkWindow *winPtr, Tk_Uid titleUid) } -declare 40 aqua { - void TkSuspendClipboard(void) -} +# +# Slot 40 unused (WAS: TkSuspendClipboard) +# declare 41 aqua { int TkMacOSXZoomToplevel(void *whichWindow, short zoomPart) } diff --git a/generic/tkIntPlatDecls.h b/generic/tkIntPlatDecls.h index e48e803..c666e3d 100644 --- a/generic/tkIntPlatDecls.h +++ b/generic/tkIntPlatDecls.h @@ -224,8 +224,7 @@ EXTERN void TkMacOSXWindowOffset(void *wRef, int *xOffset, EXTERN int TkSetMacColor(unsigned long pixel, void *macColor); /* 39 */ EXTERN void TkSetWMName(TkWindow *winPtr, Tk_Uid titleUid); -/* 40 */ -EXTERN void TkSuspendClipboard(void); +/* Slot 40 is reserved */ /* 41 */ EXTERN int TkMacOSXZoomToplevel(void *whichWindow, short zoomPart); @@ -384,7 +383,7 @@ typedef struct TkIntPlatStubs { void (*tkMacOSXWindowOffset) (void *wRef, int *xOffset, int *yOffset); /* 37 */ int (*tkSetMacColor) (unsigned long pixel, void *macColor); /* 38 */ void (*tkSetWMName) (TkWindow *winPtr, Tk_Uid titleUid); /* 39 */ - void (*tkSuspendClipboard) (void); /* 40 */ + void (*reserved40) (void); int (*tkMacOSXZoomToplevel) (void *whichWindow, short zoomPart); /* 41 */ Tk_Window (*tk_TopCoordsToWindow) (Tk_Window tkwin, int rootX, int rootY, int *newX, int *newY); /* 42 */ MacDrawable * (*tkMacOSXContainerId) (TkWindow *winPtr); /* 43 */ @@ -599,8 +598,7 @@ extern const TkIntPlatStubs *tkIntPlatStubsPtr; (tkIntPlatStubsPtr->tkSetMacColor) /* 38 */ #define TkSetWMName \ (tkIntPlatStubsPtr->tkSetWMName) /* 39 */ -#define TkSuspendClipboard \ - (tkIntPlatStubsPtr->tkSuspendClipboard) /* 40 */ +/* Slot 40 is reserved */ #define TkMacOSXZoomToplevel \ (tkIntPlatStubsPtr->tkMacOSXZoomToplevel) /* 41 */ #define Tk_TopCoordsToWindow \ diff --git a/generic/tkStubInit.c b/generic/tkStubInit.c index 9411c26..7e02302 100644 --- a/generic/tkStubInit.c +++ b/generic/tkStubInit.c @@ -547,7 +547,7 @@ static const TkIntPlatStubs tkIntPlatStubs = { TkMacOSXWindowOffset, /* 37 */ TkSetMacColor, /* 38 */ TkSetWMName, /* 39 */ - TkSuspendClipboard, /* 40 */ + 0, /* 40 */ TkMacOSXZoomToplevel, /* 41 */ Tk_TopCoordsToWindow, /* 42 */ TkMacOSXContainerId, /* 43 */ diff --git a/macosx/tkMacOSXClipboard.c b/macosx/tkMacOSXClipboard.c index 4bd39ae..9b65bc3 100644 --- a/macosx/tkMacOSXClipboard.c +++ b/macosx/tkMacOSXClipboard.c @@ -289,28 +289,6 @@ TkSelPropProc( } /* - *---------------------------------------------------------------------- - * - * TkSuspendClipboard -- - * - * Handle clipboard conversion as required by the suppend event. - * - * Results: - * None. - * - * Side effects: - * The value of changeCount is synchronized. - * - *---------------------------------------------------------------------- - */ - -void -TkSuspendClipboard(void) -{ - changeCount = [[NSPasteboard generalPasteboard] changeCount]; -} - -/* * Local Variables: * mode: objc * c-basic-offset: 4 diff --git a/macosx/tkMacOSXWindowEvent.c b/macosx/tkMacOSXWindowEvent.c index f7a2999..61817c4 100644 --- a/macosx/tkMacOSXWindowEvent.c +++ b/macosx/tkMacOSXWindowEvent.c @@ -67,6 +67,9 @@ extern NSString *NSWindowDidOrderOffScreenNotification; #ifdef TK_MAC_DEBUG_NOTIFICATIONS TKLog(@"-[%@(%p) %s] %@", [self class], self, _cmd, notification); #endif + BOOL movedOnly = [[notification name] + isEqualToString:NSWindowDidMoveNotification]; + NSWindow *w = [notification object]; TkWindow *winPtr = TkMacOSXGetTkWindow(w); -- cgit v0.12 From 4e54b1b43919621c5d881e4c61a9ee2b74467ced Mon Sep 17 00:00:00 2001 From: fvogel Date: Thu, 18 Oct 2018 18:48:22 +0000 Subject: Restore the remaining missing changes stripped out due to the recent merge/backout dance between branches (scrollbar fixes and Mojave fixes). --- generic/tkTest.c | 33 +++++---------------------------- macosx/tkMacOSXScrlbr.c | 9 +-------- tests/scrollbar.test | 34 +++++++++++++++++++++++++++++++--- 3 files changed, 37 insertions(+), 39 deletions(-) diff --git a/generic/tkTest.c b/generic/tkTest.c index 1fa461e..2dbd877 100644 --- a/generic/tkTest.c +++ b/generic/tkTest.c @@ -168,7 +168,7 @@ static int TestmenubarObjCmd(ClientData dummy, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]); #endif -#if defined(_WIN32) || defined(MAC_OSX_TK) +#if defined(_WIN32) static int TestmetricsObjCmd(ClientData dummy, Tcl_Interp *interp, int objc, Tcl_Obj * const objv[]); @@ -266,17 +266,17 @@ Tktest_Init( Tcl_CreateObjCommand(interp, "testtext", TkpTesttextCmd, (ClientData) Tk_MainWindow(interp), NULL); -#if defined(_WIN32) || defined(MAC_OSX_TK) +#if defined(_WIN32) Tcl_CreateObjCommand(interp, "testmetrics", TestmetricsObjCmd, (ClientData) Tk_MainWindow(interp), NULL); -#elif !defined(__CYGWIN__) +#elif !defined(__CYGWIN__) && !defined(MAC_OSX_TK) Tcl_CreateObjCommand(interp, "testmenubar", TestmenubarObjCmd, (ClientData) Tk_MainWindow(interp), NULL); Tcl_CreateObjCommand(interp, "testsend", TkpTestsendCmd, (ClientData) Tk_MainWindow(interp), NULL); Tcl_CreateObjCommand(interp, "testwrapper", TestwrapperObjCmd, (ClientData) Tk_MainWindow(interp), NULL); -#endif /* _WIN32 || MAC_OSX_TK */ +#endif /* _WIN32 */ /* * Create test image type. @@ -1764,7 +1764,7 @@ TestmenubarObjCmd( *---------------------------------------------------------------------- */ -#if defined(_WIN32) || defined(MAC_OSX_TK) +#if defined(_WIN32) static int TestmetricsObjCmd( ClientData clientData, /* Main window for application. */ @@ -1775,38 +1775,15 @@ TestmetricsObjCmd( char buf[TCL_INTEGER_SPACE]; int val; -#ifdef _WIN32 if (objc < 2) { Tcl_WrongNumArgs(interp, 1, objv, "option ?arg ...?"); return TCL_ERROR; } -#else - Tk_Window tkwin = (Tk_Window) clientData; - TkWindow *winPtr; - - if (objc != 3) { - Tcl_WrongNumArgs(interp, 1, objv, "option window"); - return TCL_ERROR; - } - - winPtr = (TkWindow *) Tk_NameToWindow(interp, Tcl_GetString(objv[2]), tkwin); - if (winPtr == NULL) { - return TCL_ERROR; - } -#endif if (strcmp(Tcl_GetString(objv[1]), "cyvscroll") == 0) { -#ifdef _WIN32 val = GetSystemMetrics(SM_CYVSCROLL); -#else - val = ((TkScrollbar *) winPtr->instanceData)->width; -#endif } else if (strcmp(Tcl_GetString(objv[1]), "cxhscroll") == 0) { -#ifdef _WIN32 val = GetSystemMetrics(SM_CXHSCROLL); -#else - val = ((TkScrollbar *) winPtr->instanceData)->width; -#endif } else { Tcl_AppendResult(interp, "bad option \"", Tcl_GetString(objv[1]), "\": must be cxhscroll or cyvscroll", NULL); diff --git a/macosx/tkMacOSXScrlbr.c b/macosx/tkMacOSXScrlbr.c index 00b0d84..f15146d 100644 --- a/macosx/tkMacOSXScrlbr.c +++ b/macosx/tkMacOSXScrlbr.c @@ -386,22 +386,17 @@ TkpScrollbarPosition( int length, width, tmp; register const int inset = scrollPtr->inset; - if (scrollPtr->vertical) { length = Tk_Height(scrollPtr->tkwin); - width = Tk_Width(scrollPtr->tkwin); } else { tmp = x; x = y; y = tmp; length = Tk_Width(scrollPtr->tkwin); - width = Tk_Height(scrollPtr->tkwin); } - - if (x=width-inset || y=length-inset) { return OUTSIDE; } @@ -417,15 +412,13 @@ TkpScrollbarPosition( if (y < scrollPtr->sliderFirst) { return TOP_GAP; } - if (y < scrollPtr->sliderLast){ + if (y < scrollPtr->sliderLast) { return SLIDER; } if (y >= length - (scrollPtr->arrowLength + inset)) { return BOTTOM_ARROW; } - - return BOTTOM_GAP; } diff --git a/tests/scrollbar.test b/tests/scrollbar.test index af83e93..dcfc711 100644 --- a/tests/scrollbar.test +++ b/tests/scrollbar.test @@ -284,7 +284,7 @@ test scrollbar-3.41 {ScrollbarWidgetCmd procedure, "fraction" option} { if {[testConstraint testmetrics]} { place configure .t.s -width [expr 2*[testmetrics cxhscroll .t.s]+1] } else { - place configure .t.s -width [expr [winfo reqwidth .t.s] - 4] + place configure .t.s -width [expr [winfo height .t.s] - 2*([.t.s cget -highlightthickness] + [.t.s cget -bd] + 1)] } update test scrollbar-3.42 {ScrollbarWidgetCmd procedure, "fraction" option} { @@ -633,7 +633,7 @@ test scrollbar-9.1 {scrollbar widget vs hidden commands} { list [winfo children .] [interp hidden] } [list {} $l] -test scrollbar-10.1 { event on scrollbar} -constraints {win|unix} -setup { +test scrollbar-10.1.1 { event on scrollbar} -constraints {notAqua} -setup { destroy .t .s } -body { pack [text .t -yscrollcommand {.s set}] -side left @@ -647,8 +647,22 @@ test scrollbar-10.1 { event on scrollbar} -constraints {win|unix} -s } -cleanup { destroy .t .s } -result {5.0} +test scrollbar-10.1.2 { event on scrollbar} -constraints {aqua} -setup { + destroy .t .s +} -body { + pack [text .t -yscrollcommand {.s set}] -side left + for {set i 1} {$i < 100} {incr i} {.t insert end "Line $i\n"} + pack [scrollbar .s -command {.t yview}] -fill y -expand 1 -side left + update + focus -force .s + event generate .s -delta -4 + after 200 {set eventprocessed 1} ; vwait eventprocessed + .t index @0,0 +} -cleanup { + destroy .t .s +} -result {5.0} -test scrollbar-10.2 { event on scrollbar} -constraints {win|unix} -setup { +test scrollbar-10.2.1 { event on scrollbar} -constraints {notAqua} -setup { destroy .t .s } -body { pack [text .t -xscrollcommand {.s set} -wrap none] -side top @@ -662,6 +676,20 @@ test scrollbar-10.2 { event on scrollbar} -constraints {win|unix} -s } -cleanup { destroy .t .s } -result {1.4} +test scrollbar-10.2.2 { event on scrollbar} -constraints {aqua} -setup { + destroy .t .s +} -body { + pack [text .t -xscrollcommand {.s set} -wrap none] -side top + for {set i 1} {$i < 100} {incr i} {.t insert end "Char $i "} + pack [scrollbar .s -command {.t xview} -orient horizontal] -fill x -expand 1 -side top + update + focus -force .s + event generate .s -delta -4 + after 200 {set eventprocessed 1} ; vwait eventprocessed + .t index @0,0 +} -cleanup { + destroy .t .s +} -result {1.4} test scrollbar-11.1 {bug fix: [011706ec42] Scrollbar unsafe wrt widget destruction} -body { proc destroy_scrollbar {} { -- cgit v0.12 From dd711f199cb486be0e91ea582d3b9645c90bb3b5 Mon Sep 17 00:00:00 2001 From: fvogel Date: Thu, 18 Oct 2018 20:16:30 +0000 Subject: Fix scrollbar.test: all tests that run on macOS now pass (and that's true for each platform BTW: Windows, Linux and macOS). --- tests/scrollbar.test | 106 +++++++++++++++++++++++++++++++++++++++------------ 1 file changed, 81 insertions(+), 25 deletions(-) diff --git a/tests/scrollbar.test b/tests/scrollbar.test index dcfc711..d740f7c 100644 --- a/tests/scrollbar.test +++ b/tests/scrollbar.test @@ -18,24 +18,38 @@ proc scroll args { proc getTroughSize {w} { if {[testConstraint testmetrics]} { + # Only Windows has [testmetrics] if [string match v* [$w cget -orient]] { return [expr [winfo height $w] - 2*[testmetrics cyvscroll $w]] } else { return [expr [winfo width $w] - 2*[testmetrics cxhscroll $w]] } } else { - # Calculations here assume that the arrow area is a square. - if [string match v* [$w cget -orient]] { - return [expr [winfo height $w] \ - - ([winfo width $w] \ - - [$w cget -highlightthickness] \ - - [$w cget -bd] + 1)*2] - } else { - return [expr [winfo width $w] \ - - ([winfo height $w] \ - - [$w cget -highlightthickness] \ - - [$w cget -bd] + 1)*2] - } + if {[tk windowingsystem] eq "x11"} { + # Calculations here assume that the arrow area is a square. + if [string match v* [$w cget -orient]] { + return [expr [winfo height $w] \ + - ([winfo width $w] \ + - [$w cget -highlightthickness] \ + - [$w cget -bd] + 1)*2] + } else { + return [expr [winfo width $w] \ + - ([winfo height $w] \ + - [$w cget -highlightthickness] \ + - [$w cget -bd] + 1)*2] + } + } else { + # macOS aqua + if [string match v* [$w cget -orient]] { + return [expr [winfo height $w] \ + - ([$w cget -highlightthickness] \ + +[$w cget -bd])*2] + } else { + return [expr [winfo width $w] \ + - ([$w cget -highlightthickness] \ + +[$w cget -bd])*2] + } + } } } @@ -256,13 +270,13 @@ test scrollbar-3.35 {ScrollbarWidgetCmd procedure, "fraction" option} { format {%.6g} [.s fraction 4 21] } [format %.6g [expr (21.0 - ([winfo height .s] - [getTroughSize .s])/2.0) \ /([getTroughSize .s] - 1)]] -test scrollbar-3.36 {ScrollbarWidgetCmd procedure, "fraction" option} unix { +test scrollbar-3.36 {ScrollbarWidgetCmd procedure, "fraction" option} x11 { format {%.6g} [.s fraction 4 179] } {1} test scrollbar-3.37 {ScrollbarWidgetCmd procedure, "fraction" option} {testmetrics} { format {%.6g} [.s fraction 4 [expr 200 - [testmetrics cyvscroll .s]]] } {1} -test scrollbar-3.38 {ScrollbarWidgetCmd procedure, "fraction" option} unix { +test scrollbar-3.38 {ScrollbarWidgetCmd procedure, "fraction" option} x11 { format {%.6g} [.s fraction 4 178] } {0.993711} test scrollbar-3.39 {ScrollbarWidgetCmd procedure, "fraction" option} {testmetrics win} { @@ -282,9 +296,15 @@ test scrollbar-3.41 {ScrollbarWidgetCmd procedure, "fraction" option} { format {%.6g} [.t.s fraction 100 0] } {0.5} if {[testConstraint testmetrics]} { + # Only Windows has [testmetrics] place configure .t.s -width [expr 2*[testmetrics cxhscroll .t.s]+1] } else { - place configure .t.s -width [expr [winfo height .t.s] - 2*([.t.s cget -highlightthickness] + [.t.s cget -bd] + 1)] + if {[tk windowingsystem] eq "x11"} { + place configure .t.s -width [expr [winfo height .t.s] - 2*([.t.s cget -highlightthickness] + [.t.s cget -bd] + 1)] + } else { + # macOS aqua + place configure .t.s -width [expr 2*([.t.s cget -highlightthickness] + [.t.s cget -bd])] + } } update test scrollbar-3.42 {ScrollbarWidgetCmd procedure, "fraction" option} { @@ -318,9 +338,13 @@ test scrollbar-3.48 {ScrollbarWidgetCmd procedure, "identify" option} { test scrollbar-3.49 {ScrollbarWidgetCmd procedure, "identify" option} { list [catch {.s identify -1 bogus} msg] $msg } {1 {expected integer but got "bogus"}} -test scrollbar-3.50 {ScrollbarWidgetCmd procedure, "identify" option} { +test scrollbar-3.50.1 {ScrollbarWidgetCmd procedure, "identify" option} notAqua { .s identify 5 5 } {arrow1} +test scrollbar-3.50.1 {ScrollbarWidgetCmd procedure, "identify" option} aqua { + # macOS scrollbars have no arrows nowadays + .s identify 5 5 +} {trough1} test scrollbar-3.51 {ScrollbarWidgetCmd procedure, "identify" option} { .s identify 5 35 } {trough1} @@ -331,9 +355,13 @@ test scrollbar-3.52 {ScrollbarWidgetCmd procedure, "identify" option} { test scrollbar-3.53 {ScrollbarWidgetCmd procedure, "identify" option} { .s identify 5 145 } {trough2} -test scrollbar-3.54 {ScrollbarWidgetCmd procedure, "identify" option} {unixOrPc} { +test scrollbar-3.54.1 {ScrollbarWidgetCmd procedure, "identify" option} notAqua { .s identify 5 195 } {arrow2} +test scrollbar-3.54.2 {ScrollbarWidgetCmd procedure, "identify" option} aqua { + # macOS scrollbars have no arrows nowadays + .s identify 5 195 +} {trough2} test scrollbar-3.56 {ScrollbarWidgetCmd procedure, "identify" option} unix { .s identify 0 0 } {} @@ -456,12 +484,20 @@ test scrollbar-6.9 {ScrollbarPosition procedure} { test scrollbar-6.10 {ScrollbarPosition procedure} { .s identify [winfo width .s] [expr [winfo height .s] / 2] } {} -test scrollbar-6.11 {ScrollbarPosition procedure} unix { +test scrollbar-6.11.1 {ScrollbarPosition procedure} x11 { .s identify 8 4 } {arrow1} -test scrollbar-6.12 {ScrollbarPosition procedure} unix { +test scrollbar-6.11.2 {ScrollbarPosition procedure} aqua { + # macOS scrollbars have no arrows nowadays + .s identify 8 4 +} {trough1} +test scrollbar-6.12.1 {ScrollbarPosition procedure} x11 { .s identify 8 19 } {arrow1} +test scrollbar-6.12.2 {ScrollbarPosition procedure} aqua { + # macOS scrollbars have no arrows nowadays + .s identify 8 19 +} {trough1} test scrollbar-6.14 {ScrollbarPosition procedure} win { .s identify [expr [winfo width .s] / 2] 0 } {arrow1} @@ -517,12 +553,20 @@ test scrollbar-6.28 {ScrollbarPosition procedure} {testmetrics win} { .s identify [expr [winfo width .s] / 2] [expr [winfo height .s] \ - [testmetrics cyvscroll .s] - 1] } {trough2} -test scrollbar-6.29 {ScrollbarPosition procedure} unix { +test scrollbar-6.29.1 {ScrollbarPosition procedure} x11 { .s identify 8 180 } {arrow2} -test scrollbar-6.30 {ScrollbarPosition procedure} unix { +test scrollbar-6.29.2 {ScrollbarPosition procedure} aqua { + # macOS scrollbars have no arrows nowadays + .s identify 8 180 +} {trough2} +test scrollbar-6.30.1 {ScrollbarPosition procedure} x11 { .s identify 8 195 } {arrow2} +test scrollbar-6.30.2 {ScrollbarPosition procedure} aqua { + # macOS scrollbars have no arrows nowadays + .s identify 8 195 +} {trough2} test scrollbar-6.32 {ScrollbarPosition procedure} {testmetrics win} { .s identify [expr [winfo width .s] / 2] [expr [winfo height .s] \ - [testmetrics cyvscroll .s]] @@ -551,15 +595,23 @@ place .t.s -width 200 .t.s set .2 .4 update -test scrollbar-6.39 {ScrollbarPosition procedure} unix { +test scrollbar-6.39.1 {ScrollbarPosition procedure} x11 { .t.s identify 4 8 } {arrow1} +test scrollbar-6.39.2 {ScrollbarPosition procedure} aqua { + # macOS scrollbars have no arrows nowadays + .t.s identify 4 8 +} {trough1} test scrollbar-6.40 {ScrollbarPosition procedure} win { .t.s identify 0 [expr [winfo height .t.s] / 2] } {arrow1} -test scrollbar-6.41 {ScrollbarPosition procedure} unix { +test scrollbar-6.41.1 {ScrollbarPosition procedure} x11 { .t.s identify 82 8 } {slider} +test scrollbar-6.41.2 {ScrollbarPosition procedure} aqua { + # macOS scrollbars have no arrows nowadays + .t.s identify 82 8 +} {trough2} test scrollbar-6.43 {ScrollbarPosition procedure} {testmetrics win} { .t.s identify [expr int(.4 / [.t.s delta 1 0]) + [testmetrics cxhscroll .t.s] \ - 1] [expr [winfo height .t.s] / 2] @@ -583,7 +635,9 @@ test scrollbar-7.1 {EventuallyRedraw} { catch {destroy .t} toplevel .t wm geometry .t +0+0 -test scrollbar-8.1 {TkScrollbarEventProc: recursive deletion} { +test scrollbar-8.1 {TkScrollbarEventProc: recursive deletion} notAqua { + # constrained by notAqua because this test clicks on an arrow of the + # scrollbar - but macOS has no such arrows in modern scrollbars proc doit {args} { destroy .t.f } proc bgerror {args} {} destroy .t.f @@ -602,7 +656,9 @@ test scrollbar-8.1 {TkScrollbarEventProc: recursive deletion} { rename bgerror {} set result } {1 0 0} -test scrollbar-8.2 {TkScrollbarEventProc: recursive deletion} { +test scrollbar-8.2 {TkScrollbarEventProc: recursive deletion} notAqua { + # constrained by notAqua because this test clicks on an arrow of the + # scrollbar - but macOS has no such arrows in modern scrollbars proc doit {args} { destroy .t.f.s } proc bgerror {args} {} destroy .t.f -- cgit v0.12 From f0e0adc0322734e17b059f3ca33f5cea96b1256f Mon Sep 17 00:00:00 2001 From: Joe Mistachkin Date: Fri, 19 Oct 2018 03:05:27 +0000 Subject: Add test for ticket [766ef52f3]. --- tests/option.test | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/tests/option.test b/tests/option.test index ea5b5d1..b00aff6 100644 --- a/tests/option.test +++ b/tests/option.test @@ -415,6 +415,22 @@ test option-16.1 {ReadOptionFile} -body { removeFile $option4 } -result {true false} +set opt162val {label { + foo bar +} +} +set opt162list [split $opt162val \n] + +test option-16.2 {ticket 766ef52f3} { + set option5 [makeFile {} option.file4] + set file [open $option5 w] + fconfigure $file -translation crlf + puts $file "*notok: $opt162list" + close $file + option read $option5 userDefault + option get . notok notok +} $opt162list + deleteWindows # cleanup -- cgit v0.12 From 69ab57308dd6a687eaecca6794379b70afa7b6c6 Mon Sep 17 00:00:00 2001 From: Joe Mistachkin Date: Fri, 19 Oct 2018 03:30:24 +0000 Subject: Proposed fix for ticket [766ef52f31]. --- generic/tkOption.c | 5 ++++- tests/option.test | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/generic/tkOption.c b/generic/tkOption.c index 24e7fb3..545a9b9 100644 --- a/generic/tkOption.c +++ b/generic/tkOption.c @@ -996,6 +996,9 @@ AddFromString( while ((*src == ' ') || (*src == '\t')) { src++; } + if (*src == '\\' && (src[1] == '\t' || src[1] == ' ')) { + src++; + } if (*src == '\0') { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "missing value on line %d", lineNum)); @@ -1025,7 +1028,7 @@ AddFromString( src += 2; *dst++ = '\n'; continue; - } else if (src[1] == '\t' || src[1] == ' ' || src[1] == '\\') { + } else if (src[1] == '\\') { ++src; } else if (src[1] >= '0' && src[1] <= '3' && src[2] >= '0' && src[2] <= '9' && src[3] >= '0' && src[3] <= '9') { diff --git a/tests/option.test b/tests/option.test index b00aff6..c8e29da 100644 --- a/tests/option.test +++ b/tests/option.test @@ -386,7 +386,7 @@ test option-15.6 {database files} -body { test option-15.7 {database files} -body { option read $option1 option get . x9 color -} -result " \t\\A\n" +} -result " \\\t\\A\n" test option-15.8 {database files} -body { option read $option1 widget foo } -returnCodes error -result {wrong # args: should be "option readfile fileName ?priority?"} -- cgit v0.12 From cde594cd3265075437c973761f074a82929986b1 Mon Sep 17 00:00:00 2001 From: fvogel Date: Fri, 19 Oct 2018 17:13:58 +0000 Subject: Remove 'knownBug' constraint on tests that do pass without it (text-22.199 and 22.200), and fix error in the regexp for other tests (text-22.202 and 22.203) that then pass (constraint 'knownBug' removed as well therefore). --- tests/text.test | 21 ++++++--------------- 1 file changed, 6 insertions(+), 15 deletions(-) diff --git a/tests/text.test b/tests/text.test index 6155802..5eadeac 100644 --- a/tests/text.test +++ b/tests/text.test @@ -5557,9 +5557,7 @@ test text-22.198 {TextSearchCmd, regexp search multi-line} -body { } -cleanup { destroy .t } -result {2.0 19} -test text-22.199 {TextSearchCmd, regexp search multi-line} -constraints { - knownBug -} -body { +test text-22.199 {TextSearchCmd, regexp search multi-line} -body { pack [text .t] .t insert 1.0 "aaaa\nbbbb\ncccc\nbbbb\naaaa\n" set foo {} @@ -5568,9 +5566,7 @@ test text-22.199 {TextSearchCmd, regexp search multi-line} -constraints { } -cleanup { destroy .t } -result {2.0 19} -test text-22.200 {TextSearchCmd, regexp search multi-line} -constraints { - knownBug -} -body { +test text-22.200 {TextSearchCmd, regexp search multi-line} -body { pack [text .t] .t insert 1.0 "aaaa\nbbbb\ncccc\nbbbb\naaaa\n" set foo {} @@ -5588,23 +5584,18 @@ test text-22.201 {TextSearchCmd, regexp search multi-line} -body { } -cleanup { destroy .t } -result {1.0 24} -test text-22.202 {TextSearchCmd, regexp search multi-line} -constraints { - knownBug -} -body { +test text-22.202 {TextSearchCmd, regexp search multi-line} -body { pack [text .t] .t insert 1.0 "aaaa\nbbbb\nbbbb\nbbbb\nbbbb\n" list [.t search -regexp -backward -all -count foo \ - -- {b+\n|a+\n(b+\n)+} end] $foo + -- {(b+\n|a+\n)(b+\n)+} end] $foo } -cleanup { destroy .t } -result {1.0 25} -test text-22.203 {TextSearchCmd, regexp search multi-line} -constraints { - knownBug -} -body { +test text-22.203 {TextSearchCmd, regexp search multi-line} -body { pack [text .t] .t insert 1.0 "aaaa\nbbbb\nbbbb\nbbbb\nbbbb\n" - .t search -regexp -backward -- {b+\n|a+\n(b+\n)+} end -# Should match at 1.0 for a true greedy match + .t search -regexp -backward -- {(b+\n|a+\n)(b+\n)+} end } -cleanup { destroy .t } -result {1.0} -- cgit v0.12 From 38f526f519657d58703e013e4415a7e4788ec33f Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Fri, 19 Oct 2018 19:34:25 +0000 Subject: Eliminate CONST86: Since Tk 8.7 only compiles with Tcl >= 8.6 anyway, we just can use "const" everywhere. typo's: occured -> occurred --- ChangeLog.2002 | 2 +- ChangeLog.2004 | 2 +- changes | 2 +- generic/tk.decls | 4 ++-- generic/tk.h | 31 ++++++++++++++----------------- generic/tkBind.c | 2 +- generic/tkDecls.h | 8 ++++---- generic/tkEntry.c | 4 ++-- generic/tkInt.decls | 18 +++++++++--------- generic/tkIntDecls.h | 36 ++++++++++++++++++------------------ generic/tkIntPlatDecls.h | 2 +- generic/tkPanedWindow.c | 11 ++++++----- generic/ttk/ttkEntry.c | 2 +- macosx/tkMacOSXWindowEvent.c | 2 +- tests/safe.test | 2 +- win/tkWinX.c | 2 +- xlib/X11/Xlib.h | 8 ++++---- 17 files changed, 68 insertions(+), 70 deletions(-) diff --git a/ChangeLog.2002 b/ChangeLog.2002 index b523e7d..a1ba923 100644 --- a/ChangeLog.2002 +++ b/ChangeLog.2002 @@ -2238,7 +2238,7 @@ inputContext to null. * win/Makefile.in: changed gdb and shell targets to properly build - all binaries before running (otherwise an error often occured). + all binaries before running (otherwise an error often occurred). 2002-03-28 David Gravereaux diff --git a/ChangeLog.2004 b/ChangeLog.2004 index bf86629..b900e7b 100644 --- a/ChangeLog.2004 +++ b/ChangeLog.2004 @@ -811,7 +811,7 @@ 2004-07-05 George Peter Staplin * generic/tkEvent.c: TK_XIM_SPOT preprocessor usage was modified - slightly to fix a bug that occured when TK_XIM_SPOT was defined as 0. + slightly to fix a bug that occurred when TK_XIM_SPOT was defined as 0. Thanks to Joe Mistachkin for reporting this bug. 2004-07-05 Donal K. Fellows diff --git a/changes b/changes index 7da1fc5..fde933c 100644 --- a/changes +++ b/changes @@ -5099,7 +5099,7 @@ correctly. (hobbs) 2001-08-28 (bug fix) removed 2 second 'raise' delay seen by some Unix window managers. (hobbs, baker) -2001-09-14 (bug fix) fixed memory leaks that occured if errors were +2001-09-14 (bug fix) fixed memory leaks that occurred if errors were thrown while initializing the channel for an image. (darley) 2001-09-20 (new feature) --enable-64bit support was added for HP 11 when diff --git a/generic/tk.decls b/generic/tk.decls index b435782..16de241 100644 --- a/generic/tk.decls +++ b/generic/tk.decls @@ -105,7 +105,7 @@ declare 18 { Tk_Window tkwin, const char *value, char *widgRec, int offset) } declare 19 { - CONST86 char *Tk_CanvasTagsPrintProc(ClientData clientData, Tk_Window tkwin, + const char *Tk_CanvasTagsPrintProc(ClientData clientData, Tk_Window tkwin, char *widgRec, int offset, Tcl_FreeProc **freeProcPtr) } declare 20 { @@ -404,7 +404,7 @@ declare 97 { } declare 98 { ClientData Tk_GetImageMasterData(Tcl_Interp *interp, - const char *name, CONST86 Tk_ImageType **typePtrPtr) + const char *name, const Tk_ImageType **typePtrPtr) } declare 99 { Tk_ItemType *Tk_GetItemTypes(void) diff --git a/generic/tk.h b/generic/tk.h index adc9672..6f1c98a 100644 --- a/generic/tk.h +++ b/generic/tk.h @@ -21,9 +21,6 @@ # error Tk 8.7 must be compiled with tcl.h from Tcl 8.6 or better #endif -#ifndef CONST86 -# define CONST86 const -#endif #ifndef EXTERN # define EXTERN extern TCL_STORAGE_CLASS #endif @@ -345,7 +342,7 @@ typedef struct Tk_SavedOptions { typedef int (Tk_OptionParseProc) (ClientData clientData, Tcl_Interp *interp, Tk_Window tkwin, const char *value, char *widgRec, int offset); -typedef CONST86 char *(Tk_OptionPrintProc) (ClientData clientData, +typedef const char *(Tk_OptionPrintProc) (ClientData clientData, Tk_Window tkwin, char *widgRec, int offset, Tcl_FreeProc **freeProcPtr); typedef struct Tk_CustomOption { @@ -371,7 +368,7 @@ typedef struct Tk_ConfigSpec { int type; /* Type of option, such as TK_CONFIG_COLOR; * see definitions below. Last option in table * must have type TK_CONFIG_END. */ - CONST86 char *argvName; /* Switch used to specify option in argv. NULL + const char *argvName; /* Switch used to specify option in argv. NULL * means this spec is part of a group. */ Tk_Uid dbName; /* Name for option in option database. */ Tk_Uid dbClass; /* Class for option in database. */ @@ -387,7 +384,7 @@ typedef struct Tk_ConfigSpec { int specFlags; /* Any combination of the values defined * below; other bits are used internally by * tkConfig.c. */ - CONST86 Tk_CustomOption *customPtr; + const Tk_CustomOption *customPtr; /* If type is TK_CONFIG_CUSTOM then this is a * pointer to info about how to parse and * print the option. Otherwise it is @@ -438,14 +435,14 @@ typedef enum { */ typedef struct { - CONST86 char *key; /* The key string that flags the option in the + const char *key; /* The key string that flags the option in the * argv array. */ int type; /* Indicates option type; see below. */ char *src; /* Value to be used in setting dst; usage * depends on type. */ char *dst; /* Address of value to be modified; usage * depends on type. */ - CONST86 char *help; /* Documentation message describing this + const char *help; /* Documentation message describing this * option. */ } Tk_ArgvInfo; @@ -691,7 +688,7 @@ typedef struct { * request. */ Display *display; /* Display the event was read from. */ Window event; /* Window on which event was requested. */ - Window root; /* Root window that the event occured on. */ + Window root; /* Root window that the event occurred on. */ Window subwindow; /* Child window. */ Time time; /* Milliseconds. */ int x, y; /* Pointer x, y coordinates in event @@ -934,7 +931,7 @@ typedef enum { } Tk_State; typedef struct Tk_SmoothMethod { - CONST86 char *name; + const char *name; int (*coordProc) (Tk_Canvas canvas, double *pointPtr, int numPoints, int numSteps, XPoint xPoints[], double dblPoints[]); void (*postscriptProc) (Tcl_Interp *interp, Tk_Canvas canvas, @@ -1062,7 +1059,7 @@ typedef void (Tk_ItemDCharsProc)(Tk_Canvas canvas, Tk_Item *itemPtr, #ifndef __NO_OLD_CONFIG typedef struct Tk_ItemType { - CONST86 char *name; /* The name of this type of item, such as + const char *name; /* The name of this type of item, such as * "line". */ #if TCL_MAJOR_VERSION > 8 size_t itemSize; /* Total amount of space needed for item's @@ -1073,7 +1070,7 @@ typedef struct Tk_ItemType { Tk_ItemCreateProc *createProc; /* Procedure to create a new item of this * type. */ - CONST86 Tk_ConfigSpec *configSpecs; /* Pointer to array of configuration specs for + const Tk_ConfigSpec *configSpecs; /* Pointer to array of configuration specs for * this type. Used for returning configuration * info. */ Tk_ItemConfigureProc *configProc; @@ -1243,8 +1240,8 @@ typedef int (Tk_ImageCreateProc) (Tcl_Interp *interp, char *name, int argc, char **argv, Tk_ImageType *typePtr, Tk_ImageMaster master, ClientData *masterDataPtr); #else -typedef int (Tk_ImageCreateProc) (Tcl_Interp *interp, CONST86 char *name, int objc, - Tcl_Obj *const objv[], CONST86 Tk_ImageType *typePtr, Tk_ImageMaster master, +typedef int (Tk_ImageCreateProc) (Tcl_Interp *interp, const char *name, int objc, + Tcl_Obj *const objv[], const Tk_ImageType *typePtr, Tk_ImageMaster master, ClientData *masterDataPtr); #endif /* USE_OLD_IMAGE */ typedef ClientData (Tk_ImageGetProc) (Tk_Window tkwin, ClientData masterData); @@ -1268,7 +1265,7 @@ typedef int (Tk_ImagePostscriptProc) (ClientData clientData, */ struct Tk_ImageType { - CONST86 char *name; /* Name of image type. */ + const char *name; /* Name of image type. */ Tk_ImageCreateProc *createProc; /* Procedure to call to create a new image of * this type. */ @@ -1380,7 +1377,7 @@ typedef int (Tk_ImageStringWriteProc) (Tcl_Interp *interp, Tcl_Obj *format, */ struct Tk_PhotoImageFormat { - CONST86 char *name; /* Name of image file format */ + const char *name; /* Name of image file format */ Tk_ImageFileMatchProc *fileMatchProc; /* Procedure to call to determine whether an * image file matches this format. */ @@ -1551,7 +1548,7 @@ typedef void (Tk_EventProc) (ClientData clientData, XEvent *eventPtr); typedef int (Tk_GenericProc) (ClientData clientData, XEvent *eventPtr); typedef int (Tk_ClientMessageProc) (Tk_Window tkwin, XEvent *eventPtr); typedef int (Tk_GetSelProc) (ClientData clientData, Tcl_Interp *interp, - CONST86 char *portion); + const char *portion); typedef void (Tk_LostSelProc) (ClientData clientData); typedef Tk_RestrictAction (Tk_RestrictProc) (ClientData clientData, XEvent *eventPtr); diff --git a/generic/tkBind.c b/generic/tkBind.c index 05966d1..cc0b582 100644 --- a/generic/tkBind.c +++ b/generic/tkBind.c @@ -2505,7 +2505,7 @@ DeleteVirtualEventTable( * already defined, the new definition augments those that already exist. * * Results: - * The return value is TCL_ERROR if an error occured while creating the + * The return value is TCL_ERROR if an error occurred while creating the * virtual binding. In this case, an error message will be left in the * interp's result. If all went well then the return value is TCL_OK. * diff --git a/generic/tkDecls.h b/generic/tkDecls.h index 6666c2d..eb3af95 100644 --- a/generic/tkDecls.h +++ b/generic/tkDecls.h @@ -103,7 +103,7 @@ EXTERN int Tk_CanvasTagsParseProc(ClientData clientData, Tcl_Interp *interp, Tk_Window tkwin, const char *value, char *widgRec, int offset); /* 19 */ -EXTERN CONST86 char * Tk_CanvasTagsPrintProc(ClientData clientData, +EXTERN const char * Tk_CanvasTagsPrintProc(ClientData clientData, Tk_Window tkwin, char *widgRec, int offset, Tcl_FreeProc **freeProcPtr); /* 20 */ @@ -357,7 +357,7 @@ EXTERN Tk_Image Tk_GetImage(Tcl_Interp *interp, Tk_Window tkwin, /* 98 */ EXTERN ClientData Tk_GetImageMasterData(Tcl_Interp *interp, const char *name, - CONST86 Tk_ImageType **typePtrPtr); + const Tk_ImageType **typePtrPtr); /* 99 */ EXTERN Tk_ItemType * Tk_GetItemTypes(void); /* 100 */ @@ -909,7 +909,7 @@ typedef struct TkStubs { double (*tk_CanvasPsY) (Tk_Canvas canvas, double y); /* 16 */ void (*tk_CanvasSetStippleOrigin) (Tk_Canvas canvas, GC gc); /* 17 */ int (*tk_CanvasTagsParseProc) (ClientData clientData, Tcl_Interp *interp, Tk_Window tkwin, const char *value, char *widgRec, int offset); /* 18 */ - CONST86 char * (*tk_CanvasTagsPrintProc) (ClientData clientData, Tk_Window tkwin, char *widgRec, int offset, Tcl_FreeProc **freeProcPtr); /* 19 */ + const char * (*tk_CanvasTagsPrintProc) (ClientData clientData, Tk_Window tkwin, char *widgRec, int offset, Tcl_FreeProc **freeProcPtr); /* 19 */ Tk_Window (*tk_CanvasTkwin) (Tk_Canvas canvas); /* 20 */ void (*tk_CanvasWindowCoords) (Tk_Canvas canvas, double x, double y, short *screenXPtr, short *screenYPtr); /* 21 */ void (*tk_ChangeWindowAttributes) (Tk_Window tkwin, unsigned long valueMask, XSetWindowAttributes *attsPtr); /* 22 */ @@ -988,7 +988,7 @@ typedef struct TkStubs { void (*tk_GetFontMetrics) (Tk_Font font, Tk_FontMetrics *fmPtr); /* 95 */ GC (*tk_GetGC) (Tk_Window tkwin, unsigned long valueMask, XGCValues *valuePtr); /* 96 */ Tk_Image (*tk_GetImage) (Tcl_Interp *interp, Tk_Window tkwin, const char *name, Tk_ImageChangedProc *changeProc, ClientData clientData); /* 97 */ - ClientData (*tk_GetImageMasterData) (Tcl_Interp *interp, const char *name, CONST86 Tk_ImageType **typePtrPtr); /* 98 */ + ClientData (*tk_GetImageMasterData) (Tcl_Interp *interp, const char *name, const Tk_ImageType **typePtrPtr); /* 98 */ Tk_ItemType * (*tk_GetItemTypes) (void); /* 99 */ int (*tk_GetJoinStyle) (Tcl_Interp *interp, const char *str, int *joinPtr); /* 100 */ int (*tk_GetJustify) (Tcl_Interp *interp, const char *str, Tk_Justify *justifyPtr); /* 101 */ diff --git a/generic/tkEntry.c b/generic/tkEntry.c index 6a969bf..8a69010 100644 --- a/generic/tkEntry.c +++ b/generic/tkEntry.c @@ -3348,7 +3348,7 @@ EntryValidate( * * Results: * TCL_OK if the validatecommand accepts the new string, TCL_ERROR if any - * problems occured with validatecommand. + * problems occurred with validatecommand. * * Side effects: * The insertion/deletion may be aborted, and the validatecommand might @@ -3405,7 +3405,7 @@ EntryValidateChange( /* * If e->validate has become VALIDATE_NONE during the validation, or we * now have VALIDATE_VAR set (from EntrySetValue) and didn't before, it - * means that a loop condition almost occured. Do not allow this + * means that a loop condition almost occurred. Do not allow this * validation result to finish. */ diff --git a/generic/tkInt.decls b/generic/tkInt.decls index a2d43d9..04eecf6 100644 --- a/generic/tkInt.decls +++ b/generic/tkInt.decls @@ -99,7 +99,7 @@ declare 21 { const TkStateMap *mapPtr, const char *strKey) } declare 22 { - CONST86 char *TkFindStateString(const TkStateMap *mapPtr, int numKey) + const char *TkFindStateString(const TkStateMap *mapPtr, int numKey) } declare 23 { void TkFocusDeadWindow(TkWindow *winPtr) @@ -182,7 +182,7 @@ declare 45 { void TkInstallFrameMenu(Tk_Window tkwin) } declare 46 { - CONST86 char *TkKeysymToString(KeySym keysym) + const char *TkKeysymToString(KeySym keysym) } declare 47 { int TkLineToArea(double end1Ptr[], double end2Ptr[], double rectPtr[]) @@ -389,7 +389,7 @@ declare 108 { Tcl_Obj *objPtr, Tk_Window *windowPtr) } declare 109 { - CONST86 char *TkpGetString(TkWindow *winPtr, XEvent *eventPtr, Tcl_DString *dsPtr) + const char *TkpGetString(TkWindow *winPtr, XEvent *eventPtr, Tcl_DString *dsPtr) } declare 110 { void TkpGetSubFonts(Tcl_Interp *interp, Tk_Font tkfont) @@ -570,7 +570,7 @@ declare 169 { Tk_Window tkwin, const char *value, char *widgRec, int offset) } declare 170 { - CONST86 char *TkStatePrintProc(ClientData clientData, Tk_Window tkwin, + const char *TkStatePrintProc(ClientData clientData, Tk_Window tkwin, char *widgRec, int offset, Tcl_FreeProc **freeProcPtr) } declare 171 { @@ -578,7 +578,7 @@ declare 171 { Tk_Window tkwin, const char *value, char *widgRec, int offset) } declare 172 { - CONST86 char *TkCanvasDashPrintProc(ClientData clientData, Tk_Window tkwin, + const char *TkCanvasDashPrintProc(ClientData clientData, Tk_Window tkwin, char *widgRec, int offset, Tcl_FreeProc **freeProcPtr) } declare 173 { @@ -586,7 +586,7 @@ declare 173 { Tk_Window tkwin, const char *value, char *widgRec, int offset) } declare 174 { - CONST86 char *TkOffsetPrintProc(ClientData clientData, Tk_Window tkwin, + const char *TkOffsetPrintProc(ClientData clientData, Tk_Window tkwin, char *widgRec, int offset, Tcl_FreeProc **freeProcPtr) } declare 175 { @@ -594,7 +594,7 @@ declare 175 { Tk_Window tkwin, const char *value, char *widgRec, int offset) } declare 176 { - CONST86 char *TkPixelPrintProc(ClientData clientData, Tk_Window tkwin, + const char *TkPixelPrintProc(ClientData clientData, Tk_Window tkwin, char *widgRec, int offset, Tcl_FreeProc **freeProcPtr) } declare 177 { @@ -602,7 +602,7 @@ declare 177 { Tk_Window tkwin, const char *value, char *widgRec, int offset) } declare 178 { - CONST86 char *TkOrientPrintProc(ClientData clientData, Tk_Window tkwin, + const char *TkOrientPrintProc(ClientData clientData, Tk_Window tkwin, char *widgRec, int offset, Tcl_FreeProc **freeProcPtr) } declare 179 { @@ -610,7 +610,7 @@ declare 179 { Tk_Window tkwin, const char *value, char *widgRec, int offset) } declare 180 { - CONST86 char *TkSmoothPrintProc(ClientData clientData, Tk_Window tkwin, + const char *TkSmoothPrintProc(ClientData clientData, Tk_Window tkwin, char *widgRec, int offset, Tcl_FreeProc **freeProcPtr) } diff --git a/generic/tkIntDecls.h b/generic/tkIntDecls.h index 0ffe157..a646779 100644 --- a/generic/tkIntDecls.h +++ b/generic/tkIntDecls.h @@ -104,7 +104,7 @@ EXTERN int TkFindStateNum(Tcl_Interp *interp, const char *option, const TkStateMap *mapPtr, const char *strKey); /* 22 */ -EXTERN CONST86 char * TkFindStateString(const TkStateMap *mapPtr, +EXTERN const char * TkFindStateString(const TkStateMap *mapPtr, int numKey); /* 23 */ EXTERN void TkFocusDeadWindow(TkWindow *winPtr); @@ -167,7 +167,7 @@ EXTERN void TkInOutEvents(XEvent *eventPtr, TkWindow *sourcePtr, /* 45 */ EXTERN void TkInstallFrameMenu(Tk_Window tkwin); /* 46 */ -EXTERN CONST86 char * TkKeysymToString(KeySym keysym); +EXTERN const char * TkKeysymToString(KeySym keysym); /* 47 */ EXTERN int TkLineToArea(double end1Ptr[], double end2Ptr[], double rectPtr[]); @@ -324,7 +324,7 @@ EXTERN int TkGetWindowFromObj(Tcl_Interp *interp, Tk_Window tkwin, Tcl_Obj *objPtr, Tk_Window *windowPtr); /* 109 */ -EXTERN CONST86 char * TkpGetString(TkWindow *winPtr, XEvent *eventPtr, +EXTERN const char * TkpGetString(TkWindow *winPtr, XEvent *eventPtr, Tcl_DString *dsPtr); /* 110 */ EXTERN void TkpGetSubFonts(Tcl_Interp *interp, Tk_Font tkfont); @@ -488,7 +488,7 @@ EXTERN int TkStateParseProc(ClientData clientData, Tcl_Interp *interp, Tk_Window tkwin, const char *value, char *widgRec, int offset); /* 170 */ -EXTERN CONST86 char * TkStatePrintProc(ClientData clientData, +EXTERN const char * TkStatePrintProc(ClientData clientData, Tk_Window tkwin, char *widgRec, int offset, Tcl_FreeProc **freeProcPtr); /* 171 */ @@ -496,7 +496,7 @@ EXTERN int TkCanvasDashParseProc(ClientData clientData, Tcl_Interp *interp, Tk_Window tkwin, const char *value, char *widgRec, int offset); /* 172 */ -EXTERN CONST86 char * TkCanvasDashPrintProc(ClientData clientData, +EXTERN const char * TkCanvasDashPrintProc(ClientData clientData, Tk_Window tkwin, char *widgRec, int offset, Tcl_FreeProc **freeProcPtr); /* 173 */ @@ -504,7 +504,7 @@ EXTERN int TkOffsetParseProc(ClientData clientData, Tcl_Interp *interp, Tk_Window tkwin, const char *value, char *widgRec, int offset); /* 174 */ -EXTERN CONST86 char * TkOffsetPrintProc(ClientData clientData, +EXTERN const char * TkOffsetPrintProc(ClientData clientData, Tk_Window tkwin, char *widgRec, int offset, Tcl_FreeProc **freeProcPtr); /* 175 */ @@ -512,7 +512,7 @@ EXTERN int TkPixelParseProc(ClientData clientData, Tcl_Interp *interp, Tk_Window tkwin, const char *value, char *widgRec, int offset); /* 176 */ -EXTERN CONST86 char * TkPixelPrintProc(ClientData clientData, +EXTERN const char * TkPixelPrintProc(ClientData clientData, Tk_Window tkwin, char *widgRec, int offset, Tcl_FreeProc **freeProcPtr); /* 177 */ @@ -520,7 +520,7 @@ EXTERN int TkOrientParseProc(ClientData clientData, Tcl_Interp *interp, Tk_Window tkwin, const char *value, char *widgRec, int offset); /* 178 */ -EXTERN CONST86 char * TkOrientPrintProc(ClientData clientData, +EXTERN const char * TkOrientPrintProc(ClientData clientData, Tk_Window tkwin, char *widgRec, int offset, Tcl_FreeProc **freeProcPtr); /* 179 */ @@ -528,7 +528,7 @@ EXTERN int TkSmoothParseProc(ClientData clientData, Tcl_Interp *interp, Tk_Window tkwin, const char *value, char *widgRec, int offset); /* 180 */ -EXTERN CONST86 char * TkSmoothPrintProc(ClientData clientData, +EXTERN const char * TkSmoothPrintProc(ClientData clientData, Tk_Window tkwin, char *widgRec, int offset, Tcl_FreeProc **freeProcPtr); /* 181 */ @@ -581,7 +581,7 @@ typedef struct TkIntStubs { void (*tkEventDeadWindow) (TkWindow *winPtr); /* 19 */ void (*tkFillPolygon) (Tk_Canvas canvas, double *coordPtr, int numPoints, Display *display, Drawable drawable, GC gc, GC outlineGC); /* 20 */ int (*tkFindStateNum) (Tcl_Interp *interp, const char *option, const TkStateMap *mapPtr, const char *strKey); /* 21 */ - CONST86 char * (*tkFindStateString) (const TkStateMap *mapPtr, int numKey); /* 22 */ + const char * (*tkFindStateString) (const TkStateMap *mapPtr, int numKey); /* 22 */ void (*tkFocusDeadWindow) (TkWindow *winPtr); /* 23 */ int (*tkFocusFilterEvent) (TkWindow *winPtr, XEvent *eventPtr); /* 24 */ TkWindow * (*tkFocusKeyEvent) (TkWindow *winPtr, XEvent *eventPtr); /* 25 */ @@ -605,7 +605,7 @@ typedef struct TkIntStubs { void (*tkIncludePoint) (Tk_Item *itemPtr, double *pointPtr); /* 43 */ void (*tkInOutEvents) (XEvent *eventPtr, TkWindow *sourcePtr, TkWindow *destPtr, int leaveType, int enterType, Tcl_QueuePosition position); /* 44 */ void (*tkInstallFrameMenu) (Tk_Window tkwin); /* 45 */ - CONST86 char * (*tkKeysymToString) (KeySym keysym); /* 46 */ + const char * (*tkKeysymToString) (KeySym keysym); /* 46 */ int (*tkLineToArea) (double end1Ptr[], double end2Ptr[], double rectPtr[]); /* 47 */ double (*tkLineToPoint) (double end1Ptr[], double end2Ptr[], double pointPtr[]); /* 48 */ int (*tkMakeBezierCurve) (Tk_Canvas canvas, double *pointPtr, int numPoints, int numSteps, XPoint xPoints[], double dblPoints[]); /* 49 */ @@ -668,7 +668,7 @@ typedef struct TkIntStubs { TkDisplay * (*tkGetDisplayList) (void); /* 106 */ TkMainInfo * (*tkGetMainInfoList) (void); /* 107 */ int (*tkGetWindowFromObj) (Tcl_Interp *interp, Tk_Window tkwin, Tcl_Obj *objPtr, Tk_Window *windowPtr); /* 108 */ - CONST86 char * (*tkpGetString) (TkWindow *winPtr, XEvent *eventPtr, Tcl_DString *dsPtr); /* 109 */ + const char * (*tkpGetString) (TkWindow *winPtr, XEvent *eventPtr, Tcl_DString *dsPtr); /* 109 */ void (*tkpGetSubFonts) (Tcl_Interp *interp, Tk_Font tkfont); /* 110 */ Tcl_Obj * (*tkpGetSystemDefault) (Tk_Window tkwin, const char *dbName, const char *className); /* 111 */ void (*tkpMenuThreadInit) (void); /* 112 */ @@ -756,17 +756,17 @@ typedef struct TkIntStubs { int (*tkBTreeNumLines) (TkTextBTree tree, const struct TkText *textPtr); /* 167 */ void (*tkTextInsertDisplayProc) (struct TkText *textPtr, struct TkTextDispChunk *chunkPtr, int x, int y, int height, int baseline, Display *display, Drawable dst, int screenY); /* 168 */ int (*tkStateParseProc) (ClientData clientData, Tcl_Interp *interp, Tk_Window tkwin, const char *value, char *widgRec, int offset); /* 169 */ - CONST86 char * (*tkStatePrintProc) (ClientData clientData, Tk_Window tkwin, char *widgRec, int offset, Tcl_FreeProc **freeProcPtr); /* 170 */ + const char * (*tkStatePrintProc) (ClientData clientData, Tk_Window tkwin, char *widgRec, int offset, Tcl_FreeProc **freeProcPtr); /* 170 */ int (*tkCanvasDashParseProc) (ClientData clientData, Tcl_Interp *interp, Tk_Window tkwin, const char *value, char *widgRec, int offset); /* 171 */ - CONST86 char * (*tkCanvasDashPrintProc) (ClientData clientData, Tk_Window tkwin, char *widgRec, int offset, Tcl_FreeProc **freeProcPtr); /* 172 */ + const char * (*tkCanvasDashPrintProc) (ClientData clientData, Tk_Window tkwin, char *widgRec, int offset, Tcl_FreeProc **freeProcPtr); /* 172 */ int (*tkOffsetParseProc) (ClientData clientData, Tcl_Interp *interp, Tk_Window tkwin, const char *value, char *widgRec, int offset); /* 173 */ - CONST86 char * (*tkOffsetPrintProc) (ClientData clientData, Tk_Window tkwin, char *widgRec, int offset, Tcl_FreeProc **freeProcPtr); /* 174 */ + const char * (*tkOffsetPrintProc) (ClientData clientData, Tk_Window tkwin, char *widgRec, int offset, Tcl_FreeProc **freeProcPtr); /* 174 */ int (*tkPixelParseProc) (ClientData clientData, Tcl_Interp *interp, Tk_Window tkwin, const char *value, char *widgRec, int offset); /* 175 */ - CONST86 char * (*tkPixelPrintProc) (ClientData clientData, Tk_Window tkwin, char *widgRec, int offset, Tcl_FreeProc **freeProcPtr); /* 176 */ + const char * (*tkPixelPrintProc) (ClientData clientData, Tk_Window tkwin, char *widgRec, int offset, Tcl_FreeProc **freeProcPtr); /* 176 */ int (*tkOrientParseProc) (ClientData clientData, Tcl_Interp *interp, Tk_Window tkwin, const char *value, char *widgRec, int offset); /* 177 */ - CONST86 char * (*tkOrientPrintProc) (ClientData clientData, Tk_Window tkwin, char *widgRec, int offset, Tcl_FreeProc **freeProcPtr); /* 178 */ + const char * (*tkOrientPrintProc) (ClientData clientData, Tk_Window tkwin, char *widgRec, int offset, Tcl_FreeProc **freeProcPtr); /* 178 */ int (*tkSmoothParseProc) (ClientData clientData, Tcl_Interp *interp, Tk_Window tkwin, const char *value, char *widgRec, int offset); /* 179 */ - CONST86 char * (*tkSmoothPrintProc) (ClientData clientData, Tk_Window tkwin, char *widgRec, int offset, Tcl_FreeProc **freeProcPtr); /* 180 */ + const char * (*tkSmoothPrintProc) (ClientData clientData, Tk_Window tkwin, char *widgRec, int offset, Tcl_FreeProc **freeProcPtr); /* 180 */ void (*tkDrawAngledTextLayout) (Display *display, Drawable drawable, GC gc, Tk_TextLayout layout, int x, int y, double angle, int firstChar, int lastChar); /* 181 */ void (*tkUnderlineAngledTextLayout) (Display *display, Drawable drawable, GC gc, Tk_TextLayout layout, int x, int y, double angle, int underline); /* 182 */ int (*tkIntersectAngledTextLayout) (Tk_TextLayout layout, int x, int y, int width, int height, double angle); /* 183 */ diff --git a/generic/tkIntPlatDecls.h b/generic/tkIntPlatDecls.h index 6013b36..9bc76c0 100644 --- a/generic/tkIntPlatDecls.h +++ b/generic/tkIntPlatDecls.h @@ -383,7 +383,7 @@ typedef struct TkIntPlatStubs { void (*tkMacOSXWindowOffset) (void *wRef, int *xOffset, int *yOffset); /* 37 */ int (*tkSetMacColor) (unsigned long pixel, void *macColor); /* 38 */ void (*tkSetWMName) (TkWindow *winPtr, Tk_Uid titleUid); /* 39 */ - void (*reserved40) (void); + void (*reserved40)(void); int (*tkMacOSXZoomToplevel) (void *whichWindow, short zoomPart); /* 41 */ Tk_Window (*tk_TopCoordsToWindow) (Tk_Window tkwin, int rootX, int rootY, int *newX, int *newY); /* 42 */ MacDrawable * (*tkMacOSXContainerId) (TkWindow *winPtr); /* 43 */ diff --git a/generic/tkPanedWindow.c b/generic/tkPanedWindow.c index 6fd60e9..c0bbf5f 100644 --- a/generic/tkPanedWindow.c +++ b/generic/tkPanedWindow.c @@ -236,7 +236,7 @@ static void AdjustForSticky(int sticky, int cavityWidth, int *slaveWidthPtr, int *slaveHeightPtr); static void MoveSash(PanedWindow *pwPtr, int sash, int diff); static int ObjectIsEmpty(Tcl_Obj *objPtr); -static char * ComputeSlotAddress(char *recordPtr, int offset); +static void * ComputeSlotAddress(void *recordPtr, int offset); static int PanedWindowIdentifyCoords(PanedWindow *pwPtr, Tcl_Interp *interp, int x, int y); @@ -2455,7 +2455,8 @@ SetSticky( int flags) /* Flags for the option, set Tk_SetOptions. */ { int sticky = 0; - char c, *internalPtr; + char c; + void *internalPtr; const char *string; internalPtr = ComputeSlotAddress(recordPtr, internalOffset); @@ -3019,13 +3020,13 @@ ObjectIsEmpty( *---------------------------------------------------------------------- */ -static char * +static void * ComputeSlotAddress( - char *recordPtr, /* Pointer to the start of a record. */ + void *recordPtr, /* Pointer to the start of a record. */ int offset) /* Offset of a slot within that record; may be < 0. */ { if (offset >= 0) { - return recordPtr + offset; + return (char *)recordPtr + offset; } else { return NULL; } diff --git a/generic/ttk/ttkEntry.c b/generic/ttk/ttkEntry.c index 40e49b7..e5268e7 100644 --- a/generic/ttk/ttkEntry.c +++ b/generic/ttk/ttkEntry.c @@ -585,7 +585,7 @@ static int EntryNeedsValidation(VMODE vmode, VREASON reason) * Returns: * TCL_OK if the change is accepted * TCL_BREAK if the change is rejected - * TCL_ERROR if any errors occured + * TCL_ERROR if any errors occurred * * The change will be rejected if -validatecommand returns 0, * or if -validatecommand or -invalidcommand modifies the value. diff --git a/macosx/tkMacOSXWindowEvent.c b/macosx/tkMacOSXWindowEvent.c index 36fc297..f6ec72b 100644 --- a/macosx/tkMacOSXWindowEvent.c +++ b/macosx/tkMacOSXWindowEvent.c @@ -333,7 +333,7 @@ GenerateUpdates( } /* - * Compute the bounding box of the area that the damage occured in. + * Compute the bounding box of the area that the damage occurred in. */ boundsRgn = HIShapeCreateWithRect(&bounds); diff --git a/tests/safe.test b/tests/safe.test index 475d938..16068d3 100644 --- a/tests/safe.test +++ b/tests/safe.test @@ -28,7 +28,7 @@ namespace import -force tcltest::test # This probably means that tk wasn't installed properly. ## it indicates that something went wrong sourcing tk.tcl. -## Ensure that any changes that occured to tk.tcl will work or are properly +## Ensure that any changes that occurred to tk.tcl will work or are properly ## prevented in a safe interpreter. -- hobbs # The set of hidden commands is platform dependent: diff --git a/win/tkWinX.c b/win/tkWinX.c index f666152..e3b552e 100644 --- a/win/tkWinX.c +++ b/win/tkWinX.c @@ -1256,7 +1256,7 @@ GenerateXEvent( * GetState -- * * This function constructs a state mask for the mouse buttons and - * modifier keys as they were before the event occured. + * modifier keys as they were before the event occurred. * * Results: * Returns a composite value of all the modifier and button state flags diff --git a/xlib/X11/Xlib.h b/xlib/X11/Xlib.h index 09dc518..2418672 100644 --- a/xlib/X11/Xlib.h +++ b/xlib/X11/Xlib.h @@ -538,7 +538,7 @@ typedef struct { Bool send_event; /* true if this came from a SendEvent request */ Display *display; /* Display the event was read from */ Window window; /* "event" window it is reported relative to */ - Window root; /* root window that the event occured on */ + Window root; /* root window that the event occurred on */ Window subwindow; /* child window */ Time time; /* milliseconds */ int x, y; /* pointer x, y coordinates in event window */ @@ -559,7 +559,7 @@ typedef struct { Bool send_event; /* true if this came from a SendEvent request */ Display *display; /* Display the event was read from */ Window window; /* "event" window it is reported relative to */ - Window root; /* root window that the event occured on */ + Window root; /* root window that the event occurred on */ Window subwindow; /* child window */ Time time; /* milliseconds */ int x, y; /* pointer x, y coordinates in event window */ @@ -577,7 +577,7 @@ typedef struct { Bool send_event; /* true if this came from a SendEvent request */ Display *display; /* Display the event was read from */ Window window; /* "event" window reported relative to */ - Window root; /* root window that the event occured on */ + Window root; /* root window that the event occurred on */ Window subwindow; /* child window */ Time time; /* milliseconds */ int x, y; /* pointer x, y coordinates in event window */ @@ -594,7 +594,7 @@ typedef struct { Bool send_event; /* true if this came from a SendEvent request */ Display *display; /* Display the event was read from */ Window window; /* "event" window reported relative to */ - Window root; /* root window that the event occured on */ + Window root; /* root window that the event occurred on */ Window subwindow; /* child window */ Time time; /* milliseconds */ int x, y; /* pointer x, y coordinates in event window */ -- cgit v0.12 From 411e116a5b9a3bb65bd5572447a3628a195cb934 Mon Sep 17 00:00:00 2001 From: dkf Date: Sat, 20 Oct 2018 23:29:13 +0000 Subject: Clean up prior to TIP vote --- doc/canvas.n | 28 +++++++++----- generic/tkCanvArc.c | 103 +++++++++++++++++++++++++++++++++------------------- 2 files changed, 83 insertions(+), 48 deletions(-) diff --git a/doc/canvas.n b/doc/canvas.n index 5abfc0f..fa7843d 100644 --- a/doc/canvas.n +++ b/doc/canvas.n @@ -313,6 +313,7 @@ The second possible syntax is a character list containing only The space can be used to enlarge the space between other line elements, and cannot occur as the first position in the string. Some examples: +.PP .CS \-dash . \(-> \-dash {2 4} \-dash - \(-> \-dash {6 4} @@ -1395,20 +1396,27 @@ distance of the mid-point of the arc from its chord. When this option is used the coordinates are interpreted as the start and end coordinates of the chord, and the options \fB\-start\fR and \fB-extent\fR are ignored. The value of \fIdistance\fR has the following meaning: -.CS - +.RS +.PP +.RS \fIdistance\fR > 0 creates a clockwise arc +.br \fIdistance\fR < 0 creates an counter-clockwise arc +.br \fIdistance\fR = 0 creates an arc as if this option had not been specified - -If you want the arc to have a specific radius, r, use the formula - -\fIdistance\fR = r +- sqrt(r**2 - (chordLength/2)**2) - +.RE +.PP +If you want the arc to have a specific radius, \fIr\fR, use the formula: +.PP +.RS +\fIdistance\fR = \fIr\fR \(+- sqrt(\fIr\fR**2 - (chordLength / 2)**2) +.RE +.PP choosing the minus sign for the minor arc and the plus sign for the major arc. - -Note that \fBitemcget -height\fR always returns 0 so that introspection code can be kept simple. -.CE +.PP +Note that \fBitemcget \-height\fR always returns 0 so that introspection code +can be kept simple. +.RE .TP \fB\-style \fItype\fR Specifies how to draw the arc. If \fItype\fR is \fBpieslice\fR diff --git a/generic/tkCanvArc.c b/generic/tkCanvArc.c index ef2ef72..85a0bab 100644 --- a/generic/tkCanvArc.c +++ b/generic/tkCanvArc.c @@ -62,10 +62,12 @@ typedef struct ArcItem { * start (see ComputeArcOutline). */ double center2[2]; /* Coordinates of center of arc outline at * start+extent (see ComputeArcOutline). */ - - double height; /* Distance from the arc's chord to its mid-point */ - double startPoint[2]; /* Start point of arc used when specifying height */ - double endPoint[2]; /* End point of arc used when specifying height */ + double height; /* Distance from the arc's chord to its + * mid-point. */ + double startPoint[2]; /* Start point of arc used when specifying + * height. */ + double endPoint[2]; /* End point of arc used when specifying + * height. */ } ArcItem; /* @@ -300,7 +302,6 @@ CreateArc( arcPtr->fillGC = None; arcPtr->height = 0; - /* * Process the arguments to fill in the item record. */ @@ -360,8 +361,8 @@ ArcCoords( objs[2] = Tcl_NewDoubleObj(arcPtr->bbox[2]); objs[3] = Tcl_NewDoubleObj(arcPtr->bbox[3]); Tcl_SetObjResult(interp, Tcl_NewListObj(4, objs)); - } else if ((objc == 1)||(objc == 4)) { - if (objc==1) { + } else if ((objc == 1) || (objc == 4)) { + if (objc == 1) { if (Tcl_ListObjGetElements(interp, objv[0], &objc, (Tcl_Obj ***) &objv) != TCL_OK) { return TCL_ERROR; @@ -385,9 +386,10 @@ ArcCoords( } /* - * Store bbox as start and end points so they can be used - * if either radius or height is specified. - */ + * Store bbox as start and end points so they can be used if either + * radius or height is specified. + */ + arcPtr->startPoint[0] = arcPtr->bbox[0]; arcPtr->startPoint[1] = arcPtr->bbox[1]; arcPtr->endPoint[0] = arcPtr->bbox[2]; @@ -589,8 +591,8 @@ ConfigureArc( * * ComputeArcFromHeight -- * - * This function calculates the arc parameters given - * start-point, end-point and height (!= 0). + * This function calculates the arc parameters given start-point, + * end-point and height (!= 0). * * Results: * None. @@ -603,44 +605,69 @@ ConfigureArc( static void ComputeArcFromHeight( - ArcItem* arcPtr) + ArcItem* arcPtr) { double chordLen, chordDir[2], chordCen[2], arcCen[2], d, radToDeg, radius; - /* The chord */ - chordLen = hypot(arcPtr->endPoint[1]-arcPtr->startPoint[1], arcPtr->startPoint[0]-arcPtr->endPoint[0]); - chordDir[0] = (arcPtr->endPoint[0]-arcPtr->startPoint[0])/chordLen; - chordDir[1] = (arcPtr->endPoint[1]-arcPtr->startPoint[1])/chordLen; - chordCen[0] = (arcPtr->startPoint[0]+arcPtr->endPoint[0])/2; - chordCen[1] = (arcPtr->startPoint[1]+arcPtr->endPoint[1])/2; + /* + * The chord. + */ + + chordLen = hypot(arcPtr->endPoint[1] - arcPtr->startPoint[1], + arcPtr->startPoint[0] - arcPtr->endPoint[0]); + chordDir[0] = (arcPtr->endPoint[0] - arcPtr->startPoint[0]) / chordLen; + chordDir[1] = (arcPtr->endPoint[1] - arcPtr->startPoint[1]) / chordLen; + chordCen[0] = (arcPtr->startPoint[0] + arcPtr->endPoint[0]) / 2; + chordCen[1] = (arcPtr->startPoint[1] + arcPtr->endPoint[1]) / 2; - /* Calculate the radius (assumes height != 0) */ - radius = (4*pow(arcPtr->height,2) + pow(chordLen,2))/(8*arcPtr->height); + /* + * Calculate the radius (assumes height != 0). + */ + + radius = (4*pow(arcPtr->height, 2) + pow(chordLen, 2)) + / (8 * arcPtr->height); + + /* + * The arc centre. + */ - /* The arc centre */ d = radius - arcPtr->height; - arcCen[0] = chordCen[0] - d*chordDir[1]; - arcCen[1] = chordCen[1] + d*chordDir[0]; + arcCen[0] = chordCen[0] - d * chordDir[1]; + arcCen[1] = chordCen[1] + d * chordDir[0]; - /* The arc start and span. Angles are negated because the coordinate system is left-handed */ - radToDeg = 45/atan(1); - arcPtr->start = atan2(arcCen[1]-arcPtr->startPoint[1],arcPtr->startPoint[0]-arcCen[0])*radToDeg; - arcPtr->extent = -2*asin(chordLen/(2*radius))*radToDeg; + /* + * The arc start and span. Angles are negated because the coordinate + * system is left-handed. + */ - /* Handle spans > 180 */ - if (fabs(2*arcPtr->height) > chordLen) { - arcPtr->extent = arcPtr->extent > 0 ? (360 - arcPtr->extent) : -(360+arcPtr->extent); + radToDeg = 45 / atan(1); + arcPtr->start = atan2(arcCen[1] - arcPtr->startPoint[1], + arcPtr->startPoint[0] - arcCen[0]) * radToDeg; + arcPtr->extent = -2 * asin(chordLen / (2 * radius)) * radToDeg; + + /* + * Handle spans > 180. + */ + + if (fabs(2 * arcPtr->height) > chordLen) { + arcPtr->extent = arcPtr->extent > 0 ? (360 - arcPtr->extent) + : -(360 + arcPtr->extent); } - /* Create the bounding box */ - arcPtr->bbox[0] = arcCen[0]-radius; - arcPtr->bbox[1] = arcCen[1]-radius; - arcPtr->bbox[2] = arcCen[0]+radius; - arcPtr->bbox[3] = arcCen[1]+radius; + /* + * Create the bounding box. + */ - /* Set the height to 0 so that itemcget -height returns 0 */ - arcPtr->height = 0; + arcPtr->bbox[0] = arcCen[0] - radius; + arcPtr->bbox[1] = arcCen[1] - radius; + arcPtr->bbox[2] = arcCen[0] + radius; + arcPtr->bbox[3] = arcCen[1] + radius; + + /* + * Set the height to 0 so that itemcget -height returns 0. + */ + arcPtr->height = 0; } /* -- cgit v0.12 From 56a9c541052f8779ea0124308d27a12041e7cfbe Mon Sep 17 00:00:00 2001 From: fvogel Date: Sun, 21 Oct 2018 16:23:21 +0000 Subject: Remove knownBug constraint on test scrollbar-6.27 as this test now passes (checked on Vista - comment there was for Win2K) --- tests/scrollbar.test | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/tests/scrollbar.test b/tests/scrollbar.test index d740f7c..9d6a83c 100644 --- a/tests/scrollbar.test +++ b/tests/scrollbar.test @@ -541,11 +541,7 @@ test scrollbar-6.24 {ScrollbarPosition procedure} unix { test scrollbar-6.25 {ScrollbarPosition procedure} unix { .s identify 8 179 } {trough2} -test scrollbar-6.27 {ScrollbarPosition procedure} {testmetrics win knownBug} { - # This asks for 8,21, which is actually the slider, but there is a - # bug in that GetSystemMetrics(SM_CYVTHUMB) actually returns a value - # that is larger than the thumb displayed, skewing the ability to - # calculate the trough2 area correctly (Win2k). -- hobbs +test scrollbar-6.27 {ScrollbarPosition procedure} {testmetrics win} { .s identify [expr [winfo width .s] / 2] [expr int(.4 / [.s delta 0 1]) \ + [testmetrics cyvscroll .s]] } {trough2} -- cgit v0.12 From 8ea711d0aea88cecedd9fe9f32436e376da780ee Mon Sep 17 00:00:00 2001 From: culler Date: Sun, 21 Oct 2018 21:41:34 +0000 Subject: Deal with Mojave deprecations and remove unneeded code. --- macosx/tkMacOSXClipboard.c | 1 + macosx/tkMacOSXConstants.h | 19 +++++++++++++++++++ macosx/tkMacOSXDraw.c | 10 ++++++++-- macosx/tkMacOSXFont.c | 10 +--------- macosx/tkMacOSXNotify.c | 45 +++++++++++++++++++-------------------------- macosx/tkMacOSXPrivate.h | 2 ++ macosx/tkMacOSXWm.c | 3 +-- 7 files changed, 51 insertions(+), 39 deletions(-) diff --git a/macosx/tkMacOSXClipboard.c b/macosx/tkMacOSXClipboard.c index 9b65bc3..efd3c69 100644 --- a/macosx/tkMacOSXClipboard.c +++ b/macosx/tkMacOSXClipboard.c @@ -12,6 +12,7 @@ */ #include "tkMacOSXPrivate.h" +#include "tkMacOSXConstants.h" #include "tkSelect.h" static NSInteger changeCount = -1; diff --git a/macosx/tkMacOSXConstants.h b/macosx/tkMacOSXConstants.h index bb2206e..3f0d306 100644 --- a/macosx/tkMacOSXConstants.h +++ b/macosx/tkMacOSXConstants.h @@ -21,10 +21,19 @@ * of constants. */ +#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1090 +#define kCTFontDefaultOrientation kCTFontOrientationDefault +#define kCTFontVerticalOrientation kCTFontOrientationVertical +#endif + #if MAC_OS_X_VERSION_MIN_REQUIRED >= 101000 #define NSOKButton NSModalResponseOK #endif +#if MAC_OS_X_VERSION_MIN_REQUIRED >= 101100 +#define kCTFontUserFixedPitchFontType kCTFontUIFontUserFixedPitch +#endif + #if MAC_OS_X_VERSION_MIN_REQUIRED >= 101200 #define NSAppKitDefined NSEventTypeAppKitDefined #define NSApplicationActivatedEventType NSEventSubtypeApplicationActivated @@ -93,4 +102,14 @@ #define NSFullScreenWindowMask NSWindowStyleMaskFullScreen #endif +#if MAC_OS_X_VERSION_MIN_REQUIRED >= 101400 +#define NSStringPboardType NSPasteboardTypeString +#define NSOnState NSControlStateValueOn +#define NSOffState NSControlStateValueOff +// Now we are also changing names of methods! +#define graphicsContextWithGraphicsPort graphicsContextWithCGContext #endif + + +#endif + diff --git a/macosx/tkMacOSXDraw.c b/macosx/tkMacOSXDraw.c index 1e1e893..ce53a17 100644 --- a/macosx/tkMacOSXDraw.c +++ b/macosx/tkMacOSXDraw.c @@ -18,6 +18,12 @@ #include "tkMacOSXDebug.h" #include "tkButton.h" +#if MAC_OS_X_VERSION_MIN_REQUIRED >= 101400 +#define GET_CGCONTEXT [[NSGraphicsContext currentContext] CGContext] +#else +#define GET_CGCONTEXT [[NSGraphicsContext currentContext] graphicsPort] +#endif + /* #ifdef TK_MAC_DEBUG #define TK_MAC_DEBUG_DRAWING @@ -1489,7 +1495,7 @@ TkMacOSXSetupDrawingContext( goto end; } dc.view = view; - dc.context = [[NSGraphicsContext currentContext] graphicsPort]; + dc.context = GET_CGCONTEXT; dc.portBounds = NSRectToCGRect([view bounds]); if (dc.clipRgn) { clipBounds = CGContextGetClipBoundingBox(dc.context); @@ -1658,7 +1664,7 @@ TkMacOSXGetClipRgn( TkMacOSXDbgMsg("%s", macDraw->winPtr->pathName); NSView *view = TkMacOSXDrawableView(macDraw); if ([view lockFocusIfCanDraw]) { - CGContextRef context = [[NSGraphicsContext currentContext] graphicsPort]; + CGContextRef context = GET_CGCONTEXT; CGContextSaveGState(context); CGContextConcatCTM(context, CGAffineTransformMake(1.0, 0.0, 0.0, -1.0, 0.0, [view bounds].size.height)); diff --git a/macosx/tkMacOSXFont.c b/macosx/tkMacOSXFont.c index 757daf9..0701fb6 100644 --- a/macosx/tkMacOSXFont.c +++ b/macosx/tkMacOSXFont.c @@ -14,19 +14,11 @@ #include "tkMacOSXPrivate.h" #include "tkMacOSXFont.h" +#include "tkMacOSXConstants.h" -#if MAC_OS_X_VERSION_MIN_REQUIRED < 1080 #define defaultOrientation kCTFontDefaultOrientation #define verticalOrientation kCTFontVerticalOrientation -#else -#define defaultOrientation kCTFontOrientationDefault -#define verticalOrientation kCTFontOrientationVertical -#endif -#if MAC_OS_X_VERSION_MIN_REQUIRED < 101100 -#define fixedPitch kCTFontUserFixedPitchFontType -#else #define fixedPitch kCTFontUIFontUserFixedPitch -#endif /* #ifdef TK_MAC_DEBUG diff --git a/macosx/tkMacOSXNotify.c b/macosx/tkMacOSXNotify.c index fad61b4..02f449a 100644 --- a/macosx/tkMacOSXNotify.c +++ b/macosx/tkMacOSXNotify.c @@ -39,31 +39,26 @@ static void TkMacOSXEventsCheckProc(ClientData clientData, int flags); - (void) _modalSession: (NSModalSession) session sendEvent: (NSEvent *) event; @end -@implementation NSWindow(TKNotify) -- (id) tkDisplayIfNeeded -{ - if (![self isAutodisplay]) { - [self displayIfNeeded]; - } - return nil; -} -@end - @implementation TKApplication(TKNotify) -/* Display all windows each time an event is removed from the queue.*/ -- (NSEvent *) nextEventMatchingMask: (NSUInteger) mask - untilDate: (NSDate *) expiration inMode: (NSString *) mode - dequeue: (BOOL) deqFlag -{ - NSEvent *event = [super nextEventMatchingMask:mask - untilDate:expiration - inMode:mode - dequeue:deqFlag]; - /* Retain this event for later use. Must be released.*/ - [event retain]; - [NSApp makeWindowsPerform:@selector(tkDisplayIfNeeded) inOrder:NO]; - return event; -} +/* + * Earlier versions of Tk would override nextEventMatchingMask here, adding a + * call to displayIfNeeded on all windows after calling super. This would cause + * windows to be redisplayed (if necessary) each time that an event was + * received. This was intended to replace Apple's default autoDisplay + * mechanism, which the earlier versions of Tk would disable. When autoDisplay + * is set to the default value of YES, the Apple event loop will call + * displayIfNeeded on all windows at the beginning of each iteration of their + * event loop. Since Tk does not call the Apple event loop, it was thought + * that the autoDisplay behavior needed to be replicated. + * + * However, as of OSX 10.14 (Mojave) the autoDisplay property became + * deprecated. Luckily it turns out that, even though we don't ever start the + * Apple event loop, the Apple window manager still calls displayIfNeeded on + * all windows on a regular basis, perhaps each time the queue is empty. So we + * no longer, and perhaps never did need to set autoDisplay to NO, nor call + * displayIfNeeded on our windows. We can just leave all of that to the window + * manager. + */ /* * Call super then check the pasteboard. @@ -229,7 +224,6 @@ TkMacOSXEventsSetupProc( if (currentEvent.type > 0) { Tcl_SetMaxBlockTime(&zeroBlockTime); } - [currentEvent release]; } } } @@ -298,7 +292,6 @@ TkMacOSXEventsCheckProc( [NSApp sendEvent:currentEvent]; } } - [currentEvent release]; } else { break; } diff --git a/macosx/tkMacOSXPrivate.h b/macosx/tkMacOSXPrivate.h index 28597dd..796b4db 100644 --- a/macosx/tkMacOSXPrivate.h +++ b/macosx/tkMacOSXPrivate.h @@ -344,8 +344,10 @@ VISIBILITY_HIDDEN @end @interface NSWindow(TKWm) +#if MAC_OS_X_VERSION_MIN_REQUIRED < 1012 - (NSPoint) convertPointToScreen:(NSPoint)point; - (NSPoint) convertPointFromScreen:(NSPoint)point; +#endif @end #pragma mark NSMenu & NSMenuItem Utilities diff --git a/macosx/tkMacOSXWm.c b/macosx/tkMacOSXWm.c index 55a6633..9b76066 100644 --- a/macosx/tkMacOSXWm.c +++ b/macosx/tkMacOSXWm.c @@ -212,7 +212,7 @@ static int windowHashInit = false; { return [self convertScreenToBase:point]; } -#else +#elif MAC_OS_X_VERSION_MIN_REQUIRED < 1012 - (NSPoint) convertPointToScreen: (NSPoint) point { NSRect pointrect; @@ -5649,7 +5649,6 @@ TkMacOSXMakeRealWindowExist( [window setDelegate:NSApp]; [window setAcceptsMouseMovedEvents:YES]; [window setReleasedWhenClosed:NO]; - [window setAutodisplay:NO]; if (styleMask & NSUtilityWindowMask) { [(NSPanel*)window setFloatingPanel:YES]; } -- cgit v0.12 From cbe1934ea6df107ca09461c85ca4a85975d492e8 Mon Sep 17 00:00:00 2001 From: culler Date: Sun, 21 Oct 2018 22:53:22 +0000 Subject: Add a runtime check for the OS version, to decide whether to process idle events in drawRect. --- macosx/tkMacOSXInit.c | 13 +++++++++++++ macosx/tkMacOSXPrivate.h | 4 +++- macosx/tkMacOSXWindowEvent.c | 8 ++++++-- macosx/tkMacOSXWm.c | 2 +- 4 files changed, 23 insertions(+), 4 deletions(-) diff --git a/macosx/tkMacOSXInit.c b/macosx/tkMacOSXInit.c index e03b5aa..c12c394 100644 --- a/macosx/tkMacOSXInit.c +++ b/macosx/tkMacOSXInit.c @@ -153,6 +153,19 @@ long tkMacOSXMacOSXVersion = 0; [NSApp setPoolLock:0]; /* + * Record the OS version we are running on. + */ + int minorVersion; +#if MAC_OS_X_VERSION_MIN_REQUIRED < 1080 + Gestalt(gestaltSystemVersionMinor, (SInt32*)&minorVersion); +#else + NSOperatingSystemVersion systemVersion; + systemVersion = [[NSProcessInfo processInfo] operatingSystemVersion]; + minorVersion = systemVersion.minorVersion; +#endif + [NSApp setMacMinorVersion: minorVersion]; + + /* * Be our own delegate. */ [self setDelegate:self]; diff --git a/macosx/tkMacOSXPrivate.h b/macosx/tkMacOSXPrivate.h index 796b4db..7337400 100644 --- a/macosx/tkMacOSXPrivate.h +++ b/macosx/tkMacOSXPrivate.h @@ -265,9 +265,11 @@ VISIBILITY_HIDDEN #ifdef __i386__ /* The Objective C runtime used on i386 requires this. */ int _poolLock; + int _macMinorVersion; #endif } @property int poolLock; +@property int macMinorVersion; @end @interface TKApplication(TKInit) @@ -344,7 +346,7 @@ VISIBILITY_HIDDEN @end @interface NSWindow(TKWm) -#if MAC_OS_X_VERSION_MIN_REQUIRED < 1012 +#if MAC_OS_X_VERSION_MIN_REQUIRED < 101400 - (NSPoint) convertPointToScreen:(NSPoint)point; - (NSPoint) convertPointFromScreen:(NSPoint)point; #endif diff --git a/macosx/tkMacOSXWindowEvent.c b/macosx/tkMacOSXWindowEvent.c index 36fc297..379e4a6 100644 --- a/macosx/tkMacOSXWindowEvent.c +++ b/macosx/tkMacOSXWindowEvent.c @@ -930,10 +930,14 @@ ConfigureRestrictProc( * * Fortunately, Tk schedules all drawing to be done while Tcl is idle. * So we can do the drawing by processing all of the idle events that - * were created when the expose events were processed. + * were created when the expose events were processed. Unfortunately, + * doing this on 10.13 or earlier causes hangs when drawRect is called + * while Tcl is waiting for events or variable changes. */ - while (Tcl_DoOneEvent(TCL_IDLE_EVENTS)) {} + if ([NSApp macMinorVersion] > 13 || [self inLiveResize]) { + while (Tcl_DoOneEvent(TCL_IDLE_EVENTS)) {} + } } } diff --git a/macosx/tkMacOSXWm.c b/macosx/tkMacOSXWm.c index 9b76066..8bbaae0 100644 --- a/macosx/tkMacOSXWm.c +++ b/macosx/tkMacOSXWm.c @@ -212,7 +212,7 @@ static int windowHashInit = false; { return [self convertScreenToBase:point]; } -#elif MAC_OS_X_VERSION_MIN_REQUIRED < 1012 +#elif MAC_OS_X_VERSION_MIN_REQUIRED < 101400 - (NSPoint) convertPointToScreen: (NSPoint) point { NSRect pointrect; -- cgit v0.12 From cc318f1280b90cae4f3fc825effccc181cb2e41e Mon Sep 17 00:00:00 2001 From: culler Date: Mon, 22 Oct 2018 16:12:18 +0000 Subject: On Mojave, hangs can be prevented by processing virtual events in drawRect. Also fix XSync. --- macosx/tkMacOSXEvent.c | 15 +++++---------- macosx/tkMacOSXWindowEvent.c | 30 +++++++++++++++++++++--------- 2 files changed, 26 insertions(+), 19 deletions(-) diff --git a/macosx/tkMacOSXEvent.c b/macosx/tkMacOSXEvent.c index 226f75c..77febc5 100644 --- a/macosx/tkMacOSXEvent.c +++ b/macosx/tkMacOSXEvent.c @@ -112,14 +112,16 @@ enum { * * TkMacOSXFlushWindows -- * - * This routine flushes all the visible windows of the application. It is - * called by XSync(). + * This routine is a stub called by XSync. It used to call + * displayIfNeeded on all NSWindows which belong to XWindows. This is not + * needed, and in fact dangerous, with the current design of drawRect. + * Now it is a no-op. * * Results: * None. * * Side effects: - * Flushes all visible Cocoa windows + * None * *---------------------------------------------------------------------- */ @@ -127,13 +129,6 @@ enum { MODULE_SCOPE void TkMacOSXFlushWindows(void) { - NSArray *macWindows = [NSApp orderedWindows]; - - for (NSWindow *w in macWindows) { - if (TkMacOSXGetXWindow(w)) { - [w displayIfNeeded]; - } - } } diff --git a/macosx/tkMacOSXWindowEvent.c b/macosx/tkMacOSXWindowEvent.c index 379e4a6..c29a823 100644 --- a/macosx/tkMacOSXWindowEvent.c +++ b/macosx/tkMacOSXWindowEvent.c @@ -794,6 +794,15 @@ ConfigureRestrictProc( return (eventPtr->type==ConfigureNotify ? TK_PROCESS_EVENT : TK_DEFER_EVENT); } +/*Restrict event processing to VirtualEvents.*/ +static Tk_RestrictAction +VirtualEventRestrictProc( + ClientData arg, + XEvent *eventPtr) +{ + return (eventPtr->type==VirtualEvent ? TK_PROCESS_EVENT : TK_DEFER_EVENT); +} + @implementation TKContentView(TKWindowEvent) - (void) drawRect: (NSRect) rect @@ -890,7 +899,8 @@ ConfigureRestrictProc( CGRect updateBounds; int updatesNeeded; TkWindow *winPtr = TkMacOSXGetTkWindow([self window]); - + ClientData oldArg; + Tk_RestrictProc *oldProc; if (!winPtr) { return; } @@ -914,9 +924,7 @@ ConfigureRestrictProc( * First process all of the Expose events. */ - ClientData oldArg; - Tk_RestrictProc *oldProc = Tk_RestrictEvents(ExposeRestrictProc, - UINT2PTR(serial), &oldArg); + oldProc = Tk_RestrictEvents(ExposeRestrictProc, UINT2PTR(serial), &oldArg); while (Tcl_ServiceEvent(TCL_WINDOW_EVENTS)) {}; Tk_RestrictEvents(oldProc, oldArg, &oldArg); @@ -930,13 +938,17 @@ ConfigureRestrictProc( * * Fortunately, Tk schedules all drawing to be done while Tcl is idle. * So we can do the drawing by processing all of the idle events that - * were created when the expose events were processed. Unfortunately, - * doing this on 10.13 or earlier causes hangs when drawRect is called - * while Tcl is waiting for events or variable changes. + * were created when the expose events were processed. To prevent hangs + * when virtual events are generated by one of the idle processes we + * also process virtual events here. Unfortunately this does not work + * in macOS 10.13. */ - - if ([NSApp macMinorVersion] > 13 || [self inLiveResize]) { + if ([self inLiveResize]) { while (Tcl_DoOneEvent(TCL_IDLE_EVENTS)) {} + } else if ([NSApp macMinorVersion] > 13) { + oldProc = Tk_RestrictEvents(VirtualEventRestrictProc, NULL, &oldArg); + while (Tcl_DoOneEvent(TCL_ALL_EVENTS|TCL_DONT_WAIT)) {} + Tk_RestrictEvents(oldProc, oldArg, &oldArg); } } } -- cgit v0.12 From c706cc9dd2acfd83dab0c2d07679a2f5742ecf76 Mon Sep 17 00:00:00 2001 From: culler Date: Mon, 22 Oct 2018 17:34:08 +0000 Subject: Remove the sleep from the button flash command on macOS. This causes a hang on Mojave and the flash doesn't do anything on a mac anyway. --- generic/tkButton.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/generic/tkButton.c b/generic/tkButton.c index fc2c7ec..7760359 100644 --- a/generic/tkButton.c +++ b/generic/tkButton.c @@ -879,7 +879,13 @@ ButtonWidgetObjCmd( Tcl_CancelIdleCall(TkpDisplayButton, butPtr); XFlush(butPtr->display); + #ifndef MAC_OSX_TK + /* + * On the mac you can not sleep in a display proc, and the + * flash command doesn't do anything anyway. + */ Tcl_Sleep(50); + #endif } } break; -- cgit v0.12 From 8af6259af6c2bda3d4c3b16266e5bcbbf25876a2 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Mon, 22 Oct 2018 17:56:45 +0000 Subject: Fix safe.test test-cases: since the :process and :zipfs (among others) changes this started failing. --- tests/safe.test | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/tests/safe.test b/tests/safe.test index 16068d3..d4e5f2e 100644 --- a/tests/safe.test +++ b/tests/safe.test @@ -33,14 +33,34 @@ namespace import -force tcltest::test # The set of hidden commands is platform dependent: -set hidden_cmds {bell cd clipboard encoding exec exit fconfigure glob grab load menu open pwd selection socket source tcl:encoding:dirs toplevel unload wm} +set hidden_cmds {bell cd clipboard encoding exec exit fconfigure} lappend hidden_cmds {*}[apply {{} { + if {[package vsatisfies [package provide Tcl] 8.7-]} { + lappend result file + } + lappend result glob grab load menu open pwd selection socket source tcl:encoding:dirs + if {[package vsatisfies [package provide Tcl] 8.7-]} { + lappend result tcl:encoding:system + } + lappend result toplevel unload wm foreach cmd { atime attributes copy delete dirname executable exists extension isdirectory isfile link lstat mkdir mtime nativename normalize owned readable readlink rename rootname size stat tail tempfile type volumes writable - } {lappend result tcl:file:$cmd}; return $result + } {lappend result tcl:file:$cmd} + if {[package vsatisfies [package provide Tcl] 8.7-]} { + foreach cmd { + cmdtype nameofexecutable + } {lappend result tcl:info:$cmd} + foreach cmd { + autopurge list purge status + } {lappend result tcl:process:$cmd} + foreach cmd { + lmkimg lmkzip mkimg mkkey mkzip mount mount_data unmount + } {lappend result tcl:zipfs:$cmd} + } + return $result }}] if {[tk windowingsystem] ne "x11"} { lappend hidden_cmds tk_chooseColor tk_chooseDirectory tk_getOpenFile \ -- cgit v0.12 From e9eb4fec4431e0edf6242aaa62a9196d2bfced0c Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Mon, 22 Oct 2018 17:58:56 +0000 Subject: Fix PTR2INT/PTR2UINT, so they no longer are restricted to the "int" range. Make TCL_Z_MODIFIER available in Tk (even when compiled with Tcl 8.6), and use it. More size_t/clientData related improvements --- generic/tkAtom.c | 4 ++-- generic/tkBind.c | 10 +++++----- generic/tkInt.h | 18 ++++++++++++++---- generic/tkSelect.c | 6 +++--- generic/tkSelect.h | 12 ++++++++---- macosx/tkMacOSXBitmap.c | 2 +- macosx/tkMacOSXEmbed.c | 4 ++-- macosx/tkMacOSXKeyboard.c | 4 ++-- macosx/tkMacOSXScrlbr.c | 2 +- macosx/tkMacOSXWindowEvent.c | 4 ++-- unix/tkUnixEmbed.c | 4 ++-- win/tkWinColor.c | 4 ++-- win/tkWinTest.c | 6 +++--- win/tkWinWm.c | 2 +- 14 files changed, 48 insertions(+), 34 deletions(-) diff --git a/generic/tkAtom.c b/generic/tkAtom.c index 2491fb2..ddfa97f 100644 --- a/generic/tkAtom.c +++ b/generic/tkAtom.c @@ -156,7 +156,7 @@ Tk_GetAtomName( } name = Tcl_GetHashKey(&dispPtr->nameTable, hPtr); hPtr = Tcl_CreateHashEntry(&dispPtr->atomTable, INT2PTR(atom), &isNew); - Tcl_SetHashValue(hPtr, name); + Tcl_SetHashValue(hPtr, (char *)name); } return Tcl_GetHashValue(hPtr); } @@ -202,7 +202,7 @@ AtomInit( Tcl_SetHashValue(hPtr, INT2PTR(atom)); name = Tcl_GetHashKey(&dispPtr->nameTable, hPtr); hPtr = Tcl_CreateHashEntry(&dispPtr->atomTable, INT2PTR(atom), &isNew); - Tcl_SetHashValue(hPtr, name); + Tcl_SetHashValue(hPtr, (char *)name); } } diff --git a/generic/tkBind.c b/generic/tkBind.c index cc0b582..a1511a6 100644 --- a/generic/tkBind.c +++ b/generic/tkBind.c @@ -687,11 +687,11 @@ TkBindInit( Tcl_InitHashTable(&nameTable, TCL_ONE_WORD_KEYS); for (kPtr = keyArray; kPtr->name != NULL; kPtr++) { hPtr = Tcl_CreateHashEntry(&keySymTable, kPtr->name, &newEntry); - Tcl_SetHashValue(hPtr, kPtr->value); - hPtr = Tcl_CreateHashEntry(&nameTable, (char *) kPtr->value, + Tcl_SetHashValue(hPtr, INT2PTR(kPtr->value)); + hPtr = Tcl_CreateHashEntry(&nameTable, INT2PTR(kPtr->value), &newEntry); if (newEntry) { - Tcl_SetHashValue(hPtr, kPtr->name); + Tcl_SetHashValue(hPtr, (char *) kPtr->name); } } #endif /* REDO_KEYSYM_LOOKUP */ @@ -699,13 +699,13 @@ TkBindInit( Tcl_InitHashTable(&modTable, TCL_STRING_KEYS); for (modPtr = modArray; modPtr->name != NULL; modPtr++) { hPtr = Tcl_CreateHashEntry(&modTable, modPtr->name, &newEntry); - Tcl_SetHashValue(hPtr, modPtr); + Tcl_SetHashValue(hPtr, (ModInfo *) modPtr); } Tcl_InitHashTable(&eventTable, TCL_STRING_KEYS); for (eiPtr = eventArray; eiPtr->name != NULL; eiPtr++) { hPtr = Tcl_CreateHashEntry(&eventTable, eiPtr->name, &newEntry); - Tcl_SetHashValue(hPtr, eiPtr); + Tcl_SetHashValue(hPtr, (EventInfo *) eiPtr); } initialized = 1; } diff --git a/generic/tkInt.h b/generic/tkInt.h index f903490..7be0e73 100644 --- a/generic/tkInt.h +++ b/generic/tkInt.h @@ -75,19 +75,19 @@ #if !defined(INT2PTR) && !defined(PTR2INT) # if defined(HAVE_INTPTR_T) || defined(intptr_t) # define INT2PTR(p) ((void*)(intptr_t)(p)) -# define PTR2INT(p) ((int)(intptr_t)(p)) +# define PTR2INT(p) ((intptr_t)(p)) # else # define INT2PTR(p) ((void*)(p)) -# define PTR2INT(p) ((int)(p)) +# define PTR2INT(p) ((long)(p)) # endif #endif #if !defined(UINT2PTR) && !defined(PTR2UINT) # if defined(HAVE_UINTPTR_T) || defined(uintptr_t) # define UINT2PTR(p) ((void*)(uintptr_t)(p)) -# define PTR2UINT(p) ((unsigned int)(uintptr_t)(p)) +# define PTR2UINT(p) ((uintptr_t)(p)) # else # define UINT2PTR(p) ((void*)(p)) -# define PTR2UINT(p) ((unsigned int)(p)) +# define PTR2UINT(p) ((unsigned long)(p)) # endif #endif @@ -95,6 +95,16 @@ # define TCL_AUTO_LENGTH (-1) #endif +#ifndef TCL_Z_MODIFIER +# if defined(_WIN64) +# define TCL_Z_MODIFIER "I" +# elif defined(__GNUC__) && !defined(_WIN32) +# define TCL_Z_MODIFIER "z" +# else +# define TCL_Z_MODIFIER "" +# endif +#endif /* !TCL_Z_MODIFIER */ + /* * Opaque type declarations: */ diff --git a/generic/tkSelect.c b/generic/tkSelect.c index 02268d3..d97db45 100644 --- a/generic/tkSelect.c +++ b/generic/tkSelect.c @@ -357,7 +357,7 @@ Tk_OwnSelection( TkDisplay *dispPtr = winPtr->dispPtr; TkSelectionInfo *infoPtr; Tk_LostSelProc *clearProc = NULL; - ClientData clearData = NULL;/* Initialization needed only to prevent + void *clearData = NULL;/* Initialization needed only to prevent * compiler warning. */ if (dispPtr->multipleAtom == None) { @@ -466,7 +466,7 @@ Tk_ClearSelection( TkSelectionInfo *prevPtr; TkSelectionInfo *nextPtr; Tk_LostSelProc *clearProc = NULL; - ClientData clearData = NULL;/* Initialization needed only to prevent + void *clearData = NULL;/* Initialization needed only to prevent * compiler warning. */ if (dispPtr->multipleAtom == None) { @@ -1246,7 +1246,7 @@ TkSelClearSelection( } if (infoPtr != NULL && (infoPtr->owner == tkwin) && - (eventPtr->xselectionclear.serial >= (unsigned) infoPtr->serial)) { + (eventPtr->xselectionclear.serial >= (unsigned long) infoPtr->serial)) { if (prevPtr == NULL) { dispPtr->selectionInfoPtr = infoPtr->nextPtr; } else { diff --git a/generic/tkSelect.h b/generic/tkSelect.h index 74326d0..d7df94e 100644 --- a/generic/tkSelect.h +++ b/generic/tkSelect.h @@ -25,14 +25,18 @@ typedef struct TkSelectionInfo { Atom selection; /* Selection name, e.g. XA_PRIMARY. */ Tk_Window owner; /* Current owner of this selection. */ - int serial; /* Serial number of last XSelectionSetOwner +#if TCL_MAJOR_VERSION > 8 + unsigned long serial; /* Serial number of last XSelectionSetOwner * request made to server for this selection * (used to filter out redundant * SelectionClear events). */ +#else + int serial; +#endif Time time; /* Timestamp used to acquire selection. */ Tk_LostSelProc *clearProc; /* Procedure to call when owner loses * selection. */ - ClientData clearData; /* Info to pass to clearProc. */ + void *clearData; /* Info to pass to clearProc. */ struct TkSelectionInfo *nextPtr; /* Next in list of current selections on this * display. NULL means end of list. */ @@ -52,8 +56,8 @@ typedef struct TkSelHandler { * returned, such as STRING or ATOM. */ Tk_SelectionProc *proc; /* Procedure to generate selection in this * format. */ - ClientData clientData; /* Argument to pass to proc. */ - int size; /* Size of units returned by proc (8 for + void *clientData; /* Argument to pass to proc. */ + TkSizeT size; /* Size of units returned by proc (8 for * STRING, 32 for almost anything else). */ struct TkSelHandler *nextPtr; /* Next selection handler associated with same diff --git a/macosx/tkMacOSXBitmap.c b/macosx/tkMacOSXBitmap.c index cf46202..f779097 100644 --- a/macosx/tkMacOSXBitmap.c +++ b/macosx/tkMacOSXBitmap.c @@ -173,7 +173,7 @@ TkpCreateNativeBitmap( OSErr err; err = ChkErr(GetIconRef, kOnSystemDisk, kSystemIconsCreator, - PTR2UINT(source), &icon); + (unsigned int)PTR2UINT(source), &icon); if (err == noErr) { pixmap = GetBitmapForIcon(display, icon, CGSizeMake(builtInIconSize, builtInIconSize)); diff --git a/macosx/tkMacOSXEmbed.c b/macosx/tkMacOSXEmbed.c index f6c32b3..05bf832 100644 --- a/macosx/tkMacOSXEmbed.c +++ b/macosx/tkMacOSXEmbed.c @@ -627,7 +627,7 @@ TkpTestembedCmd( if (containerPtr->parent == None) { Tcl_DStringAppendElement(&dString, ""); } else if (all) { - sprintf(buffer, "0x%x", (int) containerPtr->parent); + sprintf(buffer, "0x%" TCL_Z_MODIFIER "x", (size_t) containerPtr->parent); Tcl_DStringAppendElement(&dString, buffer); } else { Tcl_DStringAppendElement(&dString, "XXX"); @@ -641,7 +641,7 @@ TkpTestembedCmd( if (containerPtr->embedded == None) { Tcl_DStringAppendElement(&dString, ""); } else if (all) { - sprintf(buffer, "0x%x", (int) containerPtr->embedded); + sprintf(buffer, "0x%" TCL_Z_MODIFIER "x", (size_t) containerPtr->embedded); Tcl_DStringAppendElement(&dString, buffer); } else { Tcl_DStringAppendElement(&dString, "XXX"); diff --git a/macosx/tkMacOSXKeyboard.c b/macosx/tkMacOSXKeyboard.c index 31f842a..5899064 100644 --- a/macosx/tkMacOSXKeyboard.c +++ b/macosx/tkMacOSXKeyboard.c @@ -180,13 +180,13 @@ InitKeyMaps(void) for (kPtr = keyArray; kPtr->keycode != 0; kPtr++) { hPtr = Tcl_CreateHashEntry(&keycodeTable, INT2PTR(kPtr->keycode), &dummy); - Tcl_SetHashValue(hPtr, kPtr->keysym); + Tcl_SetHashValue(hPtr, INT2PTR(kPtr->keysym)); } Tcl_InitHashTable(&vkeyTable, TCL_ONE_WORD_KEYS); for (kPtr = virtualkeyArray; kPtr->keycode != 0; kPtr++) { hPtr = Tcl_CreateHashEntry(&vkeyTable, INT2PTR(kPtr->keycode), &dummy); - Tcl_SetHashValue(hPtr, kPtr->keysym); + Tcl_SetHashValue(hPtr, INT2PTR(kPtr->keysym)); } initialized = 1; } diff --git a/macosx/tkMacOSXScrlbr.c b/macosx/tkMacOSXScrlbr.c index 69389f0..f15146d 100644 --- a/macosx/tkMacOSXScrlbr.c +++ b/macosx/tkMacOSXScrlbr.c @@ -478,7 +478,7 @@ UpdateControlValues( } else { info.attributes |= kThemeTrackHorizontal; } - + /* * Given the Tk parameters for the fractions of the start and end of the * thumb, the following calculation determines the location for the diff --git a/macosx/tkMacOSXWindowEvent.c b/macosx/tkMacOSXWindowEvent.c index f6ec72b..d042450 100644 --- a/macosx/tkMacOSXWindowEvent.c +++ b/macosx/tkMacOSXWindowEvent.c @@ -237,7 +237,7 @@ extern NSString *NSWindowDidOrderOffScreenNotification; observe(NSWindowDidOrderOffScreenNotification, windowUnmapped:); #endif #undef observe - + } @end @@ -937,7 +937,7 @@ ConfigureRestrictProc( } } - + /* * These two methods allow Tk to register a virtual event which fires when the * appearance changes on 10.14. diff --git a/unix/tkUnixEmbed.c b/unix/tkUnixEmbed.c index b170ad0..3cb5d26 100644 --- a/unix/tkUnixEmbed.c +++ b/unix/tkUnixEmbed.c @@ -888,7 +888,7 @@ TkpTestembedCmd( if (containerPtr->parent == None) { Tcl_DStringAppendElement(&dString, ""); } else if (all) { - sprintf(buffer, "0x%x", (int) containerPtr->parent); + sprintf(buffer, "0x%" TCL_Z_MODIFIER "x", (size_t) containerPtr->parent); Tcl_DStringAppendElement(&dString, buffer); } else { Tcl_DStringAppendElement(&dString, "XXX"); @@ -902,7 +902,7 @@ TkpTestembedCmd( if (containerPtr->wrapper == None) { Tcl_DStringAppendElement(&dString, ""); } else if (all) { - sprintf(buffer, "0x%x", (int) containerPtr->wrapper); + sprintf(buffer, "0x%" TCL_Z_MODIFIER "x", (size_t) containerPtr->wrapper); Tcl_DStringAppendElement(&dString, buffer); } else { Tcl_DStringAppendElement(&dString, "XXX"); diff --git a/win/tkWinColor.c b/win/tkWinColor.c index ba9815c..5540d9a 100644 --- a/win/tkWinColor.c +++ b/win/tkWinColor.c @@ -364,7 +364,7 @@ XAllocColor( } else { refCount = (size_t)Tcl_GetHashValue(entryPtr) + 1; } - Tcl_SetHashValue(entryPtr, (void *)refCount); + Tcl_SetHashValue(entryPtr, INT2PTR(refCount)); } else { /* * Determine what color will actually be used on non-colormap systems. @@ -446,7 +446,7 @@ XFreeColors( } Tcl_DeleteHashEntry(entryPtr); } else { - Tcl_SetHashValue(entryPtr, (size_t)refCount); + Tcl_SetHashValue(entryPtr, INT2PTR(refCount)); } } } diff --git a/win/tkWinTest.c b/win/tkWinTest.c index 1c121cc..4fac15c 100644 --- a/win/tkWinTest.c +++ b/win/tkWinTest.c @@ -483,7 +483,7 @@ TestfindwindowObjCmd( AppendSystemError(interp, GetLastError()); r = TCL_ERROR; } else { - Tcl_SetObjResult(interp, Tcl_NewWideIntObj((size_t)hwnd)); + Tcl_SetObjResult(interp, Tcl_NewWideIntObj(PTR2INT(hwnd))); } Tcl_DStringFree(&titleString); @@ -499,7 +499,7 @@ EnumChildrenProc( { Tcl_Obj *listObj = (Tcl_Obj *) lParam; - Tcl_ListObjAppendElement(NULL, listObj, Tcl_NewWideIntObj((size_t)hwnd)); + Tcl_ListObjAppendElement(NULL, listObj, Tcl_NewWideIntObj(PTR2INT(hwnd))); return TRUE; } @@ -549,7 +549,7 @@ TestgetwindowinfoObjCmd( Tcl_DictObjPut(interp, dictObj, Tcl_NewStringObj("text", 4), textObj); Tcl_DictObjPut(interp, dictObj, Tcl_NewStringObj("parent", 6), - Tcl_NewWideIntObj((size_t)(GetParent((HWND)(size_t)hwnd)))); + Tcl_NewWideIntObj(PTR2INT(GetParent((HWND)(size_t)hwnd)))); childrenObj = Tcl_NewListObj(0, NULL); EnumChildWindows((HWND)(size_t)hwnd, EnumChildrenProc, (LPARAM)childrenObj); diff --git a/win/tkWinWm.c b/win/tkWinWm.c index 20cd72b..b750566 100644 --- a/win/tkWinWm.c +++ b/win/tkWinWm.c @@ -3728,7 +3728,7 @@ WmFrameCmd( if (hwnd == NULL) { hwnd = Tk_GetHWND(Tk_WindowId((Tk_Window) winPtr)); } - Tcl_SetObjResult(interp, Tcl_ObjPrintf("0x%x", PTR2INT(hwnd))); + Tcl_SetObjResult(interp, Tcl_ObjPrintf("0x%" TCL_Z_MODIFIER "x", (size_t)PTR2INT(hwnd))); return TCL_OK; } -- cgit v0.12 From 9425ddcb57a98e497b37a6167b687c77fb1e975a Mon Sep 17 00:00:00 2001 From: fvogel Date: Mon, 22 Oct 2018 20:42:20 +0000 Subject: Add test textDisp-24.25 exercising a basic testcase for Tablelist (see [1c8aad0efa] --- tests/textDisp.test | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/tests/textDisp.test b/tests/textDisp.test index 115b8cf..208f664 100644 --- a/tests/textDisp.test +++ b/tests/textDisp.test @@ -3374,6 +3374,16 @@ test textDisp-24.24 {TkTextCharLayoutProc, justification and tabs} {textfonts} { .t tag add x 1.0 end list [.t bbox 1.0] [.t bbox 1.10] } [list [list 45 3 7 $fixedHeight] [list 94 3 7 $fixedHeight]] +test textDisp-24.25 {TkTextCharLayoutProc, justification and tabs} -constraints {textfonts} -setup { + text .tt -tabs {40 right} -wrap none -font $fixedFont + pack .tt +} -body { + .tt insert end \t9\n\t99\n\t999 + update + list [.tt bbox 1.1] [.tt bbox 2.2] [.tt bbox 3.3] +} -cleanup { + destroy .tt +} -result [list [list 38 5 7 $fixedHeight] [list 38 20 7 $fixedHeight] [list 38 35 7 $fixedHeight]] .t configure -width 40 -bd 0 -relief flat -highlightthickness 0 -padx 0 \ -tabs 100 -- cgit v0.12 From 4164dc9d138576130eaf4267f826bfeac0c9533a Mon Sep 17 00:00:00 2001 From: culler Date: Tue, 23 Oct 2018 19:27:55 +0000 Subject: Made a small change in tkTextDisp.c which (on 10.14) fixes the hang in text-11a.41 as well as the failures in textWind-11.1 and textWind-11.2. --- generic/tkTextDisp.c | 9 ++++++++- macosx/tkMacOSXWindowEvent.c | 21 +++------------------ 2 files changed, 11 insertions(+), 19 deletions(-) diff --git a/generic/tkTextDisp.c b/generic/tkTextDisp.c index 126b631..80276e4 100644 --- a/generic/tkTextDisp.c +++ b/generic/tkTextDisp.c @@ -5134,6 +5134,7 @@ TkTextRelayoutWindow( TextDInfo *dInfoPtr = textPtr->dInfoPtr; GC newGC; XGCValues gcValues; + Bool inSync = true; /* * Schedule the window redisplay. See TkTextChanged for the reason why @@ -5142,6 +5143,7 @@ TkTextRelayoutWindow( if (!(dInfoPtr->flags & REDRAW_PENDING)) { Tcl_DoWhenIdle(DisplayText, textPtr); + inSync = false; } dInfoPtr->flags |= REDRAW_PENDING|REDRAW_BORDERS|DINFO_OUT_OF_DATE |REPICK_NEEDED; @@ -5213,6 +5215,7 @@ TkTextRelayoutWindow( dInfoPtr->yScrollFirst = dInfoPtr->yScrollLast = -1; if (mask & TK_TEXT_LINE_GEOMETRY) { + /* * Set up line metric recalculation. * @@ -5237,7 +5240,11 @@ TkTextRelayoutWindow( textPtr->refCount++; dInfoPtr->lineUpdateTimer = Tcl_CreateTimerHandler(1, AsyncUpdateLineMetrics, textPtr); - GenerateWidgetViewSyncEvent(textPtr, 0); + inSync = false; + } + + if (!inSync) { + GenerateWidgetViewSyncEvent(textPtr, 0); } } } diff --git a/macosx/tkMacOSXWindowEvent.c b/macosx/tkMacOSXWindowEvent.c index c29a823..6e9948a 100644 --- a/macosx/tkMacOSXWindowEvent.c +++ b/macosx/tkMacOSXWindowEvent.c @@ -794,15 +794,6 @@ ConfigureRestrictProc( return (eventPtr->type==ConfigureNotify ? TK_PROCESS_EVENT : TK_DEFER_EVENT); } -/*Restrict event processing to VirtualEvents.*/ -static Tk_RestrictAction -VirtualEventRestrictProc( - ClientData arg, - XEvent *eventPtr) -{ - return (eventPtr->type==VirtualEvent ? TK_PROCESS_EVENT : TK_DEFER_EVENT); -} - @implementation TKContentView(TKWindowEvent) - (void) drawRect: (NSRect) rect @@ -938,17 +929,11 @@ VirtualEventRestrictProc( * * Fortunately, Tk schedules all drawing to be done while Tcl is idle. * So we can do the drawing by processing all of the idle events that - * were created when the expose events were processed. To prevent hangs - * when virtual events are generated by one of the idle processes we - * also process virtual events here. Unfortunately this does not work - * in macOS 10.13. + * were created when the expose events were processed. Unfortunately + * this does not work in macOS 10.13. */ - if ([self inLiveResize]) { + if ([NSApp macMinorVersion] > 13 || [self inLiveResize]) { while (Tcl_DoOneEvent(TCL_IDLE_EVENTS)) {} - } else if ([NSApp macMinorVersion] > 13) { - oldProc = Tk_RestrictEvents(VirtualEventRestrictProc, NULL, &oldArg); - while (Tcl_DoOneEvent(TCL_ALL_EVENTS|TCL_DONT_WAIT)) {} - Tk_RestrictEvents(oldProc, oldArg, &oldArg); } } } -- cgit v0.12 From 10419b34ce19aa64a693bc7d393a325b47e66edd Mon Sep 17 00:00:00 2001 From: fvogel Date: Tue, 23 Oct 2018 20:06:29 +0000 Subject: Fix the build for Windows --- generic/tkTextDisp.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/generic/tkTextDisp.c b/generic/tkTextDisp.c index 80276e4..32ce558 100644 --- a/generic/tkTextDisp.c +++ b/generic/tkTextDisp.c @@ -5134,7 +5134,7 @@ TkTextRelayoutWindow( TextDInfo *dInfoPtr = textPtr->dInfoPtr; GC newGC; XGCValues gcValues; - Bool inSync = true; + Bool inSync = 1; /* * Schedule the window redisplay. See TkTextChanged for the reason why @@ -5143,7 +5143,7 @@ TkTextRelayoutWindow( if (!(dInfoPtr->flags & REDRAW_PENDING)) { Tcl_DoWhenIdle(DisplayText, textPtr); - inSync = false; + inSync = 0; } dInfoPtr->flags |= REDRAW_PENDING|REDRAW_BORDERS|DINFO_OUT_OF_DATE |REPICK_NEEDED; @@ -5240,7 +5240,7 @@ TkTextRelayoutWindow( textPtr->refCount++; dInfoPtr->lineUpdateTimer = Tcl_CreateTimerHandler(1, AsyncUpdateLineMetrics, textPtr); - inSync = false; + inSync = 0; } if (!inSync) { -- cgit v0.12 From 6327579716bd47191431b8c778cfca0552a198c8 Mon Sep 17 00:00:00 2001 From: culler Date: Tue, 23 Oct 2018 21:49:44 +0000 Subject: Restored the old tkMacOSXFlushWindows since making it a no-op breaks tests that assume the update command will run all display procs registered as idle tasks. --- macosx/tkMacOSXEvent.c | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/macosx/tkMacOSXEvent.c b/macosx/tkMacOSXEvent.c index 77febc5..25c0bea 100644 --- a/macosx/tkMacOSXEvent.c +++ b/macosx/tkMacOSXEvent.c @@ -112,16 +112,18 @@ enum { * * TkMacOSXFlushWindows -- * - * This routine is a stub called by XSync. It used to call - * displayIfNeeded on all NSWindows which belong to XWindows. This is not - * needed, and in fact dangerous, with the current design of drawRect. - * Now it is a no-op. + * This routine is a stub called by XSync, which is called during + * the Tk update command. It calls displayIfNeeded on all visible + * windows. This is necessary in order to insure that update will + * run all of the display procedures which have been registered as + * idle tasks. The test suite assumes that this is the case. * * Results: * None. * * Side effects: - * None + * Calls the drawRect method of the contentView of each visible + * window. * *---------------------------------------------------------------------- */ @@ -129,6 +131,14 @@ enum { MODULE_SCOPE void TkMacOSXFlushWindows(void) { + NSArray *macWindows = [NSApp orderedWindows]; + + for (NSWindow *w in macWindows) { + if (TkMacOSXGetXWindow(w)) { + [w displayIfNeeded]; + } + } + } -- cgit v0.12 From ddb5db1e6f025f1852420243feca27d491051596 Mon Sep 17 00:00:00 2001 From: culler Date: Wed, 24 Oct 2018 16:43:45 +0000 Subject: Added a boolean state variable so a displayProc can check if it is being run by drawRect. --- generic/tkTextDisp.c | 22 ++++++++++++++++++++-- macosx/tkMacOSXInit.c | 28 +++++++++------------------- macosx/tkMacOSXInt.h | 2 ++ macosx/tkMacOSXPrivate.h | 2 ++ macosx/tkMacOSXWindowEvent.c | 27 +++++++++++++++++++++++++++ 5 files changed, 60 insertions(+), 21 deletions(-) diff --git a/generic/tkTextDisp.c b/generic/tkTextDisp.c index 32ce558..35a43d4 100644 --- a/generic/tkTextDisp.c +++ b/generic/tkTextDisp.c @@ -206,10 +206,28 @@ typedef struct TextStyle { * Macro to make debugging/testing logging a little easier. */ +#ifndef MAC_OSX_TK #define LOG(toVar,what) \ Tcl_SetVar2(textPtr->interp, toVar, NULL, (what), \ TCL_GLOBAL_ONLY|TCL_APPEND_VALUE|TCL_LIST_ELEMENT) +#define CLEAR(var) \ + Tcl_SetVar2(interp, var, NULL, "", TCL_GLOBAL_ONLY) +#else +/* + * Drawing procedures are sometimes run because the system has decided + * to redraw the window. This can corrupt the data that a test is + * trying to collect. So we don't write to the logging variables when + * the drawing procedure is being run that way. + */ +#define LOG(toVar,what) \ + if (!TkpMacOSXAppIsDrawing()) \ + Tcl_SetVar2(textPtr->interp, toVar, NULL, (what), \ + TCL_GLOBAL_ONLY|TCL_APPEND_VALUE|TCL_LIST_ELEMENT) +#define CLEAR(var) \ + if (!TkpMacOSXAppIsDrawing()) \ + Tcl_SetVar2(interp, var, NULL, "", TCL_GLOBAL_ONLY) +#endif /* * The following structure describes one line of the display, which may be * either part or all of one line of the text. @@ -4136,7 +4154,7 @@ DisplayText( Tcl_Preserve(interp); if (tkTextDebug) { - Tcl_SetVar2(interp, "tk_textRelayout", NULL, "", TCL_GLOBAL_ONLY); + CLEAR("tk_textRelayout"); } if (!Tk_IsMapped(textPtr->tkwin) || (dInfoPtr->maxX <= dInfoPtr->x) @@ -4147,7 +4165,7 @@ DisplayText( } numRedisplays++; if (tkTextDebug) { - Tcl_SetVar2(interp, "tk_textRedraw", NULL, "", TCL_GLOBAL_ONLY); + CLEAR("tk_textRedraw"); } /* diff --git a/macosx/tkMacOSXInit.c b/macosx/tkMacOSXInit.c index c12c394..b85b66d 100644 --- a/macosx/tkMacOSXInit.c +++ b/macosx/tkMacOSXInit.c @@ -16,7 +16,6 @@ #include "tkMacOSXPrivate.h" #include -#include #include #include @@ -29,8 +28,6 @@ static char tkLibPath[PATH_MAX + 1] = ""; static char scriptPath[PATH_MAX + 1] = ""; -long tkMacOSXMacOSXVersion = 0; - #pragma mark TKApplication(TKInit) @interface TKApplication(TKKeyboard) @@ -48,6 +45,8 @@ long tkMacOSXMacOSXVersion = 0; @implementation TKApplication @synthesize poolLock = _poolLock; +@synthesize macMinorVersion = _macMinorVersion; +@synthesize isDrawing = _isDrawing; @end /* @@ -164,7 +163,13 @@ long tkMacOSXMacOSXVersion = 0; minorVersion = systemVersion.minorVersion; #endif [NSApp setMacMinorVersion: minorVersion]; - + + /* + * We are not drawing yet. + */ + + [NSApp setIsDrawing: NO]; + /* * Be our own delegate. */ @@ -268,7 +273,6 @@ TkpInit( */ if (!initialized) { - struct utsname name; struct stat st; initialized = 1; @@ -281,20 +285,6 @@ TkpInit( # error Mac OS X 10.6 required #endif - if (!uname(&name)) { - tkMacOSXMacOSXVersion = (strtod(name.release, NULL) + 96) * 10; - } - /*Check for new versioning scheme on Yosemite (10.10) and later.*/ - if (MAC_OS_X_VERSION_MIN_REQUIRED > 100000) { - tkMacOSXMacOSXVersion = MAC_OS_X_VERSION_MIN_REQUIRED/100; - } - if (tkMacOSXMacOSXVersion && MAC_OS_X_VERSION_MIN_REQUIRED < 100000 && - tkMacOSXMacOSXVersion/10 < MAC_OS_X_VERSION_MIN_REQUIRED/10) { - Tcl_Panic("Mac OS X 10.%d or later required !", - (MAC_OS_X_VERSION_MIN_REQUIRED/10)-100); - } - - #ifdef TK_FRAMEWORK /* * When Tk is in a framework, force tcl_findLibrary to look in the diff --git a/macosx/tkMacOSXInt.h b/macosx/tkMacOSXInt.h index 52be0e1..2972d46 100644 --- a/macosx/tkMacOSXInt.h +++ b/macosx/tkMacOSXInt.h @@ -199,6 +199,8 @@ MODULE_SCOPE void TkpClipDrawableToRect(Display *display, Drawable d, int x, MODULE_SCOPE void TkpRetainRegion(TkRegion r); MODULE_SCOPE void TkpReleaseRegion(TkRegion r); MODULE_SCOPE void TkpShiftButton(NSButton *button, NSPoint delta); +MODULE_SCOPE Bool TkpMacOSXAppIsDrawing(void); + /* * Include the stubbed internal platform-specific API. */ diff --git a/macosx/tkMacOSXPrivate.h b/macosx/tkMacOSXPrivate.h index 7337400..ea4c750 100644 --- a/macosx/tkMacOSXPrivate.h +++ b/macosx/tkMacOSXPrivate.h @@ -266,10 +266,12 @@ VISIBILITY_HIDDEN /* The Objective C runtime used on i386 requires this. */ int _poolLock; int _macMinorVersion; + Bool _isDrawing; #endif } @property int poolLock; @property int macMinorVersion; +@property Bool isDrawing; @end @interface TKApplication(TKInit) diff --git a/macosx/tkMacOSXWindowEvent.c b/macosx/tkMacOSXWindowEvent.c index 6e9948a..f659ad5 100644 --- a/macosx/tkMacOSXWindowEvent.c +++ b/macosx/tkMacOSXWindowEvent.c @@ -297,6 +297,31 @@ extern NSString *NSWindowDidOrderOffScreenNotification; /* *---------------------------------------------------------------------- * + * TkpMacOSXAppIsDrawing -- + * + * A widget display procedure can call this to determine whether it + * is being run inside of the drawRect method. This is needed for + * some tests, especially of the Text widget, which record data in + * a global Tcl variable and assume that display procedures will be + * run in a predictable sequence as Tcl idle tasks. + * + * Results: + * True only while running the drawRect method of a TKContentView; + * + * Side effects: + * None + * + *---------------------------------------------------------------------- + */ +MODULE_SCOPE Bool +TkpMacOSXAppIsDrawing(void) { + return [NSApp isDrawing]; +} + + +/* + *---------------------------------------------------------------------- + * * GenerateUpdates -- * * Given a Macintosh update region and a Tk window this function geneates @@ -801,6 +826,7 @@ ConfigureRestrictProc( const NSRect *rectsBeingDrawn; NSInteger rectsBeingDrawnCount; + [NSApp setIsDrawing: YES]; [self getRectsBeingDrawn:&rectsBeingDrawn count:&rectsBeingDrawnCount]; #ifdef TK_MAC_DEBUG_DRAWING @@ -820,6 +846,7 @@ ConfigureRestrictProc( } [self generateExposeEvents:(HIShapeRef)drawShape]; CFRelease(drawShape); + [NSApp setIsDrawing: NO]; } -(void) setFrameSize: (NSSize)newsize -- cgit v0.12 From 58c218ca973bfc0c773e821d360002d93ab85f02 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Wed, 24 Oct 2018 20:47:43 +0000 Subject: Some more internal use of TkSizeT (improvement of older code). No longer test for TCL_TYPE_I, since it's not in an accepted TIP yet. --- generic/tkInt.h | 14 +++----------- generic/tkMenu.h | 14 +++----------- generic/tkScale.h | 6 +----- generic/tkUtil.c | 4 +--- 4 files changed, 8 insertions(+), 30 deletions(-) diff --git a/generic/tkInt.h b/generic/tkInt.h index 7be0e73..767bbbb 100644 --- a/generic/tkInt.h +++ b/generic/tkInt.h @@ -500,7 +500,7 @@ typedef struct TkDisplay { #endif /* TK_USE_INPUT_METHODS */ Tcl_HashTable winTable; /* Maps from X window ids to TkWindow ptrs. */ - size_t refCount; /* Reference count of how many Tk applications + TkSizeT refCount; /* Reference count of how many Tk applications * are using this display. Used to clean up * the display when we no longer have any Tk * applications using it. */ @@ -604,7 +604,7 @@ typedef struct TkEventHandler { */ typedef struct TkMainInfo { - size_t refCount; /* Number of windows whose "mainPtr" fields + TkSizeT refCount; /* Number of windows whose "mainPtr" fields * point here. When this becomes zero, can * free up the structure (the reference count * is zero because windows can get deleted in @@ -855,7 +855,7 @@ typedef struct { * adding), or NULL if that has not been * computed yet. If non-NULL, this string was * allocated with ckalloc(). */ - size_t charValueLen; /* Length of string in charValuePtr when that + TkSizeT charValueLen; /* Length of string in charValuePtr when that * is non-NULL. */ KeySym keysym; /* Key symbol computed after input methods * have been invoked */ @@ -1279,20 +1279,12 @@ MODULE_SCOPE void TkUnixSetXftClipRegion(TkRegion clipRegion); MODULE_SCOPE size_t TkUniCharToUtf(int, char *); #endif -#ifdef TCL_TYPE_I -/* With TIP #481 available, we don't need to do anything special here */ -#define TkGetStringFromObj(objPtr, lenPtr) \ - Tcl_GetStringFromObj(objPtr, lenPtr) -#define TkGetByteArrayFromObj(objPtr, lenPtr) \ - Tcl_GetByteArrayFromObj(objPtr, lenPtr) -#else #define TkGetStringFromObj(objPtr, lenPtr) \ (((objPtr)->bytes ? 0 : Tcl_GetString(objPtr)), \ *(lenPtr) = (objPtr)->length, (objPtr)->bytes) MODULE_SCOPE unsigned char *TkGetByteArrayFromObj(Tcl_Obj *objPtr, size_t *lengthPtr); -#endif /* * Unsupported commands. diff --git a/generic/tkMenu.h b/generic/tkMenu.h index 6e3c3f4..1c02d4b 100644 --- a/generic/tkMenu.h +++ b/generic/tkMenu.h @@ -68,11 +68,7 @@ typedef struct TkMenuEntry { Tk_OptionTable optionTable; /* Option table for this menu entry. */ Tcl_Obj *labelPtr; /* Main text label displayed in entry (NULL if * no label). */ -#if TK_MAJOR_VERSION > 8 - size_t labelLength; /* Number of non-NULL characters in label. */ -#else - unsigned int labelLength; /* Number of non-NULL characters in label. */ -#endif + TkSizeT labelLength; /* Number of non-NULL characters in label. */ int state; /* State of button for display purposes: * normal, active, or disabled. */ int underline; /* Value of -underline option: specifies index @@ -93,11 +89,7 @@ typedef struct TkMenuEntry { Tcl_Obj *accelPtr; /* Accelerator string displayed at right of * menu entry. NULL means no such accelerator. * Malloc'ed. */ -#if TK_MAJOR_VERSION > 8 - size_t accelLength; /* Number of non-NULL characters in - * accelerator. */ -#else - unsigned int accelLength; /* Number of non-NULL characters in + TkSizeT accelLength; /* Number of non-NULL characters in * accelerator. */ #endif int indicatorOn; /* True means draw indicator, false means @@ -297,7 +289,6 @@ typedef struct TkMenu { Tcl_Obj *activeBorderWidthPtr; /* Width of border around active element. */ Tcl_Obj *reliefPtr; /* 3-d effect: TK_RELIEF_RAISED, etc. */ - Tcl_Obj *activeReliefPtr; /* 3-d effect for active element. */ Tcl_Obj *fontPtr; /* Text font for menu entries. */ Tcl_Obj *fgPtr; /* Foreground color for entries. */ Tcl_Obj *disabledFgPtr; /* Foreground color when disabled. NULL means @@ -392,6 +383,7 @@ typedef struct TkMenu { /* We actually have to allocate these because * multiple menus get changed during one * ConfigureMenu call. */ + Tcl_Obj *activeReliefPtr; /* 3-d effect for active element. */ } TkMenu; /* diff --git a/generic/tkScale.h b/generic/tkScale.h index 043d23c..d0be190 100644 --- a/generic/tkScale.h +++ b/generic/tkScale.h @@ -85,11 +85,7 @@ typedef struct TkScale { int repeatInterval; /* Interval between autorepeats (in ms). */ char *label; /* Label to display above or to right of * scale; NULL means don't display a label. */ -#if TK_MAJOR_VERSION > 8 - size_t labelLength; /* Number of non-NULL chars. in label. */ -#else - unsigned int labelLength; /* Number of non-NULL chars. in label. */ -#endif + TkSizeT labelLength; /* Number of non-NULL chars. in label. */ enum state state; /* Values are active, normal, or disabled. * Value of scale cannot be changed when * disabled. */ diff --git a/generic/tkUtil.c b/generic/tkUtil.c index 56d80bc..6850f47 100644 --- a/generic/tkUtil.c +++ b/generic/tkUtil.c @@ -1272,7 +1272,6 @@ size_t TkUniCharToUtf(int ch, char *buf) #endif -#ifndef TCL_TYPE_I unsigned char * TkGetByteArrayFromObj( Tcl_Obj *objPtr, @@ -1281,7 +1280,7 @@ TkGetByteArrayFromObj( int length; unsigned char *result = Tcl_GetByteArrayFromObj(objPtr, &length); -#if TK_MAJOR_VERSION > 8 +#if TCL_MAJOR_VERSION > 8 if (sizeof(TCL_HASH_TYPE) > sizeof(int)) { /* 64-bit and TIP #494 situation: */ *lengthPtr = *(TCL_HASH_TYPE *) objPtr->internalRep.twoPtrValue.ptr1; @@ -1291,7 +1290,6 @@ TkGetByteArrayFromObj( *lengthPtr = (size_t) (unsigned) length; return result; } -#endif /* !TCL_TYPE_I */ /* * Local Variables: -- cgit v0.12 From 9faca00371cc0231532c6b3fb8ee5a3acc4faeef Mon Sep 17 00:00:00 2001 From: culler Date: Wed, 24 Oct 2018 22:39:17 +0000 Subject: Try adding an extra display of the Text widget when it syncs, without making the tests get too much worse on Mojave. --- generic/tkTextDisp.c | 50 +++++++++++++++++++++++++------------------- macosx/tkMacOSXInt.h | 3 ++- macosx/tkMacOSXWindowEvent.c | 4 ++-- macosx/tkMacOSXWm.c | 27 ++++++++++++++++++++++++ 4 files changed, 60 insertions(+), 24 deletions(-) diff --git a/generic/tkTextDisp.c b/generic/tkTextDisp.c index 35a43d4..7d38ce4 100644 --- a/generic/tkTextDisp.c +++ b/generic/tkTextDisp.c @@ -24,6 +24,11 @@ #ifdef MAC_OSX_TK #include "tkMacOSXInt.h" +#define OK_TO_LOG (!TkpAppIsDrawing()) +#define FORCE_DISPLAY(winPtr) TkpDisplayWindow(winPtr) +#else +#define OK_TO_LOG 1 +#define FORCE_DISPLAY(winPtr) do {} while 0 #endif /* @@ -203,31 +208,22 @@ typedef struct TextStyle { (fabs((double1)-(double2))*((scaleFactor)+1.0) < 0.3) /* - * Macro to make debugging/testing logging a little easier. + * Macros to make debugging/testing logging a little easier. + * + * On OSX 10.14 Drawing procedures are sometimes run because the system has + * decided to redraw the window. This can corrupt the data that a test is + * trying to collect. So we don't write to the logging variables when the + * drawing procedure is being run that way. Other systems can always log. */ -#ifndef MAC_OSX_TK -#define LOG(toVar,what) \ - Tcl_SetVar2(textPtr->interp, toVar, NULL, (what), \ - TCL_GLOBAL_ONLY|TCL_APPEND_VALUE|TCL_LIST_ELEMENT) - -#define CLEAR(var) \ - Tcl_SetVar2(interp, var, NULL, "", TCL_GLOBAL_ONLY) -#else -/* - * Drawing procedures are sometimes run because the system has decided - * to redraw the window. This can corrupt the data that a test is - * trying to collect. So we don't write to the logging variables when - * the drawing procedure is being run that way. - */ -#define LOG(toVar,what) \ - if (!TkpMacOSXAppIsDrawing()) \ +#define LOG(toVar,what) \ + if (OK_TO_LOG) \ Tcl_SetVar2(textPtr->interp, toVar, NULL, (what), \ TCL_GLOBAL_ONLY|TCL_APPEND_VALUE|TCL_LIST_ELEMENT) -#define CLEAR(var) \ - if (!TkpMacOSXAppIsDrawing()) \ - Tcl_SetVar2(interp, var, NULL, "", TCL_GLOBAL_ONLY) -#endif +#define CLEAR(var) \ + if (OK_TO_LOG) \ + Tcl_SetVar2(interp, var, NULL, "", TCL_GLOBAL_ONLY) + /* * The following structure describes one line of the display, which may be * either part or all of one line of the text. @@ -3139,6 +3135,18 @@ GenerateWidgetViewSyncEvent( TkText *textPtr, /* Information about text widget. */ Bool InSync) /* true if in sync, false otherwise */ { + /* + * OSX 10.14 needs to be told to display the window when the Text Widget + * is in sync. (That is, to run DisplayText inside of the drawRect + * method.) Otherwise the screen might not get updated until an event + * like a mouse click is received. But that extra drawing corrupts the + * data that the test suite is trying to collect. + */ + + if (!tkTextDebug) { + FORCE_DISPLAY(textPtr->tkwin); + } + TkSendVirtualEvent(textPtr->tkwin, "WidgetViewSync", Tcl_NewBooleanObj(InSync)); } diff --git a/macosx/tkMacOSXInt.h b/macosx/tkMacOSXInt.h index 2972d46..f4859ff 100644 --- a/macosx/tkMacOSXInt.h +++ b/macosx/tkMacOSXInt.h @@ -199,7 +199,8 @@ MODULE_SCOPE void TkpClipDrawableToRect(Display *display, Drawable d, int x, MODULE_SCOPE void TkpRetainRegion(TkRegion r); MODULE_SCOPE void TkpReleaseRegion(TkRegion r); MODULE_SCOPE void TkpShiftButton(NSButton *button, NSPoint delta); -MODULE_SCOPE Bool TkpMacOSXAppIsDrawing(void); +MODULE_SCOPE Bool TkpAppIsDrawing(void); +MODULE_SCOPE void TkpDisplayWindow(Tk_Window tkwin); /* * Include the stubbed internal platform-specific API. diff --git a/macosx/tkMacOSXWindowEvent.c b/macosx/tkMacOSXWindowEvent.c index f659ad5..5495c9a 100644 --- a/macosx/tkMacOSXWindowEvent.c +++ b/macosx/tkMacOSXWindowEvent.c @@ -297,7 +297,7 @@ extern NSString *NSWindowDidOrderOffScreenNotification; /* *---------------------------------------------------------------------- * - * TkpMacOSXAppIsDrawing -- + * TkpAppIsDrawing -- * * A widget display procedure can call this to determine whether it * is being run inside of the drawRect method. This is needed for @@ -314,7 +314,7 @@ extern NSString *NSWindowDidOrderOffScreenNotification; *---------------------------------------------------------------------- */ MODULE_SCOPE Bool -TkpMacOSXAppIsDrawing(void) { +TkpAppIsDrawing(void) { return [NSApp isDrawing]; } diff --git a/macosx/tkMacOSXWm.c b/macosx/tkMacOSXWm.c index 8bbaae0..b49ab63 100644 --- a/macosx/tkMacOSXWm.c +++ b/macosx/tkMacOSXWm.c @@ -5679,6 +5679,33 @@ TkMacOSXMakeRealWindowExist( /* *---------------------------------------------------------------------- * + * TkpDisplayWindow -- + * + * Mark the contentView of this window as needing display so the + * window will be drawn by the window manager. If this is called + * within the drawRect method, do nothing. + * + * Results: + * None. + * + * Side effects: + * The window's contentView is marked as needing display. + * + *---------------------------------------------------------------------- + */ + +MODULE_SCOPE void +TkpDisplayWindow(Tk_Window tkwin) { + if (![NSApp isDrawing]) { + TkWindow *winPtr = (TkWindow*)tkwin; + NSWindow *w = TkMacOSXDrawableWindow(winPtr->window); + [[w contentView] setNeedsDisplay: YES]; + } +} + +/* + *---------------------------------------------------------------------- + * * TkMacOSXRegisterOffScreenWindow -- * * This function adds the passed in Off Screen Port to the hash table -- cgit v0.12 From efdf0a84ec80a815cec2b49e467afbdbf0ff39ac Mon Sep 17 00:00:00 2001 From: culler Date: Fri, 26 Oct 2018 03:11:35 +0000 Subject: Added some debugging tools. --- macosx/tkMacOSXNotify.c | 82 ++++++++++++++++++++++++++++++++++++++++++++ macosx/tkMacOSXWindowEvent.c | 26 +++++++++----- 2 files changed, 99 insertions(+), 9 deletions(-) diff --git a/macosx/tkMacOSXNotify.c b/macosx/tkMacOSXNotify.c index 02f449a..c14bea7 100644 --- a/macosx/tkMacOSXNotify.c +++ b/macosx/tkMacOSXNotify.c @@ -32,6 +32,84 @@ static void TkMacOSXNotifyExitHandler(ClientData clientData); static void TkMacOSXEventsSetupProc(ClientData clientData, int flags); static void TkMacOSXEventsCheckProc(ClientData clientData, int flags); +#ifdef TK_MAC_DEBUG_EVENTS +static char* Tk_EventName[39] = { + "", + "", + "KeyPress", /*2*/ + "KeyRelease", /*3*/ + "ButtonPress", /*4*/ + "ButtonRelease", /*5*/ + "MotionNotify", /*6*/ + "EnterNotify", /*7*/ + "LeaveNotify", /*8*/ + "FocusIn", /*9*/ + "FocusOut", /*10*/ + "KeymapNotify", /*11*/ + "Expose", /*12*/ + "GraphicsExpose", /*13*/ + "NoExpose", /*14*/ + "VisibilityNotify", /*15*/ + "CreateNotify", /*16*/ + "DestroyNotify", /*17*/ + "UnmapNotify", /*18*/ + "MapNotify", /*19*/ + "MapRequest", /*20*/ + "ReparentNotify", /*21*/ + "ConfigureNotify", /*22*/ + "ConfigureRequest", /*23*/ + "GravityNotify", /*24*/ + "ResizeRequest", /*25*/ + "CirculateNotify", /*26*/ + "CirculateRequest", /*27*/ + "PropertyNotify", /*28*/ + "SelectionClear", /*29*/ + "SelectionRequest", /*30*/ + "SelectionNotify", /*31*/ + "ColormapNotify", /*32*/ + "ClientMessage", /*33*/ + "MappingNotify", /*34*/ + "VirtualEvent", /*35*/ + "ActivateNotify", /*36*/ + "DeactivateNotify", /*37*/ + "MouseWheelEvent" /*38*/ +}; + +static Tk_RestrictAction +InspectQueueRestrictProc( + ClientData arg, + XEvent *eventPtr) +{ + XVirtualEvent* ve = (XVirtualEvent*) eventPtr; + const char *name; + long serial = ve->serial; + long time = eventPtr->xkey.time; + + if (eventPtr->type == VirtualEvent) { + name = ve->name; + } else { + name = Tk_EventName[eventPtr->type]; + } + printf(" > %s;serial = %lu; time=%lu)\n", name, serial, time); + return TK_DEFER_EVENT; +} + +/* + * Debugging tool which prints the current Tcl queue. + */ + +void DebugPrintQueue(void) +{ + ClientData oldArg; + Tk_RestrictProc *oldProc; + + oldProc = Tk_RestrictEvents(InspectQueueRestrictProc, NULL, &oldArg); + printf("Current queue:\n"); + while (Tcl_DoOneEvent(TCL_ALL_EVENTS|TCL_DONT_WAIT)) {}; + Tk_RestrictEvents(oldProc, oldArg, &oldArg); +} +# endif + #pragma mark TKApplication(TKNotify) @interface NSApplication(TKNotify) @@ -67,6 +145,10 @@ static void TkMacOSXEventsCheckProc(ClientData clientData, int flags); { [super sendEvent:theEvent]; [NSApp tkCheckPasteboard]; +#ifdef TK_MAC_DEBUG_EVENTS + printf("Sending event of type %d\n", (int)[theEvent type]); + DebugPrintQueue(); +#endif } @end diff --git a/macosx/tkMacOSXWindowEvent.c b/macosx/tkMacOSXWindowEvent.c index 5495c9a..2bce9d3 100644 --- a/macosx/tkMacOSXWindowEvent.c +++ b/macosx/tkMacOSXWindowEvent.c @@ -826,27 +826,35 @@ ConfigureRestrictProc( const NSRect *rectsBeingDrawn; NSInteger rectsBeingDrawnCount; - [NSApp setIsDrawing: YES]; - [self getRectsBeingDrawn:&rectsBeingDrawn count:&rectsBeingDrawnCount]; - #ifdef TK_MAC_DEBUG_DRAWING - TKLog(@"-[%@(%p) %s%@]", [self class], self, _cmd, NSStringFromRect(rect)); - [[NSColor colorWithDeviceRed:0.0 green:1.0 blue:0.0 alpha:.1] setFill]; - NSRectFillListUsingOperation(rectsBeingDrawn, rectsBeingDrawnCount, - NSCompositeSourceOver); + TkWindow *winPtr = TkMacOSXGetTkWindow([self window]); + if (winPtr) printf("drawRect: drawing %s\n", Tk_PathName(winPtr)); #endif - + + [NSApp setIsDrawing: YES]; + [self getRectsBeingDrawn:&rectsBeingDrawn count:&rectsBeingDrawnCount]; CGFloat height = [self bounds].size.height; HIMutableShapeRef drawShape = HIShapeCreateMutable(); while (rectsBeingDrawnCount--) { CGRect r = NSRectToCGRect(*rectsBeingDrawn++); + +#ifdef TK_MAC_DEBUG_DRAWING + printf("drawRect: %dx%d@(%d,%d)\n", (int)r.size.width, + (int)r.size.height, (int)r.origin.x, (int)r.origin.y); +#endif + r.origin.y = height - (r.origin.y + r.size.height); HIShapeUnionWithRect(drawShape, &r); } [self generateExposeEvents:(HIShapeRef)drawShape]; CFRelease(drawShape); [NSApp setIsDrawing: NO]; + +#ifdef TK_MAC_DEBUG_DRAWING + printf("drawRect: done.\n"); +#endif + } -(void) setFrameSize: (NSSize)newsize @@ -920,7 +928,7 @@ ConfigureRestrictProc( ClientData oldArg; Tk_RestrictProc *oldProc; if (!winPtr) { - return; + return; } /* -- cgit v0.12 From 3167c7828c98f69b87a68bddae355b21045ed002 Mon Sep 17 00:00:00 2001 From: dgp Date: Fri, 26 Oct 2018 12:08:23 +0000 Subject: Stray "#endif" broke the build. --- generic/tkMenu.h | 1 - 1 file changed, 1 deletion(-) diff --git a/generic/tkMenu.h b/generic/tkMenu.h index 1c02d4b..6d51a72 100644 --- a/generic/tkMenu.h +++ b/generic/tkMenu.h @@ -91,7 +91,6 @@ typedef struct TkMenuEntry { * Malloc'ed. */ TkSizeT accelLength; /* Number of non-NULL characters in * accelerator. */ -#endif int indicatorOn; /* True means draw indicator, false means * don't draw it. This field is ignored unless * the entry is a radio or check button. */ -- cgit v0.12 From abef80665370e7a36e3e2c8ba6d2b2cf713cbfeb Mon Sep 17 00:00:00 2001 From: culler Date: Fri, 26 Oct 2018 15:04:30 +0000 Subject: Increase the size of the event ring to 45 on macOS, because the new code demands a bigger ring. --- generic/tkBind.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/generic/tkBind.c b/generic/tkBind.c index bfedfe0..af5306b 100644 --- a/generic/tkBind.c +++ b/generic/tkBind.c @@ -75,7 +75,20 @@ typedef union { * EVENT_BUFFER_SIZE too much, shift multi-clicks will be lost. */ -#define EVENT_BUFFER_SIZE 30 +/* + * NOTE: The changes which were needed to make Tk work on OSX 10.14 (Mojave) + * also demand that the event ring be a bit bigger. It might be wise to + * augment the current double-click pattern matching by adding a new + * DoubleClick modifier bit which could be set based on the clickCount of the + * Apple NSEvent object. + */ + +#ifndef TK_MAC_OSX + #define EVENT_BUFFER_SIZE 45 +#else + #define EVENT_BUFFER_SIZE 30 +#endif + typedef struct Tk_BindingTable_ { XEvent eventRing[EVENT_BUFFER_SIZE]; /* Circular queue of recent events (higher -- cgit v0.12 From 3b82ef16195984643614309400a486ed32c786e3 Mon Sep 17 00:00:00 2001 From: culler Date: Fri, 26 Oct 2018 18:15:45 +0000 Subject: Addressed a few deprecations in the Fullscreen implementation. --- macosx/tkMacOSXWm.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/macosx/tkMacOSXWm.c b/macosx/tkMacOSXWm.c index b49ab63..72f8121 100644 --- a/macosx/tkMacOSXWm.c +++ b/macosx/tkMacOSXWm.c @@ -806,7 +806,6 @@ TkWmMapWindow( /*Add window to Window menu.*/ NSWindow *win = TkMacOSXDrawableWindow(winPtr->window); [win setExcludedFromWindowsMenu:NO]; - } /* @@ -6570,11 +6569,11 @@ TkMacOSXMakeFullscreen( exitFullScreen = [[[NSStatusBar systemStatusBar] statusItemWithLength:NSVariableStatusItemLength] retain]; NSImage *exitIcon = [NSImage imageNamed:@"NSExitFullScreenTemplate"]; - [exitFullScreen setImage:exitIcon]; - [exitFullScreen setHighlightMode:YES]; - [exitFullScreen setToolTip:@"Exit Full Screen"]; - [exitFullScreen setTarget:window]; - [exitFullScreen setAction:@selector(restoreOldScreen:)]; + exitFullScreen.button.image = exitIcon; + exitFullScreen.button.cell.highlighted = YES; + exitFullScreen.button.toolTip = @"Exit Full Screen"; + exitFullScreen.button.target = window; + exitFullScreen.button.action = @selector(restoreOldScreen:); #endif Tk_MapWindow((Tk_Window) winPtr); -- cgit v0.12 From 559f71f606ce08b18304d270ca2aa2f10abb64cf Mon Sep 17 00:00:00 2001 From: culler Date: Sat, 27 Oct 2018 18:47:34 +0000 Subject: Make TKWindow setFrame *always* generate expose events, and adjust the Fullscreen implementation to account for this. --- macosx/tkMacOSXWindowEvent.c | 8 ++-- macosx/tkMacOSXWm.c | 101 +++++++++++++++++++++++-------------------- 2 files changed, 58 insertions(+), 51 deletions(-) diff --git a/macosx/tkMacOSXWindowEvent.c b/macosx/tkMacOSXWindowEvent.c index 2bce9d3..a9ab855 100644 --- a/macosx/tkMacOSXWindowEvent.c +++ b/macosx/tkMacOSXWindowEvent.c @@ -860,10 +860,10 @@ ConfigureRestrictProc( -(void) setFrameSize: (NSSize)newsize { [super setFrameSize: newsize]; - if ([self inLiveResize]) { - NSWindow *w = [self window]; - TkWindow *winPtr = TkMacOSXGetTkWindow(w); - Tk_Window tkwin = (Tk_Window) winPtr; + NSWindow *w = [self window]; + TkWindow *winPtr = TkMacOSXGetTkWindow(w); + Tk_Window tkwin = (Tk_Window) winPtr; + if (winPtr) { unsigned int width = (unsigned int)newsize.width; unsigned int height=(unsigned int)newsize.height; ClientData oldArg; diff --git a/macosx/tkMacOSXWm.c b/macosx/tkMacOSXWm.c index 72f8121..c67911b 100644 --- a/macosx/tkMacOSXWm.c +++ b/macosx/tkMacOSXWm.c @@ -6516,13 +6516,18 @@ TkMacOSXMakeFullscreen( Tcl_Interp *interp) { WmInfo *wmPtr = winPtr->wmInfoPtr; - int result = TCL_OK, wasFullscreen = (wmPtr->flags & WM_FULLSCREEN); - static unsigned long prevMask = 0, prevPres = 0; + int screenWidth = WidthOfScreen(Tk_Screen(winPtr)); + int screenHeight = HeightOfScreen(Tk_Screen(winPtr)); + /* + * When switching to Fullscreen we can save the current state in static + * variables because only one window can be Fullscreen at a time. + */ + + static unsigned long prevMask = 0, prevPres = 0; + static NSRect bounds; if (fullscreen) { - int screenWidth = WidthOfScreen(Tk_Screen(winPtr)); - int screenHeight = HeightOfScreen(Tk_Screen(winPtr)); /* * Check max width and height if set by the user. @@ -6537,70 +6542,72 @@ TkMacOSXMakeFullscreen( Tcl_SetErrorCode(interp, "TK", "FULLSCREEN", "CONSTRAINT_FAILURE", NULL); } - result = TCL_ERROR; wmPtr->flags &= ~WM_FULLSCREEN; - } else { - Tk_UnmapWindow((Tk_Window) winPtr); - NSRect bounds = [window contentRectForFrameRect:[window frame]]; - NSRect screenBounds = NSMakeRect(0, 0, screenWidth, screenHeight); - - if (!NSEqualRects(bounds, screenBounds) && !wasFullscreen) { - wmPtr->configX = wmPtr->x; - wmPtr->configY = wmPtr->y; - wmPtr->configAttributes = wmPtr->attributes; - wmPtr->attributes &= ~kWindowResizableAttribute; - ApplyWindowAttributeFlagChanges(winPtr, window, - wmPtr->configAttributes, wmPtr->flags, 1, 0); - wmPtr->flags |= WM_SYNC_PENDING; - [window setFrame:[window frameRectForContentRect: - screenBounds] display:YES]; - wmPtr->flags &= ~WM_SYNC_PENDING; - } - wmPtr->flags |= WM_FULLSCREEN; + return TCL_ERROR; } + /* + * Save the current window state. + */ + + bounds = [window frame]; prevMask = [window styleMask]; prevPres = [NSApp presentationOptions]; + + /* + * Adjust the window style so it looks like a Fullscreen window. + */ + [window setStyleMask: NSFullScreenWindowMask]; - [NSApp setPresentationOptions: NSApplicationPresentationAutoHideDock | NSApplicationPresentationAutoHideMenuBar]; + [NSApp setPresentationOptions: (NSApplicationPresentationAutoHideDock | + NSApplicationPresentationAutoHideMenuBar)]; - /*Fullscreen implementation for 10.13 and later.*/ - #if MAC_OS_X_VERSION_MIN_REQUIRED > MAC_OS_X_VERSION_10_12 - exitFullScreen = [[[NSStatusBar systemStatusBar] + /*For 10.13 and later add a button for exiting Fullscreen.*/ + if ([NSApp macMinorVersion] > 12) { + exitFullScreen = [[[NSStatusBar systemStatusBar] statusItemWithLength:NSVariableStatusItemLength] retain]; - NSImage *exitIcon = [NSImage imageNamed:@"NSExitFullScreenTemplate"]; - exitFullScreen.button.image = exitIcon; - exitFullScreen.button.cell.highlighted = YES; - exitFullScreen.button.toolTip = @"Exit Full Screen"; - exitFullScreen.button.target = window; - exitFullScreen.button.action = @selector(restoreOldScreen:); - #endif + NSImage *exitIcon = [NSImage imageNamed:@"NSExitFullScreenTemplate"]; + exitFullScreen.button.image = exitIcon; + exitFullScreen.button.cell.highlighted = YES; + exitFullScreen.button.toolTip = @"Exit Full Screen"; + exitFullScreen.button.target = window; + exitFullScreen.button.action = @selector(restoreOldScreen:); + } - Tk_MapWindow((Tk_Window) winPtr); + /* + * Resize the window to fill the screen. (After setting the style!) + */ + + NSRect screenBounds = NSMakeRect(0, 0, screenWidth, screenHeight); + wmPtr->flags |= WM_SYNC_PENDING; + [window setFrame:[window frameRectForContentRect: screenBounds] + display:YES]; + wmPtr->flags &= ~WM_SYNC_PENDING; + wmPtr->flags |= WM_FULLSCREEN; } else { - wmPtr->flags &= ~WM_FULLSCREEN; + + /* + * Restore the previous styles and attributes. + */ + [NSApp setPresentationOptions: prevPres]; [window setStyleMask: prevMask]; - } - - if (wasFullscreen && !(wmPtr->flags & WM_FULLSCREEN)) { - Tk_UnmapWindow((Tk_Window) winPtr); UInt64 oldAttributes = wmPtr->attributes; - NSRect bounds = NSMakeRect(wmPtr->configX, tkMacOSXZeroScreenHeight - - (wmPtr->configY + wmPtr->yInParent + wmPtr->configHeight), - wmPtr->xInParent + wmPtr->configWidth, - wmPtr->yInParent + wmPtr->configHeight); - + wmPtr->flags &= ~WM_FULLSCREEN; wmPtr->attributes |= wmPtr->configAttributes & kWindowResizableAttribute; ApplyWindowAttributeFlagChanges(winPtr, window, oldAttributes, wmPtr->flags, 1, 0); + + /* + * Resize the window to its previous size. + */ + wmPtr->flags |= WM_SYNC_PENDING; [window setFrame:[window frameRectForContentRect:bounds] display:YES]; wmPtr->flags &= ~WM_SYNC_PENDING; - Tk_MapWindow((Tk_Window) winPtr); } - return result; + return TCL_OK; } /* -- cgit v0.12 From e58fbbb28c130d72b51502c53712b6bfc593513c Mon Sep 17 00:00:00 2001 From: culler Date: Sat, 27 Oct 2018 23:27:28 +0000 Subject: Cache window state in the WmInfo when going Fullscreen. If the user has two monitors, using static variables could cause trouble. --- macosx/tkMacOSXWm.c | 45 ++++++++++++++++++++------------------------- macosx/tkMacOSXWm.h | 9 +++++++++ 2 files changed, 29 insertions(+), 25 deletions(-) diff --git a/macosx/tkMacOSXWm.c b/macosx/tkMacOSXWm.c index c67911b..81b5472 100644 --- a/macosx/tkMacOSXWm.c +++ b/macosx/tkMacOSXWm.c @@ -387,11 +387,12 @@ static void RemapWindows(TkWindow *winPtr, @implementation TKWindow: NSWindow -#if MAC_OS_X_VERSION_MIN_REQUIRED > MAC_OS_X_VERSION_10_12 + /* - * Override automatic fullscreen button on >10.12 because system fullscreen API - * confuses Tk window geometry. Custom implementation setting fullscreen status using - * Tk API and NSStatusItem in menubar to exit fullscreen status. + * Override toggleFullscreen on >10.12 because, for some unknown reason, the + * window titlebar does not get drawn in the menubar when the menubar drops down. + * This custom implementation adds a button in the menubar which can be used + * to exit fullscreen status. */ NSStatusItem *exitFullScreen; @@ -401,10 +402,14 @@ NSStatusItem *exitFullScreen; TkWindow *winPtr = TkMacOSXGetTkWindow(self); Tcl_Interp *interp = Tk_Interp((Tk_Window)winPtr); - if (([self styleMask] & NSFullScreenWindowMask) == NSFullScreenWindowMask) { - TkMacOSXMakeFullscreen(winPtr, self, 0, interp); + if ([NSApp macMinorVersion] > 12) { + if (([self styleMask] & NSFullScreenWindowMask) == NSFullScreenWindowMask) { + TkMacOSXMakeFullscreen(winPtr, self, 0, interp); + } else { + TkMacOSXMakeFullscreen(winPtr, self, 1, interp); + } } else { - TkMacOSXMakeFullscreen(winPtr, self, 1, interp); + [super toggleFullScreen: sender]; } } @@ -417,7 +422,6 @@ NSStatusItem *exitFullScreen; [[NSStatusBar systemStatusBar] removeStatusItem: exitFullScreen]; } -#endif @end @implementation TKWindow(TKWm) @@ -6519,14 +6523,6 @@ TkMacOSXMakeFullscreen( int screenWidth = WidthOfScreen(Tk_Screen(winPtr)); int screenHeight = HeightOfScreen(Tk_Screen(winPtr)); - /* - * When switching to Fullscreen we can save the current state in static - * variables because only one window can be Fullscreen at a time. - */ - - static unsigned long prevMask = 0, prevPres = 0; - static NSRect bounds; - if (fullscreen) { /* @@ -6550,9 +6546,9 @@ TkMacOSXMakeFullscreen( * Save the current window state. */ - bounds = [window frame]; - prevMask = [window styleMask]; - prevPres = [NSApp presentationOptions]; + wmPtr->cachedBounds = [window frame]; + wmPtr->cachedStyle = [window styleMask]; + wmPtr->cachedPresentation = [NSApp presentationOptions]; /* * Adjust the window style so it looks like a Fullscreen window. @@ -6578,10 +6574,9 @@ TkMacOSXMakeFullscreen( * Resize the window to fill the screen. (After setting the style!) */ - NSRect screenBounds = NSMakeRect(0, 0, screenWidth, screenHeight); wmPtr->flags |= WM_SYNC_PENDING; - [window setFrame:[window frameRectForContentRect: screenBounds] - display:YES]; + NSRect screenBounds = NSMakeRect(0, 0, screenWidth, screenHeight); + [window setFrame:screenBounds display:YES]; wmPtr->flags &= ~WM_SYNC_PENDING; wmPtr->flags |= WM_FULLSCREEN; } else { @@ -6590,8 +6585,8 @@ TkMacOSXMakeFullscreen( * Restore the previous styles and attributes. */ - [NSApp setPresentationOptions: prevPres]; - [window setStyleMask: prevMask]; + [NSApp setPresentationOptions: wmPtr->cachedPresentation]; + [window setStyleMask: wmPtr->cachedStyle]; UInt64 oldAttributes = wmPtr->attributes; wmPtr->flags &= ~WM_FULLSCREEN; wmPtr->attributes |= wmPtr->configAttributes & @@ -6604,7 +6599,7 @@ TkMacOSXMakeFullscreen( */ wmPtr->flags |= WM_SYNC_PENDING; - [window setFrame:[window frameRectForContentRect:bounds] display:YES]; + [window setFrame:wmPtr->cachedBounds display:YES]; wmPtr->flags &= ~WM_SYNC_PENDING; } return TCL_OK; diff --git a/macosx/tkMacOSXWm.h b/macosx/tkMacOSXWm.h index e904f50..43f1a7a 100644 --- a/macosx/tkMacOSXWm.h +++ b/macosx/tkMacOSXWm.h @@ -185,6 +185,15 @@ typedef struct TkWmInfo { TkWindow *scrollWinPtr; /* Ptr to scrollbar handling grow widget. */ TkMenu *menuPtr; NSWindow *window; + + /* + * Space to cache current window state when window becomes Fullscreen. + */ + + unsigned long cachedStyle; + unsigned long cachedPresentation; + NSRect cachedBounds; + } WmInfo; /* -- cgit v0.12 From 367d75b1475932225bace4b4442caeef2ebf4d34 Mon Sep 17 00:00:00 2001 From: Kevin Walzer Date: Sun, 28 Oct 2018 02:22:17 +0000 Subject: Restrict fullscreen implementation to 10.13 and above; rewrite comments on fullscreen implementation to clarify its purpose --- macosx/tkMacOSXWm.c | 39 +++++++++++++++++---------------------- 1 file changed, 17 insertions(+), 22 deletions(-) diff --git a/macosx/tkMacOSXWm.c b/macosx/tkMacOSXWm.c index 81b5472..a7ea87e 100644 --- a/macosx/tkMacOSXWm.c +++ b/macosx/tkMacOSXWm.c @@ -388,39 +388,34 @@ static void RemapWindows(TkWindow *winPtr, @implementation TKWindow: NSWindow -/* - * Override toggleFullscreen on >10.12 because, for some unknown reason, the - * window titlebar does not get drawn in the menubar when the menubar drops down. - * This custom implementation adds a button in the menubar which can be used - * to exit fullscreen status. - */ +/* Custom fullscreen implementation on 10.13 and above. On older versions of macOS dating back to 10.7, the NSWindow fullscreen API was opt-in, requiring explicit calls to toggleFullScreen. On 10.13, the API became implicit, applying to all NSWindows unless they were marked non-resizable; this caused issues with Tk, which was not aware of changes in screen geometry. Here we override the toggleFullScreen call to hook directly into Tk's own fullscreen API, allowing Tk to function smoothly with the Mac's fullscreen button.*/ NSStatusItem *exitFullScreen; +#if MAC_OS_X_VERSION_MIN_REQUIRED > MAC_OS_X_VERSION_10_12 + - (void)toggleFullScreen:(id)sender { - TkWindow *winPtr = TkMacOSXGetTkWindow(self); - Tcl_Interp *interp = Tk_Interp((Tk_Window)winPtr); + TkWindow *winPtr = TkMacOSXGetTkWindow(self); + Tcl_Interp *interp = Tk_Interp((Tk_Window)winPtr); - if ([NSApp macMinorVersion] > 12) { - if (([self styleMask] & NSFullScreenWindowMask) == NSFullScreenWindowMask) { - TkMacOSXMakeFullscreen(winPtr, self, 0, interp); - } else { - TkMacOSXMakeFullscreen(winPtr, self, 1, interp); - } - } else { - [super toggleFullScreen: sender]; - } + if (([self styleMask] & NSFullScreenWindowMask) == NSFullScreenWindowMask) { + TkMacOSXMakeFullscreen(winPtr, self, 0, interp); + } else { + TkMacOSXMakeFullscreen(winPtr, self, 1, interp); + } } + -(void)restoreOldScreen:(id)sender { - TkWindow *winPtr = TkMacOSXGetTkWindow(self); - Tcl_Interp *interp = Tk_Interp((Tk_Window)winPtr); + TkWindow *winPtr = TkMacOSXGetTkWindow(self); + Tcl_Interp *interp = Tk_Interp((Tk_Window)winPtr); - TkMacOSXMakeFullscreen(winPtr, self, 0, interp); - [[NSStatusBar systemStatusBar] removeStatusItem: exitFullScreen]; + TkMacOSXMakeFullscreen(winPtr, self, 0, interp); + [[NSStatusBar systemStatusBar] removeStatusItem: exitFullScreen]; } +#endif @end @@ -6564,7 +6559,7 @@ TkMacOSXMakeFullscreen( statusItemWithLength:NSVariableStatusItemLength] retain]; NSImage *exitIcon = [NSImage imageNamed:@"NSExitFullScreenTemplate"]; exitFullScreen.button.image = exitIcon; - exitFullScreen.button.cell.highlighted = YES; + exitFullScreen.button.cell.highlighted = NO; exitFullScreen.button.toolTip = @"Exit Full Screen"; exitFullScreen.button.target = window; exitFullScreen.button.action = @selector(restoreOldScreen:); -- cgit v0.12 From ff1fee8de0ec727f046043442e8abb7159988ee7 Mon Sep 17 00:00:00 2001 From: culler Date: Sun, 28 Oct 2018 15:20:45 +0000 Subject: Format a comment and make sure that toggleFullScreen is a no-op on OSX < 10.13. --- macosx/tkMacOSXWm.c | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/macosx/tkMacOSXWm.c b/macosx/tkMacOSXWm.c index a7ea87e..0484088 100644 --- a/macosx/tkMacOSXWm.c +++ b/macosx/tkMacOSXWm.c @@ -388,24 +388,31 @@ static void RemapWindows(TkWindow *winPtr, @implementation TKWindow: NSWindow -/* Custom fullscreen implementation on 10.13 and above. On older versions of macOS dating back to 10.7, the NSWindow fullscreen API was opt-in, requiring explicit calls to toggleFullScreen. On 10.13, the API became implicit, applying to all NSWindows unless they were marked non-resizable; this caused issues with Tk, which was not aware of changes in screen geometry. Here we override the toggleFullScreen call to hook directly into Tk's own fullscreen API, allowing Tk to function smoothly with the Mac's fullscreen button.*/ +/* Custom fullscreen implementation on 10.13 and above. On older versions of + * macOS dating back to 10.7, the NSWindow fullscreen API was opt-in, requiring + * explicit calls to toggleFullScreen. On 10.13, the API became implicit, + * applying to all NSWindows unless they were marked non-resizable; this caused + * issues with Tk, which was not aware of changes in screen geometry. Here we + * override the toggleFullScreen call to hook directly into Tk's own fullscreen + * API, allowing Tk to function smoothly with the Mac's fullscreen button. +*/ NSStatusItem *exitFullScreen; -#if MAC_OS_X_VERSION_MIN_REQUIRED > MAC_OS_X_VERSION_10_12 - (void)toggleFullScreen:(id)sender { TkWindow *winPtr = TkMacOSXGetTkWindow(self); Tcl_Interp *interp = Tk_Interp((Tk_Window)winPtr); - - if (([self styleMask] & NSFullScreenWindowMask) == NSFullScreenWindowMask) { - TkMacOSXMakeFullscreen(winPtr, self, 0, interp); + if ([NSApp macMinorVersion] > 12) { + if (([self styleMask] & NSFullScreenWindowMask) == NSFullScreenWindowMask) { + TkMacOSXMakeFullscreen(winPtr, self, 0, interp); + } else { + TkMacOSXMakeFullscreen(winPtr, self, 1, interp); + } } else { - TkMacOSXMakeFullscreen(winPtr, self, 1, interp); + NSLog (@"toggleFullScreen is ignored by Tk on OSX versions < 10.13"); } -} - -(void)restoreOldScreen:(id)sender { @@ -415,7 +422,6 @@ NSStatusItem *exitFullScreen; TkMacOSXMakeFullscreen(winPtr, self, 0, interp); [[NSStatusBar systemStatusBar] removeStatusItem: exitFullScreen]; } -#endif @end -- cgit v0.12 From 89ea118d416b1ad6817c40d8b10c24dc23e2ddab Mon Sep 17 00:00:00 2001 From: culler Date: Sun, 28 Oct 2018 15:26:01 +0000 Subject: Add closing brace that got accidentally deleted. --- macosx/tkMacOSXWm.c | 1 + 1 file changed, 1 insertion(+) diff --git a/macosx/tkMacOSXWm.c b/macosx/tkMacOSXWm.c index 0484088..3cc647d 100644 --- a/macosx/tkMacOSXWm.c +++ b/macosx/tkMacOSXWm.c @@ -413,6 +413,7 @@ NSStatusItem *exitFullScreen; } else { NSLog (@"toggleFullScreen is ignored by Tk on OSX versions < 10.13"); } +} -(void)restoreOldScreen:(id)sender { -- cgit v0.12 From e82838ee004c231585924ddcb2598cb0dfe2d79a Mon Sep 17 00:00:00 2001 From: culler Date: Sun, 28 Oct 2018 17:24:40 +0000 Subject: Deal with a compiler warning about a category implementing methods of the main class. --- macosx/tkMacOSXKeyEvent.c | 2 +- macosx/tkMacOSXMenu.c | 2 +- macosx/tkMacOSXMouseEvent.c | 8 ++++---- macosx/tkMacOSXPrivate.h | 4 ++-- macosx/tkMacOSXWm.c | 10 +++++----- 5 files changed, 13 insertions(+), 13 deletions(-) diff --git a/macosx/tkMacOSXKeyEvent.c b/macosx/tkMacOSXKeyEvent.c index ba885d1..22842b3 100644 --- a/macosx/tkMacOSXKeyEvent.c +++ b/macosx/tkMacOSXKeyEvent.c @@ -330,7 +330,7 @@ unsigned short releaseCode; pt.y = caret_y; pt = [self convertPoint: pt toView: nil]; - pt = [[self window] convertPointToScreen: pt]; + pt = [[self window] tkConvertPointToScreen: pt]; pt.y -= caret_height; rect.origin = pt; diff --git a/macosx/tkMacOSXMenu.c b/macosx/tkMacOSXMenu.c index c625232..d5865f6 100644 --- a/macosx/tkMacOSXMenu.c +++ b/macosx/tkMacOSXMenu.c @@ -785,7 +785,7 @@ TkpPostMenu( NSRect frame = NSMakeRect(x + 9, tkMacOSXZeroScreenHeight - y - 9, 1, 1); frame.origin = [view convertPoint: - [win convertPointFromScreen:frame.origin] fromView:nil]; + [win tkConvertPointFromScreen:frame.origin] fromView:nil]; NSMenu *menu = (NSMenu *) menuPtr->platformData; NSPopUpButtonCell *popUpButtonCell = [[NSPopUpButtonCell alloc] diff --git a/macosx/tkMacOSXMouseEvent.c b/macosx/tkMacOSXMouseEvent.c index 010023f..828d874 100644 --- a/macosx/tkMacOSXMouseEvent.c +++ b/macosx/tkMacOSXMouseEvent.c @@ -90,14 +90,14 @@ enum { /* Create an Xevent to add to the Tk queue. */ NSPoint global, local = [theEvent locationInWindow]; if (eventWindow) { /* local will be in window coordinates. */ - global = [eventWindow convertPointToScreen: local]; + global = [eventWindow tkConvertPointToScreen: local]; local.y = [eventWindow frame].size.height - local.y; global.y = tkMacOSXZeroScreenHeight - global.y; } else { /* local will be in screen coordinates. */ if (_windowWithMouse ) { eventWindow = _windowWithMouse; global = local; - local = [eventWindow convertPointFromScreen: local]; + local = [eventWindow tkConvertPointFromScreen: local]; local.y = [eventWindow frame].size.height - local.y; global.y = tkMacOSXZeroScreenHeight - global.y; } else { /* We have no window. Use the screen???*/ @@ -373,7 +373,7 @@ XQueryPointer( if (win) { NSPoint local; - local = [win convertPointFromScreen:global]; + local = [win tkConvertPointFromScreen:global]; local.y = [win frame].size.height - local.y; if (macWin->winPtr && macWin->winPtr->wmInfoPtr) { local.x -= macWin->winPtr->wmInfoPtr->xInParent; @@ -471,7 +471,7 @@ TkGenerateButtonEvent( if (win) { NSPoint local = NSMakePoint(x, tkMacOSXZeroScreenHeight - y); - local = [win convertPointFromScreen:local]; + local = [win tkConvertPointFromScreen:local]; local.y = [win frame].size.height - local.y; if (macWin->winPtr && macWin->winPtr->wmInfoPtr) { local.x -= macWin->winPtr->wmInfoPtr->xInParent; diff --git a/macosx/tkMacOSXPrivate.h b/macosx/tkMacOSXPrivate.h index ea4c750..24108a6 100644 --- a/macosx/tkMacOSXPrivate.h +++ b/macosx/tkMacOSXPrivate.h @@ -349,8 +349,8 @@ VISIBILITY_HIDDEN @interface NSWindow(TKWm) #if MAC_OS_X_VERSION_MIN_REQUIRED < 101400 -- (NSPoint) convertPointToScreen:(NSPoint)point; -- (NSPoint) convertPointFromScreen:(NSPoint)point; +- (NSPoint) tkConvertPointToScreen:(NSPoint)point; +- (NSPoint) tkConvertPointFromScreen:(NSPoint)point; #endif @end diff --git a/macosx/tkMacOSXWm.c b/macosx/tkMacOSXWm.c index 3cc647d..3c88ecd 100644 --- a/macosx/tkMacOSXWm.c +++ b/macosx/tkMacOSXWm.c @@ -204,16 +204,16 @@ static int windowHashInit = false; @implementation NSWindow(TKWm) #if MAC_OS_X_VERSION_MIN_REQUIRED < 1070 -- (NSPoint) convertPointToScreen: (NSPoint) point +- (NSPoint) tkConvertPointToScreen: (NSPoint) point { return [self convertBaseToScreen:point]; } -- (NSPoint) convertPointFromScreen: (NSPoint)point +- (NSPoint) tkConvertPointFromScreen: (NSPoint)point { return [self convertScreenToBase:point]; } -#elif MAC_OS_X_VERSION_MIN_REQUIRED < 101400 -- (NSPoint) convertPointToScreen: (NSPoint) point +#else +- (NSPoint) tkConvertPointToScreen: (NSPoint) point { NSRect pointrect; pointrect.origin = point; @@ -221,7 +221,7 @@ static int windowHashInit = false; pointrect.size.height = 0; return [self convertRectToScreen:pointrect].origin; } -- (NSPoint) convertPointFromScreen: (NSPoint)point +- (NSPoint) tkConvertPointFromScreen: (NSPoint)point { NSRect pointrect; pointrect.origin = point; -- cgit v0.12 From 1c1dcadba2966af04e6bb238925a1981245182d1 Mon Sep 17 00:00:00 2001 From: fvogel Date: Sun, 28 Oct 2018 18:03:17 +0000 Subject: Make the branch compile on Windows (MSVC). --- generic/tkTextDisp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/generic/tkTextDisp.c b/generic/tkTextDisp.c index 7d38ce4..84be232 100644 --- a/generic/tkTextDisp.c +++ b/generic/tkTextDisp.c @@ -28,7 +28,7 @@ #define FORCE_DISPLAY(winPtr) TkpDisplayWindow(winPtr) #else #define OK_TO_LOG 1 -#define FORCE_DISPLAY(winPtr) do {} while 0 +#define FORCE_DISPLAY(winPtr) #endif /* -- cgit v0.12 From e0fc18fd888c1c70c8e6152ed3d15d2679daf1ab Mon Sep 17 00:00:00 2001 From: culler Date: Sun, 28 Oct 2018 18:40:50 +0000 Subject: Adjust some conditional compilation cutoffs to make the build work on OSX 10.9 (Mavericks) --- macosx/tkMacOSXInit.c | 2 +- macosx/tkMacOSXWm.c | 2 ++ macosx/tkMacOSXXStubs.c | 2 +- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/macosx/tkMacOSXInit.c b/macosx/tkMacOSXInit.c index b85b66d..10ef87e 100644 --- a/macosx/tkMacOSXInit.c +++ b/macosx/tkMacOSXInit.c @@ -155,7 +155,7 @@ static char scriptPath[PATH_MAX + 1] = ""; * Record the OS version we are running on. */ int minorVersion; -#if MAC_OS_X_VERSION_MIN_REQUIRED < 1080 +#if MAC_OS_X_VERSION_MIN_REQUIRED < 101000 Gestalt(gestaltSystemVersionMinor, (SInt32*)&minorVersion); #else NSOperatingSystemVersion systemVersion; diff --git a/macosx/tkMacOSXWm.c b/macosx/tkMacOSXWm.c index 3c88ecd..0e30d28 100644 --- a/macosx/tkMacOSXWm.c +++ b/macosx/tkMacOSXWm.c @@ -6562,6 +6562,7 @@ TkMacOSXMakeFullscreen( /*For 10.13 and later add a button for exiting Fullscreen.*/ if ([NSApp macMinorVersion] > 12) { +#if __MAC_OSX_VERSION_MAX_ALLOWED > 1090 exitFullScreen = [[[NSStatusBar systemStatusBar] statusItemWithLength:NSVariableStatusItemLength] retain]; NSImage *exitIcon = [NSImage imageNamed:@"NSExitFullScreenTemplate"]; @@ -6570,6 +6571,7 @@ TkMacOSXMakeFullscreen( exitFullScreen.button.toolTip = @"Exit Full Screen"; exitFullScreen.button.target = window; exitFullScreen.button.action = @selector(restoreOldScreen:); +#endif } /* diff --git a/macosx/tkMacOSXXStubs.c b/macosx/tkMacOSXXStubs.c index 66f519f..17cbc46 100644 --- a/macosx/tkMacOSXXStubs.c +++ b/macosx/tkMacOSXXStubs.c @@ -178,7 +178,7 @@ TkpOpenDisplay( { int major, minor, patch; -#if MAC_OS_X_VERSION_MIN_REQUIRED < 1080 +#if MAC_OS_X_VERSION_MIN_REQUIRED < 101000 Gestalt(gestaltSystemVersionMajor, (SInt32*)&major); Gestalt(gestaltSystemVersionMinor, (SInt32*)&minor); Gestalt(gestaltSystemVersionBugFix, (SInt32*)&patch); -- cgit v0.12 From 6bb10563aa31c100460f9c956fab0b4a29bba429 Mon Sep 17 00:00:00 2001 From: fvogel Date: Sun, 28 Oct 2018 19:07:19 +0000 Subject: Increase the size of the ring buffer (in bind.test) according to the change made in [831734f0] --- tests/bind.test | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/bind.test b/tests/bind.test index 9e30d78..7c5ccf1 100644 --- a/tests/bind.test +++ b/tests/bind.test @@ -39,10 +39,10 @@ proc unsetBindings {} { # events to make sure that there are no stray events in the ring # buffer which might cause the pattern matcher to find unintended # matches. The size of the ring buffer is EVENT_BUFFER_SIZE, which is -# currently set to 30. If this changes, the code below will need to -# change. +# currently set to 30 (or 45 on macOS). If this changes, the code +# below will need to change. proc clearRingBuffer {{event}} { - for {set i 0} {$i < 30} {incr i} { + for {set i 0} {$i < 45} {incr i} { event generate . $event } } -- cgit v0.12 From 64095fae8d758cb1757a59e8a08f913a37796462 Mon Sep 17 00:00:00 2001 From: dkf Date: Sun, 28 Oct 2018 22:17:26 +0000 Subject: Documentation --- doc/grid.n | 16 ++++++++++++++++ doc/pack.n | 8 ++++++++ generic/tkGrid.c | 7 ++++--- generic/tkPack.c | 7 ++++--- 4 files changed, 32 insertions(+), 6 deletions(-) diff --git a/doc/grid.n b/doc/grid.n index ca8b7cd..ea72db1 100644 --- a/doc/grid.n +++ b/doc/grid.n @@ -202,6 +202,14 @@ The slaves will no longer be managed by the grid geometry manager. The configuration options for that window are forgotten, so that if the slave is managed once more by the grid geometry manager, the initial default settings are used. +.RS +.PP +.VS TIP518 +If the last slave of the master becomes unmanaged, this will also send +the virtual event \fB<>\fR to the master; the master +may choose to resize itself (or otherwise respond) to such a change. +.VE TIP518 +.RE .TP \fBgrid info \fIslave\fR . @@ -278,6 +286,14 @@ However, the configuration options for that window are remembered, so that if the slave is managed once more by the grid geometry manager, the previous values are retained. +.RS +.PP +.VS TIP518 +If the last slave of the master becomes unmanaged, this will also send +the virtual event \fB<>\fR to the master; the master +may choose to resize itself (or otherwise respond) to such a change. +.VE TIP518 +.RE .TP \fBgrid size \fImaster\fR . diff --git a/doc/pack.n b/doc/pack.n index 6b39e1d..980dd6e 100644 --- a/doc/pack.n +++ b/doc/pack.n @@ -129,6 +129,14 @@ than receiving default values. Removes each of the \fIslave\fRs from the packing order for its master and unmaps their windows. The slaves will no longer be managed by the packer. +.RS +.PP +.VS TIP518 +If the last slave of the master becomes unmanaged, this will also send +the virtual event \fB<>\fR to the master; the master +may choose to resize itself (or otherwise respond) to such a change. +.VE TIP518 +.RE .TP \fBpack info \fIslave\fR Returns a list whose elements are the current configuration state of diff --git a/generic/tkGrid.c b/generic/tkGrid.c index a4ac763..4711685 100644 --- a/generic/tkGrid.c +++ b/generic/tkGrid.c @@ -1735,12 +1735,13 @@ ArrangeGrid( * If the master has no slaves anymore, then don't change the master size. * Otherwise there is no way to "relinquish" control over the master * so another geometry manager can take over. - * Send event to "NoManagedChild" to inform about no managed grid but - * not resized. + * + * Sends the event "NoManagedChild" to the master to inform it about there + * being no managed children inside it. */ if (masterPtr->slavePtr == NULL) { - TkSendVirtualEvent(masterPtr->tkwin, "NoManagedChild", NULL); + TkSendVirtualEvent(masterPtr->tkwin, "NoManagedChild", NULL); return; } diff --git a/generic/tkPack.c b/generic/tkPack.c index 12f651a..ef6e30e 100644 --- a/generic/tkPack.c +++ b/generic/tkPack.c @@ -613,12 +613,13 @@ ArrangePacking( * If the master has no slaves anymore, then leave the master's size as-is. * Otherwise there is no way to "relinquish" control over the master * so another geometry manager can take over. - * Send event to "NoManagedChild" to inform about no managed grid but - * not resized. + * + * Sends the event "NoManagedChild" to the master to inform it about there + * being no managed children inside it. */ if (masterPtr->slavePtr == NULL) { - TkSendVirtualEvent(masterPtr->tkwin, "NoManagedChild", NULL); + TkSendVirtualEvent(masterPtr->tkwin, "NoManagedChild", NULL); return; } -- cgit v0.12 From a2d3cbf84f7c94437da6df6e681495ac03b0218f Mon Sep 17 00:00:00 2001 From: culler Date: Mon, 29 Oct 2018 03:17:44 +0000 Subject: Remove an extraneous #ifdef and correct the spelling of a #define constant. --- macosx/tkMacOSXPrivate.h | 2 -- macosx/tkMacOSXWm.c | 2 +- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/macosx/tkMacOSXPrivate.h b/macosx/tkMacOSXPrivate.h index 24108a6..197879f 100644 --- a/macosx/tkMacOSXPrivate.h +++ b/macosx/tkMacOSXPrivate.h @@ -348,10 +348,8 @@ VISIBILITY_HIDDEN @end @interface NSWindow(TKWm) -#if MAC_OS_X_VERSION_MIN_REQUIRED < 101400 - (NSPoint) tkConvertPointToScreen:(NSPoint)point; - (NSPoint) tkConvertPointFromScreen:(NSPoint)point; -#endif @end #pragma mark NSMenu & NSMenuItem Utilities diff --git a/macosx/tkMacOSXWm.c b/macosx/tkMacOSXWm.c index 0e30d28..a3f2043 100644 --- a/macosx/tkMacOSXWm.c +++ b/macosx/tkMacOSXWm.c @@ -6562,7 +6562,7 @@ TkMacOSXMakeFullscreen( /*For 10.13 and later add a button for exiting Fullscreen.*/ if ([NSApp macMinorVersion] > 12) { -#if __MAC_OSX_VERSION_MAX_ALLOWED > 1090 +#if MAC_OS_X_VERSION_MAX_ALLOWED > 1090 exitFullScreen = [[[NSStatusBar systemStatusBar] statusItemWithLength:NSVariableStatusItemLength] retain]; NSImage *exitIcon = [NSImage imageNamed:@"NSExitFullScreenTemplate"]; -- cgit v0.12 From e2dd87abf18c856f4cda284db55b313e882e919f Mon Sep 17 00:00:00 2001 From: oehhar Date: Mon, 29 Oct 2018 12:52:40 +0000 Subject: Tests for virtual event <> --- tests/grid.test | 71 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ tests/pack.test | 58 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 129 insertions(+) diff --git a/tests/grid.test b/tests/grid.test index cba69db..46e54f0 100644 --- a/tests/grid.test +++ b/tests/grid.test @@ -2017,6 +2017,77 @@ test grid-23 {grid configure -in leaked from previous master - bug winfo ismapped .t ; # must return 1 } {1} grid_reset 23 + +test grid-24.1 {<> fires on last grid forget} -body { + global A + catch {unset A} + grid [frame .1] + update + bind . <> {set A 1} + grid forget .1 + update + info exists A +} -cleanup { + bind . <> {} + grid_reset 14.1 +} -result {1} + +test grid-24.2 { does not fire on last grid forget} -body { + global A + catch {unset A} + grid [frame .1] + update + bind . {set A 1} + grid forget .1 + update + info exists A +} -cleanup { + bind . {} + grid_reset 14.2 +} -result {0} + +test grid-24.3 { fires on forelast grid forget} -body { + global A + catch {unset A} + grid [frame .1] + grid [frame .2] + update + bind . {set A 1} + grid forget .1 + update + info exists A +} -cleanup { + bind . {} + grid_reset 14.3 +} -result {1} + +test grid-24.4 {<> does not fire on forelast grid forget} -body { + global A + catch {unset A} + grid [frame .1] + grid [frame .2] + update + bind . <> {set A 1} + grid forget .1 + update + info exists A +} -cleanup { + bind . <> {} + grid_reset 14.4 +} -result {0} + +test grid-24.5 {<> should not fire on grid anchor} -body { + global A + bind . <> {set A 1} + grid anchor . w + update + info exists A +} -cleanup { + grid anchor . nw + bind . <> {} + grid_reset 14.5 +} -result {0} + # cleanup cleanupTests diff --git a/tests/pack.test b/tests/pack.test index 279db8b..061ea03 100644 --- a/tests/pack.test +++ b/tests/pack.test @@ -1626,6 +1626,64 @@ test pack-19.2 {test support for minreqsize} -setup { destroy .pack.l .pack.lf } -result {162x127+0+0 172x112+0+0} +test pack-20.1 {<> fires on last pack forget} -body { + global A + catch {unset A} + pack [frame .1] + update + bind . <> {set A 1} + pack forget .1 + update + info exists A +} -cleanup { + bind . <> {} + destroy .1 +} -result {1} + +test pack-20.2 { does not fire on last pack forget} -body { + global A + catch {unset A} + pack [frame .1] + update + bind . {set A 1} + pack forget .1 + update + info exists A +} -cleanup { + bind . {} + destroy .1 +} -result {0} + +test pack-20.3 {<> does not fire on forelast pack forget} -body { + global A + catch {unset A} + pack [frame .1] + pack [frame .2] + update + bind . <> {set A 1} + pack forget .1 + update + info exists A +} -cleanup { + bind . <> {} + destroy .1 .2 +} -result {0} + +test pack-20.4 { does not fire on last pack forget} -body { + global A + catch {unset A} + pack [frame .1] + pack [frame .2] + update + bind . {set A 1} + pack forget .1 + update + info exists A +} -cleanup { + bind . {} + destroy .1 .2 +} -result {1} + # cleanup cleanupTests -- cgit v0.12 From 779ea84594b15e756513250c55c9395b89a6f7b8 Mon Sep 17 00:00:00 2001 From: culler Date: Mon, 29 Oct 2018 13:22:12 +0000 Subject: Tweak a couple of #define constants for building on OSX 10.6. --- macosx/tkMacOSXConstants.h | 4 ++++ macosx/tkMacOSXFont.c | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/macosx/tkMacOSXConstants.h b/macosx/tkMacOSXConstants.h index 3f0d306..b160083 100644 --- a/macosx/tkMacOSXConstants.h +++ b/macosx/tkMacOSXConstants.h @@ -15,6 +15,10 @@ #ifndef _TKMACCONSTANTS #define _TKMACCONSTANTS +#if MAC_OS_X_VERSION_MAX_ALLOWED < 1070 +#define NSFullScreenWindowMask (1 << 14) +#endif + /* * Let's raise a glass for the project manager who improves our lives by * generating deprecation warnings about pointless changes of the names diff --git a/macosx/tkMacOSXFont.c b/macosx/tkMacOSXFont.c index 0701fb6..30e318c 100644 --- a/macosx/tkMacOSXFont.c +++ b/macosx/tkMacOSXFont.c @@ -18,7 +18,7 @@ #define defaultOrientation kCTFontDefaultOrientation #define verticalOrientation kCTFontVerticalOrientation -#define fixedPitch kCTFontUIFontUserFixedPitch +#define fixedPitch kCTFontUserFixedPitchFontType /* #ifdef TK_MAC_DEBUG -- cgit v0.12 From e105b149f982ff16a6397783bbcb3a62de4a5323 Mon Sep 17 00:00:00 2001 From: culler Date: Mon, 29 Oct 2018 16:24:26 +0000 Subject: One more #define constant adjusted, for building on OSX 10.10. --- macosx/tkMacOSXWm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/macosx/tkMacOSXWm.c b/macosx/tkMacOSXWm.c index a3f2043..792e8b8 100644 --- a/macosx/tkMacOSXWm.c +++ b/macosx/tkMacOSXWm.c @@ -6562,7 +6562,7 @@ TkMacOSXMakeFullscreen( /*For 10.13 and later add a button for exiting Fullscreen.*/ if ([NSApp macMinorVersion] > 12) { -#if MAC_OS_X_VERSION_MAX_ALLOWED > 1090 +#if MAC_OS_X_VERSION_MAX_ALLOWED > 101200 exitFullScreen = [[[NSStatusBar systemStatusBar] statusItemWithLength:NSVariableStatusItemLength] retain]; NSImage *exitIcon = [NSImage imageNamed:@"NSExitFullScreenTemplate"]; -- cgit v0.12 From f85993dea8a3beab766ca42177166cdaf479bd08 Mon Sep 17 00:00:00 2001 From: dgp Date: Mon, 29 Oct 2018 18:44:35 +0000 Subject: Eliminate the ancient fixstrtod fallback that is damaging cross-compiling. --- unix/configure | 75 ------------------------------------------------------- unix/configure.ac | 9 ------- unix/tcl.m4 | 53 --------------------------------------- 3 files changed, 137 deletions(-) diff --git a/unix/configure b/unix/configure index 4eaf075..8ac1625 100755 --- a/unix/configure +++ b/unix/configure @@ -6760,81 +6760,6 @@ fi #-------------------------------------------------------------------- -# Under Solaris 2.4, strtod returns the wrong value for the -# terminating character under some conditions. Check for this -# and if the problem exists use a substitute procedure -# "fixstrtod" (provided by Tcl) that corrects the error. -#-------------------------------------------------------------------- - - - ac_fn_c_check_func "$LINENO" "strtod" "ac_cv_func_strtod" -if test "x$ac_cv_func_strtod" = xyes; then : - tcl_strtod=1 -else - tcl_strtod=0 -fi - - if test "$tcl_strtod" = 1; then - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for Solaris2.4/Tru64 strtod bugs" >&5 -$as_echo_n "checking for Solaris2.4/Tru64 strtod bugs... " >&6; } -if ${tcl_cv_strtod_buggy+:} false; then : - $as_echo_n "(cached) " >&6 -else - - if test "$cross_compiling" = yes; then : - tcl_cv_strtod_buggy=buggy -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - - extern double strtod(); - int main() { - char *infString="Inf", *nanString="NaN", *spaceString=" "; - char *term; - double value; - value = strtod(infString, &term); - if ((term != infString) && (term[-1] == 0)) { - exit(1); - } - value = strtod(nanString, &term); - if ((term != nanString) && (term[-1] == 0)) { - exit(1); - } - value = strtod(spaceString, &term); - if (term == (spaceString+1)) { - exit(1); - } - exit(0); - } -_ACEOF -if ac_fn_c_try_run "$LINENO"; then : - tcl_cv_strtod_buggy=ok -else - tcl_cv_strtod_buggy=buggy -fi -rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ - conftest.$ac_objext conftest.beam conftest.$ac_ext -fi - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $tcl_cv_strtod_buggy" >&5 -$as_echo "$tcl_cv_strtod_buggy" >&6; } - if test "$tcl_cv_strtod_buggy" = buggy; then - case " $LIBOBJS " in - *" fixstrtod.$ac_objext "* ) ;; - *) LIBOBJS="$LIBOBJS fixstrtod.$ac_objext" - ;; -esac - - USE_COMPAT=1 - -$as_echo "#define strtod fixstrtod" >>confdefs.h - - fi - fi - - -#-------------------------------------------------------------------- # Check for various typedefs and provide substitutes if # they don't exist. #-------------------------------------------------------------------- diff --git a/unix/configure.ac b/unix/configure.ac index 194034c..5f5213d 100644 --- a/unix/configure.ac +++ b/unix/configure.ac @@ -190,15 +190,6 @@ AC_CHECK_HEADERS(sys/time.h) AC_HEADER_TIME #-------------------------------------------------------------------- -# Under Solaris 2.4, strtod returns the wrong value for the -# terminating character under some conditions. Check for this -# and if the problem exists use a substitute procedure -# "fixstrtod" (provided by Tcl) that corrects the error. -#-------------------------------------------------------------------- - -SC_BUGGY_STRTOD - -#-------------------------------------------------------------------- # Check for various typedefs and provide substitutes if # they don't exist. #-------------------------------------------------------------------- diff --git a/unix/tcl.m4 b/unix/tcl.m4 index e27cc2c..0426c7f 100644 --- a/unix/tcl.m4 +++ b/unix/tcl.m4 @@ -2182,59 +2182,6 @@ AC_DEFUN([SC_TIME_HANDLER], [ ]) #-------------------------------------------------------------------- -# SC_BUGGY_STRTOD -# -# Under Solaris 2.4, strtod returns the wrong value for the -# terminating character under some conditions. Check for this -# and if the problem exists use a substitute procedure -# "fixstrtod" (provided by Tcl) that corrects the error. -# Also, on Compaq's Tru64 Unix 5.0, -# strtod(" ") returns 0.0 instead of a failure to convert. -# -# Arguments: -# none -# -# Results: -# -# Might defines some of the following vars: -# strtod (=fixstrtod) -# -#-------------------------------------------------------------------- - -AC_DEFUN([SC_BUGGY_STRTOD], [ - AC_CHECK_FUNC(strtod, tcl_strtod=1, tcl_strtod=0) - if test "$tcl_strtod" = 1; then - AC_CACHE_CHECK([for Solaris2.4/Tru64 strtod bugs], tcl_cv_strtod_buggy,[ - AC_TRY_RUN([ - extern double strtod(); - int main() { - char *infString="Inf", *nanString="NaN", *spaceString=" "; - char *term; - double value; - value = strtod(infString, &term); - if ((term != infString) && (term[-1] == 0)) { - exit(1); - } - value = strtod(nanString, &term); - if ((term != nanString) && (term[-1] == 0)) { - exit(1); - } - value = strtod(spaceString, &term); - if (term == (spaceString+1)) { - exit(1); - } - exit(0); - }], tcl_cv_strtod_buggy=ok, tcl_cv_strtod_buggy=buggy, - tcl_cv_strtod_buggy=buggy)]) - if test "$tcl_cv_strtod_buggy" = buggy; then - AC_LIBOBJ([fixstrtod]) - USE_COMPAT=1 - AC_DEFINE(strtod, fixstrtod, [Do we want to use the strtod() in compat?]) - fi - fi -]) - -#-------------------------------------------------------------------- # SC_TCL_LINK_LIBS # # Search for the libraries needed to link the Tcl shell. -- cgit v0.12 From 5dbd806ccb9de26b2c953153fc9057fbc7fe729b Mon Sep 17 00:00:00 2001 From: fvogel Date: Mon, 29 Oct 2018 23:01:08 +0000 Subject: Enhance the tests for <>, and fix the implementation so that this event only fires when the last slave is forgotten/removed. --- generic/tkGrid.c | 12 ++++++++---- generic/tkPack.c | 8 ++++---- tests/grid.test | 32 +++++++++++++++++++++++--------- 3 files changed, 35 insertions(+), 17 deletions(-) diff --git a/generic/tkGrid.c b/generic/tkGrid.c index 4711685..ec22016 100644 --- a/generic/tkGrid.c +++ b/generic/tkGrid.c @@ -1735,13 +1735,9 @@ ArrangeGrid( * If the master has no slaves anymore, then don't change the master size. * Otherwise there is no way to "relinquish" control over the master * so another geometry manager can take over. - * - * Sends the event "NoManagedChild" to the master to inform it about there - * being no managed children inside it. */ if (masterPtr->slavePtr == NULL) { - TkSendVirtualEvent(masterPtr->tkwin, "NoManagedChild", NULL); return; } @@ -2780,11 +2776,15 @@ Unlink( /* * If we have emptied this master from slaves it means we are no longer * handling it and should mark it as free. + * + * Send the event "NoManagedChild" to the master to inform it about there + * being no managed children inside it. */ if ((masterPtr->slavePtr == NULL) && (masterPtr->flags & ALLOCED_MASTER)) { TkFreeGeometryMaster(masterPtr->tkwin, "grid"); masterPtr->flags &= ~ALLOCED_MASTER; + TkSendVirtualEvent(masterPtr->tkwin, "NoManagedChild", NULL); } } @@ -3512,11 +3512,15 @@ ConfigureSlaves( /* * If we have emptied this master from slaves it means we are no longer * handling it and should mark it as free. + * + * Send the event "NoManagedChild" to the master to inform it about there + * being no managed children inside it. */ if (masterPtr->slavePtr == NULL && masterPtr->flags & ALLOCED_MASTER) { TkFreeGeometryMaster(masterPtr->tkwin, "grid"); masterPtr->flags &= ~ALLOCED_MASTER; + TkSendVirtualEvent(masterPtr->tkwin, "NoManagedChild", NULL); } return TCL_OK; diff --git a/generic/tkPack.c b/generic/tkPack.c index ef6e30e..f2ba642 100644 --- a/generic/tkPack.c +++ b/generic/tkPack.c @@ -613,13 +613,9 @@ ArrangePacking( * If the master has no slaves anymore, then leave the master's size as-is. * Otherwise there is no way to "relinquish" control over the master * so another geometry manager can take over. - * - * Sends the event "NoManagedChild" to the master to inform it about there - * being no managed children inside it. */ if (masterPtr->slavePtr == NULL) { - TkSendVirtualEvent(masterPtr->tkwin, "NoManagedChild", NULL); return; } @@ -1378,11 +1374,15 @@ Unlink( /* * If we have emptied this master from slaves it means we are no longer * handling it and should mark it as free. + * + * Send the event "NoManagedChild" to the master to inform it about there + * being no managed children inside it. */ if ((masterPtr->slavePtr == NULL) && (masterPtr->flags & ALLOCED_MASTER)) { TkFreeGeometryMaster(masterPtr->tkwin, "pack"); masterPtr->flags &= ~ALLOCED_MASTER; + TkSendVirtualEvent(masterPtr->tkwin, "NoManagedChild", NULL); } } diff --git a/tests/grid.test b/tests/grid.test index 46e54f0..e55f866 100644 --- a/tests/grid.test +++ b/tests/grid.test @@ -2029,10 +2029,24 @@ test grid-24.1 {<> fires on last grid forget} -body { info exists A } -cleanup { bind . <> {} - grid_reset 14.1 + grid_reset 24.1 +} -result {1} + +test grid-24.2 {<> fires on last grid remove} -body { + global A + catch {unset A} + grid [frame .1] + update + bind . <> {set A 1} + grid remove .1 + update + info exists A +} -cleanup { + bind . <> {} + grid_reset 24.2 } -result {1} -test grid-24.2 { does not fire on last grid forget} -body { +test grid-24.3 { does not fire on last grid forget} -body { global A catch {unset A} grid [frame .1] @@ -2043,10 +2057,10 @@ test grid-24.2 { does not fire on last grid forget} -body { info exists A } -cleanup { bind . {} - grid_reset 14.2 + grid_reset 24.3 } -result {0} -test grid-24.3 { fires on forelast grid forget} -body { +test grid-24.4 { fires on forelast grid forget} -body { global A catch {unset A} grid [frame .1] @@ -2058,10 +2072,10 @@ test grid-24.3 { fires on forelast grid forget} -body { info exists A } -cleanup { bind . {} - grid_reset 14.3 + grid_reset 24.4 } -result {1} -test grid-24.4 {<> does not fire on forelast grid forget} -body { +test grid-24.5 {<> does not fire on forelast grid forget} -body { global A catch {unset A} grid [frame .1] @@ -2073,10 +2087,10 @@ test grid-24.4 {<> does not fire on forelast grid forget} -body info exists A } -cleanup { bind . <> {} - grid_reset 14.4 + grid_reset 24.5 } -result {0} -test grid-24.5 {<> should not fire on grid anchor} -body { +test grid-24.6 {<> does not fire on grid anchor} -body { global A bind . <> {set A 1} grid anchor . w @@ -2085,7 +2099,7 @@ test grid-24.5 {<> should not fire on grid anchor} -body { } -cleanup { grid anchor . nw bind . <> {} - grid_reset 14.5 + grid_reset 24.6 } -result {0} -- cgit v0.12 From a16d0e701b1b7c030d0e434a5a1161c95e49b044 Mon Sep 17 00:00:00 2001 From: culler Date: Tue, 30 Oct 2018 03:56:32 +0000 Subject: Fixed scrollbar behavior. Added some padding in buttons for 10.6 only. --- macosx/tkMacOSXButton.c | 3 + macosx/tkMacOSXScrlbr.c | 193 ++++++++++++++++++++++++++++++++++-------------- 2 files changed, 139 insertions(+), 57 deletions(-) diff --git a/macosx/tkMacOSXButton.c b/macosx/tkMacOSXButton.c index 6930a36..14b8872 100644 --- a/macosx/tkMacOSXButton.c +++ b/macosx/tkMacOSXButton.c @@ -420,6 +420,9 @@ TkpComputeButtonGeometry( width += butPtr->inset*2; height += butPtr->inset*2; + if ([NSApp macMinorVersion] == 6) { + width += 12; + } Tk_GeometryRequest(butPtr->tkwin, width, height); Tk_SetInternalBorder(butPtr->tkwin, butPtr->inset); diff --git a/macosx/tkMacOSXScrlbr.c b/macosx/tkMacOSXScrlbr.c index f15146d..51c9e0c 100644 --- a/macosx/tkMacOSXScrlbr.c +++ b/macosx/tkMacOSXScrlbr.c @@ -40,9 +40,12 @@ */ typedef struct MacScrollbar { - TkScrollbar information; /* Generic scrollbar info. */ + TkScrollbar information; /* Generic scrollbar info. */ GC troughGC; /* For drawing trough. */ GC copyGC; /* Used for copying from pixmap onto screen. */ + Bool buttonDown; /* Is the mouse button down? */ + Bool mouseOver; /* Is the pointer over the scrollbar. */ + HIThemeTrackDrawInfo info; /* Controls how the scrollbar is drawn. */ } MacScrollbar; /* @@ -71,7 +74,7 @@ static ScrollbarMetrics metrics = { 15, 54, 26, 14, 14, kControlSizeNormal /* kThemeScrollBarMedium */ }; -HIThemeTrackDrawInfo info = { +HIThemeTrackDrawInfo defaultInfo = { .version = 0, .min = 0.0, .max = 100.0, @@ -84,7 +87,7 @@ HIThemeTrackDrawInfo info = { */ static void ScrollbarEventProc(ClientData clientData, XEvent *eventPtr); -static int ScrollbarPress(TkScrollbar *scrollPtr, XEvent *eventPtr); +static int ScrollbarEvent(TkScrollbar *scrollPtr, XEvent *eventPtr); static void UpdateControlValues(TkScrollbar *scrollPtr); /* @@ -112,8 +115,19 @@ TkpCreateScrollbar( scrollPtr->troughGC = None; scrollPtr->copyGC = None; - - Tk_CreateEventHandler(tkwin,ExposureMask|StructureNotifyMask|FocusChangeMask|ButtonPressMask|ButtonReleaseMask|EnterWindowMask|LeaveWindowMask|VisibilityChangeMask, ScrollbarEventProc, scrollPtr); + scrollPtr->info = defaultInfo; + scrollPtr->buttonDown = false; + + Tk_CreateEventHandler(tkwin, + ExposureMask | + StructureNotifyMask | + FocusChangeMask | + ButtonPressMask | + ButtonReleaseMask | + EnterWindowMask | + LeaveWindowMask | + VisibilityChangeMask, + ScrollbarEventProc, scrollPtr); return (TkScrollbar *) scrollPtr; } @@ -141,6 +155,7 @@ TkpDisplayScrollbar( ClientData clientData) /* Information about window. */ { register TkScrollbar *scrollPtr = (TkScrollbar *) clientData; + MacScrollbar *msPtr = (MacScrollbar *) scrollPtr; register Tk_Window tkwin = scrollPtr->tkwin; TkWindow *winPtr = (TkWindow *) tkwin; TkMacOSXDrawingContext dc; @@ -191,9 +206,9 @@ TkpDisplayScrollbar( /*Update values and draw in native rect.*/ UpdateControlValues(scrollPtr); if (MOUNTAIN_LION_STYLE) { - HIThemeDrawTrack (&info, 0, dc.context, kHIThemeOrientationInverted); + HIThemeDrawTrack (&(msPtr->info), 0, dc.context, kHIThemeOrientationInverted); } else { - HIThemeDrawTrack (&info, 0, dc.context, kHIThemeOrientationNormal); + HIThemeDrawTrack (&(msPtr->info), 0, dc.context, kHIThemeOrientationNormal); } TkMacOSXRestoreDrawingContext(&dc); @@ -228,12 +243,14 @@ TkpComputeScrollbarGeometry( { /* - * Using code from tkUnixScrlbr.c because Unix scroll bindings are - * driving the display at the script level. All the Mac scrollbar - * has to do is re-draw itself. - * There is a difference with Unix however: on macOS later than 10.6 - * (Snow Leopard) the scrollbars have no arrows at all. This is - * handled by having scrollPtr->arrowLength set to zero. + * Using code from tkUnixScrlbr.c because Unix scroll bindings are driving + * the display at the script level. All the Mac scrollbar has to do is + * re-draw itself. But we must account for some differences from Unix: on + * macOS versions newer than 10.6 (Snow Leopard) the scrollbars have no + * arrows at all. This is handled by having scrollPtr->arrowLength set to + * zero. Also on 10.6 both arrows are at the bottom. This is handled by + * shifting the scrollbar up by the arrowLength, which only has an effect on + * 10.6 since the arrowLength is 0 on newer systems. */ int fieldLength; @@ -242,7 +259,11 @@ TkpComputeScrollbarGeometry( scrollPtr->highlightWidth = 0; } scrollPtr->inset = scrollPtr->highlightWidth + scrollPtr->borderWidth; - scrollPtr->arrowLength = 0; + if ([NSApp macMinorVersion] == 6) { + scrollPtr->arrowLength = scrollPtr->width; + } else { + scrollPtr->arrowLength = 0; + } fieldLength = (scrollPtr->vertical ? Tk_Height(scrollPtr->tkwin) : Tk_Width(scrollPtr->tkwin)) - 2*(scrollPtr->arrowLength + scrollPtr->inset); @@ -270,8 +291,8 @@ TkpComputeScrollbarGeometry( if (scrollPtr->sliderLast > fieldLength) { scrollPtr->sliderLast = fieldLength; } - scrollPtr->sliderFirst += scrollPtr->arrowLength + scrollPtr->inset; - scrollPtr->sliderLast += scrollPtr->arrowLength + scrollPtr->inset; + scrollPtr->sliderFirst += -scrollPtr->arrowLength + scrollPtr->inset; + scrollPtr->sliderLast += scrollPtr->inset; /* * Register the desired geometry for the window (leave enough space for @@ -397,7 +418,8 @@ TkpScrollbarPosition( width = Tk_Height(scrollPtr->tkwin); } - if (x=width-inset || y=length-inset) { + if (x < inset || x >= width - inset || + y < inset || y >= length - inset) { return OUTSIDE; } @@ -406,21 +428,19 @@ TkpScrollbarPosition( * TkpDisplayScrollbar. Be sure to keep the two consistent. */ - if (y < inset + scrollPtr->arrowLength) { - return TOP_ARROW; - } - if (y < scrollPtr->sliderFirst) { + if (y < scrollPtr->sliderFirst + scrollPtr->arrowLength) { return TOP_GAP; - } - if (y < scrollPtr->sliderLast) { + } + if (y < scrollPtr->sliderLast) { return SLIDER; - } - if (y >= length - (scrollPtr->arrowLength + inset)) { - return BOTTOM_ARROW; - } - - return BOTTOM_GAP; - + } + if (y < length - (2*scrollPtr->arrowLength + inset)) { + return BOTTOM_GAP; + } + if (y < length - (scrollPtr->arrowLength + inset)) { + return TOP_ARROW; + } + return BOTTOM_ARROW; } /* @@ -447,6 +467,7 @@ static void UpdateControlValues( TkScrollbar *scrollPtr) /* Scrollbar data struct. */ { + MacScrollbar *msPtr = (MacScrollbar *)scrollPtr; Tk_Window tkwin = scrollPtr->tkwin; MacDrawable *macWin = (MacDrawable *) Tk_WindowId(scrollPtr->tkwin); double dViewSize; @@ -462,7 +483,7 @@ UpdateControlValues( frame.origin.y = viewHeight - (frame.origin.y + frame.size.height); contrlRect = NSRectToCGRect(frame); - info.bounds = contrlRect; + msPtr->info.bounds = contrlRect; width = contrlRect.size.width; height = contrlRect.size.height; @@ -472,11 +493,11 @@ UpdateControlValues( * have been computed. */ - info.bounds = contrlRect; + msPtr->info.bounds = contrlRect; if (scrollPtr->vertical) { - info.attributes &= ~kThemeTrackHorizontal; + msPtr->info.attributes &= ~kThemeTrackHorizontal; } else { - info.attributes |= kThemeTrackHorizontal; + msPtr->info.attributes |= kThemeTrackHorizontal; } /* @@ -493,25 +514,25 @@ UpdateControlValues( factor = RangeToFactor(maximum); dViewSize = (scrollPtr->lastFraction - scrollPtr->firstFraction) * factor; - info.max = MIN_SCROLLBAR_VALUE + + msPtr->info.max = MIN_SCROLLBAR_VALUE + factor - dViewSize; - info.trackInfo.scrollbar.viewsize = dViewSize; + msPtr->info.trackInfo.scrollbar.viewsize = dViewSize; if (scrollPtr->vertical) { if (MOUNTAIN_LION_STYLE) { - info.value = factor * scrollPtr->firstFraction; + msPtr->info.value = factor * scrollPtr->firstFraction; } else { - info.value = info.max - factor * scrollPtr->firstFraction; + msPtr->info.value = msPtr->info.max - factor * scrollPtr->firstFraction; } } else { - info.value = MIN_SCROLLBAR_VALUE + factor * scrollPtr->firstFraction; + msPtr->info.value = MIN_SCROLLBAR_VALUE + factor * scrollPtr->firstFraction; } if((scrollPtr->firstFraction <= 0.0 && scrollPtr->lastFraction >= 1.0) || height <= metrics.minHeight) { - info.enableState = kThemeTrackHideTrack; + msPtr->info.enableState = kThemeTrackHideTrack; } else { - info.enableState = kThemeTrackActive; - info.attributes = kThemeTrackShowThumb | kThemeTrackThumbRgnIsNotGhost; + msPtr->info.enableState = kThemeTrackActive; + msPtr->info.attributes = kThemeTrackShowThumb | kThemeTrackThumbRgnIsNotGhost; } } @@ -519,29 +540,78 @@ UpdateControlValues( /* *-------------------------------------------------------------- * - * ScrollbarPress -- + * ScrollbarEvent -- * * This procedure is invoked in response to , , - * , and events. Scrollbar appearance is modified. + * , and events. The Scrollbar appearance is + * modified for each event. * *-------------------------------------------------------------- */ static int -ScrollbarPress(TkScrollbar *scrollPtr, XEvent *eventPtr) +ScrollbarEvent(TkScrollbar *scrollPtr, XEvent *eventPtr) { + MacScrollbar *msPtr = (MacScrollbar *)scrollPtr; + + /* The pressState does not indicate whether the moused button was + * pressed at some location in the Scrollbar. Rather, it indicates + * that the scrollbar should appear as if it were pressed in that + * location. The standard Mac behavior is that once the button is + * pressed inside the Scrollbar the appearance should not change until + * the button is released, even if the mouse moves outside of the + * scrollbar. However, if the mouse lies over the scrollbar but the + * button is not pressed then the appearance should be the same as if + * the button had been pressed on the slider, i.e. kThemeThumbPressed. + */ - if (eventPtr->type == ButtonPress) { - UpdateControlValues(scrollPtr); - info.trackInfo.scrollbar.pressState = 1; - } - if (eventPtr->type == EnterNotify) { - info.trackInfo.scrollbar.pressState = 1; - } - if (eventPtr->type == ButtonRelease || eventPtr->type == LeaveNotify) { - info.trackInfo.scrollbar.pressState = 0; - } - return TCL_OK; + if (eventPtr->type == ButtonPress) { + msPtr->buttonDown = true; + UpdateControlValues(scrollPtr); + int where = TkpScrollbarPosition(scrollPtr, + eventPtr->xbutton.x, + eventPtr->xbutton.y); + switch(where) { + case OUTSIDE: + msPtr->info.trackInfo.scrollbar.pressState = 0; + break; + case TOP_GAP: + msPtr->info.trackInfo.scrollbar.pressState = kThemeTopTrackPressed; + break; + case SLIDER: + msPtr->info.trackInfo.scrollbar.pressState = kThemeThumbPressed; + break; + case BOTTOM_GAP: + msPtr->info.trackInfo.scrollbar.pressState = kThemeBottomTrackPressed; + break; + case TOP_ARROW: + /* This looks wrong and the docs say it is wrong but it works. */ + msPtr->info.trackInfo.scrollbar.pressState = kThemeTopInsideArrowPressed; + break; + case BOTTOM_ARROW: + msPtr->info.trackInfo.scrollbar.pressState = kThemeBottomOutsideArrowPressed; + break; + } + } + if (eventPtr->type == ButtonRelease) { + msPtr->buttonDown = false; + if (!msPtr->mouseOver) { + msPtr->info.trackInfo.scrollbar.pressState = 0; + } + } + if (eventPtr->type == EnterNotify) { + msPtr->mouseOver = true; + if (!msPtr->buttonDown) { + msPtr->info.trackInfo.scrollbar.pressState = kThemeThumbPressed; + } + } + if (eventPtr->type == LeaveNotify) { + msPtr->mouseOver = false; + if (!msPtr->buttonDown) { + msPtr->info.trackInfo.scrollbar.pressState = 0; + } + } + return TCL_OK; } @@ -583,9 +653,18 @@ ScrollbarEventProc( case ButtonRelease: case EnterNotify: case LeaveNotify: - ScrollbarPress(clientData, eventPtr); + ScrollbarEvent(clientData, eventPtr); break; default: TkScrollbarEventProc(clientData, eventPtr); } } + +/* + * Local Variables: + * mode: objc + * c-basic-offset: 4 + * fill-column: 79 + * coding: utf-8 + * End: + */ -- cgit v0.12 From 5c1a1b06716f09718519fd8c70fd062ad96ac3a5 Mon Sep 17 00:00:00 2001 From: culler Date: Tue, 30 Oct 2018 15:49:56 +0000 Subject: Edited comments in tkMacOSXScrlbr.c --- macosx/tkMacOSXScrlbr.c | 87 +++++++++++++++++++++++++++---------------------- 1 file changed, 48 insertions(+), 39 deletions(-) diff --git a/macosx/tkMacOSXScrlbr.c b/macosx/tkMacOSXScrlbr.c index 51c9e0c..d1287bb 100644 --- a/macosx/tkMacOSXScrlbr.c +++ b/macosx/tkMacOSXScrlbr.c @@ -8,6 +8,7 @@ * Copyright 2001-2009, Apple Inc. * Copyright (c) 2006-2009 Daniel A. Steffen * Copyright (c) 2015 Kevin Walzer/WordTech Commununications LLC. + * Copyright (c) 2018 Marc Culler * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. */ @@ -26,17 +27,21 @@ #define MIN_SLIDER_LENGTH 5 -/*Borrowed from ttkMacOSXTheme.c to provide appropriate scaling of scrollbar values.*/ +/*Borrowed from ttkMacOSXTheme.c to provide appropriate scaling.*/ #ifdef __LP64__ #define RangeToFactor(maximum) (((double) (INT_MAX >> 1)) / (maximum)) #else #define RangeToFactor(maximum) (((double) (LONG_MAX >> 1)) / (maximum)) #endif /* __LP64__ */ -#define MOUNTAIN_LION_STYLE (NSAppKitVersionNumber < 1138) +/* + * Apple reversed the scroll direction with the release of OSX 10.7 Lion. + */ + +#define SNOW_LEOPARD_STYLE (NSAppKitVersionNumber < 1138) /* - * Declaration of Mac specific scrollbar structure. + * Declaration of an extended scrollbar structure with Mac specific additions. */ typedef struct MacScrollbar { @@ -48,6 +53,14 @@ typedef struct MacScrollbar { HIThemeTrackDrawInfo info; /* Controls how the scrollbar is drawn. */ } MacScrollbar; +/* Used to initialize a MacScrollbar's info field. */ +HIThemeTrackDrawInfo defaultInfo = { + .version = 0, + .min = 0.0, + .max = 100.0, + .attributes = kThemeTrackShowThumb, +}; + /* * The class procedure table for the scrollbar widget. All fields except size * are left initialized to NULL, which should happen automatically since the @@ -62,7 +75,7 @@ const Tk_ClassProcs tkpScrollbarProcs = { }; -/*Information on scrollbar layout, metrics, and draw info.*/ +/* Information on scrollbar layout, metrics, and draw info.*/ typedef struct ScrollbarMetrics { SInt32 width, minThumbHeight; int minHeight, topArrowHeight, bottomArrowHeight; @@ -74,16 +87,9 @@ static ScrollbarMetrics metrics = { 15, 54, 26, 14, 14, kControlSizeNormal /* kThemeScrollBarMedium */ }; -HIThemeTrackDrawInfo defaultInfo = { - .version = 0, - .min = 0.0, - .max = 100.0, - .attributes = kThemeTrackShowThumb, -}; - /* - * Forward declarations for procedures defined later in this file: + * Declarations of static functions defined later in this file: */ static void ScrollbarEventProc(ClientData clientData, XEvent *eventPtr); @@ -145,7 +151,7 @@ TkpCreateScrollbar( * None. * * Side effects: - * Information appears on the screen. + * Draws a scrollbar on the screen. * *-------------------------------------------------------------- */ @@ -179,7 +185,7 @@ TkpDisplayScrollbar( .ty = viewHeight}; CGContextConcatCTM(dc.context, t); - /*Draw Unix-style scroll trough to provide rect for native scrollbar.*/ + /*Draw a 3D rectangle to provide a base for the native scrollbar.*/ if (scrollPtr->highlightWidth != 0) { GC fgGC, bgGC; @@ -203,9 +209,10 @@ TkpDisplayScrollbar( Tk_Width(tkwin) - 2*scrollPtr->inset, Tk_Height(tkwin) - 2*scrollPtr->inset, 0, TK_RELIEF_FLAT); - /*Update values and draw in native rect.*/ + /* Update values and then draw the native scrollbar over the rectangle.*/ UpdateControlValues(scrollPtr); - if (MOUNTAIN_LION_STYLE) { + + if (SNOW_LEOPARD_STYLE) { HIThemeDrawTrack (&(msPtr->info), 0, dc.context, kHIThemeOrientationInverted); } else { HIThemeDrawTrack (&(msPtr->info), 0, dc.context, kHIThemeOrientationNormal); @@ -243,14 +250,16 @@ TkpComputeScrollbarGeometry( { /* - * Using code from tkUnixScrlbr.c because Unix scroll bindings are driving - * the display at the script level. All the Mac scrollbar has to do is - * re-draw itself. But we must account for some differences from Unix: on - * macOS versions newer than 10.6 (Snow Leopard) the scrollbars have no - * arrows at all. This is handled by having scrollPtr->arrowLength set to - * zero. Also on 10.6 both arrows are at the bottom. This is handled by - * shifting the scrollbar up by the arrowLength, which only has an effect on - * 10.6 since the arrowLength is 0 on newer systems. + * The code below is borrowed from tkUnixScrlbr.c but has been adjusted to + * account for some differences between macOS and X11. The Unix scrollbar + * has an arrow button on each end. On macOS 10.6 (Snow Leopard) the + * scrollbars by default have both arrow buttons at the bottom or right. + * (There is a preferences setting to use the Unix layout, but we are not + * supporting that!) On more recent versions of macOS there are no arrow + * buttons at all. The case of no arrow buttons can be handled as a special + * case of having both buttons at the end, but where scrollPtr->arrowLength + * happens to be zero. To adjust for having both arrows at the same end we + * shift the scrollbar up by the arrowLength. */ int fieldLength; @@ -295,9 +304,10 @@ TkpComputeScrollbarGeometry( scrollPtr->sliderLast += scrollPtr->inset; /* - * Register the desired geometry for the window (leave enough space for - * the two arrows plus a minimum-size slider, plus border around the whole - * window, if any). Then arrange for the window to be redisplayed. + * Register the desired geometry for the window. Leave enough space for the + * two arrows, if there are any arrows, plus a minimum-size slider, plus + * border around the whole window, if any. Then arrange for the window to + * be redisplayed. */ if (scrollPtr->vertical) { @@ -342,8 +352,6 @@ TkpDestroyScrollbar( if (macScrollPtr->copyGC != None) { Tk_FreeGC(scrollPtr->display, macScrollPtr->copyGC); } - - macScrollPtr=NULL; } /* @@ -353,13 +361,13 @@ TkpDestroyScrollbar( * * This procedure is called after the generic code has finished * processing configuration options, in order to configure platform - * specific options. + * specific options. There are no such option on the Mac, however. * * Results: * None. * * Side effects: - * Configuration info may get changed. + * Currently, none. * *---------------------------------------------------------------------- */ @@ -367,8 +375,6 @@ TkpDestroyScrollbar( void TkpConfigureScrollbar( register TkScrollbar *scrollPtr) -/* Information about widget; may or may not - * already have values for some fields. */ { } @@ -399,9 +405,8 @@ TkpScrollbarPosition( { /* - * Using code from tkUnixScrlbr.c because Unix scroll bindings are - * driving the display at the script level. All the Mac scrollbar - * has to do is re-draw itself. + * The code below is borrowed from tkUnixScrlbr.c and needs no adjustment + * since it does not involve the arrow buttons. */ int length, width, tmp; @@ -424,8 +429,10 @@ TkpScrollbarPosition( } /* - * All of the calculations in this procedure mirror those in - * TkpDisplayScrollbar. Be sure to keep the two consistent. + * Here we assume that the scrollbar is layed out with both arrow buttons + * at the bottom (or right). Except on 10.6, however, the arrows do not + * actually exist, i.e. the arrowLength is 0. These are the same + * assumptions which are being made in TkpComputeScrollbarGeometry. */ if (y < scrollPtr->sliderFirst + scrollPtr->arrowLength) { @@ -437,6 +444,7 @@ TkpScrollbarPosition( if (y < length - (2*scrollPtr->arrowLength + inset)) { return BOTTOM_GAP; } + /* On systems newer than 10.6 we have already returned. */ if (y < length - (scrollPtr->arrowLength + inset)) { return TOP_ARROW; } @@ -518,7 +526,7 @@ UpdateControlValues( factor - dViewSize; msPtr->info.trackInfo.scrollbar.viewsize = dViewSize; if (scrollPtr->vertical) { - if (MOUNTAIN_LION_STYLE) { + if (SNOW_LEOPARD_STYLE) { msPtr->info.value = factor * scrollPtr->firstFraction; } else { msPtr->info.value = msPtr->info.max - factor * scrollPtr->firstFraction; @@ -563,6 +571,7 @@ ScrollbarEvent(TkScrollbar *scrollPtr, XEvent *eventPtr) * scrollbar. However, if the mouse lies over the scrollbar but the * button is not pressed then the appearance should be the same as if * the button had been pressed on the slider, i.e. kThemeThumbPressed. + * See the file Appearance.r, or HIToolbox.bridgesupport on 10.14. */ if (eventPtr->type == ButtonPress) { -- cgit v0.12 From 152ed2f3e133afff91df91511ab181f3a7fe9153 Mon Sep 17 00:00:00 2001 From: fvogel Date: Tue, 30 Oct 2018 22:07:48 +0000 Subject: Added tests checking that <> fires on destruction of the last managed child --- tests/grid.test | 34 +++++++++++++++++++++------------- tests/pack.test | 22 ++++++++++++++++------ 2 files changed, 37 insertions(+), 19 deletions(-) diff --git a/tests/grid.test b/tests/grid.test index e55f866..5f2a4f8 100644 --- a/tests/grid.test +++ b/tests/grid.test @@ -2031,7 +2031,6 @@ test grid-24.1 {<> fires on last grid forget} -body { bind . <> {} grid_reset 24.1 } -result {1} - test grid-24.2 {<> fires on last grid remove} -body { global A catch {unset A} @@ -2045,8 +2044,20 @@ test grid-24.2 {<> fires on last grid remove} -body { bind . <> {} grid_reset 24.2 } -result {1} - -test grid-24.3 { does not fire on last grid forget} -body { +test grid-24.3 {<> fires on last gridded child destruction} -body { + global A + catch {unset A} + grid [frame .1] + update + bind . <> {incr A} + destroy .1 + update + set A +} -cleanup { + bind . <> {} + grid_reset 24.3 +} -result {1} +test grid-24.4 { does not fire on last grid forget} -body { global A catch {unset A} grid [frame .1] @@ -2057,10 +2068,9 @@ test grid-24.3 { does not fire on last grid forget} -body { info exists A } -cleanup { bind . {} - grid_reset 24.3 + grid_reset 24.4 } -result {0} - -test grid-24.4 { fires on forelast grid forget} -body { +test grid-24.5 { fires on forelast grid forget} -body { global A catch {unset A} grid [frame .1] @@ -2072,10 +2082,9 @@ test grid-24.4 { fires on forelast grid forget} -body { info exists A } -cleanup { bind . {} - grid_reset 24.4 + grid_reset 24.5 } -result {1} - -test grid-24.5 {<> does not fire on forelast grid forget} -body { +test grid-24.6 {<> does not fire on forelast grid forget} -body { global A catch {unset A} grid [frame .1] @@ -2087,10 +2096,9 @@ test grid-24.5 {<> does not fire on forelast grid forget} -body info exists A } -cleanup { bind . <> {} - grid_reset 24.5 + grid_reset 24.6 } -result {0} - -test grid-24.6 {<> does not fire on grid anchor} -body { +test grid-24.7 {<> does not fire on grid anchor} -body { global A bind . <> {set A 1} grid anchor . w @@ -2099,7 +2107,7 @@ test grid-24.6 {<> does not fire on grid anchor} -body { } -cleanup { grid anchor . nw bind . <> {} - grid_reset 24.6 + grid_reset 24.7 } -result {0} diff --git a/tests/pack.test b/tests/pack.test index 061ea03..4f7c7c9 100644 --- a/tests/pack.test +++ b/tests/pack.test @@ -1639,8 +1639,20 @@ test pack-20.1 {<> fires on last pack forget} -body { bind . <> {} destroy .1 } -result {1} - -test pack-20.2 { does not fire on last pack forget} -body { +test pack-20.2 {<> fires on last packed child destruction} -body { + global A + catch {unset A} + pack [frame .1] + update + bind . <> {incr A} + destroy .1 + update + set A +} -cleanup { + bind . <> {} + destroy .1 +} -result {1} +test pack-20.3 { does not fire on last pack forget} -body { global A catch {unset A} pack [frame .1] @@ -1653,8 +1665,7 @@ test pack-20.2 { does not fire on last pack forget} -body { bind . {} destroy .1 } -result {0} - -test pack-20.3 {<> does not fire on forelast pack forget} -body { +test pack-20.4 {<> does not fire on forelast pack forget} -body { global A catch {unset A} pack [frame .1] @@ -1668,8 +1679,7 @@ test pack-20.3 {<> does not fire on forelast pack forget} -body bind . <> {} destroy .1 .2 } -result {0} - -test pack-20.4 { does not fire on last pack forget} -body { +test pack-20.5 { does not fire on last pack forget} -body { global A catch {unset A} pack [frame .1] -- cgit v0.12 From 4487c0a2445e26b62e29558edc6ef05c799c4fba Mon Sep 17 00:00:00 2001 From: fvogel Date: Tue, 30 Oct 2018 22:55:31 +0000 Subject: Add tests for the 'propagate off' case of pack and grid --- tests/grid.test | 15 +++++++++++++++ tests/pack.test | 14 ++++++++++++++ 2 files changed, 29 insertions(+) diff --git a/tests/grid.test b/tests/grid.test index 5f2a4f8..444f60f 100644 --- a/tests/grid.test +++ b/tests/grid.test @@ -2100,6 +2100,7 @@ test grid-24.6 {<> does not fire on forelast grid forget} -body } -result {0} test grid-24.7 {<> does not fire on grid anchor} -body { global A + catch {unset A} bind . <> {set A 1} grid anchor . w update @@ -2109,6 +2110,20 @@ test grid-24.7 {<> does not fire on grid anchor} -body { bind . <> {} grid_reset 24.7 } -result {0} +test grid-24.8 {<> does not fire on last grid forget if propagation is off} -body { + global A + catch {unset A} + grid [frame .1] + grid propagate . 0 + update + bind . <> {set A 1} + grid forget .1 + update + info exists A +} -cleanup { + bind . <> {} + grid_reset 24.8 +} -result {0} # cleanup diff --git a/tests/pack.test b/tests/pack.test index 4f7c7c9..22b5cbb 100644 --- a/tests/pack.test +++ b/tests/pack.test @@ -1693,6 +1693,20 @@ test pack-20.5 { does not fire on last pack forget} -body { bind . {} destroy .1 .2 } -result {1} +test pack-20.6 {<> does not fire on last pack forget if propagation is off} -body { + global A + catch {unset A} + pack [frame .1] + pack propagate . 0 + update + bind . <> {set A 1} + pack forget .1 + update + info exists A +} -cleanup { + bind . <> {} + destroy .1 +} -result {0} # cleanup -- cgit v0.12 From 7144128999f3ac6624e08c35f4c28ba1b9f10686 Mon Sep 17 00:00:00 2001 From: culler Date: Thu, 1 Nov 2018 02:52:36 +0000 Subject: Prevent recursive calls to [TKContentView drawRect]. --- macosx/tkMacOSXWindowEvent.c | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/macosx/tkMacOSXWindowEvent.c b/macosx/tkMacOSXWindowEvent.c index a9ab855..0927693 100644 --- a/macosx/tkMacOSXWindowEvent.c +++ b/macosx/tkMacOSXWindowEvent.c @@ -237,7 +237,7 @@ extern NSString *NSWindowDidOrderOffScreenNotification; observe(NSWindowDidOrderOffScreenNotification, windowUnmapped:); #endif #undef observe - + } @end @@ -828,10 +828,18 @@ ConfigureRestrictProc( #ifdef TK_MAC_DEBUG_DRAWING TkWindow *winPtr = TkMacOSXGetTkWindow([self window]); - if (winPtr) printf("drawRect: drawing %s\n", Tk_PathName(winPtr)); + if (winPtr) fprintf(stderr, "drawRect: drawing %s\n", + Tk_PathName(winPtr)); #endif - + + /* + * We do not allow recursive calls to drawRect. + */ + if ([NSApp isDrawing]) { + return; + } [NSApp setIsDrawing: YES]; + [self getRectsBeingDrawn:&rectsBeingDrawn count:&rectsBeingDrawnCount]; CGFloat height = [self bounds].size.height; HIMutableShapeRef drawShape = HIShapeCreateMutable(); @@ -840,7 +848,7 @@ ConfigureRestrictProc( CGRect r = NSRectToCGRect(*rectsBeingDrawn++); #ifdef TK_MAC_DEBUG_DRAWING - printf("drawRect: %dx%d@(%d,%d)\n", (int)r.size.width, + fprintf(stderr, "drawRect: %dx%d@(%d,%d)\n", (int)r.size.width, (int)r.size.height, (int)r.origin.x, (int)r.origin.y); #endif @@ -852,7 +860,7 @@ ConfigureRestrictProc( [NSApp setIsDrawing: NO]; #ifdef TK_MAC_DEBUG_DRAWING - printf("drawRect: done.\n"); + fprintf(stderr, "drawRect: done.\n"); #endif } @@ -973,7 +981,7 @@ ConfigureRestrictProc( } } - + /* * These two methods allow Tk to register a virtual event which fires when the * appearance changes on 10.14. -- cgit v0.12 From 61f5248dd6034c464882f9f33e557e0169a395b9 Mon Sep 17 00:00:00 2001 From: culler Date: Thu, 1 Nov 2018 12:46:14 +0000 Subject: Be consistent about using TKLog and add one new log message. --- macosx/tkMacOSXKeyEvent.c | 20 ++++++++++---------- macosx/tkMacOSXWindowEvent.c | 3 ++- macosx/tkMacOSXWm.c | 2 +- 3 files changed, 13 insertions(+), 12 deletions(-) diff --git a/macosx/tkMacOSXKeyEvent.c b/macosx/tkMacOSXKeyEvent.c index 22842b3..f79185e 100644 --- a/macosx/tkMacOSXKeyEvent.c +++ b/macosx/tkMacOSXKeyEvent.c @@ -91,7 +91,7 @@ unsigned short releaseCode; // w = [self windowWithWindowNumber:[theEvent windowNumber]]; w = [theEvent window]; #if defined(TK_MAC_DEBUG_EVENTS) || NS_KEYLOG == 1 - NSLog(@"-[%@(%p) %s] r=%d mods=%u '%@' '%@' code=%u c=%d %@ %d", [self class], self, _cmd, repeat, modifiers, characters, charactersIgnoringModifiers, keyCode,([charactersIgnoringModifiers length] == 0) ? 0 : [charactersIgnoringModifiers characterAtIndex: 0], w, type); + TKLog(@"-[%@(%p) %s] r=%d mods=%u '%@' '%@' code=%u c=%d %@ %d", [self class], self, _cmd, repeat, modifiers, characters, charactersIgnoringModifiers, keyCode,([charactersIgnoringModifiers length] == 0) ? 0 : [charactersIgnoringModifiers characterAtIndex: 0], w, type); #endif break; @@ -246,7 +246,7 @@ unsigned short releaseCode; XEvent xEvent; if (NS_KEYLOG) - NSLog (@"insertText '%@'\tlen = %d", aString, len); + TKLog (@"insertText '%@'\tlen = %d", aString, len); processingCompose = NO; finishedCompose = YES; @@ -279,7 +279,7 @@ unsigned short releaseCode; NSString *str = [aString respondsToSelector: @selector (string)] ? [aString string] : aString; if (NS_KEYLOG) - NSLog (@"setMarkedText '%@' len =%lu range %lu from %lu", str, + TKLog (@"setMarkedText '%@' len =%lu range %lu from %lu", str, (unsigned long) [str length], (unsigned long) selRange.length, (unsigned long) selRange.location); @@ -306,7 +306,7 @@ unsigned short releaseCode; NSRange rng = privateWorkingText != nil ? NSMakeRange (0, [privateWorkingText length]) : NSMakeRange (NSNotFound, 0); if (NS_KEYLOG) - NSLog (@"markedRange request"); + TKLog (@"markedRange request"); return rng; } @@ -314,7 +314,7 @@ unsigned short releaseCode; - (void)unmarkText { if (NS_KEYLOG) - NSLog (@"unmark (accept) text"); + TKLog (@"unmark (accept) text"); [self deleteWorkingText]; processingCompose = NO; } @@ -349,7 +349,7 @@ unsigned short releaseCode; - (void)doCommandBySelector: (SEL)aSelector { if (NS_KEYLOG) - NSLog (@"doCommandBySelector: %@", NSStringFromSelector (aSelector)); + TKLog (@"doCommandBySelector: %@", NSStringFromSelector (aSelector)); processingCompose = NO; if (aSelector == @selector (deleteBackward:)) { @@ -379,7 +379,7 @@ unsigned short releaseCode; - (NSRange)selectedRange { if (NS_KEYLOG) - NSLog (@"selectedRange request"); + TKLog (@"selectedRange request"); return NSMakeRange (NSNotFound, 0); } @@ -387,7 +387,7 @@ unsigned short releaseCode; - (NSUInteger)characterIndexForPoint: (NSPoint)thePoint { if (NS_KEYLOG) - NSLog (@"characterIndexForPoint request"); + TKLog (@"characterIndexForPoint request"); return 0; } @@ -397,7 +397,7 @@ unsigned short releaseCode; static NSAttributedString *str = nil; if (str == nil) str = [NSAttributedString new]; if (NS_KEYLOG) - NSLog (@"attributedSubstringFromRange request"); + TKLog (@"attributedSubstringFromRange request"); return str; } /* End impl. */ @@ -411,7 +411,7 @@ unsigned short releaseCode; if (privateWorkingText == nil) return; if (NS_KEYLOG) - NSLog(@"deleteWorkingText len = %lu\n", + TKLog(@"deleteWorkingText len = %lu\n", (unsigned long)[privateWorkingText length]); [privateWorkingText release]; privateWorkingText = nil; diff --git a/macosx/tkMacOSXWindowEvent.c b/macosx/tkMacOSXWindowEvent.c index 0927693..3e22311 100644 --- a/macosx/tkMacOSXWindowEvent.c +++ b/macosx/tkMacOSXWindowEvent.c @@ -386,7 +386,7 @@ GenerateUpdates( Tk_QueueWindowEvent(&event, TCL_QUEUE_TAIL); #ifdef TK_MAC_DEBUG_DRAWING - NSLog(@"Expose %p {{%d, %d}, {%d, %d}}", event.xany.window, event.xexpose.x, + TKLog(@"Expose %p {{%d, %d}, {%d, %d}}", event.xany.window, event.xexpose.x, event.xexpose.y, event.xexpose.width, event.xexpose.height); #endif @@ -836,6 +836,7 @@ ConfigureRestrictProc( * We do not allow recursive calls to drawRect. */ if ([NSApp isDrawing]) { + TKLog(@"WARNING: a recursive call to drawRect was aborted."); return; } [NSApp setIsDrawing: YES]; diff --git a/macosx/tkMacOSXWm.c b/macosx/tkMacOSXWm.c index 792e8b8..d0f8b24 100644 --- a/macosx/tkMacOSXWm.c +++ b/macosx/tkMacOSXWm.c @@ -411,7 +411,7 @@ NSStatusItem *exitFullScreen; TkMacOSXMakeFullscreen(winPtr, self, 1, interp); } } else { - NSLog (@"toggleFullScreen is ignored by Tk on OSX versions < 10.13"); + TKLog (@"toggleFullScreen is ignored by Tk on OSX versions < 10.13"); } } -- cgit v0.12 From baa04a4d9d77fed49102c75bb6f00d4e19a12ef3 Mon Sep 17 00:00:00 2001 From: culler Date: Thu, 1 Nov 2018 13:07:53 +0000 Subject: Use stderr when printing debug messages to the terminal. --- macosx/tkMacOSXNotify.c | 7 ++++--- macosx/tkMacOSXWm.c | 3 ++- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/macosx/tkMacOSXNotify.c b/macosx/tkMacOSXNotify.c index c14bea7..e276926 100644 --- a/macosx/tkMacOSXNotify.c +++ b/macosx/tkMacOSXNotify.c @@ -90,7 +90,8 @@ InspectQueueRestrictProc( } else { name = Tk_EventName[eventPtr->type]; } - printf(" > %s;serial = %lu; time=%lu)\n", name, serial, time); + fprintf(stderr, " > %s;serial = %lu; time=%lu)\n", + name, serial, time); return TK_DEFER_EVENT; } @@ -104,7 +105,7 @@ void DebugPrintQueue(void) Tk_RestrictProc *oldProc; oldProc = Tk_RestrictEvents(InspectQueueRestrictProc, NULL, &oldArg); - printf("Current queue:\n"); + fprintf(stderr, "Current queue:\n"); while (Tcl_DoOneEvent(TCL_ALL_EVENTS|TCL_DONT_WAIT)) {}; Tk_RestrictEvents(oldProc, oldArg, &oldArg); } @@ -146,7 +147,7 @@ void DebugPrintQueue(void) [super sendEvent:theEvent]; [NSApp tkCheckPasteboard]; #ifdef TK_MAC_DEBUG_EVENTS - printf("Sending event of type %d\n", (int)[theEvent type]); + fprintf(stderr, "Sending event of type %d\n", (int)[theEvent type]); DebugPrintQueue(); #endif } diff --git a/macosx/tkMacOSXWm.c b/macosx/tkMacOSXWm.c index d0f8b24..5dcc075 100644 --- a/macosx/tkMacOSXWm.c +++ b/macosx/tkMacOSXWm.c @@ -448,7 +448,8 @@ NSStatusItem *exitFullScreen; title = "unnamed window"; } if (DEBUG_ZOMBIES > 1){ - printf("Retained <%s>. Count is: %lu\n", title, [self retainCount]); + fprintf(stderr, "Retained <%s>. Count is: %lu\n", + title, [self retainCount]); } return result; } -- cgit v0.12 From a51b941358414d42870614bacdbae8478fcd9f39 Mon Sep 17 00:00:00 2001 From: dgp Date: Thu, 1 Nov 2018 15:37:14 +0000 Subject: Eliminate fallback attempts when broken strtod() routines are detected. This has long been creating more problems than it solves. Eliminate the ancient fixstrtod fallback that is damaging cross-compiling. --- unix/configure | 261 ++---------------------------------------------------- unix/configure.in | 9 -- unix/tcl.m4 | 53 ----------- 3 files changed, 6 insertions(+), 317 deletions(-) diff --git a/unix/configure b/unix/configure index 1259c92..d767de1 100755 --- a/unix/configure +++ b/unix/configure @@ -7465,70 +7465,6 @@ _ACEOF fi - echo "$as_me:$LINENO: checking for DIR64" >&5 -echo $ECHO_N "checking for DIR64... $ECHO_C" >&6 -if test "${tcl_cv_DIR64+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -#include -#include -int -main () -{ -struct dirent64 *p; DIR64 d = opendir64("."); - p = readdir64(d); rewinddir64(d); closedir64(d); - ; - return 0; -} -_ACEOF -rm -f conftest.$ac_objext -if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 - (eval $ac_compile) 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" - || test ! -s conftest.err' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - tcl_cv_DIR64=yes -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - -tcl_cv_DIR64=no -fi -rm -f conftest.err conftest.$ac_objext conftest.$ac_ext -fi -echo "$as_me:$LINENO: result: $tcl_cv_DIR64" >&5 -echo "${ECHO_T}$tcl_cv_DIR64" >&6 - if test "x${tcl_cv_DIR64}" = "xyes" ; then - -cat >>confdefs.h <<\_ACEOF -#define HAVE_DIR64 1 -_ACEOF - - fi - echo "$as_me:$LINENO: checking for struct stat64" >&5 echo $ECHO_N "checking for struct stat64... $ECHO_C" >&6 if test "${tcl_cv_struct_stat64+set}" = set; then @@ -8351,191 +8287,6 @@ fi #-------------------------------------------------------------------- -# Under Solaris 2.4, strtod returns the wrong value for the -# terminating character under some conditions. Check for this -# and if the problem exists use a substitute procedure -# "fixstrtod" (provided by Tcl) that corrects the error. -#-------------------------------------------------------------------- - - - echo "$as_me:$LINENO: checking for strtod" >&5 -echo $ECHO_N "checking for strtod... $ECHO_C" >&6 -if test "${ac_cv_func_strtod+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -/* Define strtod to an innocuous variant, in case declares strtod. - For example, HP-UX 11i declares gettimeofday. */ -#define strtod innocuous_strtod - -/* System header to define __stub macros and hopefully few prototypes, - which can conflict with char strtod (); below. - Prefer to if __STDC__ is defined, since - exists even on freestanding compilers. */ - -#ifdef __STDC__ -# include -#else -# include -#endif - -#undef strtod - -/* Override any gcc2 internal prototype to avoid an error. */ -#ifdef __cplusplus -extern "C" -{ -#endif -/* We use char because int might match the return type of a gcc2 - builtin and then its argument prototype would still apply. */ -char strtod (); -/* The GNU C library defines this for functions which it implements - to always fail with ENOSYS. Some functions are actually named - something starting with __ and the normal name is an alias. */ -#if defined (__stub_strtod) || defined (__stub___strtod) -choke me -#else -char (*f) () = strtod; -#endif -#ifdef __cplusplus -} -#endif - -int -main () -{ -return f != strtod; - ; - return 0; -} -_ACEOF -rm -f conftest.$ac_objext conftest$ac_exeext -if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 - (eval $ac_link) 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" - || test ! -s conftest.err' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest$ac_exeext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - ac_cv_func_strtod=yes -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - -ac_cv_func_strtod=no -fi -rm -f conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext -fi -echo "$as_me:$LINENO: result: $ac_cv_func_strtod" >&5 -echo "${ECHO_T}$ac_cv_func_strtod" >&6 -if test $ac_cv_func_strtod = yes; then - tcl_strtod=1 -else - tcl_strtod=0 -fi - - if test "$tcl_strtod" = 1; then - echo "$as_me:$LINENO: checking for Solaris2.4/Tru64 strtod bugs" >&5 -echo $ECHO_N "checking for Solaris2.4/Tru64 strtod bugs... $ECHO_C" >&6 -if test "${tcl_cv_strtod_buggy+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - - if test "$cross_compiling" = yes; then - tcl_cv_strtod_buggy=buggy -else - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ - - extern double strtod(); - int main() { - char *infString="Inf", *nanString="NaN", *spaceString=" "; - char *term; - double value; - value = strtod(infString, &term); - if ((term != infString) && (term[-1] == 0)) { - exit(1); - } - value = strtod(nanString, &term); - if ((term != nanString) && (term[-1] == 0)) { - exit(1); - } - value = strtod(spaceString, &term); - if (term == (spaceString+1)) { - exit(1); - } - exit(0); - } -_ACEOF -rm -f conftest$ac_exeext -if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 - (eval $ac_link) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { ac_try='./conftest$ac_exeext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - tcl_cv_strtod_buggy=ok -else - echo "$as_me: program exited with status $ac_status" >&5 -echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - -( exit $ac_status ) -tcl_cv_strtod_buggy=buggy -fi -rm -f core *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext -fi -fi -echo "$as_me:$LINENO: result: $tcl_cv_strtod_buggy" >&5 -echo "${ECHO_T}$tcl_cv_strtod_buggy" >&6 - if test "$tcl_cv_strtod_buggy" = buggy; then - case $LIBOBJS in - "fixstrtod.$ac_objext" | \ - *" fixstrtod.$ac_objext" | \ - "fixstrtod.$ac_objext "* | \ - *" fixstrtod.$ac_objext "* ) ;; - *) LIBOBJS="$LIBOBJS fixstrtod.$ac_objext" ;; -esac - - USE_COMPAT=1 - -cat >>confdefs.h <<\_ACEOF -#define strtod fixstrtod -_ACEOF - - fi - fi - - -#-------------------------------------------------------------------- # Check for various typedefs and provide substitutes if # they don't exist. #-------------------------------------------------------------------- @@ -9710,7 +9461,7 @@ ac_x_header_dirs=' /usr/openwin/share/include' if test "$ac_x_includes" = no; then - # Guess where to find include files, by looking for Xlib.h. + # Guess where to find include files, by looking for Intrinsic.h. # First, try using that file with no special directory specified. cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ @@ -9718,7 +9469,7 @@ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ -#include +#include _ACEOF if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 @@ -9745,7 +9496,7 @@ else sed 's/^/| /' conftest.$ac_ext >&5 for ac_dir in $ac_x_header_dirs; do - if test -r "$ac_dir/X11/Xlib.h"; then + if test -r "$ac_dir/X11/Intrinsic.h"; then ac_x_includes=$ac_dir break fi @@ -9759,18 +9510,18 @@ if test "$ac_x_libraries" = no; then # See if we find them without any special options. # Don't add to $LIBS permanently. ac_save_LIBS=$LIBS - LIBS="-lX11 $LIBS" + LIBS="-lXt $LIBS" cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ -#include +#include int main () { -XrmInitialize () +XtMalloc (0) ; return 0; } diff --git a/unix/configure.in b/unix/configure.in index a2ed566..523de3c 100644 --- a/unix/configure.in +++ b/unix/configure.in @@ -197,15 +197,6 @@ AC_CHECK_HEADERS(sys/time.h) AC_HEADER_TIME #-------------------------------------------------------------------- -# Under Solaris 2.4, strtod returns the wrong value for the -# terminating character under some conditions. Check for this -# and if the problem exists use a substitute procedure -# "fixstrtod" (provided by Tcl) that corrects the error. -#-------------------------------------------------------------------- - -SC_BUGGY_STRTOD - -#-------------------------------------------------------------------- # Check for various typedefs and provide substitutes if # they don't exist. #-------------------------------------------------------------------- diff --git a/unix/tcl.m4 b/unix/tcl.m4 index 0ee12f9..e429a79 100644 --- a/unix/tcl.m4 +++ b/unix/tcl.m4 @@ -2398,59 +2398,6 @@ AC_DEFUN([SC_TIME_HANDLER], [ ]) #-------------------------------------------------------------------- -# SC_BUGGY_STRTOD -# -# Under Solaris 2.4, strtod returns the wrong value for the -# terminating character under some conditions. Check for this -# and if the problem exists use a substitute procedure -# "fixstrtod" (provided by Tcl) that corrects the error. -# Also, on Compaq's Tru64 Unix 5.0, -# strtod(" ") returns 0.0 instead of a failure to convert. -# -# Arguments: -# none -# -# Results: -# -# Might defines some of the following vars: -# strtod (=fixstrtod) -# -#-------------------------------------------------------------------- - -AC_DEFUN([SC_BUGGY_STRTOD], [ - AC_CHECK_FUNC(strtod, tcl_strtod=1, tcl_strtod=0) - if test "$tcl_strtod" = 1; then - AC_CACHE_CHECK([for Solaris2.4/Tru64 strtod bugs], tcl_cv_strtod_buggy,[ - AC_TRY_RUN([ - extern double strtod(); - int main() { - char *infString="Inf", *nanString="NaN", *spaceString=" "; - char *term; - double value; - value = strtod(infString, &term); - if ((term != infString) && (term[-1] == 0)) { - exit(1); - } - value = strtod(nanString, &term); - if ((term != nanString) && (term[-1] == 0)) { - exit(1); - } - value = strtod(spaceString, &term); - if (term == (spaceString+1)) { - exit(1); - } - exit(0); - }], tcl_cv_strtod_buggy=ok, tcl_cv_strtod_buggy=buggy, - tcl_cv_strtod_buggy=buggy)]) - if test "$tcl_cv_strtod_buggy" = buggy; then - AC_LIBOBJ([fixstrtod]) - USE_COMPAT=1 - AC_DEFINE(strtod, fixstrtod, [Do we want to use the strtod() in compat?]) - fi - fi -]) - -#-------------------------------------------------------------------- # SC_TCL_LINK_LIBS # # Search for the libraries needed to link the Tcl shell. -- cgit v0.12 From fa21ce780259a60f2fff50e1842ab4ef920b276c Mon Sep 17 00:00:00 2001 From: dgp Date: Thu, 1 Nov 2018 15:50:41 +0000 Subject: update changes --- changes | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/changes b/changes index c460a96..5b2153a 100644 --- a/changes +++ b/changes @@ -7560,4 +7560,10 @@ Tk Cocoa 2.0: More drawing internals refinements (culler,walzer) 2018-10-06 (bug)[9658bc] borderwidth calculations on menu items (vogel) -- Released 8.6.9, October 17, 2018 - http://core.tcl-lang.org/tk/ for details - +2018-10-17 (bug)[ca403f] treeview border drawing (vogel) + +2018-10-17 (bug)[4b555a] hang in [$text search -all] (vogel) + +2018-10-30 (new) port to system changes in Mac OSX 10.14 (culler) + +- Released 8.6.9, November 9, 2018 - http://core.tcl-lang.org/tk/ for details - -- cgit v0.12 From 12e92c72776007d77bc4669f9a8a041e40a2679d Mon Sep 17 00:00:00 2001 From: dgp Date: Thu, 1 Nov 2018 16:39:38 +0000 Subject: update changes --- changes | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/changes b/changes index 5b2153a..4e9e5e9 100644 --- a/changes +++ b/changes @@ -7562,8 +7562,8 @@ Tk Cocoa 2.0: More drawing internals refinements (culler,walzer) 2018-10-17 (bug)[ca403f] treeview border drawing (vogel) -2018-10-17 (bug)[4b555a] hang in [$text search -all] (vogel) +2018-10-17 (bug)[4b555a] hang in [$text search -all] (vogel,danckaert) -2018-10-30 (new) port to system changes in Mac OSX 10.14 (culler) +2018-10-30 (new platform) port to system changes in Mac OSX 10.14 (culler) - Released 8.6.9, November 9, 2018 - http://core.tcl-lang.org/tk/ for details - -- cgit v0.12 From e1149ae012b3ab64f0076dc7651ffcf87e5bbdce Mon Sep 17 00:00:00 2001 From: dgp Date: Thu, 1 Nov 2018 18:06:40 +0000 Subject: make dist --- generic/tkIntPlatDecls.h | 2 +- unix/tkConfig.h.in | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/generic/tkIntPlatDecls.h b/generic/tkIntPlatDecls.h index c666e3d..ded5ac5 100644 --- a/generic/tkIntPlatDecls.h +++ b/generic/tkIntPlatDecls.h @@ -383,7 +383,7 @@ typedef struct TkIntPlatStubs { void (*tkMacOSXWindowOffset) (void *wRef, int *xOffset, int *yOffset); /* 37 */ int (*tkSetMacColor) (unsigned long pixel, void *macColor); /* 38 */ void (*tkSetWMName) (TkWindow *winPtr, Tk_Uid titleUid); /* 39 */ - void (*reserved40) (void); + void (*reserved40)(void); int (*tkMacOSXZoomToplevel) (void *whichWindow, short zoomPart); /* 41 */ Tk_Window (*tk_TopCoordsToWindow) (Tk_Window tkwin, int rootX, int rootY, int *newX, int *newY); /* 42 */ MacDrawable * (*tkMacOSXContainerId) (TkWindow *winPtr); /* 43 */ diff --git a/unix/tkConfig.h.in b/unix/tkConfig.h.in index 4fd7726..72d97c8 100644 --- a/unix/tkConfig.h.in +++ b/unix/tkConfig.h.in @@ -13,6 +13,9 @@ /* Do we have access to Darwin CoreFoundation.framework? */ #undef HAVE_COREFOUNDATION +/* Is 'DIR64' in ? */ +#undef HAVE_DIR64 + /* Compiler support for module scope symbols */ #undef HAVE_HIDDEN @@ -238,9 +241,6 @@ /* Define to `unsigned' if does not define. */ #undef size_t -/* Do we want to use the strtod() in compat? */ -#undef strtod - /* Define to `int' if doesn't define. */ #undef uid_t -- cgit v0.12 From a3de6291935a349da5c1e61af13b19df5b1d31ee Mon Sep 17 00:00:00 2001 From: fvogel Date: Thu, 1 Nov 2018 21:29:32 +0000 Subject: Fix [6b22d436aa]: Treeview ActivateHeading Binding Fails After Widget Deletion. Thanks to Brian O'Hagan for the report and the patch. --- library/ttk/treeview.tcl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/ttk/treeview.tcl b/library/ttk/treeview.tcl index 8772587..1ed87db 100644 --- a/library/ttk/treeview.tcl +++ b/library/ttk/treeview.tcl @@ -120,7 +120,7 @@ proc ttk::treeview::ActivateHeading {w heading} { variable State if {$w != $State(activeWidget) || $heading != $State(activeHeading)} { - if {$State(activeHeading) != {}} { + if {[winfo exists $State(activeWidget)] && $State(activeHeading) != {}} { $State(activeWidget) heading $State(activeHeading) state !active } if {$heading != {}} { -- cgit v0.12 From 244f2d89858e2a2bb09c69bb564618a4a2b87fc1 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Sat, 3 Nov 2018 16:21:59 +0000 Subject: Add support for DragonFly. And use X11 headers, not Xt --- unix/configure | 16 ++++++++-------- unix/tcl.m4 | 4 ++-- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/unix/configure b/unix/configure index d767de1..8466d3d 100755 --- a/unix/configure +++ b/unix/configure @@ -5417,7 +5417,7 @@ fi fi ;; - FreeBSD-*) + DragonFly-*|FreeBSD-*) # This configuration from FreeBSD Ports. SHLIB_CFLAGS="-fPIC" SHLIB_LD="${CC} -shared" @@ -6625,7 +6625,7 @@ fi BSD/OS*) ;; CYGWIN_*|MINGW32_*) ;; IRIX*) ;; - NetBSD-*|FreeBSD-*|OpenBSD-*) ;; + NetBSD-*|DragonFly-*|FreeBSD-*|OpenBSD-*) ;; Darwin-*) ;; SCO_SV-3.2*) ;; *) SHLIB_CFLAGS="-fPIC" ;; @@ -9461,7 +9461,7 @@ ac_x_header_dirs=' /usr/openwin/share/include' if test "$ac_x_includes" = no; then - # Guess where to find include files, by looking for Intrinsic.h. + # Guess where to find include files, by looking for Xlib.h. # First, try using that file with no special directory specified. cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ @@ -9469,7 +9469,7 @@ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ -#include +#include _ACEOF if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 @@ -9496,7 +9496,7 @@ else sed 's/^/| /' conftest.$ac_ext >&5 for ac_dir in $ac_x_header_dirs; do - if test -r "$ac_dir/X11/Intrinsic.h"; then + if test -r "$ac_dir/X11/Xlib.h"; then ac_x_includes=$ac_dir break fi @@ -9510,18 +9510,18 @@ if test "$ac_x_libraries" = no; then # See if we find them without any special options. # Don't add to $LIBS permanently. ac_save_LIBS=$LIBS - LIBS="-lXt $LIBS" + LIBS="-lX11 $LIBS" cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ -#include +#include int main () { -XtMalloc (0) +XrmInitialize () ; return 0; } diff --git a/unix/tcl.m4 b/unix/tcl.m4 index e429a79..1953798 100644 --- a/unix/tcl.m4 +++ b/unix/tcl.m4 @@ -1516,7 +1516,7 @@ AC_DEFUN([SC_CONFIG_CFLAGS], [ LDFLAGS="$LDFLAGS -pthread" ]) ;; - FreeBSD-*) + DragonFly-*|FreeBSD-*) # This configuration from FreeBSD Ports. SHLIB_CFLAGS="-fPIC" SHLIB_LD="${CC} -shared" @@ -2012,7 +2012,7 @@ dnl # preprocessing tests use only CPPFLAGS. BSD/OS*) ;; CYGWIN_*|MINGW32_*) ;; IRIX*) ;; - NetBSD-*|FreeBSD-*|OpenBSD-*) ;; + NetBSD-*|DragonFly-*|FreeBSD-*|OpenBSD-*) ;; Darwin-*) ;; SCO_SV-3.2*) ;; *) SHLIB_CFLAGS="-fPIC" ;; -- cgit v0.12 From bf6376a2e045cc8245b54c5ea9ef563c3cfb3bf4 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Sat, 3 Nov 2018 16:23:24 +0000 Subject: Deprecate Tk_MainEx() stub entry (TIP #512). Only has effect if compiled with TK_NO_DEPRECATED=1 --- generic/tk.decls | 2 +- generic/tkDecls.h | 2 +- generic/tkWindow.c | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/generic/tk.decls b/generic/tk.decls index 16de241..9619416 100644 --- a/generic/tk.decls +++ b/generic/tk.decls @@ -805,7 +805,7 @@ declare 211 { int Tk_InitOptions(Tcl_Interp *interp, void *recordPtr, Tk_OptionTable optionToken, Tk_Window tkwin) } -declare 212 { +declare 212 {nostub {Don't use this function in a stub-enabled extension}} { void Tk_MainEx(int argc, char **argv, Tcl_AppInitProc *appInitProc, Tcl_Interp *interp) } diff --git a/generic/tkDecls.h b/generic/tkDecls.h index eb3af95..0d52f2f 100644 --- a/generic/tkDecls.h +++ b/generic/tkDecls.h @@ -1102,7 +1102,7 @@ typedef struct TkStubs { int (*tk_GetReliefFromObj) (Tcl_Interp *interp, Tcl_Obj *objPtr, int *resultPtr); /* 209 */ int (*tk_GetScrollInfoObj) (Tcl_Interp *interp, int objc, Tcl_Obj *const objv[], double *dblPtr, int *intPtr); /* 210 */ int (*tk_InitOptions) (Tcl_Interp *interp, void *recordPtr, Tk_OptionTable optionToken, Tk_Window tkwin); /* 211 */ - void (*tk_MainEx) (int argc, char **argv, Tcl_AppInitProc *appInitProc, Tcl_Interp *interp); /* 212 */ + TCL_DEPRECATED_API("Don't use this function in a stub-enabled extension") void (*tk_MainEx) (int argc, char **argv, Tcl_AppInitProc *appInitProc, Tcl_Interp *interp); /* 212 */ void (*tk_RestoreSavedOptions) (Tk_SavedOptions *savePtr); /* 213 */ int (*tk_SetOptions) (Tcl_Interp *interp, void *recordPtr, Tk_OptionTable optionTable, int objc, Tcl_Obj *const objv[], Tk_Window tkwin, Tk_SavedOptions *savePtr, int *maskPtr); /* 214 */ void (*tk_InitConsoleChannels) (Tcl_Interp *interp); /* 215 */ diff --git a/generic/tkWindow.c b/generic/tkWindow.c index d36313b..198c2d7 100644 --- a/generic/tkWindow.c +++ b/generic/tkWindow.c @@ -2834,7 +2834,7 @@ static HMODULE tkcygwindll = NULL; /* * Run Tk_MainEx from libtk8.?.dll * - * This function is only ever called from wish8.4.exe, the cygwin port of Tcl. + * This function is only ever called from wish8.?.exe, the cygwin port of Tcl. * This means that the system encoding is utf-8, so we don't have to do any * encoding conversions. */ @@ -2850,7 +2850,7 @@ TkCygwinMainEx( Tcl_Interp *interp) { TCHAR name[MAX_PATH]; - int len; + size_t len; void (*tkmainex)(int, char **, Tcl_AppInitProc *, Tcl_Interp *); /* construct "/libtk8.?.dll", from "/tk8?.dll" */ -- cgit v0.12 From 7ecb35e70563f3673d088c5df201b86b4974dd97 Mon Sep 17 00:00:00 2001 From: culler Date: Sat, 3 Nov 2018 20:48:20 +0000 Subject: Cleaned up the Rube Goldberg logic of TkMacOSXSetupDrawingContext and TkMacOSXRestoreDrawingContext. Eliminated all dependencies on functions deprecated in Mojave except scrollRect:by. --- macosx/tkMacOSXDraw.c | 133 +++++++++++++++++++++---------------------- macosx/tkMacOSXInt.h | 9 ++- macosx/tkMacOSXPrivate.h | 1 - macosx/tkMacOSXWindowEvent.c | 3 +- macosx/tkMacOSXWm.c | 3 +- 5 files changed, 73 insertions(+), 76 deletions(-) diff --git a/macosx/tkMacOSXDraw.c b/macosx/tkMacOSXDraw.c index ce53a17..94e8778 100644 --- a/macosx/tkMacOSXDraw.c +++ b/macosx/tkMacOSXDraw.c @@ -162,15 +162,9 @@ TkMacOSXBitmapRepFromDrawableRect( NSRect view_rect = NSMakeRect(x + mac_drawable->xOff, view_height - height - y - mac_drawable->yOff, width, height); - - if ( [view lockFocusIfCanDraw] ) { - bitmap_rep = [NSBitmapImageRep alloc]; - bitmap_rep = [bitmap_rep initWithFocusedViewRect:view_rect]; - [view unlockFocus]; - } else { - TkMacOSXDbgMsg("Could not lock focus on view."); - } - + bitmap_rep = [view bitmapImageRepForCachingDisplayInRect: view_rect]; + [bitmap_rep retain]; + [view cacheDisplayInRect:view_rect toBitmapImageRep:bitmap_rep]; } else { TkMacOSXDbgMsg("Invalid source drawable"); } @@ -1462,38 +1456,56 @@ TkMacOSXSetupDrawingContext( TkMacOSXDrawingContext *dcPtr) { MacDrawable *macDraw = ((MacDrawable*)d); - int dontDraw = 0, isWin = 0; + Bool canDraw = true; + NSWindow *win = NULL; TkMacOSXDrawingContext dc = {}; CGRect clipBounds; - dc.clipRgn = TkMacOSXGetClipRgn(d); - if (!dontDraw) { - ClipToGC(d, gc, &dc.clipRgn); - dontDraw = dc.clipRgn ? HIShapeIsEmpty(dc.clipRgn) : 0; + /* + * If the drawable is not a pixmap and it has an associated + * NSWindow then we are drawing to a window. + */ + if (!(macDraw->flags & TK_IS_PIXMAP)) { + win = TkMacOSXDrawableWindow(d); } - if (dontDraw) { + + /* + * Check that we have a non-empty clipping region. + */ + dc.clipRgn = TkMacOSXGetClipRgn(d); + ClipToGC(d, gc, &dc.clipRgn); + if (dc.clipRgn && HIShapeIsEmpty(dc.clipRgn)) { + canDraw = false; goto end; } - if (useCG) { - dc.context = TkMacOSXGetCGContextForDrawable(d); - } - if (!dc.context || !(macDraw->flags & TK_IS_PIXMAP)) { - isWin = (TkMacOSXDrawableWindow(d) != nil); - } + + /* + * If we already have a CGContext, use it. Otherwise, if we + * are drawing to a window then we can get one from the + * window. + */ + dc.context = TkMacOSXGetCGContextForDrawable(d); if (dc.context) { dc.portBounds = clipBounds = CGContextGetClipBoundingBox(dc.context); - } else if (isWin) { + } else if (win) { NSView *view = TkMacOSXDrawableView(macDraw); if (view) { - if (view != [NSView focusView]) { - dc.focusLocked = [view lockFocusIfCanDraw]; - dontDraw = !dc.focusLocked; - } else { - dontDraw = ![view canDraw]; - } - if (dontDraw) { - goto end; - } + /* + * We can only draw into the view when the current CGContext is + * valid and belongs to the view. Validity can only be guaranteed + * inside of a view's drawRect or setFrame methods. The isDrawing + * attribute tells us whether we are being called from one of those + * methods. + * + * If the CGContext is not valid, or belongs to a different View, + * then we mark our view as needing display and return failure. + * It should get drawn in a later call to drawRect. + */ + if (view != [NSView focusView]) { + [view setNeedsDisplay:YES]; + canDraw = false; + goto end; + } dc.view = view; dc.context = GET_CGCONTEXT; dc.portBounds = NSRectToCGRect([view bounds]); @@ -1508,14 +1520,15 @@ TkMacOSXSetupDrawingContext( Tcl_Panic("TkMacOSXSetupDrawingContext(): " "no context to draw into !"); } + /* + * Configure the drawing context. + */ if (dc.context) { CGAffineTransform t = { .a = 1, .b = 0, .c = 0, .d = -1, .tx = 0, .ty = dc.portBounds.size.height}; dc.portBounds.origin.x += macDraw->xOff; dc.portBounds.origin.y += macDraw->yOff; - if (!dc.focusLocked) { - CGContextSaveGState(dc.context); - } + CGContextSaveGState(dc.context); CGContextSetTextDrawingMode(dc.context, kCGTextFill); CGContextConcatCTM(dc.context, t); if (dc.clipRgn) { @@ -1550,7 +1563,7 @@ TkMacOSXSetupDrawingContext( double w = gc->line_width; TkMacOSXSetColorInContext(gc, gc->foreground, dc.context); - if (isWin) { + if (win) { CGContextSetPatternPhase(dc.context, CGSizeMake( dc.portBounds.size.width, dc.portBounds.size.height)); } @@ -1588,13 +1601,21 @@ TkMacOSXSetupDrawingContext( } } } + end: - if (dontDraw && dc.clipRgn) { +#ifdef TK_MAC_DEBUG_DRAWING + if (!canDraw && win != NULL) { + TkWindow *winPtr = TkMacOSXGetTkWindow(win); + if (winPtr) fprintf(stderr, "Cannot draw in %s - postponing.\n", + Tk_PathName(winPtr)); + } +#endif + if (!canDraw && dc.clipRgn) { CFRelease(dc.clipRgn); dc.clipRgn = NULL; } *dcPtr = dc; - return !dontDraw; + return canDraw; } /* @@ -1619,12 +1640,7 @@ TkMacOSXRestoreDrawingContext( { if (dcPtr->context) { CGContextSynchronize(dcPtr->context); - [[dcPtr->view window] setViewsNeedDisplay:YES]; - if (dcPtr->focusLocked) { - [dcPtr->view unlockFocus]; - } else { - CGContextRestoreGState(dcPtr->context); - } + CGContextRestoreGState(dcPtr->context); } if (dcPtr->clipRgn) { CFRelease(dcPtr->clipRgn); @@ -1663,17 +1679,13 @@ TkMacOSXGetClipRgn( #ifdef TK_MAC_DEBUG_DRAWING TkMacOSXDbgMsg("%s", macDraw->winPtr->pathName); NSView *view = TkMacOSXDrawableView(macDraw); - if ([view lockFocusIfCanDraw]) { - CGContextRef context = GET_CGCONTEXT; - CGContextSaveGState(context); - CGContextConcatCTM(context, CGAffineTransformMake(1.0, 0.0, 0.0, - -1.0, 0.0, [view bounds].size.height)); - ChkErr(HIShapeReplacePathInCGContext, macDraw->visRgn, context); - CGContextSetRGBFillColor(context, 0.0, 1.0, 0.0, 0.1); - CGContextEOFillPath(context); - CGContextRestoreGState(context); - [view unlockFocus]; - } + CGContextSaveGState(context); + CGContextConcatCTM(context, CGAffineTransformMake(1.0, 0.0, 0.0, + -1.0, 0.0, [view bounds].size.height)); + ChkErr(HIShapeReplacePathInCGContext, macDraw->visRgn, context); + CGContextSetRGBFillColor(context, 0.0, 1.0, 0.0, 0.1); + CGContextEOFillPath(context); + CGContextRestoreGState(context); #endif /* TK_MAC_DEBUG_DRAWING */ } @@ -1733,13 +1745,11 @@ TkpClipDrawableToRect( int width, int height) { MacDrawable *macDraw = (MacDrawable *) d; - NSView *view = TkMacOSXDrawableView(macDraw); if (macDraw->drawRgn) { CFRelease(macDraw->drawRgn); macDraw->drawRgn = NULL; } - if (width >= 0 && height >= 0) { CGRect clipRect = CGRectMake(x + macDraw->xOff, y + macDraw->yOff, width, height); @@ -1755,17 +1765,6 @@ TkpClipDrawableToRect( } else { macDraw->drawRgn = drawRgn; } - if (view && view != [NSView focusView] && [view lockFocusIfCanDraw]) { - clipRect.origin.y = [view bounds].size.height - - (clipRect.origin.y + clipRect.size.height); - NSRectClip(NSRectFromCGRect(clipRect)); - macDraw->flags |= TK_FOCUSED_VIEW; - } - } else { - if (view && (macDraw->flags & TK_FOCUSED_VIEW)) { - [view unlockFocus]; - macDraw->flags &= ~TK_FOCUSED_VIEW; - } } } diff --git a/macosx/tkMacOSXInt.h b/macosx/tkMacOSXInt.h index f4859ff..09fbed3 100644 --- a/macosx/tkMacOSXInt.h +++ b/macosx/tkMacOSXInt.h @@ -83,11 +83,10 @@ typedef struct TkWindowPrivate MacDrawable; #define TK_CLIP_INVALID 0x02 #define TK_HOST_EXISTS 0x04 #define TK_DRAWN_UNDER_MENU 0x08 -#define TK_FOCUSED_VIEW 0x10 -#define TK_IS_PIXMAP 0x20 -#define TK_IS_BW_PIXMAP 0x40 -#define TK_DO_NOT_DRAW 0x80 -#define TK_USE_XIMAGE_ALPHA 0x100 +#define TK_IS_PIXMAP 0x10 +#define TK_IS_BW_PIXMAP 0x20 +#define TK_DO_NOT_DRAW 0x40 +#define TK_USE_XIMAGE_ALPHA 0x80 /* * I am reserving TK_EMBEDDED = 0x100 in the MacDrawable flags * This is defined in tk.h. We need to duplicate the TK_EMBEDDED flag in the diff --git a/macosx/tkMacOSXPrivate.h b/macosx/tkMacOSXPrivate.h index 197879f..f5924e5 100644 --- a/macosx/tkMacOSXPrivate.h +++ b/macosx/tkMacOSXPrivate.h @@ -131,7 +131,6 @@ typedef struct TkMacOSXDrawingContext { NSView *view; HIShapeRef clipRgn; CGRect portBounds; - int focusLocked; } TkMacOSXDrawingContext; /* diff --git a/macosx/tkMacOSXWindowEvent.c b/macosx/tkMacOSXWindowEvent.c index 3e22311..8d04564 100644 --- a/macosx/tkMacOSXWindowEvent.c +++ b/macosx/tkMacOSXWindowEvent.c @@ -863,7 +863,6 @@ ConfigureRestrictProc( #ifdef TK_MAC_DEBUG_DRAWING fprintf(stderr, "drawRect: done.\n"); #endif - } -(void) setFrameSize: (NSSize)newsize @@ -873,6 +872,7 @@ ConfigureRestrictProc( TkWindow *winPtr = TkMacOSXGetTkWindow(w); Tk_Window tkwin = (Tk_Window) winPtr; if (winPtr) { + [NSApp setIsDrawing:YES]; unsigned int width = (unsigned int)newsize.width; unsigned int height=(unsigned int)newsize.height; ClientData oldArg; @@ -918,6 +918,7 @@ ConfigureRestrictProc( [self generateExposeEvents: shape]; [w displayIfNeeded]; [NSApp _unlockAutoreleasePool]; + [NSApp setIsDrawing:NO]; } } diff --git a/macosx/tkMacOSXWm.c b/macosx/tkMacOSXWm.c index 5dcc075..211c3a8 100644 --- a/macosx/tkMacOSXWm.c +++ b/macosx/tkMacOSXWm.c @@ -741,7 +741,6 @@ TkWmMapWindow( * mapped. */ { WmInfo *wmPtr = winPtr->wmInfoPtr; - if (wmPtr->flags & WM_NEVER_MAPPED) { /* * Create the underlying Mac window for this Tk window. @@ -5677,7 +5676,7 @@ TkMacOSXMakeRealWindowExist( geometry.size.height += structureRect.size.height; geometry.origin.y = tkMacOSXZeroScreenHeight - (geometry.origin.y + geometry.size.height); - [window setFrame:geometry display:NO]; + [window setFrame:geometry display:YES]; TkMacOSXRegisterOffScreenWindow((Window) macWin, window); macWin->flags |= TK_HOST_EXISTS; } -- cgit v0.12 From 47fe871919f31cfa710821c3bfc9525f22fff775 Mon Sep 17 00:00:00 2001 From: culler Date: Sat, 3 Nov 2018 21:48:37 +0000 Subject: On 10.13 we must now process idle events in drawRect, as in 10.14, but we also must lock focus inside the s[NSView setFrame] method. --- macosx/tkMacOSXWindowEvent.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/macosx/tkMacOSXWindowEvent.c b/macosx/tkMacOSXWindowEvent.c index 8d04564..d367506 100644 --- a/macosx/tkMacOSXWindowEvent.c +++ b/macosx/tkMacOSXWindowEvent.c @@ -915,9 +915,19 @@ ConfigureRestrictProc( HIRect bounds = NSRectToCGRect([self bounds]); HIShapeRef shape = HIShapeCreateWithRect(&bounds); + Bool locked = false; + /* + * On OSX versions below 10.14 we *must* lock focus to enable drawing. + * As of 10.14 this is unnecessary and lockFocusIfCanDraw is deprecated. + */ + if (self != [NSView focusView]) { + locked = [self lockFocusIfCanDraw]; + } [self generateExposeEvents: shape]; [w displayIfNeeded]; - [NSApp _unlockAutoreleasePool]; + if (locked) { + [self unlockFocus]; + } [NSApp setIsDrawing:NO]; } } @@ -977,9 +987,7 @@ ConfigureRestrictProc( * were created when the expose events were processed. Unfortunately * this does not work in macOS 10.13. */ - if ([NSApp macMinorVersion] > 13 || [self inLiveResize]) { - while (Tcl_DoOneEvent(TCL_IDLE_EVENTS)) {} - } + while (Tcl_DoOneEvent(TCL_IDLE_EVENTS)) {} } } -- cgit v0.12 From 73b974ee14234e310fa793c9fa63568481356476 Mon Sep 17 00:00:00 2001 From: culler Date: Sat, 3 Nov 2018 22:14:38 +0000 Subject: On OSX < 10.14 do not set [NSApp isDrawing] inside [NSView setFrame]. --- macosx/tkMacOSXWindowEvent.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/macosx/tkMacOSXWindowEvent.c b/macosx/tkMacOSXWindowEvent.c index d367506..674bcb6 100644 --- a/macosx/tkMacOSXWindowEvent.c +++ b/macosx/tkMacOSXWindowEvent.c @@ -872,7 +872,12 @@ ConfigureRestrictProc( TkWindow *winPtr = TkMacOSXGetTkWindow(w); Tk_Window tkwin = (Tk_Window) winPtr; if (winPtr) { - [NSApp setIsDrawing:YES]; + /* On OSX versions below 10.14 setFrame calls drawRect. + * On 10.14 it does its own drawing. + */ + if ([NSApp macMinorVersion] > 13) { + [NSApp setIsDrawing:YES]; + } unsigned int width = (unsigned int)newsize.width; unsigned int height=(unsigned int)newsize.height; ClientData oldArg; @@ -928,7 +933,9 @@ ConfigureRestrictProc( if (locked) { [self unlockFocus]; } - [NSApp setIsDrawing:NO]; + if ([NSApp macMinorVersion] > 13) { + [NSApp setIsDrawing:NO]; + } } } -- cgit v0.12 From b236ac696bc5e78bb9aa87505d01d388b1b8cb07 Mon Sep 17 00:00:00 2001 From: culler Date: Sun, 4 Nov 2018 00:33:15 +0000 Subject: No need for lockFocusIfCanDraw in 10.13 as long as isDrawing is not set in setFrame. --- macosx/tkMacOSXWindowEvent.c | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-) diff --git a/macosx/tkMacOSXWindowEvent.c b/macosx/tkMacOSXWindowEvent.c index 674bcb6..19e4ba2 100644 --- a/macosx/tkMacOSXWindowEvent.c +++ b/macosx/tkMacOSXWindowEvent.c @@ -833,9 +833,10 @@ ConfigureRestrictProc( #endif /* - * We do not allow recursive calls to drawRect. + * We do not allow recursive calls to drawRect. Only log this + * in 10.14 and higher, where it should not happen. */ - if ([NSApp isDrawing]) { + if ([NSApp isDrawing] && [NSApp macMinorVersion] > 13) { TKLog(@"WARNING: a recursive call to drawRect was aborted."); return; } @@ -920,19 +921,8 @@ ConfigureRestrictProc( HIRect bounds = NSRectToCGRect([self bounds]); HIShapeRef shape = HIShapeCreateWithRect(&bounds); - Bool locked = false; - /* - * On OSX versions below 10.14 we *must* lock focus to enable drawing. - * As of 10.14 this is unnecessary and lockFocusIfCanDraw is deprecated. - */ - if (self != [NSView focusView]) { - locked = [self lockFocusIfCanDraw]; - } [self generateExposeEvents: shape]; [w displayIfNeeded]; - if (locked) { - [self unlockFocus]; - } if ([NSApp macMinorVersion] > 13) { [NSApp setIsDrawing:NO]; } -- cgit v0.12 From 31f82fb5b5ae52d1893a87e7a5a83c0e9eae2f58 Mon Sep 17 00:00:00 2001 From: culler Date: Mon, 5 Nov 2018 16:03:56 +0000 Subject: Make XSync, and hence update, be synchronous so test results are consistent. Fix duplicate reports of calls to the test image displayProc. --- generic/tkTest.c | 32 +++++++++++++++++++++++--------- macosx/tkMacOSXConstants.h | 2 ++ macosx/tkMacOSXEvent.c | 25 +++++++++++++++++++------ macosx/tkMacOSXInt.h | 2 +- macosx/tkMacOSXNotify.c | 2 +- macosx/tkMacOSXTest.c | 26 ++++++++++++++++++++++++++ macosx/tkMacOSXWindowEvent.c | 19 +++++++++++++++++-- 7 files changed, 89 insertions(+), 19 deletions(-) diff --git a/generic/tkTest.c b/generic/tkTest.c index 2dbd877..e95d274 100644 --- a/generic/tkTest.c +++ b/generic/tkTest.c @@ -31,6 +31,9 @@ #if defined(MAC_OSX_TK) #include "tkMacOSXInt.h" #include "tkScrollbar.h" +#define APP_IS_DRAWING (TkTestAppIsDrawing()) +#else +#define APP_IS_DRAWING 1 #endif #ifdef __UNIX__ @@ -1550,15 +1553,26 @@ ImageDisplay( TImageInstance *instPtr = (TImageInstance *) clientData; char buffer[200 + TCL_INTEGER_SPACE * 6]; - sprintf(buffer, "%s display %d %d %d %d", - instPtr->masterPtr->imageName, imageX, imageY, width, height); - Tcl_SetVar2(instPtr->masterPtr->interp, instPtr->masterPtr->varName, NULL, - buffer, TCL_GLOBAL_ONLY|TCL_APPEND_VALUE|TCL_LIST_ELEMENT); - if (width > (instPtr->masterPtr->width - imageX)) { - width = instPtr->masterPtr->width - imageX; - } - if (height > (instPtr->masterPtr->height - imageY)) { - height = instPtr->masterPtr->height - imageY; + /* + * On macOS the fake drawing below will not take place when this + * displayProc is run as an idle task. That is because the idle task will + * not have a valid graphics context available. Instead, the window will + * be marked as needing redisplay and will get redrawn in the next call to + * its contentView's drawRect method. We only record the display + * information when the actual drawing takes place to avoid duplicate + * records which would cause some image tests to fail. + */ + if (APP_IS_DRAWING) { + sprintf(buffer, "%s display %d %d %d %d", + instPtr->masterPtr->imageName, imageX, imageY, width, height); + Tcl_SetVar2(instPtr->masterPtr->interp, instPtr->masterPtr->varName, NULL, + buffer, TCL_GLOBAL_ONLY|TCL_APPEND_VALUE|TCL_LIST_ELEMENT); + if (width > (instPtr->masterPtr->width - imageX)) { + width = instPtr->masterPtr->width - imageX; + } + if (height > (instPtr->masterPtr->height - imageY)) { + height = instPtr->masterPtr->height - imageY; + } } XDrawRectangle(display, drawable, instPtr->gc, drawableX, drawableY, (unsigned) (width-1), (unsigned) (height-1)); diff --git a/macosx/tkMacOSXConstants.h b/macosx/tkMacOSXConstants.h index b160083..dbe533c 100644 --- a/macosx/tkMacOSXConstants.h +++ b/macosx/tkMacOSXConstants.h @@ -40,6 +40,7 @@ #if MAC_OS_X_VERSION_MIN_REQUIRED >= 101200 #define NSAppKitDefined NSEventTypeAppKitDefined +#define NSApplicationDefined NSEventTypeApplicationDefined #define NSApplicationActivatedEventType NSEventSubtypeApplicationActivated #define NSApplicationDeactivatedEventType NSEventSubtypeApplicationDeactivated #define NSWindowExposedEventType NSEventSubtypeWindowExposed @@ -92,6 +93,7 @@ #define NSAlphaShiftKeyMask NSEventModifierFlagCapsLock #define NSShiftKeyMask NSEventModifierFlagShift #define NSAnyEventMask NSEventMaskAny +#define NSApplicationDefinedEventMask NSEventMaskApplicationDefined #define NSTexturedBackgroundWindowMask NSWindowStyleMaskTexturedBackground #define NSUtilityWindowMask NSWindowStyleMaskUtilityWindow #define NSNonactivatingPanelMask NSWindowStyleMaskNonactivatingPanel diff --git a/macosx/tkMacOSXEvent.c b/macosx/tkMacOSXEvent.c index 25c0bea..36167cb 100644 --- a/macosx/tkMacOSXEvent.c +++ b/macosx/tkMacOSXEvent.c @@ -112,11 +112,16 @@ enum { * * TkMacOSXFlushWindows -- * - * This routine is a stub called by XSync, which is called during - * the Tk update command. It calls displayIfNeeded on all visible - * windows. This is necessary in order to insure that update will - * run all of the display procedures which have been registered as - * idle tasks. The test suite assumes that this is the case. + * This routine is a stub called by XSync, which is called during the Tk + * update command. The language specification does not require that the + * update command be synchronous but many of the tests assume that is the + * case. It is not naturally the case on macOS since many idle tasks are + * run inside of the drawRect method of a window's contentView, and that + * method will not be called until after this function returns. To make + * the tests work, we attempt to force this to be synchronous by waiting + * until drawRect has been called for each window. The mechanism we use + * for this is to have drawRect post an ApplicationDefined NSEvent on the + * AppKit event queue when it finishes drawing, and wait for it here. * * Results: * None. @@ -131,11 +136,19 @@ enum { MODULE_SCOPE void TkMacOSXFlushWindows(void) { + NSModalSession modalSession = TkMacOSXGetModalSession(); + NSEvent *syncEvent; NSArray *macWindows = [NSApp orderedWindows]; - for (NSWindow *w in macWindows) { if (TkMacOSXGetXWindow(w)) { [w displayIfNeeded]; + syncEvent = [NSApp + nextEventMatchingMask:NSApplicationDefinedEventMask + untilDate:[NSDate distantPast] + inMode:GetRunLoopMode(modalSession) + dequeue:YES]; + [NSApp discardEventsMatchingMask:NSApplicationDefinedEventMask + beforeEvent:syncEvent]; } } diff --git a/macosx/tkMacOSXInt.h b/macosx/tkMacOSXInt.h index 09fbed3..6108383 100644 --- a/macosx/tkMacOSXInt.h +++ b/macosx/tkMacOSXInt.h @@ -200,7 +200,7 @@ MODULE_SCOPE void TkpReleaseRegion(TkRegion r); MODULE_SCOPE void TkpShiftButton(NSButton *button, NSPoint delta); MODULE_SCOPE Bool TkpAppIsDrawing(void); MODULE_SCOPE void TkpDisplayWindow(Tk_Window tkwin); - +MODULE_SCOPE NSString* GetRunLoopMode(NSModalSession modalSession); /* * Include the stubbed internal platform-specific API. */ diff --git a/macosx/tkMacOSXNotify.c b/macosx/tkMacOSXNotify.c index e276926..7cbd248 100644 --- a/macosx/tkMacOSXNotify.c +++ b/macosx/tkMacOSXNotify.c @@ -169,7 +169,7 @@ void DebugPrintQueue(void) *---------------------------------------------------------------------- */ -static NSString * +NSString * GetRunLoopMode(NSModalSession modalSession) { NSString *runLoopMode = nil; diff --git a/macosx/tkMacOSXTest.c b/macosx/tkMacOSXTest.c index 1882ce6..92c925c 100644 --- a/macosx/tkMacOSXTest.c +++ b/macosx/tkMacOSXTest.c @@ -80,6 +80,32 @@ DebuggerObjCmd( } /* + *---------------------------------------------------------------------- + * + * TkTestAppIsDrawing -- + * + * A widget display procedure can call this to determine whether it + * is being run inside of the drawRect method. This is needed for + * some tests, especially of the Text widget, which record data in + * a global Tcl variable and assume that display procedures will be + * run in a predictable sequence as Tcl idle tasks. + * + * Results: + * True only while running the drawRect method of a TKContentView; + * + * Side effects: + * None + * + *---------------------------------------------------------------------- + */ +MODULE_SCOPE Bool +TkTestAppIsDrawing(void) { + return [NSApp isDrawing]; +} + + + +/* * Local Variables: * mode: objc * c-basic-offset: 4 diff --git a/macosx/tkMacOSXWindowEvent.c b/macosx/tkMacOSXWindowEvent.c index 19e4ba2..f69ee0c 100644 --- a/macosx/tkMacOSXWindowEvent.c +++ b/macosx/tkMacOSXWindowEvent.c @@ -861,6 +861,22 @@ ConfigureRestrictProc( CFRelease(drawShape); [NSApp setIsDrawing: NO]; + /* + * To make it possible to wait for this method, we post an application + * defined event when all drawing has been done. + */ + NSEvent* drawEvent = [NSEvent otherEventWithType:NSApplicationDefined + location:NSMakePoint(0,0) + modifierFlags:0 + timestamp:0 + windowNumber:[[self window] windowNumber] + context:nil + subtype:1 + data1:0 + data2:0 + ]; + [NSApp postEvent:drawEvent atStart:YES]; + #ifdef TK_MAC_DEBUG_DRAWING fprintf(stderr, "drawRect: done.\n"); #endif @@ -981,8 +997,7 @@ ConfigureRestrictProc( * * Fortunately, Tk schedules all drawing to be done while Tcl is idle. * So we can do the drawing by processing all of the idle events that - * were created when the expose events were processed. Unfortunately - * this does not work in macOS 10.13. + * were created when the expose events were processed. */ while (Tcl_DoOneEvent(TCL_IDLE_EVENTS)) {} } -- cgit v0.12 From e29eea6eac19160aa396ad3c63147441f2215b17 Mon Sep 17 00:00:00 2001 From: culler Date: Tue, 6 Nov 2018 11:54:49 +0000 Subject: Fix misspelled constant name in OSX < 10.12. --- macosx/tkMacOSXConstants.h | 2 +- macosx/tkMacOSXEvent.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/macosx/tkMacOSXConstants.h b/macosx/tkMacOSXConstants.h index dbe533c..0badf1a 100644 --- a/macosx/tkMacOSXConstants.h +++ b/macosx/tkMacOSXConstants.h @@ -93,7 +93,7 @@ #define NSAlphaShiftKeyMask NSEventModifierFlagCapsLock #define NSShiftKeyMask NSEventModifierFlagShift #define NSAnyEventMask NSEventMaskAny -#define NSApplicationDefinedEventMask NSEventMaskApplicationDefined +#define NSApplicationDefinedMask NSEventMaskApplicationDefined #define NSTexturedBackgroundWindowMask NSWindowStyleMaskTexturedBackground #define NSUtilityWindowMask NSWindowStyleMaskUtilityWindow #define NSNonactivatingPanelMask NSWindowStyleMaskNonactivatingPanel diff --git a/macosx/tkMacOSXEvent.c b/macosx/tkMacOSXEvent.c index 36167cb..676344c 100644 --- a/macosx/tkMacOSXEvent.c +++ b/macosx/tkMacOSXEvent.c @@ -143,11 +143,11 @@ TkMacOSXFlushWindows(void) if (TkMacOSXGetXWindow(w)) { [w displayIfNeeded]; syncEvent = [NSApp - nextEventMatchingMask:NSApplicationDefinedEventMask + nextEventMatchingMask:NSApplicationDefinedMask untilDate:[NSDate distantPast] inMode:GetRunLoopMode(modalSession) dequeue:YES]; - [NSApp discardEventsMatchingMask:NSApplicationDefinedEventMask + [NSApp discardEventsMatchingMask:NSApplicationDefinedMask beforeEvent:syncEvent]; } } -- cgit v0.12 From c5205ce3fbef20b6a3e78118e6ccfea8c05e0dd7 Mon Sep 17 00:00:00 2001 From: culler Date: Tue, 6 Nov 2018 13:11:09 +0000 Subject: Fix bug in FrontWindowAtPoint that was causing raise.test to fail on OSX < 10.13. --- macosx/tkMacOSXWm.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/macosx/tkMacOSXWm.c b/macosx/tkMacOSXWm.c index 211c3a8..ed930fe 100644 --- a/macosx/tkMacOSXWm.c +++ b/macosx/tkMacOSXWm.c @@ -605,15 +605,15 @@ FrontWindowAtPoint( { NSPoint p = NSMakePoint(x, tkMacOSXZeroScreenHeight - y); NSArray *windows = [NSApp orderedWindows]; - TkWindow *front = NULL; + TkWindow *winPtr = NULL; for (NSWindow *w in windows) { - if (w && NSMouseInRect(p, [w frame], NO)) { - front = TkMacOSXGetTkWindow(w); - break; - } + winPtr = TkMacOSXGetTkWindow(w); + if (winPtr && NSMouseInRect(p, [w frame], NO)) { + break; } - return front; + } + return winPtr; } /* -- cgit v0.12 From 4242adeaa1ea33a9701e15b6a1861511f9d28be5 Mon Sep 17 00:00:00 2001 From: dkf Date: Tue, 6 Nov 2018 14:40:47 +0000 Subject: Tidy up tests --- tests/grid.test | 42 +++++++++++++++++++++---------------- tests/pack.test | 65 ++++++++++++++++++++++----------------------------------- 2 files changed, 49 insertions(+), 58 deletions(-) diff --git a/tests/grid.test b/tests/grid.test index 444f60f..63bfe2a 100644 --- a/tests/grid.test +++ b/tests/grid.test @@ -1800,7 +1800,6 @@ test grid-17.1 {forget and pending idle handlers} -body { set result ok } -result ok - test grid-18.1 {test respect for internalborder} -body { toplevel .pack wm geometry .pack 200x200 @@ -2018,9 +2017,10 @@ test grid-23 {grid configure -in leaked from previous master - bug } {1} grid_reset 23 -test grid-24.1 {<> fires on last grid forget} -body { +test grid-24.1 {<> fires on last grid forget} -setup { global A - catch {unset A} + unset -nocomplain A +} -body { grid [frame .1] update bind . <> {set A 1} @@ -2031,9 +2031,10 @@ test grid-24.1 {<> fires on last grid forget} -body { bind . <> {} grid_reset 24.1 } -result {1} -test grid-24.2 {<> fires on last grid remove} -body { +test grid-24.2 {<> fires on last grid remove} -setup { global A - catch {unset A} + unset -nocomplain A +} -body { grid [frame .1] update bind . <> {set A 1} @@ -2044,9 +2045,10 @@ test grid-24.2 {<> fires on last grid remove} -body { bind . <> {} grid_reset 24.2 } -result {1} -test grid-24.3 {<> fires on last gridded child destruction} -body { +test grid-24.3 {<> fires on last gridded child destruction} -setup { global A - catch {unset A} + unset -nocomplain A +} -body { grid [frame .1] update bind . <> {incr A} @@ -2057,9 +2059,10 @@ test grid-24.3 {<> fires on last gridded child destruction} -bod bind . <> {} grid_reset 24.3 } -result {1} -test grid-24.4 { does not fire on last grid forget} -body { +test grid-24.4 { does not fire on last grid forget} -setup { global A - catch {unset A} + unset -nocomplain A +} -body { grid [frame .1] update bind . {set A 1} @@ -2070,9 +2073,10 @@ test grid-24.4 { does not fire on last grid forget} -body { bind . {} grid_reset 24.4 } -result {0} -test grid-24.5 { fires on forelast grid forget} -body { +test grid-24.5 { fires on forelast grid forget} -setup { global A - catch {unset A} + unset -nocomplain A +} -body { grid [frame .1] grid [frame .2] update @@ -2084,9 +2088,10 @@ test grid-24.5 { fires on forelast grid forget} -body { bind . {} grid_reset 24.5 } -result {1} -test grid-24.6 {<> does not fire on forelast grid forget} -body { +test grid-24.6 {<> does not fire on forelast grid forget} -setup { global A - catch {unset A} + unset -nocomplain A +} -body { grid [frame .1] grid [frame .2] update @@ -2098,9 +2103,10 @@ test grid-24.6 {<> does not fire on forelast grid forget} -body bind . <> {} grid_reset 24.6 } -result {0} -test grid-24.7 {<> does not fire on grid anchor} -body { +test grid-24.7 {<> does not fire on grid anchor} -setup { global A - catch {unset A} + unset -nocomplain A +} -body { bind . <> {set A 1} grid anchor . w update @@ -2110,9 +2116,10 @@ test grid-24.7 {<> does not fire on grid anchor} -body { bind . <> {} grid_reset 24.7 } -result {0} -test grid-24.8 {<> does not fire on last grid forget if propagation is off} -body { +test grid-24.8 {<> does not fire on last grid forget if propagation is off} -setup { global A - catch {unset A} + unset -nocomplain A +} -body { grid [frame .1] grid propagate . 0 update @@ -2124,7 +2131,6 @@ test grid-24.8 {<> does not fire on last grid forget if propagat bind . <> {} grid_reset 24.8 } -result {0} - # cleanup cleanupTests diff --git a/tests/pack.test b/tests/pack.test index 22b5cbb..9d5964c 100644 --- a/tests/pack.test +++ b/tests/pack.test @@ -1,5 +1,5 @@ -# This file is a Tcl script to test out the "pack" command -# of Tk. It is organized in the standard fashion for Tcl tests. +# This file is a Tcl script to test out the "pack" command of Tk. It is +# organized in the standard fashion for Tcl tests. # # Copyright (c) 1993 The Regents of the University of California. # Copyright (c) 1994 Sun Microsystems, Inc. @@ -28,7 +28,7 @@ foreach i {a b c d} { .pack.b config -width 50 -height 30 .pack.c config -width 80 -height 80 .pack.d config -width 40 -height 30 - + test pack-1.1 {-side option} -setup { pack forget .pack.a .pack.b .pack.c .pack.d } -body { @@ -231,7 +231,6 @@ test pack-2.21 {x padding and filling} -setup { update list [winfo geometry .pack.a] [winfo geometry .pack.b] } -result {280x40+5+0 300x160+0+40} - test pack-2.22 {x padding and filling} -setup { pack forget .pack.a .pack.b .pack.c .pack.d } -body { @@ -251,7 +250,6 @@ test pack-2.23 {x padding and filling} -setup { expr {$res1 eq $res2} } -result 1 - test pack-3.1 {y padding and filling} -setup { pack forget .pack.a .pack.b .pack.c .pack.d } -body { @@ -420,7 +418,6 @@ test pack-3.21 {y padding and filling} -setup { update list [winfo geometry .pack.a] [winfo geometry .pack.b] } -result {20x50+140+1 300x130+0+70} - test pack-3.22 {y padding and filling} -setup { pack forget .pack.a .pack.b .pack.c .pack.d } -body { @@ -440,7 +437,6 @@ test pack-3.23 {y padding and filling} -setup { expr {$res1 eq $res2} } -result 1 - test pack-4.1 {anchors} -setup { pack forget .pack.a .pack.b .pack.c .pack.d } -body { @@ -505,7 +501,6 @@ test pack-4.9 {anchors} -setup { winfo geometry .pack.a } -result {30x70+135+65} - # Repeat above tests, but with a frame that isn't at (0,0), so that # we can be sure that the frame offset is being added in correctly. @@ -591,7 +586,6 @@ test pack-5.9 {more anchors} -setup { winfo geometry .pack.b } -result {60x60+160+90} - test pack-6.1 {-expand option} -setup { pack forget .pack.a .pack.b .pack.c .pack.d } -body { @@ -697,7 +691,6 @@ test pack-6.11 {-expand option} -setup { list [winfo geometry .pack.a] [winfo geometry .pack.b] \ [winfo geometry .pack.c] [winfo geometry .pack.d] } -result {100x200+0+0 200x100+100+0 160x100+140+100 40x100+100+100} - test pack-6.12 {-expand option} -setup { toplevel .pack2 -height 400 -width 400 wm geometry .pack2 +0+0 @@ -732,7 +725,6 @@ test pack-6.13 {-expand option} -setup { destroy .pack2 } -result {38x42+181+45 38x42+181+178 38x42+181+312} - wm geometry .pack {} test pack-7.1 {requesting size for parent} -setup { pack forget .pack.a .pack.b .pack.c .pack.d @@ -791,7 +783,6 @@ test pack-7.7 {requesting size for parent} -setup { list [winfo reqwidth .pack] [winfo reqheight .pack] } -result {100 110} - # For the tests below, create a couple of "pad" windows to shrink # the available space for the remaining windows. The tests have to # be done this way rather than shrinking the whole window, because @@ -872,7 +863,6 @@ test pack-8.9 {insufficient space} -body { } -result {20x40+0+20 1 50x30+100+25 1 80x80+20+0 1} pack forget .pack.right .pack.bottom - test pack-9.1 {window ordering} -setup { pack forget .pack.a .pack.b .pack.c .pack.d } -body { @@ -945,7 +935,6 @@ test pack-9.10 {window ordering} -setup { pack slaves .pack } -result {.pack.a .pack.c .pack.d .pack.b} - test pack-10.1 {retaining/clearing configuration state} -setup { pack forget .pack.a .pack.b .pack.c .pack.d } -body { @@ -977,7 +966,6 @@ test pack-10.4 {bad -in window does not change master} -setup { pack .pack.a -in .pack.a } -returnCodes error -result {can't pack .pack.a inside itself} - test pack-11.1 {info option} -setup { pack forget .pack.a .pack.b .pack.c .pack.d } -body { @@ -1112,7 +1100,6 @@ test pack-11.19 {info option} -setup { lindex $i [expr [lsearch -exact $i -side]+1] } -result right - test pack-12.1 {command options and errors} -body { pack } -returnCodes error -result {wrong # args: should be "pack option arg ?arg ...?"} @@ -1354,7 +1341,6 @@ test pack-12.46 {command options and errors} -setup { pack lousy .pack } -returnCodes error -result {bad option "lousy": must be configure, forget, info, propagate, or slaves} - test pack-13.1 {window deletion} -setup { pack forget .pack.a .pack.b .pack.c .pack.d .pack.right .pack.bottom } -body { @@ -1368,7 +1354,6 @@ test pack-13.1 {window deletion} -setup { [winfo geometry .pack.b] [winfo geometry .pack.c]] } -result {{.pack.right .pack.bottom .pack.a .pack.b .pack.c} 20x40+30+0 50x30+15+40 80x80+0+70} - test pack-14.1 {respond to changes in expansion} -setup { pack forget .pack.a .pack.b .pack.c .pack.d .pack.right .pack.bottom } -body { @@ -1494,7 +1479,6 @@ test pack-15.5 {managing geometry with -in option} -setup { destroy .pack.f1 .pack.f2 } -result {50x16+25+22 1 50x16+25+22 0} - test pack-16.1 {geometry manager name} -setup { pack forget .pack.a .pack.b .pack.c .pack.d set result {} @@ -1506,7 +1490,6 @@ test pack-16.1 {geometry manager name} -setup { lappend result [winfo manager .pack.a] } -result {{} pack {}} - test pack-17.1 {PackLostSlaveProc procedure} -setup { pack forget .pack.a .pack.b .pack.c .pack.d } -body { @@ -1528,13 +1511,11 @@ test pack-17.2 {PackLostSlaveProc procedure} -setup { pack info .pack.a } -returnCodes error -result {window ".pack.a" isn't packed} - test pack-18.1 {unmap slaves when master unmapped} -constraints { tempNotPc } -setup { eval destroy [winfo child .pack] } -body { - # adjust the position of .pack before test to avoid a screen switch # that occurs with window managers that have desktops four times as big # as the screen (screen switch causes scale and other tests to fail). @@ -1564,7 +1545,6 @@ test pack-18.1 {unmap slaves when master unmapped} -constraints { test pack-18.2 {unmap slaves when master unmapped} -setup { eval destroy [winfo child .pack] } -body { - # adjust the position of .pack before test to avoid a screen switch # that occurs with window managers that have desktops four times as big # as the screen (screen switch causes scale and other tests to fail). @@ -1588,7 +1568,6 @@ test pack-18.2 {unmap slaves when master unmapped} -setup { lappend result [winfo ismapped .pack.b] } -result {1 0 100 30 0 1} - test pack-19.1 {test respect for internalborder} -setup { catch {eval pack forget [pack slaves .pack]} destroy .pack.l .pack.lf @@ -1626,9 +1605,10 @@ test pack-19.2 {test support for minreqsize} -setup { destroy .pack.l .pack.lf } -result {162x127+0+0 172x112+0+0} -test pack-20.1 {<> fires on last pack forget} -body { +test pack-20.1 {<> fires on last pack forget} -setup { global A - catch {unset A} + unset -nocomplain A +} -body { pack [frame .1] update bind . <> {set A 1} @@ -1639,9 +1619,10 @@ test pack-20.1 {<> fires on last pack forget} -body { bind . <> {} destroy .1 } -result {1} -test pack-20.2 {<> fires on last packed child destruction} -body { +test pack-20.2 {<> fires on last packed child destruction} -setup { global A - catch {unset A} + unset -nocomplain A +} -body { pack [frame .1] update bind . <> {incr A} @@ -1652,9 +1633,10 @@ test pack-20.2 {<> fires on last packed child destruction} -body bind . <> {} destroy .1 } -result {1} -test pack-20.3 { does not fire on last pack forget} -body { +test pack-20.3 { does not fire on last pack forget} -setup { global A - catch {unset A} + unset -nocomplain A +} -body { pack [frame .1] update bind . {set A 1} @@ -1665,9 +1647,10 @@ test pack-20.3 { does not fire on last pack forget} -body { bind . {} destroy .1 } -result {0} -test pack-20.4 {<> does not fire on forelast pack forget} -body { +test pack-20.4 {<> does not fire on forelast pack forget} -setup { global A - catch {unset A} + unset -nocomplain A +} -body { pack [frame .1] pack [frame .2] update @@ -1679,9 +1662,10 @@ test pack-20.4 {<> does not fire on forelast pack forget} -body bind . <> {} destroy .1 .2 } -result {0} -test pack-20.5 { does not fire on last pack forget} -body { +test pack-20.5 { does not fire on last pack forget} -setup { global A - catch {unset A} + unset -nocomplain A +} -body { pack [frame .1] pack [frame .2] update @@ -1693,9 +1677,10 @@ test pack-20.5 { does not fire on last pack forget} -body { bind . {} destroy .1 .2 } -result {1} -test pack-20.6 {<> does not fire on last pack forget if propagation is off} -body { +test pack-20.6 {<> does not fire on last pack forget if propagation is off} -setup { global A - catch {unset A} + unset -nocomplain A +} -body { pack [frame .1] pack propagate . 0 update @@ -1707,11 +1692,11 @@ test pack-20.6 {<> does not fire on last pack forget if propagat bind . <> {} destroy .1 } -result {0} - - + # cleanup cleanupTests return - - +# Local Variables: +# mode: tcl +# End: -- cgit v0.12 From 1cd3199254c47a7fd9e308663776b9e540d527c2 Mon Sep 17 00:00:00 2001 From: culler Date: Tue, 6 Nov 2018 21:21:50 +0000 Subject: Came up with a scheme for making test images behave the way that the tests assume they do. --- generic/tkTest.c | 48 ++++++++++++++++++++++++++------------------ macosx/tkMacOSXDraw.c | 21 ++++++++++++++++--- macosx/tkMacOSXEvent.c | 20 +++++++----------- macosx/tkMacOSXInit.c | 7 +++++-- macosx/tkMacOSXInt.h | 3 ++- macosx/tkMacOSXPrivate.h | 2 ++ macosx/tkMacOSXTest.c | 23 ++++++++++++--------- macosx/tkMacOSXWindowEvent.c | 27 ++++++++----------------- 8 files changed, 83 insertions(+), 68 deletions(-) diff --git a/generic/tkTest.c b/generic/tkTest.c index e95d274..5609391 100644 --- a/generic/tkTest.c +++ b/generic/tkTest.c @@ -31,9 +31,9 @@ #if defined(MAC_OSX_TK) #include "tkMacOSXInt.h" #include "tkScrollbar.h" -#define APP_IS_DRAWING (TkTestAppIsDrawing()) +#define SIMULATE_DRAWING TkTestSimulateDrawing(true); #else -#define APP_IS_DRAWING 1 +#define SIMULATE_DRAWING #endif #ifdef __UNIX__ @@ -1554,26 +1554,34 @@ ImageDisplay( char buffer[200 + TCL_INTEGER_SPACE * 6]; /* - * On macOS the fake drawing below will not take place when this - * displayProc is run as an idle task. That is because the idle task will - * not have a valid graphics context available. Instead, the window will - * be marked as needing redisplay and will get redrawn in the next call to - * its contentView's drawRect method. We only record the display - * information when the actual drawing takes place to avoid duplicate - * records which would cause some image tests to fail. + * The purpose of the test image type is to track the calls to an image + * display proc and record the parameters passed in each call. On macOS + * these tests will fail because of the asynchronous drawing. The low + * level graphics calls below which are supposed to draw a rectangle will + * not draw anything to the screen because the idle task will not be + * processed inside of the drawRect method and hence will not be able to + * obtain a valid graphics context. Instead, the window will be marked as + * needing display, and will be redrawn during a future asynchronous call + * to drawRect. This will generate an other call to this display proc, + * and the recorded data will show extra calls, causing the test to fail. + * To avoid this, we can set the [NSApp simulateDrawing] flag, which will + * cause all low level drawing routines to return immediately and not + * schedule the window for drawing later. This flag is cleared by the + * next call to XSync, which is called by the update command. */ - if (APP_IS_DRAWING) { - sprintf(buffer, "%s display %d %d %d %d", - instPtr->masterPtr->imageName, imageX, imageY, width, height); - Tcl_SetVar2(instPtr->masterPtr->interp, instPtr->masterPtr->varName, NULL, - buffer, TCL_GLOBAL_ONLY|TCL_APPEND_VALUE|TCL_LIST_ELEMENT); - if (width > (instPtr->masterPtr->width - imageX)) { - width = instPtr->masterPtr->width - imageX; - } - if (height > (instPtr->masterPtr->height - imageY)) { - height = instPtr->masterPtr->height - imageY; - } + + sprintf(buffer, "%s display %d %d %d %d", + instPtr->masterPtr->imageName, imageX, imageY, width, height); + Tcl_SetVar2(instPtr->masterPtr->interp, instPtr->masterPtr->varName, NULL, + buffer, TCL_GLOBAL_ONLY|TCL_APPEND_VALUE|TCL_LIST_ELEMENT); + if (width > (instPtr->masterPtr->width - imageX)) { + width = instPtr->masterPtr->width - imageX; + } + if (height > (instPtr->masterPtr->height - imageY)) { + height = instPtr->masterPtr->height - imageY; } + + SIMULATE_DRAWING XDrawRectangle(display, drawable, instPtr->gc, drawableX, drawableY, (unsigned) (width-1), (unsigned) (height-1)); XDrawLine(display, drawable, instPtr->gc, drawableX, drawableY, diff --git a/macosx/tkMacOSXDraw.c b/macosx/tkMacOSXDraw.c index 94e8778..42c9059 100644 --- a/macosx/tkMacOSXDraw.c +++ b/macosx/tkMacOSXDraw.c @@ -1448,7 +1448,7 @@ TkMacOSXSetUpGraphicsPort( *---------------------------------------------------------------------- */ -int +Bool TkMacOSXSetupDrawingContext( Drawable d, GC gc, @@ -1462,16 +1462,26 @@ TkMacOSXSetupDrawingContext( CGRect clipBounds; /* + * If we are simulating drawing for tests, just return false. + */ + + if ([NSApp simulateDrawing]) { + return false; + } + + /* * If the drawable is not a pixmap and it has an associated - * NSWindow then we are drawing to a window. + * NSWindow then we know we are drawing to a window. */ + if (!(macDraw->flags & TK_IS_PIXMAP)) { win = TkMacOSXDrawableWindow(d); } - + /* * Check that we have a non-empty clipping region. */ + dc.clipRgn = TkMacOSXGetClipRgn(d); ClipToGC(d, gc, &dc.clipRgn); if (dc.clipRgn && HIShapeIsEmpty(dc.clipRgn)) { @@ -1484,12 +1494,14 @@ TkMacOSXSetupDrawingContext( * are drawing to a window then we can get one from the * window. */ + dc.context = TkMacOSXGetCGContextForDrawable(d); if (dc.context) { dc.portBounds = clipBounds = CGContextGetClipBoundingBox(dc.context); } else if (win) { NSView *view = TkMacOSXDrawableView(macDraw); if (view) { + /* * We can only draw into the view when the current CGContext is * valid and belongs to the view. Validity can only be guaranteed @@ -1501,6 +1513,7 @@ TkMacOSXSetupDrawingContext( * then we mark our view as needing display and return failure. * It should get drawn in a later call to drawRect. */ + if (view != [NSView focusView]) { [view setNeedsDisplay:YES]; canDraw = false; @@ -1520,9 +1533,11 @@ TkMacOSXSetupDrawingContext( Tcl_Panic("TkMacOSXSetupDrawingContext(): " "no context to draw into !"); } + /* * Configure the drawing context. */ + if (dc.context) { CGAffineTransform t = { .a = 1, .b = 0, .c = 0, .d = -1, .tx = 0, .ty = dc.portBounds.size.height}; diff --git a/macosx/tkMacOSXEvent.c b/macosx/tkMacOSXEvent.c index 676344c..798c73c 100644 --- a/macosx/tkMacOSXEvent.c +++ b/macosx/tkMacOSXEvent.c @@ -136,22 +136,16 @@ enum { MODULE_SCOPE void TkMacOSXFlushWindows(void) { - NSModalSession modalSession = TkMacOSXGetModalSession(); - NSEvent *syncEvent; NSArray *macWindows = [NSApp orderedWindows]; + if ([NSApp simulateDrawing]) { + [NSApp setSimulateDrawing:NO]; + return; + } for (NSWindow *w in macWindows) { - if (TkMacOSXGetXWindow(w)) { - [w displayIfNeeded]; - syncEvent = [NSApp - nextEventMatchingMask:NSApplicationDefinedMask - untilDate:[NSDate distantPast] - inMode:GetRunLoopMode(modalSession) - dequeue:YES]; - [NSApp discardEventsMatchingMask:NSApplicationDefinedMask - beforeEvent:syncEvent]; - } + if (TkMacOSXGetXWindow(w)) { + [w displayIfNeeded]; + } } - } diff --git a/macosx/tkMacOSXInit.c b/macosx/tkMacOSXInit.c index 10ef87e..8e9c600 100644 --- a/macosx/tkMacOSXInit.c +++ b/macosx/tkMacOSXInit.c @@ -47,6 +47,7 @@ static char scriptPath[PATH_MAX + 1] = ""; @synthesize poolLock = _poolLock; @synthesize macMinorVersion = _macMinorVersion; @synthesize isDrawing = _isDrawing; +@synthesize simulateDrawing = _simulateDrawing; @end /* @@ -162,13 +163,14 @@ static char scriptPath[PATH_MAX + 1] = ""; systemVersion = [[NSProcessInfo processInfo] operatingSystemVersion]; minorVersion = systemVersion.minorVersion; #endif - [NSApp setMacMinorVersion: minorVersion]; + [NSApp setMacMinorVersion: minorVersion]; /* * We are not drawing yet. */ - [NSApp setIsDrawing: NO]; + [NSApp setIsDrawing:NO]; + [NSApp setSimulateDrawing:NO]; /* * Be our own delegate. @@ -178,6 +180,7 @@ static char scriptPath[PATH_MAX + 1] = ""; /* * Make sure we are allowed to open windows. */ + [NSApp setActivationPolicy:NSApplicationActivationPolicyRegular]; /* diff --git a/macosx/tkMacOSXInt.h b/macosx/tkMacOSXInt.h index 6108383..f04d9dc 100644 --- a/macosx/tkMacOSXInt.h +++ b/macosx/tkMacOSXInt.h @@ -200,7 +200,8 @@ MODULE_SCOPE void TkpReleaseRegion(TkRegion r); MODULE_SCOPE void TkpShiftButton(NSButton *button, NSPoint delta); MODULE_SCOPE Bool TkpAppIsDrawing(void); MODULE_SCOPE void TkpDisplayWindow(Tk_Window tkwin); -MODULE_SCOPE NSString* GetRunLoopMode(NSModalSession modalSession); +MODULE_SCOPE void TkTestSimulateDrawing(Bool); + /* * Include the stubbed internal platform-specific API. */ diff --git a/macosx/tkMacOSXPrivate.h b/macosx/tkMacOSXPrivate.h index f5924e5..5eef949 100644 --- a/macosx/tkMacOSXPrivate.h +++ b/macosx/tkMacOSXPrivate.h @@ -266,11 +266,13 @@ VISIBILITY_HIDDEN int _poolLock; int _macMinorVersion; Bool _isDrawing; + Bool _simulateDrawing; #endif } @property int poolLock; @property int macMinorVersion; @property Bool isDrawing; +@property Bool simulateDrawing; @end @interface TKApplication(TKInit) diff --git a/macosx/tkMacOSXTest.c b/macosx/tkMacOSXTest.c index 92c925c..5576c44 100644 --- a/macosx/tkMacOSXTest.c +++ b/macosx/tkMacOSXTest.c @@ -82,25 +82,28 @@ DebuggerObjCmd( /* *---------------------------------------------------------------------- * - * TkTestAppIsDrawing -- + * TkTestSimulateDrawing -- + * + * A test widget display procedure which records calls can use this to + * avoid duplicate calls which would occur due to fact that no valid + * graphics context is available to the idle task which is running the + * display proc. Note that no actual drawing to the screen will take + * place when this flag is set. This is just a wrapper for the NSApp + * property. * - * A widget display procedure can call this to determine whether it - * is being run inside of the drawRect method. This is needed for - * some tests, especially of the Text widget, which record data in - * a global Tcl variable and assume that display procedures will be - * run in a predictable sequence as Tcl idle tasks. * * Results: - * True only while running the drawRect method of a TKContentView; + * Calls to low level drawing routines will return without actually + * drawing anything to the screen. * * Side effects: * None * *---------------------------------------------------------------------- */ -MODULE_SCOPE Bool -TkTestAppIsDrawing(void) { - return [NSApp isDrawing]; +MODULE_SCOPE void +TkTestSimulateDrawing(Bool yesno) { + [NSApp setSimulateDrawing:yesno]; } diff --git a/macosx/tkMacOSXWindowEvent.c b/macosx/tkMacOSXWindowEvent.c index f69ee0c..724a9af 100644 --- a/macosx/tkMacOSXWindowEvent.c +++ b/macosx/tkMacOSXWindowEvent.c @@ -832,14 +832,19 @@ ConfigureRestrictProc( Tk_PathName(winPtr)); #endif + if ([NSApp simulateDrawing]) { + return; + } + /* - * We do not allow recursive calls to drawRect. Only log this - * in 10.14 and higher, where it should not happen. + * We do not allow recursive calls to drawRect. */ - if ([NSApp isDrawing] && [NSApp macMinorVersion] > 13) { + + if ([NSApp isDrawing]) { TKLog(@"WARNING: a recursive call to drawRect was aborted."); return; } + [NSApp setIsDrawing: YES]; [self getRectsBeingDrawn:&rectsBeingDrawn count:&rectsBeingDrawnCount]; @@ -861,22 +866,6 @@ ConfigureRestrictProc( CFRelease(drawShape); [NSApp setIsDrawing: NO]; - /* - * To make it possible to wait for this method, we post an application - * defined event when all drawing has been done. - */ - NSEvent* drawEvent = [NSEvent otherEventWithType:NSApplicationDefined - location:NSMakePoint(0,0) - modifierFlags:0 - timestamp:0 - windowNumber:[[self window] windowNumber] - context:nil - subtype:1 - data1:0 - data2:0 - ]; - [NSApp postEvent:drawEvent atStart:YES]; - #ifdef TK_MAC_DEBUG_DRAWING fprintf(stderr, "drawRect: done.\n"); #endif -- cgit v0.12 From 52bdce0ef2fe1a7ad9884d739ccab438740b4db1 Mon Sep 17 00:00:00 2001 From: culler Date: Tue, 6 Nov 2018 22:02:31 +0000 Subject: Quiet the warning about recursive calls to drawRect on older systems where they are unavoidable. --- macosx/tkMacOSXWindowEvent.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/macosx/tkMacOSXWindowEvent.c b/macosx/tkMacOSXWindowEvent.c index 724a9af..c463875 100644 --- a/macosx/tkMacOSXWindowEvent.c +++ b/macosx/tkMacOSXWindowEvent.c @@ -837,10 +837,11 @@ ConfigureRestrictProc( } /* - * We do not allow recursive calls to drawRect. + * We do not allow recursive calls to drawRect, but we only log + * them on OSX > 10.13, where they should never happen. */ - if ([NSApp isDrawing]) { + if ([NSApp isDrawing] && [NSApp macMinorVersion] > 13) { TKLog(@"WARNING: a recursive call to drawRect was aborted."); return; } -- cgit v0.12 From 6a78e0b7fc7c69f35442f490812e5265db8e8470 Mon Sep 17 00:00:00 2001 From: culler Date: Wed, 7 Nov 2018 21:17:25 +0000 Subject: Fix two image bugs. BitmapImageReps may have bytesPerRow > 4*width. Do not copy from a window to a bitmap if the contentView does not have a valid graphics context. --- macosx/tkMacOSXDraw.c | 22 +++++++++++++++++++--- macosx/tkMacOSXImage.c | 6 +++--- 2 files changed, 22 insertions(+), 6 deletions(-) diff --git a/macosx/tkMacOSXDraw.c b/macosx/tkMacOSXDraw.c index 42c9059..bff2f93 100644 --- a/macosx/tkMacOSXDraw.c +++ b/macosx/tkMacOSXDraw.c @@ -155,16 +155,32 @@ TkMacOSXBitmapRepFromDrawableRect( CGImageRelease(cg_image); } } else if ( (view = TkMacOSXDrawableView(mac_drawable)) ) { + /* * Convert Tk top-left to NSView bottom-left coordinates. */ + int view_height = [view bounds].size.height; NSRect view_rect = NSMakeRect(x + mac_drawable->xOff, view_height - height - y - mac_drawable->yOff, width, height); - bitmap_rep = [view bitmapImageRepForCachingDisplayInRect: view_rect]; - [bitmap_rep retain]; - [view cacheDisplayInRect:view_rect toBitmapImageRep:bitmap_rep]; + + /* + * Attempt to copy from the view to a bitmapImageRep. If the view does + * not have a valid CGContext, doing this will silently corrupt memory + * and make a big mess. So, in that case, we mark the view as needing + * display and return NULL. + */ + + if (view == [NSView focusView]) { + bitmap_rep = [view bitmapImageRepForCachingDisplayInRect: view_rect]; + [bitmap_rep retain]; + [view cacheDisplayInRect:view_rect toBitmapImageRep:bitmap_rep]; + } else { + TkMacOSXDbgMsg("No CGContext - cannot copy from screen to bitmap."); + [view setNeedsDisplay:YES]; + return NULL; + } } else { TkMacOSXDbgMsg("Invalid source drawable"); } diff --git a/macosx/tkMacOSXImage.c b/macosx/tkMacOSXImage.c index 096faac..861b7ab 100644 --- a/macosx/tkMacOSXImage.c +++ b/macosx/tkMacOSXImage.c @@ -206,7 +206,7 @@ XGetImage( (bitmap_fmt != 0 && bitmap_fmt != 1) || [bitmap_rep samplesPerPixel] != 4 || [bitmap_rep isPlanar] != 0 || - bytes_per_row != 4 * scaled_width || + bytes_per_row < 4 * scaled_width || size != bytes_per_row*scaled_height ) { TkMacOSXDbgMsg("XGetImage: Unrecognized bitmap format"); CFRelease(bitmap_rep); @@ -237,8 +237,8 @@ XGetImage( */ struct pixel_fmt pixel = bitmap_fmt == 0 ? bgra : abgr; - for (row=0, n=0; row Date: Wed, 7 Nov 2018 23:59:23 +0000 Subject: Fix crash due to key events from the about dialog having an NSWindow with no Tk window. --- macosx/tkMacOSXKeyEvent.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/macosx/tkMacOSXKeyEvent.c b/macosx/tkMacOSXKeyEvent.c index f79185e..e717a20 100644 --- a/macosx/tkMacOSXKeyEvent.c +++ b/macosx/tkMacOSXKeyEvent.c @@ -68,15 +68,19 @@ unsigned short releaseCode; processingCompose = NO; } + w = [theEvent window]; + TkWindow *winPtr = TkMacOSXGetTkWindow(w); + Tk_Window tkwin = (Tk_Window) winPtr; + XEvent xEvent; + + if (!winPtr) { + return theEvent; + } + switch (type) { case NSKeyUp: - /*Fix for bug #1ba71a86bb: key release firing on key press.*/ - w = [theEvent window]; - XEvent xEvent; setupXEvent(&xEvent, w, 0); - TkWindow *winPtr = TkMacOSXGetTkWindow(w); - Tk_Window tkwin = (Tk_Window) winPtr; xEvent.xany.type = KeyRelease; xEvent.xkey.keycode = releaseCode; xEvent.xany.serial = LastKnownRequestProcessed(Tk_Display(tkwin)); @@ -89,7 +93,7 @@ unsigned short releaseCode; modifiers = [theEvent modifierFlags]; keyCode = [theEvent keyCode]; // w = [self windowWithWindowNumber:[theEvent windowNumber]]; - w = [theEvent window]; + // w = [theEvent window]; #if defined(TK_MAC_DEBUG_EVENTS) || NS_KEYLOG == 1 TKLog(@"-[%@(%p) %s] r=%d mods=%u '%@' '%@' code=%u c=%d %@ %d", [self class], self, _cmd, repeat, modifiers, characters, charactersIgnoringModifiers, keyCode,([charactersIgnoringModifiers length] == 0) ? 0 : [charactersIgnoringModifiers characterAtIndex: 0], w, type); #endif -- cgit v0.12 From cba8fd61558c413f6d5e5833ffe2e0ceeb0dd225 Mon Sep 17 00:00:00 2001 From: culler Date: Thu, 8 Nov 2018 00:01:46 +0000 Subject: Remove code that was commented out. --- macosx/tkMacOSXKeyEvent.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/macosx/tkMacOSXKeyEvent.c b/macosx/tkMacOSXKeyEvent.c index e717a20..46662e5 100644 --- a/macosx/tkMacOSXKeyEvent.c +++ b/macosx/tkMacOSXKeyEvent.c @@ -76,7 +76,7 @@ unsigned short releaseCode; if (!winPtr) { return theEvent; } - + switch (type) { case NSKeyUp: /*Fix for bug #1ba71a86bb: key release firing on key press.*/ @@ -92,8 +92,7 @@ unsigned short releaseCode; case NSFlagsChanged: modifiers = [theEvent modifierFlags]; keyCode = [theEvent keyCode]; - // w = [self windowWithWindowNumber:[theEvent windowNumber]]; - // w = [theEvent window]; + #if defined(TK_MAC_DEBUG_EVENTS) || NS_KEYLOG == 1 TKLog(@"-[%@(%p) %s] r=%d mods=%u '%@' '%@' code=%u c=%d %@ %d", [self class], self, _cmd, repeat, modifiers, characters, charactersIgnoringModifiers, keyCode,([charactersIgnoringModifiers length] == 0) ? 0 : [charactersIgnoringModifiers characterAtIndex: 0], w, type); #endif -- cgit v0.12 From 57910ea38c9be2a08d11e28b5278a1400c444baa Mon Sep 17 00:00:00 2001 From: Kevin Walzer Date: Thu, 8 Nov 2018 03:03:44 +0000 Subject: Replace old about dialog with standard alert that displays correctly on 10.14 --- macosx/tkMacOSXDialog.c | 43 +++++++++++++------------------------------ 1 file changed, 13 insertions(+), 30 deletions(-) diff --git a/macosx/tkMacOSXDialog.c b/macosx/tkMacOSXDialog.c index 8d20d4e..5c4f38d 100644 --- a/macosx/tkMacOSXDialog.c +++ b/macosx/tkMacOSXDialog.c @@ -1198,36 +1198,19 @@ TkAboutDlg(void) NSString *year = [dateFormatter stringFromDate:[NSDate date]]; [dateFormatter release]; - - NSMutableParagraphStyle *style = - [[[NSParagraphStyle defaultParagraphStyle] mutableCopy] - autorelease]; - - [style setAlignment:NSCenterTextAlignment]; - - NSDictionary *options = [NSDictionary dictionaryWithObjectsAndKeys: - @"Tcl & Tk", @"ApplicationName", - @"Tcl " TCL_VERSION " & Tk " TK_VERSION, @"ApplicationVersion", - @TK_PATCH_LEVEL, @"Version", - image, @"ApplicationIcon", - [NSString stringWithFormat:@"Copyright %1$C 1987-%2$@.", 0xA9, - year], @"Copyright", - [[[NSAttributedString alloc] initWithString: - [NSString stringWithFormat: - @"%1$C 1987-%2$@ Tcl Core Team." "\n\n" - "%1$C 1989-%2$@ Contributors." "\n\n" - "%1$C 2011-%2$@ Kevin Walzer/WordTech Communications LLC." "\n\n" - "%1$C 2014-%2$@ Marc Culler." "\n\n" - "%1$C 2002-%2$@ Daniel A. Steffen." "\n\n" - "%1$C 2001-2009 Apple Inc." "\n\n" - "%1$C 2001-2002 Jim Ingham & Ian Reid" "\n\n" - "%1$C 1998-2000 Jim Ingham & Ray Johnson" "\n\n" - "%1$C 1998-2000 Scriptics Inc." "\n\n" - "%1$C 1996-1997 Sun Microsystems Inc.", 0xA9, year] attributes: - [NSDictionary dictionaryWithObject:style - forKey:NSParagraphStyleAttributeName]] autorelease], @"Credits", - nil]; - [NSApp orderFrontStandardAboutPanelWithOptions:options]; + + /*Replace old about dialog with standard alert that displays correctly on 10.14.*/ + NSString *version = @"Tcl " TCL_PATCH_LEVEL " & Tk " TCL_PATCH_LEVEL; + NSString *copyright = @"Copyright 1987-"; + NSString *contributors = @" Tcl Core Team and Contributors"; + NSString *credits = [NSString stringWithFormat:@"%@%@%@", copyright, year, contributors]; + NSAlert *about = [[NSAlert alloc] init]; + [[about window] setTitle:@"About Tcl/Tk"]; + [about setMessageText: version]; + [about setInformativeText:credits]; + [about addButtonWithTitle:@"OK"]; + [about runModal]; + [about release]; } /* -- cgit v0.12 From 2aea1a3243ce72f485476b47d501a76bc8eb03a8 Mon Sep 17 00:00:00 2001 From: Kevin Walzer Date: Thu, 8 Nov 2018 03:17:03 +0000 Subject: One more fix for about dialog --- macosx/tkMacOSXDialog.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/macosx/tkMacOSXDialog.c b/macosx/tkMacOSXDialog.c index 5c4f38d..d790b2e 100644 --- a/macosx/tkMacOSXDialog.c +++ b/macosx/tkMacOSXDialog.c @@ -1240,7 +1240,7 @@ TkMacOSXStandardAboutPanelObjCmd( Tcl_WrongNumArgs(interp, 1, objv, NULL); return TCL_ERROR; } - [NSApp orderFrontStandardAboutPanelWithOptions:[NSDictionary dictionary]]; + TkAboutDlg(); return TCL_OK; } -- cgit v0.12 From 3391cf4be8163d08bf29e7ef2adc64bdbb030b22 Mon Sep 17 00:00:00 2001 From: Kevin Walzer Date: Thu, 8 Nov 2018 04:06:42 +0000 Subject: Tweak title of about dialog --- macosx/tkMacOSXDialog.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/macosx/tkMacOSXDialog.c b/macosx/tkMacOSXDialog.c index d790b2e..f79cad0 100644 --- a/macosx/tkMacOSXDialog.c +++ b/macosx/tkMacOSXDialog.c @@ -1205,7 +1205,7 @@ TkAboutDlg(void) NSString *contributors = @" Tcl Core Team and Contributors"; NSString *credits = [NSString stringWithFormat:@"%@%@%@", copyright, year, contributors]; NSAlert *about = [[NSAlert alloc] init]; - [[about window] setTitle:@"About Tcl/Tk"]; + [[about window] setTitle:@"About Tcl & Tk"]; [about setMessageText: version]; [about setInformativeText:credits]; [about addButtonWithTitle:@"OK"]; -- cgit v0.12 From 23edb997712e41c74e3a457f54beb42ce5ed14a4 Mon Sep 17 00:00:00 2001 From: culler Date: Thu, 8 Nov 2018 20:19:29 +0000 Subject: Fixed transparency issues and crashes related to PhotoImages and greatly simplified the PhotoImage display procedure. --- generic/tkImgPhInstance.c | 64 ++++++++++++++++--------------------- macosx/tkMacOSXDraw.c | 80 +++++++++++++++++++++++++++++------------------ macosx/tkMacOSXImage.c | 78 ++++++++++++++++++++++----------------------- macosx/tkMacOSXInt.h | 2 +- macosx/tkMacOSXPrivate.h | 3 +- 5 files changed, 115 insertions(+), 112 deletions(-) diff --git a/generic/tkImgPhInstance.c b/generic/tkImgPhInstance.c index ec9ee04..0a5be7a 100644 --- a/generic/tkImgPhInstance.c +++ b/generic/tkImgPhInstance.c @@ -30,8 +30,10 @@ extern int _XInitImageFuncPtrs(XImage *image); * Forward declarations */ +#ifndef MAC_OSX_TK static void BlendComplexAlpha(XImage *bgImg, PhotoInstance *iPtr, int xOffset, int yOffset, int width, int height); +#endif static int IsValidPalette(PhotoInstance *instancePtr, const char *palette); static int CountBits(pixel mask); @@ -409,7 +411,7 @@ TkImgPhotoGet( * *---------------------------------------------------------------------- */ - +#ifndef MAC_OSX_TK #ifndef _WIN32 #define GetRValue(rgb) (UCHAR(((rgb) & red_mask) >> red_shift)) #define GetGValue(rgb) (UCHAR(((rgb) & green_mask) >> green_shift)) @@ -418,13 +420,6 @@ TkImgPhotoGet( (UCHAR(r) << red_shift) | \ (UCHAR(g) << green_shift) | \ (UCHAR(b) << blue_shift) )) -#ifdef MAC_OSX_TK -#define RGBA(r, g, b, a) ((unsigned)( \ - (UCHAR(r) << red_shift) | \ - (UCHAR(g) << green_shift) | \ - (UCHAR(b) << blue_shift) | \ - (UCHAR(a) << alpha_shift) )) -#endif #define RGB15(r, g, b) ((unsigned)( \ (((r) * red_mask / 255) & red_mask) | \ (((g) * green_mask / 255) & green_mask) | \ @@ -443,16 +438,7 @@ BlendComplexAlpha( unsigned long pixel; unsigned char r, g, b, alpha, unalpha, *masterPtr; unsigned char *alphaAr = iPtr->masterPtr->pix32; -#if defined(MAC_OSX_TK) - /* Background "pixels" are actually 2^pp x 2^pp blocks of subpixels. Each - * block gets blended with the color of one image pixel. Since we iterate - * over the background subpixels, we reset the width and height to the - * subpixel dimensions of the background image we are using. - */ - int pp = bgImg->pixelpower; - width = width << pp; - height = height << pp; -#endif + /* * This blending is an integer version of the Source-Over compositing rule * (see Porter&Duff, "Compositing Digital Images", proceedings of SIGGRAPH @@ -492,13 +478,6 @@ BlendComplexAlpha( while ((0x0001 & (blue_mask >> blue_shift)) == 0) { blue_shift++; } -#ifdef MAC_OSX_TK - unsigned long alpha_mask = visual->alpha_mask; - unsigned long alpha_shift = 0; - while ((0x0001 & (alpha_mask >> alpha_shift)) == 0) { - alpha_shift++; - } -#endif #endif /* !_WIN32 */ /* @@ -558,16 +537,9 @@ BlendComplexAlpha( #endif /* !_WIN32 && !MAC_OSX_TK */ for (y = 0; y < height; y++) { -# if !defined(MAC_OSX_TK) line = (y + yOffset) * iPtr->masterPtr->width; for (x = 0; x < width; x++) { masterPtr = alphaAr + ((line + x + xOffset) * 4); -#else - /* Repeat each image row and column 2^pp times. */ - line = ((y>>pp) + yOffset) * iPtr->masterPtr->width; - for (x = 0; x < width; x++) { - masterPtr = alphaAr + ((line + (x>>pp) + xOffset) * 4); -#endif alpha = masterPtr[3]; /* @@ -599,16 +571,13 @@ BlendComplexAlpha( g = ALPHA_BLEND(ga, g, alpha, unalpha); b = ALPHA_BLEND(ba, b, alpha, unalpha); } -#ifndef MAC_OSX_TK XPutPixel(bgImg, x, y, RGB(r, g, b)); -#else - XPutPixel(bgImg, x, y, RGBA(r, g, b, alpha)); -#endif } } } #undef ALPHA_BLEND } +#endif /* MAC_OSX_TK */ /* *---------------------------------------------------------------------- @@ -640,7 +609,6 @@ TkImgPhotoDisplay( * to imageX and imageY. */ { PhotoInstance *instancePtr = clientData; - XVisualInfo visInfo = instancePtr->visualInfo; /* * If there's no pixmap, it means that an error occurred while creating @@ -651,6 +619,27 @@ TkImgPhotoDisplay( return; } +#ifdef MAC_OSX_TK + /* + * The Mac version of TkPutImage handles RGBA images directly. There is + * no need to call XGetImage or to do the Porter-Duff compositing by hand. + * We just let the CG graphics library do it, using the graphics hardware. + */ + unsigned char *rgbaPixels = instancePtr->masterPtr->pix32; + + XImage *photo = XCreateImage(display, NULL, 32, ZPixmap, 0, (char*)rgbaPixels, + (unsigned int)instancePtr->width, + (unsigned int)instancePtr->height, + 0, (unsigned int)(4 * instancePtr->width)); + + TkPutImage(NULL, 0, display, drawable, instancePtr->gc, + photo, imageX, imageY, drawableX, drawableY, + (unsigned int) width, (unsigned int) height); + photo->data = NULL; + XDestroyImage(photo); +#else + XVisualInfo visInfo = instancePtr->visualInfo; + if ((instancePtr->masterPtr->flags & COMPLEX_ALPHA) && visInfo.depth >= 15 && (visInfo.class == DirectColor || visInfo.class == TrueColor)) { @@ -709,6 +698,7 @@ TkImgPhotoDisplay( XSetClipOrigin(display, instancePtr->gc, 0, 0); } XFlush(display); +#endif } /* diff --git a/macosx/tkMacOSXDraw.c b/macosx/tkMacOSXDraw.c index bff2f93..984e2e5 100644 --- a/macosx/tkMacOSXDraw.c +++ b/macosx/tkMacOSXDraw.c @@ -111,6 +111,25 @@ TkMacOSXInitCGDrawing( * * Extract bitmap data from a MacOSX drawable as an NSBitmapImageRep. * + * This is only used by XGetImage, which is never called. And this + * implementation does not work correctly. Originally it relied on + * [NSBitmapImageRep initWithFocusedViewRect:view_rect] which was + * deprecated by Apple in OSX 10.14 and also required the use of other + * deprecated functions such as [NSView lockFocus]. Apple's suggested + * replacement is [NSView cacheDisplayInRect: toBitmapImageRep:] and that + * is what is being used here. However, that method only works when the + * view has a valid CGContext, and a view is only guaranteed to have a + * valid context during a call to [NSView drawRect]. To further + * complicate matters, cacheDisplayInRect calls [NSView drawRect]. + * Essentially it is asking the view to draw a subrectangle of itself into + * a special graphics context which is linked to the BitmapImageRep. But + * our implementation of [NSView drawRect] does not allow recursive calls. + * If called recursively it returns immediately without doing any drawing. + * So the bottom line is that this function either returns a NULL pointer + * or a black image. To make it useful would require a significant amount + * of rewriting of the drawRect method. Perhaps the next release of OSX + * will include some more helpful ways of doing this. + * * Results: * Returns an NSBitmapRep representing the image of the given * rectangle of the given drawable. This object is retained. @@ -134,15 +153,16 @@ TkMacOSXBitmapRepFromDrawableRect( unsigned int height) { MacDrawable *mac_drawable = (MacDrawable *) drawable; - CGContextRef cg_context=NULL; - CGImageRef cg_image=NULL, sub_cg_image=NULL; - NSBitmapImageRep *bitmap_rep=NULL; + CGContextRef cg_context = NULL; + CGImageRef cg_image=NULL, sub_cg_image = NULL; + NSBitmapImageRep *bitmap_rep = NULL; NSView *view=NULL; if ( mac_drawable->flags & TK_IS_PIXMAP ) { + /* - * This means that the MacDrawable is functioning as a - * Tk Pixmap, so its view field is NULL. - */ + * This MacDrawable is a bitmap, so its view is NULL. + */ + cg_context = TkMacOSXGetCGContextForDrawable(drawable); CGRect image_rect = CGRectMake(x, y, width, height); cg_image = CGBitmapContextCreateImage( (CGContextRef) cg_context); @@ -168,10 +188,10 @@ TkMacOSXBitmapRepFromDrawableRect( /* * Attempt to copy from the view to a bitmapImageRep. If the view does * not have a valid CGContext, doing this will silently corrupt memory - * and make a big mess. So, in that case, we mark the view as needing + * and make a big mess. So, in that case, we mark the view as needing * display and return NULL. */ - + if (view == [NSView focusView]) { bitmap_rep = [view bitmapImageRepForCachingDisplayInRect: view_rect]; [bitmap_rep retain]; @@ -221,26 +241,24 @@ XCopyArea( MacDrawable *srcDraw = (MacDrawable *) src; NSBitmapImageRep *bitmap_rep = NULL; CGImageRef img = NULL; + CGRect bounds, srcRect, dstRect; display->request++; - if (!width || !height) { - /* This happens all the time. - TkMacOSXDbgMsg("Drawing of empty area requested"); - */ return; } if (!TkMacOSXSetupDrawingContext(dst, gc, 1, &dc)) { return; - /*TkMacOSXDbgMsg("Failed to setup drawing context.");*/ + TkMacOSXDbgMsg("Failed to setup drawing context."); } if ( dc.context ) { if (srcDraw->flags & TK_IS_PIXMAP) { img = TkMacOSXCreateCGImageWithDrawable(src); }else if (TkMacOSXDrawableWindow(src)) { - bitmap_rep = TkMacOSXBitmapRepFromDrawableRect(src, src_x, src_y, width, height); + bitmap_rep = TkMacOSXBitmapRepFromDrawableRect(src, + src_x, src_y, width, height); if ( bitmap_rep ) { img = [bitmap_rep CGImage]; } @@ -249,13 +267,12 @@ XCopyArea( } if (img) { - TkMacOSXDrawCGImage(dst, gc, dc.context, img, gc->foreground, gc->background, - CGRectMake(0, 0, srcDraw->size.width, srcDraw->size.height), - CGRectMake(src_x, src_y, width, height), - CGRectMake(dest_x, dest_y, width, height)); + bounds = CGRectMake(0, 0, srcDraw->size.width, srcDraw->size.height); + srcRect = CGRectMake(src_x, src_y, width, height); + dstRect = CGRectMake(dest_x, dest_y, width, height); + TkMacOSXDrawCGImage(dst, gc, dc.context, img, + gc->foreground, gc->background, bounds, srcRect, dstRect); CFRelease(img); - - } else { TkMacOSXDbgMsg("Failed to construct CGImage."); } @@ -304,7 +321,7 @@ XCopyPlane( TkMacOSXDrawingContext dc; MacDrawable *srcDraw = (MacDrawable *) src; MacDrawable *dstDraw = (MacDrawable *) dst; - + CGRect bounds, srcRect, dstRect; display->request++; if (!width || !height) { /* TkMacOSXDbgMsg("Drawing of empty area requested"); */ @@ -324,7 +341,7 @@ XCopyPlane( TkpClipMask *clipPtr = (TkpClipMask *) gc->clip_mask; unsigned long imageBackground = gc->background; if (clipPtr && clipPtr->type == TKP_CLIP_PIXMAP){ - CGRect srcRect = CGRectMake(src_x, src_y, width, height); + srcRect = CGRectMake(src_x, src_y, width, height); CGImageRef mask = TkMacOSXCreateCGImageWithDrawable(clipPtr->value.pixmap); CGImageRef submask = CGImageCreateWithImageInRect(img, srcRect); CGRect rect = CGRectMake(dest_x, dest_y, width, height); @@ -349,10 +366,11 @@ XCopyPlane( CGImageRelease(submask); CGImageRelease(subimage); } else { - TkMacOSXDrawCGImage(dst, gc, dc.context, img, gc->foreground, imageBackground, - CGRectMake(0, 0, srcDraw->size.width, srcDraw->size.height), - CGRectMake(src_x, src_y, width, height), - CGRectMake(dest_x, dest_y, width, height)); + bounds = CGRectMake(0, 0, srcDraw->size.width, srcDraw->size.height); + srcRect = CGRectMake(src_x, src_y, width, height); + dstRect = CGRectMake(dest_x, dest_y, width, height); + TkMacOSXDrawCGImage(dst, gc, dc.context, img, gc->foreground, + imageBackground, bounds, srcRect, dstRect); CGImageRelease(img); } } else { /* no image */ @@ -456,10 +474,8 @@ TkMacOSXGetNSImageWithTkImage( int height) { Pixmap pixmap = Tk_GetPixmap(display, None, width, height, 0); - MacDrawable *macDraw = (MacDrawable *) pixmap; NSImage *nsImage; - macDraw->flags |= TK_USE_XIMAGE_ALPHA; Tk_RedrawImage(image, 0, 0, width, height, pixmap, 0, 0); nsImage = CreateNSImageWithPixmap(pixmap, width, height); Tk_FreePixmap(display, pixmap); @@ -612,11 +628,13 @@ TkMacOSXDrawCGImage( } } dstBounds = CGRectOffset(dstBounds, macDraw->xOff, macDraw->yOff); - if (CGImageIsMask(image)) { - /*CGContextSaveGState(context);*/ if (macDraw->flags & TK_IS_BW_PIXMAP) { - /* Set fill color to black, background comes from the context, or is transparent. */ + + /* Set fill color to black; background comes from the context, + * or is transparent. + */ + if (imageBackground != TRANSPARENT_PIXEL << 24) { CGContextClearRect(context, dstBounds); } diff --git a/macosx/tkMacOSXImage.c b/macosx/tkMacOSXImage.c index 861b7ab..2b747f1 100644 --- a/macosx/tkMacOSXImage.c +++ b/macosx/tkMacOSXImage.c @@ -6,7 +6,7 @@ * Copyright (c) 1995-1997 Sun Microsystems, Inc. * Copyright 2001-2009, Apple Inc. * Copyright (c) 2005-2009 Daniel A. Steffen - * Copyright 2017 Marc Culler. + * Copyright 2017-2018 Marc Culler. * * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. @@ -29,7 +29,8 @@ _XInitImageFuncPtrs( * * TkMacOSXCreateCGImageWithXImage -- * - * Create CGImage from XImage, copying the image data. + * Create CGImage from XImage, copying the image data. Called + * in Tk_PutImage and (currently) nowhere else. * * Results: * CGImage, release after use. @@ -46,8 +47,7 @@ static void ReleaseData(void *info, const void *data, size_t size) { CGImageRef TkMacOSXCreateCGImageWithXImage( - XImage *image, - int use_ximage_alpha) + XImage *image) { CGImageRef img = NULL; size_t bitsPerComponent, bitsPerPixel; @@ -88,21 +88,17 @@ TkMacOSXCreateCGImageWithXImage( bitsPerPixel, image->bytes_per_line, provider, decode, 0); } } else if (image->format == ZPixmap && image->bits_per_pixel == 32) { + /* * Color image */ CGColorSpaceRef colorspace = CGColorSpaceCreateDeviceRGB(); - bitsPerComponent = 8; bitsPerPixel = 32; bitmapInfo = (image->byte_order == MSBFirst ? - kCGBitmapByteOrder32Big : kCGBitmapByteOrder32Little); - if (use_ximage_alpha) { - bitmapInfo |= kCGImageAlphaPremultipliedFirst; - } else { - bitmapInfo |= kCGImageAlphaNoneSkipFirst; - } + kCGBitmapByteOrder32Little : kCGBitmapByteOrder32Big); + bitmapInfo |= kCGImageAlphaLast; data = memcpy(ckalloc(len), image->data + image->xoffset, len); if (data) { provider = CGDataProviderCreateWithData(data, data, len, releaseData); @@ -128,7 +124,12 @@ TkMacOSXCreateCGImageWithXImage( * * XGetImage -- * - * This function copies data from a pixmap or window into an XImage. + * This function copies data from a pixmap or window into an XImage. It + * is essentially never used. At one time it was called by + * pTkImgPhotoDisplay, but that is no longer the case. Currently it is + * called two places, one of which is requesting an XY image which we do + * not support. It probably does not work correctly -- see the comments + * for TkMacOSXBitmapRepFromDrawableRect. * * Results: * Returns a newly allocated XImage containing the data from the given @@ -165,7 +166,6 @@ XGetImage( unsigned int bytes_per_row, size, row, n, m; unsigned int scalefactor=1, scaled_height=height, scaled_width=width; NSWindow *win = TkMacOSXDrawableWindow(drawable); - MacDrawable *macDraw = ((MacDrawable*)drawable); static enum {unknown, no, yes} has_retina = unknown; if (win && has_retina == unknown) { @@ -178,9 +178,11 @@ XGetImage( } if (has_retina == yes) { + /* * We only allow scale factors 1 or 2, as Apple currently does. */ + #ifdef __clang__ scalefactor = [win backingScaleFactor] == 2.0 ? 2 : 1; #endif @@ -192,8 +194,9 @@ XGetImage( if (width == 0 || height == 0) { return NULL; } + bitmap_rep = TkMacOSXBitmapRepFromDrawableRect(drawable, - x, y, width, height); + x, y, width, height); if (!bitmap_rep) { TkMacOSXDbgMsg("XGetImage: Failed to construct NSBitmapRep"); return NULL; @@ -212,29 +215,14 @@ XGetImage( CFRelease(bitmap_rep); return NULL; } - - if (macDraw->flags & TK_USE_XIMAGE_ALPHA) { - /* - * When called by TkImgPhotoDisplay we are being asked to return a - * background image to be blended with the photoimage using its - * alpha channel, if it has one. Returning a black pixmap here - * makes TkImgPhotoDisplay create an XImage with a premultiplied - * alpha channel, as favored by Apple. When TkImgPhotoDisplay - * passes this XImage to TkPutImage, targeting a pixmap, it creates - * an image with correct transparency. This is used, for example, - * when creating an iconphoto or a menu image from a PNG - * photoimage. - */ - bzero(bitmap, size); - } else { - memcpy(bitmap, (char *)[bitmap_rep bitmapData], size); - } + memcpy(bitmap, (char *)[bitmap_rep bitmapData], size); CFRelease(bitmap_rep); /* * When Apple extracts a bitmap from an NSView, it may be in * either BGRA or ABGR format. For an XImage we need RGBA. */ + struct pixel_fmt pixel = bitmap_fmt == 0 ? bgra : abgr; for (row = 0, n = 0; row < scaled_height; row++, n += bytes_per_row) { @@ -514,8 +502,9 @@ XCreateImage( * * TkPutImage -- * - * Copies a subimage from an in-memory image to a rectangle of - * of the specified drawable. + * Copies a rectangular subimage of an XImage into a drawable. + * Currently this is only called by TkImgPhotoDisplay, using + * a Window as the drawable. * * Results: * None. @@ -542,23 +531,30 @@ TkPutImage( unsigned int height) /* distination and source. */ { TkMacOSXDrawingContext dc; - MacDrawable *macDraw = ((MacDrawable*)drawable); display->request++; if (!TkMacOSXSetupDrawingContext(drawable, gc, 1, &dc)) { return BadDrawable; } if (dc.context) { - CGImageRef img = TkMacOSXCreateCGImageWithXImage(image, - macDraw->flags & TK_USE_XIMAGE_ALPHA); + CGRect bounds, srcRect, dstRect; + CGImageRef img = TkMacOSXCreateCGImageWithXImage(image); + CGContextSetBlendMode(dc.context, kCGBlendModeSourceAtop); if (img) { - /* If the XImage has big pixels, rescale the source dimensions.*/ + + /* If the XImage has big pixels, the source is rescaled to reflect + * the actual pixel dimensions. This is not currently used, but + * could arise if the image were copied from a retina monitor and + * redrawn on an ordinary monitor. + */ + int pp = image->pixelpower; + bounds = CGRectMake(0, 0, image->width, image->height); + srcRect = CGRectMake(src_x<foreground, gc->background, - CGRectMake(0, 0, image->width<height<foreground, gc->background, + bounds, srcRect, dstRect); CFRelease(img); } else { TkMacOSXDbgMsg("Invalid source drawable"); diff --git a/macosx/tkMacOSXInt.h b/macosx/tkMacOSXInt.h index f04d9dc..4e1e689 100644 --- a/macosx/tkMacOSXInt.h +++ b/macosx/tkMacOSXInt.h @@ -86,7 +86,7 @@ typedef struct TkWindowPrivate MacDrawable; #define TK_IS_PIXMAP 0x10 #define TK_IS_BW_PIXMAP 0x20 #define TK_DO_NOT_DRAW 0x40 -#define TK_USE_XIMAGE_ALPHA 0x80 + /* * I am reserving TK_EMBEDDED = 0x100 in the MacDrawable flags * This is defined in tk.h. We need to duplicate the TK_EMBEDDED flag in the diff --git a/macosx/tkMacOSXPrivate.h b/macosx/tkMacOSXPrivate.h index 5eef949..cd29791 100644 --- a/macosx/tkMacOSXPrivate.h +++ b/macosx/tkMacOSXPrivate.h @@ -189,8 +189,7 @@ MODULE_SCOPE int TkGenerateButtonEventForXPointer(Window window); MODULE_SCOPE EventModifiers TkMacOSXModifierState(void); MODULE_SCOPE NSBitmapImageRep* TkMacOSXBitmapRepFromDrawableRect(Drawable drawable, int x, int y, unsigned int width, unsigned int height); -MODULE_SCOPE CGImageRef TkMacOSXCreateCGImageWithXImage(XImage *image, - int use_ximage_alpha); +MODULE_SCOPE CGImageRef TkMacOSXCreateCGImageWithXImage(XImage *image); MODULE_SCOPE void TkMacOSXDrawCGImage(Drawable d, GC gc, CGContextRef context, CGImageRef image, unsigned long imageForeground, unsigned long imageBackground, CGRect imageBounds, -- cgit v0.12 From 653b68156bf6eb7fa6514493fa5e02bb6e5734c6 Mon Sep 17 00:00:00 2001 From: culler Date: Thu, 8 Nov 2018 21:45:43 +0000 Subject: Restore the list of contributors to the new About dialog. --- macosx/tkMacOSXDialog.c | 37 ++++++++++++++++++++++++++++++------- 1 file changed, 30 insertions(+), 7 deletions(-) diff --git a/macosx/tkMacOSXDialog.c b/macosx/tkMacOSXDialog.c index f79cad0..f8453c7 100644 --- a/macosx/tkMacOSXDialog.c +++ b/macosx/tkMacOSXDialog.c @@ -1199,16 +1199,39 @@ TkAboutDlg(void) [dateFormatter release]; - /*Replace old about dialog with standard alert that displays correctly on 10.14.*/ + /* + * This replaces the old about dialog with a standard alert that displays + * correctly on 10.14. + */ + NSString *version = @"Tcl " TCL_PATCH_LEVEL " & Tk " TCL_PATCH_LEVEL; - NSString *copyright = @"Copyright 1987-"; - NSString *contributors = @" Tcl Core Team and Contributors"; - NSString *credits = [NSString stringWithFormat:@"%@%@%@", copyright, year, contributors]; - NSAlert *about = [[NSAlert alloc] init]; + NSString *url = @"www.tcl-lang.org"; + NSTextView *credits = [[NSTextView alloc] initWithFrame:NSMakeRect(0,0,300,300)]; + NSFont *font = [NSFont systemFontOfSize:[NSFont systemFontSize]]; + NSDictionary *textAttributes = [NSDictionary dictionaryWithObject:font + forKey:NSFontAttributeName]; + [credits insertText: [[NSAttributedString alloc] + initWithString:[NSString stringWithFormat: @"\n" + "Tcl and Tk are distributed under a modified BSD license: " + "www.tcl.tk/software/tcltk/license.html\n\n" + "%1$C 1987-%2$@ Tcl Core Team and Contributers.\n\n" + "%1$C 2011-%2$@ Kevin Walzer/WordTech Communications LLC.\n\n" + "%1$C 2014-%2$@ Marc Culler.\n\n" + "%1$C 2002-2012 Daniel A. Steffen.\n\n" + "%1$C 2001-2009 Apple Inc.\n\n" + "%1$C 2001-2002 Jim Ingham & Ian Reid\n\n" + "%1$C 1998-2000 Jim Ingham & Ray Johnson\n\n" + "%1$C 1998-2000 Scriptics Inc.\n\n" + "%1$C 1996-1997 Sun Microsystems Inc.", 0xA9, year] + attributes:textAttributes] + replacementRange:NSMakeRange(0,0)]; + [credits setDrawsBackground:NO]; + [credits setEditable:NO]; + NSAlert *about = [[NSAlert alloc] init]; [[about window] setTitle:@"About Tcl & Tk"]; [about setMessageText: version]; - [about setInformativeText:credits]; - [about addButtonWithTitle:@"OK"]; + [about setInformativeText:url]; + about.accessoryView = credits; [about runModal]; [about release]; } -- cgit v0.12 From edeaa03fec080516ed29f71138581e4310c5ec86 Mon Sep 17 00:00:00 2001 From: fvogel Date: Fri, 9 Nov 2018 21:56:05 +0000 Subject: Fix spelling in comment (GitHub PR #4, chrstphrchvz) --- macosx/tkMacOSXXStubs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/macosx/tkMacOSXXStubs.c b/macosx/tkMacOSXXStubs.c index 17cbc46..ee33537 100644 --- a/macosx/tkMacOSXXStubs.c +++ b/macosx/tkMacOSXXStubs.c @@ -3,7 +3,7 @@ * * This file contains most of the X calls called by Tk. Many of these * calls are just stubs and either don't make sense on the Macintosh or - * their implamentation just doesn't do anything. Other calls will + * their implementation just doesn't do anything. Other calls will * eventually be moved into other files. * * Copyright (c) 1995-1997 Sun Microsystems, Inc. -- cgit v0.12 From bfc96895328c38d81ad657b7a5d620ad42e67796 Mon Sep 17 00:00:00 2001 From: culler Date: Sat, 10 Nov 2018 00:45:34 +0000 Subject: TkPutImage should not assume that a pixmap is transparent, even though it does have alpha=0. --- generic/tkImgPhInstance.c | 1 - macosx/tkMacOSXImage.c | 10 +++++++++- macosx/tkMacOSXXStubs.c | 1 - xlib/X11/Xlib.h | 4 ---- 4 files changed, 9 insertions(+), 7 deletions(-) diff --git a/generic/tkImgPhInstance.c b/generic/tkImgPhInstance.c index 0a5be7a..76c4a8a 100644 --- a/generic/tkImgPhInstance.c +++ b/generic/tkImgPhInstance.c @@ -631,7 +631,6 @@ TkImgPhotoDisplay( (unsigned int)instancePtr->width, (unsigned int)instancePtr->height, 0, (unsigned int)(4 * instancePtr->width)); - TkPutImage(NULL, 0, display, drawable, instancePtr->gc, photo, imageX, imageY, drawableX, drawableY, (unsigned int) width, (unsigned int) height); diff --git a/macosx/tkMacOSXImage.c b/macosx/tkMacOSXImage.c index 2b747f1..22882d2 100644 --- a/macosx/tkMacOSXImage.c +++ b/macosx/tkMacOSXImage.c @@ -531,6 +531,7 @@ TkPutImage( unsigned int height) /* distination and source. */ { TkMacOSXDrawingContext dc; + MacDrawable *macDraw = (MacDrawable *) drawable; display->request++; if (!TkMacOSXSetupDrawingContext(drawable, gc, 1, &dc)) { @@ -539,7 +540,14 @@ TkPutImage( if (dc.context) { CGRect bounds, srcRect, dstRect; CGImageRef img = TkMacOSXCreateCGImageWithXImage(image); - CGContextSetBlendMode(dc.context, kCGBlendModeSourceAtop); + if (macDraw->flags & TK_IS_PIXMAP) { + /* + * The CGContext for a pixmap is RGB only, with A = 0. + */ + CGContextSetBlendMode(dc.context, kCGImageAlphaNoneSkipLast); + } else { + CGContextSetBlendMode(dc.context, kCGBlendModeSourceAtop); + } if (img) { /* If the XImage has big pixels, the source is rescaled to reflect diff --git a/macosx/tkMacOSXXStubs.c b/macosx/tkMacOSXXStubs.c index ee33537..cc98e84 100644 --- a/macosx/tkMacOSXXStubs.c +++ b/macosx/tkMacOSXXStubs.c @@ -203,7 +203,6 @@ TkpOpenDisplay( screen->root_visual = ckalloc(sizeof(Visual)); screen->root_visual->visualid = 0; screen->root_visual->class = TrueColor; - screen->root_visual->alpha_mask = 0xFF000000; screen->root_visual->red_mask = 0x00FF0000; screen->root_visual->green_mask = 0x0000FF00; screen->root_visual->blue_mask = 0x000000FF; diff --git a/xlib/X11/Xlib.h b/xlib/X11/Xlib.h index b027e28..8d8ec68 100644 --- a/xlib/X11/Xlib.h +++ b/xlib/X11/Xlib.h @@ -203,9 +203,6 @@ typedef struct { int class; /* class of screen (monochrome, etc.) */ #endif unsigned long red_mask, green_mask, blue_mask; /* mask values */ -#if defined(MAC_OSX_TK) - unsigned long alpha_mask; -#endif int bits_per_rgb; /* log base 2 of distinct color values */ int map_entries; /* color map entries */ } Visual; @@ -335,7 +332,6 @@ typedef struct _XImage { XPointer obdata; /* hook for the object routines to hang on */ #if defined(MAC_OSX_TK) int pixelpower; /* n such that pixels are 2^n x 2^n blocks*/ - unsigned long alpha_mask; #endif struct funcs { /* image manipulation routines */ struct _XImage *(*create_image)(); -- cgit v0.12 From 8b8d040cfe3afe4615c0275dec4132c556ec088d Mon Sep 17 00:00:00 2001 From: Kevin Walzer Date: Sat, 10 Nov 2018 14:15:50 +0000 Subject: Remove new Mojave virtual events to register system appearance changes because Tk crashes unpredictably; window decotrations, menus and dialogs change when system appearance changes and virtual events are not required --- macosx/README | 13 +++++++------ macosx/tkMacOSXPrivate.h | 4 +--- macosx/tkMacOSXWindowEvent.c | 46 +------------------------------------------- 3 files changed, 9 insertions(+), 54 deletions(-) diff --git a/macosx/README b/macosx/README index c63b8ae..8b2f52f 100644 --- a/macosx/README +++ b/macosx/README @@ -561,12 +561,13 @@ source and destination rectangles for the scrolling. The embedded windows are redrawn within the DisplayText function by some conditional code which is only used for macOS. -5.0 Virtual events on 10.14 +5.0 Dark Mode on 10.14 ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 10.14 supports system appearance changes, and has added a "Dark Mode" -that casts all window frames and menus as black. Tk 8.6.9 has added two -virtual events, <> and <>, to allow you to update -your Tk app's appearance when the system appearance changes. Just bind -your appearance-updating code to these virtual events and you will see -it triggered when the system appearance toggles between dark and light. +that casts all window frames and menus as black. Tk 8.6.9 supports Dark +Mode by having the window decorations, menus, and dialogs automatically +take on the appropriate appearance when the system appearance is changed. +Because the window content itself is drawn by Tk, it will not change when +the system mode changes. + diff --git a/macosx/tkMacOSXPrivate.h b/macosx/tkMacOSXPrivate.h index cd29791..d804ca0 100644 --- a/macosx/tkMacOSXPrivate.h +++ b/macosx/tkMacOSXPrivate.h @@ -333,9 +333,7 @@ VISIBILITY_HIDDEN @interface TKContentView(TKWindowEvent) - (void) drawRect: (NSRect) rect; -- (void) generateExposeEvents: (HIShapeRef) shape; -- (void) viewDidChangeEffectiveAppearance; -- (void) updateAppearanceEvent; +- (void) generateExposeEvents: (HIShapeRef) shape; - (void) tkToolbarButton: (id) sender; - (BOOL) isOpaque; - (BOOL) wantsDefaultClipping; diff --git a/macosx/tkMacOSXWindowEvent.c b/macosx/tkMacOSXWindowEvent.c index c463875..9ec77cf 100644 --- a/macosx/tkMacOSXWindowEvent.c +++ b/macosx/tkMacOSXWindowEvent.c @@ -991,51 +991,7 @@ ConfigureRestrictProc( */ while (Tcl_DoOneEvent(TCL_IDLE_EVENTS)) {} } -} - - -/* - * These two methods allow Tk to register a virtual event which fires when the - * appearance changes on 10.14. - */ - -- (void) viewDidChangeEffectiveAppearance -{ - [self updateAppearanceEvent]; -} - -- (void) updateAppearanceEvent -{ - NSString *osxMode = [[NSUserDefaults standardUserDefaults] stringForKey:@"AppleInterfaceStyle"]; - NSWindow *w = [self window]; - TkWindow *winPtr = TkMacOSXGetTkWindow(w); - XVirtualEvent event; - int x, y; - Tk_Window tkwin = (Tk_Window) winPtr; - bzero(&event, sizeof(XVirtualEvent)); - event.type = VirtualEvent; - event.serial = LastKnownRequestProcessed(Tk_Display(tkwin)); - event.send_event = false; - event.display = Tk_Display(tkwin); - event.event = Tk_WindowId(tkwin); - event.root = XRootWindow(Tk_Display(tkwin), 0); - event.subwindow = None; - event.time = TkpGetMS(); - XQueryPointer(NULL, winPtr->window, NULL, NULL, - &event.x_root, &event.y_root, &x, &y, &event.state); - Tk_TopCoordsToWindow(tkwin, x, y, &event.x, &event.y); - event.same_screen = true; - if (osxMode == nil) { - event.name = Tk_GetUid("LightAqua"); - Tk_QueueWindowEvent((XEvent *) &event, TCL_QUEUE_TAIL); - return; - } - if ([osxMode isEqual:@"Dark"]) { - event.name = Tk_GetUid("DarkAqua"); - Tk_QueueWindowEvent((XEvent *) &event, TCL_QUEUE_TAIL); - return; - } -} +} /* * This is no-op on 10.7 and up because Apple has removed this widget, -- cgit v0.12 From 70bd22352f1b826b056c033372454ed7295b4630 Mon Sep 17 00:00:00 2001 From: Kevin Walzer Date: Sat, 10 Nov 2018 14:18:50 +0000 Subject: Remove new Mojave virtual events to register system appearance changes because Tk crashes unpredictably; window decotrations, menus and dialogs change when system appearance changes and virtual events are not required --- macosx/README | 13 ++++++------ macosx/tkMacOSXPrivate.h | 4 +--- macosx/tkMacOSXWindowEvent.c | 48 ++------------------------------------------ 3 files changed, 10 insertions(+), 55 deletions(-) diff --git a/macosx/README b/macosx/README index c63b8ae..fe761e3 100644 --- a/macosx/README +++ b/macosx/README @@ -561,12 +561,13 @@ source and destination rectangles for the scrolling. The embedded windows are redrawn within the DisplayText function by some conditional code which is only used for macOS. -5.0 Virtual events on 10.14 +5.0 Dark Mode on 10.14 ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 10.14 supports system appearance changes, and has added a "Dark Mode" -that casts all window frames and menus as black. Tk 8.6.9 has added two -virtual events, <> and <>, to allow you to update -your Tk app's appearance when the system appearance changes. Just bind -your appearance-updating code to these virtual events and you will see -it triggered when the system appearance toggles between dark and light. +that casts all window frames and menus as black. Tk 8.6.9 supports Dark +Mode by having the window decorations, menus, and dialogs automatically +take on the appropriate appearance when the system appearance is changed. +Because the window content itself is drawn by Tk, it will not change when +the system mode changes. + diff --git a/macosx/tkMacOSXPrivate.h b/macosx/tkMacOSXPrivate.h index cd29791..d804ca0 100644 --- a/macosx/tkMacOSXPrivate.h +++ b/macosx/tkMacOSXPrivate.h @@ -333,9 +333,7 @@ VISIBILITY_HIDDEN @interface TKContentView(TKWindowEvent) - (void) drawRect: (NSRect) rect; -- (void) generateExposeEvents: (HIShapeRef) shape; -- (void) viewDidChangeEffectiveAppearance; -- (void) updateAppearanceEvent; +- (void) generateExposeEvents: (HIShapeRef) shape; - (void) tkToolbarButton: (id) sender; - (BOOL) isOpaque; - (BOOL) wantsDefaultClipping; diff --git a/macosx/tkMacOSXWindowEvent.c b/macosx/tkMacOSXWindowEvent.c index b6a3cc7..9ec77cf 100644 --- a/macosx/tkMacOSXWindowEvent.c +++ b/macosx/tkMacOSXWindowEvent.c @@ -358,7 +358,7 @@ GenerateUpdates( } /* - * Compute the bounding box of the area that the damage occurred in. + * Compute the bounding box of the area that the damage occured in. */ boundsRgn = HIShapeCreateWithRect(&bounds); @@ -991,51 +991,7 @@ ConfigureRestrictProc( */ while (Tcl_DoOneEvent(TCL_IDLE_EVENTS)) {} } -} - - -/* - * These two methods allow Tk to register a virtual event which fires when the - * appearance changes on 10.14. - */ - -- (void) viewDidChangeEffectiveAppearance -{ - [self updateAppearanceEvent]; -} - -- (void) updateAppearanceEvent -{ - NSString *osxMode = [[NSUserDefaults standardUserDefaults] stringForKey:@"AppleInterfaceStyle"]; - NSWindow *w = [self window]; - TkWindow *winPtr = TkMacOSXGetTkWindow(w); - XVirtualEvent event; - int x, y; - Tk_Window tkwin = (Tk_Window) winPtr; - bzero(&event, sizeof(XVirtualEvent)); - event.type = VirtualEvent; - event.serial = LastKnownRequestProcessed(Tk_Display(tkwin)); - event.send_event = false; - event.display = Tk_Display(tkwin); - event.event = Tk_WindowId(tkwin); - event.root = XRootWindow(Tk_Display(tkwin), 0); - event.subwindow = None; - event.time = TkpGetMS(); - XQueryPointer(NULL, winPtr->window, NULL, NULL, - &event.x_root, &event.y_root, &x, &y, &event.state); - Tk_TopCoordsToWindow(tkwin, x, y, &event.x, &event.y); - event.same_screen = true; - if (osxMode == nil) { - event.name = Tk_GetUid("LightAqua"); - Tk_QueueWindowEvent((XEvent *) &event, TCL_QUEUE_TAIL); - return; - } - if ([osxMode isEqual:@"Dark"]) { - event.name = Tk_GetUid("DarkAqua"); - Tk_QueueWindowEvent((XEvent *) &event, TCL_QUEUE_TAIL); - return; - } -} +} /* * This is no-op on 10.7 and up because Apple has removed this widget, -- cgit v0.12 From e5fd5e0cbe9f0955956eb1e4c38c6f728461ebbe Mon Sep 17 00:00:00 2001 From: Joe Mistachkin Date: Sat, 10 Nov 2018 19:43:33 +0000 Subject: The 'option readfile' sub-command should maintain existing list structure for values. Fix for [766ef52f31]. Cherrypick of [5550a1383b]. --- generic/tkOption.c | 5 ++++- tests/option.test | 18 +++++++++++++++++- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/generic/tkOption.c b/generic/tkOption.c index cebb86a..5ffb301 100644 --- a/generic/tkOption.c +++ b/generic/tkOption.c @@ -996,6 +996,9 @@ AddFromString( while ((*src == ' ') || (*src == '\t')) { src++; } + if (*src == '\\' && (src[1] == '\t' || src[1] == ' ')) { + src++; + } if (*src == '\0') { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "missing value on line %d", lineNum)); @@ -1025,7 +1028,7 @@ AddFromString( src += 2; *dst++ = '\n'; continue; - } else if (src[1] == '\t' || src[1] == ' ' || src[1] == '\\') { + } else if (src[1] == '\\') { ++src; } else if (src[1] >= '0' && src[1] <= '3' && src[2] >= '0' && src[2] <= '9' && src[3] >= '0' && src[3] <= '9') { diff --git a/tests/option.test b/tests/option.test index 1d6094b..5e1568e 100644 --- a/tests/option.test +++ b/tests/option.test @@ -386,7 +386,7 @@ test option-15.6 {database files} -body { test option-15.7 {database files} -body { option read $option1 option get . x9 color -} -result " \t\\A\n" +} -result " \\\t\\A\n" test option-15.8 {database files} -body { option read $option1 widget foo } -returnCodes error -result {wrong # args: should be "option readfile fileName ?priority?"} @@ -415,6 +415,22 @@ test option-16.1 {ReadOptionFile} -body { removeFile $option4 } -result {true false} +set opt162val {label { + foo bar +} +} +set opt162list [split $opt162val \n] + +test option-16.2 {ticket 766ef52f3} { + set option5 [makeFile {} option.file4] + set file [open $option5 w] + fconfigure $file -translation crlf + puts $file "*notok: $opt162list" + close $file + option read $option5 userDefault + option get . notok notok +} $opt162list + deleteWindows # cleanup -- cgit v0.12 From 050e8dca32283d9b7ec01baa5e56e82a5a5684f7 Mon Sep 17 00:00:00 2001 From: culler Date: Sat, 10 Nov 2018 22:31:04 +0000 Subject: Support for light and dark modes on macOS. --- macosx/tkMacOSXWindowEvent.c | 50 +++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 49 insertions(+), 1 deletion(-) diff --git a/macosx/tkMacOSXWindowEvent.c b/macosx/tkMacOSXWindowEvent.c index 9ec77cf..442029d 100644 --- a/macosx/tkMacOSXWindowEvent.c +++ b/macosx/tkMacOSXWindowEvent.c @@ -991,7 +991,55 @@ ConfigureRestrictProc( */ while (Tcl_DoOneEvent(TCL_IDLE_EVENTS)) {} } -} +} + +/* + * This method is called when a user changes between light and dark mode. + * The implementation here generates a Tk virtual event which can be bound + * to a function that redraws the window in an appropriate style. + */ + +- (void) viewDidChangeEffectiveAppearance +{ + XVirtualEvent event; + int x, y; + NSString *osxMode = [[NSUserDefaults standardUserDefaults] stringForKey:@"AppleInterfaceStyle"]; + NSWindow *w = [self window]; + TkWindow *winPtr = TkMacOSXGetTkWindow(w); + Tk_Window tkwin = (Tk_Window) winPtr; + + /* + * If there is no Tk window associated to this NSWindow, just return. + */ + + if (!winPtr) { + return; + } + + bzero(&event, sizeof(XVirtualEvent)); + event.type = VirtualEvent; + event.serial = LastKnownRequestProcessed(Tk_Display(tkwin)); + event.send_event = false; + event.display = Tk_Display(tkwin); + event.event = Tk_WindowId(tkwin); + event.root = XRootWindow(Tk_Display(tkwin), 0); + event.subwindow = None; + event.time = TkpGetMS(); + XQueryPointer(NULL, winPtr->window, NULL, NULL, + &event.x_root, &event.y_root, &x, &y, &event.state); + Tk_TopCoordsToWindow(tkwin, x, y, &event.x, &event.y); + event.same_screen = true; + if (osxMode == nil) { + event.name = Tk_GetUid("LightAqua"); + Tk_QueueWindowEvent((XEvent *) &event, TCL_QUEUE_TAIL); + return; + } + if ([osxMode isEqual:@"Dark"]) { + event.name = Tk_GetUid("DarkAqua"); + Tk_QueueWindowEvent((XEvent *) &event, TCL_QUEUE_TAIL); + return; + } +} /* * This is no-op on 10.7 and up because Apple has removed this widget, -- cgit v0.12 From a9b367c36191b1de125ece91b539a0160b5cc93f Mon Sep 17 00:00:00 2001 From: culler Date: Sun, 11 Nov 2018 05:33:20 +0000 Subject: Restore the README description of virtual events for appearance changes. --- macosx/README | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/macosx/README b/macosx/README index 8b2f52f..c63b8ae 100644 --- a/macosx/README +++ b/macosx/README @@ -561,13 +561,12 @@ source and destination rectangles for the scrolling. The embedded windows are redrawn within the DisplayText function by some conditional code which is only used for macOS. -5.0 Dark Mode on 10.14 +5.0 Virtual events on 10.14 ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 10.14 supports system appearance changes, and has added a "Dark Mode" -that casts all window frames and menus as black. Tk 8.6.9 supports Dark -Mode by having the window decorations, menus, and dialogs automatically -take on the appropriate appearance when the system appearance is changed. -Because the window content itself is drawn by Tk, it will not change when -the system mode changes. - +that casts all window frames and menus as black. Tk 8.6.9 has added two +virtual events, <> and <>, to allow you to update +your Tk app's appearance when the system appearance changes. Just bind +your appearance-updating code to these virtual events and you will see +it triggered when the system appearance toggles between dark and light. -- cgit v0.12 From d1d67157b8f5db89f44ecb28e4a06cb6380ae530 Mon Sep 17 00:00:00 2001 From: culler Date: Sun, 11 Nov 2018 06:48:07 +0000 Subject: Always check whether the return value of TkMacOSXGetTkWindow is NULL. --- macosx/tkMacOSXImage.c | 12 ++++++------ macosx/tkMacOSXKeyEvent.c | 3 +++ macosx/tkMacOSXMenus.c | 6 +++--- macosx/tkMacOSXWindowEvent.c | 8 +++----- macosx/tkMacOSXWm.c | 12 ++++++++++-- 5 files changed, 25 insertions(+), 16 deletions(-) diff --git a/macosx/tkMacOSXImage.c b/macosx/tkMacOSXImage.c index 22882d2..a5c870a 100644 --- a/macosx/tkMacOSXImage.c +++ b/macosx/tkMacOSXImage.c @@ -540,12 +540,12 @@ TkPutImage( if (dc.context) { CGRect bounds, srcRect, dstRect; CGImageRef img = TkMacOSXCreateCGImageWithXImage(image); - if (macDraw->flags & TK_IS_PIXMAP) { - /* - * The CGContext for a pixmap is RGB only, with A = 0. - */ - CGContextSetBlendMode(dc.context, kCGImageAlphaNoneSkipLast); - } else { + + /* + * The CGContext for a pixmap is RGB only, with A = 0. + */ + + if (!(macDraw->flags & TK_IS_PIXMAP)) { CGContextSetBlendMode(dc.context, kCGBlendModeSourceAtop); } if (img) { diff --git a/macosx/tkMacOSXKeyEvent.c b/macosx/tkMacOSXKeyEvent.c index 46662e5..31fffa1 100644 --- a/macosx/tkMacOSXKeyEvent.c +++ b/macosx/tkMacOSXKeyEvent.c @@ -434,6 +434,9 @@ setupXEvent(XEvent *xEvent, NSWindow *w, unsigned int state) { TkWindow *winPtr = TkMacOSXGetTkWindow(w); Tk_Window tkwin = (Tk_Window) winPtr; + if (!winPtr) { + return; + } memset(xEvent, 0, sizeof(XEvent)); xEvent->xany.serial = LastKnownRequestProcessed(Tk_Display(tkwin)); diff --git a/macosx/tkMacOSXMenus.c b/macosx/tkMacOSXMenus.c index f8f00a6..15dbad4 100644 --- a/macosx/tkMacOSXMenus.c +++ b/macosx/tkMacOSXMenus.c @@ -379,13 +379,13 @@ GenerateEditEvent( XVirtualEvent event; int x, y; TkWindow *winPtr = TkMacOSXGetTkWindow([NSApp keyWindow]); - Tk_Window tkwin = (Tk_Window) winPtr; + Tk_Window tkwin; - if (tkwin == NULL) { + if (!winPtr) { return; } tkwin = (Tk_Window) winPtr->dispPtr->focusPtr; - if (tkwin == NULL) { + if (!tkwin) { return; } bzero(&event, sizeof(XVirtualEvent)); diff --git a/macosx/tkMacOSXWindowEvent.c b/macosx/tkMacOSXWindowEvent.c index 442029d..a1a3d1a 100644 --- a/macosx/tkMacOSXWindowEvent.c +++ b/macosx/tkMacOSXWindowEvent.c @@ -1008,14 +1008,9 @@ ConfigureRestrictProc( TkWindow *winPtr = TkMacOSXGetTkWindow(w); Tk_Window tkwin = (Tk_Window) winPtr; - /* - * If there is no Tk window associated to this NSWindow, just return. - */ - if (!winPtr) { return; } - bzero(&event, sizeof(XVirtualEvent)); event.type = VirtualEvent; event.serial = LastKnownRequestProcessed(Tk_Display(tkwin)); @@ -1055,6 +1050,9 @@ ConfigureRestrictProc( int x, y; TkWindow *winPtr = TkMacOSXGetTkWindow([self window]); Tk_Window tkwin = (Tk_Window) winPtr; + if (!winPtr){ + return; + } bzero(&event, sizeof(XVirtualEvent)); event.type = VirtualEvent; event.serial = LastKnownRequestProcessed(Tk_Display(tkwin)); diff --git a/macosx/tkMacOSXWm.c b/macosx/tkMacOSXWm.c index ed930fe..33a88d8 100644 --- a/macosx/tkMacOSXWm.c +++ b/macosx/tkMacOSXWm.c @@ -403,6 +403,9 @@ NSStatusItem *exitFullScreen; - (void)toggleFullScreen:(id)sender { TkWindow *winPtr = TkMacOSXGetTkWindow(self); + if (!winPtr) { + return; + } Tcl_Interp *interp = Tk_Interp((Tk_Window)winPtr); if ([NSApp macMinorVersion] > 12) { if (([self styleMask] & NSFullScreenWindowMask) == NSFullScreenWindowMask) { @@ -418,6 +421,9 @@ NSStatusItem *exitFullScreen; -(void)restoreOldScreen:(id)sender { TkWindow *winPtr = TkMacOSXGetTkWindow(self); + if (!winPtr) { + return; + } Tcl_Interp *interp = Tk_Interp((Tk_Window)winPtr); TkMacOSXMakeFullscreen(winPtr, self, 0, interp); @@ -431,8 +437,10 @@ NSStatusItem *exitFullScreen; - (BOOL) canBecomeKeyWindow { TkWindow *winPtr = TkMacOSXGetTkWindow(self); - - return (winPtr && winPtr->wmInfoPtr && (winPtr->wmInfoPtr->macClass == + if (!winPtr) { + return NO; + } + return (winPtr->wmInfoPtr && (winPtr->wmInfoPtr->macClass == kHelpWindowClass || winPtr->wmInfoPtr->attributes & kWindowNoActivatesAttribute)) ? NO : YES; } -- cgit v0.12 From 17bdedc1bd72f47554923320fa54e2c5ab938458 Mon Sep 17 00:00:00 2001 From: culler Date: Sun, 11 Nov 2018 16:00:57 +0000 Subject: Fix some inconsistent indentation; add missing emacs local variables. --- macosx/tkMacOSXButton.c | 8 ++++++++ macosx/tkMacOSXConfig.c | 9 +++++++++ macosx/tkMacOSXMenubutton.c | 8 ++++++++ macosx/tkMacOSXWm.c | 34 ++++++++++++++++------------------ 4 files changed, 41 insertions(+), 18 deletions(-) diff --git a/macosx/tkMacOSXButton.c b/macosx/tkMacOSXButton.c index 14b8872..ea78d43 100644 --- a/macosx/tkMacOSXButton.c +++ b/macosx/tkMacOSXButton.c @@ -1201,3 +1201,11 @@ PulseDefaultButtonProc(ClientData clientData) PULSE_TIMER_MSECS, PulseDefaultButtonProc, clientData); } +/* + * Local Variables: + * mode: objc + * c-basic-offset: 4 + * fill-column: 79 + * coding: utf-8 + * End: + */ diff --git a/macosx/tkMacOSXConfig.c b/macosx/tkMacOSXConfig.c index bdfcb6e..841fc54 100644 --- a/macosx/tkMacOSXConfig.c +++ b/macosx/tkMacOSXConfig.c @@ -41,3 +41,12 @@ TkpGetSystemDefault( { return NULL; } + +/* + * Local Variables: + * mode: objc + * c-basic-offset: 4 + * fill-column: 79 + * coding: utf-8 + * End: + */ diff --git a/macosx/tkMacOSXMenubutton.c b/macosx/tkMacOSXMenubutton.c index a85e572..1acefe5 100644 --- a/macosx/tkMacOSXMenubutton.c +++ b/macosx/tkMacOSXMenubutton.c @@ -843,3 +843,11 @@ TkMacOSXComputeMenuButtonDrawParams(TkMenuButton * butPtr, DrawParams * dpPtr) return 1; } +/* + * Local Variables: + * mode: objc + * c-basic-offset: 4 + * fill-column: 79 + * coding: utf-8 + * End: + */ diff --git a/macosx/tkMacOSXWm.c b/macosx/tkMacOSXWm.c index 33a88d8..a56444d 100644 --- a/macosx/tkMacOSXWm.c +++ b/macosx/tkMacOSXWm.c @@ -418,16 +418,15 @@ NSStatusItem *exitFullScreen; } } --(void)restoreOldScreen:(id)sender { - - TkWindow *winPtr = TkMacOSXGetTkWindow(self); - if (!winPtr) { - return; - } - Tcl_Interp *interp = Tk_Interp((Tk_Window)winPtr); - - TkMacOSXMakeFullscreen(winPtr, self, 0, interp); - [[NSStatusBar systemStatusBar] removeStatusItem: exitFullScreen]; +-(void)restoreOldScreen:(id)sender +{ + TkWindow *winPtr = TkMacOSXGetTkWindow(self); + if (!winPtr) { + return; + } + Tcl_Interp *interp = Tk_Interp((Tk_Window)winPtr); + TkMacOSXMakeFullscreen(winPtr, self, 0, interp); + [[NSStatusBar systemStatusBar] removeStatusItem: exitFullScreen]; } @end @@ -437,16 +436,15 @@ NSStatusItem *exitFullScreen; - (BOOL) canBecomeKeyWindow { TkWindow *winPtr = TkMacOSXGetTkWindow(self); - if (!winPtr) { - return NO; - } - return (winPtr->wmInfoPtr && (winPtr->wmInfoPtr->macClass == - kHelpWindowClass || winPtr->wmInfoPtr->attributes & - kWindowNoActivatesAttribute)) ? NO : YES; + if (!winPtr) { + return NO; + } + return (winPtr->wmInfoPtr && + (winPtr->wmInfoPtr->macClass == kHelpWindowClass || + winPtr->wmInfoPtr->attributes & kWindowNoActivatesAttribute) + ) ? NO : YES; } - - #if DEBUG_ZOMBIES - (id) retain { -- cgit v0.12 From 29acee22500b4d937e6f46118f36635cdecd8f5e Mon Sep 17 00:00:00 2001 From: fvogel Date: Sun, 11 Nov 2018 21:05:38 +0000 Subject: Restore the build for Windows (got broken by [4a251d07db]). --- generic/tkImgPhInstance.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/generic/tkImgPhInstance.c b/generic/tkImgPhInstance.c index 76c4a8a..fb106b1 100644 --- a/generic/tkImgPhInstance.c +++ b/generic/tkImgPhInstance.c @@ -609,6 +609,7 @@ TkImgPhotoDisplay( * to imageX and imageY. */ { PhotoInstance *instancePtr = clientData; + XVisualInfo visInfo = instancePtr->visualInfo; /* * If there's no pixmap, it means that an error occurred while creating @@ -637,8 +638,6 @@ TkImgPhotoDisplay( photo->data = NULL; XDestroyImage(photo); #else - XVisualInfo visInfo = instancePtr->visualInfo; - if ((instancePtr->masterPtr->flags & COMPLEX_ALPHA) && visInfo.depth >= 15 && (visInfo.class == DirectColor || visInfo.class == TrueColor)) { -- cgit v0.12 From 3ea35977ea5872517ce243b49bd5a768b0aa1352 Mon Sep 17 00:00:00 2001 From: culler Date: Tue, 13 Nov 2018 05:40:51 +0000 Subject: fix hangs in text.test caused by calling pendingsync before the text widget was mapped. --- tests/text.test | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/text.test b/tests/text.test index 5eadeac..600ce2b 100644 --- a/tests/text.test +++ b/tests/text.test @@ -3021,6 +3021,7 @@ test text-11a.22 {TextWidgetCmd procedure, "sync" option with -command} -setup { set ::x 0 toplevel .top pack [text .top.yt] + update set content {} for {set i 1} {$i < 30} {incr i} { append content [string repeat "$i " 15] \n @@ -3047,6 +3048,7 @@ test text-11a.31 {"<>" event} -setup { } -body { toplevel .top pack [text .top.yt] + update set content {} for {set i 1} {$i < 300} {incr i} { append content [string repeat "$i " 15] \n @@ -3080,6 +3082,7 @@ test text-11a.41 {"sync" "pendingsync" and <>} -setup { set res {} toplevel .top pack [text .top.yt] + update set content {} for {set i 1} {$i < 300} {incr i} { append content [string repeat "$i " 50] \n -- cgit v0.12 From bd826e322a1ee9392d130a50a2c39b1e3d423580 Mon Sep 17 00:00:00 2001 From: culler Date: Tue, 13 Nov 2018 13:40:49 +0000 Subject: Instead of calling update in the tests, fix the handling of unmapped Text widgets by AsyncUpdateLineMetrics. --- generic/tkTextDisp.c | 7 ++----- tests/text.test | 3 --- 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/generic/tkTextDisp.c b/generic/tkTextDisp.c index 84be232..3d29547 100644 --- a/generic/tkTextDisp.c +++ b/generic/tkTextDisp.c @@ -3013,15 +3013,12 @@ AsyncUpdateLineMetrics( dInfoPtr->lineUpdateTimer = NULL; - if ((textPtr->tkwin == NULL) || (textPtr->flags & DESTROYED) - || !Tk_IsMapped(textPtr->tkwin)) { + if ((textPtr->tkwin == NULL) || (textPtr->flags & DESTROYED)) { + /* * The widget has been deleted, or is not mapped. Don't do anything. */ - if (textPtr->refCount-- <= 1) { - ckfree(textPtr); - } return; } diff --git a/tests/text.test b/tests/text.test index 600ce2b..5eadeac 100644 --- a/tests/text.test +++ b/tests/text.test @@ -3021,7 +3021,6 @@ test text-11a.22 {TextWidgetCmd procedure, "sync" option with -command} -setup { set ::x 0 toplevel .top pack [text .top.yt] - update set content {} for {set i 1} {$i < 30} {incr i} { append content [string repeat "$i " 15] \n @@ -3048,7 +3047,6 @@ test text-11a.31 {"<>" event} -setup { } -body { toplevel .top pack [text .top.yt] - update set content {} for {set i 1} {$i < 300} {incr i} { append content [string repeat "$i " 15] \n @@ -3082,7 +3080,6 @@ test text-11a.41 {"sync" "pendingsync" and <>} -setup { set res {} toplevel .top pack [text .top.yt] - update set content {} for {set i 1} {$i < 300} {incr i} { append content [string repeat "$i " 50] \n -- cgit v0.12 From 8a94cc52e38bf2084dbe682bf98c9b2884736d94 Mon Sep 17 00:00:00 2001 From: culler Date: Tue, 13 Nov 2018 17:07:51 +0000 Subject: Calling update after pack .t to make sure the Text is mapped fixes the sporadic failures in text-27.11, textWind-11.1 - textWind-11.3. --- tests/text.test | 2 ++ tests/textWind.test | 6 ++++++ 2 files changed, 8 insertions(+) diff --git a/tests/text.test b/tests/text.test index 5eadeac..11dd41c 100644 --- a/tests/text.test +++ b/tests/text.test @@ -6542,6 +6542,8 @@ test text-27.10 {TextEditCmd procedure, set modified flag} -body { test text-27.11 {TextEditCmd procedure, set modified flag repeat} -setup { text .t pack .t +# Make sure the Text is mapped before we start + update set ::retval {} } -body { bind .t <> "lappend ::retval modified" diff --git a/tests/textWind.test b/tests/textWind.test index 5f0c9b0..e189663 100644 --- a/tests/textWind.test +++ b/tests/textWind.test @@ -947,6 +947,8 @@ test textWind-11.1 {EmbWinDisplayProc procedure, geometry transforms} -setup { destroy .f place forget .t pack .t +# Make sure the Text is mapped before we start + update } -body { .t insert 1.0 "Some sample text" pack forget .t @@ -965,6 +967,8 @@ test textWind-11.2 {EmbWinDisplayProc procedure, geometry transforms} -setup { destroy .t.f place forget .t pack .t +# Make sure the Text is mapped before we start + update } -body { .t insert 1.0 "Some sample text" pack forget .t @@ -984,6 +988,8 @@ test textWind-11.3 {EmbWinDisplayProc procedure, configuration optimization} -se destroy .f place forget .t pack .t +# Make sure the Text is mapped before we start + update } -body { .t insert 1.0 "Some sample text" frame .f -width 30 -height 20 -bg $color -- cgit v0.12 From 812accf5f262bf522196e67e9b1ae823d1626bd2 Mon Sep 17 00:00:00 2001 From: culler Date: Tue, 13 Nov 2018 21:47:44 +0000 Subject: Revert the change in tkTextDisp.c since it recreates the issue resolved in ticket [ff8a1e55a2]. --- generic/tkTextDisp.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/generic/tkTextDisp.c b/generic/tkTextDisp.c index 3d29547..84be232 100644 --- a/generic/tkTextDisp.c +++ b/generic/tkTextDisp.c @@ -3013,12 +3013,15 @@ AsyncUpdateLineMetrics( dInfoPtr->lineUpdateTimer = NULL; - if ((textPtr->tkwin == NULL) || (textPtr->flags & DESTROYED)) { - + if ((textPtr->tkwin == NULL) || (textPtr->flags & DESTROYED) + || !Tk_IsMapped(textPtr->tkwin)) { /* * The widget has been deleted, or is not mapped. Don't do anything. */ + if (textPtr->refCount-- <= 1) { + ckfree(textPtr); + } return; } -- cgit v0.12 From f84c9c8b0bf0acfdb54373ce1cf565c9d83210cc Mon Sep 17 00:00:00 2001 From: culler Date: Tue, 13 Nov 2018 23:35:05 +0000 Subject: Adding update commands in the setup section fixes sporadic test failures in image.test and canvImg.test. --- tests/canvImg.test | 3 +++ tests/image.test | 2 ++ 2 files changed, 5 insertions(+) diff --git a/tests/canvImg.test b/tests/canvImg.test index a609337..ea413bb 100644 --- a/tests/canvImg.test +++ b/tests/canvImg.test @@ -722,6 +722,7 @@ test canvImg-9.1 {DisplayImage procedure} -constraints testImageType -setup { test canvImg-10.1 {TranslateImage procedure} -constraints testImageType -setup { .c delete all + update } -body { image create test foo -variable x .c create image 50 100 -image foo -tags image -anchor nw @@ -737,6 +738,7 @@ test canvImg-10.1 {TranslateImage procedure} -constraints testImageType -setup { test canvImg-11.1 {TranslateImage procedure} -constraints testImageType -setup { .c delete all + update } -body { image create test foo -variable x .c create image 50 100 -image foo -tags image -anchor nw @@ -768,6 +770,7 @@ test canvImg-11.3 {ImageChangedProc procedure} -constraints { testImageType } -setup { .c delete all + update } -body { image create test foo -variable x image create test foo2 -variable y diff --git a/tests/image.test b/tests/image.test index e2e602e..d4ea745 100644 --- a/tests/image.test +++ b/tests/image.test @@ -349,6 +349,7 @@ test image-8.1 {Tk_ImageCmd procedure, "inuse" option} -constraints { test image-9.1 {Tk_ImageChanged procedure} -constraints testImageType -setup { .c delete all imageCleanup + update } -body { image create test foo -variable x .c create image 50 50 -image foo @@ -364,6 +365,7 @@ test image-9.1 {Tk_ImageChanged procedure} -constraints testImageType -setup { test image-9.2 {Tk_ImageChanged procedure} -constraints testImageType -setup { .c delete all imageCleanup + update } -body { image create test foo -variable x .c create image 50 50 -image foo -- cgit v0.12 From 550ea59f62f06ce9bc1171fcf296755dd99168ee Mon Sep 17 00:00:00 2001 From: culler Date: Tue, 13 Nov 2018 23:54:04 +0000 Subject: Calling update after pack in text.test fixes hangs on OSX 10.9. --- tests/text.test | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/text.test b/tests/text.test index 11dd41c..95e666a 100644 --- a/tests/text.test +++ b/tests/text.test @@ -3021,6 +3021,7 @@ test text-11a.22 {TextWidgetCmd procedure, "sync" option with -command} -setup { set ::x 0 toplevel .top pack [text .top.yt] + update set content {} for {set i 1} {$i < 30} {incr i} { append content [string repeat "$i " 15] \n @@ -3047,6 +3048,7 @@ test text-11a.31 {"<>" event} -setup { } -body { toplevel .top pack [text .top.yt] + update set content {} for {set i 1} {$i < 300} {incr i} { append content [string repeat "$i " 15] \n @@ -3080,6 +3082,7 @@ test text-11a.41 {"sync" "pendingsync" and <>} -setup { set res {} toplevel .top pack [text .top.yt] + update set content {} for {set i 1} {$i < 300} {incr i} { append content [string repeat "$i " 50] \n -- cgit v0.12 From 00f20fd81a83e661ed54055ab50cbfbf2ab10fd3 Mon Sep 17 00:00:00 2001 From: culler Date: Wed, 14 Nov 2018 02:29:26 +0000 Subject: Fix an unused variable warning and rename a #define constant more rationally. --- generic/tkImgPhInstance.c | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/generic/tkImgPhInstance.c b/generic/tkImgPhInstance.c index fb106b1..0daca2f 100644 --- a/generic/tkImgPhInstance.c +++ b/generic/tkImgPhInstance.c @@ -19,6 +19,9 @@ */ #include "tkImgPhoto.h" +#ifdef MAC_OSX_TK +#define TKPUTIMAGE_CAN_BLEND +#endif /* * Declaration for internal Xlib function used here: @@ -30,7 +33,7 @@ extern int _XInitImageFuncPtrs(XImage *image); * Forward declarations */ -#ifndef MAC_OSX_TK +#ifndef TKPUTIMAGE_CAN_BLEND static void BlendComplexAlpha(XImage *bgImg, PhotoInstance *iPtr, int xOffset, int yOffset, int width, int height); #endif @@ -411,7 +414,7 @@ TkImgPhotoGet( * *---------------------------------------------------------------------- */ -#ifndef MAC_OSX_TK +#ifndef TKPUTIMAGE_CAN_BLEND #ifndef _WIN32 #define GetRValue(rgb) (UCHAR(((rgb) & red_mask) >> red_shift)) #define GetGValue(rgb) (UCHAR(((rgb) & green_mask) >> green_shift)) @@ -486,7 +489,7 @@ BlendComplexAlpha( * optimized. */ -#if !(defined(_WIN32) || defined(MAC_OSX_TK)) +#if !defined(_WIN32) if (bgImg->depth < 24) { unsigned char red_mlen, green_mlen, blue_mlen; @@ -534,7 +537,7 @@ BlendComplexAlpha( } return; } -#endif /* !_WIN32 && !MAC_OSX_TK */ +#endif /* !_WIN32 */ for (y = 0; y < height; y++) { line = (y + yOffset) * iPtr->masterPtr->width; @@ -577,7 +580,7 @@ BlendComplexAlpha( } #undef ALPHA_BLEND } -#endif /* MAC_OSX_TK */ +#endif /* TKPUTIMAGE_CAN_BLEND */ /* *---------------------------------------------------------------------- @@ -609,8 +612,10 @@ TkImgPhotoDisplay( * to imageX and imageY. */ { PhotoInstance *instancePtr = clientData; +#ifndef TKPUTIMAGE_CAN_BLEND XVisualInfo visInfo = instancePtr->visualInfo; - +#endif + /* * If there's no pixmap, it means that an error occurred while creating * the image instance so it can't be displayed. @@ -620,14 +625,13 @@ TkImgPhotoDisplay( return; } -#ifdef MAC_OSX_TK +#ifdef TKPUTIMAGE_CAN_BLEND /* - * The Mac version of TkPutImage handles RGBA images directly. There is + * If TkPutImage can handle RGBA Ximages directly there is * no need to call XGetImage or to do the Porter-Duff compositing by hand. - * We just let the CG graphics library do it, using the graphics hardware. */ - unsigned char *rgbaPixels = instancePtr->masterPtr->pix32; + unsigned char *rgbaPixels = instancePtr->masterPtr->pix32; XImage *photo = XCreateImage(display, NULL, 32, ZPixmap, 0, (char*)rgbaPixels, (unsigned int)instancePtr->width, (unsigned int)instancePtr->height, @@ -638,6 +642,7 @@ TkImgPhotoDisplay( photo->data = NULL; XDestroyImage(photo); #else + if ((instancePtr->masterPtr->flags & COMPLEX_ALPHA) && visInfo.depth >= 15 && (visInfo.class == DirectColor || visInfo.class == TrueColor)) { -- cgit v0.12 -- cgit v0.12 From f4401d81a1c20c31ebbedd5b098f290ba62d187b Mon Sep 17 00:00:00 2001 From: culler Date: Thu, 15 Nov 2018 20:07:46 +0000 Subject: Setting [NSapp isDrawing] inside setFrame on Mojave can break live resize in some situations. Stop doing that. --- macosx/tkMacOSXWindowEvent.c | 9 --------- 1 file changed, 9 deletions(-) diff --git a/macosx/tkMacOSXWindowEvent.c b/macosx/tkMacOSXWindowEvent.c index a1a3d1a..4558214 100644 --- a/macosx/tkMacOSXWindowEvent.c +++ b/macosx/tkMacOSXWindowEvent.c @@ -879,12 +879,6 @@ ConfigureRestrictProc( TkWindow *winPtr = TkMacOSXGetTkWindow(w); Tk_Window tkwin = (Tk_Window) winPtr; if (winPtr) { - /* On OSX versions below 10.14 setFrame calls drawRect. - * On 10.14 it does its own drawing. - */ - if ([NSApp macMinorVersion] > 13) { - [NSApp setIsDrawing:YES]; - } unsigned int width = (unsigned int)newsize.width; unsigned int height=(unsigned int)newsize.height; ClientData oldArg; @@ -929,9 +923,6 @@ ConfigureRestrictProc( HIShapeRef shape = HIShapeCreateWithRect(&bounds); [self generateExposeEvents: shape]; [w displayIfNeeded]; - if ([NSApp macMinorVersion] > 13) { - [NSApp setIsDrawing:NO]; - } } } -- cgit v0.12 From 63f8e775d4268f87849cba0bc32e64126a486363 Mon Sep 17 00:00:00 2001 From: fvogel Date: Thu, 15 Nov 2018 21:27:19 +0000 Subject: Remove duplicate documentation of -text in ttk::label. This option is already described as a standard option in ttk::widget, to which ttk::label is linking --- doc/ttk_label.n | 3 --- 1 file changed, 3 deletions(-) diff --git a/doc/ttk_label.n b/doc/ttk_label.n index aae95e6..1e30592 100644 --- a/doc/ttk_label.n +++ b/doc/ttk_label.n @@ -49,9 +49,6 @@ Specifies the 3-D effect desired for the widget border. Valid values are \fBflat\fR, \fBgroove\fR, \fBraised\fR, \fBridge\fR, \fBsolid\fR, and \fBsunken\fR. -.OP \-text text Text -Specifies a text string to be displayed inside the widget -(unless overridden by \fB\-textvariable\fR). .OP \-wraplength wrapLength WrapLength Specifies the maximum line length (in pixels). If this option is less than or equal to zero, -- cgit v0.12 From db0ba45ceb0687513359268f6e48d97bd045ad61 Mon Sep 17 00:00:00 2001 From: culler Date: Thu, 15 Nov 2018 21:37:32 +0000 Subject: In TkMacOSXFlushWindows don't process idle tasks if there are no windows left. --- macosx/tkMacOSXEvent.c | 4 +++- macosx/tkMacOSXWindowEvent.c | 9 --------- 2 files changed, 3 insertions(+), 10 deletions(-) diff --git a/macosx/tkMacOSXEvent.c b/macosx/tkMacOSXEvent.c index c03a6fb..843ef8c 100644 --- a/macosx/tkMacOSXEvent.c +++ b/macosx/tkMacOSXEvent.c @@ -137,7 +137,9 @@ MODULE_SCOPE void TkMacOSXFlushWindows(void) { NSArray *macWindows = [NSApp orderedWindows]; - while (Tcl_DoOneEvent(TCL_IDLE_EVENTS)){} + if ([macWindows count] > 0) { + while (Tcl_DoOneEvent(TCL_IDLE_EVENTS)){} + } for (NSWindow *w in macWindows) { if (TkMacOSXGetXWindow(w)) { [w displayIfNeeded]; diff --git a/macosx/tkMacOSXWindowEvent.c b/macosx/tkMacOSXWindowEvent.c index 4532b0c..dd916d1 100644 --- a/macosx/tkMacOSXWindowEvent.c +++ b/macosx/tkMacOSXWindowEvent.c @@ -875,12 +875,6 @@ ConfigureRestrictProc( TkWindow *winPtr = TkMacOSXGetTkWindow(w); Tk_Window tkwin = (Tk_Window) winPtr; if (winPtr) { - /* On OSX versions below 10.14 setFrame calls drawRect. - * On 10.14 it does its own drawing. - */ - if ([NSApp macMinorVersion] > 13) { - [NSApp setIsDrawing:YES]; - } unsigned int width = (unsigned int)newsize.width; unsigned int height=(unsigned int)newsize.height; ClientData oldArg; @@ -925,9 +919,6 @@ ConfigureRestrictProc( HIShapeRef shape = HIShapeCreateWithRect(&bounds); [self generateExposeEvents: shape]; [w displayIfNeeded]; - if ([NSApp macMinorVersion] > 13) { - [NSApp setIsDrawing:NO]; - } } } -- cgit v0.12 From b56d2fd8f987501adc22f6a29bd0c5aef64ff477 Mon Sep 17 00:00:00 2001 From: fvogel Date: Thu, 15 Nov 2018 21:49:34 +0000 Subject: Fix [9b0f3ee54e]: Better highlight that winClipboard tests may fail if a VNC viewer is open while these tests are running --- tests/winClipboard.test | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tests/winClipboard.test b/tests/winClipboard.test index 2a7ad73..1d17b14 100644 --- a/tests/winClipboard.test +++ b/tests/winClipboard.test @@ -15,8 +15,10 @@ eval tcltest::configure $argv tcltest::loadTestedCommands namespace import -force tcltest::test -# Note that these tests may fail if another application is grabbing the -# clipboard (e.g. an X server) +########################################################################### +# Note that these tests may fail if another application is grabbing the # +# clipboard (e.g. an X server, or a VNC viewer - See ticket [9b0f3ee54e]) # +########################################################################### test winClipboard-1.1 {TkSelGetSelection} -constraints win -setup { clipboard clear -- cgit v0.12 From c37774eec0a06f4966f97ae6605ee85ff7bb635d Mon Sep 17 00:00:00 2001 From: culler Date: Fri, 16 Nov 2018 14:40:51 +0000 Subject: Fix a humongous memory leak on macOS, caused by accidentally deleting a call to [NSApp _unlockAutoreleasePool]. --- macosx/tkMacOSXWindowEvent.c | 8 +++++++- macosx/tkMacOSXWm.c | 9 ++++++--- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/macosx/tkMacOSXWindowEvent.c b/macosx/tkMacOSXWindowEvent.c index dd916d1..7136568 100644 --- a/macosx/tkMacOSXWindowEvent.c +++ b/macosx/tkMacOSXWindowEvent.c @@ -912,13 +912,19 @@ ConfigureRestrictProc( TkMacOSXUpdateClipRgn(winPtr); /* - * Finally, generate and process expose events to redraw the window. + * Generate and process expose events to redraw the window. */ HIRect bounds = NSRectToCGRect([self bounds]); HIShapeRef shape = HIShapeCreateWithRect(&bounds); [self generateExposeEvents: shape]; [w displayIfNeeded]; + + /* + * Finally, unlock the main autoreleasePool. + */ + + [NSApp _unlockAutoreleasePool]; } } diff --git a/macosx/tkMacOSXWm.c b/macosx/tkMacOSXWm.c index a56444d..9e45996 100644 --- a/macosx/tkMacOSXWm.c +++ b/macosx/tkMacOSXWm.c @@ -468,7 +468,8 @@ NSStatusItem *exitFullScreen; title = "unnamed window"; } if (DEBUG_ZOMBIES > 1){ - printf("Autoreleased <%s>. Count is %lu\n", title, [self retainCount]); + fprintf(stderr, "Autoreleased <%s>. Count is %lu\n", + title, [self retainCount]); } return result; } @@ -479,7 +480,8 @@ NSStatusItem *exitFullScreen; title = "unnamed window"; } if (DEBUG_ZOMBIES > 1){ - printf("Releasing <%s>. Count is %lu\n", title, [self retainCount]); + fprintf(stderr, "Releasing <%s>. Count is %lu\n", + title, [self retainCount]); } [super release]; } @@ -490,7 +492,8 @@ NSStatusItem *exitFullScreen; title = "unnamed window"; } if (DEBUG_ZOMBIES > 0){ - printf(">>>> Freeing <%s>. Count is %lu\n", title, [self retainCount]); + fprintf(stderr, ">>>> Freeing <%s>. Count is %lu\n", + title, [self retainCount]); } [super dealloc]; } -- cgit v0.12 From 7cbc10dfbeb569d6f01c2c49a3d14697ba26c03a Mon Sep 17 00:00:00 2001 From: dgp Date: Fri, 16 Nov 2018 17:44:47 +0000 Subject: Crash prevention. Still buggy, now test text-11a.22 fails instead of crashing. --- generic/tkText.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/generic/tkText.c b/generic/tkText.c index 4c536a2..a0de1d5 100644 --- a/generic/tkText.c +++ b/generic/tkText.c @@ -5538,6 +5538,15 @@ RunAfterSyncCmd( return; } + if (textPtr->afterSyncCmd == NULL) { + /* + * [Bug 0a9c9151b5] Probably should have idle handlers coded so that + * this cannot happen, but a safety check here at least prevents a + * crash. + */ + return; + } + Tcl_Preserve((ClientData) textPtr->interp); code = Tcl_EvalObjEx(textPtr->interp, textPtr->afterSyncCmd, TCL_EVAL_GLOBAL); if (code == TCL_ERROR) { -- cgit v0.12 From 8eb6ab3daef402bd034846ea7247eb8762a71359 Mon Sep 17 00:00:00 2001 From: dgp Date: Fri, 16 Nov 2018 18:04:31 +0000 Subject: Fix a humongous memory leak on macOS, caused by accidentally deleting a call to [NSApp _unlockAutoreleasePool]. --- macosx/tkMacOSXWindowEvent.c | 11 +++++++---- macosx/tkMacOSXWm.c | 9 ++++++--- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/macosx/tkMacOSXWindowEvent.c b/macosx/tkMacOSXWindowEvent.c index a1a3d1a..5bb42ae 100644 --- a/macosx/tkMacOSXWindowEvent.c +++ b/macosx/tkMacOSXWindowEvent.c @@ -922,16 +922,19 @@ ConfigureRestrictProc( TkMacOSXUpdateClipRgn(winPtr); /* - * Finally, generate and process expose events to redraw the window. + * Generate and process expose events to redraw the window. */ HIRect bounds = NSRectToCGRect([self bounds]); HIShapeRef shape = HIShapeCreateWithRect(&bounds); [self generateExposeEvents: shape]; [w displayIfNeeded]; - if ([NSApp macMinorVersion] > 13) { - [NSApp setIsDrawing:NO]; - } + + /* + * Finally, unlock the main autoreleasePool. + */ + + [NSApp _unlockAutoreleasePool]; } } diff --git a/macosx/tkMacOSXWm.c b/macosx/tkMacOSXWm.c index a56444d..9e45996 100644 --- a/macosx/tkMacOSXWm.c +++ b/macosx/tkMacOSXWm.c @@ -468,7 +468,8 @@ NSStatusItem *exitFullScreen; title = "unnamed window"; } if (DEBUG_ZOMBIES > 1){ - printf("Autoreleased <%s>. Count is %lu\n", title, [self retainCount]); + fprintf(stderr, "Autoreleased <%s>. Count is %lu\n", + title, [self retainCount]); } return result; } @@ -479,7 +480,8 @@ NSStatusItem *exitFullScreen; title = "unnamed window"; } if (DEBUG_ZOMBIES > 1){ - printf("Releasing <%s>. Count is %lu\n", title, [self retainCount]); + fprintf(stderr, "Releasing <%s>. Count is %lu\n", + title, [self retainCount]); } [super release]; } @@ -490,7 +492,8 @@ NSStatusItem *exitFullScreen; title = "unnamed window"; } if (DEBUG_ZOMBIES > 0){ - printf(">>>> Freeing <%s>. Count is %lu\n", title, [self retainCount]); + fprintf(stderr, ">>>> Freeing <%s>. Count is %lu\n", + title, [self retainCount]); } [super dealloc]; } -- cgit v0.12 From 41422b218e1d111f4fe66b08f94cc8719e1eb6cd Mon Sep 17 00:00:00 2001 From: dgp Date: Fri, 16 Nov 2018 18:11:09 +0000 Subject: Fix release date. --- changes | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/changes b/changes index 81108a5..29e992a 100644 --- a/changes +++ b/changes @@ -7568,4 +7568,4 @@ Tk Cocoa 2.0: More drawing internals refinements (culler,walzer) 2018-11-04 (bug)[6b22d4] [treeview] binding fix (ohagan) -- Released 8.6.9, November 9, 2018 - http://core.tcl-lang.org/tk/ for details - +- Released 8.6.9, November 16, 2018 - http://core.tcl-lang.org/tk/ for details - -- cgit v0.12 From db2ee25c92c507efa66f4946aaa841e3045eaac2 Mon Sep 17 00:00:00 2001 From: fvogel Date: Fri, 16 Nov 2018 21:54:53 +0000 Subject: Make a difference in the error message between the case where the clipboard is not available (because some other application grabbed it), and the case where the clipboard content cannot be retrieved. --- win/tkWinClipboard.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/win/tkWinClipboard.c b/win/tkWinClipboard.c index 03c0cde..877eed4 100644 --- a/win/tkWinClipboard.c +++ b/win/tkWinClipboard.c @@ -55,9 +55,14 @@ TkSelGetSelection( Tcl_Encoding encoding; int result, locale, noBackslash = 0; + if (!OpenClipboard(NULL)) { + Tcl_SetObjResult(interp, Tcl_ObjPrintf( + "clipboard cannot be opened, another application grabbed it")); + Tcl_SetErrorCode(interp, "TK", "CLIPBOARD", "BUSY", NULL); + return TCL_ERROR; + } if ((selection != Tk_InternAtom(tkwin, "CLIPBOARD")) - || (target != XA_STRING) - || !OpenClipboard(NULL)) { + || (target != XA_STRING)) { goto error; } -- cgit v0.12 From f372cc0fac89fc68a385e93b5db724674510b5f1 Mon Sep 17 00:00:00 2001 From: fvogel Date: Sat, 17 Nov 2018 08:04:24 +0000 Subject: Comment clipboard.test and winClipboard.test --- tests/clipboard.test | 5 +++++ tests/winClipboard.test | 8 ++++---- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/tests/clipboard.test b/tests/clipboard.test index 7f72f17..9689942 100644 --- a/tests/clipboard.test +++ b/tests/clipboard.test @@ -11,6 +11,11 @@ # environment variable TK_ALT_DISPLAY is set to an alternate display. # +################################################################# +# Note that some of these tests may fail if another application # +# is grabbing the clipboard (e.g. an X server, or a VNC viewer) # +################################################################# + package require tcltest 2.2 namespace import ::tcltest::* eval tcltest::configure $argv diff --git a/tests/winClipboard.test b/tests/winClipboard.test index 1d17b14..2f72966 100644 --- a/tests/winClipboard.test +++ b/tests/winClipboard.test @@ -15,10 +15,10 @@ eval tcltest::configure $argv tcltest::loadTestedCommands namespace import -force tcltest::test -########################################################################### -# Note that these tests may fail if another application is grabbing the # -# clipboard (e.g. an X server, or a VNC viewer - See ticket [9b0f3ee54e]) # -########################################################################### +################################################################# +# Note that some of these tests may fail if another application # +# is grabbing the clipboard (e.g. an X server, or a VNC viewer) # +################################################################# test winClipboard-1.1 {TkSelGetSelection} -constraints win -setup { clipboard clear -- cgit v0.12 From a705839ae15b69c4e2eb9355c4749231e3938777 Mon Sep 17 00:00:00 2001 From: fvogel Date: Sat, 17 Nov 2018 15:10:39 +0000 Subject: Fix [0a9c91951b]: text-11a.22 segfault --- generic/tkText.c | 9 --------- generic/tkTextDisp.c | 3 ++- 2 files changed, 2 insertions(+), 10 deletions(-) diff --git a/generic/tkText.c b/generic/tkText.c index a0de1d5..4c536a2 100644 --- a/generic/tkText.c +++ b/generic/tkText.c @@ -5538,15 +5538,6 @@ RunAfterSyncCmd( return; } - if (textPtr->afterSyncCmd == NULL) { - /* - * [Bug 0a9c9151b5] Probably should have idle handlers coded so that - * this cannot happen, but a safety check here at least prevents a - * crash. - */ - return; - } - Tcl_Preserve((ClientData) textPtr->interp); code = Tcl_EvalObjEx(textPtr->interp, textPtr->afterSyncCmd, TCL_EVAL_GLOBAL); if (code == TCL_ERROR) { diff --git a/generic/tkTextDisp.c b/generic/tkTextDisp.c index 84be232..348b8c4 100644 --- a/generic/tkTextDisp.c +++ b/generic/tkTextDisp.c @@ -6297,7 +6297,8 @@ TkTextPendingsync( TextDInfo *dInfoPtr = textPtr->dInfoPtr; return ( - ((dInfoPtr->metricEpoch == -1) && + (!(dInfoPtr->flags & REDRAW_PENDING) && + (dInfoPtr->metricEpoch == -1) && (dInfoPtr->lastMetricUpdateLine == dInfoPtr->currentMetricUpdateLine)) ? 0 : 1); } -- cgit v0.12 From 8ee89795932d592d7960dd2a822765f7501fcd5d Mon Sep 17 00:00:00 2001 From: fvogel Date: Sat, 17 Nov 2018 15:17:33 +0000 Subject: Add comments in text-11a.22 making it more easy to follow progress in the expected result buildind --- tests/text.test | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/tests/text.test b/tests/text.test index 95e666a..988417e 100644 --- a/tests/text.test +++ b/tests/text.test @@ -3028,17 +3028,17 @@ test text-11a.22 {TextWidgetCmd procedure, "sync" option with -command} -setup { } .top.yt insert 1.0 $content # first case: line metrics calculation still running when launching 'sync -command' - lappend res [.top.yt pendingsync] + lappend res [.top.yt pendingsync] ; # {1} .top.yt sync -command [list set ::x 1] - lappend res $::x + lappend res $::x ; # {1 0} # now finish line metrics calculations while {[.top.yt pendingsync]} {update} - lappend res [.top.yt pendingsync] $::x + lappend res [.top.yt pendingsync] $::x ; # {1 0 0 1} # second case: line metrics calculation completed when launching 'sync -command' .top.yt sync -command [list set ::x 2] - lappend res $::x + lappend res $::x ; # {1 0 0 1 1} vwait ::x - lappend res $::x + lappend res $::x ; # {1 0 0 1 1 2} } -cleanup { destroy .top.yt .top } -result {1 0 0 1 1 2} -- cgit v0.12 From 28c0241a6bb6b806bfc2094ed2c41e24c9887952 Mon Sep 17 00:00:00 2001 From: dgp Date: Sat, 17 Nov 2018 17:30:43 +0000 Subject: Possible fix for regression in Mojave appearance. Needs Mojave testing. --- macosx/tkMacOSXWindowEvent.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/macosx/tkMacOSXWindowEvent.c b/macosx/tkMacOSXWindowEvent.c index 5bb42ae..5429487 100644 --- a/macosx/tkMacOSXWindowEvent.c +++ b/macosx/tkMacOSXWindowEvent.c @@ -929,6 +929,9 @@ ConfigureRestrictProc( HIShapeRef shape = HIShapeCreateWithRect(&bounds); [self generateExposeEvents: shape]; [w displayIfNeeded]; + if ([NSApp macMinorVersion] > 13) { + [NSApp setIsDrawing:NO]; + } /* * Finally, unlock the main autoreleasePool. -- cgit v0.12 From 67e24421647db1ad20991e4dd6cabb82d136b8ae Mon Sep 17 00:00:00 2001 From: culler Date: Sun, 18 Nov 2018 13:47:56 +0000 Subject: Fix bug [273b6a4996]: spinbox shrivels --- macosx/tkMacOSXEntry.c | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/macosx/tkMacOSXEntry.c b/macosx/tkMacOSXEntry.c index ab236c6..5e38f73 100644 --- a/macosx/tkMacOSXEntry.c +++ b/macosx/tkMacOSXEntry.c @@ -91,7 +91,7 @@ TkpDrawEntryBorderAndFocus( TkMacOSXDrawingContext dc; GC bgGC; Tk_Window tkwin = entryPtr->tkwin; - int oldWidth = 0; + int boxWidth; MacDrawable *macDraw = (MacDrawable *) d; const HIThemeFrameDrawInfo info = { .version = 0, @@ -122,12 +122,9 @@ TkpDrawEntryBorderAndFocus( if (isSpinbox) { int incDecWidth; - - oldWidth = Tk_Width(tkwin); - ComputeIncDecParameters(Tk_Height(tkwin) - 2 * MAC_OSX_FOCUS_WIDTH, &incDecWidth); - Tk_Width(tkwin) -= incDecWidth + 1; + boxWidth = Tk_Width(tkwin) - incDecWidth - 1; } /* @@ -146,16 +143,13 @@ TkpDrawEntryBorderAndFocus( bounds.origin.x = macDraw->xOff + MAC_OSX_FOCUS_WIDTH; bounds.origin.y = macDraw->yOff + MAC_OSX_FOCUS_WIDTH; - bounds.size.width = Tk_Width(tkwin) - 2*MAC_OSX_FOCUS_WIDTH; + bounds.size.width = boxWidth - 2*MAC_OSX_FOCUS_WIDTH; bounds.size.height = Tk_Height(tkwin) - 2*MAC_OSX_FOCUS_WIDTH; if (!TkMacOSXSetupDrawingContext(d, NULL, 1, &dc)) { return 0; } ChkErr(HIThemeDrawFrame, &bounds, &info, dc.context, HIOrientation); TkMacOSXRestoreDrawingContext(&dc); - if (isSpinbox) { - Tk_Width(tkwin) = oldWidth; - } return 1; } -- cgit v0.12 From dd4ed400b944368e798553efd57cffeb83f1d91d Mon Sep 17 00:00:00 2001 From: culler Date: Mon, 19 Nov 2018 01:53:41 +0000 Subject: Restore protection against recursive calls to [NSView drawRect] which was accidentally broken in check-in [609de893] --- macosx/tkMacOSXWindowEvent.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/macosx/tkMacOSXWindowEvent.c b/macosx/tkMacOSXWindowEvent.c index a87a4ab..bb426a6 100644 --- a/macosx/tkMacOSXWindowEvent.c +++ b/macosx/tkMacOSXWindowEvent.c @@ -837,8 +837,10 @@ ConfigureRestrictProc( * them on OSX > 10.13, where they should never happen. */ - if ([NSApp isDrawing] && [NSApp macMinorVersion] > 13) { - TKLog(@"WARNING: a recursive call to drawRect was aborted."); + if ([NSApp isDrawing]) { + if ([NSApp macMinorVersion] > 13) { + TKLog(@"WARNING: a recursive call to drawRect was aborted."); + } return; } -- cgit v0.12 From a8b516734aa8fe95c3f7921c1ee81dd65ec4745b Mon Sep 17 00:00:00 2001 From: culler Date: Mon, 19 Nov 2018 14:21:35 +0000 Subject: Implement a *correct* fix for the Spinbox drawing code, thanks to Christian Werner. --- macosx/tkMacOSXEntry.c | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/macosx/tkMacOSXEntry.c b/macosx/tkMacOSXEntry.c index 5e38f73..dfb9eb1 100644 --- a/macosx/tkMacOSXEntry.c +++ b/macosx/tkMacOSXEntry.c @@ -91,7 +91,7 @@ TkpDrawEntryBorderAndFocus( TkMacOSXDrawingContext dc; GC bgGC; Tk_Window tkwin = entryPtr->tkwin; - int boxWidth; + int oldWidth; MacDrawable *macDraw = (MacDrawable *) d; const HIThemeFrameDrawInfo info = { .version = 0, @@ -122,9 +122,18 @@ TkpDrawEntryBorderAndFocus( if (isSpinbox) { 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. + */ + + oldWidth = Tk_Width(tkwin); ComputeIncDecParameters(Tk_Height(tkwin) - 2 * MAC_OSX_FOCUS_WIDTH, &incDecWidth); - boxWidth = Tk_Width(tkwin) - incDecWidth - 1; + Tk_Width(tkwin) -= incDecWidth + 1; } /* @@ -143,13 +152,25 @@ TkpDrawEntryBorderAndFocus( bounds.origin.x = macDraw->xOff + MAC_OSX_FOCUS_WIDTH; bounds.origin.y = macDraw->yOff + MAC_OSX_FOCUS_WIDTH; - bounds.size.width = boxWidth - 2*MAC_OSX_FOCUS_WIDTH; + bounds.size.width = Tk_Width(tkwin) - 2*MAC_OSX_FOCUS_WIDTH; bounds.size.height = Tk_Height(tkwin) - 2*MAC_OSX_FOCUS_WIDTH; if (!TkMacOSXSetupDrawingContext(d, NULL, 1, &dc)) { + + /* + * No graphics context is available. If the widget is a Spinbox, we + * must restore its width before returning 0. (Ticket [273b6a4996].) + */ + + if (isSpinbox) { + Tk_Width(tkwin) = oldWidth; + } return 0; } ChkErr(HIThemeDrawFrame, &bounds, &info, dc.context, HIOrientation); TkMacOSXRestoreDrawingContext(&dc); + if (isSpinbox) { + Tk_Width(tkwin) = oldWidth; + } return 1; } -- cgit v0.12 From 0a42f0a076ef817fb754688b9ec08860bee20569 Mon Sep 17 00:00:00 2001 From: culler Date: Mon, 19 Nov 2018 16:46:35 +0000 Subject: Use XCreateImage instead of XGetImage to create a scratch image in ttkDefaultTheme.c --- generic/ttk/ttkDefaultTheme.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/generic/ttk/ttkDefaultTheme.c b/generic/ttk/ttkDefaultTheme.c index 4a06192..20ba013 100644 --- a/generic/ttk/ttkDefaultTheme.c +++ b/generic/ttk/ttkDefaultTheme.c @@ -510,7 +510,7 @@ static void IndicatorElementDraw( XGCValues gcValues; GC copyGC; unsigned long imgColors[8]; - XImage *img; + XImage *img = NULL; Ttk_GetPaddingFromObj(NULL, tkwin, indicator->marginObj, &padding); b = Ttk_PadBox(b, padding); @@ -550,11 +550,17 @@ static void IndicatorElementDraw( /* * Create a scratch buffer to store the image: */ - img = XGetImage(display,d, 0, 0, - (unsigned int)spec->width, (unsigned int)spec->height, - AllPlanes, ZPixmap); - if (img == NULL) - return; + + img = XCreateImage(display, NULL, 32, ZPixmap, 0, NULL, + (unsigned int)spec->width, (unsigned int)spec->height, + 0, 0); + if (img == NULL) { + return; + } + img->data = ckalloc(img->bytes_per_line * img->height); + if (img->data == NULL) { + return; + } /* * Create the image, painting it into an XImage one pixel at a time. @@ -572,7 +578,6 @@ static void IndicatorElementDraw( */ memset(&gcValues, 0, sizeof(gcValues)); copyGC = Tk_GetGC(tkwin, 0, &gcValues); - TkPutImage(NULL, 0, display, d, copyGC, img, 0, 0, b.x, b.y, spec->width, spec->height); -- cgit v0.12 From 11dcff268e1d978ba036f5ea7c88b32f09330bfd Mon Sep 17 00:00:00 2001 From: culler Date: Mon, 19 Nov 2018 18:32:28 +0000 Subject: Refine TkMacOSXFlushWindows and add a call to it in ThemeChangedProc (macOS only) so that windows are updated after the theme changes. --- generic/ttk/ttkTheme.c | 4 ++++ macosx/tkMacOSXEvent.c | 17 +++++++++++++---- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/generic/ttk/ttkTheme.c b/generic/ttk/ttkTheme.c index 2f95962..ac52595 100644 --- a/generic/ttk/ttkTheme.c +++ b/generic/ttk/ttkTheme.c @@ -513,6 +513,10 @@ static void ThemeChangedProc(ClientData clientData) Tcl_BackgroundException(pkgPtr->interp, code); } pkgPtr->themeChangePending = 0; +#ifdef MAC_OSX_TK + extern void TkMacOSXFlushWindows(void); + TkMacOSXFlushWindows(); +#endif } /* diff --git a/macosx/tkMacOSXEvent.c b/macosx/tkMacOSXEvent.c index 843ef8c..d866b02 100644 --- a/macosx/tkMacOSXEvent.c +++ b/macosx/tkMacOSXEvent.c @@ -137,13 +137,22 @@ MODULE_SCOPE void TkMacOSXFlushWindows(void) { NSArray *macWindows = [NSApp orderedWindows]; + if ([macWindows count] > 0) { while (Tcl_DoOneEvent(TCL_IDLE_EVENTS)){} } - for (NSWindow *w in macWindows) { - if (TkMacOSXGetXWindow(w)) { - [w displayIfNeeded]; - } + if ([NSApp isDrawing]) { + for (NSWindow *w in macWindows) { + if (TkMacOSXGetXWindow(w)) { + [w setViewsNeedDisplay:YES]; + } + } + } else { + for (NSWindow *w in macWindows) { + if (TkMacOSXGetXWindow(w)) { + [w display]; + } + } } } -- cgit v0.12 From 13f6c367a6b4413a8ae0bdda8eb77bf1c98534d7 Mon Sep 17 00:00:00 2001 From: culler Date: Tue, 20 Nov 2018 18:52:42 +0000 Subject: Only use XCreateImage when drawing the Alt theme indicator on macOS, not on UNIX or Windows. --- generic/ttk/ttkDefaultTheme.c | 43 ++++++++++++++++++++++++++++++++++++++----- generic/ttk/ttkTheme.c | 12 ++++++++---- 2 files changed, 46 insertions(+), 9 deletions(-) diff --git a/generic/ttk/ttkDefaultTheme.c b/generic/ttk/ttkDefaultTheme.c index 20ba013..473caba 100644 --- a/generic/ttk/ttkDefaultTheme.c +++ b/generic/ttk/ttkDefaultTheme.c @@ -18,6 +18,10 @@ static const int WIN32_XDRAWLINE_HACK = 1; static const int WIN32_XDRAWLINE_HACK = 0; #endif +#if defined(MAC_OSX_TK) + #define IGNORES_VISUAL +#endif + #define BORDERWIDTH 2 #define SCROLLBAR_WIDTH 14 #define MIN_THUMB_SIZE 8 @@ -551,20 +555,47 @@ static void IndicatorElementDraw( * Create a scratch buffer to store the image: */ +#if defined(IGNORES_VISUAL) + + /* + * Platforms which ignore the VisualInfo can use XCreateImage to get the + * scratch image. This is essential on macOS, where it is not safe to call + * XGetImage in a display procedure. + */ + img = XCreateImage(display, NULL, 32, ZPixmap, 0, NULL, (unsigned int)spec->width, (unsigned int)spec->height, 0, 0); +#else + + /* + * This trick allows creating the scratch XImage without having to + * construct a VisualInfo. + */ + + img = XGetImage(display, d, 0, 0, + (unsigned int)spec->width, (unsigned int)spec->height, + AllPlanes, ZPixmap); +#endif + if (img == NULL) { - return; + return; } + +#if defined(IGNORES_VISUAL) + img->data = ckalloc(img->bytes_per_line * img->height); if (img->data == NULL) { - return; + XDestroyImage(img); + return; } +#endif + /* - * Create the image, painting it into an XImage one pixel at a time. + * Create the image, painting it into the XImage one pixel at a time. */ + index = Ttk_StateTableLookup(spec->map, state); for (iy=0 ; iyheight ; iy++) { for (ix=0 ; ixwidth ; ix++) { @@ -574,16 +605,18 @@ static void IndicatorElementDraw( } /* - * Copy onto our target drawable surface. + * Copy the image onto our target drawable surface. */ + memset(&gcValues, 0, sizeof(gcValues)); copyGC = Tk_GetGC(tkwin, 0, &gcValues); TkPutImage(NULL, 0, display, d, copyGC, img, 0, 0, b.x, b.y, spec->width, spec->height); /* - * Tidy up. + * Tidy up. Note that XDestroyImage frees img->data. */ + Tk_FreeGC(display, copyGC); XDestroyImage(img); } diff --git a/generic/ttk/ttkTheme.c b/generic/ttk/ttkTheme.c index ac52595..c0bd784 100644 --- a/generic/ttk/ttkTheme.c +++ b/generic/ttk/ttkTheme.c @@ -18,6 +18,13 @@ #define PKG_ASSOC_KEY "Ttk" +#ifdef MAC_OSX_TK + extern void TkMacOSXFlushWindows(void); + #define UPDATE_WINDOWS() TkMacOSXFlushWindows() +#else + #define UPDATE_WINDOWS() +#endif + /*------------------------------------------------------------------------ * +++ Styles. * @@ -513,10 +520,7 @@ static void ThemeChangedProc(ClientData clientData) Tcl_BackgroundException(pkgPtr->interp, code); } pkgPtr->themeChangePending = 0; -#ifdef MAC_OSX_TK - extern void TkMacOSXFlushWindows(void); - TkMacOSXFlushWindows(); -#endif + UPDATE_WINDOWS(); } /* -- cgit v0.12 From 5e47d46cce7794b3e23422170e464555fb171ce5 Mon Sep 17 00:00:00 2001 From: culler Date: Wed, 21 Nov 2018 06:42:02 +0000 Subject: Protect against the possibility that a future platform might have a strange implementaton of XDestroyImage. --- generic/ttk/ttkDefaultTheme.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/generic/ttk/ttkDefaultTheme.c b/generic/ttk/ttkDefaultTheme.c index 473caba..d331655 100644 --- a/generic/ttk/ttkDefaultTheme.c +++ b/generic/ttk/ttkDefaultTheme.c @@ -614,10 +614,22 @@ static void IndicatorElementDraw( spec->width, spec->height); /* - * Tidy up. Note that XDestroyImage frees img->data. + * Tidy up. */ Tk_FreeGC(display, copyGC); + + /* + * Protect against the possibility that some future platform might + * not use the Tk memory manager in its implementation of XDestroyImage, + * even though that would be an extremely strange thing to do. + */ + +#if defined(IGNORES_VISUAL) + ckfree(img->data); + img->data = NULL; +#endif + XDestroyImage(img); } -- cgit v0.12 From 87224927eaf6ec76c6a0f29109e1cadedf7568bc Mon Sep 17 00:00:00 2001 From: culler Date: Wed, 21 Nov 2018 15:10:33 +0000 Subject: Implement NSWindow methods toggleTabBar and toggleFullScreen by calling super and then applying window attributes. --- macosx/tkMacOSXWm.c | 157 ++++------------------------------------------------ 1 file changed, 12 insertions(+), 145 deletions(-) diff --git a/macosx/tkMacOSXWm.c b/macosx/tkMacOSXWm.c index 9e45996..bd3d68f 100644 --- a/macosx/tkMacOSXWm.c +++ b/macosx/tkMacOSXWm.c @@ -388,45 +388,26 @@ static void RemapWindows(TkWindow *winPtr, @implementation TKWindow: NSWindow -/* Custom fullscreen implementation on 10.13 and above. On older versions of - * macOS dating back to 10.7, the NSWindow fullscreen API was opt-in, requiring - * explicit calls to toggleFullScreen. On 10.13, the API became implicit, - * applying to all NSWindows unless they were marked non-resizable; this caused - * issues with Tk, which was not aware of changes in screen geometry. Here we - * override the toggleFullScreen call to hook directly into Tk's own fullscreen - * API, allowing Tk to function smoothly with the Mac's fullscreen button. -*/ - -NSStatusItem *exitFullScreen; - - - (void)toggleFullScreen:(id)sender { - TkWindow *winPtr = TkMacOSXGetTkWindow(self); - if (!winPtr) { - return; - } - Tcl_Interp *interp = Tk_Interp((Tk_Window)winPtr); - if ([NSApp macMinorVersion] > 12) { - if (([self styleMask] & NSFullScreenWindowMask) == NSFullScreenWindowMask) { - TkMacOSXMakeFullscreen(winPtr, self, 0, interp); - } else { - TkMacOSXMakeFullscreen(winPtr, self, 1, interp); - } - } else { - TKLog (@"toggleFullScreen is ignored by Tk on OSX versions < 10.13"); - } + TkWindow *winPtr = TkMacOSXGetTkWindow(self); + MacDrawable *macWin = winPtr->privatePtr; + if (!winPtr) { + return; + } + [super toggleFullScreen:sender]; + TkMacOSXApplyWindowAttributes(macWin->winPtr, self); } --(void)restoreOldScreen:(id)sender +- (void)toggleTabBar:(id)sender { TkWindow *winPtr = TkMacOSXGetTkWindow(self); + MacDrawable *macWin = winPtr->privatePtr; if (!winPtr) { return; } - Tcl_Interp *interp = Tk_Interp((Tk_Window)winPtr); - TkMacOSXMakeFullscreen(winPtr, self, 0, interp); - [[NSStatusBar systemStatusBar] removeStatusItem: exitFullScreen]; + [super toggleTabBar:sender]; + TkMacOSXApplyWindowAttributes(macWin->winPtr, self); } @end @@ -1300,10 +1281,7 @@ WmSetAttribute( return TCL_ERROR; } if (boolean != ((wmPtr->flags & WM_FULLSCREEN) != 0)) { - if (TkMacOSXMakeFullscreen(winPtr, macWindow, boolean, interp) - != TCL_OK) { - return TCL_ERROR; - } + [macWindow toggleFullScreen:macWindow]; } break; case WMATT_MODIFIED: @@ -6510,117 +6488,6 @@ ApplyMasterOverrideChanges( /* *---------------------------------------------------------------------- * - * TkMacOSXMakeFullscreen -- - * - * This procedure sets a fullscreen window to the size of the screen. - * - * Results: - * A standard Tcl result. - * - * Side effects: - * None. - * - *---------------------------------------------------------------------- - */ - -int -TkMacOSXMakeFullscreen( - TkWindow *winPtr, - NSWindow *window, - int fullscreen, - Tcl_Interp *interp) -{ - WmInfo *wmPtr = winPtr->wmInfoPtr; - int screenWidth = WidthOfScreen(Tk_Screen(winPtr)); - int screenHeight = HeightOfScreen(Tk_Screen(winPtr)); - - if (fullscreen) { - - /* - * Check max width and height if set by the user. - */ - - if ((wmPtr->maxWidth > 0 && wmPtr->maxWidth < screenWidth) - || (wmPtr->maxHeight > 0 && wmPtr->maxHeight < screenHeight)) { - if (interp) { - Tcl_SetObjResult(interp, Tcl_ObjPrintf( - "can't set fullscreen attribute for \"%s\": max" - " width/height is too small", winPtr->pathName)); - Tcl_SetErrorCode(interp, "TK", "FULLSCREEN", - "CONSTRAINT_FAILURE", NULL); - } - wmPtr->flags &= ~WM_FULLSCREEN; - return TCL_ERROR; - } - - /* - * Save the current window state. - */ - - wmPtr->cachedBounds = [window frame]; - wmPtr->cachedStyle = [window styleMask]; - wmPtr->cachedPresentation = [NSApp presentationOptions]; - - /* - * Adjust the window style so it looks like a Fullscreen window. - */ - - [window setStyleMask: NSFullScreenWindowMask]; - [NSApp setPresentationOptions: (NSApplicationPresentationAutoHideDock | - NSApplicationPresentationAutoHideMenuBar)]; - - /*For 10.13 and later add a button for exiting Fullscreen.*/ - if ([NSApp macMinorVersion] > 12) { -#if MAC_OS_X_VERSION_MAX_ALLOWED > 101200 - exitFullScreen = [[[NSStatusBar systemStatusBar] - statusItemWithLength:NSVariableStatusItemLength] retain]; - NSImage *exitIcon = [NSImage imageNamed:@"NSExitFullScreenTemplate"]; - exitFullScreen.button.image = exitIcon; - exitFullScreen.button.cell.highlighted = NO; - exitFullScreen.button.toolTip = @"Exit Full Screen"; - exitFullScreen.button.target = window; - exitFullScreen.button.action = @selector(restoreOldScreen:); -#endif - } - - /* - * Resize the window to fill the screen. (After setting the style!) - */ - - wmPtr->flags |= WM_SYNC_PENDING; - NSRect screenBounds = NSMakeRect(0, 0, screenWidth, screenHeight); - [window setFrame:screenBounds display:YES]; - wmPtr->flags &= ~WM_SYNC_PENDING; - wmPtr->flags |= WM_FULLSCREEN; - } else { - - /* - * Restore the previous styles and attributes. - */ - - [NSApp setPresentationOptions: wmPtr->cachedPresentation]; - [window setStyleMask: wmPtr->cachedStyle]; - UInt64 oldAttributes = wmPtr->attributes; - wmPtr->flags &= ~WM_FULLSCREEN; - wmPtr->attributes |= wmPtr->configAttributes & - kWindowResizableAttribute; - ApplyWindowAttributeFlagChanges(winPtr, window, oldAttributes, - wmPtr->flags, 1, 0); - - /* - * Resize the window to its previous size. - */ - - wmPtr->flags |= WM_SYNC_PENDING; - [window setFrame:wmPtr->cachedBounds display:YES]; - wmPtr->flags &= ~WM_SYNC_PENDING; - } - return TCL_OK; -} - -/* - *---------------------------------------------------------------------- - * * GetMinSize -- * * This function computes the current minWidth and minHeight values for a -- cgit v0.12 From bdc4876ca53a1aa429f37abf5beafd3b1c804266 Mon Sep 17 00:00:00 2001 From: culler Date: Thu, 22 Nov 2018 17:51:49 +0000 Subject: Apply window attributes in an NSWindowDidEnterFullScreenNotification observer rather than in toggleFullScreen. This works for split screens as well. --- macosx/tkMacOSXWindowEvent.c | 21 +++++++++++++++++++++ macosx/tkMacOSXWm.c | 11 ----------- 2 files changed, 21 insertions(+), 11 deletions(-) diff --git a/macosx/tkMacOSXWindowEvent.c b/macosx/tkMacOSXWindowEvent.c index bb426a6..2e5be8f 100644 --- a/macosx/tkMacOSXWindowEvent.c +++ b/macosx/tkMacOSXWindowEvent.c @@ -136,6 +136,26 @@ extern NSString *NSWindowDidOrderOffScreenNotification; } } +- (void) windowEnteredFullScreen: (NSNotification *) notification +{ +#ifdef TK_MAC_DEBUG_NOTIFICATIONS + TKLog(@"-[%@(%p) %s] %@", [self class], self, _cmd, notification); +#endif + NSWindow *w = [notification object]; + TkWindow *winPtr = TkMacOSXGetTkWindow(w); + MacDrawable *macWin = winPtr->privatePtr; + + /* + * We must apply the current window attributes when the window becomes a + * FullScreen or a split screen window. Otherwise the mouse cursor will be + * offset by the title bar height. The notification is sent in both cases. + */ + + if (winPtr) { + TkMacOSXApplyWindowAttributes(macWin->winPtr, w); + } +} + - (void) windowCollapsed: (NSNotification *) notification { #ifdef TK_MAC_DEBUG_NOTIFICATIONS @@ -228,6 +248,7 @@ extern NSString *NSWindowDidOrderOffScreenNotification; observe(NSWindowDidResizeNotification, windowBoundsChanged:); observe(NSWindowDidDeminiaturizeNotification, windowExpanded:); observe(NSWindowDidMiniaturizeNotification, windowCollapsed:); + observe(NSWindowDidEnterFullScreenNotification, windowEnteredFullScreen:); #ifdef TK_MAC_DEBUG_NOTIFICATIONS observe(NSWindowWillMoveNotification, windowDragStart:); observe(NSWindowWillStartLiveResizeNotification, windowLiveResize:); diff --git a/macosx/tkMacOSXWm.c b/macosx/tkMacOSXWm.c index bd3d68f..9b379c0 100644 --- a/macosx/tkMacOSXWm.c +++ b/macosx/tkMacOSXWm.c @@ -388,17 +388,6 @@ static void RemapWindows(TkWindow *winPtr, @implementation TKWindow: NSWindow -- (void)toggleFullScreen:(id)sender -{ - TkWindow *winPtr = TkMacOSXGetTkWindow(self); - MacDrawable *macWin = winPtr->privatePtr; - if (!winPtr) { - return; - } - [super toggleFullScreen:sender]; - TkMacOSXApplyWindowAttributes(macWin->winPtr, self); -} - - (void)toggleTabBar:(id)sender { TkWindow *winPtr = TkMacOSXGetTkWindow(self); -- cgit v0.12 From 74567cf0e43fecf2f994fb06f16c6866c93f27d3 Mon Sep 17 00:00:00 2001 From: Kevin Walzer Date: Thu, 22 Nov 2018 19:13:29 +0000 Subject: Fix coordinates when window exits full screen --- macosx/tkMacOSXWindowEvent.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/macosx/tkMacOSXWindowEvent.c b/macosx/tkMacOSXWindowEvent.c index 2e5be8f..44702e6 100644 --- a/macosx/tkMacOSXWindowEvent.c +++ b/macosx/tkMacOSXWindowEvent.c @@ -156,6 +156,26 @@ extern NSString *NSWindowDidOrderOffScreenNotification; } } +- (void) windowExitedFullScreen: (NSNotification *) notification +{ +#ifdef TK_MAC_DEBUG_NOTIFICATIONS + TKLog(@"-[%@(%p) %s] %@", [self class], self, _cmd, notification); +#endif + NSWindow *w = [notification object]; + TkWindow *winPtr = TkMacOSXGetTkWindow(w); + MacDrawable *macWin = winPtr->privatePtr; + + /* + * We must apply the current window attributes when the window becomes a + * FullScreen or a split screen window. Otherwise the mouse cursor will be + * offset by the title bar height. The notification is sent in both cases. + */ + + if (winPtr) { + TkMacOSXApplyWindowAttributes(macWin->winPtr, w); + } +} + - (void) windowCollapsed: (NSNotification *) notification { #ifdef TK_MAC_DEBUG_NOTIFICATIONS @@ -249,6 +269,7 @@ extern NSString *NSWindowDidOrderOffScreenNotification; observe(NSWindowDidDeminiaturizeNotification, windowExpanded:); observe(NSWindowDidMiniaturizeNotification, windowCollapsed:); observe(NSWindowDidEnterFullScreenNotification, windowEnteredFullScreen:); + observe(NSWindowDidExitFullScreenNotification, windowExitedFullScreen:); #ifdef TK_MAC_DEBUG_NOTIFICATIONS observe(NSWindowWillMoveNotification, windowDragStart:); observe(NSWindowWillStartLiveResizeNotification, windowLiveResize:); -- cgit v0.12 From 6a5cd5ed2cdcb924125f10bd9229aa00d24a2694 Mon Sep 17 00:00:00 2001 From: culler Date: Thu, 22 Nov 2018 19:30:59 +0000 Subject: Edited a comment. --- macosx/tkMacOSXWindowEvent.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/macosx/tkMacOSXWindowEvent.c b/macosx/tkMacOSXWindowEvent.c index 44702e6..fa4a8ce 100644 --- a/macosx/tkMacOSXWindowEvent.c +++ b/macosx/tkMacOSXWindowEvent.c @@ -166,9 +166,8 @@ extern NSString *NSWindowDidOrderOffScreenNotification; MacDrawable *macWin = winPtr->privatePtr; /* - * We must apply the current window attributes when the window becomes a - * FullScreen or a split screen window. Otherwise the mouse cursor will be - * offset by the title bar height. The notification is sent in both cases. + * Also apply the current window attributes when the window returns to its + * normal size, for the same reason. */ if (winPtr) { -- cgit v0.12 From 6da9178069c3c923e3df144f28034f9d4fee60ed Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Sat, 24 Nov 2018 09:04:42 +0000 Subject: sync tcl.m4 with Tcl version --- unix/configure | 12 ++++++------ unix/tcl.m4 | 4 ++-- win/tcl.m4 | 4 ++-- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/unix/configure b/unix/configure index efd289f..cf5ce30 100755 --- a/unix/configure +++ b/unix/configure @@ -7312,18 +7312,18 @@ ac_x_header_dirs=' /usr/openwin/share/include' if test "$ac_x_includes" = no; then - # Guess where to find include files, by looking for Intrinsic.h. + # Guess where to find include files, by looking for Xlib.h. # First, try using that file with no special directory specified. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ -#include +#include _ACEOF if ac_fn_c_try_cpp "$LINENO"; then : # We can compile using X headers with no special include directory. ac_x_includes= else for ac_dir in $ac_x_header_dirs; do - if test -r "$ac_dir/X11/Intrinsic.h"; then + if test -r "$ac_dir/X11/Xlib.h"; then ac_x_includes=$ac_dir break fi @@ -7337,14 +7337,14 @@ if test "$ac_x_libraries" = no; then # See if we find them without any special options. # Don't add to $LIBS permanently. ac_save_LIBS=$LIBS - LIBS="-lXt $LIBS" + LIBS="-lX11 $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ -#include +#include int main () { -XtMalloc (0) +XrmInitialize () ; return 0; } diff --git a/unix/tcl.m4 b/unix/tcl.m4 index 6955ace..2f114d7 100644 --- a/unix/tcl.m4 +++ b/unix/tcl.m4 @@ -3011,7 +3011,7 @@ AC_DEFUN([SC_ZIPFS_SUPPORT], [ done ]) if test -f "$ac_cv_path_zip" ; then - ZIP_PROG="$ac_cv_path_zip " + ZIP_PROG="$ac_cv_path_zip" AC_MSG_RESULT([$ZIP_PROG]) ZIP_PROG_OPTIONS="-rq" ZIP_PROG_VFSSEARCH="." @@ -3020,7 +3020,7 @@ AC_DEFUN([SC_ZIPFS_SUPPORT], [ else # It is not an error if an installed version of Zip can't be located. # We can use the locally distributed minizip instead - ZIP_PROG="../minizip${EXEEXT_FOR_BUILD}" + ZIP_PROG="./minizip${EXEEXT_FOR_BUILD}" ZIP_PROG_OPTIONS="-o -r" ZIP_PROG_VFSSEARCH="." ZIP_INSTALL_OBJS="minizip${EXEEXT_FOR_BUILD}" diff --git a/win/tcl.m4 b/win/tcl.m4 index bdcd8ea..a58dc2f 100644 --- a/win/tcl.m4 +++ b/win/tcl.m4 @@ -1267,7 +1267,7 @@ AC_DEFUN([SC_ZIPFS_SUPPORT], [ done ]) if test -f "$ac_cv_path_zip" ; then - ZIP_PROG="$ac_cv_path_zip " + ZIP_PROG="$ac_cv_path_zip" AC_MSG_RESULT([$ZIP_PROG]) ZIP_PROG_OPTIONS="-rq" ZIP_PROG_VFSSEARCH="." @@ -1276,7 +1276,7 @@ AC_DEFUN([SC_ZIPFS_SUPPORT], [ else # It is not an error if an installed version of Zip can't be located. # We can use the locally distributed minizip instead - ZIP_PROG="../minizip${EXEEXT_FOR_BUILD}" + ZIP_PROG="./minizip${EXEEXT_FOR_BUILD}" ZIP_PROG_OPTIONS="-o -r" ZIP_PROG_VFSSEARCH="." ZIP_INSTALL_OBJS="minizip${EXEEXT_FOR_BUILD}" -- cgit v0.12 From 181784ecec17793582b1e92f1cb0b072bb9d8791 Mon Sep 17 00:00:00 2001 From: Kevin Walzer Date: Sat, 24 Nov 2018 16:15:35 +0000 Subject: Workaround for bundled Wish console not accepting keyboard input on Mojave --- macosx/tkMacOSXInit.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/macosx/tkMacOSXInit.c b/macosx/tkMacOSXInit.c index 3a212c4..447619f 100644 --- a/macosx/tkMacOSXInit.c +++ b/macosx/tkMacOSXInit.c @@ -382,6 +382,14 @@ TkpInit( Tcl_CreateObjCommand(interp, "::tk::mac::iconBitmap", TkMacOSXIconBitmapObjCmd, NULL, NULL); + /* + * Workaround for 3efbe4a397; console not accepting keyboard input on 10.14 + * if displayed before main window. This places console in background and it + * accepts input after being raised. + */ + + while (Tcl_DoOneEvent(TCL_IDLE_EVENTS)) {} + return TCL_OK; } -- cgit v0.12 From 2db4c62686d9cffcc479f4bc70652fad961eb244 Mon Sep 17 00:00:00 2001 From: culler Date: Sat, 24 Nov 2018 17:34:47 +0000 Subject: Implement window:willUseFullScreenContentSize so fullscreen windows will really use the full screen. --- macosx/tkMacOSXEntry.c | 2 +- macosx/tkMacOSXWindowEvent.c | 19 +++++++++++++++++++ macosx/tkMacOSXWm.c | 18 ++++++++++++++++++ 3 files changed, 38 insertions(+), 1 deletion(-) diff --git a/macosx/tkMacOSXEntry.c b/macosx/tkMacOSXEntry.c index dfb9eb1..4ab3111 100644 --- a/macosx/tkMacOSXEntry.c +++ b/macosx/tkMacOSXEntry.c @@ -91,7 +91,7 @@ TkpDrawEntryBorderAndFocus( TkMacOSXDrawingContext dc; GC bgGC; Tk_Window tkwin = entryPtr->tkwin; - int oldWidth; + int oldWidth = 0; MacDrawable *macDraw = (MacDrawable *) d; const HIThemeFrameDrawInfo info = { .version = 0, diff --git a/macosx/tkMacOSXWindowEvent.c b/macosx/tkMacOSXWindowEvent.c index fa4a8ce..9503447 100644 --- a/macosx/tkMacOSXWindowEvent.c +++ b/macosx/tkMacOSXWindowEvent.c @@ -136,6 +136,20 @@ extern NSString *NSWindowDidOrderOffScreenNotification; } } +- (NSSize)window:(NSWindow *)window + willUseFullScreenContentSize:(NSSize)proposedSize +{ + + /* + * We don't need to change the proposed size, but we do need to + * implement this method. Otherwise the full screen window will + * be sized to the screen's visibleFrame, leaving black bands at + * the top and bottom. + */ + + return proposedSize; +} + - (void) windowEnteredFullScreen: (NSNotification *) notification { #ifdef TK_MAC_DEBUG_NOTIFICATIONS @@ -261,14 +275,19 @@ extern NSString *NSWindowDidOrderOffScreenNotification; #define observe(n, s) \ [nc addObserver:self selector:@selector(s) name:(n) object:nil] + observe(NSWindowDidBecomeKeyNotification, windowActivation:); observe(NSWindowDidResignKeyNotification, windowActivation:); observe(NSWindowDidMoveNotification, windowBoundsChanged:); observe(NSWindowDidResizeNotification, windowBoundsChanged:); observe(NSWindowDidDeminiaturizeNotification, windowExpanded:); observe(NSWindowDidMiniaturizeNotification, windowCollapsed:); + +#if !(MAC_OS_X_VERSION_MAX_ALLOWED < 1070) observe(NSWindowDidEnterFullScreenNotification, windowEnteredFullScreen:); observe(NSWindowDidExitFullScreenNotification, windowExitedFullScreen:); +#endif + #ifdef TK_MAC_DEBUG_NOTIFICATIONS observe(NSWindowWillMoveNotification, windowDragStart:); observe(NSWindowWillStartLiveResizeNotification, windowLiveResize:); diff --git a/macosx/tkMacOSXWm.c b/macosx/tkMacOSXWm.c index 9b379c0..29cf893 100644 --- a/macosx/tkMacOSXWm.c +++ b/macosx/tkMacOSXWm.c @@ -388,6 +388,7 @@ static void RemapWindows(TkWindow *winPtr, @implementation TKWindow: NSWindow +#if MAC_OS_X_VERSION_MAX_ALLOWED > 101100 - (void)toggleTabBar:(id)sender { TkWindow *winPtr = TkMacOSXGetTkWindow(self); @@ -398,6 +399,7 @@ static void RemapWindows(TkWindow *winPtr, [super toggleTabBar:sender]; TkMacOSXApplyWindowAttributes(macWin->winPtr, self); } +#endif @end @@ -1270,7 +1272,11 @@ WmSetAttribute( return TCL_ERROR; } if (boolean != ((wmPtr->flags & WM_FULLSCREEN) != 0)) { +#if !(MAC_OS_X_VERSION_MAX_ALLOWED < 1070) [macWindow toggleFullScreen:macWindow]; +#else + TKLog(@"The fullscreen attribute is ignored on this system.."); +#endif } break; case WMATT_MODIFIED: @@ -6357,6 +6363,18 @@ ApplyWindowAttributeFlagChanges( tkCanJoinAllSpacesAttribute | tkMoveToActiveSpaceAttribute)) || initial) { NSWindowCollectionBehavior b = NSWindowCollectionBehaviorDefault; + + /* + * This behavior, which makes the green button expand a window to + * full screen, was included in the default as of OSX 10.13. For + * uniformity we use the new default in all versions of the OS + * where the behavior exists. + */ + +#if !(MAC_OS_X_VERSION_MAX_ALLOWED < 1070) + b |= NSWindowCollectionBehaviorFullScreenPrimary; +#endif + if (newAttributes & tkCanJoinAllSpacesAttribute) { b |= NSWindowCollectionBehaviorCanJoinAllSpaces; } else if (newAttributes & tkMoveToActiveSpaceAttribute) { -- cgit v0.12 From 989bb343ac684fcbcce6a0cc39575db6e63559a0 Mon Sep 17 00:00:00 2001 From: culler Date: Sat, 24 Nov 2018 18:05:46 +0000 Subject: Avoid mouse cursor offset if a tab bar is shown in fullscreen mode. --- macosx/tkMacOSXWm.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/macosx/tkMacOSXWm.c b/macosx/tkMacOSXWm.c index 29cf893..f63128a 100644 --- a/macosx/tkMacOSXWm.c +++ b/macosx/tkMacOSXWm.c @@ -388,7 +388,7 @@ static void RemapWindows(TkWindow *winPtr, @implementation TKWindow: NSWindow -#if MAC_OS_X_VERSION_MAX_ALLOWED > 101100 +#if !(MAC_OS_X_VERSION_MAX_ALLOWED < 101200) - (void)toggleTabBar:(id)sender { TkWindow *winPtr = TkMacOSXGetTkWindow(self); @@ -397,7 +397,9 @@ static void RemapWindows(TkWindow *winPtr, return; } [super toggleTabBar:sender]; - TkMacOSXApplyWindowAttributes(macWin->winPtr, self); + if (([self styleMask] & NSFullScreenWindowMask) == 0) { + TkMacOSXApplyWindowAttributes(macWin->winPtr, self); + } } #endif -- cgit v0.12 From 699bf05287364349ba5d1a4abdbe58128f733645 Mon Sep 17 00:00:00 2001 From: fvogel Date: Sun, 25 Nov 2018 17:21:50 +0000 Subject: Fix spelling error in a variable name (GitHub PR #5, chrstphrchvz) --- library/demos/ttkbut.tcl | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/library/demos/ttkbut.tcl b/library/demos/ttkbut.tcl index 904cd31..ab49cf4 100644 --- a/library/demos/ttkbut.tcl +++ b/library/demos/ttkbut.tcl @@ -21,7 +21,7 @@ ttk::label $w.msg -font $font -wraplength 4i -justify left -text "Ttk is the new pack $w.msg -side top -fill x ## See Code / Dismiss -pack [addSeeDismiss $w.seeDismiss $w {enabled cheese tomato basil oregano happyness}]\ +pack [addSeeDismiss $w.seeDismiss $w {enabled cheese tomato basil oregano happiness}]\ -side bottom -fill x ## Add buttons for setting the theme @@ -69,11 +69,11 @@ pack $w.checks.e $w.checks.sep1 $w.checks.c1 $w.checks.c2 $w.checks.sep2 \ ## Set up the radiobutton group ttk::labelframe $w.radios -text "Radiobuttons" -ttk::radiobutton $w.radios.r1 -text "Great" -variable happyness -value great -ttk::radiobutton $w.radios.r2 -text "Good" -variable happyness -value good -ttk::radiobutton $w.radios.r3 -text "OK" -variable happyness -value ok -ttk::radiobutton $w.radios.r4 -text "Poor" -variable happyness -value poor -ttk::radiobutton $w.radios.r5 -text "Awful" -variable happyness -value awful +ttk::radiobutton $w.radios.r1 -text "Great" -variable happiness -value great +ttk::radiobutton $w.radios.r2 -text "Good" -variable happiness -value good +ttk::radiobutton $w.radios.r3 -text "OK" -variable happiness -value ok +ttk::radiobutton $w.radios.r4 -text "Poor" -variable happiness -value poor +ttk::radiobutton $w.radios.r5 -text "Awful" -variable happiness -value awful pack $w.radios.r1 $w.radios.r2 $w.radios.r3 $w.radios.r4 $w.radios.r5 \ -fill x -padx 3 -pady 2 -- cgit v0.12