summaryrefslogtreecommitdiffstats
path: root/macosx/tkMacOSXWm.c
diff options
context:
space:
mode:
Diffstat (limited to 'macosx/tkMacOSXWm.c')
-rw-r--r--macosx/tkMacOSXWm.c643
1 files changed, 353 insertions, 290 deletions
diff --git a/macosx/tkMacOSXWm.c b/macosx/tkMacOSXWm.c
index 9ac0369..b651b3c 100644
--- a/macosx/tkMacOSXWm.c
+++ b/macosx/tkMacOSXWm.c
@@ -51,7 +51,6 @@
| tkCanJoinAllSpacesAttribute | tkMoveToActiveSpaceAttribute \
| tkNonactivatingPanelAttribute | tkHUDWindowAttribute)
-
/*Objects for use in setting background color and opacity of window.*/
NSColor *colorName = NULL;
NSString *opaqueTag = NULL;
@@ -407,6 +406,7 @@ SetWindowSizeLimits(
wmPtr->maxAspect.x && wmPtr->minAspect.y == wmPtr->maxAspect.y) {
NSSize aspect = NSMakeSize(wmPtr->minAspect.x, wmPtr->minAspect.y);
CGFloat ratio = aspect.width/aspect.height;
+
[macWindow setContentAspectRatio:aspect];
if ((CGFloat)minWidth/(CGFloat)minHeight > ratio) {
minHeight = lround(minWidth / ratio);
@@ -458,7 +458,6 @@ static TkWindow*
FrontWindowAtPoint(
int x, int y)
{
-
NSPoint p = NSMakePoint(x, tkMacOSXZeroScreenHeight - y);
NSWindow *win = nil;
NSInteger windowCount;
@@ -470,6 +469,7 @@ FrontWindowAtPoint(
NSWindowList(windowCount, windowNumbers);
for (NSInteger index = 0; index < windowCount; index++) {
NSWindow *w = [NSApp windowWithWindowNumber:windowNumbers[index]];
+
if (w && NSMouseInRect(p, [w frame], NO)) {
win = w;
break;
@@ -479,7 +479,6 @@ FrontWindowAtPoint(
}
return (win ? TkMacOSXGetTkWindow(win) : NULL);
}
-
/*
*----------------------------------------------------------------------
@@ -549,7 +548,7 @@ TkWmNewWindow(
wmPtr->configHeight = -1;
wmPtr->vRoot = None;
wmPtr->protPtr = NULL;
- wmPtr->cmdArgv = NULL;
+ wmPtr->commandObj = NULL;
wmPtr->clientMachine = NULL;
wmPtr->flags = WM_NEVER_MAPPED;
wmPtr->macClass = kDocumentWindowClass;
@@ -561,7 +560,6 @@ TkWmNewWindow(
UpdateVRootGeometry(wmPtr);
-
/*
* Tk must monitor structure events for top-level windows, in order to
* detect size and position changes caused by window managers.
@@ -753,14 +751,13 @@ TkWmDeadWindow(
wmPtr2->hints.flags &= ~IconWindowHint;
}
while (wmPtr->protPtr != NULL) {
- ProtocolHandler *protPtr;
+ ProtocolHandler *protPtr = wmPtr->protPtr;
- protPtr = wmPtr->protPtr;
wmPtr->protPtr = protPtr->nextPtr;
Tcl_EventuallyFree(protPtr, TCL_DYNAMIC);
}
- if (wmPtr->cmdArgv != NULL) {
- ckfree(wmPtr->cmdArgv);
+ if (wmPtr->commandObj != NULL) {
+ Tcl_DecrRefCount(wmPtr->commandObj);
}
if (wmPtr->clientMachine != NULL) {
ckfree(wmPtr->clientMachine);
@@ -777,12 +774,13 @@ TkWmDeadWindow(
*/
NSWindow *window = wmPtr->window;
+
if (window && !Tk_IsEmbedded(winPtr) ) {
[[window parentWindow] removeChildWindow:window];
[window close];
TkMacOSXUnregisterMacWindow(window);
if (winPtr->window) {
- ((MacDrawable *)winPtr->window)->view = nil;
+ ((MacDrawable *) winPtr->window)->view = nil;
}
TkMacOSXMakeCollectableAndRelease(wmPtr->window);
}
@@ -875,13 +873,13 @@ Tk_WmObjCmd(
argv1 = Tcl_GetStringFromObj(objv[1], &length);
if ((argv1[0] == 't') && (strncmp(argv1, "tracing", length) == 0)
- && (length >= 3)) {
+ && (length >= 3)) {
if ((objc != 2) && (objc != 3)) {
Tcl_WrongNumArgs(interp, 2, objv, "?boolean?");
return TCL_ERROR;
}
if (objc == 2) {
- Tcl_SetResult(interp, ((wmTracing) ? "on" : "off"), TCL_STATIC);
+ Tcl_SetObjResult(interp, Tcl_NewBooleanObj(wmTracing));
return TCL_OK;
}
return Tcl_GetBooleanFromObj(interp, objv[2], &wmTracing);
@@ -902,8 +900,10 @@ Tk_WmObjCmd(
}
if (!Tk_IsTopLevel(winPtr)
&& (index != WMOPT_MANAGE) && (index != WMOPT_FORGET)) {
- Tcl_AppendResult(interp, "window \"", winPtr->pathName,
- "\" isn't a top-level window", NULL);
+ Tcl_SetObjResult(interp, Tcl_ObjPrintf(
+ "window \"%s\" isn't a top-level window", winPtr->pathName));
+ Tcl_SetErrorCode(interp, "TK", "LOOKUP", "TOPLEVEL", winPtr->pathName,
+ NULL);
return TCL_ERROR;
}
@@ -1013,12 +1013,13 @@ WmAspectCmd(
}
if (objc == 3) {
if (wmPtr->sizeHintsFlags & PAspect) {
- char buf[TCL_INTEGER_SPACE * 4];
+ Tcl_Obj *results[4];
- sprintf(buf, "%d %d %d %d", wmPtr->minAspect.x,
- wmPtr->minAspect.y, wmPtr->maxAspect.x,
- wmPtr->maxAspect.y);
- Tcl_SetResult(interp, buf, TCL_VOLATILE);
+ results[0] = Tcl_NewIntObj(wmPtr->minAspect.x);
+ results[1] = Tcl_NewIntObj(wmPtr->minAspect.y);
+ results[2] = Tcl_NewIntObj(wmPtr->maxAspect.x);
+ results[3] = Tcl_NewIntObj(wmPtr->maxAspect.y);
+ Tcl_SetObjResult(interp, Tcl_NewListObj(4, results));
}
return TCL_OK;
}
@@ -1033,7 +1034,9 @@ WmAspectCmd(
}
if ((numer1 <= 0) || (denom1 <= 0) || (numer2 <= 0) ||
(denom2 <= 0)) {
- Tcl_SetResult(interp, "aspect number can't be <= 0", TCL_STATIC);
+ Tcl_SetObjResult(interp, Tcl_NewStringObj(
+ "aspect number can't be <= 0", -1));
+ Tcl_SetErrorCode(interp, "TK", "WM", "ASPECT", NULL);
return TCL_ERROR;
}
wmPtr->minAspect.x = numer1;
@@ -1273,18 +1276,18 @@ WmAttributesCmd(
macWindow = TkMacOSXDrawableWindow(winPtr->window);
if (objc == 3) { /* wm attributes $win */
- Tcl_Obj *result = Tcl_NewListObj(0,0);
+ Tcl_Obj *result = Tcl_NewObj();
for (attribute = 0; attribute < _WMATT_LAST_ATTRIBUTE; ++attribute) {
- Tcl_ListObjAppendElement(interp, result,
+ Tcl_ListObjAppendElement(NULL, result,
Tcl_NewStringObj(WmAttributeNames[attribute], -1));
- Tcl_ListObjAppendElement(interp, result,
+ Tcl_ListObjAppendElement(NULL, result,
WmGetAttribute(winPtr, macWindow, attribute));
}
Tcl_SetObjResult(interp, result);
} else if (objc == 4) { /* wm attributes $win -attribute */
if (Tcl_GetIndexFromObj(interp, objv[3], WmAttributeNames,
- "attribute", 0, &attribute) != TCL_OK) {
+ "attribute", 0, &attribute) != TCL_OK) {
return TCL_ERROR;
}
Tcl_SetObjResult(interp, WmGetAttribute(winPtr, macWindow, attribute));
@@ -1293,7 +1296,7 @@ WmAttributesCmd(
for (i = 3; i < objc; i += 2) {
if (Tcl_GetIndexFromObj(interp, objv[i], WmAttributeNames,
- "attribute", 0, &attribute) != TCL_OK) {
+ "attribute", 0, &attribute) != TCL_OK) {
return TCL_ERROR;
}
if (WmSetAttribute(winPtr, macWindow, interp, attribute, objv[i+1])
@@ -1343,7 +1346,8 @@ WmClientCmd(
}
if (objc == 3) {
if (wmPtr->clientMachine != NULL) {
- Tcl_SetResult(interp, wmPtr->clientMachine, TCL_STATIC);
+ Tcl_SetObjResult(interp,
+ Tcl_NewStringObj(wmPtr->clientMachine, -1));
}
return TCL_OK;
}
@@ -1389,10 +1393,9 @@ WmColormapwindowsCmd(
Tcl_Obj *const objv[]) /* Argument objects. */
{
register WmInfo *wmPtr = winPtr->wmInfoPtr;
- TkWindow **cmapList;
- TkWindow *winPtr2;
+ TkWindow **cmapList, *winPtr2;
int i, windowObjc, gotToplevel = 0;
- Tcl_Obj **windowObjv;
+ Tcl_Obj **windowObjv, *resultObj;
if ((objc != 3) && (objc != 4)) {
Tcl_WrongNumArgs(interp, 2, objv, "window ?windowList?");
@@ -1400,17 +1403,20 @@ WmColormapwindowsCmd(
}
if (objc == 3) {
Tk_MakeWindowExist((Tk_Window) winPtr);
+ resultObj = Tcl_NewObj();
for (i = 0; i < wmPtr->cmapCount; i++) {
if ((i == (wmPtr->cmapCount-1))
- && (wmPtr->flags & WM_ADDED_TOPLEVEL_COLORMAP)) {
+ && (wmPtr->flags & WM_ADDED_TOPLEVEL_COLORMAP)) {
break;
}
- Tcl_AppendElement(interp, wmPtr->cmapList[i]->pathName);
+ Tcl_ListObjAppendElement(NULL, resultObj,
+ TkNewWindowObj((Tk_Window) wmPtr->cmapList[i]));
}
+ Tcl_SetObjResult(interp, resultObj);
return TCL_OK;
}
if (Tcl_ListObjGetElements(interp, objv[3], &windowObjc, &windowObjv)
- != TCL_OK) {
+ != TCL_OK) {
return TCL_ERROR;
}
cmapList = ckalloc((windowObjc+1) * sizeof(TkWindow*));
@@ -1476,38 +1482,34 @@ WmCommandCmd(
Tcl_Obj *const objv[]) /* Argument objects. */
{
register WmInfo *wmPtr = winPtr->wmInfoPtr;
- char *argv3;
- int cmdArgc;
- const char **cmdArgv;
+ int len;
if ((objc != 3) && (objc != 4)) {
Tcl_WrongNumArgs(interp, 2, objv, "window ?value?");
return TCL_ERROR;
}
if (objc == 3) {
- if (wmPtr->cmdArgv != NULL) {
- argv3 = Tcl_Merge(wmPtr->cmdArgc, wmPtr->cmdArgv);
- Tcl_SetResult(interp, argv3, TCL_VOLATILE);
- ckfree(argv3);
+ if (wmPtr->commandObj != NULL) {
+ Tcl_SetObjResult(interp, wmPtr->commandObj);
}
return TCL_OK;
}
- argv3 = Tcl_GetString(objv[3]);
- if (argv3[0] == 0) {
- if (wmPtr->cmdArgv != NULL) {
- ckfree(wmPtr->cmdArgv);
- wmPtr->cmdArgv = NULL;
+ if (Tcl_GetString(objv[3])[0] == 0) {
+ if (wmPtr->commandObj != NULL) {
+ Tcl_DecrRefCount(wmPtr->commandObj);
+ wmPtr->commandObj = NULL;
}
return TCL_OK;
}
- if (Tcl_SplitList(interp, argv3, &cmdArgc, &cmdArgv) != TCL_OK) {
+ if (Tcl_ListObjLength(interp, objv[3], &len) != TCL_OK) {
return TCL_ERROR;
}
- if (wmPtr->cmdArgv != NULL) {
- ckfree(wmPtr->cmdArgv);
+ if (wmPtr->commandObj != NULL) {
+ Tcl_DecrRefCount(wmPtr->commandObj);
}
- wmPtr->cmdArgc = cmdArgc;
- wmPtr->cmdArgv = cmdArgv;
+ wmPtr->commandObj = Tcl_DuplicateObj(objv[3]);
+ Tcl_IncrRefCount(wmPtr->commandObj);
+ Tcl_InvalidateStringRep(wmPtr->commandObj);
return TCL_OK;
}
@@ -1542,16 +1544,21 @@ WmDeiconifyCmd(
Tcl_WrongNumArgs(interp, 2, objv, "window");
return TCL_ERROR;
}
+
if (wmPtr->iconFor != NULL) {
- Tcl_AppendResult(interp, "can't deiconify ", Tcl_GetString(objv[2]),
- ": it is an icon for ", Tk_PathName(wmPtr->iconFor), NULL);
+ Tcl_SetObjResult(interp, Tcl_ObjPrintf(
+ "can't deiconify %s: it is an icon for %s",
+ Tcl_GetString(objv[2]), Tk_PathName(wmPtr->iconFor)));
+ Tcl_SetErrorCode(interp, "TK", "WM", "DEICONIFY", "ICON", NULL);
return TCL_ERROR;
- }
- if (winPtr->flags & TK_EMBEDDED) {
- Tcl_AppendResult(interp, "can't deiconify ", winPtr->pathName,
- ": it is an embedded window", NULL);
+ } else if (winPtr->flags & TK_EMBEDDED) {
+ Tcl_SetObjResult(interp, Tcl_ObjPrintf(
+ "can't deiconify %s: it is an embedded window",
+ winPtr->pathName));
+ Tcl_SetErrorCode(interp, "TK", "WM", "DEICONIFY", "EMBEDDED", NULL);
return TCL_ERROR;
}
+
TkpWmSetState(winPtr, TkMacOSXIsWindowZoomed(winPtr) ?
ZoomState : NormalState);
return TCL_OK;
@@ -1594,8 +1601,8 @@ WmFocusmodelCmd(
return TCL_ERROR;
}
if (objc == 3) {
- Tcl_SetResult(interp, (wmPtr->hints.input ? "passive" : "active"),
- TCL_STATIC);
+ Tcl_SetObjResult(interp, Tcl_NewStringObj(
+ wmPtr->hints.input ? "passive" : "active", -1));
return TCL_OK;
}
@@ -1636,18 +1643,17 @@ WmForgetCmd(
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
-
- register Tk_Window frameWin = (Tk_Window)winPtr;
+ register Tk_Window frameWin = (Tk_Window) winPtr;
if (Tk_IsTopLevel(frameWin)) {
-
MacDrawable *macWin = (MacDrawable *) winPtr->parentPtr->window;
+
TkFocusJoin(winPtr);
Tk_UnmapWindow(frameWin);
- TkWmDeadWindow(macWin);
+ TkWmDeadWindow((TkWindow *) macWin);
RemapWindows(winPtr, macWin);
- winPtr->flags &=~(TK_TOP_HIERARCHY|TK_TOP_LEVEL|TK_HAS_WRAPPER|TK_WIN_MANAGED);
+ winPtr->flags &= ~(TK_TOP_HIERARCHY|TK_TOP_LEVEL|TK_HAS_WRAPPER|TK_WIN_MANAGED);
/*
* Flags (above) must be cleared before calling TkMapTopFrame (below).
@@ -1655,7 +1661,9 @@ WmForgetCmd(
TkMapTopFrame(frameWin);
} else {
- /* Already not managed by wm - ignore it */
+ /*
+ * Already not managed by wm - ignore it.
+ */
}
return TCL_OK;
}
@@ -1687,7 +1695,6 @@ WmFrameCmd(
{
register WmInfo *wmPtr = winPtr->wmInfoPtr;
Window window;
- char buf[TCL_INTEGER_SPACE];
if (objc != 3) {
Tcl_WrongNumArgs(interp, 2, objv, "window");
@@ -1697,8 +1704,7 @@ WmFrameCmd(
if (window == None) {
window = Tk_WindowId((Tk_Window) winPtr);
}
- sprintf(buf, "0x%x", (unsigned) window);
- Tcl_SetResult(interp, buf, TCL_VOLATILE);
+ Tcl_SetObjResult(interp, Tcl_ObjPrintf("0x%x", (unsigned) window));
return TCL_OK;
}
@@ -1737,8 +1743,6 @@ WmGeometryCmd(
return TCL_ERROR;
}
if (objc == 3) {
- char buf[16 + TCL_INTEGER_SPACE * 4];
-
xSign = (wmPtr->flags & WM_NEGATIVE_X) ? '-' : '+';
ySign = (wmPtr->flags & WM_NEGATIVE_Y) ? '-' : '+';
if (wmPtr->gridWin != NULL) {
@@ -1750,9 +1754,8 @@ WmGeometryCmd(
width = winPtr->changes.width;
height = winPtr->changes.height;
}
- sprintf(buf, "%dx%d%c%d%c%d",
- width, height, xSign, wmPtr->x, ySign, wmPtr->y);
- Tcl_SetResult(interp, buf, TCL_VOLATILE);
+ Tcl_SetObjResult(interp, Tcl_ObjPrintf("%dx%d%c%d%c%d",
+ width, height, xSign, wmPtr->x, ySign, wmPtr->y));
return TCL_OK;
}
argv3 = Tcl_GetString(objv[3]);
@@ -1792,6 +1795,7 @@ WmGridCmd(
{
register WmInfo *wmPtr = winPtr->wmInfoPtr;
int reqWidth, reqHeight, widthInc, heightInc;
+ char *errorMsg;
if ((objc != 3) && (objc != 7)) {
Tcl_WrongNumArgs(interp, 2, objv,
@@ -1800,12 +1804,13 @@ WmGridCmd(
}
if (objc == 3) {
if (wmPtr->sizeHintsFlags & PBaseSize) {
- char buf[TCL_INTEGER_SPACE * 4];
+ Tcl_Obj *results[4];
- sprintf(buf, "%d %d %d %d", wmPtr->reqGridWidth,
- wmPtr->reqGridHeight, wmPtr->widthInc,
- wmPtr->heightInc);
- Tcl_SetResult(interp, buf, TCL_VOLATILE);
+ results[0] = Tcl_NewIntObj(wmPtr->reqGridWidth);
+ results[1] = Tcl_NewIntObj(wmPtr->reqGridHeight);
+ results[2] = Tcl_NewIntObj(wmPtr->widthInc);
+ results[3] = Tcl_NewIntObj(wmPtr->heightInc);
+ Tcl_SetObjResult(interp, Tcl_NewListObj(4, results));
}
return TCL_OK;
}
@@ -1832,20 +1837,17 @@ WmGridCmd(
return TCL_ERROR;
}
if (reqWidth < 0) {
- Tcl_SetResult(interp, "baseWidth can't be < 0", TCL_STATIC);
- return TCL_ERROR;
- }
- if (reqHeight < 0) {
- Tcl_SetResult(interp, "baseHeight can't be < 0", TCL_STATIC);
- return TCL_ERROR;
- }
- if (widthInc <= 0) {
- Tcl_SetResult(interp, "widthInc can't be <= 0", TCL_STATIC);
- return TCL_ERROR;
- }
- if (heightInc <= 0) {
- Tcl_SetResult(interp, "heightInc can't be <= 0", TCL_STATIC);
- return TCL_ERROR;
+ errorMsg = "baseWidth can't be < 0";
+ goto error;
+ } else if (reqHeight < 0) {
+ errorMsg = "baseHeight can't be < 0";
+ goto error;
+ } else if (widthInc <= 0) {
+ errorMsg = "widthInc can't be <= 0";
+ goto error;
+ } else if (heightInc <= 0) {
+ errorMsg = "heightInc can't be <= 0";
+ goto error;
}
Tk_SetGrid((Tk_Window) winPtr, reqWidth, reqHeight, widthInc,
heightInc);
@@ -1853,6 +1855,11 @@ WmGridCmd(
wmPtr->flags |= WM_UPDATE_SIZE_HINTS;
WmUpdateGeom(wmPtr, winPtr);
return TCL_OK;
+
+ error:
+ Tcl_SetObjResult(interp, Tcl_NewStringObj(errorMsg, -1));
+ Tcl_SetErrorCode(interp, "TK", "WM", "GRID", NULL);
+ return TCL_ERROR;
}
/*
@@ -1891,10 +1898,11 @@ WmGroupCmd(
}
if (objc == 3) {
if (wmPtr->hints.flags & WindowGroupHint) {
- Tcl_SetResult(interp, wmPtr->leaderName, TCL_STATIC);
+ Tcl_SetObjResult(interp, Tcl_NewStringObj(wmPtr->leaderName, -1));
}
return TCL_OK;
}
+
argv3 = Tcl_GetStringFromObj(objv[3], &length);
if (*argv3 == '\0') {
wmPtr->hints.flags &= ~WindowGroupHint;
@@ -1954,8 +1962,9 @@ WmIconbitmapCmd(
}
if (objc == 3) {
if (wmPtr->hints.flags & IconPixmapHint) {
- Tcl_SetResult(interp, (char*)Tk_NameOfBitmap(winPtr->display,
- wmPtr->hints.icon_pixmap), TCL_STATIC);
+ Tcl_SetObjResult(interp, Tcl_NewStringObj(
+ Tk_NameOfBitmap(winPtr->display,wmPtr->hints.icon_pixmap),
+ -1));
}
return TCL_OK;
}
@@ -2016,26 +2025,33 @@ WmIconifyCmd(
Tcl_WrongNumArgs(interp, 2, objv, "window");
return TCL_ERROR;
}
+
if (Tk_Attributes((Tk_Window) winPtr)->override_redirect) {
- Tcl_AppendResult(interp, "can't iconify \"", winPtr->pathName,
- "\": override-redirect flag is set", NULL);
+ Tcl_SetObjResult(interp, Tcl_ObjPrintf(
+ "can't iconify \"%s\": override-redirect flag is set",
+ winPtr->pathName));
+ Tcl_SetErrorCode(interp, "TK", "WM", "ICONIFY", "OVERRIDE_REDIRECT",
+ NULL);
return TCL_ERROR;
- }
- if (wmPtr->master != None) {
- Tcl_AppendResult(interp, "can't iconify \"", winPtr->pathName,
- "\": it is a transient", NULL);
+ } else if (wmPtr->master != None) {
+ Tcl_SetObjResult(interp, Tcl_ObjPrintf(
+ "can't iconify \"%s\": it is a transient", winPtr->pathName));
+ Tcl_SetErrorCode(interp, "TK", "WM", "ICONIFY", "TRANSIENT", NULL);
return TCL_ERROR;
- }
- if (wmPtr->iconFor != NULL) {
- Tcl_AppendResult(interp, "can't iconify ", winPtr->pathName,
- ": it is an icon for ", Tk_PathName(wmPtr->iconFor), NULL);
+ } else if (wmPtr->iconFor != NULL) {
+ Tcl_SetObjResult(interp, Tcl_ObjPrintf(
+ "can't iconify %s: it is an icon for %s",
+ winPtr->pathName, Tk_PathName(wmPtr->iconFor)));
+ Tcl_SetErrorCode(interp, "TK", "WM", "ICONIFY", "ICON", NULL);
return TCL_ERROR;
- }
- if (winPtr->flags & TK_EMBEDDED) {
- Tcl_AppendResult(interp, "can't iconify ", winPtr->pathName,
- ": it is an embedded window", NULL);
+ } else if (winPtr->flags & TK_EMBEDDED) {
+ Tcl_SetObjResult(interp, Tcl_ObjPrintf(
+ "can't iconify %s: it is an embedded window",
+ winPtr->pathName));
+ Tcl_SetErrorCode(interp, "TK", "WM", "ICONIFY", "EMBEDDED", NULL);
return TCL_ERROR;
}
+
TkpWmSetState(winPtr, IconicState);
return TCL_OK;
}
@@ -2073,13 +2089,16 @@ WmIconmaskCmd(
Tcl_WrongNumArgs(interp, 2, objv, "window ?bitmap?");
return TCL_ERROR;
}
+
if (objc == 3) {
if (wmPtr->hints.flags & IconMaskHint) {
- Tcl_SetResult(interp, (char *) Tk_NameOfBitmap(winPtr->display,
- wmPtr->hints.icon_mask), TCL_STATIC);
+ Tcl_SetObjResult(interp, Tcl_NewStringObj(
+ Tk_NameOfBitmap(winPtr->display, wmPtr->hints.icon_mask),
+ -1));
}
return TCL_OK;
}
+
argv3 = Tcl_GetString(objv[3]);
if (*argv3 == '\0') {
if (wmPtr->hints.icon_mask != None) {
@@ -2200,8 +2219,10 @@ WmIconphotoCmd(
for (i = 3 + isDefault; i < objc; i++) {
photo = Tk_FindPhoto(interp, Tcl_GetString(objv[i]));
if (photo == NULL) {
- Tcl_AppendResult(interp, "can't use \"", Tcl_GetString(objv[i]),
- "\" as iconphoto: not a photo image", NULL);
+ Tcl_SetObjResult(interp, Tcl_ObjPrintf(
+ "can't use \"%s\" as iconphoto: not a photo image",
+ Tcl_GetString(objv[i])));
+ Tcl_SetErrorCode(interp, "TK", "WM", "ICONPHOTO", "PHOTO", NULL);
return TCL_ERROR;
}
Tk_PhotoGetSize(photo, &width, &height);
@@ -2247,16 +2268,18 @@ WmIconpositionCmd(
Tcl_WrongNumArgs(interp, 2, objv, "window ?x y?");
return TCL_ERROR;
}
+
if (objc == 3) {
if (wmPtr->hints.flags & IconPositionHint) {
- char buf[TCL_INTEGER_SPACE * 2];
+ Tcl_Obj *results[2];
- sprintf(buf, "%d %d", wmPtr->hints.icon_x,
- wmPtr->hints.icon_y);
- Tcl_SetResult(interp, buf, TCL_VOLATILE);
+ results[0] = Tcl_NewIntObj(wmPtr->hints.icon_x);
+ results[1] = Tcl_NewIntObj(wmPtr->hints.icon_y);
+ Tcl_SetObjResult(interp, Tcl_NewListObj(2, results));
}
return TCL_OK;
}
+
if (*Tcl_GetString(objv[3]) == '\0') {
wmPtr->hints.flags &= ~IconPositionHint;
} else {
@@ -2304,12 +2327,14 @@ WmIconwindowCmd(
Tcl_WrongNumArgs(interp, 2, objv, "window ?pathName?");
return TCL_ERROR;
}
+
if (objc == 3) {
if (wmPtr->icon != NULL) {
- Tcl_SetResult(interp, Tk_PathName(wmPtr->icon), TCL_STATIC);
+ Tcl_SetObjResult(interp, TkNewWindowObj(wmPtr->icon));
}
return TCL_OK;
}
+
if (*Tcl_GetString(objv[3]) == '\0') {
wmPtr->hints.flags &= ~IconWindowHint;
if (wmPtr->icon != NULL) {
@@ -2323,19 +2348,24 @@ WmIconwindowCmd(
return TCL_ERROR;
}
if (!Tk_IsTopLevel(tkwin2)) {
- Tcl_AppendResult(interp, "can't use ", Tcl_GetString(objv[3]),
- " as icon window: not at top level", NULL);
+ Tcl_SetObjResult(interp, Tcl_ObjPrintf(
+ "can't use %s as icon window: not at top level",
+ Tk_PathName(tkwin2)));
+ Tcl_SetErrorCode(interp, "TK", "WM", "ICONWINDOW", "TOPLEVEL",
+ NULL);
return TCL_ERROR;
}
wmPtr2 = ((TkWindow *) tkwin2)->wmInfoPtr;
if (wmPtr2->iconFor != NULL) {
- Tcl_AppendResult(interp, Tcl_GetString(objv[3]),
- " is already an icon for ",
- Tk_PathName(wmPtr2->iconFor), NULL);
+ Tcl_SetObjResult(interp, Tcl_ObjPrintf(
+ "%s is already an icon for %s",
+ Tcl_GetString(objv[3]), Tk_PathName(wmPtr2->iconFor)));
+ Tcl_SetErrorCode(interp, "TK", "WM", "ICONWINDOW", "ICON", NULL);
return TCL_ERROR;
}
if (wmPtr->icon != NULL) {
WmInfo *wmPtr3 = ((TkWindow *) wmPtr->icon)->wmInfoPtr;
+
wmPtr3->iconFor = NULL;
}
Tk_MakeWindowExist(tkwin2);
@@ -2379,18 +2409,18 @@ WmManageCmd(
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
-
- register Tk_Window frameWin = (Tk_Window)winPtr;
+ register Tk_Window frameWin = (Tk_Window) winPtr;
register WmInfo *wmPtr = winPtr->wmInfoPtr;
- char *oldClass = (char*)Tk_Class(frameWin);
if (!Tk_IsTopLevel(frameWin)) {
MacDrawable *macWin = (MacDrawable *) winPtr->window;
if (!Tk_IsManageable(frameWin)) {
- Tcl_AppendResult(interp, "window \"",
- Tk_PathName(frameWin), "\" is not manageable: must be "
- "a frame, labelframe or toplevel", NULL);
+ Tcl_SetObjResult(interp, Tcl_ObjPrintf(
+ "window \"%s\" is not manageable: must be a"
+ " frame, labelframe or toplevel",
+ Tk_PathName(frameWin)));
+ Tcl_SetErrorCode(interp, "TK", "WM", "MANAGE", NULL);
return TCL_ERROR;
}
TkFocusSplit(winPtr);
@@ -2449,16 +2479,19 @@ WmMaxsizeCmd(
Tcl_WrongNumArgs(interp, 2, objv, "window ?width height?");
return TCL_ERROR;
}
+
if (objc == 3) {
- char buf[TCL_INTEGER_SPACE * 2];
+ Tcl_Obj *results[2];
GetMaxSize(winPtr, &width, &height);
- sprintf(buf, "%d %d", width, height);
- Tcl_SetResult(interp, buf, TCL_VOLATILE);
+ results[0] = Tcl_NewIntObj(width);
+ results[1] = Tcl_NewIntObj(height);
+ Tcl_SetObjResult(interp, Tcl_NewListObj(2, results));
return TCL_OK;
}
+
if ((Tcl_GetIntFromObj(interp, objv[3], &width) != TCL_OK)
- || (Tcl_GetIntFromObj(interp, objv[4], &height) != TCL_OK)) {
+ || (Tcl_GetIntFromObj(interp, objv[4], &height) != TCL_OK)) {
return TCL_ERROR;
}
wmPtr->maxWidth = width;
@@ -2500,14 +2533,17 @@ WmMinsizeCmd(
Tcl_WrongNumArgs(interp, 2, objv, "window ?width height?");
return TCL_ERROR;
}
+
if (objc == 3) {
- char buf[TCL_INTEGER_SPACE * 2];
+ Tcl_Obj *results[2];
GetMinSize(winPtr, &width, &height);
- sprintf(buf, "%d %d", width, height);
- Tcl_SetResult(interp, buf, TCL_VOLATILE);
+ results[0] = Tcl_NewIntObj(width);
+ results[1] = Tcl_NewIntObj(height);
+ Tcl_SetObjResult(interp, Tcl_NewListObj(2, results));
return TCL_OK;
}
+
if ((Tcl_GetIntFromObj(interp, objv[3], &width) != TCL_OK)
|| (Tcl_GetIntFromObj(interp, objv[4], &height) != TCL_OK)) {
return TCL_ERROR;
@@ -2551,11 +2587,13 @@ WmOverrideredirectCmd(
Tcl_WrongNumArgs(interp, 2, objv, "window ?boolean?");
return TCL_ERROR;
}
+
if (objc == 3) {
Tcl_SetObjResult(interp, Tcl_NewBooleanObj(
Tk_Attributes((Tk_Window) winPtr)->override_redirect));
return TCL_OK;
}
+
if (Tcl_GetBooleanFromObj(interp, objv[3], &boolean) != TCL_OK) {
return TCL_ERROR;
}
@@ -2601,14 +2639,16 @@ WmPositionfromCmd(
Tcl_WrongNumArgs(interp, 2, objv, "window ?user/program?");
return TCL_ERROR;
}
+
if (objc == 3) {
if (wmPtr->sizeHintsFlags & USPosition) {
- Tcl_SetResult(interp, "user", TCL_STATIC);
+ Tcl_SetObjResult(interp, Tcl_NewStringObj("user", -1));
} else if (wmPtr->sizeHintsFlags & PPosition) {
- Tcl_SetResult(interp, "program", TCL_STATIC);
+ Tcl_SetObjResult(interp, Tcl_NewStringObj("program", -1));
}
return TCL_OK;
}
+
if (*Tcl_GetString(objv[3]) == '\0') {
wmPtr->sizeHintsFlags &= ~(USPosition|PPosition);
} else {
@@ -2659,23 +2699,28 @@ WmProtocolCmd(
Atom protocol;
char *cmd;
int cmdLength;
+ Tcl_Obj *resultObj;
if ((objc < 3) || (objc > 5)) {
Tcl_WrongNumArgs(interp, 2, objv, "window ?name? ?command?");
return TCL_ERROR;
}
+
if (objc == 3) {
/*
* Return a list of all defined protocols for the window.
*/
+ resultObj = Tcl_NewObj();
for (protPtr = wmPtr->protPtr; protPtr != NULL;
protPtr = protPtr->nextPtr) {
- Tcl_AppendElement(interp,
- Tk_GetAtomName((Tk_Window) winPtr, protPtr->protocol));
+ Tcl_ListObjAppendElement(NULL, resultObj, Tcl_NewStringObj(
+ Tk_GetAtomName((Tk_Window)winPtr, protPtr->protocol),-1));
}
+ Tcl_SetObjResult(interp, resultObj);
return TCL_OK;
}
+
protocol = Tk_InternAtom((Tk_Window) winPtr, Tcl_GetString(objv[3]));
if (objc == 4) {
/*
@@ -2685,7 +2730,8 @@ WmProtocolCmd(
for (protPtr = wmPtr->protPtr; protPtr != NULL;
protPtr = protPtr->nextPtr) {
if (protPtr->protocol == protocol) {
- Tcl_SetResult(interp, protPtr->command, TCL_STATIC);
+ Tcl_SetObjResult(interp,
+ Tcl_NewStringObj(protPtr->command, -1));
return TCL_OK;
}
}
@@ -2755,17 +2801,18 @@ WmResizableCmd(
Tcl_WrongNumArgs(interp, 2, objv, "window ?width height?");
return TCL_ERROR;
}
+
if (objc == 3) {
- char buf[TCL_INTEGER_SPACE * 2];
+ Tcl_Obj *results[2];
- sprintf(buf, "%d %d",
- (wmPtr->flags & WM_WIDTH_NOT_RESIZABLE) ? 0 : 1,
- (wmPtr->flags & WM_HEIGHT_NOT_RESIZABLE) ? 0 : 1);
- Tcl_SetResult(interp, buf, TCL_VOLATILE);
+ results[0] = Tcl_NewBooleanObj(!(wmPtr->flags & WM_WIDTH_NOT_RESIZABLE));
+ results[1] = Tcl_NewBooleanObj(!(wmPtr->flags & WM_HEIGHT_NOT_RESIZABLE));
+ Tcl_SetObjResult(interp, Tcl_NewListObj(2, results));
return TCL_OK;
}
+
if ((Tcl_GetBooleanFromObj(interp, objv[3], &width) != TCL_OK)
- || (Tcl_GetBooleanFromObj(interp, objv[4], &height) != TCL_OK)) {
+ || (Tcl_GetBooleanFromObj(interp, objv[4], &height) != TCL_OK)) {
return TCL_ERROR;
}
if (width) {
@@ -2833,11 +2880,12 @@ WmSizefromCmd(
Tcl_WrongNumArgs(interp, 2, objv, "window ?user|program?");
return TCL_ERROR;
}
+
if (objc == 3) {
if (wmPtr->sizeHintsFlags & USSize) {
- Tcl_SetResult(interp, "user", TCL_STATIC);
+ Tcl_SetObjResult(interp, Tcl_NewStringObj("user", -1));
} else if (wmPtr->sizeHintsFlags & PSize) {
- Tcl_SetResult(interp, "program", TCL_STATIC);
+ Tcl_SetObjResult(interp, Tcl_NewStringObj("program", -1));
}
return TCL_OK;
}
@@ -2887,11 +2935,14 @@ WmStackorderCmd(
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
- TkWindow **windows, **window_ptr;
+ TkWindow **windows, **windowPtr;
static const char *const optionStrings[] = {
- "isabove", "isbelow", NULL };
+ "isabove", "isbelow", NULL
+ };
enum options {
- OPT_ISABOVE, OPT_ISBELOW };
+ OPT_ISABOVE, OPT_ISBELOW
+ };
+ Tcl_Obj *resultObj;
int index;
if ((objc != 3) && (objc != 5)) {
@@ -2905,35 +2956,40 @@ WmStackorderCmd(
Tcl_Panic("TkWmStackorderToplevel failed");
}
- for (window_ptr = windows; *window_ptr ; window_ptr++) {
- Tcl_AppendElement(interp, (*window_ptr)->pathName);
+ resultObj = Tcl_NewObj();
+ for (windowPtr = windows; *windowPtr ; windowPtr++) {
+ Tcl_ListObjAppendElement(NULL, resultObj,
+ TkNewWindowObj((Tk_Window) *windowPtr));
}
+ Tcl_SetObjResult(interp, resultObj);
ckfree(windows);
return TCL_OK;
} else {
TkWindow *winPtr2;
- int index1=-1, index2=-1, result;
+ int index1 = -1, index2 = -1, result;
if (TkGetWindowFromObj(interp, tkwin, objv[4], (Tk_Window *) &winPtr2)
- != TCL_OK) {
+ != TCL_OK) {
return TCL_ERROR;
}
if (!Tk_IsTopLevel(winPtr2)) {
- Tcl_AppendResult(interp, "window \"", winPtr2->pathName,
- "\" isn't a top-level window", NULL);
+ Tcl_SetObjResult(interp, Tcl_ObjPrintf(
+ "window \"%s\" isn't a top-level window",
+ winPtr2->pathName));
+ Tcl_SetErrorCode(interp, "TK", "WM", "STACK", "TOPLEVEL", NULL);
return TCL_ERROR;
}
if (!Tk_IsMapped(winPtr)) {
- Tcl_AppendResult(interp, "window \"", winPtr->pathName,
- "\" isn't mapped", NULL);
+ Tcl_SetObjResult(interp, Tcl_ObjPrintf(
+ "window \"%s\" isn't mapped", winPtr->pathName));
+ Tcl_SetErrorCode(interp, "TK", "WM", "STACK", "MAPPED", NULL);
return TCL_ERROR;
- }
-
- if (!Tk_IsMapped(winPtr2)) {
- Tcl_AppendResult(interp, "window \"", winPtr2->pathName,
- "\" isn't mapped", NULL);
+ } else if (!Tk_IsMapped(winPtr2)) {
+ Tcl_SetObjResult(interp, Tcl_ObjPrintf(
+ "window \"%s\" isn't mapped", winPtr2->pathName));
+ Tcl_SetErrorCode(interp, "TK", "WM", "STACK", "MAPPED", NULL);
return TCL_ERROR;
}
@@ -2944,22 +3000,23 @@ WmStackorderCmd(
windows = TkWmStackorderToplevel(winPtr->mainPtr->winPtr);
if (windows == NULL) {
- Tcl_AppendResult(interp, "TkWmStackorderToplevel failed", NULL);
+ Tcl_SetObjResult(interp, Tcl_NewStringObj(
+ "TkWmStackorderToplevel failed", -1));
+ Tcl_SetErrorCode(interp, "TK", "WM", "STACK", "FAIL", NULL);
return TCL_ERROR;
}
- for (window_ptr = windows; *window_ptr ; window_ptr++) {
- if (*window_ptr == winPtr) {
- index1 = (window_ptr - windows);
+ for (windowPtr = windows; *windowPtr ; windowPtr++) {
+ if (*windowPtr == winPtr) {
+ index1 = windowPtr - windows;
}
- if (*window_ptr == winPtr2) {
- index2 = (window_ptr - windows);
+ if (*windowPtr == winPtr2) {
+ index2 = windowPtr - windows;
}
}
if (index1 == -1) {
Tcl_Panic("winPtr window not found");
- }
- if (index2 == -1) {
+ } else if (index2 == -1) {
Tcl_Panic("winPtr2 window not found");
}
@@ -2977,7 +3034,6 @@ WmStackorderCmd(
Tcl_SetObjResult(interp, Tcl_NewBooleanObj(result));
return TCL_OK;
}
- return TCL_OK;
}
/*
@@ -3016,21 +3072,25 @@ WmStateCmd(
Tcl_WrongNumArgs(interp, 2, objv, "window ?state?");
return TCL_ERROR;
}
+
if (objc == 4) {
if (wmPtr->iconFor != NULL) {
- Tcl_AppendResult(interp, "can't change state of ",
- Tcl_GetString(objv[2]), ": it is an icon for ",
- Tk_PathName(wmPtr->iconFor), NULL);
+ Tcl_SetObjResult(interp, Tcl_ObjPrintf(
+ "can't change state of %s: it is an icon for %s",
+ Tcl_GetString(objv[2]), Tk_PathName(wmPtr->iconFor)));
+ Tcl_SetErrorCode(interp, "TK", "WM", "STATE", "ICON", NULL);
return TCL_ERROR;
}
if (winPtr->flags & TK_EMBEDDED) {
- Tcl_AppendResult(interp, "can't change state of ",
- winPtr->pathName, ": it is an embedded window", NULL);
+ Tcl_SetObjResult(interp, Tcl_ObjPrintf(
+ "can't change state of %s: it is an embedded window",
+ winPtr->pathName));
+ Tcl_SetErrorCode(interp, "TK", "WM", "STATE", "EMBEDDED", NULL);
return TCL_ERROR;
}
if (Tcl_GetIndexFromObj(interp, objv[3], optionStrings, "argument", 0,
- &index) != TCL_OK) {
+ &index) != TCL_OK) {
return TCL_ERROR;
}
@@ -3043,13 +3103,19 @@ WmStateCmd(
*/
} else if (index == OPT_ICONIC) {
if (Tk_Attributes((Tk_Window) winPtr)->override_redirect) {
- Tcl_AppendResult(interp, "can't iconify \"", winPtr->pathName,
- "\": override-redirect flag is set", NULL);
+ Tcl_SetObjResult(interp, Tcl_ObjPrintf(
+ "can't iconify \"%s\": override-redirect flag is set",
+ winPtr->pathName));
+ Tcl_SetErrorCode(interp, "TK", "WM", "STATE",
+ "OVERRIDE_REDIRECT", NULL);
return TCL_ERROR;
}
if (wmPtr->master != None) {
- Tcl_AppendResult(interp, "can't iconify \"", winPtr->pathName,
- "\": it is a transient", NULL);
+ Tcl_SetObjResult(interp, Tcl_ObjPrintf(
+ "can't iconify \"%s\": it is a transient",
+ winPtr->pathName));
+ Tcl_SetErrorCode(interp, "TK", "WM", "STATE", "TRANSIENT",
+ NULL);
return TCL_ERROR;
}
TkpWmSetState(winPtr, IconicState);
@@ -3059,7 +3125,7 @@ WmStateCmd(
TkpWmSetState(winPtr, ZoomState);
}
} else if (wmPtr->iconFor != NULL) {
- Tcl_SetResult(interp, "icon", TCL_STATIC);
+ Tcl_SetObjResult(interp, Tcl_NewStringObj("icon", -1));
} else {
if (wmPtr->hints.initial_state == NormalState ||
wmPtr->hints.initial_state == ZoomState) {
@@ -3068,16 +3134,16 @@ WmStateCmd(
}
switch (wmPtr->hints.initial_state) {
case NormalState:
- Tcl_SetResult(interp, "normal", TCL_STATIC);
+ Tcl_SetObjResult(interp, Tcl_NewStringObj("normal", -1));
break;
case IconicState:
- Tcl_SetResult(interp, "iconic", TCL_STATIC);
+ Tcl_SetObjResult(interp, Tcl_NewStringObj("iconic", -1));
break;
case WithdrawnState:
- Tcl_SetResult(interp, "withdrawn", TCL_STATIC);
+ Tcl_SetObjResult(interp, Tcl_NewStringObj("withdrawn", -1));
break;
case ZoomState:
- Tcl_SetResult(interp, "zoomed", TCL_STATIC);
+ Tcl_SetObjResult(interp, Tcl_NewStringObj("zoomed", -1));
break;
}
}
@@ -3117,11 +3183,13 @@ WmTitleCmd(
Tcl_WrongNumArgs(interp, 2, objv, "window ?newTitle?");
return TCL_ERROR;
}
+
if (objc == 3) {
- Tcl_SetResult(interp, (char *)((wmPtr->titleUid != NULL) ?
- wmPtr->titleUid : winPtr->nameUid), TCL_STATIC);
+ Tcl_SetObjResult(interp, Tcl_NewStringObj(
+ wmPtr->titleUid ? wmPtr->titleUid : winPtr->nameUid, -1));
return TCL_OK;
}
+
argv3 = Tcl_GetStringFromObj(objv[3], &length);
wmPtr->titleUid = Tk_GetUid(argv3);
if (!(wmPtr->flags & WM_NEVER_MAPPED) && !Tk_IsEmbedded(winPtr)) {
@@ -3167,7 +3235,8 @@ WmTransientCmd(
}
if (objc == 3) {
if (wmPtr->master != None) {
- Tcl_SetResult(interp, wmPtr->masterWindowName, TCL_STATIC);
+ Tcl_SetObjResult(interp,
+ Tcl_NewStringObj(wmPtr->masterWindowName, -1));
}
return TCL_OK;
}
@@ -3184,9 +3253,10 @@ WmTransientCmd(
Tk_MakeWindowExist(master);
if (wmPtr->iconFor != NULL) {
- Tcl_AppendResult(interp, "can't make \"", Tcl_GetString(objv[2]),
- "\" a transient: it is an icon for ",
- Tk_PathName(wmPtr->iconFor), NULL);
+ Tcl_SetObjResult(interp, Tcl_ObjPrintf(
+ "can't make \"%s\" a transient: it is an icon for %s",
+ Tcl_GetString(objv[2]), Tk_PathName(wmPtr->iconFor)));
+ Tcl_SetErrorCode(interp, "TK", "WM", "TRANSIENT", "ICON", NULL);
return TCL_ERROR;
}
@@ -3194,15 +3264,17 @@ WmTransientCmd(
/* Under some circumstances, wmPtr2 is NULL here */
if (wmPtr2 != NULL && wmPtr2->iconFor != NULL) {
- Tcl_AppendResult(interp, "can't make \"", Tcl_GetString(objv[3]),
- "\" a master: it is an icon for ",
- Tk_PathName(wmPtr2->iconFor), NULL);
+ Tcl_SetObjResult(interp, Tcl_ObjPrintf(
+ "can't make \"%s\" a master: it is an icon for %s",
+ Tcl_GetString(objv[3]), Tk_PathName(wmPtr2->iconFor)));
+ Tcl_SetErrorCode(interp, "TK", "WM", "TRANSIENT", "ICON", NULL);
return TCL_ERROR;
}
if ((TkWindow *) master == winPtr) {
- Tcl_AppendResult(interp, "can't make \"", Tk_PathName(winPtr),
- "\" its own master", NULL);
+ Tcl_SetObjResult(interp, Tcl_ObjPrintf(
+ "can't make \"%s\" its own master", Tk_PathName(winPtr)));
+ Tcl_SetErrorCode(interp, "TK", "WM", "TRANSIENT", "SELF", NULL);
return TCL_ERROR;
}
@@ -3249,9 +3321,12 @@ WmWithdrawCmd(
Tcl_WrongNumArgs(interp, 2, objv, "window");
return TCL_ERROR;
}
+
if (wmPtr->iconFor != NULL) {
- Tcl_AppendResult(interp, "can't withdraw ", Tcl_GetString(objv[2]),
- ": it is an icon for ", Tk_PathName(wmPtr->iconFor), NULL);
+ Tcl_SetObjResult(interp, Tcl_ObjPrintf(
+ "can't withdraw %s: it is an icon for %s",
+ Tcl_GetString(objv[2]), Tk_PathName(wmPtr->iconFor)));
+ Tcl_SetErrorCode(interp, "TK", "WM", "WITHDRAW", "ICON", NULL);
return TCL_ERROR;
}
TkpWmSetState(winPtr, WithdrawnState);
@@ -3667,7 +3742,7 @@ UpdateGeometryInfo(
if (((width != winPtr->changes.width)
|| (height != winPtr->changes.height))
&& (wmPtr->gridWin == NULL)
- && ((wmPtr->sizeHintsFlags & (PMinSize|PMaxSize)) == 0)) {
+ && !(wmPtr->sizeHintsFlags & (PMinSize|PMaxSize))) {
wmPtr->flags |= WM_UPDATE_SIZE_HINTS;
}
if (wmPtr->flags & WM_UPDATE_SIZE_HINTS) {
@@ -3871,7 +3946,7 @@ ParseGeometry(
* them.
*/
- if ((wmPtr->sizeHintsFlags & (USPosition|PPosition)) == 0) {
+ if (!(wmPtr->sizeHintsFlags & (USPosition|PPosition))) {
wmPtr->sizeHintsFlags |= USPosition;
flags |= WM_UPDATE_SIZE_HINTS;
}
@@ -3906,7 +3981,9 @@ ParseGeometry(
return TCL_OK;
error:
- Tcl_AppendResult(interp, "bad geometry specifier \"", string, "\"", NULL);
+ Tcl_SetObjResult(interp, Tcl_ObjPrintf(
+ "bad geometry specifier \"%s\"", string));
+ Tcl_SetErrorCode(interp, "TK", "VALUE", "GEOMETRY", NULL);
return TCL_ERROR;
}
@@ -4243,7 +4320,7 @@ UpdateVRootGeometry(
wmPtr->flags &= ~WM_VROOT_OFFSET_STALE;
if (wmPtr->vRoot == None) {
- noVRoot:
+ noVRoot:
wmPtr->vRootX = wmPtr->vRootY = 0;
wmPtr->vRootWidth = DisplayWidth(winPtr->display, winPtr->screenNum);
wmPtr->vRootHeight = DisplayHeight(winPtr->display, winPtr->screenNum);
@@ -4366,7 +4443,7 @@ Tk_MoveToplevelWindow(
wmPtr->y = y;
wmPtr->flags |= WM_MOVE_PENDING;
wmPtr->flags &= ~(WM_NEGATIVE_X|WM_NEGATIVE_Y);
- if ((wmPtr->sizeHintsFlags & (USPosition|PPosition)) == 0) {
+ if (!(wmPtr->sizeHintsFlags & (USPosition|PPosition))) {
wmPtr->sizeHintsFlags |= USPosition;
wmPtr->flags |= WM_UPDATE_SIZE_HINTS;
}
@@ -4974,78 +5051,64 @@ TkUnsupported1ObjCmd(
};
Tk_Window tkwin = clientData;
TkWindow *winPtr;
- int index;
+ int index, i;
if (objc < 3) {
Tcl_WrongNumArgs(interp, 1, objv, "option window ?arg ...?");
return TCL_ERROR;
}
+ /*
+ * Iterate through objc/objv to set correct background color and toggle
+ * opacity of window.
+ */
- /* Iterate through objc/objv to set correct background color and toggle opacity of window. */
- int i;
for (i= 0; i < objc; i++) {
-
- if (Tcl_StringMatch(Tcl_GetString(objv[i]), "*black*") == 1) {
- colorName = [NSColor blackColor]; // use #000000 in Tk scripts to match
- }
- if (Tcl_StringMatch(Tcl_GetString(objv[i]), "*dark*") == 1) {
+ if (Tcl_StringMatch(Tcl_GetString(objv[i]), "*black*")) {
+ colorName = [NSColor blackColor]; // use #000000 in Tk scripts to match
+ } else if (Tcl_StringMatch(Tcl_GetString(objv[i]), "*dark*")) {
colorName = [NSColor darkGrayColor]; //use #545454 in Tk scripts to match
- }
- if (Tcl_StringMatch(Tcl_GetString(objv[i]), "*light*") == 1) {
+ } else if (Tcl_StringMatch(Tcl_GetString(objv[i]), "*light*")) {
colorName = [NSColor lightGrayColor]; //use #ababab in Tk scripts to match
+ } else if (Tcl_StringMatch(Tcl_GetString(objv[i]), "*white*")) {
+ colorName = [NSColor whiteColor]; //use #ffffff in Tk scripts to match
+ } else if (Tcl_StringMatch(Tcl_GetString(objv[i]), "gray*")) {
+ colorName = [NSColor grayColor]; //use #7f7f7f in Tk scripts to match
+ } else if (Tcl_StringMatch(Tcl_GetString(objv[i]), "*red*")) {
+ colorName = [NSColor redColor]; //use #ff0000 in Tk scripts to match
+ } else if (Tcl_StringMatch(Tcl_GetString(objv[i]), "*green*")) {
+ colorName = [NSColor greenColor]; //use #00ff00 in Tk scripts to match
+ } else if (Tcl_StringMatch(Tcl_GetString(objv[i]), "*blue*")) {
+ colorName = [NSColor blueColor]; //use #0000ff in Tk scripts to match
+ } else if (Tcl_StringMatch(Tcl_GetString(objv[i]), "*cyan*")) {
+ colorName = [NSColor cyanColor]; //use #00ffff in Tk scripts to match
+ } else if (Tcl_StringMatch(Tcl_GetString(objv[i]), "*yellow*")) {
+ colorName = [NSColor yellowColor]; //use #ffff00 in Tk scripts to match
+ } else if (Tcl_StringMatch(Tcl_GetString(objv[i]), "*magenta*")) {
+ colorName = [NSColor magentaColor]; //use #ff00ff in Tk scripts to match
+ } else if (Tcl_StringMatch(Tcl_GetString(objv[i]), "*orange*")) {
+ colorName = [NSColor orangeColor]; //use #ff8000 in Tk scripts to match
+ } else if (Tcl_StringMatch(Tcl_GetString(objv[i]), "*purple*")) {
+ colorName = [NSColor purpleColor]; //use #800080 in Tk scripts to match
+ } else if (Tcl_StringMatch(Tcl_GetString(objv[i]), "*brown*")){
+ colorName = [NSColor brownColor]; //use #996633 in Tk scripts to match
+ } else if (Tcl_StringMatch(Tcl_GetString(objv[i]), "*clear*")) {
+ colorName = [NSColor clearColor]; //use systemTransparent in Tk scripts to match
}
- if (Tcl_StringMatch(Tcl_GetString(objv[i]), "*white*") == 1) {
- colorName = [NSColor whiteColor]; //use #ffffff in Tk scripts to match
- }
- if (Tcl_StringMatch(Tcl_GetString(objv[i]), "gray*") == 1) {
- colorName = [NSColor grayColor]; //use #7f7f7f in Tk scripts to match
- }
- if (Tcl_StringMatch(Tcl_GetString(objv[i]), "*red*") == 1) {
- colorName = [NSColor redColor]; //use #ff0000 in Tk scripts to match
- }
- if (Tcl_StringMatch(Tcl_GetString(objv[i]), "*green*") == 1) {
- colorName = [NSColor greenColor]; //use #00ff00 in Tk scripts to match
- }
- if (Tcl_StringMatch(Tcl_GetString(objv[i]), "*blue*") == 1) {
- colorName = [NSColor blueColor]; //use #0000ff in Tk scripts to match
- }
- if (Tcl_StringMatch(Tcl_GetString(objv[i]), "*cyan*") == 1) {
- colorName = [NSColor cyanColor]; //use #00ffff in Tk scripts to match
- }
- if (Tcl_StringMatch(Tcl_GetString(objv[i]), "*yellow*") == 1) {
- colorName = [NSColor yellowColor]; //use #ffff00 in Tk scripts to match
- }
- if (Tcl_StringMatch(Tcl_GetString(objv[i]), "*magenta*") == 1) {
- colorName = [NSColor magentaColor]; //use #ff00ff in Tk scripts to match
- }
- if (Tcl_StringMatch(Tcl_GetString(objv[i]), "*orange*") == 1) {
- colorName = [NSColor orangeColor]; //use #ff8000 in Tk scripts to match
- }
- if (Tcl_StringMatch(Tcl_GetString(objv[i]), "*purple*") == 1) {
- colorName = [NSColor purpleColor]; //use #800080 in Tk scripts to match
- }
- if (Tcl_StringMatch(Tcl_GetString(objv[i]), "*brown*") == 1){
- colorName = [NSColor brownColor]; //use #996633 in Tk scripts to match
- }
- if (Tcl_StringMatch(Tcl_GetString(objv[i]), "*clear*") == 1) {
- colorName = [NSColor clearColor]; //use systemTransparent in Tk scripts to match
- }
- if (Tcl_StringMatch(Tcl_GetString(objv[i]), "*opacity*") == 1) {
- opaqueTag=@"YES";
+ if (Tcl_StringMatch(Tcl_GetString(objv[i]), "*opacity*")) {
+ opaqueTag = @"YES";
}
}
-
winPtr = (TkWindow *)
Tk_NameToWindow(interp, Tcl_GetString(objv[2]), tkwin);
if (winPtr == NULL) {
return TCL_ERROR;
}
if (!(winPtr->flags & TK_TOP_LEVEL)) {
- Tcl_ResetResult(interp);
- Tcl_AppendResult(interp, "window \"", winPtr->pathName,
- "\" isn't a top-level window", NULL);
+ Tcl_SetObjResult(interp, Tcl_ObjPrintf(
+ "window \"%s\" isn't a top-level window", winPtr->pathName));
+ Tcl_SetErrorCode(interp, "TK", "WINDOWSTYLE", "TOPLEVEL", NULL);
return TCL_ERROR;
}
@@ -5120,7 +5183,10 @@ WmWinStyle(
{ NULL }
};
- /* Map window attributes. Color and opacity are mapped to NULL; these are parsed from the objv in TkUnsupported1ObjCmd.*/
+ /*
+ * Map window attributes. Color and opacity are mapped to NULL; these are
+ * parsed from the objv in TkUnsupported1ObjCmd.
+ */
static const struct StrIntMap attrMap[] = {
{ "closeBox", kWindowCloseBoxAttribute },
@@ -5151,21 +5217,21 @@ WmWinStyle(
{ "moveToActiveSpace", tkMoveToActiveSpaceAttribute },
{ "nonActivating", tkNonactivatingPanelAttribute },
{ "hud", tkHUDWindowAttribute },
- { "black", NULL },
- { "dark", NULL },
- { "light", NULL },
- { "gray", NULL },
- { "red", NULL },
- { "green", NULL },
- { "blue", NULL },
- { "cyan", NULL },
- { "yellow", NULL },
- { "magenta", NULL },
- { "orange", NULL },
- { "purple", NULL },
- { "brown", NULL },
- { "clear", NULL },
- { "opacity", NULL },
+ { "black", 0 },
+ { "dark", 0 },
+ { "light", 0 },
+ { "gray", 0 },
+ { "red", 0 },
+ { "green", 0 },
+ { "blue", 0 },
+ { "cyan", 0 },
+ { "yellow", 0 },
+ { "magenta", 0 },
+ { "orange", 0 },
+ { "purple", 0 },
+ { "brown", 0 },
+ { "clear", 0 },
+ { "opacity", 0 },
{ NULL }
};
@@ -5186,7 +5252,6 @@ WmWinStyle(
Tcl_Panic("invalid class");
}
-
attributeList = Tcl_NewListObj(0, NULL);
attributes = wmPtr->attributes;
@@ -5194,7 +5259,7 @@ WmWinStyle(
UInt64 intValue = compositeAttrMap[i].intValue;
if (intValue && (attributes & intValue) == intValue) {
- Tcl_ListObjAppendElement(interp, attributeList,
+ Tcl_ListObjAppendElement(NULL, attributeList,
Tcl_NewStringObj(compositeAttrMap[i].strValue,
-1));
attributes &= ~intValue;
@@ -5203,11 +5268,11 @@ WmWinStyle(
}
for (i = 0; attrMap[i].strValue != NULL; i++) {
if (attributes & attrMap[i].intValue) {
- Tcl_ListObjAppendElement(interp, attributeList,
+ Tcl_ListObjAppendElement(NULL, attributeList,
Tcl_NewStringObj(attrMap[i].strValue, -1));
}
}
- Tcl_ListObjAppendElement(interp, newResult, attributeList);
+ Tcl_ListObjAppendElement(NULL, newResult, attributeList);
Tcl_SetObjResult(interp, newResult);
} else {
int attrObjc;
@@ -5259,7 +5324,6 @@ WmWinStyle(
return TCL_ERROR;
}
-
return TCL_OK;
}
@@ -5421,7 +5485,7 @@ TkMacOSXMakeRealWindowExist(
/* Set background color and opacity of window if those flags are set. */
if (colorName != NULL) {
[window setBackgroundColor: colorName];
- }
+ }
if (opaqueTag != NULL) {
[window setOpaque: opaqueTag];
@@ -5911,7 +5975,7 @@ TkWindow **
TkWmStackorderToplevel(
TkWindow *parentPtr) /* Parent toplevel window. */
{
- TkWindow *childWinPtr, **windows, **window_ptr;
+ TkWindow *childWinPtr, **windows, **windowPtr;
Tcl_HashTable table;
Tcl_HashEntry *hPtr;
Tcl_HashSearch search;
@@ -5948,8 +6012,8 @@ TkWmStackorderToplevel(
ckfree(windows);
windows = NULL;
} else {
- window_ptr = windows + table.numEntries;
- *window_ptr-- = NULL;
+ windowPtr = windows + table.numEntries;
+ *windowPtr-- = NULL;
windowNumbers = ckalloc(windowCount * sizeof(NSInteger));
NSWindowList(windowCount, windowNumbers);
for (NSInteger index = 0; index < windowCount; index++) {
@@ -5959,11 +6023,11 @@ TkWmStackorderToplevel(
hPtr = Tcl_FindHashEntry(&table, (char*) w);
if (hPtr != NULL) {
childWinPtr = Tcl_GetHashValue(hPtr);
- *window_ptr-- = childWinPtr;
+ *windowPtr-- = childWinPtr;
}
}
}
- if (window_ptr != (windows-1)) {
+ if (windowPtr != windows-1) {
Tcl_Panic("num matched toplevel windows does not equal num "
"children");
}
@@ -6281,10 +6345,11 @@ TkMacOSXMakeFullscreen(
if ((wmPtr->maxWidth > 0 && wmPtr->maxWidth < screenWidth)
|| (wmPtr->maxHeight > 0 && wmPtr->maxHeight < screenHeight)) {
if (interp) {
- Tcl_AppendResult(interp,
- "can't set fullscreen attribute for \"",
- winPtr->pathName,
- "\": max width/height is too small", NULL);
+ Tcl_SetObjResult(interp, Tcl_ObjPrintf(
+ "can't set fullscreen attribute for \"%s\": max"
+ " width/height is too small", winPtr->pathName));
+ Tcl_SetErrorCode(interp, "TK", "FULLSCREEN",
+ "CONSTRAINT_FAILURE", NULL);
}
result = TCL_ERROR;
wmPtr->flags &= ~WM_FULLSCREEN;
@@ -6535,8 +6600,6 @@ RemapWindows(
RemapWindows(childPtr, (MacDrawable *) winPtr->window);
}
}
-
-
/*
* Local Variables: