diff options
-rw-r--r-- | generic/tkAtom.c | 6 | ||||
-rw-r--r-- | generic/tkBind.c | 6 | ||||
-rw-r--r-- | generic/tkBitmap.c | 50 | ||||
-rw-r--r-- | generic/tkBusy.c | 2 | ||||
-rw-r--r-- | generic/tkClipboard.c | 12 | ||||
-rw-r--r-- | generic/tkColor.c | 26 | ||||
-rw-r--r-- | generic/tkConfig.c | 2 | ||||
-rw-r--r-- | generic/tkCursor.c | 30 | ||||
-rw-r--r-- | generic/tkError.c | 2 | ||||
-rw-r--r-- | generic/tkFocus.c | 14 | ||||
-rw-r--r-- | generic/tkFont.c | 2 | ||||
-rw-r--r-- | generic/tkGC.c | 11 | ||||
-rw-r--r-- | generic/tkObj.c | 6 | ||||
-rw-r--r-- | generic/tkSelect.c | 2 | ||||
-rw-r--r-- | generic/tkStubLib.c | 2 | ||||
-rw-r--r-- | generic/tkStyle.c | 8 | ||||
-rw-r--r-- | generic/tkTextImage.c | 4 | ||||
-rw-r--r-- | generic/tkTextWind.c | 2 | ||||
-rw-r--r-- | generic/tkUndo.c | 10 | ||||
-rw-r--r-- | generic/tkVisual.c | 58 | ||||
-rw-r--r-- | macosx/tkMacOSXDefault.h | 2 | ||||
-rw-r--r-- | macosx/tkMacOSXFont.c | 3 | ||||
-rw-r--r-- | macosx/ttkMacOSXTheme.c | 4 | ||||
-rw-r--r-- | tests/bind.test | 28 | ||||
-rw-r--r-- | tests/constraints.tcl | 61 | ||||
-rw-r--r-- | tests/event.test | 5 | ||||
-rw-r--r-- | tests/menu.test | 5 | ||||
-rw-r--r-- | tests/textTag.test | 37 | ||||
-rw-r--r-- | win/rules.vc | 24 |
29 files changed, 250 insertions, 174 deletions
diff --git a/generic/tkAtom.c b/generic/tkAtom.c index 2491fb2..475f9d2 100644 --- a/generic/tkAtom.c +++ b/generic/tkAtom.c @@ -154,11 +154,11 @@ Tk_GetAtomName( if (mustFree) { XFree(mustFree); } - name = Tcl_GetHashKey(&dispPtr->nameTable, hPtr); + name = (const char *)Tcl_GetHashKey(&dispPtr->nameTable, hPtr); hPtr = Tcl_CreateHashEntry(&dispPtr->atomTable, INT2PTR(atom), &isNew); Tcl_SetHashValue(hPtr, name); } - return Tcl_GetHashValue(hPtr); + return (const char *)Tcl_GetHashValue(hPtr); } /* @@ -200,7 +200,7 @@ AtomInit( name = atomNameArray[atom - 1]; hPtr = Tcl_CreateHashEntry(&dispPtr->nameTable, name, &isNew); Tcl_SetHashValue(hPtr, INT2PTR(atom)); - name = Tcl_GetHashKey(&dispPtr->nameTable, hPtr); + name = (const char *)Tcl_GetHashKey(&dispPtr->nameTable, hPtr); hPtr = Tcl_CreateHashEntry(&dispPtr->atomTable, INT2PTR(atom), &isNew); Tcl_SetHashValue(hPtr, name); } diff --git a/generic/tkBind.c b/generic/tkBind.c index ad59299..da52c61 100644 --- a/generic/tkBind.c +++ b/generic/tkBind.c @@ -4490,13 +4490,13 @@ NameToWindow( * * DoWarp -- * - * Perform Warping of X pointer. Executed as an idle handler only. + * Perform warping of mouse pointer. Executed as an idle handler only. * * Results: * None * * Side effects: - * X Pointer will move to a new location. + * Mouse pointer moves to a new location. * *------------------------------------------------------------------------- */ @@ -4505,7 +4505,7 @@ static void DoWarp( ClientData clientData) { - TkDisplay *dispPtr = clientData; + TkDisplay *dispPtr = (TkDisplay *)clientData; assert(clientData); diff --git a/generic/tkBitmap.c b/generic/tkBitmap.c index 54bab69..ccc97a4 100644 --- a/generic/tkBitmap.c +++ b/generic/tkBitmap.c @@ -167,7 +167,7 @@ Tk_AllocBitmapFromObj( if (objPtr->typePtr != &tkBitmapObjType) { InitBitmapObj(objPtr); } - bitmapPtr = objPtr->internalRep.twoPtrValue.ptr1; + bitmapPtr = (TkBitmap *)objPtr->internalRep.twoPtrValue.ptr1; /* * If the object currently points to a TkBitmap, see if it's the one we @@ -197,7 +197,7 @@ Tk_AllocBitmapFromObj( */ if (bitmapPtr != NULL) { - TkBitmap *firstBitmapPtr = Tcl_GetHashValue(bitmapPtr->nameHashPtr); + TkBitmap *firstBitmapPtr = (TkBitmap *)Tcl_GetHashValue(bitmapPtr->nameHashPtr); FreeBitmapObj(objPtr); for (bitmapPtr = firstBitmapPtr; bitmapPtr != NULL; @@ -307,7 +307,7 @@ GetBitmap( Pixmap bitmap; int isNew, width = 0, height = 0, dummy2; TkDisplay *dispPtr = ((TkWindow *) tkwin)->dispPtr; - ThreadSpecificData *tsdPtr = + ThreadSpecificData *tsdPtr = (ThreadSpecificData *) Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); if (!dispPtr->bitmapInit) { @@ -317,7 +317,7 @@ GetBitmap( nameHashPtr = Tcl_CreateHashEntry(&dispPtr->bitmapNameTable, string, &isNew); if (!isNew) { - existingBitmapPtr = Tcl_GetHashValue(nameHashPtr); + existingBitmapPtr = (TkBitmap *)Tcl_GetHashValue(nameHashPtr); for (bitmapPtr = existingBitmapPtr; bitmapPtr != NULL; bitmapPtr = bitmapPtr->nextPtr) { if ((Tk_Display(tkwin) == bitmapPtr->display) && @@ -395,7 +395,7 @@ GetBitmap( goto error; } } else { - predefPtr = Tcl_GetHashValue(predefHashPtr); + predefPtr = (TkPredefBitmap *)Tcl_GetHashValue(predefHashPtr); width = predefPtr->width; height = predefPtr->height; if (predefPtr->native) { @@ -407,7 +407,7 @@ GetBitmap( } else { bitmap = XCreateBitmapFromData(Tk_Display(tkwin), RootWindowOfScreen(Tk_Screen(tkwin)), - predefPtr->source, (unsigned)width, (unsigned)height); + (const char *)predefPtr->source, (unsigned)width, (unsigned)height); } } } @@ -416,7 +416,7 @@ GetBitmap( * Add information about this bitmap to our database. */ - bitmapPtr = ckalloc(sizeof(TkBitmap)); + bitmapPtr = (TkBitmap *)ckalloc(sizeof(TkBitmap)); bitmapPtr->bitmap = bitmap; bitmapPtr->width = width; bitmapPtr->height = height; @@ -474,7 +474,7 @@ Tk_DefineBitmap( int isNew; Tcl_HashEntry *predefHashPtr; TkPredefBitmap *predefPtr; - ThreadSpecificData *tsdPtr = + ThreadSpecificData *tsdPtr = (ThreadSpecificData *) Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); /* @@ -497,7 +497,7 @@ Tk_DefineBitmap( Tcl_SetErrorCode(interp, "TK", "BITMAP", "EXISTS", NULL); return TCL_ERROR; } - predefPtr = ckalloc(sizeof(TkPredefBitmap)); + predefPtr = (TkPredefBitmap *)ckalloc(sizeof(TkPredefBitmap)); predefPtr->source = source; predefPtr->width = width; predefPtr->height = height; @@ -540,7 +540,7 @@ Tk_NameOfBitmap( if (idHashPtr == NULL) { goto unknown; } - bitmapPtr = Tcl_GetHashValue(idHashPtr); + bitmapPtr = (TkBitmap *)Tcl_GetHashValue(idHashPtr); return bitmapPtr->nameHashPtr->key.string; } @@ -582,7 +582,7 @@ Tk_SizeOfBitmap( if (idHashPtr == NULL) { goto unknownBitmap; } - bitmapPtr = Tcl_GetHashValue(idHashPtr); + bitmapPtr = (TkBitmap *)Tcl_GetHashValue(idHashPtr); *widthPtr = bitmapPtr->width; *heightPtr = bitmapPtr->height; } @@ -612,14 +612,13 @@ FreeBitmap( { TkBitmap *prevPtr; - bitmapPtr->resourceRefCount--; - if (bitmapPtr->resourceRefCount > 0) { + if (bitmapPtr->resourceRefCount-- > 1) { return; } Tk_FreePixmap(bitmapPtr->display, bitmapPtr->bitmap); Tcl_DeleteHashEntry(bitmapPtr->idHashPtr); - prevPtr = Tcl_GetHashValue(bitmapPtr->nameHashPtr); + prevPtr = (TkBitmap *)Tcl_GetHashValue(bitmapPtr->nameHashPtr); if (prevPtr == bitmapPtr) { if (bitmapPtr->nextPtr == NULL) { Tcl_DeleteHashEntry(bitmapPtr->nameHashPtr); @@ -671,7 +670,7 @@ Tk_FreeBitmap( if (idHashPtr == NULL) { Tcl_Panic("Tk_FreeBitmap received unknown bitmap argument"); } - FreeBitmap(Tcl_GetHashValue(idHashPtr)); + FreeBitmap((TkBitmap *)Tcl_GetHashValue(idHashPtr)); } /* @@ -735,7 +734,7 @@ static void FreeBitmapObj( Tcl_Obj *objPtr) /* The object we are releasing. */ { - TkBitmap *bitmapPtr = objPtr->internalRep.twoPtrValue.ptr1; + TkBitmap *bitmapPtr = (TkBitmap *)objPtr->internalRep.twoPtrValue.ptr1; if (bitmapPtr != NULL) { bitmapPtr->objRefCount--; @@ -770,7 +769,7 @@ DupBitmapObjProc( Tcl_Obj *srcObjPtr, /* The object we are copying from. */ Tcl_Obj *dupObjPtr) /* The object we are copying to. */ { - TkBitmap *bitmapPtr = srcObjPtr->internalRep.twoPtrValue.ptr1; + TkBitmap *bitmapPtr = (TkBitmap *)srcObjPtr->internalRep.twoPtrValue.ptr1; dupObjPtr->typePtr = srcObjPtr->typePtr; dupObjPtr->internalRep.twoPtrValue.ptr1 = bitmapPtr; @@ -806,7 +805,6 @@ DupBitmapObjProc( *---------------------------------------------------------------------- */ - /* ARGSUSED */ Pixmap Tk_GetBitmapFromData( Tcl_Interp *interp, /* Interpreter to use for error reporting. */ @@ -820,20 +818,20 @@ Tk_GetBitmapFromData( char string[16 + TCL_INTEGER_SPACE]; char *name; TkDisplay *dispPtr = ((TkWindow *) tkwin)->dispPtr; - ThreadSpecificData *tsdPtr = + ThreadSpecificData *tsdPtr = (ThreadSpecificData *) Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); if (!tsdPtr->initialized) { BitmapInit(dispPtr); } - nameKey.source = source; + nameKey.source = (const char *)source; nameKey.width = width; nameKey.height = height; dataHashPtr = Tcl_CreateHashEntry(&dispPtr->bitmapDataTable, (char *) &nameKey, &isNew); if (!isNew) { - name = Tcl_GetHashValue(dataHashPtr); + name = (char *)Tcl_GetHashValue(dataHashPtr); } else { dispPtr->bitmapAutoNumber++; sprintf(string, "_tk%d", dispPtr->bitmapAutoNumber); @@ -911,7 +909,7 @@ GetBitmapFromObj( InitBitmapObj(objPtr); } - bitmapPtr = objPtr->internalRep.twoPtrValue.ptr1; + bitmapPtr = (TkBitmap *)objPtr->internalRep.twoPtrValue.ptr1; if (bitmapPtr != NULL) { if ((bitmapPtr->resourceRefCount > 0) && (Tk_Display(tkwin) == bitmapPtr->display)) { @@ -932,7 +930,7 @@ GetBitmapFromObj( * more TkBitmap structures. See if any of them will work. */ - for (bitmapPtr = Tcl_GetHashValue(hashPtr); bitmapPtr != NULL; + for (bitmapPtr = (TkBitmap *)Tcl_GetHashValue(hashPtr); bitmapPtr != NULL; bitmapPtr = bitmapPtr->nextPtr) { if (Tk_Display(tkwin) == bitmapPtr->display) { objPtr->internalRep.twoPtrValue.ptr1 = bitmapPtr; @@ -1012,7 +1010,7 @@ BitmapInit( * or NULL if unavailable. */ { Tcl_Interp *dummy; - ThreadSpecificData *tsdPtr = + ThreadSpecificData *tsdPtr = (ThreadSpecificData *) Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); /* @@ -1150,7 +1148,7 @@ TkDebugBitmap( resultPtr = Tcl_NewObj(); hashPtr = Tcl_FindHashEntry(&dispPtr->bitmapNameTable, name); if (hashPtr != NULL) { - bitmapPtr = Tcl_GetHashValue(hashPtr); + bitmapPtr = (TkBitmap *)Tcl_GetHashValue(hashPtr); if (bitmapPtr == NULL) { Tcl_Panic("TkDebugBitmap found empty hash table entry"); } @@ -1190,7 +1188,7 @@ TkDebugBitmap( Tcl_HashTable * TkGetBitmapPredefTable(void) { - ThreadSpecificData *tsdPtr = + ThreadSpecificData *tsdPtr = (ThreadSpecificData *) Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); return &tsdPtr->predefBitmapTable; diff --git a/generic/tkBusy.c b/generic/tkBusy.c index 1e4e91f..6f58c52 100644 --- a/generic/tkBusy.c +++ b/generic/tkBusy.c @@ -340,7 +340,7 @@ DestroyBusy( RefWinEventProc, busyPtr); if (busyPtr->tkBusy != NULL) { - Tk_FreeConfigOptions(data, busyPtr->optionTable, busyPtr->tkBusy); + Tk_FreeConfigOptions((char *)data, busyPtr->optionTable, busyPtr->tkBusy); Tk_DeleteEventHandler(busyPtr->tkBusy, StructureNotifyMask, BusyEventProc, busyPtr); Tk_ManageGeometry(busyPtr->tkBusy, NULL, busyPtr); diff --git a/generic/tkClipboard.c b/generic/tkClipboard.c index 8bc4237..e800da9 100644 --- a/generic/tkClipboard.c +++ b/generic/tkClipboard.c @@ -134,22 +134,22 @@ ClipboardAppHandler( char *buffer, /* Place to store converted selection. */ int maxBytes) /* Maximum # of bytes to store at buffer. */ { - TkDisplay *dispPtr = clientData; - size_t length; + TkDisplay *dispPtr = (TkDisplay *)clientData; + int length; const char *p; p = dispPtr->clipboardAppPtr->winPtr->nameUid; length = strlen(p); - length -= offset; - if (length <= 0) { + if (length <= offset) { return 0; } - if (length > (size_t) maxBytes) { + length -= offset; + if (length > maxBytes) { length = maxBytes; } memcpy(buffer, p, length); buffer[length] = 0; - return (int)length; + return length; } /* diff --git a/generic/tkColor.c b/generic/tkColor.c index 48d17ac..6b6405a 100644 --- a/generic/tkColor.c +++ b/generic/tkColor.c @@ -128,7 +128,7 @@ Tk_AllocColorFromObj( */ if (tkColPtr != NULL) { - TkColor *firstColorPtr = Tcl_GetHashValue(tkColPtr->hashPtr); + TkColor *firstColorPtr = (TkColor *)Tcl_GetHashValue(tkColPtr->hashPtr); FreeColorObj(objPtr); for (tkColPtr = firstColorPtr; tkColPtr != NULL; @@ -203,7 +203,7 @@ Tk_GetColor( nameHashPtr = Tcl_CreateHashEntry(&dispPtr->colorNameTable, name, &isNew); if (!isNew) { - existingColPtr = Tcl_GetHashValue(nameHashPtr); + existingColPtr = (TkColor *)Tcl_GetHashValue(nameHashPtr); for (tkColPtr = existingColPtr; tkColPtr != NULL; tkColPtr = tkColPtr->nextPtr) { if ((tkColPtr->screen == Tk_Screen(tkwin)) @@ -314,7 +314,7 @@ Tk_GetColorByValue( valueHashPtr = Tcl_CreateHashEntry(&dispPtr->colorValueTable, (char *) &valueKey, &isNew); if (!isNew) { - tkColPtr = Tcl_GetHashValue(valueHashPtr); + tkColPtr = (TkColor *)Tcl_GetHashValue(valueHashPtr); tkColPtr->resourceRefCount++; return &tkColPtr->color; } @@ -368,7 +368,7 @@ Tk_NameOfColor( if (tkColPtr->magic==COLOR_MAGIC && tkColPtr->type==TK_COLOR_BY_NAME) { return tkColPtr->hashPtr->key.string; } else { - ThreadSpecificData *tsdPtr = + ThreadSpecificData *tsdPtr = (ThreadSpecificData *) Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); sprintf(tsdPtr->rgbString, "#%04x%04x%04x", colorPtr->red, @@ -480,8 +480,7 @@ Tk_FreeColor( Tcl_Panic("Tk_FreeColor called with bogus color"); } - tkColPtr->resourceRefCount--; - if (tkColPtr->resourceRefCount > 0) { + if (tkColPtr->resourceRefCount-- > 1) { return; } @@ -497,7 +496,7 @@ Tk_FreeColor( } TkpFreeColor(tkColPtr); - prevPtr = Tcl_GetHashValue(tkColPtr->hashPtr); + prevPtr = (TkColor *)Tcl_GetHashValue(tkColPtr->hashPtr); if (prevPtr == tkColPtr) { if (tkColPtr->nextPtr == NULL) { Tcl_DeleteHashEntry(tkColPtr->hashPtr); @@ -584,11 +583,10 @@ static void FreeColorObj( Tcl_Obj *objPtr) /* The object we are releasing. */ { - TkColor *tkColPtr = objPtr->internalRep.twoPtrValue.ptr1; + TkColor *tkColPtr = (TkColor *)objPtr->internalRep.twoPtrValue.ptr1; if (tkColPtr != NULL) { - tkColPtr->objRefCount--; - if ((tkColPtr->objRefCount == 0) + if ((tkColPtr->objRefCount-- <= 1) && (tkColPtr->resourceRefCount == 0)) { ckfree(tkColPtr); } @@ -619,7 +617,7 @@ DupColorObjProc( Tcl_Obj *srcObjPtr, /* The object we are copying from. */ Tcl_Obj *dupObjPtr) /* The object we are copying to. */ { - TkColor *tkColPtr = srcObjPtr->internalRep.twoPtrValue.ptr1; + TkColor *tkColPtr = (TkColor *)srcObjPtr->internalRep.twoPtrValue.ptr1; dupObjPtr->typePtr = srcObjPtr->typePtr; dupObjPtr->internalRep.twoPtrValue.ptr1 = tkColPtr; @@ -669,7 +667,7 @@ Tk_GetColorFromObj( * map. If it is, we are done. */ - tkColPtr = objPtr->internalRep.twoPtrValue.ptr1; + tkColPtr = (TkColor *)objPtr->internalRep.twoPtrValue.ptr1; if ((tkColPtr != NULL) && (tkColPtr->resourceRefCount > 0) && (Tk_Screen(tkwin) == tkColPtr->screen) @@ -695,7 +693,7 @@ Tk_GetColorFromObj( if (hashPtr == NULL) { goto error; } - for (tkColPtr = Tcl_GetHashValue(hashPtr); + for (tkColPtr = (TkColor *)Tcl_GetHashValue(hashPtr); (tkColPtr != NULL); tkColPtr = tkColPtr->nextPtr) { if ((Tk_Screen(tkwin) == tkColPtr->screen) && (Tk_Colormap(tkwin) == tkColPtr->colormap)) { @@ -811,7 +809,7 @@ TkDebugColor( resultPtr = Tcl_NewObj(); hashPtr = Tcl_FindHashEntry(&dispPtr->colorNameTable, name); if (hashPtr != NULL) { - TkColor *tkColPtr = Tcl_GetHashValue(hashPtr); + TkColor *tkColPtr = (TkColor *)Tcl_GetHashValue(hashPtr); if (tkColPtr == NULL) { Tcl_Panic("TkDebugColor found empty hash table entry"); diff --git a/generic/tkConfig.c b/generic/tkConfig.c index 8381a0a..6a0ffd8 100644 --- a/generic/tkConfig.c +++ b/generic/tkConfig.c @@ -664,7 +664,7 @@ DoObjConfig( if (internalPtr != NULL) { if (valuePtr != NULL) { value = Tcl_GetStringFromObj(valuePtr, &length); - newStr = ckalloc(length + 1); + newStr = (char *)ckalloc(length + 1); strcpy(newStr, value); } else { newStr = NULL; diff --git a/generic/tkCursor.c b/generic/tkCursor.c index 1e49c64..902472b 100644 --- a/generic/tkCursor.c +++ b/generic/tkCursor.c @@ -100,7 +100,7 @@ Tk_AllocCursorFromObj( if (objPtr->typePtr != &tkCursorObjType) { InitCursorObj(objPtr); } - cursorPtr = objPtr->internalRep.twoPtrValue.ptr1; + cursorPtr = (TkCursor *)objPtr->internalRep.twoPtrValue.ptr1; /* * If the object currently points to a TkCursor, see if it's the one we @@ -129,7 +129,7 @@ Tk_AllocCursorFromObj( */ if (cursorPtr != NULL) { - TkCursor *firstCursorPtr = Tcl_GetHashValue(cursorPtr->hashPtr); + TkCursor *firstCursorPtr = (TkCursor *)Tcl_GetHashValue(cursorPtr->hashPtr); FreeCursorObj(objPtr); for (cursorPtr = firstCursorPtr; cursorPtr != NULL; @@ -241,7 +241,7 @@ TkcGetCursor( nameHashPtr = Tcl_CreateHashEntry(&dispPtr->cursorNameTable, string, &isNew); if (!isNew) { - existingCursorPtr = Tcl_GetHashValue(nameHashPtr); + existingCursorPtr = (TkCursor *)Tcl_GetHashValue(nameHashPtr); for (cursorPtr = existingCursorPtr; cursorPtr != NULL; cursorPtr = cursorPtr->nextPtr) { if (Tk_Display(tkwin) == cursorPtr->display) { @@ -341,7 +341,7 @@ Tk_GetCursorFromData( dataHashPtr = Tcl_CreateHashEntry(&dispPtr->cursorDataTable, (char *) &dataKey, &isNew); if (!isNew) { - cursorPtr = Tcl_GetHashValue(dataHashPtr); + cursorPtr = (TkCursor *)Tcl_GetHashValue(dataHashPtr); cursorPtr->resourceRefCount++; return cursorPtr->cursor; } @@ -432,7 +432,7 @@ Tk_NameOfCursor( if (idHashPtr == NULL) { goto printid; } - cursorPtr = Tcl_GetHashValue(idHashPtr); + cursorPtr = (TkCursor *)Tcl_GetHashValue(idHashPtr); if (cursorPtr->otherTable != &dispPtr->cursorNameTable) { goto printid; } @@ -463,13 +463,12 @@ FreeCursor( { TkCursor *prevPtr; - cursorPtr->resourceRefCount--; - if (cursorPtr->resourceRefCount > 0) { + if (cursorPtr->resourceRefCount-- > 1) { return; } Tcl_DeleteHashEntry(cursorPtr->idHashPtr); - prevPtr = Tcl_GetHashValue(cursorPtr->hashPtr); + prevPtr = (TkCursor *)Tcl_GetHashValue(cursorPtr->hashPtr); if (prevPtr == cursorPtr) { if (cursorPtr->nextPtr == NULL) { Tcl_DeleteHashEntry(cursorPtr->hashPtr); @@ -522,7 +521,7 @@ Tk_FreeCursor( if (idHashPtr == NULL) { Tcl_Panic("Tk_FreeCursor received unknown cursor argument"); } - FreeCursor(Tcl_GetHashValue(idHashPtr)); + FreeCursor((TkCursor *)Tcl_GetHashValue(idHashPtr)); } /* @@ -587,11 +586,10 @@ static void FreeCursorObj( Tcl_Obj *objPtr) /* The object we are releasing. */ { - TkCursor *cursorPtr = objPtr->internalRep.twoPtrValue.ptr1; + TkCursor *cursorPtr = (TkCursor *)objPtr->internalRep.twoPtrValue.ptr1; if (cursorPtr != NULL) { - cursorPtr->objRefCount--; - if ((cursorPtr->objRefCount == 0) + if ((cursorPtr->objRefCount-- <= 1) && (cursorPtr->resourceRefCount == 0)) { ckfree(cursorPtr); } @@ -622,7 +620,7 @@ DupCursorObjProc( Tcl_Obj *srcObjPtr, /* The object we are copying from. */ Tcl_Obj *dupObjPtr) /* The object we are copying to. */ { - TkCursor *cursorPtr = srcObjPtr->internalRep.twoPtrValue.ptr1; + TkCursor *cursorPtr = (TkCursor *)srcObjPtr->internalRep.twoPtrValue.ptr1; dupObjPtr->typePtr = srcObjPtr->typePtr; dupObjPtr->internalRep.twoPtrValue.ptr1 = cursorPtr; @@ -707,7 +705,7 @@ GetCursorFromObj( * cached is the one that is needed. */ - cursorPtr = objPtr->internalRep.twoPtrValue.ptr1; + cursorPtr = (TkCursor *)objPtr->internalRep.twoPtrValue.ptr1; if ((cursorPtr != NULL) && (Tk_Display(tkwin) == cursorPtr->display)) { return cursorPtr; } @@ -722,7 +720,7 @@ GetCursorFromObj( if (hashPtr == NULL) { goto error; } - for (cursorPtr = Tcl_GetHashValue(hashPtr); + for (cursorPtr = (TkCursor *)Tcl_GetHashValue(hashPtr); cursorPtr != NULL; cursorPtr = cursorPtr->nextPtr) { if (Tk_Display(tkwin) == cursorPtr->display) { FreeCursorObj(objPtr); @@ -857,7 +855,7 @@ TkDebugCursor( resultPtr = Tcl_NewObj(); hashPtr = Tcl_FindHashEntry(&dispPtr->cursorNameTable, name); if (hashPtr != NULL) { - cursorPtr = Tcl_GetHashValue(hashPtr); + cursorPtr = (TkCursor *)Tcl_GetHashValue(hashPtr); if (cursorPtr == NULL) { Tcl_Panic("TkDebugCursor found empty hash table entry"); } diff --git a/generic/tkError.c b/generic/tkError.c index 277d7f0..6ff5475 100644 --- a/generic/tkError.c +++ b/generic/tkError.c @@ -107,7 +107,7 @@ Tk_CreateErrorHandler( * Create the handler record. */ - errorPtr = ckalloc(sizeof(TkErrorHandler)); + errorPtr = (TkErrorHandler *)ckalloc(sizeof(TkErrorHandler)); errorPtr->dispPtr = dispPtr; errorPtr->firstRequest = NextRequest(display); errorPtr->lastRequest = (unsigned) -1; diff --git a/generic/tkFocus.c b/generic/tkFocus.c index 42ac6bf..8066afd 100644 --- a/generic/tkFocus.c +++ b/generic/tkFocus.c @@ -113,8 +113,8 @@ Tk_FocusObjCmd( static const char *const focusOptions[] = { "-displayof", "-force", "-lastfor", NULL }; - Tk_Window tkwin = clientData; - TkWindow *winPtr = clientData; + Tk_Window tkwin = (Tk_Window)clientData; + TkWindow *winPtr = (TkWindow *)clientData; TkWindow *newPtr, *topLevelPtr; ToplevelFocusInfo *tlFocusPtr; const char *windowName; @@ -415,7 +415,7 @@ TkFocusFilterEvent( } } if (tlFocusPtr == NULL) { - tlFocusPtr = ckalloc(sizeof(ToplevelFocusInfo)); + tlFocusPtr = (ToplevelFocusInfo *)ckalloc(sizeof(ToplevelFocusInfo)); tlFocusPtr->topLevelPtr = tlFocusPtr->focusWinPtr = winPtr; tlFocusPtr->nextPtr = winPtr->mainPtr->tlFocusPtr; winPtr->mainPtr->tlFocusPtr = tlFocusPtr; @@ -622,7 +622,7 @@ TkSetFocusWin( } } if (tlFocusPtr == NULL) { - tlFocusPtr = ckalloc(sizeof(ToplevelFocusInfo)); + tlFocusPtr = (ToplevelFocusInfo *)ckalloc(sizeof(ToplevelFocusInfo)); tlFocusPtr->topLevelPtr = topLevelPtr; tlFocusPtr->nextPtr = winPtr->mainPtr->tlFocusPtr; winPtr->mainPtr->tlFocusPtr = tlFocusPtr; @@ -961,7 +961,7 @@ FocusMapProc( ClientData clientData, /* Toplevel window. */ XEvent *eventPtr) /* Information about event. */ { - TkWindow *winPtr = clientData; + TkWindow *winPtr = (TkWindow *)clientData; DisplayFocusInfo *displayFocusPtr; if (eventPtr->type == VisibilityNotify) { @@ -1015,7 +1015,7 @@ FindDisplayFocusInfo( * The record doesn't exist yet. Make a new one. */ - displayFocusPtr = ckalloc(sizeof(DisplayFocusInfo)); + displayFocusPtr = (DisplayFocusInfo *)ckalloc(sizeof(DisplayFocusInfo)); displayFocusPtr->dispPtr = dispPtr; displayFocusPtr->focusWinPtr = NULL; displayFocusPtr->focusOnMapPtr = NULL; @@ -1143,7 +1143,7 @@ TkFocusSplit( * Move focus to new toplevel. */ - ToplevelFocusInfo *newTlFocusPtr = ckalloc(sizeof(ToplevelFocusInfo)); + ToplevelFocusInfo *newTlFocusPtr = (ToplevelFocusInfo *)ckalloc(sizeof(ToplevelFocusInfo)); newTlFocusPtr->topLevelPtr = winPtr; newTlFocusPtr->focusWinPtr = tlFocusPtr->focusWinPtr; diff --git a/generic/tkFont.c b/generic/tkFont.c index 3e4044f..9c157db 100644 --- a/generic/tkFont.c +++ b/generic/tkFont.c @@ -3780,7 +3780,7 @@ NewChunk( if (layoutPtr->numChunks == maxChunks) { maxChunks *= 2; s = Tk_Offset(TextLayout, chunks) + (maxChunks * sizeof(LayoutChunk)); - layoutPtr = ckrealloc(layoutPtr, s); + layoutPtr = (TextLayout *)ckrealloc(layoutPtr, s); *layoutPtrPtr = layoutPtr; *maxPtr = maxChunks; diff --git a/generic/tkGC.c b/generic/tkGC.c index a03c156..8744ec4 100644 --- a/generic/tkGC.c +++ b/generic/tkGC.c @@ -218,7 +218,7 @@ Tk_GetGC( valueHashPtr = Tcl_CreateHashEntry(&dispPtr->gcValueTable, (char *) &valueKey, &isNew); if (!isNew) { - gcPtr = Tcl_GetHashValue(valueHashPtr); + gcPtr = (TkGC *)Tcl_GetHashValue(valueHashPtr); gcPtr->refCount++; return gcPtr->gc; } @@ -228,7 +228,7 @@ Tk_GetGC( * and add a new structure to the database. */ - gcPtr = ckalloc(sizeof(TkGC)); + gcPtr = (TkGC *)ckalloc(sizeof(TkGC)); /* * Find or make a drawable to use to specify the screen and depth of the @@ -311,9 +311,8 @@ Tk_FreeGC( if (idHashPtr == NULL) { Tcl_Panic("Tk_FreeGC received unknown gc argument"); } - gcPtr = Tcl_GetHashValue(idHashPtr); - gcPtr->refCount--; - if (gcPtr->refCount == 0) { + gcPtr = (TkGC *)Tcl_GetHashValue(idHashPtr); + if (gcPtr->refCount-- <= 1) { XFreeGC(gcPtr->display, gcPtr->gc); Tcl_DeleteHashEntry(gcPtr->valueHashPtr); Tcl_DeleteHashEntry(idHashPtr); @@ -348,7 +347,7 @@ TkGCCleanup( for (entryPtr = Tcl_FirstHashEntry(&dispPtr->gcIdTable, &search); entryPtr != NULL; entryPtr = Tcl_NextHashEntry(&search)) { - gcPtr = Tcl_GetHashValue(entryPtr); + gcPtr = (TkGC *)Tcl_GetHashValue(entryPtr); XFreeGC(gcPtr->display, gcPtr->gc); Tcl_DeleteHashEntry(gcPtr->valueHashPtr); diff --git a/generic/tkObj.c b/generic/tkObj.c index db2e501..1552d11 100644 --- a/generic/tkObj.c +++ b/generic/tkObj.c @@ -934,8 +934,8 @@ DupWindowInternalRep( { WindowRep *oldPtr, *newPtr; - oldPtr = srcPtr->internalRep.twoPtrValue.ptr1; - newPtr = ckalloc(sizeof(WindowRep)); + oldPtr = (WindowRep *)srcPtr->internalRep.twoPtrValue.ptr1; + newPtr = (WindowRep *)ckalloc(sizeof(WindowRep)); newPtr->tkwin = oldPtr->tkwin; newPtr->mainPtr = oldPtr->mainPtr; newPtr->epoch = oldPtr->epoch; @@ -997,7 +997,7 @@ TkNewWindowObj( SetWindowFromAny(NULL, objPtr); - winPtr = objPtr->internalRep.twoPtrValue.ptr1; + winPtr = (WindowRep *)objPtr->internalRep.twoPtrValue.ptr1; winPtr->tkwin = tkwin; winPtr->mainPtr = mainPtr; winPtr->epoch = mainPtr->deletionEpoch; diff --git a/generic/tkSelect.c b/generic/tkSelect.c index 55fa473..f187f83 100644 --- a/generic/tkSelect.c +++ b/generic/tkSelect.c @@ -1325,7 +1325,7 @@ HandleTclCommand( char *buffer, /* Place to store converted selection. */ int maxBytes) /* Maximum # of bytes to store at buffer. */ { - CommandInfo *cmdInfoPtr = clientData; + CommandInfo *cmdInfoPtr = (CommandInfo *)clientData; int length; Tcl_Obj *command; const char *string; diff --git a/generic/tkStubLib.c b/generic/tkStubLib.c index ea48894..0400bfa 100644 --- a/generic/tkStubLib.c +++ b/generic/tkStubLib.c @@ -80,7 +80,7 @@ Tk_InitStubs( ClientData clientData = NULL; const char *actualVersion = tclStubsPtr->tcl_PkgRequireEx(interp, packageName, version, 0, &clientData); - const TkStubs *stubsPtr = clientData; + const TkStubs *stubsPtr = (const TkStubs *)clientData; if (actualVersion == NULL) { return NULL; diff --git a/generic/tkStyle.c b/generic/tkStyle.c index 1289f14..14bae66 100644 --- a/generic/tkStyle.c +++ b/generic/tkStyle.c @@ -1402,14 +1402,10 @@ Tk_AllocStyleFromObj( Tcl_Obj *objPtr) /* Object containing name of the style to * retrieve. */ { - Style *stylePtr; - if (objPtr->typePtr != &styleObjType) { SetStyleFromAny(interp, objPtr); } - stylePtr = objPtr->internalRep.twoPtrValue.ptr1; - - return (Tk_Style) stylePtr; + return (Tk_Style)objPtr->internalRep.twoPtrValue.ptr1; } /* @@ -1439,7 +1435,7 @@ Tk_GetStyleFromObj( SetStyleFromAny(NULL, objPtr); } - return objPtr->internalRep.twoPtrValue.ptr1; + return (Tk_Style)objPtr->internalRep.twoPtrValue.ptr1; } /* diff --git a/generic/tkTextImage.c b/generic/tkTextImage.c index b396314..776eb04 100644 --- a/generic/tkTextImage.c +++ b/generic/tkTextImage.c @@ -284,7 +284,7 @@ TkTextImageCmd( for (hPtr = Tcl_FirstHashEntry(&textPtr->sharedTextPtr->imageTable, &search); hPtr != NULL; hPtr = Tcl_NextHashEntry(&search)) { Tcl_ListObjAppendElement(NULL, resultObj, Tcl_NewStringObj( - Tcl_GetHashKey(&textPtr->sharedTextPtr->markTable, hPtr), -1)); + (const char *)Tcl_GetHashKey(&textPtr->sharedTextPtr->markTable, hPtr), -1)); } Tcl_SetObjResult(interp, resultObj); return TCL_OK; @@ -796,7 +796,7 @@ TkTextImageIndex( indexPtr->linePtr = eiPtr->body.ei.linePtr; indexPtr->byteIndex = TkTextSegToOffset(eiPtr, indexPtr->linePtr); - /* + /* * If indexPtr refers to somewhere outside the -startline/-endline * range limits of the widget, error out since the image indeed is not * reachable from this text widget (it may be reachable from a peer). diff --git a/generic/tkTextWind.c b/generic/tkTextWind.c index cb8e533..fdd5378 100644 --- a/generic/tkTextWind.c +++ b/generic/tkTextWind.c @@ -1352,7 +1352,7 @@ TkTextWindowIndex( indexPtr->tree = textPtr->sharedTextPtr->tree; indexPtr->linePtr = ewPtr->body.ew.linePtr; indexPtr->byteIndex = TkTextSegToOffset(ewPtr, indexPtr->linePtr); - + /* * If indexPtr refers to somewhere outside the -startline/-endline * range limits of the widget, error out since the window indeed is not diff --git a/generic/tkUndo.c b/generic/tkUndo.c index c66905d..7494332 100644 --- a/generic/tkUndo.c +++ b/generic/tkUndo.c @@ -94,7 +94,7 @@ TkUndoInsertSeparator( TkUndoAtom *separator; if (*stack!=NULL && (*stack)->type!=TK_UNDO_SEPARATOR) { - separator = ckalloc(sizeof(TkUndoAtom)); + separator = (TkUndoAtom *)ckalloc(sizeof(TkUndoAtom)); separator->type = TK_UNDO_SEPARATOR; TkUndoPushStack(stack,separator); return 1; @@ -181,7 +181,7 @@ TkUndoPushAction( { TkUndoAtom *atom; - atom = ckalloc(sizeof(TkUndoAtom)); + atom = (TkUndoAtom *)ckalloc(sizeof(TkUndoAtom)); atom->type = TK_UNDO_ACTION; atom->apply = apply; atom->revert = revert; @@ -237,7 +237,7 @@ TkUndoMakeCmdSubAtom( Tcl_Panic("NULL command and actionScript in TkUndoMakeCmdSubAtom"); } - atom = ckalloc(sizeof(TkUndoSubAtom)); + atom = (TkUndoSubAtom *)ckalloc(sizeof(TkUndoSubAtom)); atom->command = command; atom->funcPtr = NULL; atom->clientData = NULL; @@ -299,7 +299,7 @@ TkUndoMakeSubAtom( Tcl_Panic("NULL funcPtr in TkUndoMakeSubAtom"); } - atom = ckalloc(sizeof(TkUndoSubAtom)); + atom = (TkUndoSubAtom *)ckalloc(sizeof(TkUndoSubAtom)); atom->command = NULL; atom->funcPtr = funcPtr; atom->clientData = clientData; @@ -341,7 +341,7 @@ TkUndoInitStack( { TkUndoRedoStack *stack; /* An Undo/Redo stack */ - stack = ckalloc(sizeof(TkUndoRedoStack)); + stack = (TkUndoRedoStack *)ckalloc(sizeof(TkUndoRedoStack)); stack->undoStack = NULL; stack->redoStack = NULL; stack->interp = interp; diff --git a/generic/tkVisual.c b/generic/tkVisual.c index 567c552..9324499 100644 --- a/generic/tkVisual.c +++ b/generic/tkVisual.c @@ -96,10 +96,10 @@ Tk_GetVisual( * Tk_FreeColormap. */ { Tk_Window tkwin2; - XVisualInfo template, *visInfoList, *bestPtr; + XVisualInfo templ, *visInfoList, *bestPtr; long mask; Visual *visual; - ptrdiff_t length; + size_t length; int c, numVisuals, prio, bestPrio, i; const char *p; const VisualDictionary *dictPtr; @@ -137,20 +137,20 @@ Tk_GetVisual( for (cmapPtr = dispPtr->cmapPtr; cmapPtr != NULL; cmapPtr = cmapPtr->nextPtr) { if (cmapPtr->colormap == *colormapPtr) { - cmapPtr->refCount += 1; + cmapPtr->refCount++; break; } } } return visual; } - template.depth = Tk_Depth(tkwin2); - template.c_class = visual->c_class; - template.red_mask = visual->red_mask; - template.green_mask = visual->green_mask; - template.blue_mask = visual->blue_mask; - template.colormap_size = visual->map_entries; - template.bits_per_rgb = visual->bits_per_rgb; + templ.depth = Tk_Depth(tkwin2); + templ.c_class = visual->c_class; + templ.red_mask = visual->red_mask; + templ.green_mask = visual->green_mask; + templ.blue_mask = visual->blue_mask; + templ.colormap_size = visual->map_entries; + templ.bits_per_rgb = visual->bits_per_rgb; mask = VisualDepthMask|VisualClassMask|VisualRedMaskMask |VisualGreenMaskMask|VisualBlueMaskMask|VisualColormapSizeMask |VisualBitsPerRGBMask; @@ -178,7 +178,7 @@ Tk_GetVisual( Tcl_SetErrorCode(interp, "TK", "VALUE", "VISUALID", NULL); return NULL; } - template.visualid = visualId; + templ.visualid = visualId; mask = VisualIDMask; } else { /* @@ -192,16 +192,15 @@ Tk_GetVisual( } } length = p - string; - template.c_class = -1; + templ.c_class = -1; for (dictPtr = visualNames; dictPtr->name != NULL; dictPtr++) { - if ((dictPtr->name[0] == c) && (length >= dictPtr->minLength) - && (strncmp(string, dictPtr->name, - (size_t) length) == 0)) { - template.c_class = dictPtr->c_class; + if ((dictPtr->name[0] == c) && (length >= (size_t)dictPtr->minLength) + && (strncmp(string, dictPtr->name, length) == 0)) { + templ.c_class = dictPtr->c_class; break; } } - if (template.c_class == -1) { + if (templ.c_class == -1) { Tcl_Obj *msgObj = Tcl_ObjPrintf( "unknown or ambiguous visual name \"%s\": class must be ", string); @@ -218,8 +217,8 @@ Tk_GetVisual( p++; } if (*p == 0) { - template.depth = 10000; - } else if (Tcl_GetInt(interp, p, &template.depth) != TCL_OK) { + templ.depth = 10000; + } else if (Tcl_GetInt(interp, p, &templ.depth) != TCL_OK) { return NULL; } if (c == 'b') { @@ -234,9 +233,9 @@ Tk_GetVisual( * an error if there are none that match. */ - template.screen = Tk_ScreenNumber(tkwin); + templ.screen = Tk_ScreenNumber(tkwin); mask |= VisualScreenMask; - visInfoList = XGetVisualInfo(Tk_Display(tkwin), mask, &template, + visInfoList = XGetVisualInfo(Tk_Display(tkwin), mask, &templ, &numVisuals); if (visInfoList == NULL) { Tcl_SetObjResult(interp, Tcl_NewStringObj( @@ -286,11 +285,11 @@ Tk_GetVisual( goto newBest; } if (visInfoList[i].depth < bestPtr->depth) { - if (visInfoList[i].depth >= template.depth) { + if (visInfoList[i].depth >= templ.depth) { goto newBest; } } else if (visInfoList[i].depth > bestPtr->depth) { - if (bestPtr->depth < template.depth) { + if (bestPtr->depth < templ.depth) { goto newBest; } } else { @@ -324,11 +323,11 @@ Tk_GetVisual( cmapPtr = cmapPtr->nextPtr) { if (cmapPtr->shareable && (cmapPtr->visual == visual)) { *colormapPtr = cmapPtr->colormap; - cmapPtr->refCount += 1; + cmapPtr->refCount++; goto done; } } - cmapPtr = ckalloc(sizeof(TkColormap)); + cmapPtr = (TkColormap *)ckalloc(sizeof(TkColormap)); cmapPtr->colormap = XCreateColormap(Tk_Display(tkwin), RootWindowOfScreen(Tk_Screen(tkwin)), visual, AllocNone); @@ -383,7 +382,7 @@ Tk_GetColormap( */ if (strcmp(string, "new") == 0) { - cmapPtr = ckalloc(sizeof(TkColormap)); + cmapPtr = (TkColormap *)ckalloc(sizeof(TkColormap)); cmapPtr->colormap = XCreateColormap(Tk_Display(tkwin), RootWindowOfScreen(Tk_Screen(tkwin)), Tk_Visual(tkwin), AllocNone); @@ -427,7 +426,7 @@ Tk_GetColormap( for (cmapPtr = dispPtr->cmapPtr; cmapPtr != NULL; cmapPtr = cmapPtr->nextPtr) { if (cmapPtr->colormap == colormap) { - cmapPtr->refCount += 1; + cmapPtr->refCount++; } } return colormap; @@ -476,8 +475,7 @@ Tk_FreeColormap( for (prevPtr = NULL, cmapPtr = dispPtr->cmapPtr; cmapPtr != NULL; prevPtr = cmapPtr, cmapPtr = cmapPtr->nextPtr) { if (cmapPtr->colormap == colormap) { - cmapPtr->refCount -= 1; - if (cmapPtr->refCount == 0) { + if (cmapPtr->refCount-- <= 1) { XFreeColormap(display, colormap); if (prevPtr == NULL) { dispPtr->cmapPtr = cmapPtr->nextPtr; @@ -534,7 +532,7 @@ Tk_PreserveColormap( for (cmapPtr = dispPtr->cmapPtr; cmapPtr != NULL; cmapPtr = cmapPtr->nextPtr) { if (cmapPtr->colormap == colormap) { - cmapPtr->refCount += 1; + cmapPtr->refCount++; return; } } diff --git a/macosx/tkMacOSXDefault.h b/macosx/tkMacOSXDefault.h index 15677a1..c0f72fb 100644 --- a/macosx/tkMacOSXDefault.h +++ b/macosx/tkMacOSXDefault.h @@ -74,7 +74,7 @@ #define DEF_BUTTON_HEIGHT "0" #define DEF_BUTTON_HIGHLIGHT_BG_COLOR DEF_BUTTON_BG_COLOR #define DEF_BUTTON_HIGHLIGHT_BG_MONO DEF_BUTTON_BG_MONO -#define DEF_BUTTON_HIGHLIGHT "systemButtonFrame" +#define DEF_BUTTON_HIGHLIGHT NORMAL_FG #define DEF_LABEL_HIGHLIGHT_WIDTH "0" //#if TK_MAC_BUTTON_USE_COMPATIBILITY_METRICS //#define DEF_BUTTON_HIGHLIGHT_WIDTH "4" diff --git a/macosx/tkMacOSXFont.c b/macosx/tkMacOSXFont.c index 8189bdb..d9c1c01 100644 --- a/macosx/tkMacOSXFont.c +++ b/macosx/tkMacOSXFont.c @@ -1208,11 +1208,13 @@ TkpDrawAngledCharsInContext( TkSetMacColor(gc->foreground, &fg); attributes = [fontPtr->nsAttributes mutableCopy]; [attributes setObject:(id)fg forKey:(id)kCTForegroundColorAttributeName]; + CFRelease(fg); nsFont = [attributes objectForKey:NSFontAttributeName]; [nsFont setInContext:GET_NSCONTEXT(context, NO)]; CGContextSetTextMatrix(context, CGAffineTransformIdentity); attributedString = [[NSAttributedString alloc] initWithString:string attributes:attributes]; + [string release]; typesetter = CTTypesetterCreateWithAttributedString( (CFAttributedStringRef)attributedString); textX += (CGFloat) macWin->xOff; @@ -1249,7 +1251,6 @@ TkpDrawAngledCharsInContext( CFRelease(line); CFRelease(typesetter); [attributedString release]; - [string release]; [attributes release]; TkMacOSXRestoreDrawingContext(&drawingContext); } diff --git a/macosx/ttkMacOSXTheme.c b/macosx/ttkMacOSXTheme.c index ce098f4..8379812 100644 --- a/macosx/ttkMacOSXTheme.c +++ b/macosx/ttkMacOSXTheme.c @@ -555,10 +555,6 @@ static void SolidFillRoundedRectangle( CGContextSetFillColorWithColor(context, CGCOLOR(color)); CGContextBeginPath(context); CGContextAddPath(context, path); -#ifdef TK_MAC_DEBUG_CG - fprintf(stderr, "Filling rounded rectangle at %s\n", - NSStringFromRect(bounds).UTF8String); -#endif CGContextFillPath(context); CFRelease(path); } diff --git a/tests/bind.test b/tests/bind.test index 47b80ed..7a075fe 100644 --- a/tests/bind.test +++ b/tests/bind.test @@ -48,7 +48,7 @@ proc pointerAway {} { # but let's wait more (it depends on computer performance). after 100 ; update event generate .top <Button-1> -warp 1 - update + controlPointerWarpTiming destroy .top } pointerAway @@ -6153,6 +6153,7 @@ test bind-32.1 {-warp, window was destroyed before the idle callback DoWarp} -se update } -body { event generate .t.f <Button-1> -warp 1 + controlPointerWarpTiming event generate .t.f <ButtonRelease-1> destroy .t.f update ; # shall simply not crash @@ -6745,14 +6746,12 @@ test bind-34.1 {-warp works relatively to a window} -setup { wm geometry .top +200+200 after 10 ; update event generate .top <Motion> -x 20 -y 20 -warp 1 - update idletasks ; # DoWarp is an idle callback - after 50 ; # Win specific - wait for SendInput to be executed + controlPointerWarpTiming set pointerPos1 [winfo pointerxy .top] wm geometry .top +600+600 after 10 ; update event generate .top <Motion> -x 20 -y 20 -warp 1 - update idletasks ; # DoWarp is an idle callback - after 50 ; # Win specific - wait for SendInput to be executed + controlPointerWarpTiming set pointerPos2 [winfo pointerxy .top] # from the first warped position to the second one, the mouse # pointer should have moved the same amount as the window moved @@ -6770,12 +6769,10 @@ test bind-34.2 {-warp works relatively to the screen} -setup { } -body { # Contrary to bind-34.1, we're directly checking screen coordinates event generate {} <Motion> -x 20 -y 20 -warp 1 - update idletasks ; # DoWarp is an idle callback - after 50 ; # Win specific - wait for SendInput to be executed + controlPointerWarpTiming set res [winfo pointerxy .] event generate {} <Motion> -x 200 -y 200 -warp 1 - update idletasks ; # DoWarp is an idle callback - after 50 ; # Win specific - wait for SendInput to be executed + controlPointerWarpTiming lappend res {*}[winfo pointerxy .] } -cleanup { } -result {20 20 200 200} @@ -6793,8 +6790,7 @@ test bind-34.3 {-warp works with null or negative coordinates} -setup { set res {} } -body { event generate {} <Motion> -x 0 -y 0 -warp 1 - update idletasks ; # DoWarp is an idle callback - after 50 ; # Win specific - wait for SendInput to be executed + controlPointerWarpTiming foreach dim [winfo pointerxy .] { if {$dim <= $halo} { lappend res ok @@ -6803,9 +6799,9 @@ test bind-34.3 {-warp works with null or negative coordinates} -setup { } } event generate {} <Motion> -x 100 -y 100 -warp 1 - update idletasks ; after 50 + controlPointerWarpTiming event generate {} <Motion> -x -1 -y -1 -warp 1 - update idletasks ; after 50 + controlPointerWarpTiming foreach dim [winfo pointerxy .] { if {$dim <= $halo} { lappend res ok @@ -6967,15 +6963,15 @@ test bind-36.1 {pointer warp with grab on toplevel, bug [e3888d5820]} -setup { after 50 update event generate .top.l <Motion> -warp 1 -x 10 -y 10 - update idletasks ; after 50 + controlPointerWarpTiming foreach {x1 y1} [winfo pointerxy .top.l] {} event generate {} <Motion> -warp 1 -x 50 -y 50 - update idletasks ; after 50 + controlPointerWarpTiming grab release .top ; # this will queue events after 50 update event generate .top.l <Motion> -warp 1 -x 10 -y 10 - update idletasks ; after 50 + controlPointerWarpTiming foreach {x2 y2} [winfo pointerxy .top.l] {} # success if the coords are the same with or without the grab, and if they # are at (10,10) inside the label widget as requested by the warping diff --git a/tests/constraints.tcl b/tests/constraints.tcl index ee073cf..65609d6 100644 --- a/tests/constraints.tcl +++ b/tests/constraints.tcl @@ -172,6 +172,67 @@ namespace eval tk { return $r } + # + # CONTROL TIMING ASPECTS OF POINTER WARPING + # + # The proc [controlPointerWarpTiming] takes care of the following timing + # details of pointer warping: + # + # a. Allow pointer warping to happen if it was scheduled for execution at + # idle time. + # - In Tk releases 8.6 and older, pointer warping is scheduled for + # execution at idle time + # - In release 8.7 and newer this happens synchronously and no extra + # control is needed. + # The namespace variable idle_pointer_warping records which of these is + # the case. + # + # b. Work around a race condition associated with OS notification of + # mouse motion on Windows. + # + # When calling [event generate $w $event -warp 1 ...], the following + # sequence occurs: + # - At some point in the processing of this command, either via a + # synchronous execution path, or asynchronously at idle time, Tk calls + # an OS function* to carry out the mouse cursor motion. + # - Tk has previously registered a callback function** with the OS, for + # the OS to call in order to notify Tk when a mouse move is completed. + # - Tk doesn't wait for the callback function to receive the notification + # from the OS, but continues processing. This suits most use cases + # because (usually) the notification comes quickly enough + # (range: a few ms?). However ... + # - A problem arises if Tk performs some processing, immediately following + # up on [event generate $w $event -warp 1 ...], and that processing + # relies on the mouse pointer having actually moved. If such processing + # happens just before the notification from the OS has been received, + # Tk will be using not yet updated info (e.g. mouse coordinates). + # + # Hickup, choke etc ... ! + # + # * the function SendInput() of the Win32 API + # ** the callback function is TkWinChildProc() + # + # This timing issue can be addressed by putting the Tk process on hold + # (do nothing at all) for a somewhat extended amount of time, while + # letting the OS complete its job in the meantime. This is what is + # accomplished by calling [after ms]. + # + # ---- + # For the history of this issue please refer to Tk ticket [69b48f427e], + # specifically the comment on 2019-10-27 14:24:26. + # + variable idle_pointer_warping [expr {![package vsatisfies [package provide Tk] 8.7-]}] + proc controlPointerWarpTiming {{duration 50}} { + variable idle_pointer_warping + if {$idle_pointer_warping} { + update idletasks ;# see a. above + } + if {[tk windowingsystem] eq "win32"} { + after $duration ;# see b. above + } + } + namespace export controlPointerWarpTiming + } } diff --git a/tests/event.test b/tests/event.test index ea190de..f0e2311 100644 --- a/tests/event.test +++ b/tests/event.test @@ -875,8 +875,11 @@ test event-9 {no <Enter> event is generated for the container window when its bind .top <Enter> {lappend res %W} pack [frame .top.f -bg green -width 50 -height 50] -anchor se -side bottom tkwait visibility .top.f + after 50 + update + focus -force .top.f event generate .top.f <Motion> -warp 1 -x 25 -y 25 ; # <Enter> sent to .top and .top.f - after 50 ; # Win specific - wait for SendInput to be executed + controlPointerWarpTiming update ; # idletasks not enough destroy .top.f ; # no <Enter> event sent update diff --git a/tests/menu.test b/tests/menu.test index ec43ad3..718643e 100644 --- a/tests/menu.test +++ b/tests/menu.test @@ -3941,9 +3941,8 @@ test menu-38.1 {Can't dismiss ttk::menubutton menu until mouse has hovered over pack .top.mb update # simulate mouse click on the menubutton, which posts its menu - event generate .top.mb <ButtonPress-1> -warp 1 - update - after 50 + event generate .top.mb <Button-1> -warp 1 + controlPointerWarpTiming event generate .top.mb <ButtonRelease-1> update # simulate mouse click on the menu again, i.e. without diff --git a/tests/textTag.test b/tests/textTag.test index e36cf30..9e5ccdc 100644 --- a/tests/textTag.test +++ b/tests/textTag.test @@ -1492,7 +1492,8 @@ set y3 [expr {[lindex $c 1] + [lindex $c 3]/2}] test textTag-15.1 {TkTextBindProc} -constraints haveCourier12 -setup { .t tag delete x y wm geometry . +200+200 ; update - event generate {} <Motion> -warp 1 -x 5 -y 5 ; update idletasks ; after 50 + event generate {} <Motion> -warp 1 -x 5 -y 5 + controlPointerWarpTiming } -body { bind .t <ButtonRelease> {lappend x up} .t tag bind x <ButtonRelease> {lappend x x-up} @@ -1518,7 +1519,8 @@ test textTag-15.1 {TkTextBindProc} -constraints haveCourier12 -setup { test textTag-15.2 {TkTextBindProc} -constraints haveCourier12 -setup { .t tag delete x y wm geometry . +200+200 ; update - event generate {} <Motion> -warp 1 -x 5 -y 5 ; update idletasks ; after 50 + event generate {} <Motion> -warp 1 -x 5 -y 5 + controlPointerWarpTiming } -body { .t tag bind x <Enter> {lappend x x-enter} .t tag bind x <ButtonPress> {lappend x x-down} @@ -1547,7 +1549,8 @@ test textTag-15.2 {TkTextBindProc} -constraints haveCourier12 -setup { test textTag-15.3 {TkTextBindProc} -constraints haveCourier12 -setup { .t tag delete x y wm geometry . +200+200 ; update - event generate {} <Motion> -warp 1 -x 5 -y 5 ; update idletasks ; after 50 + event generate {} <Motion> -warp 1 -x 5 -y 5 + controlPointerWarpTiming } -body { .t tag bind x <Enter> {lappend x x-enter} .t tag bind x <Any-ButtonPress-1> {lappend x x-down} @@ -1583,7 +1586,8 @@ test textTag-16.1 {TkTextPickCurrent procedure} -constraints { } -setup { .t tag delete {*}[.t tag names] wm geometry . +200+200 ; update - event generate {} <Motion> -warp 1 -x 5 -y 5 ; update idletasks ; after 50 + event generate {} <Motion> -warp 1 -x 5 -y 5 + controlPointerWarpTiming } -body { event gen .t <ButtonRelease-1> -state 0x100 -x $x1 -y $y1 set x [.t index current] @@ -1606,7 +1610,8 @@ test textTag-16.2 {TkTextPickCurrent procedure} -constraints { } -setup { .t tag delete {*}[.t tag names] wm geometry . +200+200 ; update - event generate {} <Motion> -warp 1 -x 5 -y 5 ; update idletasks ; after 50 + event generate {} <Motion> -warp 1 -x 5 -y 5 + controlPointerWarpTiming } -body { .t tag configure big -font $bigFont # update needed here to stabilize the test @@ -1628,7 +1633,8 @@ test textTag-16.3 {TkTextPickCurrent procedure} -constraints { .t tag remove $i 1.0 end } wm geometry . +200+200 ; update - event generate {} <Motion> -warp 1 -x 5 -y 5 ; update idletasks ; after 50 + event generate {} <Motion> -warp 1 -x 5 -y 5 + controlPointerWarpTiming } -body { foreach i {a b c d} { .t tag bind $i <Enter> "lappend x enter-$i" @@ -1658,7 +1664,8 @@ test textTag-16.4 {TkTextPickCurrent procedure} -constraints { .t tag remove $i 1.0 end } wm geometry . +200+200 ; update - event generate {} <Motion> -warp 1 -x 5 -y 5 ; update idletasks ; after 50 + event generate {} <Motion> -warp 1 -x 5 -y 5 + controlPointerWarpTiming } -body { foreach i {a b c d} { .t tag bind $i <Enter> "lappend x enter-$i" @@ -1687,7 +1694,8 @@ test textTag-16.5 {TkTextPickCurrent procedure} -constraints { .t tag remove $i 1.0 end } wm geometry . +200+200 ; update - event generate {} <Motion> -warp 1 -x 5 -y 5 ; update idletasks ; after 50 + event generate {} <Motion> -warp 1 -x 5 -y 5 + controlPointerWarpTiming } -body { .t tag configure big -font $bigFont event gen .t <Motion> -x $x1 -y $y1 @@ -1706,7 +1714,8 @@ test textTag-16.6 {TkTextPickCurrent procedure} -constraints { .t tag remove $i 1.0 end } wm geometry . +200+200 ; update - event generate {} <Motion> -warp 1 -x 5 -y 5 ; update idletasks ; after 50 + event generate {} <Motion> -warp 1 -x 5 -y 5 + controlPointerWarpTiming } -body { .t tag configure big -font $bigFont event gen .t <Motion> -x $x1 -y $y1 @@ -1726,7 +1735,8 @@ test textTag-16.7 {TkTextPickCurrent procedure} -constraints { .t tag remove $i 1.0 end } wm geometry . +200+200 ; update - event generate {} <Motion> -warp 1 -x 5 -y 5 ; update idletasks ; after 50 + event generate {} <Motion> -warp 1 -x 5 -y 5 + controlPointerWarpTiming } -body { .t tag configure big -font $bigFont .t tag bind a <Enter> {.t tag add big 3.0 3.2} @@ -1757,7 +1767,8 @@ test textTag-17.1 {insert procedure inserts tags} -setup { test textTag-18.1 {TkTextPickCurrent tag bindings} -setup { destroy .t wm geometry . +200+200 ; update - event generate {} <Motion> -warp 1 -x 5 -y 5 ; update idletasks ; after 50 + event generate {} <Motion> -warp 1 -x 5 -y 5 + controlPointerWarpTiming } -body { text .t -width 30 -height 4 -relief sunken -borderwidth 10 \ -highlightthickness 10 -pady 2 @@ -1774,6 +1785,10 @@ test textTag-18.1 {TkTextPickCurrent tag bindings} -setup { set res {} # Bindings must not trigger on the widget border, only over # the actual tagged characters themselves. + # Note that we don't need to call controlPointerWarpTiming + # in the following six calls because we're not checking that + # the mouse pointer has actually moved but rather that the + # tag binding mechanism of the text widget correctly triggers. event gen .t <Motion> -warp 1 -x 0 -y 0 ; update event gen .t <Motion> -warp 1 -x 10 -y 10 ; update event gen .t <Motion> -warp 1 -x 25 -y 25 ; update diff --git a/win/rules.vc b/win/rules.vc index 85c37f2..19f0dd8 100644 --- a/win/rules.vc +++ b/win/rules.vc @@ -1260,7 +1260,13 @@ tklibs = "$(TKSTUBLIB)" "$(TKIMPLIB)" # Various output paths
PRJIMPLIB = $(OUT_DIR)\$(PROJECT)$(VERSION)$(SUFX).lib
-PRJLIBNAME = $(PROJECT)$(VERSION)$(SUFX).$(EXT)
+PRJLIBNAME8 = $(PROJECT)$(VERSION)$(SUFX).$(EXT)
+PRJLIBNAME9 = tcl9$(PROJECT)$(VERSION)$(SUFX).$(EXT)
+!if $(TCL_MAJOR_VERSION) == 8
+PRJLIBNAME = $(PRJLIBNAME8)
+!else
+PRJLIBNAME = $(PRJLIBNAME9)
+!endif
PRJLIB = $(OUT_DIR)\$(PRJLIBNAME)
PRJSTUBLIBNAME = $(STUBPREFIX)$(VERSION).lib
@@ -1590,12 +1596,22 @@ default-target: $(DEFAULT_BUILD_TARGET) !if $(MULTIPLATFORM_INSTALL)
default-pkgindex:
+ @echo if {[package vsatisfies [package provide Tcl] 9.0-]} { > $(OUT_DIR)\pkgIndex.tcl
@echo package ifneeded $(PRJ_PACKAGE_TCLNAME) $(DOTVERSION) \
- [list load [file join $$dir $(PLATFORM_IDENTIFY) $(PRJLIBNAME)]] > $(OUT_DIR)\pkgIndex.tcl
+ [list load [file join $$dir $(PLATFORM_IDENTIFY) $(PRJLIBNAME9)]] >> $(OUT_DIR)\pkgIndex.tcl
+ @echo } else { >> $(OUT_DIR)\pkgIndex.tcl
+ @echo package ifneeded $(PRJ_PACKAGE_TCLNAME) $(DOTVERSION) \
+ [list load [file join $$dir $(PLATFORM_IDENTIFY) $(PRJLIBNAME8)]] >> $(OUT_DIR)\pkgIndex.tcl
+ @echo } >> $(OUT_DIR)\pkgIndex.tcl
!else
default-pkgindex:
+ @echo if {[package vsatisfies [package provide Tcl] 9.0-]} { > $(OUT_DIR)\pkgIndex.tcl
+ @echo package ifneeded $(PRJ_PACKAGE_TCLNAME) $(DOTVERSION) \
+ [list load [file join $$dir $(PRJLIBNAME9)]] >> $(OUT_DIR)\pkgIndex.tcl
+ @echo } else { >> $(OUT_DIR)\pkgIndex.tcl
@echo package ifneeded $(PRJ_PACKAGE_TCLNAME) $(DOTVERSION) \
- [list load [file join $$dir $(PRJLIBNAME)]] > $(OUT_DIR)\pkgIndex.tcl
+ [list load [file join $$dir $(PRJLIBNAME8)]] >> $(OUT_DIR)\pkgIndex.tcl
+ @echo } >> $(OUT_DIR)\pkgIndex.tcl
!endif
default-pkgindex-tea:
@@ -1604,6 +1620,8 @@ default-pkgindex-tea: @PACKAGE_NAME@ $(PRJ_PACKAGE_TCLNAME)
@PACKAGE_TCLNAME@ $(PRJ_PACKAGE_TCLNAME)
@PKG_LIB_FILE@ $(PRJLIBNAME)
+@PKG_LIB_FILE8@ $(PRJLIBNAME8)
+@PKG_LIB_FILE9@ $(PRJLIBNAME9)
<<
default-install: default-install-binaries default-install-libraries
|