diff options
author | jan.nijtmans <nijtmans@users.sourceforge.net> | 2019-01-13 14:51:58 (GMT) |
---|---|---|
committer | jan.nijtmans <nijtmans@users.sourceforge.net> | 2019-01-13 14:51:58 (GMT) |
commit | 40b76dbd4f4479294a9cd461da0400e31734ac2b (patch) | |
tree | 0b9c811cef1183d76e05a6ac238b5652de5bb12d | |
parent | ad423a347178d6279b112f7031e683c7e15d798a (diff) | |
parent | 75aab96f3ddb340be5aecbb880f1af2a07d9ec25 (diff) | |
download | tk-40b76dbd4f4479294a9cd461da0400e31734ac2b.zip tk-40b76dbd4f4479294a9cd461da0400e31734ac2b.tar.gz tk-40b76dbd4f4479294a9cd461da0400e31734ac2b.tar.bz2 |
Merge 8.7
102 files changed, 1300 insertions, 757 deletions
diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..f2095d0 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,84 @@ +sudo: required +language: c +addons: + apt: + packages: + - tcl-dev + - libx11-dev +matrix: + include: + - os: linux + dist: trusty + compiler: clang + env: + - BUILD_DIR=unix + - os: linux + dist: trusty + compiler: clang + env: + - CFGOPT=--disable-shared + - BUILD_DIR=unix + - os: linux + dist: trusty + compiler: gcc + env: + - BUILD_DIR=unix + - os: linux + dist: trusty + compiler: gcc + env: + - CFGOPT=--disable-shared + - BUILD_DIR=unix + - os: linux + dist: trusty + compiler: gcc-4.9 + addons: + apt: + sources: + - ubuntu-toolchain-r-test + packages: + - g++-4.9 + env: + - BUILD_DIR=unix + - os: linux + dist: trusty + compiler: gcc-5 + addons: + apt: + sources: + - ubuntu-toolchain-r-test + packages: + - g++-5 + env: + - BUILD_DIR=unix + - os: linux + dist: trusty + compiler: gcc-6 + addons: + apt: + sources: + - ubuntu-toolchain-r-test + packages: + - g++-6 + env: + - BUILD_DIR=unix + - os: linux + dist: trusty + compiler: gcc-7 + addons: + apt: + sources: + - ubuntu-toolchain-r-test + packages: + - g++-7 + env: + - BUILD_DIR=unix +before_install: + - export ERROR_ON_FAILURES=1 + - cd ${BUILD_DIR} +install: + - test -n "$NO_DIRECT_CONFIGURE" || ./configure ${CFGOPT} +script: + - make + # The styles=develop avoids some weird problems on OSX + #- test -n "$NO_DIRECT_TEST" || make test styles=develop @@ -61,6 +61,16 @@ The \fBfocus\fR command is still used to determine which window in the application receives the keyboard events. The keyboard grab is released when the grab is released. .PP +On macOS a global grab affects all windows created by one Tk process. +No window in that process other than the grab window can even be +focused, hence no other window receives key or mouse events. A local +grab on macOS affects all windows created by one Tcl interpreter. It +is possible to focus any window belonging to the Tk process during a +local grab but the grab window is the only window created by its +interpreter which receives key or mouse events. Windows belonging to the +same process but created by different interpreters continue to receive +key and mouse events normally. +.PP Grabs apply to particular displays. If an application has windows on multiple displays then it can establish a separate grab on each display. @@ -267,7 +267,7 @@ toplevels are automatically appended after all the Tk-defined items and a separator. The Window menu on the Mac also allows toggling the window into a fullscreen state, and managing a tabbed window interface (multiple windows grouped into a single window) if supported by that -version of the operating system. +version of the operating system. .PP When Tk sees a .menubar.help menu on the Macintosh, the menu's contents are appended to the standard Help menu of the user's menubar whenever diff --git a/doc/winfo.n b/doc/winfo.n index bff4973..fed5c39 100644 --- a/doc/winfo.n +++ b/doc/winfo.n @@ -73,6 +73,9 @@ to the screen containing \fIwindow\fR; otherwise they refer to the screen of the application's main window. If no window in this application contains the point then an empty string is returned. +An empty string is also returned if the point lies in the title bar +or border of its highest containing toplevel in this application. +(Note that with some window managers the borders may be invisible.) In selecting the containing window, children are given higher priority than parents and among siblings the highest one in the stacking order is chosen. diff --git a/generic/tk3d.c b/generic/tk3d.c index 87ddf76..92a7803 100644 --- a/generic/tk3d.c +++ b/generic/tk3d.c @@ -236,9 +236,9 @@ Tk_Get3DBorder( borderPtr->darkColorPtr = NULL; borderPtr->lightColorPtr = NULL; borderPtr->shadow = None; - borderPtr->bgGC = None; - borderPtr->darkGC = None; - borderPtr->lightGC = None; + borderPtr->bgGC = NULL; + borderPtr->darkGC = NULL; + borderPtr->lightGC = NULL; borderPtr->hashPtr = hashPtr; borderPtr->nextPtr = existingBorderPtr; Tcl_SetHashValue(hashPtr, borderPtr); @@ -374,7 +374,7 @@ Tk_3DBorderGC( { TkBorder * borderPtr = (TkBorder *) border; - if ((borderPtr->lightGC == None) && (which != TK_3D_FLAT_GC)) { + if ((borderPtr->lightGC == NULL) && (which != TK_3D_FLAT_GC)) { TkpGetShadows(borderPtr, tkwin); } if (which == TK_3D_FLAT_GC) { @@ -391,7 +391,7 @@ Tk_3DBorderGC( * compilers happy. */ - return (GC) None; + return NULL; } /* @@ -439,13 +439,13 @@ Tk_Free3DBorder( if (borderPtr->shadow != None) { Tk_FreeBitmap(display, borderPtr->shadow); } - if (borderPtr->bgGC != None) { + if (borderPtr->bgGC != NULL) { Tk_FreeGC(display, borderPtr->bgGC); } - if (borderPtr->darkGC != None) { + if (borderPtr->darkGC != NULL) { Tk_FreeGC(display, borderPtr->darkGC); } - if (borderPtr->lightGC != None) { + if (borderPtr->lightGC != NULL) { Tk_FreeGC(display, borderPtr->lightGC); } if (prevPtr == borderPtr) { @@ -765,7 +765,7 @@ Tk_Draw3DPolygon( int i, lightOnLeft, dx, dy, parallel, pointsSeen; Display *display = Tk_Display(tkwin); - if (borderPtr->lightGC == None) { + if (borderPtr->lightGC == NULL) { TkpGetShadows(borderPtr, tkwin); } @@ -1380,9 +1380,9 @@ TkDebugBorder( Tcl_Obj *objPtr = Tcl_NewObj(); Tcl_ListObjAppendElement(NULL, objPtr, - Tcl_NewIntObj(borderPtr->resourceRefCount)); + Tcl_NewWideIntObj(borderPtr->resourceRefCount)); Tcl_ListObjAppendElement(NULL, objPtr, - Tcl_NewIntObj(borderPtr->objRefCount)); + Tcl_NewWideIntObj(borderPtr->objRefCount)); Tcl_ListObjAppendElement(NULL, resultPtr, objPtr); } } diff --git a/generic/tk3d.h b/generic/tk3d.h index f574de7..d36b95e 100644 --- a/generic/tk3d.h +++ b/generic/tk3d.h @@ -54,10 +54,10 @@ typedef struct TkBorder { GC bgGC; /* Used (if necessary) to draw areas in the * background color. */ GC darkGC; /* Used to draw darker parts of the border. - * None means the shadow colors haven't been + * NULL means the shadow colors haven't been * allocated yet.*/ GC lightGC; /* Used to draw lighter parts of the border. - * None means the shadow colors haven't been + * NULL means the shadow colors haven't been * allocated yet. */ Tcl_HashEntry *hashPtr; /* Entry in borderTable (needed in order to * delete structure). */ diff --git a/generic/tkBind.c b/generic/tkBind.c index 469725e..b06fbc9 100644 --- a/generic/tkBind.c +++ b/generic/tkBind.c @@ -3587,7 +3587,7 @@ DoWarp( if (dispPtr->warpWindow) { Tcl_Release(dispPtr->warpWindow); - dispPtr->warpWindow = None; + dispPtr->warpWindow = NULL; } dispPtr->flags &= ~TK_DISPLAY_IN_WARP; } diff --git a/generic/tkBitmap.c b/generic/tkBitmap.c index a2730d7..0ab922b 100644 --- a/generic/tkBitmap.c +++ b/generic/tkBitmap.c @@ -1157,9 +1157,9 @@ TkDebugBitmap( for ( ; (bitmapPtr != NULL); bitmapPtr = bitmapPtr->nextPtr) { objPtr = Tcl_NewObj(); Tcl_ListObjAppendElement(NULL, objPtr, - Tcl_NewIntObj(bitmapPtr->resourceRefCount)); + Tcl_NewWideIntObj(bitmapPtr->resourceRefCount)); Tcl_ListObjAppendElement(NULL, objPtr, - Tcl_NewIntObj(bitmapPtr->objRefCount)); + Tcl_NewWideIntObj(bitmapPtr->objRefCount)); Tcl_ListObjAppendElement(NULL, resultPtr, objPtr); } } diff --git a/generic/tkBusy.c b/generic/tkBusy.c index 8991462..1846a94 100644 --- a/generic/tkBusy.c +++ b/generic/tkBusy.c @@ -519,7 +519,8 @@ CreateBusy( Tk_Window tkRef) /* Window hosting the busy window */ { Busy *busyPtr; - int length, x, y; + size_t length; + int x, y; const char *fmt; char *name; Tk_Window tkBusy, tkChild, tkParent; @@ -568,7 +569,7 @@ CreateBusy( busyPtr->height = Tk_Height(tkRef); busyPtr->x = Tk_X(tkRef); busyPtr->y = Tk_Y(tkRef); - busyPtr->cursor = None; + busyPtr->cursor = NULL; Tk_SetClass(tkBusy, "Busy"); busyPtr->optionTable = Tk_CreateOptionTable(interp, busyOptionSpecs); if (Tk_InitOptions(interp, busyPtr, busyPtr->optionTable, @@ -598,7 +599,7 @@ CreateBusy( */ Tk_ManageGeometry(tkBusy, &busyMgrInfo, busyPtr); - if (busyPtr->cursor != None) { + if (busyPtr->cursor != NULL) { Tk_DefineCursor(tkBusy, busyPtr->cursor); } @@ -643,7 +644,7 @@ ConfigureBusy( return TCL_ERROR; } if (busyPtr->cursor != oldCursor) { - if (busyPtr->cursor == None) { + if (busyPtr->cursor == NULL) { Tk_UndefineCursor(busyPtr->tkBusy); } else { Tk_DefineCursor(busyPtr->tkBusy, busyPtr->cursor); diff --git a/generic/tkButton.c b/generic/tkButton.c index be8c6c4..9755861 100644 --- a/generic/tkButton.c +++ b/generic/tkButton.c @@ -710,12 +710,12 @@ ButtonCreate( butPtr->normalFg = NULL; butPtr->activeFg = NULL; butPtr->disabledFg = NULL; - butPtr->normalTextGC = None; - butPtr->activeTextGC = None; - butPtr->disabledGC = None; - butPtr->stippleGC = None; + butPtr->normalTextGC = NULL; + butPtr->activeTextGC = NULL; + butPtr->disabledGC = NULL; + butPtr->stippleGC = NULL; butPtr->gray = None; - butPtr->copyGC = None; + butPtr->copyGC = NULL; butPtr->widthPtr = NULL; butPtr->width = 0; butPtr->heightPtr = NULL; @@ -740,7 +740,7 @@ ButtonCreate( butPtr->onValuePtr = NULL; butPtr->offValuePtr = NULL; butPtr->tristateValuePtr = NULL; - butPtr->cursor = None; + butPtr->cursor = NULL; butPtr->takeFocusPtr = NULL; butPtr->commandPtr = NULL; butPtr->flags = 0; @@ -981,22 +981,22 @@ DestroyButton( if (butPtr->tristateImage != NULL) { Tk_FreeImage(butPtr->tristateImage); } - if (butPtr->normalTextGC != None) { + if (butPtr->normalTextGC != NULL) { Tk_FreeGC(butPtr->display, butPtr->normalTextGC); } - if (butPtr->activeTextGC != None) { + if (butPtr->activeTextGC != NULL) { Tk_FreeGC(butPtr->display, butPtr->activeTextGC); } - if (butPtr->disabledGC != None) { + if (butPtr->disabledGC != NULL) { Tk_FreeGC(butPtr->display, butPtr->disabledGC); } - if (butPtr->stippleGC != None) { + if (butPtr->stippleGC != NULL) { Tk_FreeGC(butPtr->display, butPtr->stippleGC); } if (butPtr->gray != None) { Tk_FreeBitmap(butPtr->display, butPtr->gray); } - if (butPtr->copyGC != None) { + if (butPtr->copyGC != NULL) { Tk_FreeGC(butPtr->display, butPtr->copyGC); } if (butPtr->textLayout != NULL) { @@ -1367,7 +1367,7 @@ TkButtonWorldChanged( gcValues.graphics_exposures = False; mask = GCForeground | GCBackground | GCFont | GCGraphicsExposures; newGC = Tk_GetGC(butPtr->tkwin, mask, &gcValues); - if (butPtr->normalTextGC != None) { + if (butPtr->normalTextGC != NULL) { Tk_FreeGC(butPtr->display, butPtr->normalTextGC); } butPtr->normalTextGC = newGC; @@ -1377,7 +1377,7 @@ TkButtonWorldChanged( gcValues.background = Tk_3DBorderColor(butPtr->activeBorder)->pixel; mask = GCForeground | GCBackground | GCFont; newGC = Tk_GetGC(butPtr->tkwin, mask, &gcValues); - if (butPtr->activeTextGC != None) { + if (butPtr->activeTextGC != NULL) { Tk_FreeGC(butPtr->display, butPtr->activeTextGC); } butPtr->activeTextGC = newGC; @@ -1389,7 +1389,7 @@ TkButtonWorldChanged( * Create the GC that can be used for stippling */ - if (butPtr->stippleGC == None) { + if (butPtr->stippleGC == NULL) { gcValues.foreground = gcValues.background; mask = GCForeground; if (butPtr->gray == None) { @@ -1415,12 +1415,12 @@ TkButtonWorldChanged( gcValues.foreground = gcValues.background; } newGC = Tk_GetGC(butPtr->tkwin, mask, &gcValues); - if (butPtr->disabledGC != None) { + if (butPtr->disabledGC != NULL) { Tk_FreeGC(butPtr->display, butPtr->disabledGC); } butPtr->disabledGC = newGC; - if (butPtr->copyGC == None) { + if (butPtr->copyGC == NULL) { butPtr->copyGC = Tk_GetGC(butPtr->tkwin, 0, &gcValues); } diff --git a/generic/tkButton.h b/generic/tkButton.h index 7ed464f..7e04fb9 100644 --- a/generic/tkButton.h +++ b/generic/tkButton.h @@ -235,7 +235,7 @@ typedef struct { * Miscellaneous information: */ - Tk_Cursor cursor; /* Value of -cursor option: if not None, + Tk_Cursor cursor; /* Value of -cursor option: if not NULL, * specifies current cursor for window. */ Tcl_Obj *takeFocusPtr; /* Value of -takefocus option; not used in the * C code, but used by keyboard traversal diff --git a/generic/tkCanvArc.c b/generic/tkCanvArc.c index 880d313..d9c2eca 100644 --- a/generic/tkCanvArc.c +++ b/generic/tkCanvArc.c @@ -299,7 +299,7 @@ CreateArc( arcPtr->activeFillStipple = None; arcPtr->disabledFillStipple = None; arcPtr->style = PIESLICE_STYLE; - arcPtr->fillGC = None; + arcPtr->fillGC = NULL; arcPtr->height = 0; /* @@ -508,9 +508,9 @@ ConfigureArc( mask |= GCCapStyle; newGC = Tk_GetGC(tkwin, mask, &gcValues); } else { - newGC = None; + newGC = NULL; } - if (arcPtr->outline.gc != None) { + if (arcPtr->outline.gc != NULL) { Tk_FreeGC(Tk_Display(tkwin), arcPtr->outline.gc); } arcPtr->outline.gc = newGC; @@ -542,9 +542,9 @@ ConfigureArc( } if (arcPtr->style == ARC_STYLE) { - newGC = None; + newGC = NULL; } else if (color == NULL) { - newGC = None; + newGC = NULL; } else { gcValues.foreground = color->pixel; if (arcPtr->style == CHORD_STYLE) { @@ -560,7 +560,7 @@ ConfigureArc( } newGC = Tk_GetGC(tkwin, mask, &gcValues); } - if (arcPtr->fillGC != None) { + if (arcPtr->fillGC != NULL) { Tk_FreeGC(Tk_Display(tkwin), arcPtr->fillGC); } arcPtr->fillGC = newGC; @@ -717,7 +717,7 @@ DeleteArc( if (arcPtr->disabledFillStipple != None) { Tk_FreeBitmap(display, arcPtr->disabledFillStipple); } - if (arcPtr->fillGC != None) { + if (arcPtr->fillGC != NULL) { Tk_FreeGC(display, arcPtr->fillGC); } } @@ -848,7 +848,7 @@ ComputeArcBbox( * drawn) and add one extra pixel just for safety. */ - if (arcPtr->outline.gc == None) { + if (arcPtr->outline.gc == NULL) { tmp = 1; } else { tmp = (int) ((width + 1.0)/2.0 + 1); @@ -947,7 +947,7 @@ DisplayArc( * window servers to crash and should be a no-op anyway. */ - if ((arcPtr->fillGC != None) && (extent != 0)) { + if ((arcPtr->fillGC != NULL) && (extent != 0)) { if (stipple != None) { int w = 0; int h = 0; @@ -981,7 +981,7 @@ DisplayArc( XSetTSOrigin(display, arcPtr->fillGC, 0, 0); } } - if (arcPtr->outline.gc != None) { + if (arcPtr->outline.gc != NULL) { Tk_ChangeOutlineGC(canvas, itemPtr, &(arcPtr->outline)); if (extent != 0) { @@ -1019,13 +1019,13 @@ DisplayArc( } else { if (arcPtr->style == CHORD_STYLE) { TkFillPolygon(canvas, arcPtr->outlinePtr, CHORD_OUTLINE_PTS, - display, drawable, arcPtr->outline.gc, None); + display, drawable, arcPtr->outline.gc, NULL); } else if (arcPtr->style == PIESLICE_STYLE) { TkFillPolygon(canvas, arcPtr->outlinePtr, PIE_OUTLINE1_PTS, - display, drawable, arcPtr->outline.gc, None); + display, drawable, arcPtr->outline.gc, NULL); TkFillPolygon(canvas, arcPtr->outlinePtr + 2*PIE_OUTLINE1_PTS, PIE_OUTLINE2_PTS, display, drawable, - arcPtr->outline.gc, None); + arcPtr->outline.gc, NULL); } } @@ -1131,12 +1131,12 @@ ArcToPoint( return dist; } - if ((arcPtr->fillGC != None) || (arcPtr->outline.gc == None)) { + if ((arcPtr->fillGC != NULL) || (arcPtr->outline.gc == NULL)) { filled = 1; } else { filled = 0; } - if (arcPtr->outline.gc == None) { + if (arcPtr->outline.gc == NULL) { width = 0.0; } @@ -1258,12 +1258,12 @@ ArcToArea( } } - if ((arcPtr->fillGC != None) || (arcPtr->outline.gc == None)) { + if ((arcPtr->fillGC != NULL) || (arcPtr->outline.gc == NULL)) { filled = 1; } else { filled = 0; } - if (arcPtr->outline.gc == None) { + if (arcPtr->outline.gc == NULL) { width = 0.0; } @@ -1997,7 +1997,7 @@ ArcToPostscript( * arc. */ - if (arcPtr->fillGC != None) { + if (arcPtr->fillGC != NULL) { Tcl_AppendPrintfToObj(psObj, "matrix currentmatrix\n" "%.15g %.15g translate %.15g %.15g scale\n", @@ -2026,7 +2026,7 @@ ArcToPostscript( } Tcl_AppendObjToObj(psObj, Tcl_GetObjResult(interp)); - if (arcPtr->outline.gc != None) { + if (arcPtr->outline.gc != NULL) { Tcl_AppendToObj(psObj, "grestore gsave\n", -1); } } else { @@ -2038,7 +2038,7 @@ ArcToPostscript( * If there's an outline for the arc, draw it. */ - if (arcPtr->outline.gc != None) { + if (arcPtr->outline.gc != NULL) { Tcl_AppendPrintfToObj(psObj, "matrix currentmatrix\n" "%.15g %.15g translate %.15g %.15g scale\n", diff --git a/generic/tkCanvBmap.c b/generic/tkCanvBmap.c index 8e3a410..1fbfddf 100644 --- a/generic/tkCanvBmap.c +++ b/generic/tkCanvBmap.c @@ -189,7 +189,7 @@ TkcCreateBitmap( bmapPtr->bgColor = NULL; bmapPtr->activeBgColor = NULL; bmapPtr->disabledBgColor = NULL; - bmapPtr->gc = None; + bmapPtr->gc = NULL; /* * Process the arguments to fill in the item record. Only 1 (list) or 2 (x @@ -372,7 +372,7 @@ ConfigureBitmap( } if (bitmap == None) { - newGC = None; + newGC = NULL; } else { gcValues.foreground = fgColor->pixel; mask = GCForeground; @@ -385,7 +385,7 @@ ConfigureBitmap( } newGC = Tk_GetGC(tkwin, mask, &gcValues); } - if (bmapPtr->gc != None) { + if (bmapPtr->gc != NULL) { Tk_FreeGC(Tk_Display(tkwin), bmapPtr->gc); } bmapPtr->gc = newGC; diff --git a/generic/tkCanvImg.c b/generic/tkCanvImg.c index 0d4aa9d..76b3689 100644 --- a/generic/tkCanvImg.c +++ b/generic/tkCanvImg.c @@ -449,7 +449,7 @@ ComputeImageBbox( x = (int) (imgPtr->x + ((imgPtr->x >= 0) ? 0.5 : - 0.5)); y = (int) (imgPtr->y + ((imgPtr->y >= 0) ? 0.5 : - 0.5)); - if ((state == TK_STATE_HIDDEN) || (image == None)) { + if ((state == TK_STATE_HIDDEN) || (image == NULL)) { imgPtr->header.x1 = imgPtr->header.x2 = x; imgPtr->header.y1 = imgPtr->header.y2 = y; return; diff --git a/generic/tkCanvLine.c b/generic/tkCanvLine.c index e35cbd9..dd0a6cb 100644 --- a/generic/tkCanvLine.c +++ b/generic/tkCanvLine.c @@ -296,7 +296,7 @@ CreateLine( linePtr->coordPtr = NULL; linePtr->capStyle = CapButt; linePtr->joinStyle = JoinRound; - linePtr->arrowGC = None; + linePtr->arrowGC = NULL; linePtr->arrow = ARROWS_NONE; linePtr->arrowShapeA = (float)8.0; linePtr->arrowShapeB = (float)10.0; @@ -521,12 +521,12 @@ ConfigureLine( #endif arrowGC = Tk_GetGC(tkwin, mask, &gcValues); } else { - newGC = arrowGC = None; + newGC = arrowGC = NULL; } - if (linePtr->outline.gc != None) { + if (linePtr->outline.gc != NULL) { Tk_FreeGC(Tk_Display(tkwin), linePtr->outline.gc); } - if (linePtr->arrowGC != None) { + if (linePtr->arrowGC != NULL) { Tk_FreeGC(Tk_Display(tkwin), linePtr->arrowGC); } linePtr->outline.gc = newGC; @@ -611,7 +611,7 @@ DeleteLine( if (linePtr->coordPtr != NULL) { ckfree(linePtr->coordPtr); } - if (linePtr->arrowGC != None) { + if (linePtr->arrowGC != NULL) { Tk_FreeGC(display, linePtr->arrowGC); } if (linePtr->firstArrowPtr != NULL) { @@ -840,7 +840,7 @@ DisplayLine( int numPoints; Tk_State state = itemPtr->state; - if ((!linePtr->numPoints) || (linePtr->outline.gc == None)) { + if (!linePtr->numPoints || (linePtr->outline.gc == NULL)) { return; } diff --git a/generic/tkCanvPoly.c b/generic/tkCanvPoly.c index 5241bd8..f10aae7 100644 --- a/generic/tkCanvPoly.c +++ b/generic/tkCanvPoly.c @@ -273,7 +273,7 @@ CreatePolygon( polyPtr->fillStipple = None; polyPtr->activeFillStipple = None; polyPtr->disabledFillStipple = None; - polyPtr->fillGC = None; + polyPtr->fillGC = NULL; polyPtr->smooth = NULL; polyPtr->splineSteps = 12; polyPtr->autoClosed = 0; @@ -478,9 +478,9 @@ ConfigurePolygon( mask |= GCCapStyle|GCJoinStyle; newGC = Tk_GetGC(tkwin, mask, &gcValues); } else { - newGC = None; + newGC = NULL; } - if (polyPtr->outline.gc != None) { + if (polyPtr->outline.gc != NULL) { Tk_FreeGC(Tk_Display(tkwin), polyPtr->outline.gc); } polyPtr->outline.gc = newGC; @@ -504,7 +504,7 @@ ConfigurePolygon( } if (color == NULL) { - newGC = None; + newGC = NULL; } else { gcValues.foreground = color->pixel; mask = GCForeground; @@ -518,13 +518,13 @@ ConfigurePolygon( * Mac OS X CG drawing needs access to the outline linewidth * even for fills (as linewidth controls antialiasing). */ - gcValues.line_width = polyPtr->outline.gc != None ? + gcValues.line_width = polyPtr->outline.gc != NULL ? polyPtr->outline.gc->line_width : 0; mask |= GCLineWidth; #endif newGC = Tk_GetGC(tkwin, mask, &gcValues); } - if (polyPtr->fillGC != None) { + if (polyPtr->fillGC != NULL) { Tk_FreeGC(Tk_Display(tkwin), polyPtr->fillGC); } polyPtr->fillGC = newGC; @@ -590,7 +590,7 @@ DeletePolygon( if (polyPtr->disabledFillStipple != None) { Tk_FreeBitmap(display, polyPtr->disabledFillStipple); } - if (polyPtr->fillGC != None) { + if (polyPtr->fillGC != NULL) { Tk_FreeGC(display, polyPtr->fillGC); } } @@ -694,7 +694,7 @@ ComputePolygonBbox( } } - if (polyPtr->outline.gc != None) { + if (polyPtr->outline.gc != NULL) { tsoffset = &polyPtr->outline.tsoffset; if (tsoffset) { if (tsoffset->flags & TK_OFFSET_INDEX) { @@ -836,11 +836,11 @@ TkFillPolygon( * allocated. */ - if (gc != None && numPoints > 3) { + if (gc != NULL && numPoints > 3) { XFillPolygon(display, drawable, gc, pointPtr, numPoints, Complex, CoordModeOrigin); } - if (outlineGC != None) { + if (outlineGC != NULL) { XDrawLines(display, drawable, outlineGC, pointPtr, numPoints, CoordModeOrigin); } @@ -881,9 +881,9 @@ DisplayPolygon( Pixmap stipple = polyPtr->fillStipple; double linewidth = polyPtr->outline.width; - if (((polyPtr->fillGC == None) && (polyPtr->outline.gc == None)) || + if (((polyPtr->fillGC == NULL) && (polyPtr->outline.gc == NULL)) || (polyPtr->numPoints < 1) || - (polyPtr->numPoints < 3 && polyPtr->outline.gc == None)) { + (polyPtr->numPoints < 3 && polyPtr->outline.gc == NULL)) { return; } @@ -911,7 +911,7 @@ DisplayPolygon( * reset the offset when done, since the GC is supposed to be read-only. */ - if ((stipple != None) && (polyPtr->fillGC != None)) { + if ((stipple != None) && (polyPtr->fillGC != NULL)) { Tk_TSOffset *tsoffset = &polyPtr->tsoffset; int w = 0, h = 0; int flags = tsoffset->flags; @@ -973,11 +973,11 @@ DisplayPolygon( } numPoints = polyPtr->smooth->coordProc(canvas, polyPtr->coordPtr, polyPtr->numPoints, polyPtr->splineSteps, pointPtr, NULL); - if (polyPtr->fillGC != None) { + if (polyPtr->fillGC != NULL) { XFillPolygon(display, drawable, polyPtr->fillGC, pointPtr, numPoints, Complex, CoordModeOrigin); } - if (polyPtr->outline.gc != None) { + if (polyPtr->outline.gc != NULL) { XDrawLines(display, drawable, polyPtr->outline.gc, pointPtr, numPoints, CoordModeOrigin); } @@ -986,7 +986,7 @@ DisplayPolygon( } } Tk_ResetOutlineGC(canvas, itemPtr, &polyPtr->outline); - if ((stipple != None) && (polyPtr->fillGC != None)) { + if ((stipple != None) && (polyPtr->fillGC != NULL)) { XSetTSOrigin(display, polyPtr->fillGC, 0, 0); } } @@ -1299,7 +1299,7 @@ PolygonToPoint( if (bestDist <= 0.0) { goto donepoint; } - if ((polyPtr->outline.gc != None) && (polyPtr->joinStyle == JoinRound)) { + if ((polyPtr->outline.gc != NULL) && (polyPtr->joinStyle == JoinRound)) { dist = bestDist - radius; if (dist <= 0.0) { bestDist = 0.0; @@ -1309,7 +1309,7 @@ PolygonToPoint( } } - if ((polyPtr->outline.gc == None) || (width <= 1)) { + if ((polyPtr->outline.gc == NULL) || (width <= 1)) { goto donepoint; } @@ -1515,7 +1515,7 @@ PolygonToArea( goto donearea; } - if (polyPtr->outline.gc == None) { + if (polyPtr->outline.gc == NULL) { goto donearea; } diff --git a/generic/tkCanvText.c b/generic/tkCanvText.c index b4fa656..cfffc62 100644 --- a/generic/tkCanvText.c +++ b/generic/tkCanvText.c @@ -269,9 +269,9 @@ CreateText( textPtr->textLayout = NULL; textPtr->actualWidth = 0; textPtr->drawOrigin[0] = textPtr->drawOrigin[1] = 0.0; - textPtr->gc = None; - textPtr->selTextGC = None; - textPtr->cursorOffGC = None; + textPtr->gc = NULL; + textPtr->selTextGC = NULL; + textPtr->cursorOffGC = NULL; textPtr->sine = 0.0; textPtr->cosine = 1.0; @@ -447,7 +447,7 @@ ConfigureText( } } - newGC = newSelGC = None; + newGC = newSelGC = NULL; if (textPtr->tkfont != NULL) { gcValues.font = Tk_FontId(textPtr->tkfont); mask = GCFont; @@ -472,11 +472,11 @@ ConfigureText( } newSelGC = Tk_GetGC(tkwin, mask|GCForeground, &gcValues); } - if (textPtr->gc != None) { + if (textPtr->gc != NULL) { Tk_FreeGC(Tk_Display(tkwin), textPtr->gc); } textPtr->gc = newGC; - if (textPtr->selTextGC != None) { + if (textPtr->selTextGC != NULL) { Tk_FreeGC(Tk_Display(tkwin), textPtr->selTextGC); } textPtr->selTextGC = newSelGC; @@ -491,9 +491,9 @@ ConfigureText( } newGC = Tk_GetGC(tkwin, GCForeground, &gcValues); } else { - newGC = None; + newGC = NULL; } - if (textPtr->cursorOffGC != None) { + if (textPtr->cursorOffGC != NULL) { Tk_FreeGC(Tk_Display(tkwin), textPtr->cursorOffGC); } textPtr->cursorOffGC = newGC; @@ -592,13 +592,13 @@ DeleteText( } Tk_FreeTextLayout(textPtr->textLayout); - if (textPtr->gc != None) { + if (textPtr->gc != NULL) { Tk_FreeGC(display, textPtr->gc); } - if (textPtr->selTextGC != None) { + if (textPtr->selTextGC != NULL) { Tk_FreeGC(display, textPtr->selTextGC); } - if (textPtr->cursorOffGC != None) { + if (textPtr->cursorOffGC != NULL) { Tk_FreeGC(display, textPtr->cursorOffGC); } } @@ -820,7 +820,7 @@ DisplayCanvText( } } - if (textPtr->gc == None) { + if (textPtr->gc == NULL) { return; } @@ -932,7 +932,7 @@ DisplayCanvText( Tk_Fill3DPolygon(Tk_CanvasTkwin(canvas), drawable, textInfoPtr->insertBorder, points, 4, textInfoPtr->insertBorderWidth, TK_RELIEF_RAISED); - } else if (textPtr->cursorOffGC != None) { + } else if (textPtr->cursorOffGC != NULL) { /* * Redraw the background over the area of the cursor, even * though the cursor is turned off. This guarantees that the diff --git a/generic/tkCanvUtil.c b/generic/tkCanvUtil.c index 09ce98c..6ce671d 100644 --- a/generic/tkCanvUtil.c +++ b/generic/tkCanvUtil.c @@ -961,7 +961,7 @@ void Tk_CreateOutline( Tk_Outline *outline) /* Outline structure to be filled in. */ { - outline->gc = None; + outline->gc = NULL; outline->width = 1.0; outline->activeWidth = 0.0; outline->disabledWidth = 0.0; @@ -1002,7 +1002,7 @@ Tk_DeleteOutline( Display *display, /* Display containing window. */ Tk_Outline *outline) { - if (outline->gc != None) { + if (outline->gc != NULL) { Tk_FreeGC(display, outline->gc); } if ((unsigned) ABS(outline->dash.number) > sizeof(char *)) { diff --git a/generic/tkCanvas.c b/generic/tkCanvas.c index c0b5dce..01f2981 100644 --- a/generic/tkCanvas.c +++ b/generic/tkCanvas.c @@ -625,7 +625,7 @@ Tk_CanvasObjCmd( canvasPtr->highlightBgColorPtr = NULL; canvasPtr->highlightColorPtr = NULL; canvasPtr->inset = 0; - canvasPtr->pixmapGC = None; + canvasPtr->pixmapGC = NULL; canvasPtr->width = None; canvasPtr->height = None; canvasPtr->confine = 0; @@ -671,7 +671,7 @@ Tk_CanvasObjCmd( canvasPtr->scanYOrigin = 0; canvasPtr->hotPtr = NULL; canvasPtr->hotPrevPtr = NULL; - canvasPtr->cursor = None; + canvasPtr->cursor = NULL; canvasPtr->takeFocus = NULL; canvasPtr->pixelsPerMM = WidthOfScreen(Tk_Screen(newWin)); canvasPtr->pixelsPerMM /= WidthMMOfScreen(Tk_Screen(newWin)); @@ -2135,7 +2135,7 @@ DestroyCanvas( */ Tcl_DeleteHashTable(&canvasPtr->idTable); - if (canvasPtr->pixmapGC != None) { + if (canvasPtr->pixmapGC != NULL) { Tk_FreeGC(canvasPtr->display, canvasPtr->pixmapGC); } expr = canvasPtr->bindTagExprs; @@ -2209,7 +2209,7 @@ ConfigureCanvas( gcValues.foreground = Tk_3DBorderColor(canvasPtr->bgBorder)->pixel; newGC = Tk_GetGC(canvasPtr->tkwin, GCFunction|GCGraphicsExposures|GCForeground, &gcValues); - if (canvasPtr->pixmapGC != None) { + if (canvasPtr->pixmapGC != NULL) { Tk_FreeGC(canvasPtr->display, canvasPtr->pixmapGC); } canvasPtr->pixmapGC = newGC; diff --git a/generic/tkCanvas.h b/generic/tkCanvas.h index b8b1b46..e2221a8 100644 --- a/generic/tkCanvas.h +++ b/generic/tkCanvas.h @@ -206,7 +206,7 @@ typedef struct TkCanvas { * Miscellaneous information: */ - Tk_Cursor cursor; /* Current cursor for window, or None. */ + Tk_Cursor cursor; /* Current cursor for window, or NULL. */ char *takeFocus; /* Value of -takefocus option; not used in the * C code, but used by keyboard traversal * scripts. Malloc'ed, but may be NULL. */ diff --git a/generic/tkCmds.c b/generic/tkCmds.c index f0c489a..cefd5fc 100644 --- a/generic/tkCmds.c +++ b/generic/tkCmds.c @@ -942,11 +942,11 @@ InactiveCmd( return TCL_ERROR; } if (objc - skip == 1) { - long inactive; + Tcl_WideInt inactive; inactive = (Tcl_IsSafe(interp) ? -1 : Tk_GetUserInactiveTime(Tk_Display(tkwin))); - Tcl_SetObjResult(interp, Tcl_NewLongObj(inactive)); + Tcl_SetObjResult(interp, Tcl_NewWideIntObj(inactive)); } else if (objc - skip == 2) { const char *string; @@ -1579,11 +1579,11 @@ Tk_WinfoObjCmd( objv += skip; string = Tcl_GetString(objv[2]); Tcl_SetObjResult(interp, - Tcl_NewLongObj((long) Tk_InternAtom(tkwin, string))); + Tcl_NewWideIntObj(Tk_InternAtom(tkwin, string))); break; case WIN_ATOMNAME: { const char *name; - long id; + Tcl_WideInt id; skip = TkGetDisplayOf(interp, objc - 2, objv + 2, &tkwin); if (skip < 0) { @@ -1594,7 +1594,7 @@ Tk_WinfoObjCmd( return TCL_ERROR; } objv += skip; - if (Tcl_GetLongFromObj(interp, objv[2], &id) != TCL_OK) { + if (Tcl_GetWideIntFromObj(interp, objv[2], &id) != TCL_OK) { return TCL_ERROR; } name = Tk_GetAtomName(tkwin, (Atom) id); diff --git a/generic/tkColor.c b/generic/tkColor.c index 9d5e157..3a82545 100644 --- a/generic/tkColor.c +++ b/generic/tkColor.c @@ -245,7 +245,7 @@ Tk_GetColor( */ tkColPtr->magic = COLOR_MAGIC; - tkColPtr->gc = None; + tkColPtr->gc = NULL; tkColPtr->screen = Tk_Screen(tkwin); tkColPtr->colormap = Tk_Colormap(tkwin); tkColPtr->visual = Tk_Visual(tkwin); @@ -326,7 +326,7 @@ Tk_GetColorByValue( tkColPtr = TkpGetColorByValue(tkwin, colorPtr); tkColPtr->magic = COLOR_MAGIC; - tkColPtr->gc = None; + tkColPtr->gc = NULL; tkColPtr->screen = Tk_Screen(tkwin); tkColPtr->colormap = valueKey.colormap; tkColPtr->visual = Tk_Visual(tkwin); @@ -436,7 +436,7 @@ Tk_GCForColor( Tcl_Panic("Tk_GCForColor called with bogus color"); } - if (tkColPtr->gc == None) { + if (tkColPtr->gc == NULL) { gcValues.foreground = tkColPtr->color.pixel; tkColPtr->gc = XCreateGC(DisplayOfScreen(tkColPtr->screen), drawable, GCForeground, &gcValues); @@ -490,9 +490,9 @@ Tk_FreeColor( * longer any objects referencing it. */ - if (tkColPtr->gc != None) { + if (tkColPtr->gc != NULL) { XFreeGC(DisplayOfScreen(screen), tkColPtr->gc); - tkColPtr->gc = None; + tkColPtr->gc = NULL; } TkpFreeColor(tkColPtr); diff --git a/generic/tkColor.h b/generic/tkColor.h index d5bde9d..bcd71fe 100644 --- a/generic/tkColor.h +++ b/generic/tkColor.h @@ -32,7 +32,7 @@ typedef struct TkColor { * COLOR_MAGIC. */ GC gc; /* Simple gc with this color as foreground * color and all other fields defaulted. May - * be None. */ + * be NULL. */ Screen *screen; /* Screen where this color is valid. Used to * delete it, and to find its display. */ Colormap colormap; /* Colormap from which this entry was diff --git a/generic/tkConfig.c b/generic/tkConfig.c index 46300d3..b9499e5 100644 --- a/generic/tkConfig.c +++ b/generic/tkConfig.c @@ -799,11 +799,11 @@ DoObjConfig( Tk_Cursor newCursor; if (nullOK && ObjectIsEmpty(valuePtr)) { - newCursor = None; + newCursor = NULL; valuePtr = NULL; } else { newCursor = Tk_AllocCursorFromObj(interp, tkwin, valuePtr); - if (newCursor == None) { + if (newCursor == NULL) { return TCL_ERROR; } } @@ -861,7 +861,7 @@ DoObjConfig( if (nullOK && ObjectIsEmpty(valuePtr)) { valuePtr = NULL; - newWin = None; + newWin = NULL; } else { if (TkGetWindowFromObj(interp, tkwin, valuePtr, &newWin) != TCL_OK) { @@ -1663,9 +1663,9 @@ FreeResources( break; case TK_OPTION_CURSOR: if (internalFormExists) { - if (*((Tk_Cursor *) internalPtr) != None) { + if (*((Tk_Cursor *) internalPtr) != NULL) { Tk_FreeCursor(Tk_Display(tkwin), *((Tk_Cursor *) internalPtr)); - *((Tk_Cursor *) internalPtr) = None; + *((Tk_Cursor *) internalPtr) = NULL; } } else if (objPtr != NULL) { Tk_FreeCursorFromObj(tkwin, objPtr); @@ -1936,7 +1936,7 @@ GetObjectForOption( case TK_OPTION_CURSOR: { Tk_Cursor cursor = *((Tk_Cursor *) internalPtr); - if (cursor != None) { + if (cursor != NULL) { objPtr = Tcl_NewStringObj( Tk_NameOfCursor(Tk_Display(tkwin), cursor), -1); } diff --git a/generic/tkCursor.c b/generic/tkCursor.c index afdf6dd..76bbc89 100644 --- a/generic/tkCursor.c +++ b/generic/tkCursor.c @@ -150,7 +150,7 @@ Tk_AllocCursorFromObj( cursorPtr = TkcGetCursor(interp, tkwin, Tcl_GetString(objPtr)); objPtr->internalRep.twoPtrValue.ptr1 = cursorPtr; if (cursorPtr == NULL) { - return None; + return NULL; } cursorPtr->objRefCount++; return cursorPtr->cursor; @@ -190,7 +190,7 @@ Tk_GetCursor( TkCursor *cursorPtr = TkcGetCursor(interp, tkwin, string); if (cursorPtr == NULL) { - return None; + return NULL; } return cursorPtr->cursor; } @@ -388,7 +388,7 @@ Tk_GetCursorFromData( error: Tcl_DeleteHashEntry(dataHashPtr); - return None; + return NULL; } /* diff --git a/generic/tkEntry.c b/generic/tkEntry.c index e045772..5a39f53 100644 --- a/generic/tkEntry.c +++ b/generic/tkEntry.c @@ -536,20 +536,20 @@ Tk_EntryObjCmd( entryPtr->selectFirst = -1; entryPtr->selectLast = -1; - entryPtr->cursor = None; + entryPtr->cursor = NULL; entryPtr->exportSelection = 1; entryPtr->justify = TK_JUSTIFY_LEFT; entryPtr->relief = TK_RELIEF_FLAT; entryPtr->state = STATE_NORMAL; entryPtr->displayString = entryPtr->string; entryPtr->inset = XPAD; - entryPtr->textGC = None; - entryPtr->selTextGC = None; - entryPtr->highlightGC = None; + entryPtr->textGC = NULL; + entryPtr->selTextGC = NULL; + entryPtr->highlightGC = NULL; entryPtr->avgWidth = 1; entryPtr->validate = VALIDATE_NONE; - entryPtr->placeholderGC = None; + entryPtr->placeholderGC = NULL; /* * Keep a hold of the associated tkwin until we destroy the entry, @@ -1047,10 +1047,10 @@ DestroyEntry( EntryTextVarProc, entryPtr); entryPtr->flags &= ~ENTRY_VAR_TRACED; } - if (entryPtr->textGC != None) { + if (entryPtr->textGC != NULL) { Tk_FreeGC(entryPtr->display, entryPtr->textGC); } - if (entryPtr->selTextGC != None) { + if (entryPtr->selTextGC != NULL) { Tk_FreeGC(entryPtr->display, entryPtr->selTextGC); } Tcl_DeleteTimerHandler(entryPtr->insertBlinkHandler); @@ -1446,7 +1446,7 @@ EntryWorldChanged( ClientData instanceData) /* Information about widget. */ { XGCValues gcValues; - GC gc = None; + GC gc = NULL; unsigned long mask; Tk_3DBorder border; XColor *colorPtr; @@ -1498,7 +1498,7 @@ EntryWorldChanged( gcValues.graphics_exposures = False; mask = GCForeground | GCFont | GCGraphicsExposures; gc = Tk_GetGC(entryPtr->tkwin, mask, &gcValues); - if (entryPtr->textGC != None) { + if (entryPtr->textGC != NULL) { Tk_FreeGC(entryPtr->display, entryPtr->textGC); } entryPtr->textGC = gc; @@ -1508,7 +1508,7 @@ EntryWorldChanged( } mask = GCForeground | GCFont | GCGraphicsExposures; gc = Tk_GetGC(entryPtr->tkwin, mask, &gcValues); - if (entryPtr->placeholderGC != None) { + if (entryPtr->placeholderGC != NULL) { Tk_FreeGC(entryPtr->display, entryPtr->placeholderGC); } entryPtr->placeholderGC = gc; @@ -1521,7 +1521,7 @@ EntryWorldChanged( gcValues.font = Tk_FontId(entryPtr->tkfont); mask = GCForeground | GCFont; gc = Tk_GetGC(entryPtr->tkwin, mask, &gcValues); - if (entryPtr->selTextGC != None) { + if (entryPtr->selTextGC != NULL) { Tk_FreeGC(entryPtr->display, entryPtr->selTextGC); } entryPtr->selTextGC = gc; @@ -2541,9 +2541,9 @@ EntryEventProc( } else if ((elem == SEL_BUTTONDOWN) || (elem == SEL_BUTTONUP)) { cursor = sbPtr->bCursor; } else { - cursor = None; + cursor = NULL; } - if (cursor != None) { + if (cursor != NULL) { Tk_DefineCursor(entryPtr->tkwin, cursor); } else { Tk_UndefineCursor(entryPtr->tkwin); @@ -3717,22 +3717,22 @@ Tk_SpinboxObjCmd( entryPtr->selectFirst = -1; entryPtr->selectLast = -1; - entryPtr->cursor = None; + entryPtr->cursor = NULL; entryPtr->exportSelection = 1; entryPtr->justify = TK_JUSTIFY_LEFT; entryPtr->relief = TK_RELIEF_FLAT; entryPtr->state = STATE_NORMAL; entryPtr->displayString = entryPtr->string; entryPtr->inset = XPAD; - entryPtr->textGC = None; - entryPtr->selTextGC = None; - entryPtr->highlightGC = None; + entryPtr->textGC = NULL; + entryPtr->selTextGC = NULL; + entryPtr->highlightGC = NULL; entryPtr->avgWidth = 1; entryPtr->validate = VALIDATE_NONE; sbPtr->selElement = SEL_NONE; sbPtr->curElement = SEL_NONE; - sbPtr->bCursor = None; + sbPtr->bCursor = NULL; sbPtr->repeatDelay = 400; sbPtr->repeatInterval = 100; sbPtr->fromValue = 0.0; @@ -3742,7 +3742,7 @@ Tk_SpinboxObjCmd( sbPtr->bdRelief = TK_RELIEF_FLAT; sbPtr->buRelief = TK_RELIEF_FLAT; - entryPtr->placeholderGC = None; + entryPtr->placeholderGC = NULL; /* * Keep a hold of the associated tkwin until we destroy the spinbox, diff --git a/generic/tkEntry.h b/generic/tkEntry.h index e74b52b..c81563c 100644 --- a/generic/tkEntry.h +++ b/generic/tkEntry.h @@ -82,7 +82,7 @@ typedef struct { * in readonly state, plus used for * background. */ int borderWidth; /* Width of 3-D border around window. */ - Tk_Cursor cursor; /* Current cursor for window, or None. */ + Tk_Cursor cursor; /* Current cursor for window, or NULL. */ int exportSelection; /* Non-zero means tie internal entry selection * to X selection. */ Tk_Font tkfont; /* Information about text font, or NULL. */ @@ -205,7 +205,7 @@ typedef struct { Tk_3DBorder activeBorder; /* Used for drawing border around active * buttons. */ Tk_3DBorder buttonBorder; /* Used for drawing border around buttons. */ - Tk_Cursor bCursor; /* cursor for buttons, or None. */ + Tk_Cursor bCursor; /* cursor for buttons, or NULL. */ int bdRelief; /* 3-D effect: TK_RELIEF_RAISED, etc. */ int buRelief; /* 3-D effect: TK_RELIEF_RAISED, etc. */ char *command; /* Command to invoke for spin buttons. NULL diff --git a/generic/tkEvent.c b/generic/tkEvent.c index d058e7c..891f667 100644 --- a/generic/tkEvent.c +++ b/generic/tkEvent.c @@ -1368,7 +1368,7 @@ Tk_HandleEvent( * handle CreateNotify events, so we gotta pass 'em through. */ - if ((ip.winPtr != None) + if ((ip.winPtr != NULL) && ((mask != SubstructureNotifyMask) || (eventPtr->type == CreateNotify))) { TkBindEventProc(winPtr, eventPtr); @@ -1439,7 +1439,7 @@ TkEventDeadWindow( ipPtr->nextHandler = NULL; } if (ipPtr->winPtr == winPtr) { - ipPtr->winPtr = None; + ipPtr->winPtr = NULL; } } ckfree(handlerPtr); diff --git a/generic/tkFrame.c b/generic/tkFrame.c index eb9dc4c..708faef 100644 --- a/generic/tkFrame.c +++ b/generic/tkFrame.c @@ -663,13 +663,13 @@ CreateFrame( framePtr->type = type; framePtr->colormap = colormap; framePtr->relief = TK_RELIEF_FLAT; - framePtr->cursor = None; + framePtr->cursor = NULL; if (framePtr->type == TYPE_LABELFRAME) { Labelframe *labelframePtr = (Labelframe *) framePtr; labelframePtr->labelAnchor = LABELANCHOR_NW; - labelframePtr->textGC = None; + labelframePtr->textGC = NULL; } /* @@ -866,7 +866,7 @@ DestroyFrame( if (framePtr->type == TYPE_LABELFRAME) { Tk_FreeTextLayout(labelframePtr->textLayout); - if (labelframePtr->textGC != None) { + if (labelframePtr->textGC != NULL) { Tk_FreeGC(framePtr->display, labelframePtr->textGC); } } @@ -1122,7 +1122,7 @@ FrameWorldChanged( gcValues.graphics_exposures = False; gc = Tk_GetGC(tkwin, GCForeground | GCFont | GCGraphicsExposures, &gcValues); - if (labelframePtr->textGC != None) { + if (labelframePtr->textGC != NULL) { Tk_FreeGC(framePtr->display, labelframePtr->textGC); } labelframePtr->textGC = gc; diff --git a/generic/tkGrab.c b/generic/tkGrab.c index c37b6be..ff5d083 100644 --- a/generic/tkGrab.c +++ b/generic/tkGrab.c @@ -426,12 +426,7 @@ Tk_Grab( } Tk_MakeWindowExist(tkwin); -#ifndef MAC_OSX_TK - if (!grabGlobal) -#else - if (0) -#endif /* MAC_OSX_TK */ - { + if (!grabGlobal) { Window dummy1, dummy2; int dummy3, dummy4, dummy5, dummy6; unsigned int state; diff --git a/generic/tkImage.c b/generic/tkImage.c index 359d6c6..32e09c0 100644 --- a/generic/tkImage.c +++ b/generic/tkImage.c @@ -775,7 +775,7 @@ Tk_PostscriptImage( gcValues.foreground = WhitePixelOfScreen(Tk_Screen(tkwin)); newGC = Tk_GetGC(tkwin, GCForeground, &gcValues); - if (newGC != None) { + if (newGC != NULL) { XFillRectangle(Tk_Display(tkwin), pmap, newGC, 0, 0, (unsigned) width, (unsigned) height); Tk_FreeGC(Tk_Display(tkwin), newGC); diff --git a/generic/tkImgBmap.c b/generic/tkImgBmap.c index 2104ea8..f83f4cc 100644 --- a/generic/tkImgBmap.c +++ b/generic/tkImgBmap.c @@ -427,9 +427,9 @@ ImgBmapConfigureInstance( } gc = Tk_GetGC(instancePtr->tkwin, mask, &gcValues); } else { - gc = None; + gc = NULL; } - if (instancePtr->gc != None) { + if (instancePtr->gc != NULL) { Tk_FreeGC(Tk_Display(instancePtr->tkwin), instancePtr->gc); } instancePtr->gc = gc; @@ -441,10 +441,10 @@ ImgBmapConfigureInstance( * it clear that this instance cannot be displayed. Then report the error. */ - if (instancePtr->gc != None) { + if (instancePtr->gc != NULL) { Tk_FreeGC(Tk_Display(instancePtr->tkwin), instancePtr->gc); } - instancePtr->gc = None; + instancePtr->gc = NULL; Tcl_AppendObjToErrorInfo(masterPtr->interp, Tcl_ObjPrintf( "\n (while configuring image \"%s\")", Tk_NameOfImage( masterPtr->tkMaster))); @@ -848,7 +848,7 @@ ImgBmapGet( instancePtr->bg = NULL; instancePtr->bitmap = None; instancePtr->mask = None; - instancePtr->gc = None; + instancePtr->gc = NULL; instancePtr->nextPtr = masterPtr->instancePtr; masterPtr->instancePtr = instancePtr; ImgBmapConfigureInstance(instancePtr); @@ -902,7 +902,7 @@ ImgBmapDisplay( * creating the image instance so it can't be displayed. */ - if (instancePtr->gc == None) { + if (instancePtr->gc == NULL) { return; } @@ -972,7 +972,7 @@ ImgBmapFree( if (instancePtr->mask != None) { Tk_FreePixmap(display, instancePtr->mask); } - if (instancePtr->gc != None) { + if (instancePtr->gc != NULL) { Tk_FreeGC(display, instancePtr->gc); } if (instancePtr->masterPtr->instancePtr == instancePtr) { diff --git a/generic/tkImgPhInstance.c b/generic/tkImgPhInstance.c index 1dc8840..f67ab36 100644 --- a/generic/tkImgPhInstance.c +++ b/generic/tkImgPhInstance.c @@ -1589,7 +1589,7 @@ TkImgDisposeInstance( if (instancePtr->pixels != None) { Tk_FreePixmap(instancePtr->display, instancePtr->pixels); } - if (instancePtr->gc != None) { + if (instancePtr->gc != NULL) { Tk_FreeGC(instancePtr->display, instancePtr->gc); } if (instancePtr->imagePtr != NULL) { diff --git a/generic/tkListbox.c b/generic/tkListbox.c index dce0106..e35c6c5 100644 --- a/generic/tkListbox.c +++ b/generic/tkListbox.c @@ -542,13 +542,13 @@ Tk_ListboxObjCmd( listPtr->itemAttrTable = ckalloc(sizeof(Tcl_HashTable)); Tcl_InitHashTable(listPtr->itemAttrTable, TCL_ONE_WORD_KEYS); listPtr->relief = TK_RELIEF_RAISED; - listPtr->textGC = None; - listPtr->selFgColorPtr = None; - listPtr->selTextGC = None; + listPtr->textGC = NULL; + listPtr->selFgColorPtr = NULL; + listPtr->selTextGC = NULL; listPtr->fullLines = 1; listPtr->xScrollUnit = 1; listPtr->exportSelection = 1; - listPtr->cursor = None; + listPtr->cursor = NULL; listPtr->state = STATE_NORMAL; listPtr->gray = None; listPtr->justify = TK_JUSTIFY_LEFT; @@ -1489,10 +1489,10 @@ DestroyListbox( * Tk_FreeOptions handle all the standard option-related stuff. */ - if (listPtr->textGC != None) { + if (listPtr->textGC != NULL) { Tk_FreeGC(listPtr->display, listPtr->textGC); } - if (listPtr->selTextGC != None) { + if (listPtr->selTextGC != NULL) { Tk_FreeGC(listPtr->display, listPtr->selTextGC); } if (listPtr->gray != None) { @@ -1792,7 +1792,7 @@ ListboxWorldChanged( gcValues.font = Tk_FontId(listPtr->tkfont); gc = Tk_GetGC(listPtr->tkwin, mask, &gcValues); - if (listPtr->textGC != None) { + if (listPtr->textGC != NULL) { Tk_FreeGC(listPtr->display, listPtr->textGC); } listPtr->textGC = gc; @@ -1803,7 +1803,7 @@ ListboxWorldChanged( gcValues.font = Tk_FontId(listPtr->tkfont); mask = GCForeground | GCFont; gc = Tk_GetGC(listPtr->tkwin, mask, &gcValues); - if (listPtr->selTextGC != None) { + if (listPtr->selTextGC != NULL) { Tk_FreeGC(listPtr->display, listPtr->selTextGC); } listPtr->selTextGC = gc; diff --git a/generic/tkMain.c b/generic/tkMain.c index ffcaecf..eb311ff 100644 --- a/generic/tkMain.c +++ b/generic/tkMain.c @@ -37,7 +37,7 @@ extern int TkCygwinMainEx(int, char **, Tcl_AppInitProc *, Tcl_Interp *); * The default prompt used when the user has not overridden it. */ -#define DEFAULT_PRIMARY_PROMPT "% " +static const char DEFAULT_PRIMARY_PROMPT[] = "% "; /* * This file can be compiled on Windows in UNICODE mode, as well as @@ -512,7 +512,7 @@ Prompt( chan = Tcl_GetStdChannel(TCL_STDOUT); if (chan != NULL) { Tcl_WriteChars(chan, DEFAULT_PRIMARY_PROMPT, - strlen(DEFAULT_PRIMARY_PROMPT)); + sizeof(DEFAULT_PRIMARY_PROMPT) - 1); } } } else { diff --git a/generic/tkMenu.c b/generic/tkMenu.c index e67c476..0bd40a6 100644 --- a/generic/tkMenu.c +++ b/generic/tkMenu.c @@ -458,7 +458,7 @@ Tk_MenuObjCmd( Tk_PathName(menuPtr->tkwin), MenuWidgetObjCmd, menuPtr, MenuCmdDeletedProc); menuPtr->active = -1; - menuPtr->cursorPtr = None; + menuPtr->cursorPtr = NULL; menuPtr->masterMenuPtr = menuPtr; menuPtr->menuType = UNKNOWN_TYPE; TkMenuInitializeDrawingFields(menuPtr); diff --git a/generic/tkMenu.h b/generic/tkMenu.h index 6d51a72..802781a 100644 --- a/generic/tkMenu.h +++ b/generic/tkMenu.h @@ -75,8 +75,8 @@ typedef struct TkMenuEntry { * of character to underline (-1 means don't * underline anything). */ Tcl_Obj *underlinePtr; /* Index of character to underline. */ - Tcl_Obj *bitmapPtr; /* Bitmap to display in menu entry, or None. - * If not None then label is ignored. */ + Tcl_Obj *bitmapPtr; /* Bitmap to display in menu entry, or NULL. + * If not NULL then label is ignored. */ Tcl_Obj *imagePtr; /* Name of image to display, or NULL. If not * NULL, bitmap, text, and textVarName are * ignored. */ @@ -175,7 +175,7 @@ typedef struct TkMenuEntry { * NULL means use overall disabledGC from menu * structure. See comments for disabledFg in * menu structure for more information. */ - GC indicatorGC; /* For drawing indicators. None means use GC + GC indicatorGC; /* For drawing indicators. NULL means use GC * from menu. */ /* @@ -340,7 +340,7 @@ typedef struct TkMenu { Tcl_Obj *takeFocusPtr; /* Value of -takefocus option; not used in the * C code, but used by keyboard traversal * scripts. Malloc'ed, but may be NULL. */ - Tcl_Obj *cursorPtr; /* Current cursor for window, or None. */ + Tcl_Obj *cursorPtr; /* Current cursor for window, or NULL. */ Tcl_Obj *postCommandPtr; /* Used to detect cycles in cascade hierarchy * trees when preprocessing postcommands on * some platforms. See PostMenu for more diff --git a/generic/tkMenuDraw.c b/generic/tkMenuDraw.c index 3f492db..3abfc3c 100644 --- a/generic/tkMenuDraw.c +++ b/generic/tkMenuDraw.c @@ -43,12 +43,12 @@ void TkMenuInitializeDrawingFields( TkMenu *menuPtr) /* The menu we are initializing. */ { - menuPtr->textGC = None; + menuPtr->textGC = NULL; menuPtr->gray = None; - menuPtr->disabledGC = None; - menuPtr->activeGC = None; - menuPtr->indicatorGC = None; - menuPtr->disabledImageGC = None; + menuPtr->disabledGC = NULL; + menuPtr->activeGC = NULL; + menuPtr->indicatorGC = NULL; + menuPtr->disabledImageGC = NULL; menuPtr->totalWidth = menuPtr->totalHeight = 0; } @@ -79,10 +79,10 @@ TkMenuInitializeEntryDrawingFields( mePtr->y = 0; mePtr->indicatorSpace = 0; mePtr->labelWidth = 0; - mePtr->textGC = None; - mePtr->activeGC = None; - mePtr->disabledGC = None; - mePtr->indicatorGC = None; + mePtr->textGC = NULL; + mePtr->activeGC = NULL; + mePtr->disabledGC = NULL; + mePtr->indicatorGC = NULL; } /* @@ -106,22 +106,22 @@ void TkMenuFreeDrawOptions( TkMenu *menuPtr) { - if (menuPtr->textGC != None) { + if (menuPtr->textGC != NULL) { Tk_FreeGC(menuPtr->display, menuPtr->textGC); } - if (menuPtr->disabledImageGC != None) { + if (menuPtr->disabledImageGC != NULL) { Tk_FreeGC(menuPtr->display, menuPtr->disabledImageGC); } if (menuPtr->gray != None) { Tk_FreeBitmap(menuPtr->display, menuPtr->gray); } - if (menuPtr->disabledGC != None) { + if (menuPtr->disabledGC != NULL) { Tk_FreeGC(menuPtr->display, menuPtr->disabledGC); } - if (menuPtr->activeGC != None) { + if (menuPtr->activeGC != NULL) { Tk_FreeGC(menuPtr->display, menuPtr->activeGC); } - if (menuPtr->indicatorGC != None) { + if (menuPtr->indicatorGC != NULL) { Tk_FreeGC(menuPtr->display, menuPtr->indicatorGC); } } @@ -147,16 +147,16 @@ void TkMenuEntryFreeDrawOptions( TkMenuEntry *mePtr) { - if (mePtr->textGC != None) { + if (mePtr->textGC != NULL) { Tk_FreeGC(mePtr->menuPtr->display, mePtr->textGC); } - if (mePtr->disabledGC != None) { + if (mePtr->disabledGC != NULL) { Tk_FreeGC(mePtr->menuPtr->display, mePtr->disabledGC); } - if (mePtr->activeGC != None) { + if (mePtr->activeGC != NULL) { Tk_FreeGC(mePtr->menuPtr->display, mePtr->activeGC); } - if (mePtr->indicatorGC != None) { + if (mePtr->indicatorGC != NULL) { Tk_FreeGC(mePtr->menuPtr->display, mePtr->indicatorGC); } } @@ -205,7 +205,7 @@ TkMenuConfigureDrawOptions( gcValues.background = Tk_3DBorderColor(border)->pixel; newGC = Tk_GetGC(menuPtr->tkwin, GCForeground|GCBackground|GCFont, &gcValues); - if (menuPtr->textGC != None) { + if (menuPtr->textGC != NULL) { Tk_FreeGC(menuPtr->display, menuPtr->textGC); } menuPtr->textGC = newGC; @@ -233,7 +233,7 @@ TkMenuConfigureDrawOptions( } } newGC = Tk_GetGC(menuPtr->tkwin, mask, &gcValues); - if (menuPtr->disabledGC != None) { + if (menuPtr->disabledGC != NULL) { Tk_FreeGC(menuPtr->display, menuPtr->disabledGC); } menuPtr->disabledGC = newGC; @@ -249,7 +249,7 @@ TkMenuConfigureDrawOptions( newGC = Tk_GetGC(menuPtr->tkwin, GCForeground|GCFillStyle|GCStipple, &gcValues); } - if (menuPtr->disabledImageGC != None) { + if (menuPtr->disabledImageGC != NULL) { Tk_FreeGC(menuPtr->display, menuPtr->disabledImageGC); } menuPtr->disabledImageGC = newGC; @@ -262,7 +262,7 @@ TkMenuConfigureDrawOptions( gcValues.background = Tk_3DBorderColor(activeBorder)->pixel; newGC = Tk_GetGC(menuPtr->tkwin, GCForeground|GCBackground|GCFont, &gcValues); - if (menuPtr->activeGC != None) { + if (menuPtr->activeGC != NULL) { Tk_FreeGC(menuPtr->display, menuPtr->activeGC); } menuPtr->activeGC = newGC; @@ -273,7 +273,7 @@ TkMenuConfigureDrawOptions( gcValues.background = Tk_3DBorderColor(border)->pixel; newGC = Tk_GetGC(menuPtr->tkwin, GCForeground|GCBackground|GCFont, &gcValues); - if (menuPtr->indicatorGC != None) { + if (menuPtr->indicatorGC != NULL) { Tk_FreeGC(menuPtr->display, menuPtr->indicatorGC); } menuPtr->indicatorGC = newGC; @@ -385,24 +385,24 @@ TkMenuConfigureEntryDrawOptions( GCForeground|GCBackground|GCFont|GCGraphicsExposures, &gcValues); } else { - newGC = None; - newActiveGC = None; - newDisabledGC = None; - newIndicatorGC = None; + newGC = NULL; + newActiveGC = NULL; + newDisabledGC = NULL; + newIndicatorGC = NULL; } - if (mePtr->textGC != None) { + if (mePtr->textGC != NULL) { Tk_FreeGC(menuPtr->display, mePtr->textGC); } mePtr->textGC = newGC; - if (mePtr->activeGC != None) { + if (mePtr->activeGC != NULL) { Tk_FreeGC(menuPtr->display, mePtr->activeGC); } mePtr->activeGC = newActiveGC; - if (mePtr->disabledGC != None) { + if (mePtr->disabledGC != NULL) { Tk_FreeGC(menuPtr->display, mePtr->disabledGC); } mePtr->disabledGC = newDisabledGC; - if (mePtr->indicatorGC != None) { + if (mePtr->indicatorGC != NULL) { Tk_FreeGC(menuPtr->display, mePtr->indicatorGC); } mePtr->indicatorGC = newIndicatorGC; diff --git a/generic/tkMenubutton.c b/generic/tkMenubutton.c index d3372cc..65883c0 100644 --- a/generic/tkMenubutton.c +++ b/generic/tkMenubutton.c @@ -279,11 +279,11 @@ Tk_MenubuttonObjCmd( mbPtr->normalFg = NULL; mbPtr->activeFg = NULL; mbPtr->disabledFg = NULL; - mbPtr->normalTextGC = None; - mbPtr->activeTextGC = None; + mbPtr->normalTextGC = NULL; + mbPtr->activeTextGC = NULL; mbPtr->gray = None; - mbPtr->disabledGC = None; - mbPtr->stippleGC = None; + mbPtr->disabledGC = NULL; + mbPtr->stippleGC = NULL; mbPtr->leftBearing = 0; mbPtr->rightBearing = 0; mbPtr->widthString = NULL; @@ -300,7 +300,7 @@ Tk_MenubuttonObjCmd( mbPtr->indicatorWidth = 0; mbPtr->indicatorHeight = 0; mbPtr->direction = DIRECTION_FLUSH; - mbPtr->cursor = None; + mbPtr->cursor = NULL; mbPtr->takeFocus = NULL; mbPtr->flags = 0; @@ -443,16 +443,16 @@ DestroyMenuButton( if (mbPtr->image != NULL) { Tk_FreeImage(mbPtr->image); } - if (mbPtr->normalTextGC != None) { + if (mbPtr->normalTextGC != NULL) { Tk_FreeGC(mbPtr->display, mbPtr->normalTextGC); } - if (mbPtr->activeTextGC != None) { + if (mbPtr->activeTextGC != NULL) { Tk_FreeGC(mbPtr->display, mbPtr->activeTextGC); } - if (mbPtr->disabledGC != None) { + if (mbPtr->disabledGC != NULL) { Tk_FreeGC(mbPtr->display, mbPtr->disabledGC); } - if (mbPtr->stippleGC != None) { + if (mbPtr->stippleGC != NULL) { Tk_FreeGC(mbPtr->display, mbPtr->stippleGC); } if (mbPtr->gray != None) { @@ -690,7 +690,7 @@ TkMenuButtonWorldChanged( gcValues.graphics_exposures = False; mask = GCForeground | GCBackground | GCFont | GCGraphicsExposures; gc = Tk_GetGC(mbPtr->tkwin, mask, &gcValues); - if (mbPtr->normalTextGC != None) { + if (mbPtr->normalTextGC != NULL) { Tk_FreeGC(mbPtr->display, mbPtr->normalTextGC); } mbPtr->normalTextGC = gc; @@ -699,7 +699,7 @@ TkMenuButtonWorldChanged( gcValues.background = Tk_3DBorderColor(mbPtr->activeBorder)->pixel; mask = GCForeground | GCBackground | GCFont; gc = Tk_GetGC(mbPtr->tkwin, mask, &gcValues); - if (mbPtr->activeTextGC != None) { + if (mbPtr->activeTextGC != NULL) { Tk_FreeGC(mbPtr->display, mbPtr->activeTextGC); } mbPtr->activeTextGC = gc; @@ -710,7 +710,7 @@ TkMenuButtonWorldChanged( * Create the GC that can be used for stippling */ - if (mbPtr->stippleGC == None) { + if (mbPtr->stippleGC == NULL) { gcValues.foreground = gcValues.background; mask = GCForeground; if (mbPtr->gray == None) { @@ -736,7 +736,7 @@ TkMenuButtonWorldChanged( gcValues.foreground = gcValues.background; } gc = Tk_GetGC(mbPtr->tkwin, mask, &gcValues); - if (mbPtr->disabledGC != None) { + if (mbPtr->disabledGC != NULL) { Tk_FreeGC(mbPtr->display, mbPtr->disabledGC); } mbPtr->disabledGC = gc; diff --git a/generic/tkMenubutton.h b/generic/tkMenubutton.h index e8dc12f..1dbacb3 100644 --- a/generic/tkMenubutton.h +++ b/generic/tkMenubutton.h @@ -170,7 +170,7 @@ typedef struct { * "left" and "right" will pop the menu left * or right, and the active item will be next * to the button. */ - Tk_Cursor cursor; /* Current cursor for window, or None. */ + Tk_Cursor cursor; /* Current cursor for window, or NULL. */ char *takeFocus; /* Value of -takefocus option; not used in the * C code, but used by keyboard traversal * scripts. Malloc'ed, but may be NULL. */ diff --git a/generic/tkMessage.c b/generic/tkMessage.c index 96724db..2495ce2 100644 --- a/generic/tkMessage.c +++ b/generic/tkMessage.c @@ -256,11 +256,11 @@ Tk_MessageObjCmd( MessageCmdDeletedProc); msgPtr->optionTable = optionTable; msgPtr->relief = TK_RELIEF_FLAT; - msgPtr->textGC = None; + msgPtr->textGC = NULL; msgPtr->anchor = TK_ANCHOR_CENTER; msgPtr->aspect = 150; msgPtr->justify = TK_JUSTIFY_LEFT; - msgPtr->cursor = None; + msgPtr->cursor = NULL; Tk_SetClass(msgPtr->tkwin, "Message"); Tk_SetClassProcs(msgPtr->tkwin, &messageClass, msgPtr); @@ -398,7 +398,7 @@ DestroyMessage( * Tk_FreeConfigOptions handle all the standard option-related stuff. */ - if (msgPtr->textGC != None) { + if (msgPtr->textGC != NULL) { Tk_FreeGC(msgPtr->display, msgPtr->textGC); } if (msgPtr->textLayout != NULL) { @@ -525,7 +525,7 @@ MessageWorldChanged( ClientData instanceData) /* Information about widget. */ { XGCValues gcValues; - GC gc = None; + GC gc = NULL; Tk_FontMetrics fm; Message *msgPtr = instanceData; @@ -536,7 +536,7 @@ MessageWorldChanged( gcValues.font = Tk_FontId(msgPtr->tkfont); gcValues.foreground = msgPtr->fgColorPtr->pixel; gc = Tk_GetGC(msgPtr->tkwin, GCForeground | GCFont, &gcValues); - if (msgPtr->textGC != None) { + if (msgPtr->textGC != NULL) { Tk_FreeGC(msgPtr->display, msgPtr->textGC); } msgPtr->textGC = gc; diff --git a/generic/tkOldConfig.c b/generic/tkOldConfig.c index 4473a3e..d83c30b 100644 --- a/generic/tkOldConfig.c +++ b/generic/tkOldConfig.c @@ -481,16 +481,16 @@ DoConfig( Tk_Cursor newCursor, oldCursor; if (nullValue) { - newCursor = None; + newCursor = NULL; } else { uid = valueIsUid ? (Tk_Uid) value : Tk_GetUid(value); newCursor = Tk_GetCursor(interp, tkwin, uid); - if (newCursor == None) { + if (newCursor == NULL) { return TCL_ERROR; } } oldCursor = *((Tk_Cursor *) ptr); - if (oldCursor != None) { + if (oldCursor != NULL) { Tk_FreeCursor(Tk_Display(tkwin), oldCursor); } *((Tk_Cursor *) ptr) = newCursor; @@ -842,7 +842,7 @@ FormatConfigValue( case TK_CONFIG_ACTIVE_CURSOR: { Tk_Cursor cursor = *((Tk_Cursor *) ptr); - if (cursor != None) { + if (cursor != NULL) { result = Tk_NameOfCursor(Tk_Display(tkwin), cursor); } break; @@ -1027,9 +1027,9 @@ Tk_FreeOptions( break; case TK_CONFIG_CURSOR: case TK_CONFIG_ACTIVE_CURSOR: - if (*((Tk_Cursor *) ptr) != None) { + if (*((Tk_Cursor *) ptr) != NULL) { Tk_FreeCursor(display, *((Tk_Cursor *) ptr)); - *((Tk_Cursor *) ptr) = None; + *((Tk_Cursor *) ptr) = NULL; } } } diff --git a/generic/tkPanedWindow.c b/generic/tkPanedWindow.c index 967d322..d6953e7 100644 --- a/generic/tkPanedWindow.c +++ b/generic/tkPanedWindow.c @@ -448,9 +448,9 @@ Tk_PanedWindowObjCmd( pwPtr->optionTable = pwOpts->pwOptions; pwPtr->slaveOpts = pwOpts->slaveOpts; pwPtr->relief = TK_RELIEF_RAISED; - pwPtr->gc = None; - pwPtr->cursor = None; - pwPtr->sashCursor = None; + pwPtr->gc = NULL; + pwPtr->cursor = NULL; + pwPtr->sashCursor = NULL; /* * Keep a hold of the associated tkwin until we destroy the widget, @@ -862,7 +862,7 @@ ConfigureSlaves( index = -1; haveLoc = 0; - if (options.after != None) { + if (options.after != NULL) { tkwin = options.after; haveLoc = 1; for (i = 0; i < pwPtr->numSlaves; i++) { @@ -871,7 +871,7 @@ ConfigureSlaves( break; } } - } else if (options.before != None) { + } else if (options.before != NULL) { tkwin = options.before; haveLoc = 1; for (i = 0; i < pwPtr->numSlaves; i++) { @@ -1304,7 +1304,7 @@ PanedWindowWorldChanged( gcValues.background = Tk_3DBorderColor(pwPtr->background)->pixel; newGC = Tk_GetGC(pwPtr->tkwin, GCBackground, &gcValues); - if (pwPtr->gc != None) { + if (pwPtr->gc != NULL) { Tk_FreeGC(pwPtr->display, pwPtr->gc); } pwPtr->gc = newGC; @@ -2044,10 +2044,10 @@ Unlink( for (i = 0; i < masterPtr->numSlaves; i++) { if (masterPtr->slaves[i]->before == slavePtr->tkwin) { - masterPtr->slaves[i]->before = None; + masterPtr->slaves[i]->before = NULL; } if (masterPtr->slaves[i]->after == slavePtr->tkwin) { - masterPtr->slaves[i]->after = None; + masterPtr->slaves[i]->after = NULL; } } diff --git a/generic/tkPlace.c b/generic/tkPlace.c index e7cfbaf..1e606be 100644 --- a/generic/tkPlace.c +++ b/generic/tkPlace.c @@ -395,7 +395,7 @@ CreateSlave( slavePtr = ckalloc(sizeof(Slave)); memset(slavePtr, 0, sizeof(Slave)); slavePtr->tkwin = tkwin; - slavePtr->inTkwin = None; + slavePtr->inTkwin = NULL; slavePtr->anchor = TK_ANCHOR_NW; slavePtr->borderMode = BM_INSIDE; slavePtr->optionTable = table; diff --git a/generic/tkRectOval.c b/generic/tkRectOval.c index e650030..58bb99a 100644 --- a/generic/tkRectOval.c +++ b/generic/tkRectOval.c @@ -258,7 +258,7 @@ CreateRectOval( rectOvalPtr->fillStipple = None; rectOvalPtr->activeFillStipple = None; rectOvalPtr->disabledFillStipple = None; - rectOvalPtr->fillGC = None; + rectOvalPtr->fillGC = NULL; /* * Process the arguments to fill in the item record. @@ -466,9 +466,9 @@ ConfigureRectOval( mask |= GCCapStyle; newGC = Tk_GetGC(tkwin, mask, &gcValues); } else { - newGC = None; + newGC = NULL; } - if (rectOvalPtr->outline.gc != None) { + if (rectOvalPtr->outline.gc != NULL) { Tk_FreeGC(Tk_Display(tkwin), rectOvalPtr->outline.gc); } rectOvalPtr->outline.gc = newGC; @@ -500,7 +500,7 @@ ConfigureRectOval( } if (color == NULL) { - newGC = None; + newGC = NULL; } else { gcValues.foreground = color->pixel; if (stipple != None) { @@ -515,14 +515,13 @@ ConfigureRectOval( * Mac OS X CG drawing needs access to the outline linewidth even for * fills (as linewidth controls antialiasing). */ - - gcValues.line_width = rectOvalPtr->outline.gc != None ? + gcValues.line_width = rectOvalPtr->outline.gc != NULL ? rectOvalPtr->outline.gc->line_width : 0; mask |= GCLineWidth; #endif newGC = Tk_GetGC(tkwin, mask, &gcValues); } - if (rectOvalPtr->fillGC != None) { + if (rectOvalPtr->fillGC != NULL) { Tk_FreeGC(Tk_Display(tkwin), rectOvalPtr->fillGC); } rectOvalPtr->fillGC = newGC; @@ -595,7 +594,7 @@ DeleteRectOval( if (rectOvalPtr->disabledFillStipple != None) { Tk_FreeBitmap(display, rectOvalPtr->disabledFillStipple); } - if (rectOvalPtr->fillGC != None) { + if (rectOvalPtr->fillGC != NULL) { Tk_FreeGC(display, rectOvalPtr->fillGC); } } @@ -664,7 +663,7 @@ ComputeRectOvalBbox( rectOvalPtr->bbox[0] = tmpX; } - if (rectOvalPtr->outline.gc == None) { + if (rectOvalPtr->outline.gc == NULL) { /* * The Win32 switch was added for 8.3 to solve a problem with ovals * leaving traces on bottom and right of 1 pixel. This may not be the @@ -878,7 +877,7 @@ DisplayRectOval( } } - if (rectOvalPtr->fillGC != None) { + if (rectOvalPtr->fillGC != NULL) { if (fillStipple != None) { Tk_TSOffset *tsoffset; int w = 0, h = 0; @@ -922,7 +921,7 @@ DisplayRectOval( } } - if (rectOvalPtr->outline.gc != None) { + if (rectOvalPtr->outline.gc != NULL) { Tk_ChangeOutlineGC(canvas, itemPtr, &(rectOvalPtr->outline)); if (rectOvalPtr->header.typePtr == &tkRectangleType) { XDrawRectangle(display, drawable, rectOvalPtr->outline.gc, @@ -993,7 +992,7 @@ RectToPoint( y1 = rectPtr->bbox[1]; x2 = rectPtr->bbox[2]; y2 = rectPtr->bbox[3]; - if (rectPtr->outline.gc != None) { + if (rectPtr->outline.gc != NULL) { inc = width/2.0; x1 -= inc; y1 -= inc; @@ -1009,7 +1008,7 @@ RectToPoint( if ((pointPtr[0] >= x1) && (pointPtr[0] < x2) && (pointPtr[1] >= y1) && (pointPtr[1] < y2)) { - if ((rectPtr->fillGC != None) || (rectPtr->outline.gc == None)) { + if ((rectPtr->fillGC != NULL) || (rectPtr->outline.gc == NULL)) { return 0.0; } xDiff = pointPtr[0] - x1; @@ -1105,8 +1104,8 @@ OvalToPoint( } - filled = ovalPtr->fillGC != None; - if (ovalPtr->outline.gc == None) { + filled = ovalPtr->fillGC != NULL; + if (ovalPtr->outline.gc == NULL) { width = 0.0; filled = 1; } @@ -1161,7 +1160,7 @@ RectToArea( } halfWidth = width/2.0; - if (rectPtr->outline.gc == None) { + if (rectPtr->outline.gc == NULL) { halfWidth = 0.0; } @@ -1171,7 +1170,7 @@ RectToArea( || (areaPtr[1] >= (rectPtr->bbox[3] + halfWidth))) { return -1; } - if ((rectPtr->fillGC == None) && (rectPtr->outline.gc != None) + if ((rectPtr->fillGC == NULL) && (rectPtr->outline.gc != NULL) && (areaPtr[0] >= (rectPtr->bbox[0] + halfWidth)) && (areaPtr[1] >= (rectPtr->bbox[1] + halfWidth)) && (areaPtr[2] <= (rectPtr->bbox[2] - halfWidth)) @@ -1239,7 +1238,7 @@ OvalToArea( */ halfWidth = width/2.0; - if (ovalPtr->outline.gc == None) { + if (ovalPtr->outline.gc == NULL) { halfWidth = 0.0; } oval[0] = ovalPtr->bbox[0] - halfWidth; @@ -1256,8 +1255,8 @@ OvalToArea( * return "outside". */ - if ((result == 0) && (ovalPtr->outline.gc != None) - && (ovalPtr->fillGC == None)) { + if ((result == 0) && (ovalPtr->outline.gc != NULL) + && (ovalPtr->fillGC == NULL)) { double centerX, centerY, height; double xDelta1, yDelta1, xDelta2, yDelta2; diff --git a/generic/tkScale.c b/generic/tkScale.c index ab8c125..6862ea9 100644 --- a/generic/tkScale.c +++ b/generic/tkScale.c @@ -270,11 +270,11 @@ Tk_ScaleObjCmd( scalePtr->activeBorder = NULL; scalePtr->sliderRelief = TK_RELIEF_RAISED; scalePtr->troughColorPtr = NULL; - scalePtr->troughGC = None; - scalePtr->copyGC = None; + scalePtr->troughGC = NULL; + scalePtr->copyGC = NULL; scalePtr->tkfont = NULL; scalePtr->textColorPtr = NULL; - scalePtr->textGC = None; + scalePtr->textGC = NULL; scalePtr->relief = TK_RELIEF_FLAT; scalePtr->highlightWidth = 0; scalePtr->highlightBorder = NULL; @@ -291,7 +291,7 @@ Tk_ScaleObjCmd( scalePtr->vertTroughX = 0; scalePtr->vertLabelX = 0; scalePtr->fontHeight = 0; - scalePtr->cursor = None; + scalePtr->cursor = NULL; scalePtr->takeFocusPtr = NULL; scalePtr->flags = NEVER_SET; @@ -518,13 +518,13 @@ DestroyScale( NULL, TCL_GLOBAL_ONLY|TCL_TRACE_WRITES|TCL_TRACE_UNSETS, ScaleVarProc, scalePtr); } - if (scalePtr->troughGC != None) { + if (scalePtr->troughGC != NULL) { Tk_FreeGC(scalePtr->display, scalePtr->troughGC); } - if (scalePtr->copyGC != None) { + if (scalePtr->copyGC != NULL) { Tk_FreeGC(scalePtr->display, scalePtr->copyGC); } - if (scalePtr->textGC != None) { + if (scalePtr->textGC != NULL) { Tk_FreeGC(scalePtr->display, scalePtr->textGC); } Tk_FreeConfigOptions((char *) scalePtr, scalePtr->optionTable, @@ -729,7 +729,7 @@ ScaleWorldChanged( gcValues.foreground = scalePtr->troughColorPtr->pixel; gc = Tk_GetGC(scalePtr->tkwin, GCForeground, &gcValues); - if (scalePtr->troughGC != None) { + if (scalePtr->troughGC != NULL) { Tk_FreeGC(scalePtr->display, scalePtr->troughGC); } scalePtr->troughGC = gc; @@ -737,12 +737,12 @@ ScaleWorldChanged( gcValues.font = Tk_FontId(scalePtr->tkfont); gcValues.foreground = scalePtr->textColorPtr->pixel; gc = Tk_GetGC(scalePtr->tkwin, GCForeground | GCFont, &gcValues); - if (scalePtr->textGC != None) { + if (scalePtr->textGC != NULL) { Tk_FreeGC(scalePtr->display, scalePtr->textGC); } scalePtr->textGC = gc; - if (scalePtr->copyGC == None) { + if (scalePtr->copyGC == NULL) { gcValues.graphics_exposures = False; scalePtr->copyGC = Tk_GetGC(scalePtr->tkwin, GCGraphicsExposures, &gcValues); diff --git a/generic/tkScale.h b/generic/tkScale.h index d0be190..e7e0dde 100644 --- a/generic/tkScale.h +++ b/generic/tkScale.h @@ -151,7 +151,7 @@ typedef struct TkScale { */ int fontHeight; /* Height of scale font. */ - Tk_Cursor cursor; /* Current cursor for window, or None. */ + Tk_Cursor cursor; /* Current cursor for window, or NULL. */ Tcl_Obj *takeFocusPtr; /* Value of -takefocus option; not used in the * C code, but used by keyboard traversal * scripts. May be NULL. */ diff --git a/generic/tkScrollbar.c b/generic/tkScrollbar.c index 4898b37..f88b37b 100644 --- a/generic/tkScrollbar.c +++ b/generic/tkScrollbar.c @@ -187,7 +187,7 @@ Tk_ScrollbarObjCmd( #endif /* TK_NO_DEPRECATED */ scrollPtr->firstFraction = 0.0; scrollPtr->lastFraction = 0.0; - scrollPtr->cursor = None; + scrollPtr->cursor = NULL; scrollPtr->takeFocus = NULL; scrollPtr->flags = 0; diff --git a/generic/tkScrollbar.h b/generic/tkScrollbar.h index 99f16a4..f7c39c8 100644 --- a/generic/tkScrollbar.h +++ b/generic/tkScrollbar.h @@ -123,7 +123,7 @@ typedef struct TkScrollbar { * Miscellaneous information: */ - Tk_Cursor cursor; /* Current cursor for window, or None. */ + Tk_Cursor cursor; /* Current cursor for window, or NULL. */ char *takeFocus; /* Value of -takefocus option; not used in the * C code, but used by keyboard traversal * scripts. Malloc'ed, but may be NULL. */ diff --git a/generic/tkSquare.c b/generic/tkSquare.c index 10d481b..8421988 100644 --- a/generic/tkSquare.c +++ b/generic/tkSquare.c @@ -169,7 +169,7 @@ SquareObjCmd( squarePtr->widgetCmd = Tcl_CreateObjCommand(interp, Tk_PathName(squarePtr->tkwin), SquareWidgetObjCmd, squarePtr, SquareDeletedProc); - squarePtr->gc = None; + squarePtr->gc = NULL; squarePtr->optionTable = optionTable; if (Tk_InitOptions(interp, squarePtr, optionTable, tkwin) @@ -335,7 +335,7 @@ SquareConfigure( Tk_SetWindowBackground(squarePtr->tkwin, Tk_3DBorderColor(bgBorder)->pixel); Tcl_GetBooleanFromObj(NULL, squarePtr->doubleBufferPtr, &doubleBuffer); - if ((squarePtr->gc == None) && (doubleBuffer)) { + if ((squarePtr->gc == NULL) && doubleBuffer) { XGCValues gcValues; gcValues.function = GXcopy; gcValues.graphics_exposures = False; @@ -400,7 +400,7 @@ SquareObjEventProc( if (squarePtr->tkwin != NULL) { Tk_FreeConfigOptions((char *) squarePtr, squarePtr->optionTable, squarePtr->tkwin); - if (squarePtr->gc != None) { + if (squarePtr->gc != NULL) { Tk_FreeGC(squarePtr->display, squarePtr->gc); } squarePtr->tkwin = NULL; diff --git a/generic/tkText.c b/generic/tkText.c index fb230cd..3710b31 100644 --- a/generic/tkText.c +++ b/generic/tkText.c @@ -406,7 +406,6 @@ static Tcl_Obj * TextGetText(const TkText *textPtr, static void GenerateModifiedEvent(TkText *textPtr); static void GenerateUndoStackEvent(TkText *textPtr); static void UpdateDirtyFlag(TkSharedText *sharedPtr); -static void RunAfterSyncCmd(ClientData clientData); static void TextPushUndoAction(TkText *textPtr, Tcl_Obj *undoString, int insert, const TkTextIndex *index1Ptr, @@ -587,7 +586,7 @@ CreateWidget( textPtr->state = TK_TEXT_STATE_NORMAL; textPtr->relief = TK_RELIEF_FLAT; - textPtr->cursor = None; + textPtr->cursor = NULL; textPtr->charWidth = 1; textPtr->charHeight = 10; textPtr->wrapMode = TEXT_WRAPMODE_CHAR; @@ -1544,7 +1543,7 @@ TextWidgetObjCmd( textPtr->afterSyncCmd = cmd; } else { textPtr->afterSyncCmd = cmd; - Tcl_DoWhenIdle(RunAfterSyncCmd, (ClientData) textPtr); + Tcl_DoWhenIdle(TkTextRunAfterSyncCmd, (ClientData) textPtr); } break; } else if (objc != 2) { @@ -1556,7 +1555,7 @@ TextWidgetObjCmd( Tcl_DecrRefCount(textPtr->afterSyncCmd); } textPtr->afterSyncCmd = NULL; - TkTextUpdateLineMetrics(textPtr, 1, + TkTextUpdateLineMetrics(textPtr, 0, TkBTreeNumLines(textPtr->sharedTextPtr->tree, textPtr), -1); break; } @@ -2275,7 +2274,7 @@ ConfigureText( textPtr->selTagPtr->affectsDisplay = 0; textPtr->selTagPtr->affectsDisplayGeometry = 0; if ((textPtr->selTagPtr->elideString != NULL) - || (textPtr->selTagPtr->tkfont != None) + || (textPtr->selTagPtr->tkfont != NULL) || (textPtr->selTagPtr->justifyString != NULL) || (textPtr->selTagPtr->lMargin1String != NULL) || (textPtr->selTagPtr->lMargin2String != NULL) @@ -5587,7 +5586,7 @@ UpdateDirtyFlag( /* *---------------------------------------------------------------------- * - * RunAfterSyncCmd -- + * TkTextRunAfterSyncCmd -- * * This function is called by the event loop and executes the command * scheduled by [.text sync -command $cmd]. @@ -5601,8 +5600,8 @@ UpdateDirtyFlag( *---------------------------------------------------------------------- */ -static void -RunAfterSyncCmd( +void +TkTextRunAfterSyncCmd( ClientData clientData) /* Information about text widget. */ { register TkText *textPtr = clientData; diff --git a/generic/tkText.h b/generic/tkText.h index 5e84fd5..8fb4134 100644 --- a/generic/tkText.h +++ b/generic/tkText.h @@ -677,7 +677,7 @@ typedef struct TkText { /* Color for drawing traversal highlight area * when highlight is off. */ XColor *highlightColorPtr; /* Color for drawing traversal highlight. */ - Tk_Cursor cursor; /* Current cursor for window, or None. */ + Tk_Cursor cursor; /* Current cursor for window, or NULL. */ XColor *fgColor; /* Default foreground color for text. */ Tk_Font tkfont; /* Default font for displaying text. */ int charWidth; /* Width of average character in default @@ -1080,7 +1080,7 @@ MODULE_SCOPE int TkTextGetObjIndex(Tcl_Interp *interp, TkText *textPtr, MODULE_SCOPE int TkTextSharedGetObjIndex(Tcl_Interp *interp, TkSharedText *sharedTextPtr, Tcl_Obj *idxPtr, TkTextIndex *indexPtr); -MODULE_SCOPE const TkTextIndex *TkTextGetIndexFromObj(Tcl_Interp *interp, +MODULE_SCOPE const TkTextIndex *TkTextGetIndexFromObj(Tcl_Interp *interp, TkText *textPtr, Tcl_Obj *objPtr); MODULE_SCOPE TkTextTabArray *TkTextGetTabs(Tcl_Interp *interp, TkText *textPtr, Tcl_Obj *stringPtr); @@ -1169,7 +1169,7 @@ MODULE_SCOPE int TkTextYviewCmd(TkText *textPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]); MODULE_SCOPE void TkTextWinFreeClient(Tcl_HashEntry *hPtr, TkTextEmbWindowClient *client); - +MODULE_SCOPE void TkTextRunAfterSyncCmd(ClientData clientData); #endif /* _TKTEXT */ /* diff --git a/generic/tkTextDisp.c b/generic/tkTextDisp.c index 64d455f..cb22646 100644 --- a/generic/tkTextDisp.c +++ b/generic/tkTextDisp.c @@ -491,13 +491,15 @@ static TkTextDispChunk *baseCharChunkPtr = NULL; * different character might be under the mouse * cursor now). Need to recompute the current * character before the next redisplay. + * OUT_OF_SYNC 1 means that the last <<WidgetViewSync>> event had + * value 0, indicating that the widget is out of sync. */ #define DINFO_OUT_OF_DATE 1 #define REDRAW_PENDING 2 #define REDRAW_BORDERS 4 #define REPICK_NEEDED 8 - +#define OUT_OF_SYNC 16 /* * Action values for FreeDLines: * @@ -658,7 +660,7 @@ TkTextCreateDInfo( dInfoPtr = ckalloc(sizeof(TextDInfo)); Tcl_InitHashTable(&dInfoPtr->styleTable, sizeof(StyleValues)/sizeof(int)); dInfoPtr->dLinePtr = NULL; - dInfoPtr->copyGC = None; + dInfoPtr->copyGC = NULL; gcValues.graphics_exposures = True; dInfoPtr->scrollGC = Tk_GetGC(textPtr->tkwin, GCGraphicsExposures, &gcValues); @@ -675,7 +677,7 @@ TkTextCreateDInfo( dInfoPtr->scanTotalYScroll = 0; dInfoPtr->scanMarkY = 0; dInfoPtr->dLinesInvalidated = 0; - dInfoPtr->flags = DINFO_OUT_OF_DATE; + dInfoPtr->flags = 0; dInfoPtr->topPixelOffset = 0; dInfoPtr->newTopPixelOffset = 0; dInfoPtr->currentMetricUpdateLine = -1; @@ -722,7 +724,7 @@ TkTextFreeDInfo( FreeDLines(textPtr, dInfoPtr->dLinePtr, NULL, DLINE_UNLINK); Tcl_DeleteHashTable(&dInfoPtr->styleTable); - if (dInfoPtr->copyGC != None) { + if (dInfoPtr->copyGC != NULL) { Tk_FreeGC(textPtr->display, dInfoPtr->copyGC); } Tk_FreeGC(textPtr->display, dInfoPtr->scrollGC); @@ -854,7 +856,7 @@ GetStyle( border = tagPtr->selBorder; } - if ((tagPtr->selFgColor != None) && (isSelected)) { + if ((tagPtr->selFgColor != NULL) && isSelected) { fgColor = tagPtr->selFgColor; } @@ -881,11 +883,11 @@ GetStyle( styleValues.bgStipple = tagPtr->bgStipple; bgStipplePrio = tagPtr->priority; } - if ((fgColor != None) && (tagPtr->priority > fgPrio)) { + if ((fgColor != NULL) && (tagPtr->priority > fgPrio)) { styleValues.fgColor = fgColor; fgPrio = tagPtr->priority; } - if ((tagPtr->tkfont != None) && (tagPtr->priority > fontPrio)) { + if ((tagPtr->tkfont != NULL) && (tagPtr->priority > fontPrio)) { styleValues.tkfont = tagPtr->tkfont; fontPrio = tagPtr->priority; } @@ -923,9 +925,9 @@ GetStyle( && (tagPtr->priority > overstrikePrio)) { styleValues.overstrike = tagPtr->overstrike; overstrikePrio = tagPtr->priority; - if (tagPtr->overstrikeColor != None) { + if (tagPtr->overstrikeColor != NULL) { styleValues.overstrikeColor = tagPtr->overstrikeColor; - } else if (fgColor != None) { + } else if (fgColor != NULL) { styleValues.overstrikeColor = fgColor; } } @@ -968,9 +970,9 @@ GetStyle( && (tagPtr->priority > underlinePrio)) { styleValues.underline = tagPtr->underline; underlinePrio = tagPtr->priority; - if (tagPtr->underlineColor != None) { + if (tagPtr->underlineColor != NULL) { styleValues.underlineColor = tagPtr->underlineColor; - } else if (fgColor != None) { + } else if (fgColor != NULL) { styleValues.underlineColor = fgColor; } } @@ -1017,7 +1019,7 @@ GetStyle( } stylePtr->bgGC = Tk_GetGC(textPtr->tkwin, mask, &gcValues); } else { - stylePtr->bgGC = None; + stylePtr->bgGC = NULL; } mask = GCFont; gcValues.font = Tk_FontId(styleValues.tkfont); @@ -1067,16 +1069,16 @@ FreeStyle( /* Information about style to free. */ { if (stylePtr->refCount-- <= 1) { - if (stylePtr->bgGC != None) { + if (stylePtr->bgGC != NULL) { Tk_FreeGC(textPtr->display, stylePtr->bgGC); } - if (stylePtr->fgGC != None) { + if (stylePtr->fgGC != NULL) { Tk_FreeGC(textPtr->display, stylePtr->fgGC); } - if (stylePtr->ulGC != None) { + if (stylePtr->ulGC != NULL) { Tk_FreeGC(textPtr->display, stylePtr->ulGC); } - if (stylePtr->ovGC != None) { + if (stylePtr->ovGC != NULL) { Tk_FreeGC(textPtr->display, stylePtr->ovGC); } Tcl_DeleteHashEntry(stylePtr->hPtr); @@ -2681,7 +2683,7 @@ DisplayLineBackground( if ((chunkPtr->nextPtr == NULL) && (rightX < maxX)) { rightX = maxX; } - if (chunkPtr->stylePtr->bgGC != None) { + if (chunkPtr->stylePtr->bgGC != NULL) { /* * Not visible - bail out now. */ @@ -3063,10 +3065,13 @@ AsyncUpdateLineMetrics( * We have looped over all lines, so we're done. We must release our * refCount on the widget (the timer token was already set to NULL * above). If there is a registered aftersync command, run that first. + * Cancel any pending idle task which would try to run the command + * after the afterSyncCmd pointer had been set to NULL. */ if (textPtr->afterSyncCmd) { int code; + Tcl_CancelIdleCall(TkTextRunAfterSyncCmd, textPtr); Tcl_Preserve((ClientData) textPtr->interp); code = Tcl_EvalObjEx(textPtr->interp, textPtr->afterSyncCmd, TCL_EVAL_GLOBAL); @@ -3084,7 +3089,6 @@ AsyncUpdateLineMetrics( * with its internal data (actually it will be after the next trip * through the event loop, because the widget redraws at idle-time). */ - GenerateWidgetViewSyncEvent(textPtr, 1); if (textPtr->refCount-- <= 1) { @@ -3108,8 +3112,14 @@ AsyncUpdateLineMetrics( * GenerateWidgetViewSyncEvent -- * * Send the <<WidgetViewSync>> event related to the text widget - * line metrics asynchronous update. - * This is equivalent to: + * line metrics asynchronous update. These events should only + * be sent when the sync status has changed. So this function + * compares the requested state with the state saved in the + * TkText structure, and only generates the event if they are + * different. This means that it is safe to call this function + * at any time when the state is known. + * + * If an event is sent, the effect is equivalent to: * event generate $textWidget <<WidgetViewSync>> -data $s * where $s is the sync status: true (when the widget view is in * sync with its internal data) or false (when it is not). @@ -3125,9 +3135,12 @@ AsyncUpdateLineMetrics( static void GenerateWidgetViewSyncEvent( - TkText *textPtr, /* Information about text widget. */ - Bool InSync) /* true if in sync, false otherwise */ + TkText *textPtr, /* Information about text widget. */ + Bool InSync) /* true if becoming in sync, false otherwise */ { + Bool NewSyncState = (InSync != 0); /* ensure 0 or 1 value */ + Bool OldSyncState = !(textPtr->dInfoPtr->flags & OUT_OF_SYNC); + /* * 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 @@ -3140,8 +3153,15 @@ GenerateWidgetViewSyncEvent( FORCE_DISPLAY(textPtr->tkwin); } - TkSendVirtualEvent(textPtr->tkwin, "WidgetViewSync", - Tcl_NewBooleanObj(InSync)); + if (NewSyncState != OldSyncState) { + if (NewSyncState) { + textPtr->dInfoPtr->flags &= ~OUT_OF_SYNC; + } else { + textPtr->dInfoPtr->flags |= OUT_OF_SYNC; + } + TkSendVirtualEvent(textPtr->tkwin, "WidgetViewSync", + Tcl_NewBooleanObj(NewSyncState)); + } } /* @@ -3184,6 +3204,9 @@ TkTextUpdateLineMetrics( TkTextLine *linePtr = NULL; int count = 0; int totalLines = TkBTreeNumLines(textPtr->sharedTextPtr->tree, textPtr); + int fullUpdateRequested = (lineNum == 0 && + endLine == totalLines && + doThisMuch == -1); if (totalLines == 0) { /* @@ -3194,6 +3217,7 @@ TkTextUpdateLineMetrics( } while (1) { + /* * Get a suitable line. */ @@ -3220,6 +3244,8 @@ TkTextUpdateLineMetrics( */ if (textPtr->dInfoPtr->metricEpoch == TCL_AUTO_LENGTH && lineNum == endLine) { + + /* * We have looped over all lines, so we're done. */ @@ -3243,10 +3269,12 @@ TkTextUpdateLineMetrics( if (TkBTreeLinePixelEpoch(textPtr, linePtr) == textPtr->dInfoPtr->lineMetricUpdateEpoch) { + /* * This line is already up to date. That means there's nothing * to do here. */ + } else if (doThisMuch == -1) { count += 8 * TkTextUpdateOneLine(textPtr, linePtr, 0,NULL,0); } else { @@ -3268,6 +3296,7 @@ TkTextUpdateLineMetrics( indexPtr = &textPtr->dInfoPtr->metricIndex; pixelHeight = textPtr->dInfoPtr->metricPixelHeight; } else { + /* * We must reset the partial line height calculation data * here, so we don't use it when it is out of date. @@ -3291,6 +3320,7 @@ TkTextUpdateLineMetrics( pixelHeight, indexPtr, 1); if (indexPtr->linePtr == linePtr) { + /* * We didn't complete the logical line, because it * produced very many display lines, which must be because @@ -3299,6 +3329,7 @@ TkTextUpdateLineMetrics( */ if (pixelHeight == 0) { + /* * These have already been stored, unless we just * started the new line. @@ -3320,6 +3351,7 @@ TkTextUpdateLineMetrics( textPtr->dInfoPtr->metricEpoch = -1; } } else { + /* * We must never recalculate the height of the last artificial * line. It must stay at zero, and if we recalculate it, it will @@ -3344,13 +3376,17 @@ TkTextUpdateLineMetrics( } } if (doThisMuch == -1) { + /* - * If we were requested to provide a full update, then also update the - * scrollbar. + * If we were requested to update the entire range, then also update + * the scrollbar. */ GetYView(textPtr->interp, textPtr, 1); } + if (fullUpdateRequested) { + GenerateWidgetViewSyncEvent(textPtr, 1); + } return lineNum; } @@ -3519,8 +3555,12 @@ TextInvalidateLineMetrics( textPtr->refCount++; dInfoPtr->lineUpdateTimer = Tcl_CreateTimerHandler(1, AsyncUpdateLineMetrics, textPtr); - GenerateWidgetViewSyncEvent(textPtr, 0); } + + /* + * The widget is out of sync: send a <<WidgetViewSync>> event. + */ + GenerateWidgetViewSyncEvent(textPtr, 0); } /* @@ -4537,7 +4577,7 @@ DisplayText( dlPtr->spaceAbove, dlPtr->height-dlPtr->spaceAbove-dlPtr->spaceBelow, dlPtr->baseline - dlPtr->spaceAbove, NULL, - (Drawable) None, dlPtr->y + dlPtr->spaceAbove); + None, dlPtr->y + dlPtr->spaceAbove); } } } @@ -5173,7 +5213,7 @@ TkTextRelayoutWindow( gcValues.graphics_exposures = False; newGC = Tk_GetGC(textPtr->tkwin, GCGraphicsExposures, &gcValues); - if (dInfoPtr->copyGC != None) { + if (dInfoPtr->copyGC != NULL) { Tk_FreeGC(textPtr->display, dInfoPtr->copyGC); } dInfoPtr->copyGC = newGC; @@ -5262,9 +5302,7 @@ TkTextRelayoutWindow( inSync = 0; } - if (!inSync) { - GenerateWidgetViewSyncEvent(textPtr, 0); - } + GenerateWidgetViewSyncEvent(textPtr, inSync); } } @@ -6289,11 +6327,7 @@ TkTextPendingsync( { TextDInfo *dInfoPtr = textPtr->dInfoPtr; - return ( - (!(dInfoPtr->flags & REDRAW_PENDING) && - (dInfoPtr->metricEpoch == TCL_AUTO_LENGTH) && - (dInfoPtr->lastMetricUpdateLine == dInfoPtr->currentMetricUpdateLine)) ? - 0 : 1); + return ((dInfoPtr->flags & OUT_OF_SYNC) != 0); } /* @@ -7987,7 +8021,7 @@ CharDisplayProc( */ if (!sValuePtr->elide && (numBytes > offsetBytes) - && (stylePtr->fgGC != None)) { + && (stylePtr->fgGC != NULL)) { #if TK_DRAW_IN_CONTEXT int start = ciPtr->baseOffset + offsetBytes; int len = ciPtr->numBytes - offsetBytes; diff --git a/generic/tkTextTag.c b/generic/tkTextTag.c index d04c71d..25e6af1 100644 --- a/generic/tkTextTag.c +++ b/generic/tkTextTag.c @@ -516,7 +516,7 @@ TkTextTagCmd( tagPtr->affectsDisplay = 0; tagPtr->affectsDisplayGeometry = 0; if ((tagPtr->elideString != NULL) - || (tagPtr->tkfont != None) + || (tagPtr->tkfont != NULL) || (tagPtr->justifyString != NULL) || (tagPtr->lMargin1String != NULL) || (tagPtr->lMargin2String != NULL) diff --git a/generic/tkWindow.c b/generic/tkWindow.c index 23c0891..3d91927 100644 --- a/generic/tkWindow.c +++ b/generic/tkWindow.c @@ -2089,7 +2089,7 @@ void Tk_UndefineCursor( Tk_Window tkwin) /* Window to manipulate. */ { - Tk_DefineCursor(tkwin, None); + Tk_DefineCursor(tkwin, NULL); } void diff --git a/generic/ttk/ttkClassicTheme.c b/generic/ttk/ttkClassicTheme.c index 62bf4eb..b22e5d5 100644 --- a/generic/ttk/ttkClassicTheme.c +++ b/generic/ttk/ttkClassicTheme.c @@ -6,8 +6,6 @@ */ #include "tkInt.h" -#include <X11/Xlib.h> -#include <X11/Xutil.h> #include "ttkTheme.h" #define DEFAULT_BORDERWIDTH "2" diff --git a/generic/ttk/ttkDefaultTheme.c b/generic/ttk/ttkDefaultTheme.c index 9fbcd02..002448b 100644 --- a/generic/ttk/ttkDefaultTheme.c +++ b/generic/ttk/ttkDefaultTheme.c @@ -5,8 +5,6 @@ */ #include "tkInt.h" -#include <X11/Xlib.h> -#include <X11/Xutil.h> #include "ttkTheme.h" #if defined(_WIN32) diff --git a/generic/ttk/ttkEntry.c b/generic/ttk/ttkEntry.c index 66b3418..b46b2fb 100644 --- a/generic/ttk/ttkEntry.c +++ b/generic/ttk/ttkEntry.c @@ -9,8 +9,6 @@ */ #include "tkInt.h" -#include <X11/Xatom.h> - #include "ttkTheme.h" #include "ttkWidget.h" @@ -357,7 +355,7 @@ EntryFetchSelection( ClientData clientData, int offset, char *buffer, int maxBytes) { Entry *entryPtr = clientData; - size_t byteCount; + int byteCount; const char *string; const char *selStart, *selEnd; @@ -371,7 +369,7 @@ EntryFetchSelection( selEnd = Tcl_UtfAtIndex(selStart, entryPtr->entry.selectLast - entryPtr->entry.selectFirst); byteCount = selEnd - selStart - offset; - if (byteCount > (size_t)maxBytes) { + if (byteCount > maxBytes) { /* @@@POSSIBLE BUG: Can transfer partial UTF-8 sequences. Is this OK? */ byteCount = maxBytes; } @@ -1179,7 +1177,7 @@ static GC EntryGetGC(Entry *entryPtr, Tcl_Obj *colorObj, TkRegion clip) mask |= GCForeground; } gc = Tk_GetGC(entryPtr->core.tkwin, mask, &gcValues); - if (clip != None) { + if (clip != NULL) { TkSetRegion(Tk_Display(entryPtr->core.tkwin), gc, clip); } return gc; @@ -1290,7 +1288,7 @@ static void EntryDisplay(void *clientData, Drawable d) cursorX = field.x + field.width - cursorWidth; } - gc = EntryGetGC(entryPtr, es.insertColorObj, None); + gc = EntryGetGC(entryPtr, es.insertColorObj, NULL); XFillRectangle(Tk_Display(tkwin), d, gc, cursorX, cursorY, cursorWidth, cursorHeight); Tk_FreeGC(Tk_Display(tkwin), gc); @@ -1336,7 +1334,7 @@ static void EntryDisplay(void *clientData, Drawable d) * it from the Xft guts (if they're being used). */ #ifdef HAVE_XFT - TkUnixSetXftClipRegion(None); + TkUnixSetXftClipRegion(NULL); #endif TkDestroyRegion(clipRegion); } diff --git a/generic/ttk/ttkLabel.c b/generic/ttk/ttkLabel.c index de530e9..2367f99 100644 --- a/generic/ttk/ttkLabel.c +++ b/generic/ttk/ttkLabel.c @@ -182,7 +182,7 @@ static void TextDraw(TextElement *text, Tk_Window tkwin, Drawable d, Ttk_Box b) if (clipRegion != NULL) { #ifdef HAVE_XFT - TkUnixSetXftClipRegion(None); + TkUnixSetXftClipRegion(NULL); #endif XSetClipMask(Tk_Display(tkwin), gc1, None); XSetClipMask(Tk_Display(tkwin), gc2, None); diff --git a/generic/ttk/ttkState.c b/generic/ttk/ttkState.c index 7ac6740..9e5cf4b 100644 --- a/generic/ttk/ttkState.c +++ b/generic/ttk/ttkState.c @@ -129,7 +129,7 @@ static void StateSpecUpdateString(Tcl_Obj *objPtr) unsigned int mask = onbits | offbits; Tcl_DString result; int i; - size_t len; + int len; Tcl_DStringInit(&result); @@ -145,14 +145,14 @@ static void StateSpecUpdateString(Tcl_Obj *objPtr) len = Tcl_DStringLength(&result); if (len) { /* 'len' includes extra trailing ' ' */ - objPtr->bytes = Tcl_Alloc(len); + objPtr->bytes = ckalloc(len); objPtr->length = len-1; strncpy(objPtr->bytes, Tcl_DStringValue(&result), len-1); objPtr->bytes[len-1] = '\0'; } else { /* empty string */ objPtr->length = 0; - objPtr->bytes = Tcl_Alloc(1); + objPtr->bytes = ckalloc(1); *objPtr->bytes = '\0'; } diff --git a/library/demos/dialog1.tcl b/library/demos/dialog1.tcl index 5c572be..976e955 100644 --- a/library/demos/dialog1.tcl +++ b/library/demos/dialog1.tcl @@ -2,8 +2,16 @@ # # This demonstration script creates a dialog box with a local grab. +interp create slave +load {} Tk slave +slave eval { + wm title . slave + wm geometry . +700+30 + pack [text .t -width 30 -height 10] +} + after idle {.dialog1.msg configure -wraplength 4i} -set i [tk_dialog .dialog1 "Dialog with local grab" {This is a modal dialog box. It uses Tk's "grab" command to create a "local grab" on the dialog box. The grab prevents any pointer-related events from getting to any other windows in the application until you have answered the dialog by invoking one of the buttons below. However, you can still interact with other applications.} \ +set i [tk_dialog .dialog1 "Dialog with local grab" {This is a modal dialog box. It uses Tk's "grab" command to create a "local grab" on the dialog box. The grab prevents any mouse or keyboard events from getting to any other windows in the application until you have answered the dialog by invoking one of the buttons below. However, you can still interact with other applications. For example, you should be able to edit text in the window named "slave" which was created by a slave interpreter.} \ info 0 OK Cancel {Show Code}] switch $i { @@ -11,3 +19,7 @@ switch $i { 1 {puts "You pressed Cancel"} 2 {showCode .dialog1} } + +if {[interp exists slave]} { + interp delete slave +} diff --git a/library/demos/dialog2.tcl b/library/demos/dialog2.tcl index 2f45da8..6ae27a8 100644 --- a/library/demos/dialog2.tcl +++ b/library/demos/dialog2.tcl @@ -8,7 +8,8 @@ after idle { after 100 { grab -global .dialog2 } -set i [tk_dialog .dialog2 "Dialog with global grab" {This dialog box uses a global grab, so it prevents you from interacting with anything on your display until you invoke one of the buttons below. Global grabs are almost always a bad idea; don't use them unless you're truly desperate.} warning 0 OK Cancel {Show Code}] +set i [tk_dialog .dialog2 "Dialog with global grab" {This dialog box uses a global grab. If you are using an X11 window manager you will be prevented from interacting with anything on your display until you invoke one of the buttons below. This is almost always a bad idea; don't use global grabs with X11 unless you're truly desperate. On macOS systems you will not be able to interact with any window belonging to this process, but interaction with other macOS Applications will still be possible.}\ +warning 0 OK Cancel {Show Code}] switch $i { 0 {puts "You pressed OK"} diff --git a/macosx/README b/macosx/README index 6c38dbc..1f5d8a1 100644 --- a/macosx/README +++ b/macosx/README @@ -652,7 +652,7 @@ conditional code which is only used for macOS. 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. +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/tkMacOSXDefault.h b/macosx/tkMacOSXDefault.h index ce41751..c85fcdb 100644 --- a/macosx/tkMacOSXDefault.h +++ b/macosx/tkMacOSXDefault.h @@ -37,7 +37,7 @@ #define ACTIVE_BG "systemButtonFacePressed" #define ACTIVE_FG "systemPushButtonPressedText" #define SELECT_BG "systemHighlight" -#define SELECT_FG None +#define SELECT_FG NULL #define INACTIVE_SELECT_BG "systemHighlightSecondary" #define TROUGH "#c3c3c3" #define INDICATOR "#b03060" @@ -284,7 +284,7 @@ #define DEF_MENU_ENTRY_ACTIVE_FG NULL #define DEF_MENU_ENTRY_ACCELERATOR NULL #define DEF_MENU_ENTRY_BG NULL -#define DEF_MENU_ENTRY_BITMAP None +#define DEF_MENU_ENTRY_BITMAP NULL #define DEF_MENU_ENTRY_COLUMN_BREAK "0" #define DEF_MENU_ENTRY_COMMAND NULL #define DEF_MENU_ENTRY_COMPOUND "none" diff --git a/macosx/tkMacOSXDialog.c b/macosx/tkMacOSXDialog.c index e828b39..c3778f1 100644 --- a/macosx/tkMacOSXDialog.c +++ b/macosx/tkMacOSXDialog.c @@ -1194,12 +1194,12 @@ TkAboutDlg(void) NSString *year = [dateFormatter stringFromDate:[NSDate date]]; [dateFormatter release]; - + /* * 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 *url = @"www.tcl-lang.org"; NSTextView *credits = [[NSTextView alloc] initWithFrame:NSMakeRect(0,0,300,300)]; diff --git a/macosx/tkMacOSXEmbed.c b/macosx/tkMacOSXEmbed.c index 05bf832..f093c96 100644 --- a/macosx/tkMacOSXEmbed.c +++ b/macosx/tkMacOSXEmbed.c @@ -494,7 +494,7 @@ TkMacOSXContainerId( } } Tcl_Panic("TkMacOSXContainerId couldn't find window"); - return None; + return NULL; } /* @@ -530,8 +530,8 @@ TkMacOSXGetHostToplevel( * TODO: Here we should handle out of process embedding. */ - if (contWinPtr == NULL) { - return None; + if (!contWinPtr) { + return NULL; } return TkMacOSXGetHostToplevel(contWinPtr); } diff --git a/macosx/tkMacOSXEntry.c b/macosx/tkMacOSXEntry.c index 4ab3111..a1c5d60 100644 --- a/macosx/tkMacOSXEntry.c +++ b/macosx/tkMacOSXEntry.c @@ -156,10 +156,10 @@ TkpDrawEntryBorderAndFocus( 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; diff --git a/macosx/tkMacOSXHLEvents.c b/macosx/tkMacOSXHLEvents.c index 468e41c..9b874a5 100644 --- a/macosx/tkMacOSXHLEvents.c +++ b/macosx/tkMacOSXHLEvents.c @@ -93,12 +93,7 @@ static int ReallyKillMe(Tcl_Event *eventPtr, int flags); - (void) handleReopenApplicationEvent: (NSAppleEventDescriptor *)event withReplyEvent: (NSAppleEventDescriptor *)replyEvent { -#if MAC_OS_X_VERSION_MIN_REQUIRED < 1090 - ProcessSerialNumber thePSN = {0, kCurrentProcess}; - SetFrontProcess(&thePSN); -#else - [[NSApplication sharedApplication] activateIgnoringOtherApps: YES]; -#endif + [NSApp activateIgnoringOtherApps: YES]; if (_eventInterp && Tcl_FindCommand(_eventInterp, "::tk::mac::ReopenApplication", NULL, 0)) { int code = Tcl_EvalEx(_eventInterp, "::tk::mac::ReopenApplication", diff --git a/macosx/tkMacOSXImage.c b/macosx/tkMacOSXImage.c index 0c9fcb3..38f4a70 100644 --- a/macosx/tkMacOSXImage.c +++ b/macosx/tkMacOSXImage.c @@ -100,7 +100,7 @@ TkMacOSXCreateCGImageWithXImage( /* * CGCreateImage complains on early macOS releases. */ - + return NULL; } bitsPerComponent = 8; diff --git a/macosx/tkMacOSXInit.c b/macosx/tkMacOSXInit.c index 65534ae..5f64a4a 100644 --- a/macosx/tkMacOSXInit.c +++ b/macosx/tkMacOSXInit.c @@ -373,7 +373,7 @@ TkpInit( * 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; diff --git a/macosx/tkMacOSXKeyEvent.c b/macosx/tkMacOSXKeyEvent.c index a153797..3327f0a 100644 --- a/macosx/tkMacOSXKeyEvent.c +++ b/macosx/tkMacOSXKeyEvent.c @@ -139,18 +139,26 @@ unsigned short releaseCode; } /* - * The focus must be in the FrontWindow on the Macintosh. We then query Tk - * to determine the exact Tk window that owns the focus. + * Events are only received for the front Window on the Macintosh. + * So to build an XEvent we look up the Tk window associated to the + * Front window. If a different window has a local grab we ignore + * the event. */ TkWindow *winPtr = TkMacOSXGetTkWindow(w); Tk_Window tkwin = (Tk_Window) winPtr; - if (!tkwin) { - TkMacOSXDbgMsg("tkwin == NULL"); - return theEvent; - } - tkwin = (Tk_Window) winPtr->dispPtr->focusPtr; + if (tkwin) { + TkWindow *grabWinPtr = winPtr->dispPtr->grabWinPtr; + if (grabWinPtr && + grabWinPtr != winPtr && + !winPtr->dispPtr->grabFlags && /* this means the grab is local. */ + grabWinPtr->mainPtr == winPtr->mainPtr) { + return theEvent; + } + } else { + tkwin = (Tk_Window) winPtr->dispPtr->focusPtr; + } if (!tkwin) { TkMacOSXDbgMsg("tkwin == NULL"); return theEvent; /* Give up. No window for this event. */ @@ -160,6 +168,7 @@ unsigned short releaseCode; * If it's a function key, or we have modifiers other than Shift or Alt, * pass it straight to Tk. Otherwise we'll send for input processing. */ + int code = (len == 0) ? 0 : [charactersIgnoringModifiers characterAtIndex: 0]; if (type != NSKeyDown || isFunctionKey(code) diff --git a/macosx/tkMacOSXMenu.c b/macosx/tkMacOSXMenu.c index ec32a78..8f3be9f 100644 --- a/macosx/tkMacOSXMenu.c +++ b/macosx/tkMacOSXMenu.c @@ -1481,10 +1481,10 @@ TkpMenuInit(void) #undef observe [NSMenuItem setUsesUserKeyEquivalents:NO]; - tkColPtr = TkpGetColor(None, DEF_MENU_BG_COLOR); + tkColPtr = TkpGetColor(NULL, DEF_MENU_BG_COLOR); defaultBg = tkColPtr->color.pixel; ckfree(tkColPtr); - tkColPtr = TkpGetColor(None, DEF_MENU_FG); + tkColPtr = TkpGetColor(NULL, DEF_MENU_FG); defaultFg = tkColPtr->color.pixel; ckfree(tkColPtr); diff --git a/macosx/tkMacOSXMouseEvent.c b/macosx/tkMacOSXMouseEvent.c index 828d874..7b83679 100644 --- a/macosx/tkMacOSXMouseEvent.c +++ b/macosx/tkMacOSXMouseEvent.c @@ -106,23 +106,32 @@ enum { } } - Window window = TkMacOSXGetXWindow(eventWindow); - Tk_Window tkwin = window ? Tk_IdToWindow(TkGetDisplayList()->display, - window) : NULL; - if (!tkwin) { + TkWindow *winPtr = TkMacOSXGetTkWindow(eventWindow); + Tk_Window tkwin = (Tk_Window) winPtr; + + if (tkwin) { + TkWindow *grabWinPtr = winPtr->dispPtr->grabWinPtr; + if (grabWinPtr && + grabWinPtr != winPtr && + !winPtr->dispPtr->grabFlags && /* this means the grab is local. */ + grabWinPtr->mainPtr == winPtr->mainPtr) { + return theEvent; + } + } else { tkwin = TkMacOSXGetCapture(); } if (!tkwin) { + TkMacOSXDbgMsg("tkwin == NULL"); return theEvent; /* Give up. No window for this event. */ + } else { + winPtr = (TkWindow *)tkwin; } - TkWindow *winPtr = (TkWindow *) tkwin; local.x -= winPtr->wmInfoPtr->xInParent; local.y -= winPtr->wmInfoPtr->yInParent; int win_x, win_y; - tkwin = Tk_TopCoordsToWindow(tkwin, local.x, local.y, - &win_x, &win_y); + tkwin = Tk_TopCoordsToWindow(tkwin, local.x, local.y, &win_x, &win_y); unsigned int state = 0; NSInteger button = [theEvent buttonNumber]; diff --git a/macosx/tkMacOSXNotify.c b/macosx/tkMacOSXNotify.c index 88e7c76..3a32527 100644 --- a/macosx/tkMacOSXNotify.c +++ b/macosx/tkMacOSXNotify.c @@ -84,7 +84,7 @@ InspectQueueRestrictProc( const char *name; long serial = ve->serial; long time = eventPtr->xkey.time; - + if (eventPtr->type == VirtualEvent) { name = ve->name; } else { @@ -137,14 +137,14 @@ void DebugPrintQueue(void) /* * Since the contentView is the first responder for a Tk Window, it is * responsible for sending events up the responder chain. We also check - * the pasteboard here. + * the pasteboard here. */ - (void) sendEvent: (NSEvent *) theEvent { [super sendEvent:theEvent]; [NSApp tkCheckPasteboard]; #ifdef TK_MAC_DEBUG_EVENTS - fprintf(stderr, "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/tkMacOSXPrivate.h b/macosx/tkMacOSXPrivate.h index 27fe6d8..105317d 100644 --- a/macosx/tkMacOSXPrivate.h +++ b/macosx/tkMacOSXPrivate.h @@ -342,7 +342,7 @@ VISIBILITY_HIDDEN @interface TKContentView(TKWindowEvent) - (void) drawRect: (NSRect) rect; -- (void) generateExposeEvents: (HIShapeRef) shape; +- (void) generateExposeEvents: (HIShapeRef) shape; - (void) tkToolbarButton: (id) sender; - (BOOL) isOpaque; - (BOOL) wantsDefaultClipping; diff --git a/macosx/tkMacOSXScrlbr.c b/macosx/tkMacOSXScrlbr.c index d1287bb..4a108db 100644 --- a/macosx/tkMacOSXScrlbr.c +++ b/macosx/tkMacOSXScrlbr.c @@ -48,7 +48,7 @@ typedef struct MacScrollbar { 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 buttonDown; /* Is the mouse button down? */ Bool mouseOver; /* Is the pointer over the scrollbar. */ HIThemeTrackDrawInfo info; /* Controls how the scrollbar is drawn. */ } MacScrollbar; @@ -119,11 +119,11 @@ TkpCreateScrollbar( MacScrollbar *scrollPtr = (MacScrollbar *)ckalloc(sizeof(MacScrollbar)); - scrollPtr->troughGC = None; - scrollPtr->copyGC = None; + scrollPtr->troughGC = NULL; + scrollPtr->copyGC = NULL; scrollPtr->info = defaultInfo; scrollPtr->buttonDown = false; - + Tk_CreateEventHandler(tkwin, ExposureMask | StructureNotifyMask | @@ -561,7 +561,7 @@ static int 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 diff --git a/macosx/tkMacOSXSubwindows.c b/macosx/tkMacOSXSubwindows.c index 0f9214f..7bc807a 100644 --- a/macosx/tkMacOSXSubwindows.c +++ b/macosx/tkMacOSXSubwindows.c @@ -157,11 +157,15 @@ XMapWindow( * the app to activate too early can make the menu bar * unresponsive. */ + TkMacOSXApplyWindowAttributes(macWin->winPtr, win); + [win setExcludedFromWindowsMenu:NO]; [NSApp activateIgnoringOtherApps:NO]; + [[win contentView] setNeedsDisplay:YES]; if ( [win canBecomeKeyWindow] ) { [win makeKeyAndOrderFront:NSApp]; + } else { + [win orderFrontRegardless]; } - TkMacOSXApplyWindowAttributes(macWin->winPtr, win); } else { /* * Rebuild the container's clipping region and display diff --git a/macosx/tkMacOSXWindowEvent.c b/macosx/tkMacOSXWindowEvent.c index b234e72..ad6af30 100644 --- a/macosx/tkMacOSXWindowEvent.c +++ b/macosx/tkMacOSXWindowEvent.c @@ -31,7 +31,7 @@ */ static int GenerateUpdates(HIShapeRef updateRgn, - CGRect *updateBounds, TkWindow *winPtr); + CGRect *updateBounds, TkWindow *winPtr); static int GenerateActivateEvents(TkWindow *winPtr, int activeFlag); static void DoWindowActivate(ClientData clientData); @@ -69,18 +69,19 @@ extern NSString *NSWindowDidOrderOffScreenNotification; #endif BOOL movedOnly = [[notification name] isEqualToString:NSWindowDidMoveNotification]; - NSWindow *w = [notification object]; TkWindow *winPtr = TkMacOSXGetTkWindow(w); if (winPtr) { WmInfo *wmPtr = winPtr->wmInfoPtr; NSRect bounds = [w frame]; + NSRect screenRect = [[w screen] frame]; int x, y, width = -1, height = -1, flags = 0; + int minY = 1 + [[NSApp mainMenu] menuBarHeight]; x = bounds.origin.x; - y = tkMacOSXZeroScreenHeight - (bounds.origin.y + bounds.size.height); - if (winPtr->changes.x != x || winPtr->changes.y != y){ + y = screenRect.size.height - (bounds.origin.y + bounds.size.height); + if (winPtr->changes.x != x || winPtr->changes.y != y) { flags |= TK_LOCATION_CHANGED; } else { x = y = -1; @@ -99,8 +100,24 @@ extern NSString *NSWindowDidOrderOffScreenNotification; flags |= TK_MACOSX_HANDLE_EVENT_IMMEDIATELY; } + + /* + * Mac windows cannot go higher than the bottom of the menu bar. The + * Tk window manager can request that a window be drawn so that it + * overlaps the menu bar, but it will actually be drawn immediately + * below the menu bar. In such a case it saves a lot of trouble and + * causes no harm if we let Tk think that the window is located at the + * requested point. (Many of the the tests assume that this is the + * case, especially for windows with upper left corner at (0,0).) So + * we just tell a harmless white lie here. + */ + + if (y == minY && wmPtr->y < minY) { + y = wmPtr->y; + } TkGenWMConfigureEvent((Tk_Window) winPtr, x, y, width, height, flags); } + } - (void) windowExpanded: (NSNotification *) notification @@ -136,6 +153,19 @@ extern NSString *NSWindowDidOrderOffScreenNotification; } } +- (NSRect)windowWillUseStandardFrame:(NSWindow *)window + defaultFrame:(NSRect)newFrame +{ + + /* + * This method needs to be implemented in order for [NSWindow isZoomed] + * to give the correct answer. But it suffices to always validate + * every request. + */ + + return newFrame; +} + - (NSSize)window:(NSWindow *)window willUseFullScreenContentSize:(NSSize)proposedSize { @@ -146,7 +176,6 @@ extern NSString *NSWindowDidOrderOffScreenNotification; * be sized to the screen's visibleFrame, leaving black bands at * the top and bottom. */ - return proposedSize; } @@ -297,6 +326,20 @@ extern NSString *NSWindowDidOrderOffScreenNotification; #endif } +- (BOOL)applicationShouldHandleReopen:(NSApplication *)sender + hasVisibleWindows:(BOOL)flag +{ + /* + * Allowing the default response means that withdrawn windows will get + * displayed on the screen with unresponsive title buttons. We don't + * really want that. Besides, we can write our own code to handle this + * with ::tk::mac::ReopenApplication. So we just say NO. + */ + + return NO; +} + + - (void) applicationShowHide: (NSNotification *) notification { #ifdef TK_MAC_DEBUG_NOTIFICATIONS @@ -637,7 +680,7 @@ TkGenWMConfigureEvent( if (flags & TK_LOCATION_CHANGED) { wmPtr->x = x; wmPtr->y = y; - wmPtr->flags &= ~(WM_NEGATIVE_X | WM_NEGATIVE_Y); + //wmPtr->flags &= ~(WM_NEGATIVE_X | WM_NEGATIVE_Y); } if ((flags & TK_SIZE_CHANGED) && !(wmPtr->flags & WM_SYNC_PENDING) && ((width != Tk_Width(tkwin)) || (height != Tk_Height(tkwin)))) { @@ -680,6 +723,7 @@ TkGenWMConfigureEvent( } } + /* * Now set up the changes structure. Under X we wait for the * ConfigureNotify to set these values. On the Mac we know imediatly that @@ -968,7 +1012,7 @@ ConfigureRestrictProc( /* * Finally, unlock the main autoreleasePool. */ - + [NSApp _unlockAutoreleasePool]; } } diff --git a/macosx/tkMacOSXWm.c b/macosx/tkMacOSXWm.c index 4a85551..a839ab2 100644 --- a/macosx/tkMacOSXWm.c +++ b/macosx/tkMacOSXWm.c @@ -152,13 +152,13 @@ static const struct { typedef enum { WMATT_ALPHA, WMATT_FULLSCREEN, WMATT_MODIFIED, WMATT_NOTIFY, WMATT_TITLEPATH, WMATT_TOPMOST, WMATT_TRANSPARENT, - _WMATT_LAST_ATTRIBUTE + WMATT_TYPE, _WMATT_LAST_ATTRIBUTE } WmAttribute; static const char *const WmAttributeNames[] = { "-alpha", "-fullscreen", "-modified", "-notify", "-titlepath", "-topmost", "-transparent", - NULL + "-type", NULL }; /* @@ -389,7 +389,7 @@ static void RemapWindows(TkWindow *winPtr, */ if ([self styleMask] & NSFullScreenWindowMask) { - frameRect = [NSWindow frameRectForContentRect:NSZeroRect + frameRect = [NSWindow frameRectForContentRect:NSZeroRect styleMask:[self styleMask]]; } else { frameRect = [self frameRectForContentRect:NSZeroRect]; @@ -414,7 +414,6 @@ static void RemapWindows(TkWindow *winPtr, } #endif - - (NSSize)windowWillResize:(NSWindow *)sender toSize:(NSSize)frameSize { @@ -595,7 +594,8 @@ SetWindowSizeLimits( * * FrontWindowAtPoint -- * - * Find frontmost toplevel window at a given screen location. + * Find frontmost toplevel window at a given screen location which has the + * specified mainPtr. If the location is in the title bar, return NULL. * * Results: * TkWindow*. @@ -608,7 +608,8 @@ SetWindowSizeLimits( static TkWindow* FrontWindowAtPoint( - int x, int y) + int x, + int y) { NSPoint p = NSMakePoint(x, tkMacOSXZeroScreenHeight - y); NSArray *windows = [NSApp orderedWindows]; @@ -616,11 +617,28 @@ FrontWindowAtPoint( for (NSWindow *w in windows) { winPtr = TkMacOSXGetTkWindow(w); - if (winPtr && NSMouseInRect(p, [w frame], NO)) { - break; + if (winPtr) { + WmInfo *wmPtr = winPtr->wmInfoPtr; + NSRect windowFrame = [w frame]; + NSRect contentFrame = [w frame]; + contentFrame.size.height = [[w contentView] frame].size.height; + /* + * For consistency with other platforms, points in the + * title bar are not considered to be contained in the + * window. + */ + + if ((wmPtr->hints.initial_state == NormalState || + wmPtr->hints.initial_state == ZoomState)) { + if (NSMouseInRect(p, contentFrame, NO)) { + return winPtr; + } else if (NSMouseInRect(p, windowFrame, NO)) { + return NULL; + } + } } } - return winPtr; + return NULL; } /* @@ -815,10 +833,6 @@ TkWmMapWindow( */ XMapWindow(winPtr->display, winPtr->window); - - /*Add window to Window menu.*/ - NSWindow *win = TkMacOSXDrawableWindow(winPtr->window); - [win setExcludedFromWindowsMenu:NO]; } /* @@ -935,7 +949,8 @@ TkWmDeadWindow( if (title == nil) { title = "unnamed window"; } - printf(">>>> Closing <%s>. Count is: %lu\n", title, [window retainCount]); + fprintf(stderr, ">>>> Closing <%s>. Count is: %lu\n", title, + [window retainCount]); } #endif [window close]; @@ -1301,7 +1316,7 @@ WmSetAttribute( #if !(MAC_OS_X_VERSION_MAX_ALLOWED < 1070) [macWindow toggleFullScreen:macWindow]; #else - TKLog(@"The fullscreen attribute is ignored on this system.."); + TKLog(@"The fullscreen attribute is ignored on this system."); #endif } break; @@ -1379,6 +1394,9 @@ WmSetAttribute( TK_PARENT_WINDOW); } break; + case WMATT_TYPE: + TKLog(@"The type attribute is ignored on macOS."); + break; case _WMATT_LAST_ATTRIBUTE: default: return TCL_ERROR; @@ -1429,6 +1447,9 @@ WmGetAttribute( case WMATT_TRANSPARENT: result = Tcl_NewBooleanObj(wmPtr->flags & WM_TRANSPARENT); break; + case WMATT_TYPE: + result = Tcl_NewStringObj("unsupported", -1); + break; case _WMATT_LAST_ATTRIBUTE: default: break; @@ -1736,6 +1757,7 @@ WmDeiconifyCmd( Tcl_Obj *const objv[]) /* Argument objects. */ { register WmInfo *wmPtr = winPtr->wmInfoPtr; + NSWindow *win = TkMacOSXDrawableWindow(winPtr->window); if (objc != 3) { Tcl_WrongNumArgs(interp, 2, objv, "window"); @@ -1758,6 +1780,12 @@ WmDeiconifyCmd( TkpWmSetState(winPtr, TkMacOSXIsWindowZoomed(winPtr) ? ZoomState : NormalState); + [win setExcludedFromWindowsMenu:NO]; + TkMacOSXApplyWindowAttributes(winPtr, win); + [win orderFront:nil]; + if (wmPtr->icon) { + Tk_UnmapWindow((Tk_Window)wmPtr->icon); + } return TCL_OK; } @@ -1947,8 +1975,9 @@ WmGeometryCmd( Tcl_Obj *const objv[]) /* Argument objects. */ { register WmInfo *wmPtr = winPtr->wmInfoPtr; - char xSign, ySign; - int width, height; + NSWindow *win = TkMacOSXDrawableWindow(winPtr->window); + char xSign = '+', ySign = '+'; + int width, height, x = wmPtr->x, y= wmPtr->y; char *argv3; if ((objc != 3) && (objc != 4)) { @@ -1956,8 +1985,6 @@ WmGeometryCmd( return TCL_ERROR; } if (objc == 3) { - xSign = (wmPtr->flags & WM_NEGATIVE_X) ? '-' : '+'; - ySign = (wmPtr->flags & WM_NEGATIVE_Y) ? '-' : '+'; if (wmPtr->gridWin != NULL) { width = wmPtr->reqGridWidth + (winPtr->changes.width - winPtr->reqWidth)/wmPtr->widthInc; @@ -1967,8 +1994,20 @@ WmGeometryCmd( width = winPtr->changes.width; height = winPtr->changes.height; } + if (win) { + if (wmPtr->flags & WM_NEGATIVE_X) { + xSign = '-'; + x = wmPtr->vRootWidth - wmPtr->x + - (width + (wmPtr->parentWidth - winPtr->changes.width)); + } + if (wmPtr->flags & WM_NEGATIVE_Y) { + ySign = '-'; + y = wmPtr->vRootHeight - wmPtr->y + - (height + (wmPtr->parentHeight - winPtr->changes.height)); + } + } Tcl_SetObjResult(interp, Tcl_ObjPrintf("%dx%d%c%d%c%d", - width, height, xSign, wmPtr->x, ySign, wmPtr->y)); + width, height, xSign, x, ySign, y)); return TCL_OK; } argv3 = Tcl_GetString(objv[3]); @@ -2266,6 +2305,9 @@ WmIconifyCmd( } TkpWmSetState(winPtr, IconicState); + if (wmPtr->icon) { + Tk_MapWindow((Tk_Window)wmPtr->icon); + } return TCL_OK; } @@ -2584,8 +2626,17 @@ WmIconwindowCmd( return TCL_ERROR; } if (wmPtr->icon != NULL) { - WmInfo *wmPtr3 = ((TkWindow *) wmPtr->icon)->wmInfoPtr; + TkWindow *oldIcon = (TkWindow *)wmPtr->icon; + WmInfo *wmPtr3 = oldIcon->wmInfoPtr; + NSWindow *win = TkMacOSXDrawableWindow(oldIcon->window); + + /* + * The old icon should be withdrawn. + */ + TkpWmSetState(oldIcon, WithdrawnState); + [win orderOut:nil]; + [win setExcludedFromWindowsMenu:YES]; wmPtr3->iconFor = NULL; } Tk_MakeWindowExist(tkwin2); @@ -2594,11 +2645,16 @@ WmIconwindowCmd( wmPtr->icon = tkwin2; wmPtr2->iconFor = (Tk_Window) winPtr; if (!(wmPtr2->flags & WM_NEVER_MAPPED)) { + /* - * Don't have iconwindows on the Mac. We just withdraw. + * If the window is in normal or zoomed state, the icon should be + * unmapped. */ - Tk_UnmapWindow(tkwin2); + if (wmPtr->hints.initial_state == NormalState || + wmPtr->hints.initial_state == ZoomState) { + Tk_UnmapWindow(tkwin2); + } } } return TCL_OK; @@ -2802,8 +2858,9 @@ WmOverrideredirectCmd( int objc, /* Number of arguments. */ Tcl_Obj *const objv[]) /* Argument objects. */ { - int boolean; + int flag; XSetWindowAttributes atts; + TKWindow *win = (TKWindow *)TkMacOSXDrawableWindow(winPtr->window); if ((objc != 3) && (objc != 4)) { Tcl_WrongNumArgs(interp, 2, objv, "window ?boolean?"); @@ -2816,12 +2873,12 @@ WmOverrideredirectCmd( return TCL_OK; } - if (Tcl_GetBooleanFromObj(interp, objv[3], &boolean) != TCL_OK) { + if (Tcl_GetBooleanFromObj(interp, objv[3], &flag) != TCL_OK) { return TCL_ERROR; } - atts.override_redirect = (boolean) ? True : False; + atts.override_redirect = flag ? True : False; Tk_ChangeWindowAttributes((Tk_Window) winPtr, CWOverrideRedirect, &atts); - ApplyMasterOverrideChanges(winPtr, NULL); + ApplyMasterOverrideChanges(winPtr, win); return TCL_OK; } @@ -3477,6 +3534,7 @@ WmTransientCmd( } TkWindow* masterPtr = (TkWindow*) master; while (!Tk_TopWinHierarchy(masterPtr)) { + /* * Ensure that the master window is actually a Tk toplevel. */ @@ -3563,8 +3621,8 @@ WmWithdrawCmd( return TCL_ERROR; } TkpWmSetState(winPtr, WithdrawnState); - /*Remove window from Window menu.*/ NSWindow *win = TkMacOSXDrawableWindow(winPtr->window); + [win orderOut:nil]; [win setExcludedFromWindowsMenu:YES]; return TCL_OK; @@ -3947,27 +4005,8 @@ UpdateGeometryInfo( } else if ((max > 0) && (height > max)) { height = max; } - - /* - * Compute the new position for the upper-left pixel of the window's - * decorative frame. This is tricky, because we need to include the border - * widths supplied by a reparented parent in this calculation, but can't - * use the parent's current overall size since that may change as a result - * of this code. - */ - - if (wmPtr->flags & WM_NEGATIVE_X) { - x = wmPtr->vRootWidth - wmPtr->x - - (width + (wmPtr->parentWidth - winPtr->changes.width)); - } else { - x = wmPtr->x; - } - if (wmPtr->flags & WM_NEGATIVE_Y) { - y = wmPtr->vRootHeight - wmPtr->y - - (height + (wmPtr->parentHeight - winPtr->changes.height)); - } else { - y = wmPtr->y; - } + x = wmPtr->x; + y = wmPtr->y; /* * If the window's size is going to change and the window is supposed to @@ -4128,8 +4167,8 @@ ParseGeometry( width = wmPtr->width; height = wmPtr->height; - x = wmPtr->x; - y = wmPtr->y; + x = -1; + y = -1; flags = wmPtr->flags; if (isdigit(UCHAR(*p))) { width = strtoul(p, &end, 10); @@ -4193,24 +4232,45 @@ ParseGeometry( * Everything was parsed OK. Update the fields of *wmPtr and arrange for * the appropriate information to be percolated out to the window manager * at the next idle moment. + * + * Computing the new position for the upper-left pixel of the window's + * decorative frame is tricky because we need to include the border + * widths supplied by a reparented parent in the calculation, but we can't + * use the parent's current overall size since that may change as a result + * of this code. */ wmPtr->width = width; wmPtr->height = height; - if ((x != wmPtr->x) || (y != wmPtr->y) - || ((flags & (WM_NEGATIVE_X|WM_NEGATIVE_Y)) - != (wmPtr->flags & (WM_NEGATIVE_X|WM_NEGATIVE_Y)))) { - if (wmPtr->flags & WM_FULLSCREEN) { - wmPtr->configX = x; - wmPtr->configY = y; - } else { - wmPtr->x = x; - wmPtr->y = y; - } - flags |= WM_MOVE_PENDING; + if (flags & WM_NEGATIVE_X) { + int borderwidth = wmPtr->parentWidth - winPtr->changes.width; + int newWidth = width == -1 ? winPtr->changes.width : width; + x = (x == -1) ? + wmPtr->x + winPtr->changes.width - newWidth : + wmPtr->vRootWidth - x - newWidth - borderwidth; + } + if (x == -1) { + x = wmPtr->x; + } + if (flags & WM_NEGATIVE_Y) { + int borderheight = wmPtr->parentHeight - winPtr->changes.height; + int newHeight = height == -1 ? winPtr->changes.height : height; + y = (y == -1) ? + wmPtr->y + winPtr->changes.height - newHeight : + wmPtr->vRootHeight - y - newHeight - borderheight; + } + if (y == -1) { + y = wmPtr->y; + } + if (wmPtr->flags & WM_FULLSCREEN) { + wmPtr->configX = x; + wmPtr->configY = y; + } else { + wmPtr->x = x; + wmPtr->y = y; } + flags |= WM_MOVE_PENDING; wmPtr->flags = flags; - if (!(wmPtr->flags & (WM_UPDATE_PENDING|WM_NEVER_MAPPED))) { Tcl_DoWhenIdle(UpdateGeometryInfo, winPtr); wmPtr->flags |= WM_UPDATE_PENDING; @@ -4417,6 +4477,9 @@ Tk_CoordsToWindow( } winPtr = nextPtr; } + if (winPtr->mainPtr != ((TkWindow *) tkwin)->mainPtr) { + return NULL; + } return (Tk_Window) winPtr; } @@ -4671,7 +4734,7 @@ Tk_MoveToplevelWindow( wmPtr->x = x; wmPtr->y = y; wmPtr->flags |= WM_MOVE_PENDING; - wmPtr->flags &= ~(WM_NEGATIVE_X|WM_NEGATIVE_Y); + // wmPtr->flags &= ~(WM_NEGATIVE_X|WM_NEGATIVE_Y); if (!(wmPtr->sizeHintsFlags & (USPosition|PPosition))) { wmPtr->sizeHintsFlags |= USPosition; wmPtr->flags |= WM_UPDATE_SIZE_HINTS; @@ -5199,7 +5262,8 @@ MODULE_SCOPE int TkMacOSXIsWindowZoomed( TkWindow *winPtr) { - return [TkMacOSXDrawableWindow(winPtr->window) isZoomed]; + NSWindow *macWindow = TkMacOSXDrawableWindow(winPtr->window); + return [macWindow isZoomed]; } @@ -5244,13 +5308,13 @@ TkMacOSXZoomToplevel( * Do nothing if already in desired zoom state. */ - if ((![window isZoomed] == (zoomPart == inZoomIn))) { + if (([window isZoomed] == (zoomPart == inZoomOut))) { return false; } - [window zoom:NSApp]; + [window zoom:NSApp]; - wmPtr->hints.initial_state = - (zoomPart == inZoomIn ? NormalState : ZoomState); + wmPtr->hints.initial_state = + (zoomPart == inZoomIn ? NormalState : ZoomState); return true; } @@ -5424,21 +5488,6 @@ WmWinStyle( { "moveToActiveSpace", tkMoveToActiveSpaceAttribute }, { "nonActivating", tkNonactivatingPanelAttribute }, { "hud", tkHUDWindowAttribute }, - { "black", 0 }, - { "dark", 0 }, - { "light", 0 }, - { "gray", 0 }, - { "red", 0 }, - { "green", 0 }, - { "blue", 0 }, - { "cyan", 0 }, - { "yellow", 0 }, - { "magenta", 0 }, - { "orange", 0 }, - { "purple", 0 }, - { "brown", 0 }, - { "clear", 0 }, - { "opacity", 0 }, { NULL } }; @@ -5520,10 +5569,8 @@ WmWinStyle( macClassAttrs[macClass].validAttrs); wmPtr->flags |= macClassAttrs[macClass].flags; wmPtr->macClass = macClass; - ApplyWindowAttributeFlagChanges(winPtr, NULL, oldAttributes, oldFlags, 0, 1); - return TCL_OK; badClassAttrs: @@ -5664,6 +5711,8 @@ TkMacOSXMakeRealWindowExist( { WmInfo *wmPtr = winPtr->wmInfoPtr; MacDrawable *macWin; + WindowClass macClass; + Bool overrideRedirect = Tk_Attributes((Tk_Window) winPtr)->override_redirect; if (TkMacOSXHostToplevelExists(winPtr)) { return; @@ -5700,7 +5749,16 @@ TkMacOSXMakeRealWindowExist( * TODO: Here we should handle out of process embedding. */ } - WindowClass macClass = wmPtr->macClass; + + /* + * If this is an override-redirect window, the NSWindow is created + * first as a document window then converted to a simple window. + */ + + if (overrideRedirect) { + wmPtr->macClass = kDocumentWindowClass; + } + macClass = wmPtr->macClass; wmPtr->attributes &= (tkAlwaysValidAttributes | macClassAttrs[macClass].validAttrs); wmPtr->flags |= macClassAttrs[macClass].flags | @@ -5753,12 +5811,10 @@ TkMacOSXMakeRealWindowExist( */ [window setMovableByWindowBackground:NO]; } - [window setDocumentEdited:NO]; wmPtr->window = window; macWin->view = window.contentView; TkMacOSXApplyWindowAttributes(winPtr, window); - NSRect geometry = InitialWindowBounds(winPtr, window); geometry.size.width += structureRect.size.width; geometry.size.height += structureRect.size.height; @@ -5766,7 +5822,14 @@ TkMacOSXMakeRealWindowExist( geometry.size.height); [window setFrame:geometry display:YES]; TkMacOSXRegisterOffScreenWindow((Window) macWin, window); + macWin->flags |= TK_HOST_EXISTS; + if (overrideRedirect) { + XSetWindowAttributes atts; + atts.override_redirect = True; + Tk_ChangeWindowAttributes((Tk_Window) winPtr, CWOverrideRedirect, &atts); + ApplyMasterOverrideChanges(winPtr, NULL); + } } /* @@ -6474,21 +6537,35 @@ ApplyWindowAttributeFlagChanges( * 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. + * after 10.10. */ -#if !(MAC_OS_X_VERSION_MAX_ALLOWED < 1070) +#if !(MAC_OS_X_VERSION_MAX_ALLOWED < 101000) if (!(macWindow.styleMask & NSUtilityWindowMask)) { - NSSize screenSize = [[macWindow screen]frame].size; - b |= NSWindowCollectionBehaviorFullScreenPrimary; - /* The default max size has height less than the screen height. - * This causes the window manager to refuse to allow the window - * to be resized when it is a split window. To work around - * this we make the max size equal to the screen size. + /* + * Exclude overrideredirect, transient, and "help"-styled + * windows from moving into their own fullscreen space. + * */ - - [macWindow setMaxFullScreenContentSize:screenSize]; + + if ((winPtr->atts.override_redirect) || + (wmPtr->master != None) || + (winPtr->wmInfoPtr->macClass == kHelpWindowClass)) { + b |= (NSWindowCollectionBehaviorCanJoinAllSpaces | + NSWindowCollectionBehaviorFullScreenAuxiliary); + } else { + NSSize screenSize = [[macWindow screen]frame].size; + b |= NSWindowCollectionBehaviorFullScreenPrimary; + + /* The default max size has height less than the screen height. + * This causes the window manager to refuse to allow the window + * to be resized when it is a split window. To work around + * this we make the max size equal to the screen size. + */ + + [macWindow setMaxFullScreenContentSize:screenSize]; + } } #endif @@ -6548,6 +6625,14 @@ ApplyMasterOverrideChanges( WmInfo *wmPtr = winPtr->wmInfoPtr; UInt64 oldAttributes = wmPtr->attributes; int oldFlags = wmPtr->flags; + unsigned long styleMask; + NSRect structureRect; + + if (!macWindow && winPtr->window != None && + TkMacOSXHostToplevelExists(winPtr)) { + macWindow = TkMacOSXDrawableWindow(winPtr->window); + } + styleMask = [macWindow styleMask]; /* * FIX: We need an UpdateWrapper equivalent to make this 100% correct @@ -6559,6 +6644,11 @@ ApplyMasterOverrideChanges( wmPtr->attributes = macClassAttrs[kSimpleWindowClass].defaultAttrs; } wmPtr->attributes |= kWindowNoActivatesAttribute; + if ([NSApp macMinorVersion] == 6) { + styleMask = 0; + } else { + styleMask &= ~NSTitledWindowMask; + } } else { if (wmPtr->macClass == kSimpleWindowClass && oldAttributes == kWindowNoActivatesAttribute) { @@ -6567,18 +6657,50 @@ ApplyMasterOverrideChanges( macClassAttrs[kDocumentWindowClass].defaultAttrs; } wmPtr->attributes &= ~kWindowNoActivatesAttribute; - } - if (!macWindow && winPtr->window != None && - TkMacOSXHostToplevelExists(winPtr)) { - macWindow = TkMacOSXDrawableWindow(winPtr->window); + if ([NSApp macMinorVersion] == 6) { + styleMask = NSTitledWindowMask | + NSClosableWindowMask | + NSMiniaturizableWindowMask | + NSResizableWindowMask; + } else { + styleMask |= NSTitledWindowMask; + } } if (macWindow) { - if (winPtr->atts.override_redirect && wmPtr->master != None) { - wmPtr->flags |= WM_TOPMOST; + NSWindow *parentWindow = [macWindow parentWindow]; + structureRect = [NSWindow frameRectForContentRect:NSZeroRect + styleMask:styleMask]; + + /* + * Synchronize the wmInfoPtr to match the new window configuration + * so windowBoundsChanged won't corrupt the window manager info. + */ + + wmPtr->xInParent = -structureRect.origin.x; + wmPtr->yInParent = structureRect.origin.y + structureRect.size.height; + wmPtr->parentWidth = winPtr->changes.width + structureRect.size.width; + wmPtr->parentHeight = winPtr->changes.height + structureRect.size.height; + if (winPtr->atts.override_redirect) { + [macWindow setExcludedFromWindowsMenu:YES]; + [macWindow setStyleMask:styleMask]; + if (wmPtr->hints.initial_state == NormalState) { + [macWindow orderFront:nil]; + } + if (wmPtr->master != None) { + wmPtr->flags |= WM_TOPMOST; + } else { + wmPtr->flags &= ~WM_TOPMOST; + } } else { + const char *title = winPtr->wmInfoPtr->titleUid; + if (!title) { + title = winPtr->nameUid; + } + [macWindow setStyleMask:styleMask]; + [macWindow setTitle:[NSString stringWithUTF8String:title]]; + [macWindow setExcludedFromWindowsMenu:NO]; wmPtr->flags &= ~WM_TOPMOST; } - NSWindow *parentWindow = [macWindow parentWindow]; if (wmPtr->master != None) { TkDisplay *dispPtr = TkGetDisplayList(); TkWindow *masterWinPtr = (TkWindow *) diff --git a/tests/text.test b/tests/text.test index 621a9eb..5359407 100644 --- a/tests/text.test +++ b/tests/text.test @@ -2948,11 +2948,13 @@ test text-11a.1 {TextWidgetCmd procedure, "pendingsync" option} -setup { } -cleanup { destroy .yt } -result {1 {wrong # args: should be ".yt pendingsync"}} + test text-11a.2 {TextWidgetCmd procedure, "pendingsync" option} -setup { destroy .top.yt .top } -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 @@ -2990,9 +2992,11 @@ test text-11a.12 {TextWidgetCmd procedure, "sync" option} -setup { } -body { toplevel .top pack [text .top.yt] + update set content {} + # Use long lines so the line metrics will need updating. for {set i 1} {$i < 30} {incr i} { - append content [string repeat "$i " 15] \n + append content [string repeat "$i " 200] \n } .top.yt insert 1.0 $content # wait for end of line metrics calculation to get correct $fraction1 @@ -3065,19 +3069,18 @@ test text-11a.31 {"<<WidgetViewSync>>" event} -setup { for {set i 1} {$i < 300} {incr i} { append content [string repeat "$i " 15] \n } - .top.yt insert 1.0 $content + # Sync the widget and process <<WidgetViewSync>> events before binding. + .top.yt sync update bind .top.yt <<WidgetViewSync>> { if {%d} {set yud(%W) 1} } - # wait for end of line metrics calculation to get correct $fraction1 - # as a reference - if {[.top.yt pendingsync]} {vwait yud(.top.yt)} + .top.yt insert 1.0 $content .top.yt yview moveto 1 set fraction1 [lindex [.top.yt yview] 0] set res [expr {$fraction1 > 0}] .top.yt delete 1.0 end .top.yt insert 1.0 $content # synchronously wait for completion of line metrics calculation - # and ensure the test is relevant + # and verify that the fractions agree. set waited 0 if {[.top.yt pendingsync]} {set waited 1 ; vwait yud(.top.yt)} lappend res $waited @@ -3091,7 +3094,6 @@ test text-11a.31 {"<<WidgetViewSync>>" event} -setup { test text-11a.41 {"sync" "pendingsync" and <<WidgetViewSync>>} -setup { destroy .top.yt .top } -body { - set res {} toplevel .top pack [text .top.yt] update @@ -3099,15 +3101,21 @@ test text-11a.41 {"sync" "pendingsync" and <<WidgetViewSync>>} -setup { for {set i 1} {$i < 300} {incr i} { append content [string repeat "$i " 50] \n } + # Sync the widget and process all <<WidgetViewSync>> events before binding. + .top.yt sync + update bind .top.yt <<WidgetViewSync>> {lappend res Sync:%d} + set res {} + # The next line triggers <<WidgetViewSync>> with %d==0 i.e. out of sync. .top.yt insert 1.0 $content - vwait res ; # event dealt with by the event loop, with %d==0 i.e. we're out of sync - # ensure the test is relevant + vwait res + # Verify that the line metrics are not up-to-date (pendingsync is 1). lappend res "Pending:[.top.yt pendingsync]" - # - <<WidgetViewSync>> fires when sync returns if there was pending syncs - # - there is no more any pending sync after running 'sync' + # Update all line metrics by calling the sync command. .top.yt sync - vwait res ; # event dealt with by the event loop, with %d==1 i.e. we're in sync again + # <<WidgetViewSync>> should fire with %d==1 i.e. back in sync. + vwait res + # At this time the line metrics should be up-to-date (pendingsync is 0). lappend res "Pending:[.top.yt pendingsync]" set res } -cleanup { @@ -3122,6 +3130,7 @@ test text-11a.51 {<<WidgetViewSync>> calls TkSendVirtualEvent(), set res {} toplevel .top pack [text .top.t] + update for {set i 1} {$i < 10000} {incr i} { .top.t insert end "Hello world!\n" } @@ -7429,6 +7438,194 @@ test text-32.1 {line heights on creation} -setup { destroy .t } -result {1} +test text-32.2 {peer widget -start, -end and deletion (bug 1630262)} -setup { + destroy .t .pt + set res {} +} -body { + text .t + .t peer create .pt + for {set i 1} {$i < 100} {incr i} { + .t insert end "Line $i\n" + } + .t configure -startline 5 + # none of the following delete shall crash + # (all did before fixing bug 1630262) + # 1. delete on the same line: line1 == line2 in DeleteIndexRange, + # and resetView is true neither for .t not for .pt + .pt delete 2.0 2.2 + # 2. delete just one line: line1 < line2 in DeleteIndexRange, + # and resetView is true only for .t, not for .pt + .pt delete 2.0 3.0 + # 3. delete several lines: line1 < line2 in DeleteIndexRange, + # and resetView is true only for .t, not for .pt + .pt delete 2.0 5.0 + # 4. delete to the end line: line1 < line2 in DeleteIndexRange, + # and resetView is true only for .t, not for .pt + .pt delete 2.0 end + # this test succeeds provided there is no crash + set res 1 +} -cleanup { + destroy .pt +} -result {1} + +test text-32.3 {peer widget -start, -end and deletion (bug 1630262)} -setup { + destroy .t .pt + set res {} +} -body { + text .t + .t peer create .pt + for {set i 1} {$i < 100} {incr i} { + .t insert end "Line $i\n" + } + .t configure -startline 5 + .pt configure -startline 3 + # the following delete shall not crash + # (it did before fixing bug 1630262) + .pt delete 2.0 3.0 + # moreover -startline shall be correct + # (was wrong before fixing bug 1630262) + lappend res [.t cget -start] [.pt cget -start] +} -cleanup { + destroy .pt +} -result {4 3} + +test text-32.4 {peer widget -start, -end and deletion (bug 1630262)} -setup { + destroy .t .pt + set res {} +} -body { + text .t + .t peer create .pt + for {set i 1} {$i < 100} {incr i} { + .t insert end "Line $i\n" + } + .t configure -startline 5 -endline 15 + .pt configure -startline 8 -endline 12 + # .pt now shows a range entirely inside the range of .pt + # from .t, delete lines located after [.pt cget -end] + .t delete 9.0 10.0 + # from .t, delete lines straddling [.pt cget -end] + .t delete 6.0 9.0 + lappend res [.t cget -start] [.t cget -end] [.pt cget -start] [.pt cget -end] + .t configure -startline 5 -endline 12 + .pt configure -startline 8 -endline 12 + # .pt now shows again a range entirely inside the range of .pt + # from .t, delete lines located before [.pt cget -start] + .t delete 2.0 3.0 + # from .t, delete lines straddling [.pt cget -start] + .t delete 2.0 5.0 + lappend res [.t cget -start] [.t cget -end] [.pt cget -start] [.pt cget -end] + .t configure -startline 22 -endline 31 + .pt configure -startline 42 -endline 51 + # .t now shows a range entirely before the range of .pt + # from .t, delete some lines, then do it from .pt + .t delete 2.0 3.0 + .t delete 2.0 5.0 + .pt delete 2.0 5.0 + lappend res [.t cget -start] [.t cget -end] [.pt cget -start] [.pt cget -end] + .t configure -startline 55 -endline 75 + .pt configure -startline 60 -endline 70 + # .pt now shows a range entirely inside the range of .t + # from .t, delete a range straddling the entire range of .pt + .t delete 3.0 18.0 + lappend res [.t cget -start] [.t cget -end] [.pt cget -start] [.pt cget -end] +} -cleanup { + destroy .pt .t +} -result {5 11 8 10 5 8 6 8 22 27 38 44 55 60 57 57} + +test text-32.2 {peer widget -start, -end and deletion (bug 1630262)} -setup { + destroy .t .pt + set res {} +} -body { + text .t + .t peer create .pt + for {set i 1} {$i < 100} {incr i} { + .t insert end "Line $i\n" + } + .t configure -startline 5 + # none of the following delete shall crash + # (all did before fixing bug 1630262) + # 1. delete on the same line: line1 == line2 in DeleteIndexRange, + # and resetView is true neither for .t not for .pt + .pt delete 2.0 2.2 + # 2. delete just one line: line1 < line2 in DeleteIndexRange, + # and resetView is true only for .t, not for .pt + .pt delete 2.0 3.0 + # 3. delete several lines: line1 < line2 in DeleteIndexRange, + # and resetView is true only for .t, not for .pt + .pt delete 2.0 5.0 + # 4. delete to the end line: line1 < line2 in DeleteIndexRange, + # and resetView is true only for .t, not for .pt + .pt delete 2.0 end + # this test succeeds provided there is no crash + set res 1 +} -cleanup { + destroy .pt +} -result {1} + +test text-32.3 {peer widget -start, -end and deletion (bug 1630262)} -setup { + destroy .t .pt + set res {} +} -body { + text .t + .t peer create .pt + for {set i 1} {$i < 100} {incr i} { + .t insert end "Line $i\n" + } + .t configure -startline 5 + .pt configure -startline 3 + # the following delete shall not crash + # (it did before fixing bug 1630262) + .pt delete 2.0 3.0 + # moreover -startline shall be correct + # (was wrong before fixing bug 1630262) + lappend res [.t cget -start] [.pt cget -start] +} -cleanup { + destroy .pt +} -result {4 3} + +test text-32.4 {peer widget -start, -end and deletion (bug 1630262)} -setup { + destroy .t .pt + set res {} +} -body { + text .t + .t peer create .pt + for {set i 1} {$i < 100} {incr i} { + .t insert end "Line $i\n" + } + .t configure -startline 5 -endline 15 + .pt configure -startline 8 -endline 12 + # .pt now shows a range entirely inside the range of .pt + # from .t, delete lines located after [.pt cget -end] + .t delete 9.0 10.0 + # from .t, delete lines straddling [.pt cget -end] + .t delete 6.0 9.0 + lappend res [.t cget -start] [.t cget -end] [.pt cget -start] [.pt cget -end] + .t configure -startline 5 -endline 12 + .pt configure -startline 8 -endline 12 + # .pt now shows again a range entirely inside the range of .pt + # from .t, delete lines located before [.pt cget -start] + .t delete 2.0 3.0 + # from .t, delete lines straddling [.pt cget -start] + .t delete 2.0 5.0 + lappend res [.t cget -start] [.t cget -end] [.pt cget -start] [.pt cget -end] + .t configure -startline 22 -endline 31 + .pt configure -startline 42 -endline 51 + # .t now shows a range entirely before the range of .pt + # from .t, delete some lines, then do it from .pt + .t delete 2.0 3.0 + .t delete 2.0 5.0 + .pt delete 2.0 5.0 + lappend res [.t cget -start] [.t cget -end] [.pt cget -start] [.pt cget -end] + .t configure -startline 55 -endline 75 + .pt configure -startline 60 -endline 70 + # .pt now shows a range entirely inside the range of .t + # from .t, delete a range straddling the entire range of .pt + .t delete 3.0 18.0 + lappend res [.t cget -start] [.t cget -end] [.pt cget -start] [.pt cget -end] +} -cleanup { + destroy .pt .t +} -result {5 11 8 10 5 8 6 8 22 27 38 44 55 60 57 57} + test text-33.1 {TextWidgetCmd procedure, "peer" option} -setup { text .t @@ -7561,100 +7758,6 @@ test text-34.1 {peer widget -start, -end and selection} -setup { destroy .t } -result {{10.0 20.0} {6.0 16.0} {6.0 11.0} {1.0 6.0} {1.0 2.0} {} {10.0 20.0}} -test text-32.2 {peer widget -start, -end and deletion (bug 1630262)} -setup { - destroy .t .pt - set res {} -} -body { - text .t - .t peer create .pt - for {set i 1} {$i < 100} {incr i} { - .t insert end "Line $i\n" - } - .t configure -startline 5 - # none of the following delete shall crash - # (all did before fixing bug 1630262) - # 1. delete on the same line: line1 == line2 in DeleteIndexRange, - # and resetView is true neither for .t not for .pt - .pt delete 2.0 2.2 - # 2. delete just one line: line1 < line2 in DeleteIndexRange, - # and resetView is true only for .t, not for .pt - .pt delete 2.0 3.0 - # 3. delete several lines: line1 < line2 in DeleteIndexRange, - # and resetView is true only for .t, not for .pt - .pt delete 2.0 5.0 - # 4. delete to the end line: line1 < line2 in DeleteIndexRange, - # and resetView is true only for .t, not for .pt - .pt delete 2.0 end - # this test succeeds provided there is no crash - set res 1 -} -cleanup { - destroy .pt -} -result {1} - -test text-32.3 {peer widget -start, -end and deletion (bug 1630262)} -setup { - destroy .t .pt - set res {} -} -body { - text .t - .t peer create .pt - for {set i 1} {$i < 100} {incr i} { - .t insert end "Line $i\n" - } - .t configure -startline 5 - .pt configure -startline 3 - # the following delete shall not crash - # (it did before fixing bug 1630262) - .pt delete 2.0 3.0 - # moreover -startline shall be correct - # (was wrong before fixing bug 1630262) - lappend res [.t cget -start] [.pt cget -start] -} -cleanup { - destroy .pt -} -result {4 3} - -test text-32.4 {peer widget -start, -end and deletion (bug 1630262)} -setup { - destroy .t .pt - set res {} -} -body { - text .t - .t peer create .pt - for {set i 1} {$i < 100} {incr i} { - .t insert end "Line $i\n" - } - .t configure -startline 5 -endline 15 - .pt configure -startline 8 -endline 12 - # .pt now shows a range entirely inside the range of .pt - # from .t, delete lines located after [.pt cget -end] - .t delete 9.0 10.0 - # from .t, delete lines straddling [.pt cget -end] - .t delete 6.0 9.0 - lappend res [.t cget -start] [.t cget -end] [.pt cget -start] [.pt cget -end] - .t configure -startline 5 -endline 12 - .pt configure -startline 8 -endline 12 - # .pt now shows again a range entirely inside the range of .pt - # from .t, delete lines located before [.pt cget -start] - .t delete 2.0 3.0 - # from .t, delete lines straddling [.pt cget -start] - .t delete 2.0 5.0 - lappend res [.t cget -start] [.t cget -end] [.pt cget -start] [.pt cget -end] - .t configure -startline 22 -endline 31 - .pt configure -startline 42 -endline 51 - # .t now shows a range entirely before the range of .pt - # from .t, delete some lines, then do it from .pt - .t delete 2.0 3.0 - .t delete 2.0 5.0 - .pt delete 2.0 5.0 - lappend res [.t cget -start] [.t cget -end] [.pt cget -start] [.pt cget -end] - .t configure -startline 55 -endline 75 - .pt configure -startline 60 -endline 70 - # .pt now shows a range entirely inside the range of .t - # from .t, delete a range straddling the entire range of .pt - .t delete 3.0 18.0 - lappend res [.t cget -start] [.t cget -end] [.pt cget -start] [.pt cget -end] -} -cleanup { - destroy .pt .t -} -result {5 11 8 10 5 8 6 8 22 27 38 44 55 60 57 57} - test text-35.1 {widget dump -command alters tags} -setup { proc Dumpy {key value index} { #puts "KK: $key, $value" diff --git a/tests/unixWm.test b/tests/unixWm.test index 0c3fb9b..826cd72 100644 --- a/tests/unixWm.test +++ b/tests/unixWm.test @@ -19,6 +19,16 @@ proc sleep ms { vwait x } +# The macOS window manager shows an animation when a window is deiconified. +# Tests which check the geometry of a window after deiconifying it should +# wait for the animation to finish. + + proc animationDelay {} { + if {[tk windowingsystem] == "aqua"} { + sleep 250 + } + } + # Procedure to set up a collection of top-level windows proc makeToplevels {} { @@ -76,6 +86,7 @@ foreach geom {+20+80 +80+20 +0+0 -0-0 +0-0 -0+0 -10-5 -10+5 +10-5} { wm geom .t $geom update wm deiconify .t + animationDelay scan [wm geom .t] %dx%d%1s%d%1s%d width height xsign x ysign y format "%s%d%s%d" $xsign [eval expr $x$xsign$xerr] $ysign \ [eval expr $y$ysign$yerr] @@ -91,6 +102,7 @@ foreach geom {+20+80 +100+40 +0+0} { wm geom .t $geom update wm deiconify .t + animationDelay wm geom .t } 100x150$geom incr i @@ -400,6 +412,7 @@ test unixWm-9.4 {TkWmMapWindow procedure, icon windows} unix { destroy .t sleep 500 toplevel .t -width 100 -height 50 -bg blue + tkwait visibility .t wm iconwindow . .t update set result [winfo ismapped .t] @@ -795,9 +808,15 @@ test unixWm-22.2 {Tk_WmCmd procedure, "iconbitmap" option} {unix testwrapper} { WM_HINTS] 0]]] lappend result [wm iconbitmap .t] $bit } {{} questhead 0x4 {} 0x0} -test unixWm-22.3 {Tk_WmCmd procedure, "iconbitmap" option} unix { +if {[tk windowingsystem] == "aqua"} { + set result_22_3 {0 {}} +} else { + set result_22_3 {1 {bitmap "bad-bitmap" not defined}} +} +test unixWm-22.3 {Tk_WmCmd procedure, "iconbitmap" option for unix only} \ +unix { list [catch {wm iconbitmap .t bad-bitmap} msg] $msg -} {1 {bitmap "bad-bitmap" not defined}} +} $result_22_3 test unixWm-23.1 {Tk_WmCmd procedure, "iconify" option} unix { list [catch {wm iconify .t 12} msg] $msg @@ -1200,10 +1219,14 @@ test unixWm-34.2 {Tk_WmCmd procedure, "sizefrom" option} {unix testwrapper} { test unixWm-34.3 {Tk_WmCmd procedure, "sizefrom" option} unix { list [catch {wm sizefrom .t none} msg] $msg } {1 {bad argument "none": must be program or user}} - -test unixWm-35.1 {Tk_WmCmd procedure, "state" option} unix { +if {[tk windowingsystem] == "aqua"} { + set result_35_1 {1 {bad argument "1": must be normal, iconic, withdrawn, or zoomed}} +} else { + set result_35_1 {1 {bad argument "1": must be normal, iconic, or withdrawn}} +} +test unixWm-35.1 {Tk_WmCmd procedure, "state" option} {unix notAqua} { list [catch {wm state .t 1} msg] $msg -} {1 {bad argument "1": must be normal, iconic, or withdrawn}} +} $result_35_1 test unixWm-35.2 {Tk_WmCmd procedure, "state" option} unix { list [catch {wm state .t iconic 1} msg] $msg } {1 {wrong # args: should be "wm state window ?state?"}} @@ -1415,9 +1438,11 @@ test unixWm-42.1 {WrapperEventProc procedure, map and unmap events} unix { bind .t <Unmap> {set x "unmapped"} set x {no event} wm iconify .t + animationDelay lappend result $x [winfo ismapped .t] set x {no event} wm deiconify .t + animationDelay lappend result $x [winfo ismapped .t] } {unmapped 0 mapped 1} @@ -1507,9 +1532,9 @@ test unixWm-44.5 {UpdateGeometryInfo procedure, negative width} unix { update list [winfo width .t] [winfo height .t] } {1 72} +destroy .t +toplevel .t -width 80 -height 60 test unixWm-44.6 {UpdateGeometryInfo procedure, negative height} unix { - destroy .t - toplevel .t -width 80 -height 60 wm grid .t 18 7 10 12 wm geometry .t +30+40 wm overrideredirect .t 1 @@ -1518,22 +1543,24 @@ test unixWm-44.6 {UpdateGeometryInfo procedure, negative height} unix { update list [winfo width .t] [winfo height .t] } {100 1} - destroy .t toplevel .t -width 80 -height 60 test unixWm-44.7 {UpdateGeometryInfo procedure, computing position} unix { - wm geometry .t +5-10 - wm overrideredirect .t 1 tkwait visibility .t + wm overrideredirect .t 1 + update + wm geometry .t +5-10 + update list [winfo x .t] [winfo y .t] } [list 5 [expr [winfo screenheight .t] - 70]] - destroy .t toplevel .t -width 80 -height 60 test unixWm-44.8 {UpdateGeometryInfo procedure, computing position} unix { - wm geometry .t -30+2 - wm overrideredirect .t 1 tkwait visibility .t + wm overrideredirect .t 1 + update + wm geometry .t -30+2 + update list [winfo x .t] [winfo y .t] } [list [expr [winfo screenwidth .t] - 110] 2] destroy .t @@ -1752,88 +1779,103 @@ test unixWm-49.2 {Tk_GetRootCoords procedure, menubars} {unix testmenubar} { } {52 7 12 62} deleteWindows -wm iconify . -test unixWm-50.1 {Tk_CoordsToWindow procedure, finding a toplevel, x-coords} unix { - deleteWindows +wm withdraw . +if {[tk windowingsystem] == "aqua"} { + # Modern mac windows have no border. + set result_50_1 {{} {} .t .t .t2 {} .t2 .t .t} +} else { + # Windows are assumed to have a border (invisible in Gnome 3). + set result_50_1 {{} {} .t {} .t2 {} .t2 {} .t} +} +test unixWm-50.1 {Tk_CoordsToWindow procedure, finding a toplevel, x-coords, title bar} unix { + update toplevel .t -width 300 -height 400 -bg green - wm geom .t +40+0 + wm geom .t +100+100 tkwait visibility .t - toplevel .t2 -width 100 -height 80 -bg red - wm geom .t2 +140+200 + toplevel .t2 -width 100 -height 200 -bg red + wm geom .t2 +200+200 tkwait visibility .t2 raise .t2 + update set x [winfo rootx .t] set y [winfo rooty .t] - list [winfo containing [expr $x - 30] [expr $y + 250]] \ - [winfo containing [expr $x - 1] [expr $y + 250]] \ - [winfo containing $x [expr $y + 250]] \ - [winfo containing [expr $x + 99] [expr $y + 250]] \ - [winfo containing [expr $x + 100] [expr $y + 250]] \ - [winfo containing [expr $x + 199] [expr $y + 250]] \ - [winfo containing [expr $x + 200] [expr $y + 250]] \ - [winfo containing [expr $x + 220] [expr $y + 250]] -} {{} {} .t {} .t2 .t2 {} .t} + list [winfo containing [expr $x - 30] [expr $y + 250]] \ + [winfo containing [expr $x - 1] [expr $y + 250]] \ + [winfo containing $x [expr $y + 250]] \ + [winfo containing [expr $x + 99] [expr $y + 250]] \ + [winfo containing [expr $x + 100] [expr $y + 250]] \ + [winfo containing [expr $x + 150] [expr $y + 90]] \ + [winfo containing [expr $x + 199] [expr $y + 250]] \ + [winfo containing [expr $x + 200] [expr $y + 250]] \ + [winfo containing [expr $x + 220] [expr $y + 250]] \ +} $result_50_1 test unixWm-50.2 {Tk_CoordsToWindow procedure, finding a toplevel, y-coords and overrideredirect} unix { deleteWindows - toplevel .t -width 300 -height 400 -bg yellow - wm geom .t +0+50 + toplevel .t -width 400 -height 300 -bg yellow + wm geom .t +100+100 tkwait visibility .t - toplevel .t2 -width 100 -height 80 -bg blue + toplevel .t2 -width 200 -height 100 -bg blue wm overrideredirect .t2 1 - wm geom .t2 +100+200 + wm geom .t2 +200+200 tkwait visibility .t2 raise .t2 set x [winfo rootx .t] set y [winfo rooty .t] set y2 [winfo rooty .t2] - list [winfo containing [expr $x +150] 10] \ - [winfo containing [expr $x +150] [expr $y - 1]] \ - [winfo containing [expr $x +150] $y] \ - [winfo containing [expr $x +150] [expr $y2 - 1]] \ - [winfo containing [expr $x +150] $y2] \ - [winfo containing [expr $x +150] [expr $y2 + 79]] \ - [winfo containing [expr $x +150] [expr $y2 + 80]] \ - [winfo containing [expr $x +150] [expr $y + 450]] + list [winfo containing [expr $x +200] [expr $y - 30]] \ + [winfo containing [expr $x +200] [expr $y - 1]] \ + [winfo containing [expr $x +200] $y] \ + [winfo containing [expr $x +200] [expr $y2 - 1]] \ + [winfo containing [expr $x +200] $y2] \ + [winfo containing [expr $x +200] [expr $y2 + 99]] \ + [winfo containing [expr $x +200] [expr $y2 + 100]] \ + [winfo containing [expr $x +200] [expr $y + 450]] } {{} {} .t .t .t2 .t2 .t {}} test unixWm-50.3 { Tk_CoordsToWindow procedure, finding a toplevel with embedding -} -constraints tempNotWin -setup { +} tempNotWin { deleteWindows + catch {interp delete slave} + toplevel .t -width 300 -height 400 -bg blue - wm geom .t +0+50 - frame .t.f -container 1 + wm geom .t +100+100 + frame .t.f -container 1 -bg red place .t.f -x 150 -y 50 tkwait visibility .t.f - setupbg -} -body { - dobg " + update + interp create slave + load {} Tk slave + slave alias frameid winfo id .t.f + slave eval { wm withdraw . - toplevel .x -width 100 -height 80 -use [winfo id .t.f] -bg yellow - tkwait visibility .x" - set result [dobg { - set x [winfo rootx .x] - set y [winfo rooty .x] - list [winfo containing [expr $x - 1] [expr $y + 50]] \ - [winfo containing $x [expr $y +50]] - }] + toplevel .x -width 100 -height 80 -use [frameid] -bg yellow + tkwait visibility .x + update + set x [winfo rootx .x] + set y [winfo rooty .x] + } + set result [list [slave eval {winfo containing [expr $x - 1] [expr $y + 50]}] \ + [slave eval {winfo containing $x [expr $y + 50]}]] + interp delete slave set x [winfo rootx .t] set y [winfo rooty .t] lappend result [winfo containing [expr $x + 200] [expr $y + 49]] \ - [winfo containing [expr $x + 200] [expr $y +50]] -} -cleanup { - cleanupbg -} -result {{} .x .t .t.f} + [winfo containing [expr $x + 200] [expr $y +50]] + set result +} {{} .x .t .t.f} test unixWm-50.4 {Tk_CoordsToWindow procedure, window in other application} unix { destroy .t + catch {interp delete slave} toplevel .t -width 200 -height 200 -bg green - wm geometry .t +0+0 + wm geometry .t +100+100 tkwait visibility .t + update interp create slave load {} Tk slave - slave eval {wm geometry . 200x200+0+0; tkwait visibility .} - set result [list [winfo containing 100 100] \ - [slave eval {winfo containing 100 100}]] + slave eval {wm geometry . 200x200+100+100; tkwait visibility . ; update} + set result [list [winfo containing 200 200] \ + [slave eval {winfo containing 200 200}]] interp delete slave set result } {{} .} @@ -1851,13 +1893,13 @@ test unixWm-50.5 {Tk_CoordsToWindow procedure, handling menubars} {unix testmenu update set x [winfo rootx .t] set y [winfo rooty .t] - list [winfo containing $x [expr $y - 31]] \ - [winfo containing $x [expr $y - 30]] \ - [winfo containing [expr $x + 50] [expr $y - 19]] \ - [winfo containing [expr $x + 50] [expr $y - 18]] \ - [winfo containing [expr $x + 50] $y] \ - [winfo containing [expr $x + 11] [expr $y + 152]] \ - [winfo containing [expr $x + 12] [expr $y + 152]] + list [winfo containing $x [expr $y - 31]] \ + [winfo containing $x [expr $y - 30]] \ + [winfo containing [expr $x + 50] [expr $y - 19]] \ + [winfo containing [expr $x + 50] [expr $y - 18]] \ + [winfo containing [expr $x + 50] $y] \ + [winfo containing [expr $x + 11] [expr $y + 152]] \ + [winfo containing [expr $x + 12] [expr $y + 152]] } {{} .t.menu .t.menu .t.menu.f .t .t .t.f} test unixWm-50.6 {Tk_CoordsToWindow procedure, embedding within one app.} unix { deleteWindows @@ -1922,6 +1964,7 @@ test unixWm-50.9 {Tk_CoordsToWindow procedure, unmapped windows} unix { tkwait visibility .t2 set result [list [winfo containing 100 100]] wm iconify .t2 + animationDelay lappend result [winfo containing 100 100] } {.t2 .t} test unixWm-50.10 {Tk_CoordsToWindow procedure, unmapped windows} unix { @@ -2007,6 +2050,7 @@ test unixWm-51.6 {TkWmRestackToplevel procedure, window to be stacked isn't mapp test unixWm-51.7 {TkWmRestackToplevel procedure, other window isn't mapped} unix { foreach w {.t .t2 .t3} { destroy $w + update toplevel $w -width 200 -height 200 -bg green wm geometry $w +0+0 } @@ -2043,13 +2087,19 @@ test unixWm-51.8 {TkWmRestackToplevel procedure, overrideredirect windows} unix raise .t2 lappend result [winfo containing $x $y] } {.t2 .t .t2} +# The mac won't put an overrideredirect window above the root, +if {[tk windowingsystem] == "aqua"} { + wm withdraw . +} test unixWm-51.9 {TkWmRestackToplevel procedure, other window overrideredirect} unix { foreach w {.t .t2 .t3} { destroy $w + update toplevel $w -width 200 -height 200 -bg green wm overrideredirect $w 1 wm geometry $w +0+0 tkwait visibility $w + update } lower .t3 .t2 update @@ -2065,6 +2115,9 @@ test unixWm-51.9 {TkWmRestackToplevel procedure, other window overrideredirect} lower .t2 lappend result [winfo containing $x $y] } {.t2 .t3} +if {[tk windowingsystem] == "aqua"} { + wm deiconify . +} test unixWm-51.10 {TkWmRestackToplevel procedure, don't move window that's already in the right place} unix { makeToplevels raise .raise1 @@ -2440,11 +2493,18 @@ test unixWm-59.3 {exit processing} unix { # NOTE: since [wm attributes] is not guaranteed to have any effect, # the only thing we can really test here is the syntax. # +if {[tk windowingsystem] == "aqua"} { + set result_60_1 {-alpha 1.0 -fullscreen 0 -modified 0 -notify 0\ + -titlepath {} -topmost 0 -transparent 0\ + -type unsupported} +} else { + set result_60_1 {-alpha 1.0 -topmost 0 -zoomed 0 -fullscreen 0 -type {}} +} test unixWm-60.1 {wm attributes - test} -constraints unix -body { destroy .t toplevel .t wm attributes .t -} -result [list -alpha 1.0 -topmost 0 -zoomed 0 -fullscreen 0 -type {}] +} -result $result_60_1 test unixWm-60.2 {wm attributes - test} -constraints unix -body { destroy .t diff --git a/tests/wm.test b/tests/wm.test index 9cbe49a..af37c80 100644 --- a/tests/wm.test +++ b/tests/wm.test @@ -140,7 +140,7 @@ test wm-attributes-1.2.4 {usage} -constraints {unix notAqua} -returnCodes error } -result {bad attribute "_": must be -alpha, -topmost, -zoomed, -fullscreen, or -type} test wm-attributes-1.2.5 {usage} -constraints aqua -returnCodes error -body { wm attributes . _ -} -result {bad attribute "_": must be -alpha, -fullscreen, -modified, -notify, -titlepath, -topmost, or -transparent} +} -result {bad attribute "_": must be -alpha, -fullscreen, -modified, -notify, -titlepath, -topmost, -transparent, or -type} ### wm client ### @@ -1516,9 +1516,10 @@ test wm-stackorder-5.1 {a menu is not a toplevel} -body { } -cleanup { destroy .t } -result {.t .} -test wm-stackorder-5.2 {A normal toplevel can't be\ - raised above an overrideredirect toplevel} -body { +test wm-stackorder-5.2 {A normal toplevel can't be raised above an \ + overrideredirect toplevel on unix} -constraints x11 -body { toplevel .t + tkwait visibility .t wm overrideredirect .t 1 raise . update @@ -1527,9 +1528,22 @@ test wm-stackorder-5.2 {A normal toplevel can't be\ } -cleanup { destroy .t } -result 0 +test wm-stackorder-5.2.1 {A normal toplevel can be raised above an \ + overrideredirect toplevel on macOS or win} -constraints aquaOrWin32 -body { + toplevel .t + tkwait visibility .t + wm overrideredirect .t 1 + raise . + update + raiseDelay + wm stackorder . isabove .t +} -cleanup { + destroy .t +} -result 1 test wm-stackorder-5.3 {An overrideredirect window\ can be explicitly lowered} -body { toplevel .t + tkwait visibility .t wm overrideredirect .t 1 lower .t update @@ -1540,7 +1554,7 @@ test wm-stackorder-5.3 {An overrideredirect window\ } -result 1 test wm-stackorder-6.1 {An embedded toplevel does not\ - appear in the stacking order} -body { + appear in the stacking order on unix or win} -constraints notAqua -body { toplevel .real -container 1 toplevel .embd -bg blue -use [winfo id .real] update @@ -1548,6 +1562,15 @@ test wm-stackorder-6.1 {An embedded toplevel does not\ } -cleanup { deleteWindows } -result {. .real} +test wm-stackorder-6.1.1 {An embedded toplevel does\ + appear in the stacking order on macOS} -constraints aqua -body { + toplevel .real -container 1 + toplevel .embd -bg blue -use [winfo id .real] + update + wm stackorder . +} -cleanup { + deleteWindows +} -result {. .embd} stdWindow diff --git a/unix/tkUnix3d.c b/unix/tkUnix3d.c index 038d4e1..2969de1 100644 --- a/unix/tkUnix3d.c +++ b/unix/tkUnix3d.c @@ -48,7 +48,7 @@ TkpGetBorder(void) { UnixBorder *borderPtr = ckalloc(sizeof(UnixBorder)); - borderPtr->solidGC = None; + borderPtr->solidGC = NULL; return (TkBorder *) borderPtr; } @@ -76,7 +76,7 @@ TkpFreeBorder( UnixBorder *unixBorderPtr = (UnixBorder *) borderPtr; Display *display = DisplayOfScreen(borderPtr->screen); - if (unixBorderPtr->solidGC != None) { + if (unixBorderPtr->solidGC != NULL) { Tk_FreeGC(display, unixBorderPtr->solidGC); } } @@ -124,7 +124,7 @@ Tk_3DVerticalBevel( GC left, right; Display *display = Tk_Display(tkwin); - if ((borderPtr->lightGC == None) && (relief != TK_RELIEF_FLAT)) { + if ((borderPtr->lightGC == NULL) && (relief != TK_RELIEF_FLAT)) { TkpGetShadows(borderPtr, tkwin); } @@ -159,7 +159,7 @@ Tk_3DVerticalBevel( (unsigned) width, (unsigned) height); } else if (relief == TK_RELIEF_SOLID) { UnixBorder *unixBorderPtr = (UnixBorder *) borderPtr; - if (unixBorderPtr->solidGC == None) { + if (unixBorderPtr->solidGC == NULL) { XGCValues gcValues; gcValues.foreground = BlackPixelOfScreen(borderPtr->screen); @@ -216,11 +216,11 @@ Tk_3DHorizontalBevel( Display *display = Tk_Display(tkwin); int bottom, halfway, x1, x2, x1Delta, x2Delta; UnixBorder *unixBorderPtr = (UnixBorder *) borderPtr; - GC topGC = None, bottomGC = None; + GC topGC = NULL, bottomGC = NULL; /* Initializations needed only to prevent * compiler warnings. */ - if ((borderPtr->lightGC == None) && (relief != TK_RELIEF_FLAT) && + if ((borderPtr->lightGC == NULL) && (relief != TK_RELIEF_FLAT) && (relief != TK_RELIEF_SOLID)) { TkpGetShadows(borderPtr, tkwin); } @@ -246,7 +246,7 @@ Tk_3DHorizontalBevel( bottomGC = borderPtr->darkGC; break; case TK_RELIEF_SOLID: - if (unixBorderPtr->solidGC == None) { + if (unixBorderPtr->solidGC == NULL) { XGCValues gcValues; gcValues.foreground = BlackPixelOfScreen(borderPtr->screen); @@ -344,7 +344,7 @@ TkpGetShadows( int r, g, b; XGCValues gcValues; - if (borderPtr->lightGC != None) { + if (borderPtr->lightGC != NULL) { return; } stressed = TkpCmapStressed(tkwin, borderPtr->colormap); diff --git a/unix/tkUnixDefault.h b/unix/tkUnixDefault.h index a5bcf4d..bc7cd93 100644 --- a/unix/tkUnixDefault.h +++ b/unix/tkUnixDefault.h @@ -246,7 +246,7 @@ #define DEF_MENU_ENTRY_ACTIVE_FG NULL #define DEF_MENU_ENTRY_ACCELERATOR NULL #define DEF_MENU_ENTRY_BG NULL -#define DEF_MENU_ENTRY_BITMAP None +#define DEF_MENU_ENTRY_BITMAP NULL #define DEF_MENU_ENTRY_COLUMN_BREAK "0" #define DEF_MENU_ENTRY_COMMAND NULL #define DEF_MENU_ENTRY_COMPOUND "none" diff --git a/unix/tkUnixMenubu.c b/unix/tkUnixMenubu.c index ba78016..c49f15b 100644 --- a/unix/tkUnixMenubu.c +++ b/unix/tkUnixMenubu.c @@ -92,7 +92,7 @@ TkpDisplayMenuButton( border = mbPtr->normalBorder; } - if (mbPtr->image != None) { + if (mbPtr->image != NULL) { Tk_SizeOfImage(mbPtr->image, &width, &height); haveImage = 1; } else if (mbPtr->bitmap != None) { @@ -358,7 +358,7 @@ TkpComputeMenuButtonGeometry( txtHeight = 0; avgWidth = 0; - if (mbPtr->image != None) { + if (mbPtr->image != NULL) { Tk_SizeOfImage(mbPtr->image, &width, &height); haveImage = 1; } else if (mbPtr->bitmap != None) { diff --git a/unix/tkUnixRFont.c b/unix/tkUnixRFont.c index fd5c73c..9c15369 100644 --- a/unix/tkUnixRFont.c +++ b/unix/tkUnixRFont.c @@ -937,7 +937,7 @@ Tk_DrawChars( doUnderlineStrikeout: if (tsdPtr->clipRegion != None) { - XftDrawSetClip(fontPtr->ftDraw, None); + XftDrawSetClip(fontPtr->ftDraw, NULL); } if (fontPtr->font.fa.underline != 0) { XFillRectangle(display, drawable, gc, xStart, @@ -1183,7 +1183,7 @@ TkDrawAngledChars( doUnderlineStrikeout: if (tsdPtr->clipRegion != None) { - XftDrawSetClip(fontPtr->ftDraw, None); + XftDrawSetClip(fontPtr->ftDraw, NULL); } if (fontPtr->font.fa.underline || fontPtr->font.fa.overstrike) { XPoint points[5]; diff --git a/unix/tkUnixScrlbr.c b/unix/tkUnixScrlbr.c index 5a7b0a1..d3e4436 100644 --- a/unix/tkUnixScrlbr.c +++ b/unix/tkUnixScrlbr.c @@ -65,8 +65,8 @@ TkpCreateScrollbar( { UnixScrollbar *scrollPtr = ckalloc(sizeof(UnixScrollbar)); - scrollPtr->troughGC = None; - scrollPtr->copyGC = None; + scrollPtr->troughGC = NULL; + scrollPtr->copyGC = NULL; Tk_CreateEventHandler(tkwin, ExposureMask|StructureNotifyMask|FocusChangeMask, @@ -366,10 +366,10 @@ TkpDestroyScrollbar( { UnixScrollbar *unixScrollPtr = (UnixScrollbar *)scrollPtr; - if (unixScrollPtr->troughGC != None) { + if (unixScrollPtr->troughGC != NULL) { Tk_FreeGC(scrollPtr->display, unixScrollPtr->troughGC); } - if (unixScrollPtr->copyGC != None) { + if (unixScrollPtr->copyGC != NULL) { Tk_FreeGC(scrollPtr->display, unixScrollPtr->copyGC); } } @@ -406,11 +406,11 @@ TkpConfigureScrollbar( gcValues.foreground = scrollPtr->troughColorPtr->pixel; new = Tk_GetGC(scrollPtr->tkwin, GCForeground, &gcValues); - if (unixScrollPtr->troughGC != None) { + if (unixScrollPtr->troughGC != NULL) { Tk_FreeGC(scrollPtr->display, unixScrollPtr->troughGC); } unixScrollPtr->troughGC = new; - if (unixScrollPtr->copyGC == None) { + if (unixScrollPtr->copyGC == NULL) { gcValues.graphics_exposures = False; unixScrollPtr->copyGC = Tk_GetGC(scrollPtr->tkwin, GCGraphicsExposures, &gcValues); diff --git a/unix/tkUnixWm.c b/unix/tkUnixWm.c index 5bfa69e..b84791b 100644 --- a/unix/tkUnixWm.c +++ b/unix/tkUnixWm.c @@ -5781,6 +5781,18 @@ Tk_GetRootCoords( *---------------------------------------------------------------------- */ +static int PointInWindow( + int x, + int y, + WmInfo *wmPtr) +{ + XWindowChanges changes = wmPtr->winPtr->changes; + return (x >= changes.x && + x < changes.x + changes.width && + y >= changes.y - wmPtr->menuHeight && + y < changes.y + changes.height); +} + Tk_Window Tk_CoordsToWindow( int rootX, int rootY, /* Coordinates of point in root window. If a @@ -5851,13 +5863,38 @@ Tk_CoordsToWindow( } for (wmPtr = (WmInfo *) dispPtr->firstWmPtr; wmPtr != NULL; wmPtr = wmPtr->nextPtr) { - if (wmPtr->reparent == child) { - goto gotToplevel; + if (wmPtr->winPtr->mainPtr == NULL) { + continue; + } + if (child == wmPtr->reparent) { + if (PointInWindow(x, y, wmPtr)) { + goto gotToplevel; + } else { + + /* + * Return NULL if the point is in the title bar or border. + */ + + return NULL; + } } if (wmPtr->wrapperPtr != NULL) { if (child == wmPtr->wrapperPtr->window) { goto gotToplevel; - } + } else if (wmPtr->winPtr->flags & TK_EMBEDDED && + TkpGetOtherWindow(wmPtr->winPtr) == NULL) { + + /* + * This toplevel is embedded in a window belonging to + * a different application. + */ + + int rx, ry; + Tk_GetRootCoords((Tk_Window) wmPtr->winPtr, &rx, &ry); + childX -= rx; + childY -= ry; + goto gotToplevel; + } } else if (child == wmPtr->winPtr->window) { goto gotToplevel; } @@ -5879,9 +5916,6 @@ Tk_CoordsToWindow( handler = NULL; } winPtr = wmPtr->winPtr; - if (winPtr->mainPtr != ((TkWindow *) tkwin)->mainPtr) { - return NULL; - } /* * Step 3: at this point winPtr and wmPtr refer to the toplevel that @@ -5938,27 +5972,30 @@ Tk_CoordsToWindow( if (nextPtr == NULL) { break; } - winPtr = nextPtr; - x -= winPtr->changes.x; - y -= winPtr->changes.y; - if ((winPtr->flags & TK_CONTAINER) - && (winPtr->flags & TK_BOTH_HALVES)) { + x -= nextPtr->changes.x; + y -= nextPtr->changes.y; + if ((nextPtr->flags & TK_CONTAINER) + && (nextPtr->flags & TK_BOTH_HALVES)) { /* * The window containing the point is a container, and the * embedded application is in this same process. Switch over to * the toplevel for the embedded application and start processing * that toplevel from scratch. */ - - winPtr = TkpGetOtherWindow(winPtr); + winPtr = TkpGetOtherWindow(nextPtr); if (winPtr == NULL) { - return NULL; + return (Tk_Window) nextPtr; } wmPtr = winPtr->wmInfoPtr; childX = x; childY = y; goto gotToplevel; - } + } else { + winPtr = nextPtr; + } + } + if (winPtr->mainPtr != ((TkWindow *) tkwin)->mainPtr) { + return NULL; } return (Tk_Window) winPtr; } diff --git a/win/tkWin3d.c b/win/tkWin3d.c index d3c443d..9f7ca22 100644 --- a/win/tkWin3d.c +++ b/win/tkWin3d.c @@ -127,7 +127,7 @@ Tk_3DVerticalBevel( HDC dc = TkWinGetDrawableDC(display, drawable, &state); int half; - if ((borderPtr->lightGC == None) && (relief != TK_RELIEF_FLAT)) { + if ((borderPtr->lightGC == NULL) && (relief != TK_RELIEF_FLAT)) { TkpGetShadows(borderPtr, tkwin); } @@ -222,7 +222,7 @@ Tk_3DHorizontalBevel( HDC dc = TkWinGetDrawableDC(display, drawable, &state); int topColor, bottomColor; - if ((borderPtr->lightGC == None) && (relief != TK_RELIEF_FLAT)) { + if ((borderPtr->lightGC == NULL) && (relief != TK_RELIEF_FLAT)) { TkpGetShadows(borderPtr, tkwin); } @@ -339,7 +339,7 @@ TkpGetShadows( int r, g, b; XGCValues gcValues; - if (borderPtr->lightGC != None) { + if (borderPtr->lightGC != NULL) { return; } @@ -540,7 +540,7 @@ TkWinGetBorderPixels( { WinBorder *borderPtr = (WinBorder *) border; - if (borderPtr->info.lightGC == None) { + if (borderPtr->info.lightGC == NULL) { TkpGetShadows(&borderPtr->info, tkwin); } switch (which) { diff --git a/win/tkWinButton.c b/win/tkWinButton.c index 9cd13a7..f4039cf 100644 --- a/win/tkWinButton.c +++ b/win/tkWinButton.c @@ -127,7 +127,7 @@ InitBoxes(void) HRSRC hrsrc; HGLOBAL hblk; LPBITMAPINFOHEADER newBitmap; - DWORD size; + size_t size; ThreadSpecificData *tsdPtr = (ThreadSpecificData *) Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); @@ -146,8 +146,9 @@ InitBoxes(void) if (tsdPtr->boxesPtr != NULL && !(tsdPtr->boxesPtr->biWidth % 4) && !(tsdPtr->boxesPtr->biHeight % 2)) { - size = tsdPtr->boxesPtr->biSize + (1 << tsdPtr->boxesPtr->biBitCount) - * sizeof(RGBQUAD) + tsdPtr->boxesPtr->biSizeImage; + size = tsdPtr->boxesPtr->biSize + + (sizeof(RGBQUAD) << tsdPtr->boxesPtr->biBitCount) + + tsdPtr->boxesPtr->biSizeImage; newBitmap = ckalloc(size); memcpy(newBitmap, tsdPtr->boxesPtr, size); tsdPtr->boxesPtr = newBitmap; @@ -156,7 +157,7 @@ InitBoxes(void) tsdPtr->boxesPalette = (DWORD*) (((LPSTR) tsdPtr->boxesPtr) + tsdPtr->boxesPtr->biSize); tsdPtr->boxesBits = ((LPSTR) tsdPtr->boxesPalette) - + ((1 << tsdPtr->boxesPtr->biBitCount) * sizeof(RGBQUAD)); + + (sizeof(RGBQUAD) << tsdPtr->boxesPtr->biBitCount); } else { tsdPtr->boxesPtr = NULL; } @@ -433,7 +434,7 @@ TkpDisplayButton( * Display image or bitmap or text for button. */ - if (butPtr->image != None) { + if (butPtr->image != NULL) { Tk_SizeOfImage(butPtr->image, &width, &height); haveImage = 1; } else if (butPtr->bitmap != None) { diff --git a/win/tkWinDefault.h b/win/tkWinDefault.h index a1c8f88..194ee1f 100644 --- a/win/tkWinDefault.h +++ b/win/tkWinDefault.h @@ -249,7 +249,7 @@ #define DEF_MENU_ENTRY_ACTIVE_FG NULL #define DEF_MENU_ENTRY_ACCELERATOR NULL #define DEF_MENU_ENTRY_BG NULL -#define DEF_MENU_ENTRY_BITMAP None +#define DEF_MENU_ENTRY_BITMAP NULL #define DEF_MENU_ENTRY_COLUMN_BREAK "0" #define DEF_MENU_ENTRY_COMMAND NULL #define DEF_MENU_ENTRY_COMPOUND "none" diff --git a/win/tkWinDialog.c b/win/tkWinDialog.c index 5a9034d..11b556a 100644 --- a/win/tkWinDialog.c +++ b/win/tkWinDialog.c @@ -3351,7 +3351,7 @@ FontchooserConfigureCmd( Tk_Window parent = Tk_NameToWindow(interp, Tcl_GetString(objv[i+1]), tkwin); - if (parent == None) { + if (parent == NULL) { return TCL_ERROR; } if (hdPtr->parentObj) { @@ -3446,7 +3446,7 @@ FontchooserShowCmd( if (hdPtr->parentObj) { parent = Tk_NameToWindow(interp, Tcl_GetString(hdPtr->parentObj), tkwin); - if (parent == None) { + if (parent == NULL) { return TCL_ERROR; } } diff --git a/win/tkWinFont.c b/win/tkWinFont.c index aa0697c..4ffa32b 100644 --- a/win/tkWinFont.c +++ b/win/tkWinFont.c @@ -988,7 +988,7 @@ Tk_MeasureChars( } *lengthPtr = curX; - return p - source; + return (int)(p - source); } /* diff --git a/win/tkWinImage.c b/win/tkWinImage.c index d61b84a..0a8ef73 100644 --- a/win/tkWinImage.c +++ b/win/tkWinImage.c @@ -347,7 +347,7 @@ XGetImageZPixmap( size = sizeof(BITMAPINFO); if (depth <= 8) { - size += sizeof(unsigned short) * (1 << depth); + size += sizeof(unsigned short) << depth; } bmInfo = ckalloc(size); diff --git a/win/tkWinMenu.c b/win/tkWinMenu.c index 6ac14c2..b172db2 100644 --- a/win/tkWinMenu.c +++ b/win/tkWinMenu.c @@ -2363,7 +2363,7 @@ DrawMenuEntryLabel( XFillRectangle(menuPtr->display, d, menuPtr->disabledGC, x, y, (unsigned) width, (unsigned) height); } else if ((mePtr->image != NULL) - && (menuPtr->disabledImageGC != None)) { + && (menuPtr->disabledImageGC != NULL)) { XFillRectangle(menuPtr->display, d, menuPtr->disabledImageGC, leftEdge + imageXOffset, (int) (y + (mePtr->height - imageHeight)/2 + imageYOffset), diff --git a/win/tkWinPort.h b/win/tkWinPort.h index 11b60f3..254f44e 100644 --- a/win/tkWinPort.h +++ b/win/tkWinPort.h @@ -91,6 +91,10 @@ * See ticket [916c1095438eae56]: GetVersionExW triggers warnings */ #if defined(_MSC_VER) +# pragma warning(disable:4267) +# pragma warning(disable:4244) +# pragma warning(disable:4311) +# pragma warning(disable:4312) # pragma warning(disable:4996) #endif diff --git a/win/tkWinTest.c b/win/tkWinTest.c index b99c47b..70465d6 100644 --- a/win/tkWinTest.c +++ b/win/tkWinTest.c @@ -570,7 +570,7 @@ TestwinlocaleObjCmd( Tcl_WrongNumArgs(interp, 1, objv, NULL); return TCL_ERROR; } - Tcl_SetObjResult(interp, Tcl_NewIntObj((int)GetThreadLocale())); + Tcl_SetObjResult(interp, Tcl_NewWideIntObj(GetThreadLocale())); return TCL_OK; } diff --git a/win/tkWinWm.c b/win/tkWinWm.c index 52a7d3d..81ae667 100644 --- a/win/tkWinWm.c +++ b/win/tkWinWm.c @@ -2625,7 +2625,7 @@ TkWmDeadWindow( VisibilityChangeMask|StructureNotifyMask, WmWaitVisibilityOrMapProc, wmPtr2->winPtr); wmPtr2->masterPtr = NULL; - if ((wmPtr2->wrapper != None) + if ((wmPtr2->wrapper != NULL) && !(wmPtr2->flags & (WM_NEVER_MAPPED))) { UpdateWrapper(wmPtr2->winPtr); } @@ -8623,7 +8623,7 @@ TkpWinToplevelDetachWindow( SendMessage(wmPtr->wrapper, TK_DETACHWINDOW, 0, 0); winPtr->flags &= ~TK_EMBEDDED; winPtr->privatePtr = NULL; - wmPtr->wrapper = None; + wmPtr->wrapper = NULL; if (state >= 0 && state <= 3) { wmPtr->hints.initial_state = state; } diff --git a/win/tkWinX.c b/win/tkWinX.c index e35fd3c..7b91596 100644 --- a/win/tkWinX.c +++ b/win/tkWinX.c @@ -539,7 +539,7 @@ TkpOpenDisplay( twdPtr = ckalloc(sizeof(TkWinDrawable)); if (twdPtr == NULL) { - return None; + return NULL; } twdPtr->type = TWD_WINDOW; twdPtr->window.winPtr = NULL; @@ -1837,8 +1837,8 @@ Tk_SetCaretPos( * Return the number of milliseconds the user was inactive. * * Results: - * Milliseconds of user inactive time or -1 if the user32.dll doesn't - * have the symbol GetLastInputInfo or GetLastInputInfo returns an error. + * Milliseconds of user inactive time or -1 if GetLastInputInfo + * returns an error. * * Side effects: * None. @@ -1853,7 +1853,7 @@ Tk_GetUserInactiveTime( LASTINPUTINFO li; li.cbSize = sizeof(li); - if (!(BOOL)GetLastInputInfo(&li)) { + if (!GetLastInputInfo(&li)) { return -1; } @@ -1875,7 +1875,7 @@ Tk_GetUserInactiveTime( * none * * Side effects: - * The user inactivity timer of the underlaying windowing system is reset + * The user inactivity timer of the underlying windowing system is reset * to zero. * *---------------------------------------------------------------------- diff --git a/xlib/X11/X.h b/xlib/X11/X.h index daf2283..2a9cd52 100644 --- a/xlib/X11/X.h +++ b/xlib/X11/X.h @@ -73,7 +73,7 @@ typedef unsigned long KeyCode; /* In order to use IME, the Macintosh needs * RESERVED RESOURCE AND CONSTANT DEFINITIONS *****************************************************************/ -#define None 0L /* universal null resource or null atom */ +/* #define None 0L See bug [9e31fd9449] and below */ #define ParentRelative 1L /* background pixmap in CreateWindow and ChangeWindowAttributes */ @@ -179,13 +179,16 @@ are reserved in the protocol for errors and replies. */ #define ShiftMask (1<<0) #define LockMask (1<<1) -#define ControlMask (1<<2) +/* #define ControlMask (1<<2) See bug [9e31fd9449] and below */ #define Mod1Mask (1<<3) #define Mod2Mask (1<<4) #define Mod3Mask (1<<5) #define Mod4Mask (1<<6) #define Mod5Mask (1<<7) +/* See bug [9e31fd9449], this way prevents conflicts with Win32 headers */ +enum _Bug9e31fd9449 { None = 0, ControlMask = (1<<2) }; + /* modifier names. Used to build a SetModifierMapping request or to read a GetModifierMapping request. These correspond to the masks defined above. */ @@ -50,7 +50,7 @@ static TkpClipMask *AllocClipMask(GC gc) { TkpClipMask *clip_mask = (TkpClipMask*) gc->clip_mask; - if (clip_mask == None) { + if (clip_mask == NULL) { clip_mask = ckalloc(sizeof(TkpClipMask)); gc->clip_mask = (Pixmap) clip_mask; #ifdef MAC_OSX_TK @@ -125,7 +125,7 @@ XCreateGC( gp = ckalloc(sizeof(XGCValues) + MAX_DASH_LIST_SIZE + gcCacheSize); if (!gp) { - return None; + return NULL; } #define InitField(name,maskbit,default) \ @@ -268,7 +268,7 @@ int XFreeGC( Display *d, GC gc) { - if (gc != None) { + if (gc != NULL) { FreeClipMask(gc); TkpFreeGCCache(gc); ckfree(gc); @@ -464,8 +464,8 @@ TkSetRegion( GC gc, TkRegion r) { - if (r == None) { - Tcl_Panic("must not pass None to TkSetRegion for compatibility with X11; use XSetClipMask instead"); + if (r == NULL) { + Tcl_Panic("must not pass NULL to TkSetRegion for compatibility with X11; use XSetClipMask instead"); } else { TkpClipMask *clip_mask = AllocClipMask(gc); diff --git a/xlib/xutil.c b/xlib/xutil.c index c629b82..1e81549 100644 --- a/xlib/xutil.c +++ b/xlib/xutil.c @@ -10,9 +10,6 @@ */ #include "tkInt.h" -#include <X11/Xlib.h> -#include <X11/Xutil.h> -#include <X11/Xatom.h> /* *---------------------------------------------------------------------- |