summaryrefslogtreecommitdiffstats
path: root/mac/tkMacWm.c
diff options
context:
space:
mode:
Diffstat (limited to 'mac/tkMacWm.c')
-rw-r--r--mac/tkMacWm.c222
1 files changed, 134 insertions, 88 deletions
diff --git a/mac/tkMacWm.c b/mac/tkMacWm.c
index 56c4b8a..4cd7920 100644
--- a/mac/tkMacWm.c
+++ b/mac/tkMacWm.c
@@ -11,7 +11,7 @@
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * SCCS: @(#) tkMacWm.c 1.72 97/10/29 13:27:30
+ * SCCS: @(#) tkMacWm.c 1.77 98/02/18 11:03:54
*/
#include <Gestalt.h>
@@ -19,6 +19,7 @@
#include <Windows.h>
#include <ToolUtils.h>
+#include <tclMac.h>
#include "tkPort.h"
#include "tkInt.h"
#include "tkMacInt.h"
@@ -26,14 +27,12 @@
#include "tkScrollbar.h"
/*
- * If HAVE_APPEARANCE is defined in MW_TkHeader.pch then we must have the
- * Appearance manager header & library. If so we can use these new API's to
- * have the iconify code do the right thing.
+ * We now require the Appearance headers. They come with CodeWarrior Pro,
+ * and are on the SDK CD. However, we do not require the Appearance
+ * extension
*/
-
-#ifdef HAVE_APPEARANCE
-# include <Appearance.h>
-#endif
+
+#include <Appearance.h>
/*
* A data structure of the following type holds information for
@@ -313,7 +312,6 @@ void MacMoveWindow(WindowRef window, int x, int y);
* Forward declarations for procedures defined in this file:
*/
-static int HaveAppearance _ANSI_ARGS_((void));
static void InitialWindowBounds _ANSI_ARGS_((TkWindow *winPtr,
Rect *geometry));
static int ParseGeometry _ANSI_ARGS_((Tcl_Interp *interp,
@@ -532,7 +530,7 @@ TkWmMapWindow(
*/
XMapWindow(winPtr->display, winPtr->window);
-
+
/*
* Now that the window is visable we can determine the offset
* from the window's content orgin to the window's decorative
@@ -711,7 +709,7 @@ Tk_WmCmd(
return TCL_ERROR;
}
if (argc == 2) {
- interp->result = (wmTracing) ? "on" : "off";
+ Tcl_SetResult(interp, ((wmTracing) ? "on" : "off"), TCL_STATIC);
return TCL_OK;
}
return Tcl_GetBoolean(interp, argv[2], &wmTracing);
@@ -741,9 +739,12 @@ Tk_WmCmd(
}
if (argc == 3) {
if (wmPtr->sizeHintsFlags & PAspect) {
- sprintf(interp->result, "%d %d %d %d", wmPtr->minAspect.x,
+ char buf[TCL_INTEGER_SPACE * 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);
}
return TCL_OK;
}
@@ -758,7 +759,8 @@ Tk_WmCmd(
}
if ((numer1 <= 0) || (denom1 <= 0) || (numer2 <= 0) ||
(denom2 <= 0)) {
- interp->result = "aspect number can't be <= 0";
+ Tcl_SetResult(interp, "aspect number can't be <= 0",
+ TCL_STATIC);
return TCL_ERROR;
}
wmPtr->minAspect.x = numer1;
@@ -779,7 +781,7 @@ Tk_WmCmd(
}
if (argc == 3) {
if (wmPtr->clientMachine != NULL) {
- interp->result = wmPtr->clientMachine;
+ Tcl_SetResult(interp, wmPtr->clientMachine, TCL_STATIC);
}
return TCL_OK;
}
@@ -877,8 +879,9 @@ Tk_WmCmd(
}
if (argc == 3) {
if (wmPtr->cmdArgv != NULL) {
- interp->result = Tcl_Merge(wmPtr->cmdArgc, wmPtr->cmdArgv);
- interp->freeProc = (Tcl_FreeProc *) free;
+ Tcl_SetResult(interp,
+ Tcl_Merge(wmPtr->cmdArgc, wmPtr->cmdArgv),
+ TCL_DYNAMIC);
}
return TCL_OK;
}
@@ -928,7 +931,8 @@ Tk_WmCmd(
return TCL_ERROR;
}
if (argc == 3) {
- interp->result = wmPtr->hints.input ? "passive" : "active";
+ Tcl_SetResult(interp, (wmPtr->hints.input ? "passive" : "active"),
+ TCL_STATIC);
return TCL_OK;
}
c = argv[3][0];
@@ -945,6 +949,7 @@ Tk_WmCmd(
} else if ((c == 'f') && (strncmp(argv[1], "frame", length) == 0)
&& (length >= 2)) {
Window window;
+ char buf[TCL_INTEGER_SPACE];
if (argc != 3) {
Tcl_AppendResult(interp, "wrong # arguments: must be \"",
@@ -955,7 +960,8 @@ Tk_WmCmd(
if (window == None) {
window = Tk_WindowId((Tk_Window) winPtr);
}
- sprintf(interp->result, "0x%x", (unsigned int) window);
+ sprintf(buf, "0x%x", (unsigned int) window);
+ Tcl_SetResult(interp, buf, TCL_VOLATILE);
} else if ((c == 'g') && (strncmp(argv[1], "geometry", length) == 0)
&& (length >= 2)) {
char xSign, ySign;
@@ -968,6 +974,8 @@ Tk_WmCmd(
return TCL_ERROR;
}
if (argc == 3) {
+ char buf[16 + TCL_INTEGER_SPACE * 4];
+
xSign = (wmPtr->flags & WM_NEGATIVE_X) ? '-' : '+';
ySign = (wmPtr->flags & WM_NEGATIVE_Y) ? '-' : '+';
if (wmPtr->gridWin != NULL) {
@@ -979,8 +987,9 @@ Tk_WmCmd(
width = winPtr->changes.width;
height = winPtr->changes.height;
}
- sprintf(interp->result, "%dx%d%c%d%c%d", width, height,
- xSign, wmPtr->x, ySign, wmPtr->y);
+ sprintf(buf, "%dx%d%c%d%c%d", width, height, xSign, wmPtr->x,
+ ySign, wmPtr->y);
+ Tcl_SetResult(interp, buf, TCL_VOLATILE);
return TCL_OK;
}
if (*argv[3] == '\0') {
@@ -1001,9 +1010,12 @@ Tk_WmCmd(
}
if (argc == 3) {
if (wmPtr->sizeHintsFlags & PBaseSize) {
- sprintf(interp->result, "%d %d %d %d", wmPtr->reqGridWidth,
+ char buf[TCL_INTEGER_SPACE * 4];
+
+ sprintf(buf, "%d %d %d %d", wmPtr->reqGridWidth,
wmPtr->reqGridHeight, wmPtr->widthInc,
wmPtr->heightInc);
+ Tcl_SetResult(interp, buf, TCL_VOLATILE);
}
return TCL_OK;
}
@@ -1030,19 +1042,19 @@ Tk_WmCmd(
return TCL_ERROR;
}
if (reqWidth < 0) {
- interp->result = "baseWidth can't be < 0";
+ Tcl_SetResult(interp, "baseWidth can't be < 0", TCL_STATIC);
return TCL_ERROR;
}
if (reqHeight < 0) {
- interp->result = "baseHeight can't be < 0";
+ Tcl_SetResult(interp, "baseHeight can't be < 0", TCL_STATIC);
return TCL_ERROR;
}
if (widthInc < 0) {
- interp->result = "widthInc can't be < 0";
+ Tcl_SetResult(interp, "widthInc can't be < 0", TCL_STATIC);
return TCL_ERROR;
}
if (heightInc < 0) {
- interp->result = "heightInc can't be < 0";
+ Tcl_SetResult(interp, "heightInc can't be < 0", TCL_STATIC);
return TCL_ERROR;
}
Tk_SetGrid((Tk_Window) winPtr, reqWidth, reqHeight, widthInc,
@@ -1062,7 +1074,7 @@ Tk_WmCmd(
}
if (argc == 3) {
if (wmPtr->hints.flags & WindowGroupHint) {
- interp->result = wmPtr->leaderName;
+ Tcl_SetResult(interp, wmPtr->leaderName, TCL_STATIC);
}
return TCL_OK;
}
@@ -1095,8 +1107,9 @@ Tk_WmCmd(
}
if (argc == 3) {
if (wmPtr->hints.flags & IconPixmapHint) {
- interp->result = Tk_NameOfBitmap(winPtr->display,
- wmPtr->hints.icon_pixmap);
+ Tcl_SetResult(interp,
+ Tk_NameOfBitmap(winPtr->display, wmPtr->hints.icon_pixmap),
+ TCL_STATIC);
}
return TCL_OK;
}
@@ -1155,8 +1168,9 @@ Tk_WmCmd(
}
if (argc == 3) {
if (wmPtr->hints.flags & IconMaskHint) {
- interp->result = Tk_NameOfBitmap(winPtr->display,
- wmPtr->hints.icon_mask);
+ Tcl_SetResult(interp,
+ Tk_NameOfBitmap(winPtr->display, wmPtr->hints.icon_mask),
+ TCL_STATIC);
}
return TCL_OK;
}
@@ -1181,7 +1195,9 @@ Tk_WmCmd(
return TCL_ERROR;
}
if (argc == 3) {
- interp->result = (wmPtr->iconName != NULL) ? wmPtr->iconName : "";
+ Tcl_SetResult(interp,
+ ((wmPtr->iconName != NULL) ? wmPtr->iconName : ""),
+ TCL_STATIC);
return TCL_OK;
} else {
wmPtr->iconName = Tk_GetUid(argv[3]);
@@ -1201,8 +1217,11 @@ Tk_WmCmd(
}
if (argc == 3) {
if (wmPtr->hints.flags & IconPositionHint) {
- sprintf(interp->result, "%d %d", wmPtr->hints.icon_x,
+ char buf[TCL_INTEGER_SPACE * 2];
+
+ sprintf(buf, "%d %d", wmPtr->hints.icon_x,
wmPtr->hints.icon_y);
+ Tcl_SetResult(interp, buf, TCL_VOLATILE);
}
return TCL_OK;
}
@@ -1230,7 +1249,7 @@ Tk_WmCmd(
}
if (argc == 3) {
if (wmPtr->icon != NULL) {
- interp->result = Tk_PathName(wmPtr->icon);
+ Tcl_SetResult(interp, Tk_PathName(wmPtr->icon), TCL_STATIC);
}
return TCL_OK;
}
@@ -1284,8 +1303,10 @@ Tk_WmCmd(
return TCL_ERROR;
}
if (argc == 3) {
- sprintf(interp->result, "%d %d", wmPtr->maxWidth,
- wmPtr->maxHeight);
+ char buf[TCL_INTEGER_SPACE * 2];
+
+ sprintf(buf, "%d %d", wmPtr->maxWidth, wmPtr->maxHeight);
+ Tcl_SetResult(interp, buf, TCL_VOLATILE);
return TCL_OK;
}
if ((Tcl_GetInt(interp, argv[3], &width) != TCL_OK)
@@ -1305,8 +1326,10 @@ Tk_WmCmd(
return TCL_ERROR;
}
if (argc == 3) {
- sprintf(interp->result, "%d %d", wmPtr->minWidth,
- wmPtr->minHeight);
+ char buf[TCL_INTEGER_SPACE * 2];
+
+ sprintf(buf, "%d %d", wmPtr->minWidth, wmPtr->minHeight);
+ Tcl_SetResult(interp, buf, TCL_VOLATILE);
return TCL_OK;
}
if ((Tcl_GetInt(interp, argv[3], &width) != TCL_OK)
@@ -1330,9 +1353,9 @@ Tk_WmCmd(
}
if (argc == 3) {
if (Tk_Attributes((Tk_Window) winPtr)->override_redirect) {
- interp->result = "1";
+ Tcl_SetResult(interp, "1", TCL_STATIC);
} else {
- interp->result = "0";
+ Tcl_SetResult(interp, "0", TCL_STATIC);
}
return TCL_OK;
}
@@ -1353,9 +1376,9 @@ Tk_WmCmd(
}
if (argc == 3) {
if (wmPtr->sizeHintsFlags & USPosition) {
- interp->result = "user";
+ Tcl_SetResult(interp, "user", TCL_STATIC);
} else if (wmPtr->sizeHintsFlags & PPosition) {
- interp->result = "program";
+ Tcl_SetResult(interp, "program", TCL_STATIC);
}
return TCL_OK;
}
@@ -1410,7 +1433,7 @@ Tk_WmCmd(
for (protPtr = wmPtr->protPtr; protPtr != NULL;
protPtr = protPtr->nextPtr) {
if (protPtr->protocol == protocol) {
- interp->result = protPtr->command;
+ Tcl_SetResult(interp, protPtr->command, TCL_STATIC);
return TCL_OK;
}
}
@@ -1454,9 +1477,12 @@ Tk_WmCmd(
return TCL_ERROR;
}
if (argc == 3) {
- sprintf(interp->result, "%d %d",
+ char buf[TCL_INTEGER_SPACE * 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);
return TCL_OK;
}
if ((Tcl_GetBoolean(interp, argv[3], &width) != TCL_OK)
@@ -1489,9 +1515,9 @@ Tk_WmCmd(
}
if (argc == 3) {
if (wmPtr->sizeHintsFlags & USSize) {
- interp->result = "user";
+ Tcl_SetResult(interp, "user", TCL_STATIC);
} else if (wmPtr->sizeHintsFlags & PSize) {
- interp->result = "program";
+ Tcl_SetResult(interp, "program", TCL_STATIC);
}
return TCL_OK;
}
@@ -1523,20 +1549,20 @@ Tk_WmCmd(
return TCL_ERROR;
}
if (wmPtr->iconFor != NULL) {
- interp->result = "icon";
+ Tcl_SetResult(interp, "icon", TCL_STATIC);
} else {
switch (wmPtr->hints.initial_state) {
case NormalState:
- interp->result = "normal";
+ Tcl_SetResult(interp, "normal", TCL_STATIC);
break;
case IconicState:
- interp->result = "iconic";
+ Tcl_SetResult(interp, "iconic", TCL_STATIC);
break;
case WithdrawnState:
- interp->result = "withdrawn";
+ Tcl_SetResult(interp, "withdrawn", TCL_STATIC);
break;
case ZoomState:
- interp->result = "zoomed";
+ Tcl_SetResult(interp, "zoomed", TCL_STATIC);
break;
}
}
@@ -1548,8 +1574,9 @@ Tk_WmCmd(
return TCL_ERROR;
}
if (argc == 3) {
- interp->result = (wmPtr->titleUid != NULL) ? wmPtr->titleUid
- : winPtr->nameUid;
+ Tcl_SetResult(interp,
+ ((wmPtr->titleUid != NULL) ? wmPtr->titleUid : winPtr->nameUid),
+ TCL_STATIC);
return TCL_OK;
} else {
wmPtr->titleUid = Tk_GetUid(argv[3]);
@@ -1568,7 +1595,7 @@ Tk_WmCmd(
}
if (argc == 3) {
if (wmPtr->master != None) {
- interp->result = wmPtr->masterWindowName;
+ Tcl_SetResult(interp, wmPtr->masterWindowName, TCL_STATIC);
}
return TCL_OK;
}
@@ -2148,7 +2175,7 @@ UpdateSizeHints(
*
* Results:
* A standard Tcl return value, plus an error message in
- * interp->result if an error occurs.
+ * the interp's result if an error occurs.
*
* Side effects:
* The size and/or location of winPtr may change.
@@ -2333,12 +2360,26 @@ Tk_GetRootCoords(
y += winPtr->changes.y + winPtr->changes.border_width;
} else {
+ Point theOffset;
- /*
- * NOTE: Here we should handle
- * out of process embedding.
- */
-
+ if (gMacEmbedHandler->getOffsetProc != NULL) {
+ /*
+ * We do not require that the changes.x & changes.y for
+ * a non-Tk master window be kept up to date. So we
+ * first subtract off the possibly bogus values that have
+ * been added on at the top of this pass through the loop,
+ * and then call out to the getOffsetProc to give us
+ * the correct offset.
+ */
+
+ x -= winPtr->changes.x + winPtr->changes.border_width;
+ y -= winPtr->changes.y + winPtr->changes.border_width;
+
+ gMacEmbedHandler->getOffsetProc((Tk_Window) winPtr, &theOffset);
+
+ x += theOffset.h;
+ y += theOffset.v;
+ }
break;
}
}
@@ -3318,15 +3359,19 @@ TkSetWMName(
{
Str255 pTitle;
GWorldPtr macWin;
+ int destWrote;
if (Tk_IsEmbedded(winPtr)) {
return;
}
+ Tcl_UtfToExternal(NULL, NULL, titleUid,
+ strlen(titleUid), 0, NULL,
+ (char *) &pTitle[1],
+ 255, NULL, &destWrote, NULL); /* Internalize native */
+ pTitle[0] = destWrote;
- macWin = TkMacGetDrawablePort(winPtr->window);
-
- strcpy((char *) pTitle + 1, titleUid);
- pTitle[0] = strlen(titleUid);
+ macWin = TkMacGetDrawablePort(winPtr->window);
+
SetWTitle((WindowPtr) macWin, pTitle);
}
@@ -3685,42 +3730,42 @@ TkUnsupported1Cmd(
switch (wmPtr->style) {
case noGrowDocProc:
case documentProc:
- interp->result = "documentProc";
+ Tcl_SetResult(interp, "documentProc", TCL_STATIC);
break;
case dBoxProc:
- interp->result = "dBoxProc";
+ Tcl_SetResult(interp, "dBoxProc", TCL_STATIC);
break;
case plainDBox:
- interp->result = "plainDBox";
+ Tcl_SetResult(interp, "plainDBox", TCL_STATIC);
break;
case altDBoxProc:
- interp->result = "altDBoxProc";
+ Tcl_SetResult(interp, "altDBoxProc", TCL_STATIC);
break;
case movableDBoxProc:
- interp->result = "movableDBoxProc";
+ Tcl_SetResult(interp, "movableDBoxProc", TCL_STATIC);
break;
case zoomDocProc:
case zoomNoGrow:
- interp->result = "zoomDocProc";
+ Tcl_SetResult(interp, "zoomDocProc", TCL_STATIC);
break;
case rDocProc:
- interp->result = "rDocProc";
+ Tcl_SetResult(interp, "rDocProc", TCL_STATIC);
break;
case floatProc:
case floatGrowProc:
- interp->result = "floatProc";
+ Tcl_SetResult(interp, "floatProc", TCL_STATIC);
break;
case floatZoomProc:
case floatZoomGrowProc:
- interp->result = "floatZoomProc";
+ Tcl_SetResult(interp, "floatZoomProc", TCL_STATIC);
break;
case floatSideProc:
case floatSideGrowProc:
- interp->result = "floatSideProc";
+ Tcl_SetResult(interp, "floatSideProc", TCL_STATIC);
break;
case floatSideZoomProc:
case floatSideZoomGrowProc:
- interp->result = "floatSideZoomProc";
+ Tcl_SetResult(interp, "floatSideZoomProc", TCL_STATIC);
break;
default:
panic("invalid style");
@@ -3861,6 +3906,13 @@ TkMacMakeRealWindowExist(
TkMacMakeRealWindowExist(contWinPtr->privatePtr->toplevel->winPtr);
macWin->flags |= TK_HOST_EXISTS;
return;
+ } else if (gMacEmbedHandler != NULL) {
+ if (gMacEmbedHandler->containerExistProc != NULL) {
+ if (gMacEmbedHandler->containerExistProc((Tk_Window) winPtr) != TCL_OK) {
+ panic("ContainerExistProc could not make container");
+ }
+ }
+ return;
} else {
panic("TkMacMakeRealWindowExist could not find container");
}
@@ -4148,8 +4200,7 @@ TkpWmSetState(winPtr, state)
Tk_UnmapWindow((Tk_Window) winPtr);
} else if (state == IconicState) {
Tk_UnmapWindow((Tk_Window) winPtr);
-#ifdef HAVE_APPEARANCE
- if (HaveAppearance()) {
+ if (TkMacHaveAppearance()) {
/*
* The window always gets unmapped. However, if we can show the
* icon version of the window (collapsed) we make the window visable
@@ -4163,14 +4214,11 @@ TkpWmSetState(winPtr, state)
CollapseWindow((WindowPtr) macWin, true);
}
}
-#endif
} else if (state == NormalState) {
Tk_MapWindow((Tk_Window) winPtr);
-#ifdef HAVE_APPEARANCE
- if (HaveAppearance()) {
+ if (TkMacHaveAppearance()) {
CollapseWindow((WindowPtr) macWin, false);
}
-#endif
} else if (state == ZoomState) {
/* TODO: need to support zoomed windows */
}
@@ -4178,7 +4226,7 @@ TkpWmSetState(winPtr, state)
/*
*----------------------------------------------------------------------
*
- * HaveAppearance --
+ * TkMacHaveAppearance --
*
* Determine if the appearance manager is available on this Mac.
* We cache the result so future calls are fast.
@@ -4192,22 +4240,20 @@ TkpWmSetState(winPtr, state)
*----------------------------------------------------------------------
*/
-static int
-HaveAppearance()
+int
+TkMacHaveAppearance()
{
static initialized = false;
- static int haveAppearance = false;
+ static int TkMacHaveAppearance = false;
long response = 0;
OSErr err = noErr;
-#ifdef HAVE_APPEARANCE
if (!initialized) {
err = Gestalt(gestaltAppearanceAttr, &response);
if (err == noErr) {
- haveAppearance = true;
+ TkMacHaveAppearance = true;
}
}
-#endif
- return haveAppearance;
+ return TkMacHaveAppearance;
}