summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--doc/menu.n5
-rw-r--r--generic/tkBind.c19
-rw-r--r--generic/tkBitmap.c6
-rw-r--r--generic/tkBusy.c2
-rw-r--r--generic/tkCanvas.c385
-rw-r--r--generic/tkClipboard.c4
-rw-r--r--generic/tkCmds.c2
-rw-r--r--generic/tkCursor.c4
-rw-r--r--generic/tkGC.c2
-rw-r--r--generic/tkGeometry.c2
-rw-r--r--generic/tkGrid.c2
-rw-r--r--generic/tkImgPhInstance.c2
-rw-r--r--generic/tkPack.c2
-rw-r--r--generic/tkPlace.c12
-rw-r--r--generic/tkTest.c44
-rw-r--r--generic/tkText.c2
-rw-r--r--generic/tkTextDisp.c2
-rw-r--r--generic/tkWindow.c4
-rw-r--r--generic/ttk/ttkBlink.c2
-rw-r--r--generic/ttk/ttkEntry.c6
-rw-r--r--generic/ttk/ttkProgress.c2
-rw-r--r--library/demos/widget6
-rw-r--r--macosx/README129
-rw-r--r--macosx/tkMacOSXImage.c9
-rw-r--r--macosx/tkMacOSXKeyEvent.c18
-rw-r--r--macosx/tkMacOSXMenu.c66
-rw-r--r--macosx/tkMacOSXMenus.c53
-rw-r--r--macosx/tkMacOSXNotify.c7
-rw-r--r--macosx/tkMacOSXPrivate.h10
-rw-r--r--macosx/tkMacOSXWindowEvent.c33
-rw-r--r--macosx/tkMacOSXWm.c254
-rw-r--r--unix/tkUnixButton.c2
-rw-r--r--unix/tkUnixEvent.c2
-rw-r--r--unix/tkUnixMenubu.c2
-rw-r--r--unix/tkUnixScale.c2
-rw-r--r--unix/tkUnixScrlbr.c2
-rw-r--r--unix/tkUnixSelect.c2
-rw-r--r--unix/tkUnixWm.c2
-rw-r--r--win/tkWinButton.c10
-rw-r--r--win/tkWinDialog.c2
-rw-r--r--win/tkWinEmbed.c8
-rw-r--r--win/tkWinMenu.c15
-rw-r--r--win/tkWinScrlbr.c8
-rw-r--r--win/tkWinTest.c12
-rw-r--r--win/tkWinWindow.c6
-rw-r--r--win/tkWinWm.c2
-rw-r--r--win/tkWinX.c6
-rw-r--r--win/ttkWinMonitor.c2
48 files changed, 546 insertions, 635 deletions
diff --git a/doc/menu.n b/doc/menu.n
index a274e6a..0e91c1f 100644
--- a/doc/menu.n
+++ b/doc/menu.n
@@ -264,7 +264,10 @@ contents are inserted into the standard Window menu of the user's
menubar whenever the window's menubar is in front. The first items in
the menu are provided by Mac OS X, and the names of the current
toplevels are automatically appended after all the Tk-defined items and
-a separator.
+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.
.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/generic/tkBind.c b/generic/tkBind.c
index 89839d3..469725e 100644
--- a/generic/tkBind.c
+++ b/generic/tkBind.c
@@ -997,7 +997,7 @@ Tk_DeleteBinding(
* its pattern.
*/
- hPtr = Tcl_FindHashEntry(&bindPtr->objectTable, (char *) object);
+ hPtr = Tcl_FindHashEntry(&bindPtr->objectTable, object);
if (hPtr == NULL) {
Tcl_Panic("Tk_DeleteBinding couldn't find object table entry");
}
@@ -1110,7 +1110,7 @@ Tk_GetAllBindings(
Tcl_HashEntry *hPtr;
Tcl_Obj *resultObj;
- hPtr = Tcl_FindHashEntry(&bindPtr->objectTable, (char *) object);
+ hPtr = Tcl_FindHashEntry(&bindPtr->objectTable, object);
if (hPtr == NULL) {
return;
}
@@ -1154,7 +1154,7 @@ Tk_DeleteAllBindings(
PatSeq *nextPtr;
Tcl_HashEntry *hPtr;
- hPtr = Tcl_FindHashEntry(&bindPtr->objectTable, (char *) object);
+ hPtr = Tcl_FindHashEntry(&bindPtr->objectTable, object);
if (hPtr == NULL) {
return;
}
@@ -1376,14 +1376,14 @@ Tk_BindEvent(
key.type = ringPtr->type;
key.detail = detail;
- hPtr = Tcl_FindHashEntry(veptPtr, (char *) &key);
+ hPtr = Tcl_FindHashEntry(veptPtr, &key);
if (hPtr != NULL) {
vMatchDetailList = Tcl_GetHashValue(hPtr);
}
if (key.detail.clientData != 0) {
key.detail.clientData = 0;
- hPtr = Tcl_FindHashEntry(veptPtr, (char *) &key);
+ hPtr = Tcl_FindHashEntry(veptPtr, &key);
if (hPtr != NULL) {
vMatchNoDetailList = Tcl_GetHashValue(hPtr);
}
@@ -1415,7 +1415,7 @@ Tk_BindEvent(
key.object = *objectPtr;
key.type = ringPtr->type;
key.detail = detail;
- hPtr = Tcl_FindHashEntry(&bindPtr->patternTable, (char *) &key);
+ hPtr = Tcl_FindHashEntry(&bindPtr->patternTable, &key);
if (hPtr != NULL) {
matchPtr = MatchPatterns(dispPtr, bindPtr, Tcl_GetHashValue(hPtr),
matchPtr, NULL, &sourcePtr);
@@ -1433,7 +1433,7 @@ Tk_BindEvent(
if ((detail.clientData != 0) && (matchPtr == NULL)) {
key.detail.clientData = 0;
- hPtr = Tcl_FindHashEntry(&bindPtr->patternTable, (char *) &key);
+ hPtr = Tcl_FindHashEntry(&bindPtr->patternTable, &key);
if (hPtr != NULL) {
matchPtr = MatchPatterns(dispPtr, bindPtr,
Tcl_GetHashValue(hPtr), matchPtr, NULL, &sourcePtr);
@@ -1806,8 +1806,7 @@ MatchPatterns(
key.detail.name = (Tk_Uid) Tcl_GetHashKey(hPtr->tablePtr,
hPtr);
- hPtr = Tcl_FindHashEntry(&bindPtr->patternTable,
- (char *) &key);
+ hPtr = Tcl_FindHashEntry(&bindPtr->patternTable, &key);
if (hPtr != NULL) {
/*
* This tag is interested in this virtual event and its
@@ -4291,7 +4290,7 @@ TkKeysymToString(
KeySym keysym)
{
#ifdef REDO_KEYSYM_LOOKUP
- Tcl_HashEntry *hPtr = Tcl_FindHashEntry(&nameTable, (char *)keysym);
+ Tcl_HashEntry *hPtr = Tcl_FindHashEntry(&nameTable, keysym);
if (hPtr != NULL) {
return Tcl_GetHashValue(hPtr);
diff --git a/generic/tkBitmap.c b/generic/tkBitmap.c
index 88f3e2b..a2730d7 100644
--- a/generic/tkBitmap.c
+++ b/generic/tkBitmap.c
@@ -536,7 +536,7 @@ Tk_NameOfBitmap(
Tcl_Panic("Tk_NameOfBitmap received unknown bitmap argument");
}
- idHashPtr = Tcl_FindHashEntry(&dispPtr->bitmapIdTable, (char *) bitmap);
+ idHashPtr = Tcl_FindHashEntry(&dispPtr->bitmapIdTable, bitmap);
if (idHashPtr == NULL) {
goto unknown;
}
@@ -578,7 +578,7 @@ Tk_SizeOfBitmap(
Tcl_Panic("Tk_SizeOfBitmap received unknown bitmap argument");
}
- idHashPtr = Tcl_FindHashEntry(&dispPtr->bitmapIdTable, (char *) bitmap);
+ idHashPtr = Tcl_FindHashEntry(&dispPtr->bitmapIdTable, bitmap);
if (idHashPtr == NULL) {
goto unknownBitmap;
}
@@ -667,7 +667,7 @@ Tk_FreeBitmap(
Tcl_Panic("Tk_FreeBitmap called before Tk_GetBitmap");
}
- idHashPtr = Tcl_FindHashEntry(&dispPtr->bitmapIdTable, (char *) bitmap);
+ idHashPtr = Tcl_FindHashEntry(&dispPtr->bitmapIdTable, bitmap);
if (idHashPtr == NULL) {
Tcl_Panic("Tk_FreeBitmap received unknown bitmap argument");
}
diff --git a/generic/tkBusy.c b/generic/tkBusy.c
index 6b87290..8991462 100644
--- a/generic/tkBusy.c
+++ b/generic/tkBusy.c
@@ -687,7 +687,7 @@ GetBusy(
&tkwin) != TCL_OK) {
return NULL;
}
- hPtr = Tcl_FindHashEntry(busyTablePtr, (char *) tkwin);
+ hPtr = Tcl_FindHashEntry(busyTablePtr, tkwin);
if (hPtr == NULL) {
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"can't find busy window \"%s\"", Tcl_GetString(windowObj)));
diff --git a/generic/tkCanvas.c b/generic/tkCanvas.c
index 7d9cf91..c0b5dce 100644
--- a/generic/tkCanvas.c
+++ b/generic/tkCanvas.c
@@ -13,8 +13,6 @@
* this file, and for a DISCLAIMER OF ALL WARRANTIES.
*/
-/* #define USE_OLD_TAG_SEARCH 1 */
-
#include "tkInt.h"
#include "tkCanvas.h"
#include "default.h"
@@ -28,26 +26,6 @@
* See tkCanvas.h for key data structures used to implement canvases.
*/
-#ifdef USE_OLD_TAG_SEARCH
-/*
- * The structure defined below is used to keep track of a tag search in
- * progress. No field should be accessed by anyone other than StartTagSearch
- * and NextItem.
- */
-
-typedef struct TagSearch {
- TkCanvas *canvasPtr; /* Canvas widget being searched. */
- Tk_Uid tag; /* Tag to search for. 0 means return all
- * items. */
- Tk_Item *currentPtr; /* Pointer to last item returned. */
- Tk_Item *lastPtr; /* The item right before the currentPtr is
- * tracked so if the currentPtr is deleted we
- * don't have to start from the beginning. */
- int searchOver; /* Non-zero means NextItem should always
- * return NULL. */
-} TagSearch;
-
-#else /* USE_OLD_TAG_SEARCH */
/*
* The structure defined below is used to keep track of a tag search in
* progress. No field should be accessed by anyone other than TagSearchScan,
@@ -94,8 +72,6 @@ typedef struct TagSearch {
#define SEARCH_TYPE_TAG 3 /* Looking for an item by simple tag */
#define SEARCH_TYPE_EXPR 4 /* Compound search */
-#endif /* USE_OLD_TAG_SEARCH */
-
/*
* Custom option for handling "-state" and "-offset"
*/
@@ -215,7 +191,6 @@ static Tk_ItemType *typeList = NULL;
* yet. */
TCL_DECLARE_MUTEX(typeListMutex)
-#ifndef USE_OLD_TAG_SEARCH
/*
* Uids for operands in compiled advanced tag search expressions.
* Initialization is done by GetStaticUids()
@@ -236,7 +211,6 @@ typedef struct {
static Tcl_ThreadDataKey dataKey;
static SearchUids * GetStaticUids(void);
-#endif /* USE_OLD_TAG_SEARCH */
/*
* Prototypes for functions defined later in this file:
@@ -267,40 +241,25 @@ static void CanvasWorldChanged(ClientData instanceData);
static int ConfigureCanvas(Tcl_Interp *interp,
TkCanvas *canvasPtr, int argc,
Tcl_Obj *const *argv, int flags);
-static void DestroyCanvas(char *memPtr);
-static int DrawCanvas(Tcl_Interp *interp, ClientData clientData, Tk_PhotoHandle photohandle, int subsample, int zoom);
+static void DestroyCanvas(void *memPtr);
+static int DrawCanvas(Tcl_Interp *interp, ClientData clientData, Tk_PhotoHandle photohandle, int subsample, int zoom);
static void DisplayCanvas(ClientData clientData);
static void DoItem(Tcl_Obj *accumObj,
Tk_Item *itemPtr, Tk_Uid tag);
static void EventuallyRedrawItem(TkCanvas *canvasPtr,
Tk_Item *itemPtr);
-#ifdef USE_OLD_TAG_SEARCH
-static int FindItems(Tcl_Interp *interp, TkCanvas *canvasPtr,
- int argc, Tcl_Obj *const *argv,
- Tcl_Obj *newTagObj, int first);
-#else /* USE_OLD_TAG_SEARCH */
static int FindItems(Tcl_Interp *interp, TkCanvas *canvasPtr,
int argc, Tcl_Obj *const *argv,
Tcl_Obj *newTagObj, int first,
TagSearch **searchPtrPtr);
-#endif /* USE_OLD_TAG_SEARCH */
static int FindArea(Tcl_Interp *interp, TkCanvas *canvasPtr,
Tcl_Obj *const *argv, Tk_Uid uid, int enclosed);
static double GridAlign(double coord, double spacing);
static const char** TkGetStringsFromObjs(int argc, Tcl_Obj *const *objv);
static void InitCanvas(void);
-#ifdef USE_OLD_TAG_SEARCH
-static Tk_Item * NextItem(TagSearch *searchPtr);
-#endif /* USE_OLD_TAG_SEARCH */
static void PickCurrentItem(TkCanvas *canvasPtr, XEvent *eventPtr);
static Tcl_Obj * ScrollFractions(int screen1,
int screen2, int object1, int object2);
-#ifdef USE_OLD_TAG_SEARCH
-static void RelinkItems(TkCanvas *canvasPtr,
- Tcl_Obj *tag, Tk_Item *prevPtr);
-static Tk_Item * StartTagSearch(TkCanvas *canvasPtr,
- Tcl_Obj *tag, TagSearch *searchPtr);
-#else /* USE_OLD_TAG_SEARCH */
static int RelinkItems(TkCanvas *canvasPtr, Tcl_Obj *tag,
Tk_Item *prevPtr, TagSearch **searchPtrPtr);
static void TagSearchExprInit(TagSearchExpr **exprPtrPtr);
@@ -314,7 +273,6 @@ static int TagSearchEvalExpr(TagSearchExpr *expr,
Tk_Item *itemPtr);
static Tk_Item * TagSearchFirst(TagSearch *searchPtr);
static Tk_Item * TagSearchNext(TagSearch *searchPtr);
-#endif /* USE_OLD_TAG_SEARCH */
/*
* The structure below defines canvas class behavior by means of functions
@@ -332,17 +290,6 @@ static const Tk_ClassProcs canvasClass = {
* Macros that significantly simplify all code that finds items.
*/
-#ifdef USE_OLD_TAG_SEARCH
-#define FIRST_CANVAS_ITEM_MATCHING(objPtr,searchPtrPtr,errorExitClause) \
- itemPtr = StartTagSearch(canvasPtr,(objPtr),&search)
-#define FOR_EVERY_CANVAS_ITEM_MATCHING(objPtr,searchPtrPtr,errorExitClause) \
- for (itemPtr = StartTagSearch(canvasPtr, (objPtr), &search); \
- itemPtr != NULL; itemPtr = NextItem(&search))
-#define FIND_ITEMS(objPtr, n) \
- FindItems(interp, canvasPtr, objc, objv, (objPtr), (n))
-#define RELINK_ITEMS(objPtr, itemPtr) \
- RelinkItems(canvasPtr, (objPtr), (itemPtr))
-#else /* USE_OLD_TAG_SEARCH */
#define FIRST_CANVAS_ITEM_MATCHING(objPtr,searchPtrPtr,errorExitClause) \
if ((result=TagSearchScan(canvasPtr,(objPtr),(searchPtrPtr))) != TCL_OK){ \
errorExitClause; \
@@ -358,7 +305,6 @@ static const Tk_ClassProcs canvasClass = {
FindItems(interp, canvasPtr, objc, objv, (objPtr), (n), &searchPtr)
#define RELINK_ITEMS(objPtr, itemPtr) \
result = RelinkItems(canvasPtr, (objPtr), (itemPtr), &searchPtr)
-#endif /* USE_OLD_TAG_SEARCH */
/*
* ----------------------------------------------------------------------
@@ -736,9 +682,7 @@ Tk_CanvasObjCmd(
canvasPtr->tsoffset.flags = 0;
canvasPtr->tsoffset.xoffset = 0;
canvasPtr->tsoffset.yoffset = 0;
-#ifndef USE_OLD_TAG_SEARCH
canvasPtr->bindTagExprs = NULL;
-#endif
Tcl_InitHashTable(&canvasPtr->idTable, TCL_ONE_WORD_KEYS);
Tk_SetClass(canvasPtr->tkwin, "Canvas");
@@ -793,12 +737,8 @@ CanvasWidgetCmd(
int c, result;
Tk_Item *itemPtr = NULL; /* Initialization needed only to prevent
* compiler warning. */
-#ifdef USE_OLD_TAG_SEARCH
- TagSearch search;
-#else /* USE_OLD_TAG_SEARCH */
TagSearch *searchPtr = NULL;/* Allocated by first TagSearchScan, freed by
* TagSearchDestroy */
-#endif /* USE_OLD_TAG_SEARCH */
int index;
static const char *const optionStrings[] = {
@@ -900,7 +840,7 @@ CanvasWidgetCmd(
break;
}
case CANV_BIND: {
- ClientData object;
+ void *object;
if ((objc < 3) || (objc > 5)) {
Tcl_WrongNumArgs(interp, 2, objv, "tagOrId ?sequence? ?command?");
@@ -914,35 +854,6 @@ CanvasWidgetCmd(
*/
object = NULL;
-#ifdef USE_OLD_TAG_SEARCH
- if (isdigit(UCHAR(Tcl_GetString(objv[2])[0]))) {
- int id;
- char *end;
- Tcl_HashEntry *entryPtr;
-
- id = strtoul(Tcl_GetString(objv[2]), &end, 0);
- if (*end != 0) {
- goto bindByTag;
- }
- entryPtr = Tcl_FindHashEntry(&canvasPtr->idTable, (char *) id);
- if (entryPtr != NULL) {
- itemPtr = Tcl_GetHashValue(entryPtr);
- object = itemPtr;
- }
-
- if (object == NULL) {
- Tcl_SetObjResult(interp, Tcl_ObjPrintf(
- "item \"%s\" doesn't exist", Tcl_GetString(objv[2])));
- Tcl_SetErrorCode(interp, "TK", "LOOKUP", "CANVAS_ITEM",
- Tcl_GetString(objv[2]), NULL);
- result = TCL_ERROR;
- goto done;
- }
- } else {
- bindByTag:
- object = Tk_GetUid(Tcl_GetString(objv[2]));
- }
-#else /* USE_OLD_TAG_SEARCH */
result = TagSearchScan(canvasPtr, objv[2], &searchPtr);
if (result != TCL_OK) {
goto done;
@@ -951,7 +862,7 @@ CanvasWidgetCmd(
Tcl_HashEntry *entryPtr;
entryPtr = Tcl_FindHashEntry(&canvasPtr->idTable,
- (char *) INT2PTR(searchPtr->id));
+ INT2PTR(searchPtr->id));
if (entryPtr != NULL) {
itemPtr = Tcl_GetHashValue(entryPtr);
object = itemPtr;
@@ -966,9 +877,8 @@ CanvasWidgetCmd(
goto done;
}
} else {
- object = (ClientData) searchPtr->expr->uid;
+ object = (char *)searchPtr->expr->uid;
}
-#endif /* USE_OLD_TAG_SEARCH */
/*
* Make a binding table if the canvas doesn't already have one.
@@ -988,7 +898,6 @@ CanvasWidgetCmd(
object, Tcl_GetString(objv[3]));
goto done;
}
-#ifndef USE_OLD_TAG_SEARCH
if (searchPtr->type == SEARCH_TYPE_EXPR) {
/*
* If new tag expression, then insert in linked list.
@@ -1019,7 +928,6 @@ CanvasWidgetCmd(
searchPtr->expr = NULL;
}
}
-#endif /* not USE_OLD_TAG_SEARCH */
if (argv4[0] == '+') {
argv4++;
append = 1;
@@ -1317,7 +1225,7 @@ CanvasWidgetCmd(
itemPtr->nextPtr = NULL;
entryPtr = Tcl_CreateHashEntry(&canvasPtr->idTable,
- (char *) INT2PTR(itemPtr->id), &isNew);
+ INT2PTR(itemPtr->id), &isNew);
Tcl_SetHashValue(entryPtr, itemPtr);
itemPtr->prevPtr = canvasPtr->lastItemPtr;
canvasPtr->hotPtr = itemPtr;
@@ -1396,7 +1304,7 @@ CanvasWidgetCmd(
ckfree(itemPtr->tagPtr);
}
entryPtr = Tcl_FindHashEntry(&canvasPtr->idTable,
- (char *) INT2PTR(itemPtr->id));
+ INT2PTR(itemPtr->id));
Tcl_DeleteHashEntry(entryPtr);
if (itemPtr->nextPtr != NULL) {
itemPtr->nextPtr->prevPtr = itemPtr->prevPtr;
@@ -2176,9 +2084,7 @@ CanvasWidgetCmd(
}
done:
-#ifndef USE_OLD_TAG_SEARCH
TagSearchDestroy(searchPtr);
-#endif /* not USE_OLD_TAG_SEARCH */
Tcl_Release(canvasPtr);
return result;
}
@@ -2203,13 +2109,11 @@ CanvasWidgetCmd(
static void
DestroyCanvas(
- char *memPtr) /* Info about canvas widget. */
+ void *memPtr) /* Info about canvas widget. */
{
- TkCanvas *canvasPtr = (TkCanvas *) memPtr;
+ TkCanvas *canvasPtr = memPtr;
Tk_Item *itemPtr;
-#ifndef USE_OLD_TAG_SEARCH
TagSearchExpr *expr, *next;
-#endif
/*
* Free up all of the items in the canvas.
@@ -2234,14 +2138,12 @@ DestroyCanvas(
if (canvasPtr->pixmapGC != None) {
Tk_FreeGC(canvasPtr->display, canvasPtr->pixmapGC);
}
-#ifndef USE_OLD_TAG_SEARCH
expr = canvasPtr->bindTagExprs;
while (expr) {
next = expr->next;
TagSearchExprDestroy(expr);
expr = next;
}
-#endif /* USE_OLD_TAG_SEARCH */
Tcl_DeleteTimerHandler(canvasPtr->insertBlinkHandler);
if (canvasPtr->bindingTable != NULL) {
Tk_DeleteBindingTable(canvasPtr->bindingTable);
@@ -3586,208 +3488,6 @@ InitCanvas(void)
Tcl_MutexUnlock(&typeListMutex);
}
-#ifdef USE_OLD_TAG_SEARCH
-/*
- *--------------------------------------------------------------
- *
- * StartTagSearch --
- *
- * This function is called to initiate an enumeration of all items in a
- * given canvas that contain a given tag.
- *
- * Results:
- * The return value is a pointer to the first item in canvasPtr that
- * matches tag, or NULL if there is no such item. The information at
- * *searchPtr is initialized such that successive calls to NextItem will
- * return successive items that match tag.
- *
- * Side effects:
- * SearchPtr is linked into a list of searches in progress on canvasPtr,
- * so that elements can safely be deleted while the search is in
- * progress. EndTagSearch must be called at the end of the search to
- * unlink searchPtr from this list.
- *
- *--------------------------------------------------------------
- */
-
-static Tk_Item *
-StartTagSearch(
- TkCanvas *canvasPtr, /* Canvas whose items are to be searched. */
- Tcl_Obj *tagObj, /* Object giving tag value. */
- TagSearch *searchPtr) /* Record describing tag search; will be
- * initialized here. */
-{
- int id;
- Tk_Item *itemPtr, *lastPtr;
- Tk_Uid *tagPtr;
- Tk_Uid uid;
- char *tag = Tcl_GetString(tagObj);
- int count;
- TkWindow *tkwin = (TkWindow *) canvasPtr->tkwin;
- TkDisplay *dispPtr = tkwin->dispPtr;
-
- /*
- * Initialize the search.
- */
-
- searchPtr->canvasPtr = canvasPtr;
- searchPtr->searchOver = 0;
-
- /*
- * Find the first matching item in one of several ways. If the tag is a
- * number then it selects the single item with the matching identifier.
- * In this case see if the item being requested is the hot item, in which
- * case the search can be skipped.
- */
-
- if (isdigit(UCHAR(*tag))) {
- char *end;
- Tcl_HashEntry *entryPtr;
-
- dispPtr->numIdSearches++;
- id = strtoul(tag, &end, 0);
- if (*end == 0) {
- itemPtr = canvasPtr->hotPtr;
- lastPtr = canvasPtr->hotPrevPtr;
- if ((itemPtr == NULL) || (itemPtr->id != id) || (lastPtr == NULL)
- || (lastPtr->nextPtr != itemPtr)) {
- dispPtr->numSlowSearches++;
- entryPtr = Tcl_FindHashEntry(&canvasPtr->idTable, (char*) id);
- if (entryPtr != NULL) {
- itemPtr = Tcl_GetHashValue(entryPtr);
- lastPtr = itemPtr->prevPtr;
- } else {
- lastPtr = itemPtr = NULL;
- }
- }
- searchPtr->lastPtr = lastPtr;
- searchPtr->searchOver = 1;
- canvasPtr->hotPtr = itemPtr;
- canvasPtr->hotPrevPtr = lastPtr;
- return itemPtr;
- }
- }
-
- searchPtr->tag = uid = Tk_GetUid(tag);
- if (uid == Tk_GetUid("all")) {
- /*
- * All items match.
- */
-
- searchPtr->tag = NULL;
- searchPtr->lastPtr = NULL;
- searchPtr->currentPtr = canvasPtr->firstItemPtr;
- return canvasPtr->firstItemPtr;
- }
-
- /*
- * None of the above. Search for an item with a matching tag.
- */
-
- for (lastPtr = NULL, itemPtr = canvasPtr->firstItemPtr; itemPtr != NULL;
- lastPtr = itemPtr, itemPtr = itemPtr->nextPtr) {
- for (tagPtr = itemPtr->tagPtr, count = itemPtr->numTags;
- count > 0; tagPtr++, count--) {
- if (*tagPtr == uid) {
- searchPtr->lastPtr = lastPtr;
- searchPtr->currentPtr = itemPtr;
- return itemPtr;
- }
- }
- }
- searchPtr->lastPtr = lastPtr;
- searchPtr->searchOver = 1;
- return NULL;
-}
-
-/*
- *--------------------------------------------------------------
- *
- * NextItem --
- *
- * This function returns successive items that match a given tag; it
- * should be called only after StartTagSearch has been used to begin a
- * search.
- *
- * Results:
- * The return value is a pointer to the next item that matches the tag
- * specified to StartTagSearch, or NULL if no such item exists.
- * *SearchPtr is updated so that the next call to this function will
- * return the next item.
- *
- * Side effects:
- * None.
- *
- *--------------------------------------------------------------
- */
-
-static Tk_Item *
-NextItem(
- TagSearch *searchPtr) /* Record describing search in progress. */
-{
- Tk_Item *itemPtr, *lastPtr;
- int count;
- Tk_Uid uid;
- Tk_Uid *tagPtr;
-
- /*
- * Find next item in list (this may not actually be a suitable one to
- * return), and return if there are no items left.
- */
-
- lastPtr = searchPtr->lastPtr;
- if (lastPtr == NULL) {
- itemPtr = searchPtr->canvasPtr->firstItemPtr;
- } else {
- itemPtr = lastPtr->nextPtr;
- }
- if ((itemPtr == NULL) || (searchPtr->searchOver)) {
- searchPtr->searchOver = 1;
- return NULL;
- }
- if (itemPtr != searchPtr->currentPtr) {
- /*
- * The structure of the list has changed. Probably the previously-
- * returned item was removed from the list. In this case, don't
- * advance lastPtr; just return its new successor (i.e. do nothing
- * here).
- */
- } else {
- lastPtr = itemPtr;
- itemPtr = lastPtr->nextPtr;
- }
-
- /*
- * Handle special case of "all" search by returning next item.
- */
-
- uid = searchPtr->tag;
- if (uid == NULL) {
- searchPtr->lastPtr = lastPtr;
- searchPtr->currentPtr = itemPtr;
- return itemPtr;
- }
-
- /*
- * Look for an item with a particular tag.
- */
-
- for ( ; itemPtr != NULL; lastPtr = itemPtr, itemPtr = itemPtr->nextPtr) {
- for (tagPtr = itemPtr->tagPtr, count = itemPtr->numTags;
- count > 0; tagPtr++, count--) {
- if (*tagPtr == uid) {
- searchPtr->lastPtr = lastPtr;
- searchPtr->currentPtr = itemPtr;
- return itemPtr;
- }
- }
- }
- searchPtr->lastPtr = lastPtr;
- searchPtr->searchOver = 1;
- return NULL;
-}
-
-#else /* !USE_OLD_TAG_SEARCH */
/*
*----------------------------------------------------------------------
*
@@ -4551,7 +4251,7 @@ TagSearchFirst(
if ((itemPtr == NULL) || (itemPtr->id != searchPtr->id)
|| (lastPtr == NULL) || (lastPtr->nextPtr != itemPtr)) {
entryPtr = Tcl_FindHashEntry(&searchPtr->canvasPtr->idTable,
- (char *) INT2PTR(searchPtr->id));
+ INT2PTR(searchPtr->id));
if (entryPtr != NULL) {
itemPtr = Tcl_GetHashValue(entryPtr);
lastPtr = itemPtr->prevPtr;
@@ -4716,7 +4416,6 @@ TagSearchNext(
searchPtr->searchOver = 1;
return NULL;
}
-#endif /* USE_OLD_TAG_SEARCH */
/*
*--------------------------------------------------------------
@@ -4829,14 +4528,9 @@ FindItems(
int first /* For error messages: gives number of
* elements of objv which are already
* handled. */
-#ifndef USE_OLD_TAG_SEARCH
,TagSearch **searchPtrPtr /* From CanvasWidgetCmd local vars*/
-#endif /* not USE_OLD_TAG_SEARCH */
)
{
-#ifdef USE_OLD_TAG_SEARCH
- TagSearch search;
-#endif /* USE_OLD_TAG_SEARCH */
Tk_Item *itemPtr;
Tk_Uid uid;
int index, result;
@@ -5153,16 +4847,6 @@ FindArea(
*--------------------------------------------------------------
*/
-#ifdef USE_OLD_TAG_SEARCH
-static void
-RelinkItems(
- TkCanvas *canvasPtr, /* Canvas to be modified. */
- Tcl_Obj *tag, /* Tag identifying items to be moved in the
- * redisplay list. */
- Tk_Item *prevPtr) /* Reposition the items so that they go just
- * after this item (NULL means put at
- * beginning of list). */
-#else /* USE_OLD_TAG_SEARCH */
static int
RelinkItems(
TkCanvas *canvasPtr, /* Canvas to be modified. */
@@ -5172,12 +4856,8 @@ RelinkItems(
* after this item (NULL means put at
* beginning of list). */
TagSearch **searchPtrPtr) /* From CanvasWidgetCmd local vars */
-#endif /* USE_OLD_TAG_SEARCH */
{
Tk_Item *itemPtr;
-#ifdef USE_OLD_TAG_SEARCH
- TagSearch search;
-#endif /* USE_OLD_TAG_SEARCH */
Tk_Item *firstMovePtr, *lastMovePtr;
int result;
@@ -5229,11 +4909,7 @@ RelinkItems(
*/
if (firstMovePtr == NULL) {
-#ifdef USE_OLD_TAG_SEARCH
- return;
-#else /* USE_OLD_TAG_SEARCH */
return TCL_OK;
-#endif /* USE_OLD_TAG_SEARCH */
}
if (prevPtr == NULL) {
if (canvasPtr->firstItemPtr != NULL) {
@@ -5254,9 +4930,7 @@ RelinkItems(
if (canvasPtr->lastItemPtr == prevPtr) {
canvasPtr->lastItemPtr = lastMovePtr;
}
-#ifndef USE_OLD_TAG_SEARCH
return TCL_OK;
-#endif /* not USE_OLD_TAG_SEARCH */
}
/*
@@ -5400,9 +5074,7 @@ PickCurrentItem(
double coords[2];
int buttonDown;
Tk_Item *prevItemPtr;
-#ifndef USE_OLD_TAG_SEARCH
SearchUids *searchUids = GetStaticUids();
-#endif
/*
* Check whether or not a button is down. If so, we'll log entry and exit
@@ -5525,11 +5197,7 @@ PickCurrentItem(
if ((itemPtr == canvasPtr->currentItemPtr) && !buttonDown) {
for (i = itemPtr->numTags-1; i >= 0; i--) {
-#ifdef USE_OLD_TAG_SEARCH
- if (itemPtr->tagPtr[i] == Tk_GetUid("current"))
-#else /* USE_OLD_TAG_SEARCH */
if (itemPtr->tagPtr[i] == searchUids->currentUid)
-#endif /* USE_OLD_TAG_SEARCH */
/* then */ {
itemPtr->tagPtr[i] = itemPtr->tagPtr[itemPtr->numTags-1];
itemPtr->numTags--;
@@ -5566,11 +5234,7 @@ PickCurrentItem(
if (canvasPtr->currentItemPtr != NULL) {
XEvent event;
-#ifdef USE_OLD_TAG_SEARCH
- DoItem(NULL, canvasPtr->currentItemPtr, Tk_GetUid("current"));
-#else /* USE_OLD_TAG_SEARCH */
DoItem(NULL, canvasPtr->currentItemPtr, searchUids->currentUid);
-#endif /* USE_OLD_TAG_SEARCH */
if ((canvasPtr->currentItemPtr->redraw_flags & TK_ITEM_STATE_DEPENDANT
&& prevItemPtr != canvasPtr->currentItemPtr)) {
ItemConfigure(canvasPtr, canvasPtr->currentItemPtr, 0, NULL);
@@ -5664,15 +5328,13 @@ CanvasDoEvent(
* processed. */
{
#define NUM_STATIC 3
- ClientData staticObjects[NUM_STATIC];
- ClientData *objectPtr;
+ void *staticObjects[NUM_STATIC];
+ void **objectPtr;
int numObjects, i;
Tk_Item *itemPtr;
-#ifndef USE_OLD_TAG_SEARCH
TagSearchExpr *expr;
int numExprs;
SearchUids *searchUids = GetStaticUids();
-#endif /* not USE_OLD_TAG_SEARCH */
if (canvasPtr->bindingTable == NULL) {
return;
@@ -5686,16 +5348,6 @@ CanvasDoEvent(
return;
}
-#ifdef USE_OLD_TAG_SEARCH
- /*
- * Set up an array with all the relevant objects for processing this
- * event. The relevant objects are (a) the event's item, (b) the tags
- * associated with the event's item, and (c) the tag "all". If there are a
- * lot of tags then malloc an array to hold all of the objects.
- */
-
- numObjects = itemPtr->numTags + 2;
-#else /* USE_OLD_TAG_SEARCH */
/*
* Set up an array with all the relevant objects for processing this
* event. The relevant objects are:
@@ -5724,23 +5376,17 @@ CanvasDoEvent(
}
numObjects = itemPtr->numTags + numExprs + 2;
-#endif /* not USE_OLD_TAG_SEARCH */
if (numObjects <= NUM_STATIC) {
objectPtr = staticObjects;
} else {
- objectPtr = ckalloc(numObjects * sizeof(ClientData));
+ objectPtr = ckalloc(numObjects * sizeof(void *));
}
-#ifdef USE_OLD_TAG_SEARCH
- objectPtr[0] = (ClientData) Tk_GetUid("all");
-#else /* USE_OLD_TAG_SEARCH */
- objectPtr[0] = (ClientData) searchUids->allUid;
-#endif /* USE_OLD_TAG_SEARCH */
+ objectPtr[0] = (char *)searchUids->allUid;
for (i = itemPtr->numTags-1; i >= 0; i--) {
- objectPtr[i+1] = (ClientData) itemPtr->tagPtr[i];
+ objectPtr[i+1] = (char *)itemPtr->tagPtr[i];
}
objectPtr[itemPtr->numTags+1] = itemPtr;
-#ifndef USE_OLD_TAG_SEARCH
/*
* Copy uids of matching expressions into object array
*/
@@ -5753,7 +5399,6 @@ CanvasDoEvent(
}
expr = expr->next;
}
-#endif /* not USE_OLD_TAG_SEARCH */
/*
* Invoke the binding system, then free up the object array if it was
diff --git a/generic/tkClipboard.c b/generic/tkClipboard.c
index aa6bb93..9f6822f 100644
--- a/generic/tkClipboard.c
+++ b/generic/tkClipboard.c
@@ -422,7 +422,7 @@ Tk_ClipboardObjCmd(
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument strings. */
{
- Tk_Window tkwin = (Tk_Window) clientData;
+ Tk_Window tkwin = clientData;
const char *path = NULL;
Atom selection;
static const char *const optionStrings[] = { "append", "clear", "get", NULL };
@@ -709,7 +709,7 @@ ClipboardGetProc(
* used). */
const char *portion) /* New information to be appended. */
{
- Tcl_DStringAppend((Tcl_DString *) clientData, portion, -1);
+ Tcl_DStringAppend(clientData, portion, -1);
return TCL_OK;
}
diff --git a/generic/tkCmds.c b/generic/tkCmds.c
index 81bb335..f0c489a 100644
--- a/generic/tkCmds.c
+++ b/generic/tkCmds.c
@@ -1860,7 +1860,7 @@ Tk_WmObjCmd(
TKWM_TRACING, TKWM_TRANSIENT, TKWM_WITHDRAW
};
- tkwin = (Tk_Window) clientData;
+ tkwin = clientData;
if (objc < 2) {
Tcl_WrongNumArgs(interp, 1, objv, "option window ?arg?");
diff --git a/generic/tkCursor.c b/generic/tkCursor.c
index e337b37..afdf6dd 100644
--- a/generic/tkCursor.c
+++ b/generic/tkCursor.c
@@ -428,7 +428,7 @@ Tk_NameOfCursor(
sprintf(dispPtr->cursorString, "cursor id %p", cursor);
return dispPtr->cursorString;
}
- idHashPtr = Tcl_FindHashEntry(&dispPtr->cursorIdTable, (char *) cursor);
+ idHashPtr = Tcl_FindHashEntry(&dispPtr->cursorIdTable, cursor);
if (idHashPtr == NULL) {
goto printid;
}
@@ -517,7 +517,7 @@ Tk_FreeCursor(
Tcl_Panic("Tk_FreeCursor called before Tk_GetCursor");
}
- idHashPtr = Tcl_FindHashEntry(&dispPtr->cursorIdTable, (char *) cursor);
+ idHashPtr = Tcl_FindHashEntry(&dispPtr->cursorIdTable, cursor);
if (idHashPtr == NULL) {
Tcl_Panic("Tk_FreeCursor received unknown cursor argument");
}
diff --git a/generic/tkGC.c b/generic/tkGC.c
index 55e5774..4caa046 100644
--- a/generic/tkGC.c
+++ b/generic/tkGC.c
@@ -307,7 +307,7 @@ Tk_FreeGC(
return;
}
- idHashPtr = Tcl_FindHashEntry(&dispPtr->gcIdTable, (char *) gc);
+ idHashPtr = Tcl_FindHashEntry(&dispPtr->gcIdTable, gc);
if (idHashPtr == NULL) {
Tcl_Panic("Tk_FreeGC received unknown gc argument");
}
diff --git a/generic/tkGeometry.c b/generic/tkGeometry.c
index 2e0009a..eab3850 100644
--- a/generic/tkGeometry.c
+++ b/generic/tkGeometry.c
@@ -587,7 +587,7 @@ Tk_UnmaintainGeometry(
if (!(((TkWindow *) slave)->flags & TK_ALREADY_DEAD)) {
Tk_UnmapWindow(slave);
}
- hPtr = Tcl_FindHashEntry(&dispPtr->maintainHashTable, (char *) master);
+ hPtr = Tcl_FindHashEntry(&dispPtr->maintainHashTable, master);
if (hPtr == NULL) {
return;
}
diff --git a/generic/tkGrid.c b/generic/tkGrid.c
index ec22016..c632793 100644
--- a/generic/tkGrid.c
+++ b/generic/tkGrid.c
@@ -2885,7 +2885,7 @@ GridStructureProc(
slavePtr->nextPtr = NULL;
}
Tcl_DeleteHashEntry(Tcl_FindHashEntry(&dispPtr->gridHashTable,
- (char *) gridPtr->tkwin));
+ gridPtr->tkwin));
if (gridPtr->flags & REQUESTED_RELAYOUT) {
Tcl_CancelIdleCall(ArrangeGrid, gridPtr);
}
diff --git a/generic/tkImgPhInstance.c b/generic/tkImgPhInstance.c
index 12bdb7b..1dc8840 100644
--- a/generic/tkImgPhInstance.c
+++ b/generic/tkImgPhInstance.c
@@ -1461,7 +1461,7 @@ DisposeColorTable(
ckfree(colorPtr->pixelMap);
}
- entry = Tcl_FindHashEntry(&imgPhotoColorHash, (char *) &colorPtr->id);
+ entry = Tcl_FindHashEntry(&imgPhotoColorHash, &colorPtr->id);
if (entry == NULL) {
Tcl_Panic("DisposeColorTable couldn't find hash entry");
}
diff --git a/generic/tkPack.c b/generic/tkPack.c
index f2ba642..aabfe1f 100644
--- a/generic/tkPack.c
+++ b/generic/tkPack.c
@@ -1474,7 +1474,7 @@ PackStructureProc(
if (packPtr->tkwin != NULL) {
TkDisplay *dispPtr = ((TkWindow *) packPtr->tkwin)->dispPtr;
Tcl_DeleteHashEntry(Tcl_FindHashEntry(&dispPtr->packerHashTable,
- (char *) packPtr->tkwin));
+ packPtr->tkwin));
}
if (packPtr->flags & REQUESTED_REPACK) {
diff --git a/generic/tkPlace.c b/generic/tkPlace.c
index 324f4f6..e7cfbaf 100644
--- a/generic/tkPlace.c
+++ b/generic/tkPlace.c
@@ -315,7 +315,7 @@ Tk_PlaceObjCmd(
}
UnlinkSlave(slavePtr);
Tcl_DeleteHashEntry(Tcl_FindHashEntry(&dispPtr->slaveTable,
- (char *) tkwin));
+ tkwin));
Tk_DeleteEventHandler(tkwin, StructureNotifyMask, SlaveStructureProc,
slavePtr);
Tk_ManageGeometry(tkwin, NULL, NULL);
@@ -455,7 +455,7 @@ FindSlave(
register Tcl_HashEntry *hPtr;
TkDisplay *dispPtr = ((TkWindow *) tkwin)->dispPtr;
- hPtr = Tcl_FindHashEntry(&dispPtr->slaveTable, (char *) tkwin);
+ hPtr = Tcl_FindHashEntry(&dispPtr->slaveTable, tkwin);
if (hPtr == NULL) {
return NULL;
}
@@ -578,7 +578,7 @@ FindMaster(
register Tcl_HashEntry *hPtr;
TkDisplay *dispPtr = ((TkWindow *) tkwin)->dispPtr;
- hPtr = Tcl_FindHashEntry(&dispPtr->masterTable, (char *) tkwin);
+ hPtr = Tcl_FindHashEntry(&dispPtr->masterTable, tkwin);
if (hPtr == NULL) {
return NULL;
}
@@ -1084,7 +1084,7 @@ MasterStructureProc(
slavePtr->nextPtr = NULL;
}
Tcl_DeleteHashEntry(Tcl_FindHashEntry(&dispPtr->masterTable,
- (char *) masterPtr->tkwin));
+ masterPtr->tkwin));
if (masterPtr->flags & PARENT_RECONFIG_PENDING) {
Tcl_CancelIdleCall(RecomputePlacement, masterPtr);
}
@@ -1151,7 +1151,7 @@ SlaveStructureProc(
UnlinkSlave(slavePtr);
}
Tcl_DeleteHashEntry(Tcl_FindHashEntry(&dispPtr->slaveTable,
- (char *) slavePtr->tkwin));
+ slavePtr->tkwin));
FreeSlave(slavePtr);
}
}
@@ -1230,7 +1230,7 @@ PlaceLostSlaveProc(
Tk_UnmapWindow(tkwin);
UnlinkSlave(slavePtr);
Tcl_DeleteHashEntry(Tcl_FindHashEntry(&dispPtr->slaveTable,
- (char *) tkwin));
+ tkwin));
Tk_DeleteEventHandler(tkwin, StructureNotifyMask, SlaveStructureProc,
slavePtr);
FreeSlave(slavePtr);
diff --git a/generic/tkTest.c b/generic/tkTest.c
index 1733300..cc9b54b 100644
--- a/generic/tkTest.c
+++ b/generic/tkTest.c
@@ -537,7 +537,7 @@ TestobjconfigObjCmd(
CustomOptionFree,
INT2PTR(1)
};
- Tk_Window mainWin = (Tk_Window) clientData;
+ Tk_Window mainWin = clientData;
Tk_Window tkwin;
int index, result = TCL_OK;
@@ -651,7 +651,7 @@ TestobjconfigObjCmd(
optionTable = Tk_CreateOptionTable(interp, typesSpecs);
tables[index] = optionTable;
- tkwin = Tk_CreateWindowFromPath(interp, (Tk_Window) clientData,
+ tkwin = Tk_CreateWindowFromPath(interp, clientData,
Tcl_GetString(objv[2]), NULL);
if (tkwin == NULL) {
return TCL_ERROR;
@@ -706,7 +706,7 @@ TestobjconfigObjCmd(
Tk_Window tkwin;
Tk_OptionTable optionTable;
- tkwin = Tk_CreateWindowFromPath(interp, (Tk_Window) clientData,
+ tkwin = Tk_CreateWindowFromPath(interp, clientData,
Tcl_GetString(objv[2]), NULL);
if (tkwin == NULL) {
return TCL_ERROR;
@@ -759,7 +759,7 @@ TestobjconfigObjCmd(
Tk_Window tkwin;
Tk_OptionTable optionTable;
- tkwin = Tk_CreateWindowFromPath(interp, (Tk_Window) clientData,
+ tkwin = Tk_CreateWindowFromPath(interp, clientData,
Tcl_GetString(objv[2]), NULL);
if (tkwin == NULL) {
return TCL_ERROR;
@@ -929,7 +929,7 @@ TestobjconfigObjCmd(
optionTable = Tk_CreateOptionTable(interp, internalSpecs);
tables[index] = optionTable;
- tkwin = Tk_CreateWindowFromPath(interp, (Tk_Window) clientData,
+ tkwin = Tk_CreateWindowFromPath(interp, clientData,
Tcl_GetString(objv[2]), NULL);
if (tkwin == NULL) {
return TCL_ERROR;
@@ -1081,7 +1081,7 @@ TestobjconfigObjCmd(
{TK_OPTION_END, NULL, NULL, NULL, NULL, 0, 0, 0, NULL, 0}
};
Tk_Window tkwin = Tk_CreateWindowFromPath(interp,
- (Tk_Window) clientData, Tcl_GetString(objv[2]), NULL);
+ clientData, Tcl_GetString(objv[2]), NULL);
if (tkwin == NULL) {
return TCL_ERROR;
@@ -1158,7 +1158,7 @@ TrivialConfigObjCmd(
};
Tcl_Obj *resultObjPtr;
int index, mask;
- TrivialCommandHeader *headerPtr = (TrivialCommandHeader *) clientData;
+ TrivialCommandHeader *headerPtr = clientData;
Tk_Window tkwin = headerPtr->tkwin;
Tk_SavedOptions saved;
@@ -1253,7 +1253,7 @@ static void
TrivialCmdDeletedProc(
ClientData clientData) /* Pointer to widget record for widget. */
{
- TrivialCommandHeader *headerPtr = (TrivialCommandHeader *) clientData;
+ TrivialCommandHeader *headerPtr = clientData;
Tk_Window tkwin = headerPtr->tkwin;
if (tkwin != NULL) {
@@ -1265,8 +1265,8 @@ TrivialCmdDeletedProc(
* here.
*/
- Tk_FreeConfigOptions((char *) clientData,
- headerPtr->optionTable, (Tk_Window) NULL);
+ Tk_FreeConfigOptions(clientData,
+ headerPtr->optionTable, NULL);
Tcl_EventuallyFree(clientData, TCL_DYNAMIC);
}
}
@@ -1292,11 +1292,11 @@ TrivialEventProc(
ClientData clientData, /* Information about window. */
XEvent *eventPtr) /* Information about event. */
{
- TrivialCommandHeader *headerPtr = (TrivialCommandHeader *) clientData;
+ TrivialCommandHeader *headerPtr = clientData;
if (eventPtr->type == DestroyNotify) {
if (headerPtr->tkwin != NULL) {
- Tk_FreeConfigOptions((char *) clientData,
+ Tk_FreeConfigOptions(clientData,
headerPtr->optionTable, headerPtr->tkwin);
headerPtr->optionTable = NULL;
headerPtr->tkwin = NULL;
@@ -1338,7 +1338,7 @@ TestfontObjCmd(
Tk_Window tkwin;
Tk_Font tkfont;
- tkwin = (Tk_Window) clientData;
+ tkwin = clientData;
if (objc < 3) {
Tcl_WrongNumArgs(interp, 1, objv, "option fontName");
@@ -1458,7 +1458,7 @@ ImageObjCmd(
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument strings. */
{
- TImageMaster *timPtr = (TImageMaster *) clientData;
+ TImageMaster *timPtr = clientData;
int x, y, width, height;
if (objc < 2) {
@@ -1513,7 +1513,7 @@ ImageGet(
* used. */
ClientData clientData) /* Pointer to TImageMaster for image. */
{
- TImageMaster *timPtr = (TImageMaster *) clientData;
+ TImageMaster *timPtr = clientData;
TImageInstance *instPtr;
char buffer[100];
XGCValues gcValues;
@@ -1560,7 +1560,7 @@ ImageDisplay(
/* Coordinates in drawable corresponding to
* imageX and imageY. */
{
- TImageInstance *instPtr = (TImageInstance *) clientData;
+ TImageInstance *instPtr = clientData;
char buffer[200 + TCL_INTEGER_SPACE * 6];
/*
@@ -1624,7 +1624,7 @@ ImageFree(
ClientData clientData, /* Pointer to TImageInstance for instance. */
Display *display) /* Display where image was to be drawn. */
{
- TImageInstance *instPtr = (TImageInstance *) clientData;
+ TImageInstance *instPtr = clientData;
char buffer[200];
sprintf(buffer, "%s free", instPtr->masterPtr->imageName);
@@ -1658,7 +1658,7 @@ ImageDelete(
* this function is called, no more instances
* exist. */
{
- TImageMaster *timPtr = (TImageMaster *) clientData;
+ TImageMaster *timPtr = clientData;
char buffer[100];
sprintf(buffer, "%s delete", timPtr->imageName);
@@ -1697,7 +1697,7 @@ TestmakeexistObjCmd(
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument strings. */
{
- Tk_Window mainWin = (Tk_Window) clientData;
+ Tk_Window mainWin = clientData;
int i;
Tk_Window tkwin;
@@ -1740,7 +1740,7 @@ TestmenubarObjCmd(
Tcl_Obj *const objv[]) /* Argument strings. */
{
#ifdef __UNIX__
- Tk_Window mainWin = (Tk_Window) clientData;
+ Tk_Window mainWin = clientData;
Tk_Window tkwin, menubar;
if (objc < 2) {
@@ -1853,7 +1853,7 @@ TestpropObjCmd(
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument strings. */
{
- Tk_Window mainWin = (Tk_Window) clientData;
+ Tk_Window mainWin = clientData;
int result, actualFormat;
unsigned long bytesAfter, length, value;
Atom actualType, propName;
@@ -1994,7 +1994,7 @@ TestwrapperObjCmd(
return TCL_ERROR;
}
- tkwin = (Tk_Window) clientData;
+ tkwin = clientData;
winPtr = (TkWindow *) Tk_NameToWindow(interp, Tcl_GetString(objv[1]), tkwin);
if (winPtr == NULL) {
return TCL_ERROR;
diff --git a/generic/tkText.c b/generic/tkText.c
index bea19d8..fb230cd 100644
--- a/generic/tkText.c
+++ b/generic/tkText.c
@@ -5605,7 +5605,7 @@ static void
RunAfterSyncCmd(
ClientData clientData) /* Information about text widget. */
{
- register TkText *textPtr = (TkText *) clientData;
+ register TkText *textPtr = clientData;
int code;
if ((textPtr->tkwin == NULL) || (textPtr->flags & DESTROYED)) {
diff --git a/generic/tkTextDisp.c b/generic/tkTextDisp.c
index 1a31e93..64d455f 100644
--- a/generic/tkTextDisp.c
+++ b/generic/tkTextDisp.c
@@ -7725,7 +7725,7 @@ TkTextCharLayoutProc(
#if !TK_LAYOUT_WITH_BASE_CHUNKS
ciPtr = ckalloc(offsetof(CharInfo, chars) + 1 + bytesThatFit);
chunkPtr->clientData = ciPtr;
- memcpy(ciPtr->chars, p, (unsigned) bytesThatFit);
+ memcpy(ciPtr->chars, p, bytesThatFit);
#endif /* TK_LAYOUT_WITH_BASE_CHUNKS */
ciPtr->numBytes = bytesThatFit;
diff --git a/generic/tkWindow.c b/generic/tkWindow.c
index 198c2d7..23c0891 100644
--- a/generic/tkWindow.c
+++ b/generic/tkWindow.c
@@ -1443,7 +1443,7 @@ Tk_DestroyWindow(
}
#endif
Tcl_DeleteHashEntry(Tcl_FindHashEntry(&dispPtr->winTable,
- (char *) winPtr->window));
+ winPtr->window));
winPtr->window = None;
}
UnlinkWindow(winPtr);
@@ -2362,7 +2362,7 @@ Tk_IdToWindow(
return NULL;
}
- hPtr = Tcl_FindHashEntry(&dispPtr->winTable, (char *) window);
+ hPtr = Tcl_FindHashEntry(&dispPtr->winTable, window);
if (hPtr == NULL) {
return NULL;
}
diff --git a/generic/ttk/ttkBlink.c b/generic/ttk/ttkBlink.c
index 7294f8b..484e66b 100644
--- a/generic/ttk/ttkBlink.c
+++ b/generic/ttk/ttkBlink.c
@@ -68,7 +68,7 @@ static CursorManager *GetCursorManager(Tcl_Interp *interp)
static void
CursorBlinkProc(ClientData clientData)
{
- CursorManager *cm = (CursorManager*)clientData;
+ CursorManager *cm = clientData;
int blinkTime;
if (cm->owner->flags & CURSOR_ON) {
diff --git a/generic/ttk/ttkEntry.c b/generic/ttk/ttkEntry.c
index ff3be12..66b3418 100644
--- a/generic/ttk/ttkEntry.c
+++ b/generic/ttk/ttkEntry.c
@@ -356,7 +356,7 @@ static int
EntryFetchSelection(
ClientData clientData, int offset, char *buffer, int maxBytes)
{
- Entry *entryPtr = (Entry *) clientData;
+ Entry *entryPtr = clientData;
size_t byteCount;
const char *string;
const char *selStart, *selEnd;
@@ -389,7 +389,7 @@ EntryFetchSelection(
*/
static void EntryLostSelection(ClientData clientData)
{
- Entry *entryPtr = (Entry *) clientData;
+ Entry *entryPtr = clientData;
entryPtr->core.flags &= ~GOT_SELECTION;
entryPtr->entry.selectFirst = entryPtr->entry.selectLast = -1;
TtkRedisplayWidget(&entryPtr->core);
@@ -924,7 +924,7 @@ DeleteChars(
static void
EntryEventProc(ClientData clientData, XEvent *eventPtr)
{
- Entry *entryPtr = (Entry *) clientData;
+ Entry *entryPtr = clientData;
Tcl_Preserve(clientData);
switch (eventPtr->type) {
diff --git a/generic/ttk/ttkProgress.c b/generic/ttk/ttkProgress.c
index 5aad05b..f1dbb2f 100644
--- a/generic/ttk/ttkProgress.c
+++ b/generic/ttk/ttkProgress.c
@@ -159,7 +159,7 @@ static void CheckAnimation(Progressbar *pb)
if (AnimationEnabled(pb)) {
if (pb->progress.timer == 0) {
pb->progress.timer = Tcl_CreateTimerHandler(
- pb->progress.period, AnimateProgressProc, (ClientData)pb);
+ pb->progress.period, AnimateProgressProc, pb);
}
} else {
if (pb->progress.timer != 0) {
diff --git a/library/demos/widget b/library/demos/widget
index 1d838ad..6d0b045 100644
--- a/library/demos/widget
+++ b/library/demos/widget
@@ -92,13 +92,14 @@ image create photo ::img::new -format GIF -data [mc {
}]
#----------------------------------------------------------------
-# The code below create the main window, consisting of a menu bar and a text
+# The code below creates the main window, consisting of a menu bar and a text
# widget that explains how to use the program, plus lists all of the demos as
# hypertext items.
#----------------------------------------------------------------
menu .menuBar -tearoff 0
+# On Aqua, just use the default menu.
if {[tk windowingsystem] ne "aqua"} {
# This is a tk-internal procedure to make i18n easier
::tk::AmpMenuArgs .menuBar add cascade -label [mc "&File"] \
@@ -118,10 +119,9 @@ if {[tk windowingsystem] ne "aqua"} {
-command {exit} -accelerator [mc "Meta-Q"]
bind . <[mc "Meta-q"]> {exit}
}
+ . configure -menu .menuBar
}
-. configure -menu .menuBar
-
ttk::frame .statusBar
ttk::label .statusBar.lab -text " " -anchor w
if {[tk windowingsystem] eq "aqua"} {
diff --git a/macosx/README b/macosx/README
index fe761e3..6c38dbc 100644
--- a/macosx/README
+++ b/macosx/README
@@ -152,14 +152,13 @@ app bundle files used by the about panel.
This support was added with the Cocoa-based Tk 8.5.7.
- TkAqua has three special menu names that give access to the standard
-Application, Window and Help menus, see menu.n for details.
-By default, the platform-specific standard Help menu item "YourApp Help" peforms
-the default Cocoa action of showing the Help Book configured in the
-application's Info.plist (or displaying an alert if no Help Book is set). This
-action can be customized by defining a procedure named [tk::mac::ShowHelp], if
-present, this procedure is invoked instead by the standard Help menu item.
-Support for the Window menu and [tk::mac::ShowHelp] was added with the
-Cocoa-based Tk 8.5.7.
+Application, Window and Help menus, see menu.n for details. By default, the
+platform-specific standard Help menu item "YourApp Help" performs the default
+Cocoa action of showing the Help Book configured in the application's
+Info.plist (or displaying an alert if no Help Book is set). This action can be
+customized by defining a procedure named [tk::mac::ShowHelp]. If present, this
+procedure is invoked instead by the standard Help menu item. Support for the
+Window menu and [tk::mac::ShowHelp] was added with the Cocoa-based Tk 8.5.7.
- The TkAqua-specific command [tk::unsupported::MacWindowStyle style] is used to
get and set macOS-specific toplevel window class and attributes. Note that
@@ -180,18 +179,104 @@ Window attribute names:
noActivates, hideOnSuspend, inWindowMenu, ignoreClicks, doesNotHide,
canJoinAllSpaces, moveToActiveSpace, nonActivating
-Note that not all attributes are valid for all window classes.
-Support for the 3 argument form was added with the Cocoa-based Tk 8.5.7, at the
-same time support for some legacy Carbon-specific classes and attributes was
-removed (they are still accepted by the command but no longer have any effect).
+Note that not all attributes are valid for all window classes. Support for the
+3 argument form was added with the Cocoa-based Tk 8.5.7, at the same time
+support for some legacy Carbon-specific classes and attributes was removed
+(they are still accepted by the command but no longer have any effect).
-If you want to use Remote Debugging with Xcode, you need to set the
+- Another command available in the tk::unsupported::MacWindowStyle namespace is
+tk::unsupported::MacWindowStyle tabbingid window ?newId? which can be used to
+get or set the tabbingIdentifier for the NSWindow associated with a Tk Window.
+See section 3 for details.
+
+- If you want to use Remote Debugging with Xcode, you need to set the
environment variable XCNOSTDIN to 1 in the Executable editor for Wish. That will
cause us to force closing stdin & stdout. Otherwise, given how Xcode launches
Wish remotely, they will be left open and then Wish & gdb will fight for stdin.
-
-3. Building Tcl/Tk on macOS
+3. FullScreen, Split View and Tabbed Windows
+--------------------------------------------
+
+Since the release of OSX 10.6 (Snow Leopard) a steadily expanding sequence of
+high level window operations have been added to Apple's window manager. These
+operations are launched by user actions which are handled directly by the
+window manager; they are not initiated by the application. In some, but not
+all cases, the application is notified before and after the operations are
+carried out.
+
+In OSX releases up to and including 10.6 there were three buttons with
+stoplight colors located on the left side of a window's title bar. The
+function of the green button was to "zoom" or "maximize" the window, i.e. to
+expand the window so that it fills the entire screen, while preserving the
+appearance of the window including its title bar. The release of OSX 10.7
+(Lion) introduced the "FullScreen" window which not only filled the screen but
+also hid the window's title bar and the menu bar which normally appears at the
+top of the screen. These hidden objects would only become visible when the
+mouse hovered near the top of the screen. FullScreen mode was initiated by
+pressing a button showing two outward pointing arrows located on the right side
+of the title bar; it was terminated by pressing a similar button with inward
+pointing arrows on the right hand side of the menu bar. In OSX 10.10
+(Yosemite) the FullScreen button was removed. The green button was repurposed
+to cause a window to become a FullScreen window. To zoom a window the user had
+to hold down the option key while pressing the green button. The release of
+OSX 10.11 added a third function to the green button: to create two half-screen
+windows with hidden title bars and a hidden menu bar, called Split View
+windows. If the green button is held down for one second its window expands to
+fill half of the screen. It can be moved to one side or the other with the
+mouse. The opposite side shows thumbnail images of other windows. Selecting
+one of the thumbnails expands its window to fill that half of the screen. The
+divider between the two windows can be moved to adjust the percentage of the
+screen occupied by each of the two tiles. In OSX 10.12 (Sierra) Tabbed windows
+were introduced. These allow an application with multiple windows to display
+its windows as tabs within a single window frame. Clicking on a tab brings its
+window into view. Tabs can be rearranged by dragging. Dragging a tab to the
+desktop turns it into a separate window. Items in the Window menu can be used
+to cycle through the tabs, move tabbed windows to separate windows, or merge a
+set of separate windows as tabs in the same window frame.
+
+Tk now fully supports all of these high level window operations on any system
+where the operation exists. The FullScreen and Split View windows are handled
+automatically with no action required on the part of the programmer. Tabbed
+windows, on the other hand, require some attention from the programmer.
+Because many of the operations with tabs are handled through the application's
+Window menu, it is essential that an application provide a Windows menu to
+avoid presenting a confusing interface to the user. This cannot be ignored, in
+part because the systemwide Dock Preferences offers an option to always attempt
+to open application windows as tabs. An application which does not provide a
+Window menu will necessarily present a confusing interface to any user who has
+selected this option.
+
+A further complication is that it is not neccessarily appropriate for all of an
+application's windows to be grouped together as tabs in the same frame. In
+fact, the Apple guidelines insist that windows which are grouped together as
+tabs should be similar to each other. The mechanism provided for arranging
+this was to assign to each NSwindow a tabbingIdentifier, and to require that
+all windows grouped together as tabs in the same window frame must have the
+same tabbingIdentifier. A tabbingIdentifier is implemented as an arbitrary
+string, and a system-generated default tabbingIdentifier is provided to all new
+windows.
+
+Tk provides a means for getting and setting the tabbingIdentifier of
+the NSWindow underlying a Tk Window. This is handled by the command
+
+tk::unsupported::MacWindowStyle tabbingid window ?newId?
+
+(This command generates an error if used on OSX 10.11 or earlier, since the
+tabbingIdentifier does not exist on those systems.) The command returns the
+tabbingIdentifier which had been assigned to the window prior to execution of
+the command. If the optional newId argument is omitted, the window's
+tabbingIdentifier is not changed. Otherwise it is set to the string specified
+by the argument.
+
+Since NSWindows can only be grouped together as tabs if they all have the same
+tabbingIdentifier, one can prevent a window from becoming a tab by giving it a
+unique tabbingIdentifier. This is independent of any preferences setting. To
+ensure that we maintain consistency, changing the tabbingIdentifier of a window
+which is already displayed as a tab will also cause it to become a separate
+window.
+
+
+4. Building Tcl/Tk on macOS
------------------------------
- At least macOS 10.3 is required to build Tcl and TkX11, and macOS 10.6
@@ -199,7 +284,7 @@ is required to build TkAqua. The XCode application provides everything
needed to build Tk, but it is not necessary to install the full XCode.
It suffices to install the Command Line Tools package, which can be done
by running the command:
-xcode-selecct --install
+xcode-select --install
- Tcl/Tk are most easily built as macOS frameworks via GNUmakefile in
tcl/macosx and tk/macosx (see below for details), but can also be built with the
@@ -354,10 +439,10 @@ make overrides to the tk/macosx GNUmakefile, e.g.
TCL_FRAMEWORK_DIR=$HOME/Library/Frameworks TCLSH_DIR=$HOME/usr/bin
The Makefile variables TCL_FRAMEWORK_DIR and TCLSH_DIR were added with Tk 8.4.3.
-4. Details regarding the macOS port of Tk.
+5. Details regarding the macOS port of Tk.
-------------------------------------------
-4.1 About the event loop
+5.1 About the event loop
~~~~~~~~~~~~~~~~~~~~~~~~
The main program in a typical OSX application looks like this (see
@@ -416,7 +501,7 @@ for each dirty rectangle of the NSView, and then adds the expose
event to the Tcl queue.
-4.2 Autorelease pools
+5.2 Autorelease pools
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In order to carry out the job of managing autorelease pools, which
@@ -451,7 +536,7 @@ called in these preliminary stages need to create and drain their own
NSAutoreleasePools whenever they call methods of Appkit objects
(e.g. NSFont).
-4.3 Clipping regions and "ghost windows"
+5.3 Clipping regions and "ghost windows"
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Another unusual aspect of the macOS port is its use of clipping
@@ -561,8 +646,8 @@ source and destination rectangles for the scrolling. The embedded
windows are redrawn within the DisplayText function by some
conditional code which is only used for macOS.
-5.0 Dark Mode on 10.14
-~~~~~~~~~~~~~~~~~~~~~~~~~~~
+6. Virtual events on 10.14
+---------------------------
10.14 supports system appearance changes, and has added a "Dark Mode"
that casts all window frames and menus as black. Tk 8.6.9 supports Dark
diff --git a/macosx/tkMacOSXImage.c b/macosx/tkMacOSXImage.c
index a5c870a..0c9fcb3 100644
--- a/macosx/tkMacOSXImage.c
+++ b/macosx/tkMacOSXImage.c
@@ -94,6 +94,15 @@ TkMacOSXCreateCGImageWithXImage(
*/
CGColorSpaceRef colorspace = CGColorSpaceCreateDeviceRGB();
+
+ if (image->width == 0 && image->height == 0) {
+
+ /*
+ * CGCreateImage complains on early macOS releases.
+ */
+
+ return NULL;
+ }
bitsPerComponent = 8;
bitsPerPixel = 32;
bitmapInfo = (image->byte_order == MSBFirst ?
diff --git a/macosx/tkMacOSXKeyEvent.c b/macosx/tkMacOSXKeyEvent.c
index 31fffa1..a153797 100644
--- a/macosx/tkMacOSXKeyEvent.c
+++ b/macosx/tkMacOSXKeyEvent.c
@@ -55,9 +55,11 @@ unsigned short releaseCode;
#endif
NSWindow* w;
NSEventType type = [theEvent type];
- NSUInteger modifiers, len = 0;
+ NSUInteger modifiers = ([theEvent modifierFlags] &
+ NSDeviceIndependentModifierFlagsMask);
+ NSUInteger len = 0;
BOOL repeat = NO;
- unsigned short keyCode;
+ unsigned short keyCode = [theEvent keyCode];
NSString *characters = nil, *charactersIgnoringModifiers = nil;
static NSUInteger savedModifiers = 0;
static NSMutableArray *nsEvArray;
@@ -77,6 +79,16 @@ unsigned short releaseCode;
return theEvent;
}
+ /*
+ * Control-Tab and Control-Shift-Tab are used to switch tabs in a tabbed
+ * window. We do not want to generate an Xevent for these since that might
+ * cause the deselected tab to be reactivated.
+ */
+
+ if (keyCode == 48 && (modifiers & NSControlKeyMask) == NSControlKeyMask) {
+ return theEvent;
+ }
+
switch (type) {
case NSKeyUp:
/*Fix for bug #1ba71a86bb: key release firing on key press.*/
@@ -90,8 +102,6 @@ unsigned short releaseCode;
charactersIgnoringModifiers = [theEvent charactersIgnoringModifiers];
len = [charactersIgnoringModifiers length];
case NSFlagsChanged:
- modifiers = [theEvent modifierFlags];
- keyCode = [theEvent keyCode];
#if defined(TK_MAC_DEBUG_EVENTS) || NS_KEYLOG == 1
TKLog(@"-[%@(%p) %s] r=%d mods=%u '%@' '%@' code=%u c=%d %@ %d", [self class], self, _cmd, repeat, modifiers, characters, charactersIgnoringModifiers, keyCode,([charactersIgnoringModifiers length] == 0) ? 0 : [charactersIgnoringModifiers characterAtIndex: 0], w, type);
diff --git a/macosx/tkMacOSXMenu.c b/macosx/tkMacOSXMenu.c
index 590402a..ec32a78 100644
--- a/macosx/tkMacOSXMenu.c
+++ b/macosx/tkMacOSXMenu.c
@@ -227,14 +227,16 @@ static int ModifierCharWidth(Tk_Font tkfont);
@end
@implementation TKMenu(TKMenuActions)
-// target methods
- (BOOL) validateMenuItem: (NSMenuItem *) menuItem
{
return [menuItem isEnabled];
}
-// Workaround for bug 3572016; leaves menu items enabled during modal dialog.
+/*
+ * Workaround for bug 3572016; leave menu items enabled during modal dialog.
+ */
+
- (BOOL)worksWhenModal
{
return YES;
@@ -244,8 +246,8 @@ static int ModifierCharWidth(Tk_Font tkfont);
{
/*
* With the delegate matching key equivalents, when a menu action is sent
- * in response to a key equivalent, sender is the whole menu and not the
- * the specific menu item, use this to ignore key equivalents for our
+ * in response to a key equivalent, the sender is the whole menu and not the
+ * specific menu item. We use this to ignore key equivalents for Tk
* menus (as Tk handles them directly via bindings).
*/
@@ -256,10 +258,12 @@ static int ModifierCharWidth(Tk_Font tkfont);
if (menuPtr && mePtr) {
Tcl_Interp *interp = menuPtr->interp;
+
/*Add time for errors to fire if necessary. This is sub-optimal
*but avoids issues with Tcl/Cocoa event loop integration.
*/
- Tcl_Sleep(100);
+
+ //Tcl_Sleep(100);
Tcl_Preserve(interp);
Tcl_Preserve(menuPtr);
@@ -278,40 +282,56 @@ static int ModifierCharWidth(Tk_Font tkfont);
@end
@implementation TKMenu(TKMenuDelegate)
-#define keyEquivModifiersMatch(km, m) (( \
- ((km) & NSCommandKeyMask) != ((m) & NSCommandKeyMask) || \
- ((km) & NSAlternateKeyMask) != ((m) & NSAlternateKeyMask) || \
- ((km) & NSControlKeyMask) != ((m) & NSControlKeyMask) || \
- (((km) & NSShiftKeyMask) != ((m) & NSShiftKeyMask) && \
- ((m) & NSFunctionKeyMask))) ? NO : YES)
- (BOOL) menuHasKeyEquivalent: (NSMenu *) menu forEvent: (NSEvent *) event
target: (id *) target action: (SEL *) action
{
- /*Use lowercaseString to keep "shift" from firing twice if bound to different procedure.*/
+ /*
+ * Use lowercaseString when comparing keyEquivalents since the notion of
+ * a shifted upper case letter does not make much sense.
+ */
+
NSString *key = [[event charactersIgnoringModifiers] lowercaseString];
NSUInteger modifiers = [event modifierFlags] &
NSDeviceIndependentModifierFlagsMask;
if (modifiers == (NSCommandKeyMask | NSShiftKeyMask) &&
[key compare:@"?"] == NSOrderedSame) {
- return NO;
- }
+ /*
+ * Command-Shift-? has not been allowed as a keyboard equivalent since
+ * the first aqua port, for some mysterious reason.
+ */
- // For command key, take input manager's word so things
- // like dvorak / qwerty layout work.
- if (([event modifierFlags] & NSCommandKeyMask) == NSCommandKeyMask) {
- key = [event characters];
+ return NO;
+ } else if (modifiers == (NSControlKeyMask | NSShiftKeyMask) &&
+ [event keyCode] == 48) {
+
+ /* Starting with OSX 10.12 Control-Tab and Control-Shift-Tab are used
+ * to select window tabs. But for some even more mysterious reason the
+ * Control-Shift-Tab event has character 0x19 = NSBackTabCharacter
+ * rather than 0x09 = NSTabCharacter. At the same time, the
+ * keyEquivalent must be \0x09 in order for it to be displayed
+ * correctly in the menu. This makes it impossible for the standard
+ * "Select Previous Tab" to work correctly, unless we intervene.
+ */
+
+ key = @"\t";
+ } else if (([event modifierFlags] & NSCommandKeyMask) == NSCommandKeyMask) {
+
+ /*
+ * If the command modifier is set, use the full character string so
+ * things like the dvorak / qwerty layout will work.
+ */
+
+ key = [event characters];
}
NSArray *itemArray = [self itemArray];
-
for (NSMenuItem *item in itemArray) {
- if ([item isEnabled] && [[item keyEquivalent] compare:key] ==
- NSOrderedSame) {
+ if ([item isEnabled] &&
+ [[item keyEquivalent] compare:key] == NSOrderedSame) {
NSUInteger keyEquivModifiers = [item keyEquivalentModifierMask];
-
- if (keyEquivModifiersMatch(keyEquivModifiers, modifiers)) {
+ if (keyEquivModifiers == modifiers) {
*target = [item target];
*action = [item action];
return YES;
diff --git a/macosx/tkMacOSXMenus.c b/macosx/tkMacOSXMenus.c
index 15dbad4..7d77d23 100644
--- a/macosx/tkMacOSXMenus.c
+++ b/macosx/tkMacOSXMenus.c
@@ -17,6 +17,7 @@
static void GenerateEditEvent(const char *name);
static Tcl_Obj * GetWidgetDemoPath(Tcl_Interp *interp);
+
#pragma mark TKApplication(TKMenus)
@@ -97,19 +98,49 @@ static Tcl_Obj * GetWidgetDemoPath(Tcl_Interp *interp);
target:nil],
nil]];
- _defaultWindowsMenuItems = [[NSArray arrayWithObjects:
- [NSMenuItem itemWithTitle:@"Minimize"
- action:@selector(performMiniaturize:) target:nil
- keyEquivalent:@"m"],
- [NSMenuItem itemWithTitle:@"Zoom" action:@selector(performZoom:)
- target:nil],
- [NSMenuItem separatorItem],
+ _defaultWindowsMenuItems = [NSArray arrayWithObjects:
+ [NSMenuItem itemWithTitle:@"Minimize"
+ action:@selector(performMiniaturize:) target:nil
+ keyEquivalent:@"m"],
+ [NSMenuItem itemWithTitle:@"Zoom" action:@selector(performZoom:)
+ target:nil],
+ nil];
+
+ /*
+ * On OS X 10.12 we get duplicate tab control items if we create them here.
+ */
+
+ if ([NSApp macMinorVersion] > 12) {
+ _defaultWindowsMenuItems = [_defaultWindowsMenuItems
+ arrayByAddingObjectsFromArray:
+ [NSArray arrayWithObjects:
+ [NSMenuItem separatorItem],
+ [NSMenuItem itemWithTitle:@"Show Previous Tab"
+ action:@selector(selectPreviousTab:)
+ target:nil
+ keyEquivalent:@"\t"
+ keyEquivalentModifierMask:
+ NSControlKeyMask|NSShiftKeyMask],
+ [NSMenuItem itemWithTitle:@"Show Next Tab"
+ action:@selector(selectNextTab:)
+ target:nil
+ keyEquivalent:@"\t"
+ keyEquivalentModifierMask:NSControlKeyMask],
+ [NSMenuItem itemWithTitle:@"Move Tab To New Window"
+ action:@selector(moveTabToNewWindow:)
+ target:nil],
+ [NSMenuItem itemWithTitle:@"Merge All Windows"
+ action:@selector(mergeAllWindows:)
+ target:nil],
+ [NSMenuItem separatorItem],
+ nil]];
+ }
+ _defaultWindowsMenuItems = [_defaultWindowsMenuItems arrayByAddingObject:
[NSMenuItem itemWithTitle:@"Bring All to Front"
- action:@selector(arrangeInFront:)],
- nil] retain];
-
+ action:@selector(arrangeInFront:)]];
+ [_defaultWindowsMenuItems retain];
TKMenu *windowsMenu = [TKMenu menuWithTitle:@"Window" menuItems:
- _defaultWindowsMenuItems];
+ _defaultWindowsMenuItems];
_defaultHelpMenuItems = [[NSArray arrayWithObjects:
[NSMenuItem itemWithTitle:
diff --git a/macosx/tkMacOSXNotify.c b/macosx/tkMacOSXNotify.c
index 8c01fe3..88e7c76 100644
--- a/macosx/tkMacOSXNotify.c
+++ b/macosx/tkMacOSXNotify.c
@@ -135,7 +135,9 @@ void DebugPrintQueue(void)
*/
/*
- * Call super then check the pasteboard.
+ * 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.
*/
- (void) sendEvent: (NSEvent *) theEvent
{
@@ -360,7 +362,7 @@ TkMacOSXEventsCheckProc(
int oldServiceMode = Tcl_SetServiceMode(TCL_SERVICE_ALL);
NSEvent *processedEvent = [NSApp tkProcessEvent:currentEvent];
Tcl_SetServiceMode(oldServiceMode);
- if (processedEvent) { /* Should always be non-NULL. */
+ if (processedEvent) {
#ifdef TK_MAC_DEBUG_EVENTS
TKLog(@" event: %@", currentEvent);
#endif
@@ -370,6 +372,7 @@ TkMacOSXEventsCheckProc(
[NSApp sendEvent:currentEvent];
}
}
+
} else {
break;
}
diff --git a/macosx/tkMacOSXPrivate.h b/macosx/tkMacOSXPrivate.h
index a2a7a8f..27fe6d8 100644
--- a/macosx/tkMacOSXPrivate.h
+++ b/macosx/tkMacOSXPrivate.h
@@ -350,13 +350,17 @@ VISIBILITY_HIDDEN
- (void) keyDown: (NSEvent *) theEvent;
@end
+@interface NSWindow(TKWm)
+- (NSPoint) tkConvertPointToScreen:(NSPoint)point;
+- (NSPoint) tkConvertPointFromScreen:(NSPoint)point;
+@end
+
VISIBILITY_HIDDEN
@interface TKWindow : NSWindow
@end
-@interface NSWindow(TKWm)
-- (NSPoint) tkConvertPointToScreen:(NSPoint)point;
-- (NSPoint) tkConvertPointFromScreen:(NSPoint)point;
+@interface TKWindow(TKWm)
+- (void) tkLayoutChanged;
@end
@interface NSDrawerWindow : NSWindow
diff --git a/macosx/tkMacOSXWindowEvent.c b/macosx/tkMacOSXWindowEvent.c
index ba2134d..b234e72 100644
--- a/macosx/tkMacOSXWindowEvent.c
+++ b/macosx/tkMacOSXWindowEvent.c
@@ -155,19 +155,7 @@ extern NSString *NSWindowDidOrderOffScreenNotification;
#ifdef TK_MAC_DEBUG_NOTIFICATIONS
TKLog(@"-[%@(%p) %s] %@", [self class], self, _cmd, notification);
#endif
- NSWindow *w = [notification object];
- TkWindow *winPtr = TkMacOSXGetTkWindow(w);
- MacDrawable *macWin = winPtr->privatePtr;
-
- /*
- * We must apply the current window attributes when the window becomes a
- * FullScreen or a split screen window. Otherwise the mouse cursor will be
- * offset by the title bar height. The notification is sent in both cases.
- */
-
- if (winPtr) {
- TkMacOSXApplyWindowAttributes(macWin->winPtr, w);
- }
+ [(TKWindow *)[notification object] tkLayoutChanged];
}
- (void) windowExitedFullScreen: (NSNotification *) notification
@@ -175,18 +163,7 @@ extern NSString *NSWindowDidOrderOffScreenNotification;
#ifdef TK_MAC_DEBUG_NOTIFICATIONS
TKLog(@"-[%@(%p) %s] %@", [self class], self, _cmd, notification);
#endif
- NSWindow *w = [notification object];
- TkWindow *winPtr = TkMacOSXGetTkWindow(w);
- MacDrawable *macWin = winPtr->privatePtr;
-
- /*
- * Also apply the current window attributes when the window returns to its
- * normal size, for the same reason.
- */
-
- if (winPtr) {
- TkMacOSXApplyWindowAttributes(macWin->winPtr, w);
- }
+ [(TKWindow *)[notification object] tkLayoutChanged];
}
- (void) windowCollapsed: (NSNotification *) notification
@@ -936,6 +913,12 @@ ConfigureRestrictProc(
NSWindow *w = [self window];
TkWindow *winPtr = TkMacOSXGetTkWindow(w);
Tk_Window tkwin = (Tk_Window) winPtr;
+
+ if (![self inLiveResize] &&
+ [w respondsToSelector: @selector (tkLayoutChanged)]) {
+ [(TKWindow *)w tkLayoutChanged];
+ }
+
if (winPtr) {
unsigned int width = (unsigned int)newsize.width;
unsigned int height=(unsigned int)newsize.height;
diff --git a/macosx/tkMacOSXWm.c b/macosx/tkMacOSXWm.c
index f6577ce..4a85551 100644
--- a/macosx/tkMacOSXWm.c
+++ b/macosx/tkMacOSXWm.c
@@ -10,7 +10,7 @@
* Copyright 2001-2009, Apple Inc.
* Copyright (c) 2006-2009 Daniel A. Steffen <das@users.sourceforge.net>
* Copyright (c) 2010 Kevin Walzer/WordTech Communications LLC.
- * Copyright (c) 2017 Marc Culler.
+ * Copyright (c) 2017-2018 Marc Culler.
*
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
@@ -195,62 +195,6 @@ static int tkMacOSXWmAttrNotifyVal = 0;
static Tcl_HashTable windowTable;
static int windowHashInit = false;
-
-#pragma mark NSWindow(TKWm)
-
-/*
- * Conversion of coordinates between window and screen.
- */
-
-@implementation NSWindow(TKWm)
-#if MAC_OS_X_VERSION_MIN_REQUIRED < 1070
-- (NSPoint) tkConvertPointToScreen: (NSPoint) point
-{
- return [self convertBaseToScreen:point];
-}
-- (NSPoint) tkConvertPointFromScreen: (NSPoint)point
-{
- return [self convertScreenToBase:point];
-}
-#else
-- (NSPoint) tkConvertPointToScreen: (NSPoint) point
-{
- NSRect pointrect;
- pointrect.origin = point;
- pointrect.size.width = 0;
- pointrect.size.height = 0;
- return [self convertRectToScreen:pointrect].origin;
-}
-- (NSPoint) tkConvertPointFromScreen: (NSPoint)point
-{
- NSRect pointrect;
- pointrect.origin = point;
- pointrect.size.width = 0;
- pointrect.size.height = 0;
- return [self convertRectFromScreen:pointrect].origin;
-}
-#endif
-
-- (NSSize)windowWillResize:(NSWindow *)sender
- toSize:(NSSize)frameSize
-{
- NSRect currentFrame = [sender frame];
- TkWindow *winPtr = TkMacOSXGetTkWindow(sender);
- if (winPtr) {
- if (winPtr->wmInfoPtr->flags & WM_WIDTH_NOT_RESIZABLE) {
- frameSize.width = currentFrame.size.width;
- }
- if (winPtr->wmInfoPtr->flags & WM_HEIGHT_NOT_RESIZABLE) {
- frameSize.height = currentFrame.size.height;
- }
- }
- return frameSize;
-}
-@end
-
-#pragma mark -
-
-
/*
* Forward declarations for procedures defined in this file:
*/
@@ -365,6 +309,8 @@ static int WmWithdrawCmd(Tk_Window tkwin, TkWindow *winPtr,
static void WmUpdateGeom(WmInfo *wmPtr, TkWindow *winPtr);
static int WmWinStyle(Tcl_Interp *interp, TkWindow *winPtr,
int objc, Tcl_Obj *const objv[]);
+static int WmWinTabbingId(Tcl_Interp *interp, TkWindow *winPtr,
+ int objc, Tcl_Obj *const objv[]);
static void ApplyWindowAttributeFlagChanges(TkWindow *winPtr,
NSWindow *macWindow, UInt64 oldAttributes,
int oldFlags, int create, int initial);
@@ -377,28 +323,113 @@ static void GetMaxSize(TkWindow *winPtr, int *maxWidthPtr,
static void RemapWindows(TkWindow *winPtr,
MacDrawable *parentWin);
+#pragma mark NSWindow(TKWm)
+
+@implementation NSWindow(TKWm)
+
+#if MAC_OS_X_VERSION_MIN_REQUIRED < 1070
+- (NSPoint) tkConvertPointToScreen: (NSPoint) point
+{
+ return [self convertBaseToScreen:point];
+}
+- (NSPoint) tkConvertPointFromScreen: (NSPoint)point
+{
+ return [self convertScreenToBase:point];
+}
+#else
+- (NSPoint) tkConvertPointToScreen: (NSPoint) point
+{
+ NSRect pointrect;
+ pointrect.origin = point;
+ pointrect.size.width = 0;
+ pointrect.size.height = 0;
+ return [self convertRectToScreen:pointrect].origin;
+}
+- (NSPoint) tkConvertPointFromScreen: (NSPoint)point
+{
+ NSRect pointrect;
+ pointrect.origin = point;
+ pointrect.size.width = 0;
+ pointrect.size.height = 0;
+ return [self convertRectFromScreen:pointrect].origin;
+}
+#endif
+
+@end
+
+#pragma mark -
+
#pragma mark TKWindow(TKWm)
@implementation TKWindow: NSWindow
+@end
+
+@implementation TKWindow(TKWm)
+
+/*
+ * This method synchronizes Tk's understanding of the bounds of a contentView
+ * with the window's. It is needed because there are situations when the
+ * window manager can change the layout of an NSWindow without having been
+ * requested to do so by Tk. Examples are when a window goes FullScreen or
+ * shows a tab bar. NSWindow methods which involve such layout changes should
+ * be overridden or protected by methods which call this.
+ */
+
+- (void) tkLayoutChanged
+{
+ TkWindow *winPtr = TkMacOSXGetTkWindow(self);
+
+ if (winPtr) {
+ NSRect frameRect;
+
+ /*
+ * This avoids including the title bar for full screen windows
+ * but does include it for normal windows.
+ */
+
+ if ([self styleMask] & NSFullScreenWindowMask) {
+ frameRect = [NSWindow frameRectForContentRect:NSZeroRect
+ styleMask:[self styleMask]];
+ } else {
+ frameRect = [self frameRectForContentRect:NSZeroRect];
+ }
+ WmInfo *wmPtr = winPtr->wmInfoPtr;
+ wmPtr->xInParent = -frameRect.origin.x;
+ wmPtr->yInParent = frameRect.origin.y + frameRect.size.height;
+ wmPtr->parentWidth = winPtr->changes.width + frameRect.size.width;
+ wmPtr->parentHeight = winPtr->changes.height + frameRect.size.height;
+ }
+}
+
#if !(MAC_OS_X_VERSION_MAX_ALLOWED < 101200)
- (void)toggleTabBar:(id)sender
{
TkWindow *winPtr = TkMacOSXGetTkWindow(self);
- MacDrawable *macWin = winPtr->privatePtr;
if (!winPtr) {
return;
}
[super toggleTabBar:sender];
- if (([self styleMask] & NSFullScreenWindowMask) == 0) {
- TkMacOSXApplyWindowAttributes(macWin->winPtr, self);
- }
+ [self tkLayoutChanged];
}
#endif
-@end
-@implementation TKWindow(TKWm)
+- (NSSize)windowWillResize:(NSWindow *)sender
+ toSize:(NSSize)frameSize
+{
+ NSRect currentFrame = [sender frame];
+ TkWindow *winPtr = TkMacOSXGetTkWindow(sender);
+ if (winPtr) {
+ if (winPtr->wmInfoPtr->flags & WM_WIDTH_NOT_RESIZABLE) {
+ frameSize.width = currentFrame.size.width;
+ }
+ if (winPtr->wmInfoPtr->flags & WM_HEIGHT_NOT_RESIZABLE) {
+ frameSize.height = currentFrame.size.height;
+ }
+ }
+ return frameSize;
+}
- (BOOL) canBecomeKeyWindow
{
@@ -5250,10 +5281,10 @@ TkUnsupported1ObjCmd(
Tcl_Obj *const objv[]) /* Argument objects. */
{
static const char *const subcmds[] = {
- "style", NULL
+ "style", "tabbingid", NULL
};
enum SubCmds {
- TKMWS_STYLE
+ TKMWS_STYLE, TKMWS_TABID
};
Tk_Window tkwin = clientData;
TkWindow *winPtr;
@@ -5287,6 +5318,17 @@ TkUnsupported1ObjCmd(
return TCL_ERROR;
}
return WmWinStyle(interp, winPtr, objc, objv);
+ } else if (((enum SubCmds) index) == TKMWS_TABID) {
+ if ([NSApp macMinorVersion] < 12) {
+ Tcl_AddErrorInfo(interp,
+ "\n (TabbingIdentifiers only exist on OSX 10.12 or later)");
+ return TCL_ERROR;
+ }
+ if ((objc < 3) || (objc > 4)) {
+ Tcl_WrongNumArgs(interp, 2, objv, "tabbingid window ?newid?");
+ return TCL_ERROR;
+ }
+ return WmWinTabbingId(interp, winPtr, objc, objv);
}
/* won't be reached */
return TCL_ERROR;
@@ -5495,6 +5537,75 @@ WmWinStyle(
/*
*----------------------------------------------------------------------
*
+ * WmWinTabbingId --
+ *
+ * This procedure is invoked to process the
+ * "::tk::unsupported::MacWindowStyle tabbingid" subcommand. The command
+ * allows you to get or set the tabbingIdentifier for the NSWindow
+ * associated with a Tk Window. The syntax is:
+ * tk::unsupported::MacWindowStyle tabbingid window ?newId?
+ *
+ * Results:
+ * Returns the tabbingIdentifier of the window prior to calling this
+ * function. If the optional newId argument is omitted, the window's
+ * tabbingIdentifier is not changed.
+ *
+ * Side effects:
+ * Windows may only be grouped together as tabs if they all have the same
+ * tabbingIdentifier. In particular, by giving a window a unique
+ * tabbingIdentifier one can prevent it from becoming a tab in any other
+ * window. Note, however, that changing the tabbingIdentifier of a window
+ * which is already a tab does not cause it to become a separate window.
+ *
+ *
+ *----------------------------------------------------------------------
+ */
+
+static int
+WmWinTabbingId(
+ Tcl_Interp *interp, /* Current interpreter. */
+ TkWindow *winPtr, /* Window to be manipulated. */
+ int objc, /* Number of arguments. */
+ Tcl_Obj * const objv[]) /* Argument objects. */
+{
+#if !(MAC_OS_X_VERSION_MAX_ALLOWED < 101200)
+ Tcl_Obj *result = NULL;
+ NSString *idString;
+ NSWindow *win = TkMacOSXDrawableWindow(winPtr->window);
+ if (win) {
+ idString = win.tabbingIdentifier;
+ result = Tcl_NewStringObj(idString.UTF8String, [idString length]);
+ }
+ if (result == NULL) {
+ Tcl_Panic("Failed to read tabbing identifier.");
+ }
+ Tcl_SetObjResult(interp, result);
+ if (objc == 3) {
+ return TCL_OK;
+ } else if (objc == 4) {
+ int len;
+ char *newId = Tcl_GetStringFromObj(objv[3], &len);
+ NSString *newIdString = [NSString stringWithUTF8String:newId];
+ [win setTabbingIdentifier: newIdString];
+
+ /*
+ * If the tabbingIdentifier of a tab is changed we also turn it into a
+ * separate window so we don't violate the rule that all tabs in the
+ * same frame must have the same tabbingIdentifier.
+ */
+
+ if ([idString compare:newIdString] != NSOrderedSame && [win tab]) {
+ [win moveTabToNewWindow:nil];
+ }
+ return TCL_OK;
+ }
+#endif
+ return TCL_ERROR;
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
* TkpMakeMenuWindow --
*
* Configure the window to be either a undecorated pull-down (or pop-up)
@@ -6367,8 +6478,17 @@ ApplyWindowAttributeFlagChanges(
*/
#if !(MAC_OS_X_VERSION_MAX_ALLOWED < 1070)
- if (!(macWindow.styleMask & NSWindowStyleMaskUtilityWindow)) {
+ 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.
+ */
+
+ [macWindow setMaxFullScreenContentSize:screenSize];
}
#endif
@@ -6393,7 +6513,7 @@ ApplyWindowAttributeFlagChanges(
/*
* The change of window class/attributes might have changed the window
- * structure widths:
+ * frame geometry:
*/
NSRect structureRect = [macWindow frameRectForContentRect:NSZeroRect];
diff --git a/unix/tkUnixButton.c b/unix/tkUnixButton.c
index 6a99124..975fca8 100644
--- a/unix/tkUnixButton.c
+++ b/unix/tkUnixButton.c
@@ -396,7 +396,7 @@ void
TkpDisplayButton(
ClientData clientData) /* Information about widget. */
{
- register TkButton *butPtr = (TkButton *) clientData;
+ register TkButton *butPtr = clientData;
GC gc;
Tk_3DBorder border;
Pixmap pixmap;
diff --git a/unix/tkUnixEvent.c b/unix/tkUnixEvent.c
index cc626c2..a3867a4 100644
--- a/unix/tkUnixEvent.c
+++ b/unix/tkUnixEvent.c
@@ -462,7 +462,7 @@ DisplayFileProc(
ClientData clientData, /* The display pointer. */
int flags) /* Should be TCL_READABLE. */
{
- TkDisplay *dispPtr = (TkDisplay *) clientData;
+ TkDisplay *dispPtr = clientData;
Display *display = dispPtr->display;
int numFound;
diff --git a/unix/tkUnixMenubu.c b/unix/tkUnixMenubu.c
index ad71b7b..ba78016 100644
--- a/unix/tkUnixMenubu.c
+++ b/unix/tkUnixMenubu.c
@@ -58,7 +58,7 @@ void
TkpDisplayMenuButton(
ClientData clientData) /* Information about widget. */
{
- register TkMenuButton *mbPtr = (TkMenuButton *) clientData;
+ register TkMenuButton *mbPtr = clientData;
GC gc;
Tk_3DBorder border;
Pixmap pixmap;
diff --git a/unix/tkUnixScale.c b/unix/tkUnixScale.c
index 8f88018..d0208b7 100644
--- a/unix/tkUnixScale.c
+++ b/unix/tkUnixScale.c
@@ -541,7 +541,7 @@ void
TkpDisplayScale(
ClientData clientData) /* Widget record for scale. */
{
- TkScale *scalePtr = (TkScale *) clientData;
+ TkScale *scalePtr = clientData;
Tk_Window tkwin = scalePtr->tkwin;
Tcl_Interp *interp = scalePtr->interp;
Pixmap pixmap;
diff --git a/unix/tkUnixScrlbr.c b/unix/tkUnixScrlbr.c
index 2446c3f..5a7b0a1 100644
--- a/unix/tkUnixScrlbr.c
+++ b/unix/tkUnixScrlbr.c
@@ -97,7 +97,7 @@ void
TkpDisplayScrollbar(
ClientData clientData) /* Information about window. */
{
- register TkScrollbar *scrollPtr = (TkScrollbar *) clientData;
+ register TkScrollbar *scrollPtr = clientData;
register Tk_Window tkwin = scrollPtr->tkwin;
XPoint points[7];
Tk_3DBorder border;
diff --git a/unix/tkUnixSelect.c b/unix/tkUnixSelect.c
index e67970d..6155f54 100644
--- a/unix/tkUnixSelect.c
+++ b/unix/tkUnixSelect.c
@@ -766,7 +766,7 @@ SelTimeoutProc(
retrPtr->result = TCL_ERROR;
} else {
retrPtr->timeout = Tcl_CreateTimerHandler(1000, SelTimeoutProc,
- (ClientData) retrPtr);
+ retrPtr);
}
}
diff --git a/unix/tkUnixWm.c b/unix/tkUnixWm.c
index 16914c4..5bfa69e 100644
--- a/unix/tkUnixWm.c
+++ b/unix/tkUnixWm.c
@@ -6411,7 +6411,7 @@ TkWmStackorderToplevel(
windows = NULL;
} else {
for (i = 0; i < numChildren; i++) {
- hPtr = Tcl_FindHashEntry(&table, (char *) children[i]);
+ hPtr = Tcl_FindHashEntry(&table, children[i]);
if (hPtr != NULL) {
childWinPtr = Tcl_GetHashValue(hPtr);
*window_ptr++ = childWinPtr;
diff --git a/win/tkWinButton.c b/win/tkWinButton.c
index e46bcb3..9cd13a7 100644
--- a/win/tkWinButton.c
+++ b/win/tkWinButton.c
@@ -315,7 +315,7 @@ TkpDisplayButton(
{
TkWinDCState state;
HDC dc;
- register TkButton *butPtr = (TkButton *) clientData;
+ register TkButton *butPtr = clientData;
GC gc;
Tk_3DBorder border;
Pixmap pixmap;
@@ -1253,7 +1253,7 @@ ButtonProc(
PAINTSTRUCT ps;
BeginPaint(hwnd, &ps);
EndPaint(hwnd, &ps);
- TkpDisplayButton((ClientData)butPtr);
+ TkpDisplayButton(butPtr);
/*
* Special note: must cancel any existing idle handler for
@@ -1261,7 +1261,7 @@ ButtonProc(
* cleared the REDRAW_PENDING flag.
*/
- Tcl_CancelIdleCall(TkpDisplayButton, (ClientData)butPtr);
+ Tcl_CancelIdleCall(TkpDisplayButton, butPtr);
return 0;
}
case BN_CLICKED: {
@@ -1276,14 +1276,14 @@ ButtonProc(
Tcl_Interp *interp = butPtr->info.interp;
if (butPtr->info.state != STATE_DISABLED) {
- Tcl_Preserve((ClientData)interp);
+ Tcl_Preserve(interp);
code = TkInvokeButton((TkButton*)butPtr);
if (code != TCL_OK && code != TCL_CONTINUE
&& code != TCL_BREAK) {
Tcl_AddErrorInfo(interp, "\n (button invoke)");
Tcl_BackgroundException(interp, code);
}
- Tcl_Release((ClientData)interp);
+ Tcl_Release(interp);
}
Tcl_ServiceAll();
return 0;
diff --git a/win/tkWinDialog.c b/win/tkWinDialog.c
index d8eec68..5a9034d 100644
--- a/win/tkWinDialog.c
+++ b/win/tkWinDialog.c
@@ -3022,7 +3022,7 @@ SetTkDialog(
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
char buf[32];
- sprintf(buf, "0x%p", (HWND) clientData);
+ sprintf(buf, "0x%p", clientData);
Tcl_SetVar2(tsdPtr->debugInterp, "tk_dialog", NULL, buf, TCL_GLOBAL_ONLY);
}
diff --git a/win/tkWinEmbed.c b/win/tkWinEmbed.c
index 43c5e25..daffb94 100644
--- a/win/tkWinEmbed.c
+++ b/win/tkWinEmbed.c
@@ -173,7 +173,7 @@ void Tk_MapEmbeddedWindow(
TkpWmSetState(winPtr, state);
TkWmMapWindow(winPtr);
}
- Tcl_Release((ClientData)winPtr);
+ Tcl_Release(winPtr);
}
/*
@@ -331,8 +331,8 @@ TkpUseWindow(
* window.
*/
- Tcl_Preserve((ClientData) winPtr);
- Tcl_DoWhenIdle((Tcl_IdleProc*) Tk_MapEmbeddedWindow, (ClientData) winPtr);
+ Tcl_Preserve(winPtr);
+ Tcl_DoWhenIdle((Tcl_IdleProc*) Tk_MapEmbeddedWindow, winPtr);
return TCL_OK;
}
@@ -392,7 +392,7 @@ TkpMakeContainer(
*/
Tk_CreateEventHandler(tkwin, StructureNotifyMask,
- ContainerEventProc, (ClientData) containerPtr);
+ ContainerEventProc, containerPtr);
}
/*
diff --git a/win/tkWinMenu.c b/win/tkWinMenu.c
index 435c7a1..6ac14c2 100644
--- a/win/tkWinMenu.c
+++ b/win/tkWinMenu.c
@@ -420,7 +420,7 @@ TkpDestroyMenu(
if (tsdPtr->menuHWND != NULL) {
Tcl_HashEntry *hashEntryPtr =
- Tcl_FindHashEntry(&tsdPtr->winMenuTable, (char *) winMenuHdl);
+ Tcl_FindHashEntry(&tsdPtr->winMenuTable, winMenuHdl);
if (hashEntryPtr != NULL) {
Tcl_DeleteHashEntry(hashEntryPtr);
@@ -1043,7 +1043,7 @@ TkWinHandleMenuEvent(
switch (*pMessage) {
case WM_UNINITMENUPOPUP:
hashEntryPtr = Tcl_FindHashEntry(&tsdPtr->winMenuTable,
- (char *) *pwParam);
+ *pwParam);
if (hashEntryPtr != NULL) {
menuPtr = Tcl_GetHashValue(hashEntryPtr);
if ((menuPtr->menuRefPtr != NULL)
@@ -1057,7 +1057,7 @@ TkWinHandleMenuEvent(
case WM_INITMENU:
TkMenuInit();
hashEntryPtr = Tcl_FindHashEntry(&tsdPtr->winMenuTable,
- (char *) *pwParam);
+ *pwParam);
if (hashEntryPtr != NULL) {
tsdPtr->oldServiceMode = Tcl_SetServiceMode(TCL_SERVICE_ALL);
menuPtr = Tcl_GetHashValue(hashEntryPtr);
@@ -1142,7 +1142,7 @@ TkWinHandleMenuEvent(
case WM_MENUCHAR: {
hashEntryPtr = Tcl_FindHashEntry(&tsdPtr->winMenuTable,
- (char *) *plParam);
+ *plParam);
if (hashEntryPtr != NULL) {
int i, len, underline;
Tcl_Obj *labelPtr;
@@ -1279,7 +1279,7 @@ TkWinHandleMenuEvent(
menuPtr = NULL;
if (*plParam != 0) {
hashEntryPtr = Tcl_FindHashEntry(&tsdPtr->winMenuTable,
- (char *) *plParam);
+ *plParam);
if (hashEntryPtr != NULL) {
menuPtr = Tcl_GetHashValue(hashEntryPtr);
}
@@ -1404,7 +1404,7 @@ TkpSetWindowMenuBar(
winMenuHdl = (HMENU) menuPtr->platformData;
hashEntryPtr = Tcl_FindHashEntry(&tsdPtr->winMenuTable,
- (char *) winMenuHdl);
+ winMenuHdl);
Tcl_DeleteHashEntry(hashEntryPtr);
DestroyMenu(winMenuHdl);
winMenuHdl = CreateMenu();
@@ -2148,8 +2148,7 @@ TkpInitializeMenuBindings(
*/
(void) Tcl_CreateObjCommand(interp, "tk::WinMenuKey",
- TkWinMenuKeyObjCmd,
- (ClientData) Tk_MainWindow(interp), (Tcl_CmdDeleteProc *) NULL);
+ TkWinMenuKeyObjCmd, Tk_MainWindow(interp), NULL);
(void) Tk_CreateBinding(interp, bindingTable, (ClientData) uid,
"<Alt_L>", "tk::WinMenuKey %W %N", 0);
diff --git a/win/tkWinScrlbr.c b/win/tkWinScrlbr.c
index 1b3717e..43a33ee 100644
--- a/win/tkWinScrlbr.c
+++ b/win/tkWinScrlbr.c
@@ -275,7 +275,7 @@ void
TkpDisplayScrollbar(
ClientData clientData) /* Information about window. */
{
- WinScrollbar *scrollPtr = (WinScrollbar *) clientData;
+ WinScrollbar *scrollPtr = clientData;
Tk_Window tkwin = scrollPtr->info.tkwin;
scrollPtr->info.flags &= ~REDRAW_PENDING;
@@ -295,7 +295,7 @@ TkpDisplayScrollbar(
DestroyWindow(hwnd);
CreateProc(tkwin, Tk_WindowId(Tk_Parent(tkwin)),
- (ClientData) scrollPtr);
+ scrollPtr);
} else {
UpdateScrollbar(scrollPtr);
}
@@ -617,7 +617,7 @@ ModalLoop(
int oldMode;
if (scrollPtr->hwnd) {
- Tcl_Preserve((ClientData)scrollPtr);
+ Tcl_Preserve(scrollPtr);
scrollPtr->winFlags |= IN_MODAL_LOOP;
oldMode = Tcl_SetServiceMode(TCL_SERVICE_ALL);
TkWinResendEvent(scrollPtr->oldProc, scrollPtr->hwnd, eventPtr);
@@ -626,7 +626,7 @@ ModalLoop(
if (scrollPtr->hwnd && scrollPtr->winFlags & ALREADY_DEAD) {
DestroyWindow(scrollPtr->hwnd);
}
- Tcl_Release((ClientData)scrollPtr);
+ Tcl_Release(scrollPtr);
}
}
diff --git a/win/tkWinTest.c b/win/tkWinTest.c
index 4fac15c..b99c47b 100644
--- a/win/tkWinTest.c
+++ b/win/tkWinTest.c
@@ -67,15 +67,15 @@ TkplatformtestInit(
*/
Tcl_CreateObjCommand(interp, "testclipboard", TestclipboardObjCmd,
- (ClientData) Tk_MainWindow(interp), NULL);
+ Tk_MainWindow(interp), NULL);
Tcl_CreateObjCommand(interp, "testwinevent", TestwineventObjCmd,
- (ClientData) Tk_MainWindow(interp), NULL);
+ Tk_MainWindow(interp), NULL);
Tcl_CreateObjCommand(interp, "testfindwindow", TestfindwindowObjCmd,
- (ClientData) Tk_MainWindow(interp), NULL);
+ Tk_MainWindow(interp), NULL);
Tcl_CreateObjCommand(interp, "testgetwindowinfo", TestgetwindowinfoObjCmd,
- (ClientData) Tk_MainWindow(interp), NULL);
+ Tk_MainWindow(interp), NULL);
Tcl_CreateObjCommand(interp, "testwinlocale", TestwinlocaleObjCmd,
- (ClientData) Tk_MainWindow(interp), NULL);
+ Tk_MainWindow(interp), NULL);
return TCL_OK;
}
@@ -244,7 +244,7 @@ TestclipboardObjCmd(
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument values. */
{
- Tk_Window tkwin = (Tk_Window) clientData;
+ Tk_Window tkwin = clientData;
if (objc != 1) {
Tcl_WrongNumArgs(interp, 1, objv, NULL);
diff --git a/win/tkWinWindow.c b/win/tkWinWindow.c
index 385e72b..fc72dac 100644
--- a/win/tkWinWindow.c
+++ b/win/tkWinWindow.c
@@ -71,7 +71,7 @@ Tk_AttachHWND(
twdPtr->window.winPtr = (TkWindow *) tkwin;
} else if (twdPtr->window.handle != NULL) {
entryPtr = Tcl_FindHashEntry(&tsdPtr->windowTable,
- (char *)twdPtr->window.handle);
+ twdPtr->window.handle);
Tcl_DeleteHashEntry(entryPtr);
}
@@ -115,7 +115,7 @@ Tk_HWNDToWindow(
Tcl_InitHashTable(&tsdPtr->windowTable, TCL_ONE_WORD_KEYS);
tsdPtr->initialized = 1;
}
- entryPtr = Tcl_FindHashEntry(&tsdPtr->windowTable, (char *) hwnd);
+ entryPtr = Tcl_FindHashEntry(&tsdPtr->windowTable, hwnd);
if (entryPtr != NULL) {
return (Tk_Window) Tcl_GetHashValue(entryPtr);
}
@@ -323,7 +323,7 @@ XDestroyWindow(
TkPointerDeadWindow(winPtr);
- entryPtr = Tcl_FindHashEntry(&tsdPtr->windowTable, (char*)hwnd);
+ entryPtr = Tcl_FindHashEntry(&tsdPtr->windowTable, hwnd);
if (entryPtr != NULL) {
Tcl_DeleteHashEntry(entryPtr);
}
diff --git a/win/tkWinWm.c b/win/tkWinWm.c
index 2222c72..52a7d3d 100644
--- a/win/tkWinWm.c
+++ b/win/tkWinWm.c
@@ -6677,7 +6677,7 @@ TkWmStackorderToplevelEnumProc(
/*fprintf(stderr, "Looking up HWND %d\n", hwnd);*/
- hPtr = Tcl_FindHashEntry(pair->table, (char *) hwnd);
+ hPtr = Tcl_FindHashEntry(pair->table, hwnd);
if (hPtr != NULL) {
childWinPtr = Tcl_GetHashValue(hPtr);
diff --git a/win/tkWinX.c b/win/tkWinX.c
index e3b552e..e35fd3c 100644
--- a/win/tkWinX.c
+++ b/win/tkWinX.c
@@ -256,7 +256,7 @@ TkWinXInit(
* Make sure we cleanup on finalize.
*/
- TkCreateExitHandler(TkWinXCleanup, (ClientData) hInstance);
+ TkCreateExitHandler(TkWinXCleanup, hInstance);
}
/*
@@ -279,7 +279,7 @@ void
TkWinXCleanup(
ClientData clientData)
{
- HINSTANCE hInstance = (HINSTANCE) clientData;
+ HINSTANCE hInstance = clientData;
/*
* Clean up our own class.
@@ -650,7 +650,7 @@ TkClipCleanup(
dispPtr->windowAtom);
Tk_DestroyWindow(dispPtr->clipWindow);
- Tcl_Release((ClientData) dispPtr->clipWindow);
+ Tcl_Release(dispPtr->clipWindow);
dispPtr->clipWindow = NULL;
}
}
diff --git a/win/ttkWinMonitor.c b/win/ttkWinMonitor.c
index 6e46374..5d9cf0a 100644
--- a/win/ttkWinMonitor.c
+++ b/win/ttkWinMonitor.c
@@ -152,7 +152,7 @@ MODULE_SCOPE int Ttk_WinPlatformInit(Tcl_Interp *interp)
HWND hwnd;
hwnd = CreateThemeMonitorWindow(Tk_GetHINSTANCE(), interp);
- Ttk_RegisterCleanup(interp, (ClientData)hwnd, DestroyThemeMonitorWindow);
+ Ttk_RegisterCleanup(interp, hwnd, DestroyThemeMonitorWindow);
TtkWinTheme_Init(interp, hwnd);
TtkXPTheme_Init(interp, hwnd);