diff options
author | jingham <jingham> | 2000-02-10 08:55:18 (GMT) |
---|---|---|
committer | jingham <jingham> | 2000-02-10 08:55:18 (GMT) |
commit | 824761dbcda694ee8ba6b108a373eb3c2aec026f (patch) | |
tree | f43637344ebdd7b323a38445d97180d1e32e880d /mac | |
parent | e082656eda18c1458feedf3392c25a00f88b92ef (diff) | |
download | tk-824761dbcda694ee8ba6b108a373eb3c2aec026f.zip tk-824761dbcda694ee8ba6b108a373eb3c2aec026f.tar.gz tk-824761dbcda694ee8ba6b108a373eb3c2aec026f.tar.bz2 |
Add support for Appearance Manager 1.2 Floating windows, and the new window classes in unsupported1
Diffstat (limited to 'mac')
-rw-r--r-- | mac/tkMacInt.h | 6 | ||||
-rw-r--r-- | mac/tkMacMenu.c | 11 | ||||
-rw-r--r-- | mac/tkMacMenus.c | 14 | ||||
-rw-r--r-- | mac/tkMacScrlbr.c | 12 | ||||
-rw-r--r-- | mac/tkMacSubwindows.c | 16 | ||||
-rw-r--r-- | mac/tkMacWindowMgr.c | 114 | ||||
-rw-r--r-- | mac/tkMacWm.c | 259 |
7 files changed, 387 insertions, 45 deletions
diff --git a/mac/tkMacInt.h b/mac/tkMacInt.h index 6a526d5..3a96f15 100644 --- a/mac/tkMacInt.h +++ b/mac/tkMacInt.h @@ -8,7 +8,7 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tkMacInt.h,v 1.8 1999/05/22 06:32:55 jingham Exp $ + * RCS: @(#) $Id: tkMacInt.h,v 1.9 2000/02/10 08:55:18 jingham Exp $ */ #ifndef _TKMACINT @@ -206,4 +206,8 @@ typedef TkMenuDefProcPtr TkMenuDefUPP; #include "tkIntPlatDecls.h" +/* FIXME - This has to go in the tkInt.decls!!! */ + +int TkpIsWindowFloating _ANSI_ARGS_((WindowRef window)); + #endif /* _TKMACINT */ diff --git a/mac/tkMacMenu.c b/mac/tkMacMenu.c index cbcc229..c0db274 100644 --- a/mac/tkMacMenu.c +++ b/mac/tkMacMenu.c @@ -8,7 +8,7 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tkMacMenu.c,v 1.17 1999/12/16 21:58:02 hobbs Exp $ + * RCS: @(#) $Id: tkMacMenu.c,v 1.18 2000/02/10 08:55:47 jingham Exp $ */ #include "tkMacInt.h" @@ -1881,8 +1881,15 @@ TkpSetMainMenubar( { TkWindow *winPtr = (TkWindow *) tkwin; WindowRef macWindowPtr = (WindowRef) TkMacGetDrawablePort(winPtr->window); + WindowRef frontNonFloating; - if ((macWindowPtr == NULL) || (macWindowPtr != FrontWindow())) { + if (TkMacHaveAppearance() >= 0x110) { + frontNonFloating = FrontNonFloatingWindow(); + } else { + frontNonFloating = FrontWindow(); + } + + if ((macWindowPtr == NULL) || (macWindowPtr != frontNonFloating)) { return; } diff --git a/mac/tkMacMenus.c b/mac/tkMacMenus.c index 0d9fa31..2230f7a 100644 --- a/mac/tkMacMenus.c +++ b/mac/tkMacMenus.c @@ -9,7 +9,7 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tkMacMenus.c,v 1.4 1999/05/22 06:33:41 jingham Exp $ + * RCS: @(#) $Id: tkMacMenus.c,v 1.5 2000/02/10 08:56:03 jingham Exp $ */ #include "tcl.h" @@ -120,7 +120,11 @@ TkMacHandleMenuSelect( break; case kCloseItem: /* Send close event */ - window = TkMacGetXWindow(FrontWindow()); + if (TkMacHaveAppearance() >= 0x110) { + window = TkMacGetXWindow(FrontNonFloatingWindow()); + } else { + window = TkMacGetXWindow(FrontWindow()); + } dispPtr = TkGetDisplayList(); tkwin = Tk_IdToWindow(dispPtr->display, window); TkGenWMDestroyEvent(tkwin); @@ -255,7 +259,11 @@ GenerateEditEvent( Window window; TkDisplay *dispPtr; - window = TkMacGetXWindow(FrontWindow()); + if (TkMacHaveAppearance() >= 0x110) { + window = TkMacGetXWindow(FrontNonFloatingWindow()); + } else { + window = TkMacGetXWindow(FrontWindow()); + } dispPtr = TkGetDisplayList(); tkwin = Tk_IdToWindow(dispPtr->display, window); tkwin = (Tk_Window) ((TkWindow *) tkwin)->dispPtr->focusPtr; diff --git a/mac/tkMacScrlbr.c b/mac/tkMacScrlbr.c index 333cc27..df030e0 100644 --- a/mac/tkMacScrlbr.c +++ b/mac/tkMacScrlbr.c @@ -10,7 +10,7 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tkMacScrlbr.c,v 1.3 1999/08/10 05:05:18 jingham Exp $ + * RCS: @(#) $Id: tkMacScrlbr.c,v 1.4 2000/02/10 08:56:12 jingham Exp $ */ #include "tkScrollbar.h" @@ -242,6 +242,7 @@ TkpDisplayScrollbar( if (macScrollPtr->sbHandle == NULL) { Rect r; + WindowRef frontNonFloating; r.left = r.top = 0; r.right = r.bottom = 1; @@ -252,7 +253,14 @@ TkpDisplayScrollbar( /* * If we are foremost than make us active. */ - if ((WindowPtr) destPort == FrontWindow()) { + + if (TkMacHaveAppearance() >= 0x110) { + frontNonFloating = FrontNonFloatingWindow(); + } else { + frontNonFloating = FrontWindow(); + } + + if ((WindowPtr) destPort == FrontWindow() || TkpIsWindowFloating((WindowPtr) destPort)) { macScrollPtr->macFlags |= ACTIVE; } } diff --git a/mac/tkMacSubwindows.c b/mac/tkMacSubwindows.c index 09bf09b..23942f9 100644 --- a/mac/tkMacSubwindows.c +++ b/mac/tkMacSubwindows.c @@ -8,7 +8,7 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tkMacSubwindows.c,v 1.5 1999/04/16 01:51:32 stanton Exp $ + * RCS: @(#) $Id: tkMacSubwindows.c,v 1.6 2000/02/10 08:56:24 jingham Exp $ */ #include "tkInt.h" @@ -938,7 +938,15 @@ TkMacGetDrawablePort( } if (resultPort == NULL) { - panic("TkMacGetDrawablePort couldn't find container"); + /* + * FIXME: + * + * So far as I can tell, the only time that this happens is when + * we are tearing down an embedded child interpreter, and most + * of the time, this is harmless... However, we really need to + * find why the embedding loses. + */ + DebugStr("\pTkMacGetDrawablePort couldn't find container"); return NULL; } @@ -1075,10 +1083,14 @@ tkMacMoveWindow( { int xOffset, yOffset; + if (TkMacHaveAppearance() >= 0x110) { + MoveWindowStructure((WindowRef) window, (short) x, (short) y); + } else { TkMacWindowOffset(window, &xOffset, &yOffset); MoveWindow((WindowRef) window, (short) (x + xOffset), (short) (y + yOffset), false); } +} /* *---------------------------------------------------------------------- diff --git a/mac/tkMacWindowMgr.c b/mac/tkMacWindowMgr.c index 0644847..f751969 100644 --- a/mac/tkMacWindowMgr.c +++ b/mac/tkMacWindowMgr.c @@ -8,7 +8,7 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tkMacWindowMgr.c,v 1.6 1999/12/07 03:51:11 hobbs Exp $ + * RCS: @(#) $Id: tkMacWindowMgr.c,v 1.7 2000/02/10 08:56:38 jingham Exp $ */ #include <Events.h> @@ -99,7 +99,7 @@ WindowManagerMouse( EventRecord *eventPtr, /* Macintosh event record. */ Window window) /* Window pointer. */ { - WindowRef whichWindow, frontWindow; + WindowRef whichWindow, frontWindow, frontNonFloating; Tk_Window tkwin; Point where, where2; int xOffset, yOffset; @@ -107,6 +107,11 @@ WindowManagerMouse( TkDisplay *dispPtr; frontWindow = FrontWindow(); + if (TkMacHaveAppearance() >= 0x110) { + frontNonFloating = FrontNonFloatingWindow(); + } else { + frontNonFloating = frontWindow; + } /* * The window manager only needs to know about mouse down events @@ -130,7 +135,7 @@ WindowManagerMouse( SystemClick(eventPtr, (GrafPort *) whichWindow); return false; case inDrag: - if (whichWindow != frontWindow) { + if (!(TkpIsWindowFloating(whichWindow)) && (whichWindow != frontNonFloating)) { if (!(eventPtr->modifiers & cmdKey)) { if ((gGrabWinPtr != NULL) && (gGrabWinPtr != tkwin)) { SysBeep(1); @@ -164,7 +169,8 @@ WindowManagerMouse( return true; case inGrow: case inContent: - if (whichWindow != frontWindow ) { + if (!(TkpIsWindowFloating(whichWindow)) + && (whichWindow != frontNonFloating)) { /* * This click moves the window forward. We don't want * the corasponding mouse-up to be reported to the application @@ -174,9 +180,9 @@ WindowManagerMouse( SysBeep(1); return false; } - BringWindowForward(whichWindow); gEatButtonUp = true; SetPort((GrafPort *) whichWindow); + BringWindowForward(whichWindow); return false; } else { /* @@ -270,7 +276,11 @@ TkAboutDlg() DisposDialog(aboutDlog); aboutDlog = NULL; + if (TkMacHaveAppearance() >= 0x110) { SelectWindow(FrontWindow()); + } else { + SelectWindow(FrontNonFloatingWindow()); + } return; } @@ -483,9 +493,14 @@ TkGenerateButtonEvent( where.h = x; where.v = y; FindWindow(where, &whichWin); - frontWin = FrontWindow(); - - if ((frontWin == NULL) || (frontWin != whichWin && gGrabWinPtr == NULL)) { + if (TkMacHaveAppearance() >= 0x110) { + frontWin = FrontNonFloatingWindow(); + } else { + frontWin = FrontWindow(); + } + + if ((frontWin == NULL) || ((!(TkpIsWindowFloating(whichWin)) && (frontWin != whichWin)) + && gGrabWinPtr == NULL)) { return false; } @@ -800,7 +815,7 @@ GeneratePollingEvents() { Tk_Window tkwin, rootwin; Window window; - WindowRef whichwindow, frontWin; + WindowRef whichWindow, frontWin, frontNonFloating; Point whereLocal, whereGlobal; Boolean inContentRgn; short part; @@ -822,13 +837,31 @@ GeneratePollingEvents() whereGlobal = whereLocal; LocalToGlobal(&whereGlobal); - part = FindWindow(whereGlobal, &whichwindow); + part = FindWindow(whereGlobal, &whichWindow); inContentRgn = (part == inContent || part == inGrow); - if ((frontWin != whichwindow) || !inContentRgn) { + if (TkMacHaveAppearance() >= 0x110) { + /* + * If the mouse is over the front non-floating window, then we + * need to set the local coordinates relative to that window + * rather than a possibly floating window above it. + */ + + frontNonFloating = FrontNonFloatingWindow(); + if (whichWindow == frontNonFloating + && (whichWindow != frontWin)) { + SetPort((GrafPort *) frontNonFloating); + whereLocal = whereGlobal; + GlobalToLocal(&whereLocal); + } + } else { + frontNonFloating = frontWin; + } + + if ((!TkpIsWindowFloating(whichWindow) && (frontNonFloating != whichWindow)) || !inContentRgn) { tkwin = NULL; } else { - window = TkMacGetXWindow(whichwindow); + window = TkMacGetXWindow(whichWindow); dispPtr = TkGetDisplayList(); rootwin = Tk_IdToWindow(dispPtr->display, window); if (rootwin == NULL) { @@ -1197,7 +1230,7 @@ TkMacConvertEvent( /* fall through */ case keyUp: - whichWindow = FrontWindow(); + whichWindow = FrontNonFloatingWindow(); if (whichWindow == NULL) { /* * This happens if we get a key event before Tk has had a @@ -1250,6 +1283,13 @@ TkMacConvertEvent( TkSuspendClipboard(); } tkMacAppInFront = (eventPtr->message & resumeFlag); + if (TkMacHaveAppearance() >= 0x110) { + if (tkMacAppInFront) { + ShowFloatingWindows(); + } else { + HideFloatingWindows(); + } + } break; } break; @@ -1408,6 +1448,13 @@ TkMacConvertTkEvent( TkSuspendClipboard(); } tkMacAppInFront = (eventPtr->message & resumeFlag); + if (TkMacHaveAppearance() >= 0x110) { + if (tkMacAppInFront) { + ShowFloatingWindows(); + } else { + HideFloatingWindows(); + } + } break; } break; @@ -1542,6 +1589,12 @@ TkMacWindowOffset( if (!strucRgn || !contRgn) { err = MemError( ); + + } else if (TkMacHaveAppearance()) { + GetWindowRegion(wRef, kWindowStructureRgn, strucRgn); + GetWindowRegion(wRef, kWindowContentRgn, contRgn); + strucRect = (**strucRgn).rgnBBox; + contRect = (**contRgn).rgnBBox; } else { CopyRgn(wPeek->strucRgn, strucRgn); CopyRgn(wPeek->contRgn, contRgn); @@ -1657,7 +1710,10 @@ static void BringWindowForward( WindowRef wRef) { - SelectWindow(wRef); + if (!TkpIsWindowFloating(wRef)) { + if (IsValidWindowPtr(wRef)) + SelectWindow(wRef); + } } /* @@ -1695,3 +1751,33 @@ TkpGetMS() return (long) *int64Ptr; } +/* + *---------------------------------------------------------------------- + * + * TkpIsWindowFloating -- + * + * Returns 1 if a window is floating, 0 otherwise. + * + * Results: + * 1 or 0 depending on window's floating attribute. + * + * Side effects: + * None. + * + *---------------------------------------------------------------------- + */ + +int +TkpIsWindowFloating(WindowRef wRef) +{ + WindowClass class; + + if (TkMacHaveAppearance() < 0x110) { + return 0; + } + + GetWindowClass(wRef, &class); + + return (class == kFloatingWindowClass); + +} diff --git a/mac/tkMacWm.c b/mac/tkMacWm.c index 1a21c3e..825aae4 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. * - * RCS: @(#) $Id: tkMacWm.c,v 1.8 2000/01/12 11:45:33 hobbs Exp $ + * RCS: @(#) $Id: tkMacWm.c,v 1.9 2000/02/10 08:57:11 jingham Exp $ */ #include <Gestalt.h> @@ -205,6 +205,8 @@ typedef struct TkWmInfo { * Macintosh information. */ int style; /* Native window style. */ + int macClass; + int attributes; TkWindow *scrollWinPtr; /* Ptr to scrollbar handling grow widget. */ } WmInfo; @@ -402,7 +404,13 @@ TkWmNewWindow( wmPtr->cmdArgv = NULL; wmPtr->clientMachine = NULL; wmPtr->flags = WM_NEVER_MAPPED; - wmPtr->style = zoomDocProc; + if (TkMacHaveAppearance() >= 0x110) { + wmPtr->style = -1; + } else { + wmPtr->style = documentProc; + } + wmPtr->macClass = kDocumentWindowClass; + wmPtr->attributes = kWindowStandardDocumentAttributes; wmPtr->scrollWinPtr = NULL; winPtr->wmInfoPtr = wmPtr; @@ -1342,7 +1350,7 @@ Tk_WmCmd( goto updateGeom; } else if ((c == 'o') && (strncmp(argv[1], "overrideredirect", length) == 0)) { - int boolean, curValue; + int boolean; XSetWindowAttributes atts; if ((argc != 3) && (argc != 4)) { @@ -1351,23 +1359,21 @@ Tk_WmCmd( (char *) NULL); return TCL_ERROR; } - curValue = Tk_Attributes((Tk_Window) winPtr)->override_redirect; if (argc == 3) { - Tcl_SetBooleanObj(Tcl_GetObjResult(interp), curValue); + if (Tk_Attributes((Tk_Window) winPtr)->override_redirect) { + Tcl_SetResult(interp, "1", TCL_STATIC); + } else { + Tcl_SetResult(interp, "0", TCL_STATIC); + } return TCL_OK; } if (Tcl_GetBoolean(interp, argv[3], &boolean) != TCL_OK) { return TCL_ERROR; } - if (curValue != boolean) { - /* - * Only do this if we are really changing value - */ atts.override_redirect = (boolean) ? True : False; Tk_ChangeWindowAttributes((Tk_Window) winPtr, CWOverrideRedirect, &atts); wmPtr->style = (boolean) ? plainDBox : documentProc; - } } else if ((c == 'p') && (strncmp(argv[1], "positionfrom", length) == 0) && (length >= 2)) { if ((argc != 3) && (argc != 4)) { @@ -1582,7 +1588,7 @@ Tk_WmCmd( (char *) NULL); return TCL_ERROR; } - if (wmPtr->masterPtr != NULL) { + if (wmPtr->master != NULL) { Tcl_AppendResult(interp, "can't iconify \"", winPtr->pathName, "\": it is a transient", (char *) NULL); @@ -2981,7 +2987,12 @@ TkWmRestackToplevel( otherMacWindow = NULL; } + if (TkMacHaveAppearance() >= 0x110) { + frontWindow = (WindowPeek) FrontNonFloatingWindow(); + } else { frontWindow = (WindowPeek) FrontWindow(); + } + if (aboveBelow == Above) { if (macWindow == frontWindow) { /* @@ -3781,14 +3792,30 @@ TkUnsupported1Cmd( c = argv[1][0]; length = strlen(argv[1]); if ((c == 's') && (strncmp(argv[1], "style", length) == 0)) { - if ((argc != 3) && (argc != 4)) { - Tcl_AppendResult(interp, "wrong # arguments: must be \"", - argv[0], " style window ?windowStyle?\"", - (char *) NULL); - return TCL_ERROR; + if (TkMacHaveAppearance() >= 0x110) { + if ((argc < 3) || (argc > 5)) { + Tcl_AppendResult(interp, "wrong # arguments: must be \"", + argv[0], " style window ?windowStyle?\"", + " or \"", argv[0], "style window ?class attributes?\"", + (char *) NULL); + return TCL_ERROR; + } + } else { + if ((argc != 3) && (argc != 4)) { + Tcl_AppendResult(interp, "wrong # arguments: must be \"", + argv[0], " style window ?windowStyle?\"", + (char *) NULL); + return TCL_ERROR; + } } + if (argc == 3) { + int appearanceSpec = 0; + switch (wmPtr->style) { + case -1: + appearanceSpec = 1; + break; case noGrowDocProc: case documentProc: Tcl_SetResult(interp, "documentProc", TCL_STATIC); @@ -3831,8 +3858,81 @@ TkUnsupported1Cmd( default: panic("invalid style"); } + if (appearanceSpec) { + Tcl_Obj *attributeList, *newResult; + + switch (wmPtr->macClass) { + case kAlertWindowClass: + newResult = Tcl_NewStringObj("alert", -1); + break; + case kMovableAlertWindowClass: + newResult = Tcl_NewStringObj("moveableAlert", -1); + break; + case kModalWindowClass: + newResult = Tcl_NewStringObj("modal", -1); + break; + case kMovableModalWindowClass: + newResult = Tcl_NewStringObj("moveableModal", -1); + break; + case kFloatingWindowClass: + newResult = Tcl_NewStringObj("floating", -1); + break; + case kDocumentWindowClass: + newResult = Tcl_NewStringObj("document", -1); + break; + default: + panic("invalid class"); + } + + attributeList = Tcl_NewListObj(0, NULL); + if (wmPtr->attributes == kWindowNoAttributes) { + Tcl_ListObjAppendElement(interp, attributeList, + Tcl_NewStringObj("none", -1)); + } else if (wmPtr->attributes == kWindowStandardDocumentAttributes) { + Tcl_ListObjAppendElement(interp, attributeList, + Tcl_NewStringObj("standardDocument", -1)); + } else if (wmPtr->attributes == kWindowStandardFloatingAttributes) { + Tcl_ListObjAppendElement(interp, attributeList, + Tcl_NewStringObj("standardFloating", -1)); + } else { + if (wmPtr->attributes & kWindowCloseBoxAttribute) { + Tcl_ListObjAppendElement(interp, attributeList, + Tcl_NewStringObj("closeBox", -1)); + } + if (wmPtr->attributes & kWindowHorizontalZoomAttribute) { + Tcl_ListObjAppendElement(interp, attributeList, + Tcl_NewStringObj("horizontalZoom", -1)); + } + if (wmPtr->attributes & kWindowVerticalZoomAttribute) { + Tcl_ListObjAppendElement(interp, attributeList, + Tcl_NewStringObj("verticalZoom", -1)); + } + if (wmPtr->attributes & kWindowCollapseBoxAttribute) { + Tcl_ListObjAppendElement(interp, attributeList, + Tcl_NewStringObj("collapseBox", -1)); + } + if (wmPtr->attributes & kWindowResizableAttribute) { + Tcl_ListObjAppendElement(interp, attributeList, + Tcl_NewStringObj("resizable", -1)); + } + if (wmPtr->attributes & kWindowSideTitlebarAttribute) { + Tcl_ListObjAppendElement(interp, attributeList, + Tcl_NewStringObj("sideTitlebar", -1)); + } + if (wmPtr->attributes & kWindowNoUpdatesAttribute) { + Tcl_ListObjAppendElement(interp, attributeList, + Tcl_NewStringObj("noUpdates", -1)); + } + if (wmPtr->attributes & kWindowNoActivatesAttribute) { + Tcl_ListObjAppendElement(interp, attributeList, + Tcl_NewStringObj("noActivates", -1)); + } + } + Tcl_ListObjAppendElement(interp, newResult, attributeList); + Tcl_SetObjResult(interp, newResult); + } return TCL_OK; - } + } else if (argc == 4) { if (strcmp(argv[3], "documentProc") == 0) { wmPtr->style = documentProc; } else if (strcmp(argv[3], "noGrowDocProc") == 0) { @@ -3875,6 +3975,102 @@ TkUnsupported1Cmd( (char *) NULL); return TCL_ERROR; } + } else if (argc == 5) { + int oldClass = wmPtr->macClass; + int oldAttributes = wmPtr->attributes; + + if (strcmp(argv[3], "alert") == 0) { + wmPtr->macClass = kAlertWindowClass; + } else if (strcmp(argv[3], "moveableAlert") == 0) { + wmPtr->macClass = kMovableAlertWindowClass; + } else if (strcmp(argv[3], "modal") == 0) { + wmPtr->macClass = kModalWindowClass; + } else if (strcmp(argv[3], "moveableModal") == 0) { + wmPtr->macClass = kMovableModalWindowClass; + } else if (strcmp(argv[3], "floating") == 0) { + wmPtr->macClass = kFloatingWindowClass; + } else if (strcmp(argv[3], "document") == 0) { + wmPtr->macClass = kDocumentWindowClass; + } else { + wmPtr->macClass = oldClass; + Tcl_AppendResult(interp, "bad class: should be alert, ", + "moveableAlert, modal, moveableModal, floating, ", + "or document", + (char *) NULL); + return TCL_ERROR; + } + + if (strcmp(argv[4], "none") == 0) { + wmPtr->attributes = kWindowNoAttributes; + } else if (strcmp(argv[4], "standardDocument") == 0) { + wmPtr->attributes = kWindowStandardDocumentAttributes; + } else if (strcmp(argv[4], "standardFloating") == 0) { + wmPtr->attributes = kWindowStandardFloatingAttributes; + } else { + int foundOne = 0; + int attrArgc, i; + char **attrArgv = NULL; + + if (Tcl_SplitList(interp, argv[4], &attrArgc, &attrArgv) != TCL_OK) { + wmPtr->macClass = oldClass; + Tcl_AppendResult(interp, "Ill-formed attributes list: \"", + argv[4], "\".", (char *) NULL); + return TCL_ERROR; + } + + wmPtr->attributes = kWindowNoAttributes; + + for (i = 0; i < attrArgc; i++) { + if ((*attrArgv[i] == 'c') + && (strcmp(attrArgv[i], "closeBox") == 0)) { + wmPtr->attributes |= kWindowCloseBoxAttribute; + foundOne = 1; + } else if ((*attrArgv[i] == 'h') + && (strcmp(attrArgv[i], "horizontalZoom") == 0)) { + wmPtr->attributes |= kWindowHorizontalZoomAttribute; + foundOne = 1; + } else if ((*attrArgv[i] == 'v') + && (strcmp(attrArgv[i], "verticalZoom") == 0)) { + wmPtr->attributes |= kWindowVerticalZoomAttribute; + foundOne = 1; + } else if ((*attrArgv[i] == 'c') + && (strcmp(attrArgv[i], "collapseBox") == 0)) { + wmPtr->attributes |= kWindowCollapseBoxAttribute; + foundOne = 1; + } else if ((*attrArgv[i] == 'r') + && (strcmp(attrArgv[i], "resizable") == 0)) { + wmPtr->attributes |= kWindowResizableAttribute; + foundOne = 1; + } else if ((*attrArgv[i] == 's') + && (strcmp(attrArgv[i], "sideTitlebar") == 0)) { + wmPtr->attributes |= kWindowSideTitlebarAttribute; + foundOne = 1; + } else { + foundOne = 0; + break; + } + } + + if (attrArgv != NULL) { + ckfree ((char *) attrArgv); + } + + if (foundOne != 1) { + wmPtr->macClass = oldClass; + wmPtr->attributes = oldAttributes; + + Tcl_AppendResult(interp, "bad attribute: \"", argv[4], + "\", should be standardDocument, ", + "standardFloating, or some combination of ", + "closeBox, horizontalZoom, verticalZoom, ", + "collapseBox, resizable, or sideTitlebar.", + (char *) NULL); + return TCL_ERROR; + } + } + + wmPtr->style = -1; + } } else { Tcl_AppendResult(interp, "unknown or ambiguous option \"", argv[1], "\": must be style", @@ -3943,7 +4139,7 @@ TkMacMakeRealWindowExist( WmInfo *wmPtr = winPtr->wmInfoPtr; WindowRef newWindow = NULL; MacDrawable *macWin; - Rect geometry; + Rect geometry = {0,0,0,0}; Tcl_HashEntry *valueHashPtr; int new; TkMacWindowList *listPtr; @@ -3986,8 +4182,29 @@ TkMacMakeRealWindowExist( InitialWindowBounds(winPtr, &geometry); + if (TkMacHaveAppearance() >= 0x110 && wmPtr->style == -1) { + OSStatus err; + /* + * There seems to be a bug in CreateNewWindow: If I set the + * window geometry to be the too small for the structure region, + * then the whole window is positioned incorrectly. + * Adding this here makes the positioning work, and the size will + * get overwritten when you actually map the contents of the window. + */ + + geometry.right += 64; + geometry.bottom += 24; + err = CreateNewWindow(wmPtr->macClass, wmPtr->attributes, + &geometry, &newWindow); + if (err != noErr) { + newWindow = NULL; + } + + } else { newWindow = NewCWindow(NULL, &geometry, "\ptemp", false, (short) wmPtr->style, (WindowRef) -1, true, 0); + } + if (newWindow == NULL) { panic("couldn't allocate new Mac window"); } @@ -4264,8 +4481,8 @@ TkpWmSetState(winPtr, state) if (TkMacHaveAppearance()) { /* * The window always gets unmapped. However, if we can show the - * icon version of the window (collapsed) we make the window - * visible and then collapse it. + * icon version of the window (collapsed) we make the window visable + * and then collapse it. * * TODO: This approach causes flashing! */ @@ -4319,7 +4536,7 @@ TkMacHaveAppearance() } err = Gestalt(gestaltAppearanceVersion, &response); if (err == noErr) { - TkMacHaveAppearance = 2; + TkMacHaveAppearance = (int) response; } } |