diff options
author | das <das> | 2009-06-29 14:35:01 (GMT) |
---|---|---|
committer | das <das> | 2009-06-29 14:35:01 (GMT) |
commit | 8f9b8fd63b4da5f6f27b46c438c89f2baa15f0e8 (patch) | |
tree | 81b5743d2ff5d45f2ee4992153e4f34949ea8f8a /macosx/tkMacOSXWm.c | |
parent | e4a87c21cb59539eeddcc65d359e9b06d597fed3 (diff) | |
download | tk-8f9b8fd63b4da5f6f27b46c438c89f2baa15f0e8.zip tk-8f9b8fd63b4da5f6f27b46c438c89f2baa15f0e8.tar.gz tk-8f9b8fd63b4da5f6f27b46c438c89f2baa15f0e8.tar.bz2 |
Merge of TkAqua Cocoa portmacosx_cocoa_merge
Diffstat (limited to 'macosx/tkMacOSXWm.c')
-rw-r--r-- | macosx/tkMacOSXWm.c | 1799 |
1 files changed, 900 insertions, 899 deletions
diff --git a/macosx/tkMacOSXWm.c b/macosx/tkMacOSXWm.c index 94fa8ba..bdb7bf9 100644 --- a/macosx/tkMacOSXWm.c +++ b/macosx/tkMacOSXWm.c @@ -7,13 +7,13 @@ * manager. * * Copyright (c) 1994-1997 Sun Microsystems, Inc. - * Copyright 2001, Apple Computer, Inc. - * Copyright (c) 2006-2007 Daniel A. Steffen <das@users.sourceforge.net> + * Copyright 2001-2009, Apple Inc. + * Copyright (c) 2006-2009 Daniel A. Steffen <das@users.sourceforge.net> * - * See the file "license.terms" for information on usage and redistribution of - * this file, and for a DISCLAIMER OF ALL WARRANTIES. + * See the file "license.terms" for information on usage and redistribution + * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tkMacOSXWm.c,v 1.74 2009/02/06 08:12:07 das Exp $ + * RCS: @(#) $Id: tkMacOSXWm.c,v 1.75 2009/06/29 14:35:01 das Exp $ */ #include "tkMacOSXPrivate.h" @@ -29,8 +29,122 @@ */ /* + * Window attributes and classes + */ + +#define WM_NSMASK_SHIFT 36 +#define tkWindowDoesNotHideAttribute \ + ((UInt64) 1 << kHIWindowBitDoesNotHide) +#define tkCanJoinAllSpacesAttribute \ + ((UInt64) NSWindowCollectionBehaviorCanJoinAllSpaces << 34) +#define tkMoveToActiveSpaceAttribute \ + ((UInt64) NSWindowCollectionBehaviorMoveToActiveSpace << 34) +#define tkNonactivatingPanelAttribute \ + ((UInt64) NSNonactivatingPanelMask << WM_NSMASK_SHIFT) +#define tkHUDWindowAttribute \ + ((UInt64) NSHUDWindowMask << WM_NSMASK_SHIFT) +#define tkAlwaysValidAttributes (kWindowNoUpdatesAttribute \ + | kWindowNoActivatesAttribute | kWindowHideOnSuspendAttribute \ + | kWindowHideOnFullScreenAttribute | kWindowNoConstrainAttribute \ + | kWindowNoShadowAttribute | kWindowLiveResizeAttribute \ + | kWindowOpaqueForEventsAttribute | kWindowIgnoreClicksAttribute \ + | kWindowDoesNotCycleAttribute | tkWindowDoesNotHideAttribute \ + | tkCanJoinAllSpacesAttribute | tkMoveToActiveSpaceAttribute \ + | tkNonactivatingPanelAttribute | tkHUDWindowAttribute) + +static const struct { + const UInt64 validAttrs, defaultAttrs, forceOnAttrs, forceOffAttrs; + int flags; NSUInteger styleMask; +} macClassAttrs[] = { + [kAlertWindowClass] = { + .defaultAttrs = kWindowDoesNotCycleAttribute, }, + [kMovableAlertWindowClass] = { + .defaultAttrs = kWindowDoesNotCycleAttribute, }, + [kModalWindowClass] = { + .defaultAttrs = kWindowDoesNotCycleAttribute, }, + [kMovableModalWindowClass] = { + .validAttrs = kWindowCloseBoxAttribute | kWindowMetalAttribute | + kWindowFullZoomAttribute | kWindowResizableAttribute, + .defaultAttrs = kWindowDoesNotCycleAttribute, }, + [kFloatingWindowClass] = { + .validAttrs = kWindowCloseBoxAttribute | kWindowCollapseBoxAttribute | + kWindowMetalAttribute | kWindowToolbarButtonAttribute | + kWindowNoTitleBarAttribute | kWindowFullZoomAttribute | + kWindowResizableAttribute | kWindowSideTitlebarAttribute, + .defaultAttrs = kWindowStandardFloatingAttributes | + kWindowHideOnSuspendAttribute | kWindowDoesNotCycleAttribute, + .forceOnAttrs = kWindowResizableAttribute, + .forceOffAttrs = kWindowCollapseBoxAttribute, + .styleMask = NSUtilityWindowMask, }, + [kDocumentWindowClass] = { + .validAttrs = kWindowCloseBoxAttribute | kWindowCollapseBoxAttribute | + kWindowMetalAttribute | kWindowToolbarButtonAttribute | + kWindowNoTitleBarAttribute | + kWindowUnifiedTitleAndToolbarAttribute | + kWindowInWindowMenuAttribute | kWindowFullZoomAttribute | + kWindowResizableAttribute, + .forceOnAttrs = kWindowResizableAttribute, + .defaultAttrs = kWindowStandardDocumentAttributes | + kWindowLiveResizeAttribute | kWindowInWindowMenuAttribute, }, + [kUtilityWindowClass] = { + .validAttrs = kWindowCloseBoxAttribute | kWindowCollapseBoxAttribute | + kWindowMetalAttribute | kWindowToolbarButtonAttribute | + kWindowNoTitleBarAttribute | kWindowFullZoomAttribute | + kWindowResizableAttribute | kWindowSideTitlebarAttribute, + .defaultAttrs = kWindowStandardFloatingAttributes | + kWindowHideOnFullScreenAttribute | + tkWindowDoesNotHideAttribute | tkNonactivatingPanelAttribute | + kWindowDoesNotCycleAttribute, + .forceOnAttrs = kWindowResizableAttribute, + .forceOffAttrs = kWindowCollapseBoxAttribute, + .flags = WM_TOPMOST, + .styleMask = NSUtilityWindowMask, }, + [kHelpWindowClass] = { + .defaultAttrs = kWindowHideOnSuspendAttribute, + .forceOnAttrs = kWindowNoTitleBarAttribute | + kWindowDoesNotCycleAttribute, + .flags = WM_TOPMOST, }, + [kSheetWindowClass] = { + .validAttrs = kWindowResizableAttribute, + .forceOnAttrs = kWindowNoTitleBarAttribute | + kWindowDoesNotCycleAttribute, + .styleMask = NSDocModalWindowMask, }, + [kToolbarWindowClass] = { + .defaultAttrs = kWindowHideOnSuspendAttribute, + .forceOnAttrs = kWindowNoTitleBarAttribute | + kWindowDoesNotCycleAttribute, + .styleMask = NSUtilityWindowMask, }, + [kPlainWindowClass] = { + .defaultAttrs = kWindowDoesNotCycleAttribute, + .forceOnAttrs = kWindowNoTitleBarAttribute, }, + [kOverlayWindowClass] = { + .forceOnAttrs = kWindowNoTitleBarAttribute | + kWindowDoesNotCycleAttribute, + .flags = WM_TOPMOST | WM_TRANSPARENT, }, + [kSheetAlertWindowClass] = { + .forceOnAttrs = kWindowNoTitleBarAttribute | + kWindowDoesNotCycleAttribute, + .styleMask = NSDocModalWindowMask, }, + [kAltPlainWindowClass] = { + .defaultAttrs = kWindowDoesNotCycleAttribute, + .forceOnAttrs = kWindowNoTitleBarAttribute, }, + [kSimpleWindowClass] = { + .defaultAttrs = kWindowDoesNotCycleAttribute, + .forceOnAttrs = kWindowNoTitleBarAttribute, }, + [kDrawerWindowClass] = { + .validAttrs = kWindowMetalAttribute | kWindowResizableAttribute, + .forceOnAttrs = kWindowNoTitleBarAttribute | + kWindowDoesNotCycleAttribute, }, +}; + +#define ForceAttributes(attributes, class) \ + ((attributes) & (~macClassAttrs[(class)].forceOffAttrs | \ + (macClassAttrs[(class)].forceOnAttrs & ~kWindowResizableAttribute))) + +/* * Data for [wm attributes] command: */ + typedef enum { WMATT_ALPHA, WMATT_FULLSCREEN, WMATT_MODIFIED, WMATT_NOTIFY, WMATT_TITLEPATH, WMATT_TOPMOST, WMATT_TRANSPARENT, @@ -44,14 +158,6 @@ static const char *const WmAttributeNames[] = { }; /* - * This is a list of all of the toplevels that have been mapped so far. It is - * used by the menu code to inval windows that were damaged by menus, and will - * eventually also be used to keep track of floating windows. - */ - -TkMacOSXWindowList *tkMacOSXWindowListPtr = NULL; - -/* * The variable below is used to enable or disable tracing in this module. If * tracing is enabled, then information is printed on standard output about * interesting interactions with the window manager. @@ -89,8 +195,8 @@ static int windowHashInit = false; * Forward declarations for procedures defined in this file: */ -static void InitialWindowBounds(TkWindow *winPtr, - WindowRef macWindow, Rect *geometry); +static NSRect InitialWindowBounds(TkWindow *winPtr, + NSWindow *macWindow); static int ParseGeometry(Tcl_Interp *interp, char *string, TkWindow *winPtr); static void TopLevelEventProc(ClientData clientData, @@ -199,12 +305,11 @@ 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 void ApplyWindowClassAttributeChanges(TkWindow *winPtr, - WindowRef macWindow, WindowClass oldClass, - WindowAttributes oldAttributes, int create); +static void ApplyWindowAttributeFlagChanges(TkWindow *winPtr, + NSWindow *macWindow, UInt64 oldAttributes, + int oldFlags, int create, int initial); static void ApplyMasterOverrideChanges(TkWindow *winPtr, - WindowRef macWindow); -static WindowGroupRef WmGetWindowGroup(TkWindow *winPtr); + NSWindow *macWindow); static void GetMinSize(TkWindow *winPtr, int *minWidthPtr, int *minHeightPtr); static void GetMaxSize(TkWindow *winPtr, int *maxWidthPtr, @@ -212,6 +317,165 @@ static void GetMaxSize(TkWindow *winPtr, int *maxWidthPtr, static void RemapWindows(TkWindow *winPtr, MacDrawable *parentWin); +#pragma mark TKWindow(TKWm) + +#if MAC_OS_X_VERSION_MIN_REQUIRED < 1060 +@interface NSWindow(TkWm) +- (void)setCanCycle:(BOOL)canCycleFlag; +@end +#endif + +@interface NSDrawerWindow : NSWindow +{ + id _i1, _i2; +} +@end + +@implementation TKWindow +@end + +@implementation TKWindow(TKWm) +- (BOOL)canBecomeKeyWindow { + TkWindow *winPtr = TkMacOSXGetTkWindow(self); + + return (winPtr && winPtr->wmInfoPtr && (winPtr->wmInfoPtr->macClass == + kHelpWindowClass || winPtr->wmInfoPtr->attributes & + kWindowNoActivatesAttribute)) ? NO : YES; +} +@end + +#pragma mark - + +/* + *---------------------------------------------------------------------- + * + * SetWindowSizeLimits -- + * + * Sets NSWindow size limits + * + * Results: + * None. + * + * Side effects: + * None. + * + *---------------------------------------------------------------------- + */ + +static void +SetWindowSizeLimits( + TkWindow *winPtr) +{ + NSWindow *macWindow = TkMacOSXDrawableWindow(winPtr->window); + WmInfo *wmPtr = winPtr->wmInfoPtr; + int minWidth, minHeight, maxWidth, maxHeight, base; + + if (!macWindow) { + return; + } + GetMinSize(winPtr, &minWidth, &minHeight); + GetMaxSize(winPtr, &maxWidth, &maxHeight); + if (wmPtr->gridWin) { + base = winPtr->reqWidth - (wmPtr->reqGridWidth * wmPtr->widthInc); + if (base < 0) { + base = 0; + } + minWidth = base + (minWidth * wmPtr->widthInc); + maxWidth = base + (maxWidth * wmPtr->widthInc); + base = winPtr->reqHeight - (wmPtr->reqGridHeight * wmPtr->heightInc); + if (base < 0) { + base = 0; + } + minHeight = base + (minHeight * wmPtr->heightInc); + maxHeight = base + (maxHeight * wmPtr->heightInc); + } + if (wmPtr->flags & WM_WIDTH_NOT_RESIZABLE) { + minWidth = maxWidth = wmPtr->configWidth; + } + if (wmPtr->flags & WM_HEIGHT_NOT_RESIZABLE) { + minHeight = maxHeight = wmPtr->configHeight; + } + if (wmPtr->gridWin) { + [macWindow setResizeIncrements:NSMakeSize(wmPtr->widthInc, + wmPtr->heightInc)]; + } else if (wmPtr->sizeHintsFlags & PAspect && wmPtr->minAspect.x == + 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); + } else { + minWidth = lround(minHeight * ratio); + } + if ((CGFloat)maxWidth/(CGFloat)maxHeight > ratio) { + maxWidth = lround(maxHeight * ratio); + } else { + maxHeight = lround(maxWidth / ratio); + } + if ((CGFloat)wmPtr->configWidth/(CGFloat)wmPtr->configHeight > ratio) { + wmPtr->configWidth = lround(wmPtr->configHeight * ratio); + if (wmPtr->configWidth < minWidth) { + wmPtr->configWidth = minWidth; + wmPtr->configHeight = minHeight; + } + } else { + wmPtr->configHeight = lround(wmPtr->configWidth / ratio); + if (wmPtr->configHeight < minHeight) { + wmPtr->configWidth = minWidth; + wmPtr->configHeight = minHeight; + } + } + } else { + [macWindow setResizeIncrements:NSMakeSize(1.0, 1.0)]; + } + [macWindow setContentMinSize:NSMakeSize(minWidth, minHeight)]; + [macWindow setContentMaxSize:NSMakeSize(maxWidth, maxHeight)]; +} + +/* + *---------------------------------------------------------------------- + * + * FrontWindowAtPoint -- + * + * Find frontmost toplevel window at a given screen location. + * + * Results: + * TkWindow*. + * + * Side effects: + * None. + * + *---------------------------------------------------------------------- + */ + +static TkWindow* +FrontWindowAtPoint( + int x, int y) +{ + + NSPoint p = NSMakePoint(x, tkMacOSXZeroScreenHeight - y); + NSWindow *win = nil; + NSInteger windowCount; + NSInteger *windowNumbers; + + NSCountWindows(&windowCount); + if (windowCount) { + windowNumbers = (NSInteger *) ckalloc(windowCount * sizeof(NSInteger)); + 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; + } + } + ckfree((char *) windowNumbers); + } + return (win ? TkMacOSXGetTkWindow(win) : NULL); +} + + /* *---------------------------------------------------------------------- * @@ -283,11 +547,11 @@ TkWmNewWindow( wmPtr->cmdArgv = NULL; wmPtr->clientMachine = NULL; wmPtr->flags = WM_NEVER_MAPPED; - wmPtr->style = -1; wmPtr->macClass = kDocumentWindowClass; - wmPtr->attributes = kWindowStandardDocumentAttributes - | kWindowLiveResizeAttribute; + wmPtr->attributes = macClassAttrs[kDocumentWindowClass].defaultAttrs; wmPtr->scrollWinPtr = NULL; + wmPtr->menuPtr = NULL; + wmPtr->window = nil; winPtr->wmInfoPtr = wmPtr; UpdateVRootGeometry(wmPtr); @@ -307,7 +571,7 @@ TkWmNewWindow( Tk_ManageGeometry((Tk_Window) winPtr, &wmMgrType, (ClientData) 0); } - + /* *---------------------------------------------------------------------- * @@ -339,8 +603,6 @@ TkWmMapWindow( WmInfo *wmPtr = winPtr->wmInfoPtr; if (wmPtr->flags & WM_NEVER_MAPPED) { - wmPtr->flags &= ~WM_NEVER_MAPPED; - /* * Create the underlying Mac window for this Tk window. */ @@ -349,6 +611,8 @@ TkWmMapWindow( TkMacOSXMakeRealWindowExist(winPtr); } + wmPtr->flags &= ~WM_NEVER_MAPPED; + /* * Generate configure event when we first map the window. */ @@ -406,7 +670,7 @@ TkWmMapWindow( XMapWindow(winPtr->display, winPtr->window); } - + /* *---------------------------------------------------------------------- * @@ -431,7 +695,7 @@ TkWmUnmapWindow( { XUnmapWindow(winPtr->display, winPtr->window); } - + /* *---------------------------------------------------------------------- * @@ -453,8 +717,7 @@ void TkWmDeadWindow( TkWindow *winPtr) /* Top-level window that's being deleted. */ { - WmInfo *wmPtr = winPtr->wmInfoPtr; - WmInfo *wmPtr2; + WmInfo *wmPtr = winPtr->wmInfoPtr, *wmPtr2; if (wmPtr == NULL) { return; @@ -499,10 +762,29 @@ TkWmDeadWindow( if (wmPtr->flags & WM_UPDATE_PENDING) { Tk_CancelIdleCall(UpdateGeometryInfo, winPtr); } + + /* + * Delete the Mac window and remove it from the windowTable. The window + * could be nil if the window was never mapped. However, we don't do this + * for embedded windows, they don't go in the window list, and they do not + * own their portPtr's. + */ + + 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; + } + TkMacOSXMakeCollectableAndRelease(wmPtr->window); + } + ckfree((char *) wmPtr); winPtr->wmInfoPtr = NULL; } - + /* *---------------------------------------------------------------------- * @@ -528,7 +810,7 @@ TkWmSetClass( { return; } - + /* *---------------------------------------------------------------------- * @@ -689,7 +971,7 @@ Tk_WmObjCmd( /* This should not happen */ return TCL_ERROR; } - + /* *---------------------------------------------------------------------- * @@ -758,7 +1040,7 @@ WmAspectCmd( WmUpdateGeom(wmPtr, winPtr); return TCL_OK; } - + /* *---------------------------------------------------------------------- * @@ -778,7 +1060,7 @@ WmAspectCmd( static int WmSetAttribute( TkWindow *winPtr, /* Toplevel to work with */ - WindowRef macWindow, + NSWindow *macWindow, Tcl_Interp *interp, /* Current interpreter */ WmAttribute attribute, /* Code of attribute to set */ Tcl_Obj *value) /* New value */ @@ -803,7 +1085,7 @@ WmSetAttribute( } else if (dval > 1.0) { dval = 1.0; } - ChkErr(SetWindowAlpha, macWindow, dval); + [macWindow setAlphaValue:dval]; break; } case WMATT_FULLSCREEN: @@ -821,8 +1103,8 @@ WmSetAttribute( if (Tcl_GetBooleanFromObj(interp, value, &boolean) != TCL_OK) { return TCL_ERROR; } - if (boolean != IsWindowModified(macWindow)) { - ChkErr(SetWindowModified, macWindow, boolean); + if (boolean != [macWindow isDocumentEdited]) { + [macWindow setDocumentEdited:boolean]; } break; case WMATT_NOTIFY: @@ -830,54 +1112,26 @@ WmSetAttribute( return TCL_ERROR; } if (boolean == !tkMacOSXWmAttrNotifyVal) { - static NMRec notifyRec; + static NSInteger request = -1; + if (request >= 0) { + [NSApp cancelUserAttentionRequest:request]; + request = -1; + } if (boolean) { - bzero(¬ifyRec, sizeof(notifyRec)); - notifyRec.qType = nmType; - notifyRec.nmMark = 1; - ChkErr(NMInstall, ¬ifyRec); - } else { - ChkErr(NMRemove, ¬ifyRec); + request = [NSApp requestUserAttention:NSCriticalRequest]; } tkMacOSXWmAttrNotifyVal = boolean; } break; case WMATT_TITLEPATH: { const char *path = Tcl_FSGetNativePath(value); - OSStatus err; + NSString *filename = @""; if (path && *path) { - FSRef ref; - Boolean d; - - err = ChkErr(FSPathMakeRef, (const unsigned char*)path, &ref, &d); - if (err == noErr) { - TK_IF_MAC_OS_X_API (4, HIWindowSetProxyFSRef, - err = ChkErr(HIWindowSetProxyFSRef, macWindow, &ref); - ) TK_ELSE_MAC_OS_X (4, - AliasHandle alias; - - err = ChkErr(FSNewAlias, NULL, &ref, &alias); - if (err == noErr) { - err = ChkErr(SetWindowProxyAlias, macWindow, alias); - DisposeHandle((Handle) alias); - } - ) TK_ENDIF - } - } else { - int len; - - Tcl_GetStringFromObj(value, &len); - if (!len) { - err = ChkErr(RemoveWindowProxy, macWindow); - } else { - err = fnfErr; - } - } - if (err != noErr) { - return TCL_ERROR; + filename = [NSString stringWithUTF8String:path]; } + [macWindow setRepresentedFilename:filename]; break; } case WMATT_TOPMOST: @@ -885,17 +1139,15 @@ WmSetAttribute( return TCL_ERROR; } if (boolean != ((wmPtr->flags & WM_TOPMOST) != 0)) { - WindowGroupRef group; + int oldFlags = wmPtr->flags; if (boolean) { wmPtr->flags |= WM_TOPMOST; } else { wmPtr->flags &= ~WM_TOPMOST; } - group = WmGetWindowGroup(winPtr); - if (group && group != GetWindowGroup(macWindow)) { - ChkErr(SetWindowGroup, macWindow, group); - } + ApplyWindowAttributeFlagChanges(winPtr, macWindow, + wmPtr->attributes, oldFlags, 1, 0); } break; case WMATT_TRANSPARENT: @@ -903,27 +1155,20 @@ WmSetAttribute( return TCL_ERROR; } if (boolean != ((wmPtr->flags & WM_TRANSPARENT) != 0)) { - WindowAttributes oldAttributes = wmPtr->attributes; + UInt64 oldAttributes = wmPtr->attributes; + int oldFlags = wmPtr->flags; if (boolean) { wmPtr->flags |= WM_TRANSPARENT; wmPtr->attributes |= kWindowNoShadowAttribute; - TK_IF_MAC_OS_X_API (3, HIWindowChangeFeatures, - UInt32 features; - - ChkErr(GetWindowFeatures, macWindow, &features); - if (features & kWindowIsOpaque) { - ChkErr(HIWindowChangeFeatures, macWindow, 0, - kWindowIsOpaque); - } - ) TK_ENDIF } else { wmPtr->flags &= ~WM_TRANSPARENT; wmPtr->attributes &= ~kWindowNoShadowAttribute; } - ApplyWindowClassAttributeChanges(winPtr, macWindow, - wmPtr->macClass, oldAttributes, 1); - ChkErr(ReshapeCustomWindow, macWindow); + ApplyWindowAttributeFlagChanges(winPtr, macWindow, oldAttributes, + oldFlags, 1, 0); + [macWindow setBackgroundColor:boolean ? [NSColor clearColor] : nil]; + [macWindow setOpaque:!boolean]; TkMacOSXInvalidateWindow((MacDrawable *) winPtr->window, TK_PARENT_WINDOW); } @@ -934,7 +1179,7 @@ WmSetAttribute( } return TCL_OK; } - + /* *---------------------------------------------------------------------- * @@ -949,54 +1194,29 @@ WmSetAttribute( static Tcl_Obj * WmGetAttribute( TkWindow *winPtr, /* Toplevel to work with */ - WindowRef macWindow, + NSWindow *macWindow, WmAttribute attribute) /* Code of attribute to get */ { - WmInfo *wmPtr = winPtr->wmInfoPtr; Tcl_Obj *result = NULL; + WmInfo *wmPtr = winPtr->wmInfoPtr; switch (attribute) { - case WMATT_ALPHA: { - float fval = 1.0; - - ChkErr(GetWindowAlpha, macWindow, &fval); - result = Tcl_NewDoubleObj(fval); + case WMATT_ALPHA: + result = Tcl_NewDoubleObj([macWindow alphaValue]); break; - } case WMATT_FULLSCREEN: result = Tcl_NewBooleanObj(wmPtr->flags & WM_FULLSCREEN); break; case WMATT_MODIFIED: - result = Tcl_NewBooleanObj(IsWindowModified(macWindow)); + result = Tcl_NewBooleanObj([macWindow isDocumentEdited]); break; case WMATT_NOTIFY: result = Tcl_NewBooleanObj(tkMacOSXWmAttrNotifyVal); break; - case WMATT_TITLEPATH: { - FSRef ref; - UInt8 path[PATH_MAX+1]; - OSStatus err; - - TK_IF_MAC_OS_X_API (4, HIWindowSetProxyFSRef, - err = ChkErr(HIWindowGetProxyFSRef, macWindow, &ref); - ) TK_ELSE_MAC_OS_X (4, - Boolean wasChanged; - AliasHandle alias; - - err = ChkErr(GetWindowProxyAlias, macWindow, &alias); - if (err == noErr) { - err = ChkErr(FSResolveAlias, NULL, alias, &ref, &wasChanged); - } - ) TK_ENDIF - if (err == noErr) { - err = ChkErr(FSRefMakePath, &ref, path, PATH_MAX); - } - if (err != noErr) { - *path = 0; - } - result = Tcl_NewStringObj((char*) path, -1); + case WMATT_TITLEPATH: + result = Tcl_NewStringObj([[macWindow representedFilename] UTF8String], + -1); break; - } case WMATT_TOPMOST: result = Tcl_NewBooleanObj(wmPtr->flags & WM_TOPMOST); break; @@ -1009,7 +1229,7 @@ WmGetAttribute( } return result; } - + /* *---------------------------------------------------------------------- * @@ -1036,7 +1256,7 @@ WmAttributesCmd( Tcl_Obj *const objv[]) /* Argument objects. */ { int attribute = 0; - WindowRef macWindow; + NSWindow *macWindow; if (winPtr->window == None) { Tk_MakeWindowExist((Tk_Window) winPtr); @@ -1081,7 +1301,7 @@ WmAttributesCmd( } return TCL_OK; } - + /* *---------------------------------------------------------------------- * @@ -1136,7 +1356,7 @@ WmClientCmd( strcpy(wmPtr->clientMachine, argv3); return TCL_OK; } - + /* *---------------------------------------------------------------------- * @@ -1224,7 +1444,7 @@ WmColormapwindowsCmd( return TCL_OK; } - + /* *---------------------------------------------------------------------- * @@ -1285,7 +1505,7 @@ WmCommandCmd( wmPtr->cmdArgv = cmdArgv; return TCL_OK; } - + /* *---------------------------------------------------------------------- * @@ -1331,7 +1551,7 @@ WmDeiconifyCmd( ZoomState : NormalState); return TCL_OK; } - + /* *---------------------------------------------------------------------- * @@ -1385,7 +1605,7 @@ WmFocusmodelCmd( } return TCL_OK; } - + /* *---------------------------------------------------------------------- * @@ -1447,7 +1667,7 @@ WmForgetCmd( return TCL_OK; #endif } - + /* *---------------------------------------------------------------------- * @@ -1489,7 +1709,7 @@ WmFrameCmd( Tcl_SetResult(interp, buf, TCL_VOLATILE); return TCL_OK; } - + /* *---------------------------------------------------------------------- * @@ -1552,7 +1772,7 @@ WmGeometryCmd( } return ParseGeometry(interp, argv3, winPtr); } - + /* *---------------------------------------------------------------------- * @@ -1642,7 +1862,7 @@ WmGridCmd( WmUpdateGeom(wmPtr, winPtr); return TCL_OK; } - + /* *---------------------------------------------------------------------- * @@ -1705,7 +1925,7 @@ WmGroupCmd( } return TCL_OK; } - + /* *---------------------------------------------------------------------- * @@ -1773,7 +1993,7 @@ WmIconbitmapCmd( } return TCL_OK; } - + /* *---------------------------------------------------------------------- * @@ -1827,7 +2047,7 @@ WmIconifyCmd( TkpWmSetState(winPtr, IconicState); return TCL_OK; } - + /* *---------------------------------------------------------------------- * @@ -1884,7 +2104,7 @@ WmIconmaskCmd( } return TCL_OK; } - + /* *---------------------------------------------------------------------- * @@ -1936,7 +2156,7 @@ WmIconnameCmd( } return TCL_OK; } - + /* *---------------------------------------------------------------------- * @@ -2002,7 +2222,7 @@ WmIconphotoCmd( return TCL_OK; } - + /* *---------------------------------------------------------------------- * @@ -2058,7 +2278,7 @@ WmIconpositionCmd( } return TCL_OK; } - + /* *---------------------------------------------------------------------- * @@ -2141,7 +2361,7 @@ WmIconwindowCmd( } return TCL_OK; } - + /* *---------------------------------------------------------------------- * @@ -2209,7 +2429,7 @@ WmManageCmd( return TCL_OK; #endif } - + /* *---------------------------------------------------------------------- * @@ -2260,7 +2480,7 @@ WmMaxsizeCmd( WmUpdateGeom(wmPtr, winPtr); return TCL_OK; } - + /* *---------------------------------------------------------------------- * @@ -2311,7 +2531,7 @@ WmMinsizeCmd( WmUpdateGeom(wmPtr, winPtr); return TCL_OK; } - + /* *---------------------------------------------------------------------- * @@ -2357,7 +2577,7 @@ WmOverrideredirectCmd( ApplyMasterOverrideChanges(winPtr, NULL); return TCL_OK; } - + /* *---------------------------------------------------------------------- * @@ -2421,7 +2641,7 @@ WmPositionfromCmd( WmUpdateGeom(wmPtr, winPtr); return TCL_OK; } - + /* *---------------------------------------------------------------------- * @@ -2513,7 +2733,7 @@ WmProtocolCmd( } return TCL_OK; } - + /* *---------------------------------------------------------------------- * @@ -2541,7 +2761,8 @@ WmResizableCmd( { register WmInfo *wmPtr = winPtr->wmInfoPtr; int width, height; - WindowAttributes oldAttributes = wmPtr->attributes; + UInt64 oldAttributes = wmPtr->attributes; + int oldFlags = wmPtr->flags; if ((objc != 3) && (objc != 5)) { Tcl_WrongNumArgs(interp, 2, objv, "window ?width height?"); @@ -2585,11 +2806,10 @@ WmResizableCmd( wmPtr->scrollWinPtr->instanceData); } WmUpdateGeom(wmPtr, winPtr); - ApplyWindowClassAttributeChanges(winPtr, NULL, wmPtr->macClass, - oldAttributes, 1); + ApplyWindowAttributeFlagChanges(winPtr, NULL, oldAttributes, oldFlags, 1,0); return TCL_OK; } - + /* *---------------------------------------------------------------------- * @@ -2654,7 +2874,7 @@ WmSizefromCmd( WmUpdateGeom(wmPtr, winPtr); return TCL_OK; } - + /* *---------------------------------------------------------------------- * @@ -2772,7 +2992,7 @@ WmStackorderCmd( } return TCL_OK; } - + /* *---------------------------------------------------------------------- * @@ -2876,7 +3096,7 @@ WmStateCmd( } return TCL_OK; } - + /* *---------------------------------------------------------------------- * @@ -2922,7 +3142,7 @@ WmTitleCmd( } return TCL_OK; } - + /* *---------------------------------------------------------------------- * @@ -2951,7 +3171,7 @@ WmTransientCmd( register WmInfo *wmPtr = winPtr->wmInfoPtr; Tk_Window master; WmInfo *wmPtr2; - char *argv3; + char *masterWindowName; int length; if ((objc != 3) && (objc != 4)) { @@ -2999,18 +3219,18 @@ WmTransientCmd( return TCL_ERROR; } - argv3 = Tcl_GetStringFromObj(objv[3], &length); wmPtr->master = Tk_WindowId(master); + masterWindowName = Tcl_GetStringFromObj(objv[3], &length); if (wmPtr->masterWindowName != NULL) { ckfree(wmPtr->masterWindowName); } wmPtr->masterWindowName = ckalloc((unsigned) length+1); - strcpy(wmPtr->masterWindowName, argv3); + strcpy(wmPtr->masterWindowName, masterWindowName); } ApplyMasterOverrideChanges(winPtr, NULL); return TCL_OK; } - + /* *---------------------------------------------------------------------- * @@ -3066,7 +3286,7 @@ WmUpdateGeom( wmPtr->flags |= WM_UPDATE_PENDING; } } - + /* *---------------------------------------------------------------------- * @@ -3172,7 +3392,7 @@ Tk_SetGrid( wmPtr->flags |= WM_UPDATE_PENDING; } } - + /* *---------------------------------------------------------------------- * @@ -3229,7 +3449,7 @@ Tk_UnsetGrid( wmPtr->flags |= WM_UPDATE_PENDING; } } - + /* *---------------------------------------------------------------------- * @@ -3279,7 +3499,7 @@ TopLevelEventProc( Tcl_Panic("recieved unwanted reparent event"); } } - + /* *---------------------------------------------------------------------- * @@ -3314,7 +3534,7 @@ TopLevelReqProc( wmPtr->flags |= WM_UPDATE_PENDING; } } - + /* *---------------------------------------------------------------------- * @@ -3514,9 +3734,10 @@ UpdateGeometryInfo( TkMacOSXDbgMsg("Moving to %d %d, resizing to %d x %d", x, y, width, height); } + SetWindowSizeLimits(winPtr); wmPtr->flags |= WM_SYNC_PENDING; XMoveResizeWindow(winPtr->display, winPtr->window, x, y, - (unsigned) width, (unsigned) height); + wmPtr->configWidth, wmPtr->configHeight); wmPtr->flags &= ~WM_SYNC_PENDING; } else if ((width != wmPtr->configWidth) || (height != wmPtr->configHeight)) { @@ -3525,13 +3746,16 @@ UpdateGeometryInfo( if (wmTracing) { TkMacOSXDbgMsg("Resizing to %d x %d\n", width, height); } + SetWindowSizeLimits(winPtr); wmPtr->flags |= WM_SYNC_PENDING; - XResizeWindow(winPtr->display, winPtr->window, (unsigned) width, - (unsigned) height); + XResizeWindow(winPtr->display, winPtr->window, wmPtr->configWidth, + wmPtr->configHeight); wmPtr->flags &= ~WM_SYNC_PENDING; + } else { + SetWindowSizeLimits(winPtr); } } - + /* *---------------------------------------------------------------------- * @@ -3557,7 +3781,7 @@ UpdateSizeHints( wmPtr->flags &= ~WM_UPDATE_SIZE_HINTS; } - + /* *---------------------------------------------------------------------- * @@ -3698,7 +3922,7 @@ ParseGeometry( Tcl_AppendResult(interp, "bad geometry specifier \"", string, "\"", NULL); return TCL_ERROR; } - + /* *---------------------------------------------------------------------- * @@ -3794,7 +4018,7 @@ Tk_GetRootCoords( *xPtr = x; *yPtr = y; } - + /* *---------------------------------------------------------------------- * @@ -3825,30 +4049,18 @@ Tk_CoordsToWindow( Tk_Window tkwin) /* Token for any window in application; used * to identify the display. */ { - WindowPtr whichWin; - Point where; - Window rootChild; TkWindow *winPtr, *childPtr; TkWindow *nextPtr; /* Coordinates of highest child found so far * that contains point. */ int x, y; /* Coordinates in winPtr. */ int tmpx, tmpy, bd; - TkDisplay *dispPtr; /* * Step 1: find the top-level window that contains the desired point. */ - where.h = rootX; - where.v = rootY; - FindWindow(where, &whichWin); - if (whichWin == NULL) { - return NULL; - } - rootChild = TkMacOSXGetXWindow(whichWin); - dispPtr = TkGetDisplayList(); - winPtr = (TkWindow *) Tk_IdToWindow(dispPtr->display, rootChild); - if (winPtr == NULL) { + winPtr = FrontWindowAtPoint(rootX, rootY); + if (!winPtr) { return NULL; } @@ -3914,7 +4126,7 @@ Tk_CoordsToWindow( } return (Tk_Window) winPtr; } - + /* *---------------------------------------------------------------------- * @@ -4007,7 +4219,7 @@ Tk_TopCoordsToWindow( *newY = y; return (Tk_Window) winPtr; } - + /* *---------------------------------------------------------------------- * @@ -4074,7 +4286,7 @@ UpdateVRootGeometry( goto noVRoot; } } - + /* *---------------------------------------------------------------------- * @@ -4131,7 +4343,7 @@ Tk_GetVRootGeometry( *widthPtr = wmPtr->vRootWidth; *heightPtr = wmPtr->vRootHeight; } - + /* *---------------------------------------------------------------------- * @@ -4185,7 +4397,7 @@ Tk_MoveToplevelWindow( UpdateGeometryInfo(winPtr); } } - + /* *---------------------------------------------------------------------- * @@ -4213,11 +4425,8 @@ TkWmRestackToplevel( * NULL, then winPtr gets restacked above or * below *all* siblings. */ { - WmInfo *wmPtr; - - WindowRef macWindow, otherMacWindow, frontWindow, tmpWindow; - - wmPtr = winPtr->wmInfoPtr; + NSWindow *macWindow; + NSInteger otherMacWindowNumber; /* * Get the mac window. Make sure it exists & is mapped. @@ -4248,58 +4457,15 @@ TkWmRestackToplevel( if (otherPtr->wmInfoPtr->flags & WM_NEVER_MAPPED) { TkWmMapWindow(otherPtr); } - otherMacWindow = TkMacOSXDrawableWindow(otherPtr->window); + otherMacWindowNumber = [TkMacOSXDrawableWindow(otherPtr->window) + windowNumber]; } else { - otherMacWindow = NULL; - } - - frontWindow = ActiveNonFloatingWindow(); - - if (aboveBelow == Above) { - if (macWindow == frontWindow) { - /* - * Do nothing - it's already at the top. - */ - } else if (otherMacWindow == frontWindow || otherMacWindow == NULL) { - /* - * Raise the window to the top. If the window is visible then we - * also make it the active window. - */ - - if (wmPtr->hints.initial_state == WithdrawnState) { - BringToFront(macWindow); - } else { - SelectWindow(macWindow); - } - } else { - /* - * Find the window to be above. (Front window will actually be the - * window to be behind.) Front window is NULL if no other windows. - */ - - while (frontWindow != NULL && - (tmpWindow=GetNextWindow(frontWindow)) != otherMacWindow) { - frontWindow = tmpWindow; - } - if (frontWindow != NULL) { - SendBehind(macWindow, frontWindow); - } - } - } else { - /* - * Send behind. If it was in front find another window to make active. - */ - - if (macWindow == frontWindow) { - tmpWindow = GetNextWindow(macWindow); - if (tmpWindow != NULL) { - SelectWindow(tmpWindow); - } - } - SendBehind(macWindow, otherMacWindow); + otherMacWindowNumber = 0; } + [macWindow orderWindow:(aboveBelow == Above ? NSWindowAbove : NSWindowBelow) + relativeTo:otherMacWindowNumber]; } - + /* *---------------------------------------------------------------------- * @@ -4390,7 +4556,7 @@ TkWmAddToColormapWindows( * we don't support colormaps. If we did they would be installed here. */ } - + /* *---------------------------------------------------------------------- * @@ -4459,7 +4625,7 @@ TkWmRemoveFromColormapWindows( } } } - + /* *---------------------------------------------------------------------- * @@ -4487,7 +4653,7 @@ TkGetPointerCoords( { XQueryPointer(NULL, None, NULL, NULL, xPtr, yPtr, NULL, NULL, NULL); } - + /* *---------------------------------------------------------------------- * @@ -4499,7 +4665,7 @@ TkGetPointerCoords( * monitor of the Mac. * * Results: - * The bounds are returned in geometry. + * Window bounds. * * Side effects: * None. @@ -4507,46 +4673,27 @@ TkGetPointerCoords( *---------------------------------------------------------------------- */ -static void +static NSRect InitialWindowBounds( TkWindow *winPtr, /* Window to get initial bounds for. */ - WindowRef macWindow, - Rect *geometry) /* On return the initial bounds. */ + NSWindow *macWindow) { WmInfo *wmPtr = winPtr->wmInfoPtr; if (!(wmPtr->sizeHintsFlags & (USPosition | PPosition))) { - WindowRef parent; + static NSPoint cascadePoint = { .x = 0, .y = 0 }; + NSRect frame; - parent = GetFrontWindowOfClass(wmPtr->macClass, false); - if (parent && parent == macWindow) { - parent = GetNextWindowOfClass(parent, wmPtr->macClass, false); - } - if (parent && parent != macWindow) { - Rect bounds; - - ChkErr(RepositionWindow, macWindow, parent, - kWindowCascadeOnParentWindowScreen); - ChkErr(GetWindowBounds, macWindow, kWindowStructureRgn, &bounds); - wmPtr->x = bounds.left; - wmPtr->y = bounds.top; - } else { - static SInt16 menuBarHeight = 0; - - if (!menuBarHeight) { - ChkErr(GetThemeMenuBarHeight, &menuBarHeight); - } - wmPtr->x = 5; - wmPtr->y = menuBarHeight + 5; - } + cascadePoint = [macWindow cascadeTopLeftFromPoint:cascadePoint]; + frame = [macWindow frame]; + wmPtr->x = frame.origin.x; + wmPtr->y = tkMacOSXZeroScreenHeight - (frame.origin.y + + frame.size.height); } - - geometry->left = wmPtr->x; - geometry->top = wmPtr->y; - geometry->right = wmPtr->x + winPtr->changes.width; - geometry->bottom = wmPtr->y + winPtr->changes.height; + return NSMakeRect(wmPtr->x, wmPtr->y, winPtr->changes.width, + winPtr->changes.height); } - + /* *---------------------------------------------------------------------- * @@ -4586,7 +4733,7 @@ TkMacOSXResizable( return true; } } - + /* *---------------------------------------------------------------------- * @@ -4608,107 +4755,12 @@ TkMacOSXResizable( int TkMacOSXGrowToplevel( - WindowRef whichWindow, - Point start) + void *whichWindow, + XPoint start) { - Point where = start; - TkDisplay *dispPtr; - Rect portRect; - CGrafPtr destPort = GetWindowPort(whichWindow); - - QDGlobalToLocalPoint(destPort, &where); - GetPortBounds(destPort, &portRect); - if (where.h > (portRect.right - 16) && - where.v > (portRect.bottom - 16)) { - Window window; - TkWindow *winPtr; - WmInfo *wmPtr; - int minWidth, minHeight, maxWidth, maxHeight; - Rect limits, bounds, *maxBounds; - Boolean resizeResult; - - window = TkMacOSXGetXWindow(whichWindow); - dispPtr = TkGetDisplayList(); - winPtr = (TkWindow *) Tk_IdToWindow(dispPtr->display, window); - wmPtr = winPtr->wmInfoPtr; - maxBounds = (Rect*)(dispPtr->display->screens->ext_data); - - if ((wmPtr->flags & WM_WIDTH_NOT_RESIZABLE) && - (wmPtr->flags & WM_HEIGHT_NOT_RESIZABLE)) { - return false; - } - GetMinSize(winPtr, &minWidth, &minHeight); - GetMaxSize(winPtr, &maxWidth, &maxHeight); - if (wmPtr->gridWin != NULL) { - int base = winPtr->reqWidth - (wmPtr->reqGridWidth - * wmPtr->widthInc); - - if (base < 0) { - base = 0; - } - limits.left = base + (minWidth * wmPtr->widthInc); - limits.right = base + (maxWidth * wmPtr->widthInc); - base = winPtr->reqHeight - (wmPtr->reqGridHeight - * wmPtr->heightInc); - if (base < 0) { - base = 0; - } - limits.top = base + (minHeight * wmPtr->heightInc); - limits.bottom = base + (maxHeight * wmPtr->heightInc); - } else { - limits.left = minWidth; - limits.right = maxWidth; - limits.top = minHeight; - limits.bottom = maxHeight; - } - if (wmPtr->flags & WM_WIDTH_NOT_RESIZABLE) { - limits.left = limits.right = winPtr->changes.width; - } - if (wmPtr->flags & WM_HEIGHT_NOT_RESIZABLE) { - limits.top = limits.bottom = winPtr->changes.height; - } - if (PtInRect(start, maxBounds)) { - Rect strBounds, strWidths, limitBounds; - - ChkErr(GetWindowBounds, whichWindow, kWindowStructureRgn, - &strBounds); - ChkErr(GetWindowStructureWidths, whichWindow, &strWidths); - - limitBounds.left = limits.left + (strBounds.left + strWidths.left); - limitBounds.right = limits.right + - (strBounds.left + strWidths.left + strWidths.right); - limitBounds.top = limits.top + (strBounds.top + strWidths.top); - limitBounds.bottom = limits.bottom + - (strBounds.top + strWidths.top + strWidths.bottom); - if (limitBounds.left < maxBounds->left) { - limitBounds.left = maxBounds->left; - } - if (limitBounds.right > maxBounds->right) { - limitBounds.right = maxBounds->right; - } - if (limitBounds.top < maxBounds->top) { - limitBounds.top = maxBounds->top; - } - if (limitBounds.bottom > maxBounds->bottom) { - limitBounds.bottom = maxBounds->bottom; - } - limits.left = limitBounds.left - (strBounds.left + strWidths.left); - limits.right = limitBounds.right - - (strBounds.left + strWidths.left + strWidths.right); - limits.top = limitBounds.top - (strBounds.top + strWidths.top); - limits.bottom = limitBounds.bottom - - (strBounds.top + strWidths.top + strWidths.bottom); - } - TkMacOSXTrackingLoop(1); - resizeResult = ResizeWindow(whichWindow, start, &limits, &bounds); - TkMacOSXTrackingLoop(0); - if (resizeResult) { - return true; - } - } return false; } - + /* *---------------------------------------------------------------------- * @@ -4731,22 +4783,15 @@ TkSetWMName( TkWindow *winPtr, Tk_Uid titleUid) { - CFStringRef title; - if (Tk_IsEmbedded(winPtr)) { return; } - title = CFStringCreateWithBytes(NULL, (const unsigned char *) titleUid, - strlen(titleUid), kCFStringEncodingUTF8, false); - if (title) { - WindowRef macWin = TkMacOSXDrawableWindow(winPtr->window); - - SetWindowTitleWithCFString(macWin, title); - CFRelease(title); - } + NSString *title = [[NSString alloc] initWithUTF8String:titleUid]; + [TkMacOSXDrawableWindow(winPtr->window) setTitle:title]; + [title release]; } - + /* *---------------------------------------------------------------------- * @@ -4773,13 +4818,13 @@ TkGetTransientMaster( } return None; } - + /* *---------------------------------------------------------------------- * * TkMacOSXGetXWindow -- * - * Returns the X window Id associated with the given WindowRef. + * Returns the X window Id associated with the given NSWindow*. * * Results: * The window id is returned. None is returned if not a Tk window. @@ -4792,20 +4837,47 @@ TkGetTransientMaster( Window TkMacOSXGetXWindow( - WindowRef macWinPtr) + void *macWinPtr) { Tcl_HashEntry *hPtr; - if ((macWinPtr == NULL) || !windowHashInit) { + if (!macWinPtr || !windowHashInit) { return None; } - hPtr = Tcl_FindHashEntry(&windowTable, (char *) macWinPtr); + hPtr = Tcl_FindHashEntry(&windowTable, macWinPtr); if (hPtr == NULL) { return None; } return (Window) Tcl_GetHashValue(hPtr); } + +/* + *---------------------------------------------------------------------- + * + * TkMacOSXGetTkWindow -- + * + * Returns the TkWindow* associated with the given NSWindow*. + * + * Results: + * The TkWindow* returned. NULL is returned if not a Tk window. + * + * Side effects: + * None. + * + *---------------------------------------------------------------------- + */ + +TkWindow* +TkMacOSXGetTkWindow( + NSWindow *w) +{ + Window window = TkMacOSXGetXWindow(w); + TkDisplay *dispPtr = TkGetDisplayList(); + return (window != None ? + (TkWindow *)Tk_IdToWindow(dispPtr->display, window) : NULL); +} + /* *---------------------------------------------------------------------- * @@ -4828,43 +4900,9 @@ MODULE_SCOPE int TkMacOSXIsWindowZoomed( TkWindow *winPtr) { - WmInfo *wmPtr = winPtr->wmInfoPtr; - int maxWidth, maxHeight; - Point idealSize; - - if ((wmPtr->flags & WM_WIDTH_NOT_RESIZABLE) && - (wmPtr->flags & WM_HEIGHT_NOT_RESIZABLE)) { - return false; - } - GetMaxSize(winPtr, &maxWidth, &maxHeight); - if (wmPtr->gridWin != NULL) { - int base = winPtr->reqWidth - (wmPtr->reqGridWidth * wmPtr->widthInc); - - if (base < 0) { - base = 0; - } - maxWidth = base + (maxWidth * wmPtr->widthInc); - base = winPtr->reqHeight - (wmPtr->reqGridHeight * wmPtr->heightInc); - if (base < 0) { - base = 0; - } - maxHeight = base + (maxHeight * wmPtr->heightInc); - } - if (wmPtr->flags & WM_WIDTH_NOT_RESIZABLE) { - idealSize.h = winPtr->changes.width; - } else { - idealSize.h = maxWidth; - } - if (wmPtr->flags & WM_HEIGHT_NOT_RESIZABLE) { - idealSize.v = winPtr->changes.height; - } else { - idealSize.v = maxHeight; - } - - return IsWindowInStandardState(TkMacOSXDrawableWindow(winPtr->window), - &idealSize, NULL); + return [TkMacOSXDrawableWindow(winPtr->window) isZoomed]; } - + /* *---------------------------------------------------------------------- * @@ -4886,69 +4924,35 @@ TkMacOSXIsWindowZoomed( int TkMacOSXZoomToplevel( - WindowRef whichWindow, /* The Macintosh window to zoom. */ + void *whichWindow, /* The Macintosh window to zoom. */ short zoomPart) /* Either inZoomIn or inZoomOut */ { - Window window; - TkDisplay *dispPtr; - TkWindow *winPtr; + NSWindow *window = whichWindow; + TkWindow *winPtr = TkMacOSXGetTkWindow(window); WmInfo *wmPtr; - Point idealSize; - int maxWidth, maxHeight; - OSStatus err; - window = TkMacOSXGetXWindow(whichWindow); - dispPtr = TkGetDisplayList(); - winPtr = (TkWindow *) Tk_IdToWindow(dispPtr->display, window); + if (!winPtr || !winPtr->wmInfoPtr) { + return false; + } wmPtr = winPtr->wmInfoPtr; - if ((wmPtr->flags & WM_WIDTH_NOT_RESIZABLE) && (wmPtr->flags & WM_HEIGHT_NOT_RESIZABLE)) { return false; } - GetMaxSize(winPtr, &maxWidth, &maxHeight); - if (wmPtr->gridWin != NULL) { - int base = winPtr->reqWidth - (wmPtr->reqGridWidth * wmPtr->widthInc); - - if (base < 0) { - base = 0; - } - maxWidth = base + (maxWidth * wmPtr->widthInc); - base = winPtr->reqHeight - (wmPtr->reqGridHeight * wmPtr->heightInc); - if (base < 0) { - base = 0; - } - maxHeight = base + (maxHeight * wmPtr->heightInc); - } - if (wmPtr->flags & WM_WIDTH_NOT_RESIZABLE) { - idealSize.h = winPtr->changes.width; - } else { - idealSize.h = maxWidth; - } - if (wmPtr->flags & WM_HEIGHT_NOT_RESIZABLE) { - idealSize.v = winPtr->changes.height; - } else { - idealSize.v = maxHeight; - } /* * Do nothing if already in desired zoom state. */ - if (!IsWindowInStandardState(whichWindow, &idealSize, NULL) == - (zoomPart == inZoomIn)) { - return false; - } - - err = ChkErr(ZoomWindowIdeal, whichWindow, zoomPart, &idealSize); - if (err != noErr) { + if (![window isZoomed] == (zoomPart == inZoomIn)) { return false; } + [window zoom:NSApp]; wmPtr->hints.initial_state = (zoomPart == inZoomIn ? NormalState : ZoomState); return true; } - + /* *---------------------------------------------------------------------- * @@ -5016,7 +5020,7 @@ TkUnsupported1ObjCmd( /* won't be reached */ return TCL_ERROR; } - + /* *---------------------------------------------------------------------- * @@ -5044,52 +5048,33 @@ WmWinStyle( { struct StrIntMap { const char *strValue; - UInt32 intValue; - }; - static const struct StrIntMap styleMap[] = { - { "documentProc", documentProc }, - { "noGrowDocProc", documentProc }, - { "dBoxProc", dBoxProc }, - { "plainDBox", plainDBox }, - { "altDBoxProc", altDBoxProc }, - { "movableDBoxProc", movableDBoxProc }, - { "zoomDocProc", zoomDocProc }, - { "zoomNoGrow", zoomNoGrow }, - { "floatProc", floatGrowProc }, - { "floatGrowProc", floatGrowProc }, - { "floatZoomProc", floatZoomGrowProc }, - { "floatZoomGrowProc", floatZoomGrowProc }, - { "floatSideProc", floatSideGrowProc }, - { "floatSideGrowProc", floatSideGrowProc }, - { "floatSideZoomProc", floatSideZoomGrowProc }, - { "floatSideZoomGrowProc", floatSideZoomGrowProc }, - { NULL, 0 } + UInt64 intValue; }; static const struct StrIntMap classMap[] = { - { "alert", kAlertWindowClass }, - { "moveableAlert", kMovableAlertWindowClass }, - { "modal", kModalWindowClass }, - { "moveableModal", kMovableModalWindowClass }, - { "floating", kFloatingWindowClass }, - { "document", kDocumentWindowClass }, - { "utility", kUtilityWindowClass }, - { "help", kHelpWindowClass }, - { "sheet", kSheetWindowClass }, - { "toolbar", kToolbarWindowClass }, - { "plain", kPlainWindowClass }, - { "overlay", kOverlayWindowClass }, - { "sheetAlert", kSheetAlertWindowClass }, - { "altPlain", kAltPlainWindowClass }, - { "simple", kSimpleWindowClass }, - { "drawer", kDrawerWindowClass }, - { NULL, 0 } + { "alert", kAlertWindowClass }, + { "moveableAlert", kMovableAlertWindowClass }, + { "modal", kModalWindowClass }, + { "moveableModal", kMovableModalWindowClass }, + { "floating", kFloatingWindowClass }, + { "document", kDocumentWindowClass }, + { "utility", kUtilityWindowClass }, + { "help", kHelpWindowClass }, + { "sheet", kSheetWindowClass }, + { "toolbar", kToolbarWindowClass }, + { "plain", kPlainWindowClass }, + { "overlay", kOverlayWindowClass }, + { "sheetAlert", kSheetAlertWindowClass }, + { "altPlain", kAltPlainWindowClass }, + { "simple", kSimpleWindowClass }, + { "drawer", kDrawerWindowClass }, + { NULL } }; static const struct StrIntMap compositeAttrMap[] = { - { "none", kWindowNoAttributes }, - { "standardDocument", kWindowStandardDocumentAttributes }, - { "standardFloating", kWindowStandardFloatingAttributes }, - { "fullZoom", kWindowFullZoomAttribute }, - { NULL, 0 } + { "none", kWindowNoAttributes }, + { "standardDocument", kWindowStandardDocumentAttributes }, + { "standardFloating", kWindowStandardFloatingAttributes }, + { "fullZoom", kWindowFullZoomAttribute }, + { NULL } }; static const struct StrIntMap attrMap[] = { { "closeBox", kWindowCloseBoxAttribute }, @@ -5115,110 +5100,102 @@ WmWinStyle( { "liveResize", kWindowLiveResizeAttribute }, { "ignoreClicks", kWindowIgnoreClicksAttribute }, { "noConstrain", kWindowNoConstrainAttribute }, - { NULL, 0 } + { "doesNotHide", tkWindowDoesNotHideAttribute }, + { "canJoinAllSpaces", tkCanJoinAllSpacesAttribute }, + { "moveToActiveSpace", tkMoveToActiveSpaceAttribute }, + { "nonActivating", tkNonactivatingPanelAttribute }, + { "hud", tkHUDWindowAttribute }, + { NULL } }; int index, i; WmInfo *wmPtr = winPtr->wmInfoPtr; if (objc == 3) { - if (wmPtr->style != -1) { - for (i = 0; styleMap[i].strValue != NULL; i++) { - if (wmPtr->style == (short) styleMap[i].intValue) { - Tcl_SetObjResult(interp, - Tcl_NewStringObj(styleMap[i].strValue, -1)); - return TCL_OK; - } - } - Tcl_Panic("invalid style"); - } else { - Tcl_Obj *attributeList, *newResult = NULL; - WindowAttributes attributes; + Tcl_Obj *attributeList, *newResult = NULL; + UInt64 attributes; - for (i = 0; classMap[i].strValue != NULL; i++) { - if (wmPtr->macClass == classMap[i].intValue) { - newResult = Tcl_NewStringObj(classMap[i].strValue, -1); - break; - } - } - if (newResult == NULL) { - Tcl_Panic("invalid class"); + for (i = 0; classMap[i].strValue != NULL; i++) { + if (wmPtr->macClass == classMap[i].intValue) { + newResult = Tcl_NewStringObj(classMap[i].strValue, -1); + break; } + } + if (newResult == NULL) { + Tcl_Panic("invalid class"); + } - attributeList = Tcl_NewListObj(0, NULL); - attributes = wmPtr->attributes; + attributeList = Tcl_NewListObj(0, NULL); + attributes = wmPtr->attributes; - for (i = 0; compositeAttrMap[i].strValue != NULL; i++) { - UInt32 intValue = compositeAttrMap[i].intValue; + for (i = 0; compositeAttrMap[i].strValue != NULL; i++) { + UInt64 intValue = compositeAttrMap[i].intValue; - if (intValue && (attributes & intValue) == intValue) { - Tcl_ListObjAppendElement(interp, attributeList, - Tcl_NewStringObj(compositeAttrMap[i].strValue, - -1)); - attributes &= ~intValue; - break; - } - } - for (i = 0; attrMap[i].strValue != NULL; i++) { - if (attributes & attrMap[i].intValue) { - Tcl_ListObjAppendElement(interp, attributeList, - Tcl_NewStringObj(attrMap[i].strValue, -1)); - } + if (intValue && (attributes & intValue) == intValue) { + Tcl_ListObjAppendElement(interp, attributeList, + Tcl_NewStringObj(compositeAttrMap[i].strValue, + -1)); + attributes &= ~intValue; + break; } - Tcl_ListObjAppendElement(interp, newResult, attributeList); - Tcl_SetObjResult(interp, newResult); } - } else if (objc == 4) { - if (Tcl_GetIndexFromObjStruct(interp, objv[3], styleMap, - sizeof(struct StrIntMap), "style", 0, &index) != TCL_OK) { - return TCL_ERROR; + for (i = 0; attrMap[i].strValue != NULL; i++) { + if (attributes & attrMap[i].intValue) { + Tcl_ListObjAppendElement(interp, attributeList, + Tcl_NewStringObj(attrMap[i].strValue, -1)); + } } - wmPtr->style = styleMap[index].intValue; - } else if (objc == 5) { + Tcl_ListObjAppendElement(interp, newResult, attributeList); + Tcl_SetObjResult(interp, newResult); + } else { int attrObjc; Tcl_Obj **attrObjv = NULL; - WindowClass oldClass = wmPtr->macClass; - WindowAttributes oldAttributes = wmPtr->attributes; + WindowClass macClass; + UInt64 oldAttributes = wmPtr->attributes; + int oldFlags = wmPtr->flags; if (Tcl_GetIndexFromObjStruct(interp, objv[3], classMap, sizeof(struct StrIntMap), "class", 0, &index) != TCL_OK) { goto badClassAttrs; } - wmPtr->macClass = classMap[index].intValue; - if (!IsValidWindowClass(wmPtr->macClass)) { - goto badClassAttrs; - } - if (Tcl_ListObjGetElements(interp, objv[4], &attrObjc, &attrObjv) - != TCL_OK) { - goto badClassAttrs; - } - wmPtr->attributes = kWindowNoAttributes; - for (i = 0; i < attrObjc; i++) { - if (Tcl_GetIndexFromObjStruct(interp, attrObjv[i], - compositeAttrMap, sizeof(struct StrIntMap), - "attribute", 0, &index) == TCL_OK) { - wmPtr->attributes |= compositeAttrMap[index].intValue; - } else if (Tcl_GetIndexFromObjStruct(interp, attrObjv[i], - attrMap, sizeof(struct StrIntMap), - "attribute", 0, &index) == TCL_OK) { - Tcl_ResetResult(interp); - wmPtr->attributes |= attrMap[index].intValue; - } else { + macClass = classMap[index].intValue; + if (objc == 5) { + if (Tcl_ListObjGetElements(interp, objv[4], &attrObjc, &attrObjv) + != TCL_OK) { goto badClassAttrs; } - } - ApplyWindowClassAttributeChanges(winPtr, NULL, oldClass, oldAttributes, - 0); - wmPtr->style = -1; + wmPtr->attributes = kWindowNoAttributes; + for (i = 0; i < attrObjc; i++) { + if (Tcl_GetIndexFromObjStruct(interp, attrObjv[i], + compositeAttrMap, sizeof(struct StrIntMap), + "attribute", 0, &index) == TCL_OK) { + wmPtr->attributes |= compositeAttrMap[index].intValue; + } else if (Tcl_GetIndexFromObjStruct(interp, attrObjv[i], + attrMap, sizeof(struct StrIntMap), + "attribute", 0, &index) == TCL_OK) { + Tcl_ResetResult(interp); + wmPtr->attributes |= attrMap[index].intValue; + } else { + goto badClassAttrs; + } + } + } else { + wmPtr->attributes = macClassAttrs[macClass].defaultAttrs; + } + wmPtr->attributes &= (tkAlwaysValidAttributes | + macClassAttrs[macClass].validAttrs); + wmPtr->flags |= macClassAttrs[macClass].flags; + wmPtr->macClass = macClass; + ApplyWindowAttributeFlagChanges(winPtr, NULL, oldAttributes, oldFlags, + 0, 1); return TCL_OK; badClassAttrs: - wmPtr->macClass = oldClass; wmPtr->attributes = oldAttributes; return TCL_ERROR; } return TCL_OK; } - + /* *---------------------------------------------------------------------- * @@ -5256,7 +5233,7 @@ TkpMakeMenuWindow( winPtr->wmInfoPtr->flags |= WM_HEIGHT_NOT_RESIZABLE; } } - + /* *---------------------------------------------------------------------- * @@ -5279,13 +5256,7 @@ TkMacOSXMakeRealWindowExist( TkWindow *winPtr) /* Tk window. */ { WmInfo *wmPtr = winPtr->wmInfoPtr; - WindowRef newWindow = NULL; - ControlRef rootControl = NULL; MacDrawable *macWin; - Rect initialBounds = {42, 0, 43, 1}, geometry, strWidths; - short structureW, structureH; - TkMacOSXWindowList *listPtr; - OSStatus err; if (TkMacOSXHostToplevelExists(winPtr)) { return; @@ -5323,91 +5294,69 @@ TkMacOSXMakeRealWindowExist( */ } - if (wmPtr->style == -1) { - if (!IsValidWindowClass(wmPtr->macClass)) { - TkMacOSXDbgMsg("Invalid window class: %ld", wmPtr->macClass); - wmPtr->macClass = kPlainWindowClass; - } - wmPtr->attributes = (wmPtr->attributes | kWindowAsyncDragAttribute) & - GetAvailableWindowAttributes(wmPtr->macClass); - err = ChkErr(CreateNewWindow, wmPtr->macClass, wmPtr->attributes, - &initialBounds, &newWindow); - if (err != noErr) { - newWindow = NULL; - } - } else { - TkMacOSXDbgMsg("Window creation via NewCWindow API is deprecated, " - "use a window class instead of style %d", wmPtr->style); - newWindow = NewCWindow(NULL, &initialBounds, "\p", false, - wmPtr->style, (WindowRef) -1, true, 0); - } - - if (newWindow == NULL) { + WindowClass macClass = wmPtr->macClass; + wmPtr->attributes &= (tkAlwaysValidAttributes | + macClassAttrs[macClass].validAttrs); + wmPtr->flags |= macClassAttrs[macClass].flags | + ((wmPtr->attributes & kWindowResizableAttribute) ? 0 : + WM_WIDTH_NOT_RESIZABLE|WM_HEIGHT_NOT_RESIZABLE); + UInt64 attributes = (wmPtr->attributes & + ~macClassAttrs[macClass].forceOffAttrs) | + macClassAttrs[macClass].forceOnAttrs; + NSUInteger styleMask = macClassAttrs[macClass].styleMask | + ((attributes & kWindowNoTitleBarAttribute) ? 0 : NSTitledWindowMask) | + ((attributes & kWindowCloseBoxAttribute) ? NSClosableWindowMask : 0) | + ((attributes & kWindowCollapseBoxAttribute) ? + NSMiniaturizableWindowMask : 0) | + ((attributes & kWindowResizableAttribute) ? NSResizableWindowMask : 0) | + ((attributes & kWindowMetalAttribute) ? + NSTexturedBackgroundWindowMask : 0) | + ((attributes & kWindowUnifiedTitleAndToolbarAttribute) ? + NSUnifiedTitleAndToolbarWindowMask : 0) | + ((attributes & kWindowSideTitlebarAttribute) ? 1 << 9 : 0) | + (attributes >> WM_NSMASK_SHIFT); + Class winClass = (macClass == kDrawerWindowClass ? [NSDrawerWindow class] : + (styleMask & (NSUtilityWindowMask|NSDocModalWindowMask| + NSNonactivatingPanelMask|NSHUDWindowMask)) ? [NSPanel class] : + [TKWindow class]); + NSRect structureRect = [winClass frameRectForContentRect:NSZeroRect + styleMask:styleMask]; + NSRect contentRect = NSMakeRect(5 - structureRect.origin.x, + tkMacOSXZeroScreenHeight - (tkMacOSXZeroScreenTop + 5 + + structureRect.origin.y + structureRect.size.height + 200), 200, 200); + NSWindow *window = [[winClass alloc] initWithContentRect:contentRect + styleMask:styleMask backing:NSBackingStoreBuffered defer:YES]; + if (!window) { Tcl_Panic("couldn't allocate new Mac window"); } - - ChkErr(GetWindowStructureWidths, newWindow, &strWidths); - if (wmPtr->macClass == kFloatingWindowClass) { - /* - * Workaround GetWindowStructureWidths() Carbon bug: - */ - - strWidths.top = 16; - } - wmPtr->xInParent = strWidths.left; - wmPtr->yInParent = strWidths.top; - structureW = strWidths.left + strWidths.right; - structureH = strWidths.top + strWidths.bottom; - wmPtr->parentWidth = winPtr->changes.width + structureW; - wmPtr->parentHeight = winPtr->changes.height + structureH; - InitialWindowBounds(winPtr, newWindow, &geometry); - geometry.right += structureW; - geometry.bottom += structureH; - ChkErr(SetWindowBounds, newWindow, kWindowStructureRgn, &geometry); - - TkMacOSXInstallWindowCarbonEventHandler(NULL, newWindow); - if (ChkErr(CreateRootControl, newWindow, &rootControl) != noErr ) { - Tcl_Panic("couldn't create root control for new Mac window"); - } - if (wmPtr->attributes & kWindowResizableAttribute) { - HIViewRef growBoxView; - - err = HIViewFindByID(HIViewGetRoot(newWindow), - kHIViewWindowGrowBoxID, &growBoxView); - if (err == noErr && !HIGrowBoxViewIsTransparent(growBoxView)) { - ChkErr(HIGrowBoxViewSetTransparent, growBoxView, true); - } - } - - /* - * Add this window to the list of toplevel windows. - */ - - listPtr = (TkMacOSXWindowList *) ckalloc(sizeof(TkMacOSXWindowList)); - listPtr->nextPtr = tkMacOSXWindowListPtr; - listPtr->winPtr = winPtr; - tkMacOSXWindowListPtr = listPtr; - - macWin->grafPtr = GetWindowPort(newWindow); - macWin->rootControl = rootControl; - - if (wmPtr->master != None || winPtr->atts.override_redirect) { - ApplyMasterOverrideChanges(winPtr, newWindow); - } - SetWindowModified(newWindow, false); - TkMacOSXRegisterOffScreenWindow((Window) macWin, (GWorldPtr) newWindow); + TkMacOSXMakeUncollectable(window); + TKContentView *contentView = [[TKContentView alloc] + initWithFrame:NSZeroRect]; + [window setContentView:contentView]; + [contentView release]; + [window setDelegate:NSApp]; + [window setAcceptsMouseMovedEvents:YES]; + [window setReleasedWhenClosed:NO]; + [window setAutodisplay:NO]; + if (styleMask & NSUtilityWindowMask) { + [(NSPanel*)window setFloatingPanel:YES]; + } + [window setDocumentEdited:NO]; + wmPtr->window = window; + macWin->view = contentView; + TkMacOSXApplyWindowAttributes(winPtr, window); + + NSRect geometry = InitialWindowBounds(winPtr, window); + geometry.size.width += structureRect.size.width; + geometry.size.height += structureRect.size.height; + geometry.origin.y = tkMacOSXZeroScreenHeight - (geometry.origin.y + + geometry.size.height); + [window setFrame:geometry display:NO]; + + TkMacOSXRegisterOffScreenWindow((Window) macWin, window); macWin->flags |= TK_HOST_EXISTS; - ChkErr(GetWindowClass, newWindow, &(wmPtr->macClass)); - ChkErr(GetWindowAttributes, newWindow, &(wmPtr->attributes)); - -#ifdef TK_MAC_DEBUG_WINDOWS - TkMacOSXInitNamedDebugSymbol(HIToolbox, void, DebugPrintWindow, WindowRef); - if (DebugPrintWindow) { - DebugPrintWindow(newWindow); - } -#endif /* TK_MAC_DEBUG_WINDOWS */ } - + /* *---------------------------------------------------------------------- * @@ -5428,7 +5377,7 @@ TkMacOSXMakeRealWindowExist( void TkMacOSXRegisterOffScreenWindow( Window window, /* Window structure. */ - GWorldPtr portPtr) /* Pointer to a Mac GWorld. */ + void *portPtr) /* Pointer to a Mac Window. */ { Tcl_HashEntry *valueHashPtr; int isNew; @@ -5443,7 +5392,7 @@ TkMacOSXRegisterOffScreenWindow( } Tcl_SetHashValue(valueHashPtr, window); } - + /* *---------------------------------------------------------------------- * @@ -5463,21 +5412,21 @@ TkMacOSXRegisterOffScreenWindow( void TkMacOSXUnregisterMacWindow( - WindowRef macWinPtr) /* Reference to a Mac Window */ + void *macWinPtr) /* Reference to a Mac Window */ { Tcl_HashEntry *entryPtr; if (!windowHashInit) { Tcl_Panic("TkMacOSXUnregisterMacWindow: unmapping before inited"); } - entryPtr = Tcl_FindHashEntry(&windowTable,(char *) macWinPtr); + entryPtr = Tcl_FindHashEntry(&windowTable, macWinPtr); if (!entryPtr) { - TkMacOSXDbgMsg("Failed to find window %08x", (int) macWinPtr); + TkMacOSXDbgMsg("Failed to find window %p", macWinPtr); } else { Tcl_DeleteHashEntry(entryPtr); } } - + /* *---------------------------------------------------------------------- * @@ -5509,7 +5458,7 @@ TkMacOSXSetScrollbarGrow( winPtr->privatePtr->toplevel->winPtr->wmInfoPtr->scrollWinPtr = NULL; } } - + /* *---------------------------------------------------------------------- * @@ -5542,7 +5491,7 @@ TkWmFocusToplevel( } return winPtr; } - + /* *---------------------------------------------------------------------- * @@ -5572,7 +5521,7 @@ TkpGetWrapperWindow( } return winPtr; } - + /* *---------------------------------------------------------------------- * @@ -5597,7 +5546,7 @@ TkpWmSetState( * or WithdrawnState. */ { WmInfo *wmPtr = winPtr->wmInfoPtr; - WindowRef macWin; + NSWindow *macWin; wmPtr->hints.initial_state = state; if (wmPtr->flags & WM_NEVER_MAPPED) { @@ -5614,25 +5563,22 @@ TkpWmSetState( * the window we also collapse it. */ - if (IsWindowCollapsable(macWin) && !IsWindowCollapsed(macWin)) { - CollapseWindow(macWin, true); + if (macWin && ([macWin styleMask] & NSMiniaturizableWindowMask) && + ![macWin isMiniaturized]) { + [macWin miniaturize:NSApp]; } Tk_UnmapWindow((Tk_Window) winPtr); - } else if (state == NormalState) { + } else if (state == NormalState || state == ZoomState) { Tk_MapWindow((Tk_Window) winPtr); - if (IsWindowCollapsable(macWin) && IsWindowCollapsed(macWin)) { - CollapseWindow(macWin, false); + if (macWin && ([macWin styleMask] & NSMiniaturizableWindowMask) && + [macWin isMiniaturized]) { + [macWin deminiaturize:NSApp]; } - TkMacOSXZoomToplevel(macWin, inZoomIn); - } else if (state == ZoomState) { - Tk_MapWindow((Tk_Window) winPtr); - if (IsWindowCollapsable(macWin) && IsWindowCollapsed(macWin)) { - CollapseWindow(macWin, false); - } - TkMacOSXZoomToplevel(macWin, inZoomOut); + TkMacOSXZoomToplevel(macWin, state == NormalState ? inZoomIn : + inZoomOut); } } - + /* *---------------------------------------------------------------------- * @@ -5651,18 +5597,11 @@ TkpWmSetState( int TkpIsWindowFloating( - WindowRef wRef) + void *wRef) { - WindowClass class; - - if (wRef == NULL) { - return 0; - } - - GetWindowClass(wRef, &class); - return (class == kFloatingWindowClass); + return [(NSWindow *)wRef level] == kCGFloatingWindowLevel; } - + /* *---------------------------------------------------------------------- * @@ -5685,7 +5624,7 @@ TkMacOSXWindowClass( { return winPtr->wmInfoPtr->macClass; } - + /* *-------------------------------------------------------------- * @@ -5706,21 +5645,21 @@ TkMacOSXWindowClass( void TkMacOSXWindowOffset( - WindowRef wRef, + void *wRef, int *xOffset, int *yOffset) { - Window window; - TkDisplay *dispPtr; - TkWindow *winPtr; + TkWindow *winPtr = TkMacOSXGetTkWindow(wRef); - window = TkMacOSXGetXWindow(wRef); - dispPtr = TkGetDisplayList(); - winPtr = (TkWindow *) Tk_IdToWindow(dispPtr->display, window); - *xOffset = winPtr->wmInfoPtr->xInParent; - *yOffset = winPtr->wmInfoPtr->yInParent; + if (winPtr && winPtr->wmInfoPtr) { + *xOffset = winPtr->wmInfoPtr->xInParent; + *yOffset = winPtr->wmInfoPtr->yInParent; + } else { + *xOffset = 0; + *yOffset = 0; + } } - + /* *---------------------------------------------------------------------- * @@ -5746,7 +5685,7 @@ TkpGetMS(void) Tcl_GetTime(&now); return (long) now.sec * 1000 + now.usec / 1000; } - + /* *---------------------------------------------------------------------- * @@ -5774,7 +5713,7 @@ XSetInputFocus( * Don't need to do a thing. Tk manages the focus for us. */ } - + /* *---------------------------------------------------------------------- * @@ -5820,7 +5759,7 @@ TkpChangeFocus( return NextRequest(winPtr->display); } - + /* *---------------------------------------------------------------------- * @@ -5850,15 +5789,12 @@ WmStackorderToplevelWrapperMap( { TkWindow *childPtr; Tcl_HashEntry *hPtr; - WindowRef macWindow; int newEntry; if (Tk_IsMapped(winPtr) && Tk_IsTopLevel(winPtr) && (winPtr->display == display)) { - macWindow = TkMacOSXDrawableWindow(winPtr->window); - hPtr = Tcl_CreateHashEntry(table, - (const char *) macWindow, &newEntry); + (char*) TkMacOSXDrawableWindow(winPtr->window), &newEntry); Tcl_SetHashValue(hPtr, winPtr); } @@ -5867,7 +5803,7 @@ WmStackorderToplevelWrapperMap( WmStackorderToplevelWrapperMap(childPtr, display, table); } } - + /* *---------------------------------------------------------------------- * @@ -5889,11 +5825,12 @@ TkWindow ** TkWmStackorderToplevel( TkWindow *parentPtr) /* Parent toplevel window. */ { - WindowRef frontWindow; TkWindow *childWinPtr, **windows, **window_ptr; Tcl_HashTable table; Tcl_HashEntry *hPtr; Tcl_HashSearch search; + NSInteger windowCount; + NSInteger *windowNumbers; /* * Map mac windows to a TkWindow of the wrapped toplevel. @@ -5921,38 +5858,72 @@ TkWmStackorderToplevel( goto done; } - frontWindow = GetFrontWindowOfClass(kAllWindowClasses, false); - if (frontWindow == NULL) { + NSCountWindows(&windowCount); + if (!windowCount) { ckfree((char *) windows); windows = NULL; } else { window_ptr = windows + table.numEntries; *window_ptr-- = NULL; - while (frontWindow != NULL) { - hPtr = Tcl_FindHashEntry(&table, (char *) frontWindow); - if (hPtr != NULL) { - childWinPtr = Tcl_GetHashValue(hPtr); - *window_ptr-- = childWinPtr; + windowNumbers = (NSInteger *) ckalloc(windowCount * sizeof(NSInteger)); + NSWindowList(windowCount, windowNumbers); + for (NSInteger index = 0; index < windowCount; index++) { + NSWindow *w = [NSApp windowWithWindowNumber:windowNumbers[index]]; + + if (w) { + hPtr = Tcl_FindHashEntry(&table, (char*) w); + if (hPtr != NULL) { + childWinPtr = Tcl_GetHashValue(hPtr); + *window_ptr-- = childWinPtr; + } } - frontWindow = GetNextWindow(frontWindow); } if (window_ptr != (windows-1)) { Tcl_Panic("num matched toplevel windows does not equal num " "children"); } + ckfree((char *) windowNumbers); } done: Tcl_DeleteHashTable(&table); return windows; } + +/* + *---------------------------------------------------------------------- + * + * TkMacOSXApplyWindowAttributes -- + * + * This procedure applies all window attributes to the NSWindow. + * + * Results: + * None. + * + * Side effects: + * None. + * + *---------------------------------------------------------------------- + */ +void +TkMacOSXApplyWindowAttributes( + TkWindow *winPtr, + NSWindow *macWindow) +{ + WmInfo *wmPtr = winPtr->wmInfoPtr; + ApplyWindowAttributeFlagChanges(winPtr, macWindow, 0, 0, 0, 1); + if (wmPtr->master != None || winPtr->atts.override_redirect) { + ApplyMasterOverrideChanges(winPtr, macWindow); + } +} + /* *---------------------------------------------------------------------- * - * ApplyWindowClassAttributeChanges -- + * ApplyWindowAttributeFlagChanges -- * - * This procedure applies carbon window class and attribute changes. + * This procedure applies window attribute and flag changes. * * Results: * None. @@ -5964,20 +5935,20 @@ TkWmStackorderToplevel( */ static void -ApplyWindowClassAttributeChanges( +ApplyWindowAttributeFlagChanges( TkWindow *winPtr, - WindowRef macWindow, - WindowClass oldClass, - WindowAttributes oldAttributes, - int create) + NSWindow *macWindow, + UInt64 oldAttributes, + int oldFlags, + int create, + int initial) { WmInfo *wmPtr = winPtr->wmInfoPtr; - WindowAttributes newAttributes = wmPtr->attributes | - kWindowAsyncDragAttribute; - - if (wmPtr->macClass != oldClass || newAttributes != oldAttributes) { - Rect strWidths; + UInt64 newAttributes = ForceAttributes(wmPtr->attributes, wmPtr->macClass); + UInt64 changedAttributes = newAttributes ^ ForceAttributes(oldAttributes, + wmPtr->macClass); + if (changedAttributes || wmPtr->flags != oldFlags || initial) { if (!macWindow) { if (winPtr->window == None) { if (create) { @@ -5995,32 +5966,98 @@ ApplyWindowClassAttributeChanges( } macWindow = TkMacOSXDrawableWindow(winPtr->window); } - if (wmPtr->macClass != oldClass) { - TK_IF_MAC_OS_X_API (4, HIWindowChangeClass, - ChkErr(HIWindowChangeClass, macWindow, wmPtr->macClass); - ) TK_ENDIF - ChkErr(GetWindowClass, macWindow, &(wmPtr->macClass)); - } - if (newAttributes != oldAttributes) { - newAttributes &= GetAvailableWindowAttributes(wmPtr->macClass); - ChkErr(ChangeWindowAttributes, macWindow, - newAttributes & (newAttributes ^ oldAttributes), - oldAttributes & (newAttributes ^ oldAttributes)); - } - ChkErr(GetWindowAttributes, macWindow, &(wmPtr->attributes)); - if ((wmPtr->attributes ^ oldAttributes) & kWindowResizableAttribute) { - if (wmPtr->attributes & kWindowResizableAttribute) { - HIViewRef growBoxView; - OSStatus err = HIViewFindByID(HIViewGetRoot(macWindow), - kHIViewWindowGrowBoxID, &growBoxView); - - if (err == noErr && !HIGrowBoxViewIsTransparent(growBoxView)) { - ChkErr(HIGrowBoxViewSetTransparent, growBoxView, true); - } + if ((changedAttributes & kWindowCloseBoxAttribute) || initial) { + [[macWindow standardWindowButton:NSWindowCloseButton] + setEnabled:!!(newAttributes & kWindowCloseBoxAttribute)]; + } + if ((changedAttributes & kWindowCollapseBoxAttribute) || initial) { + [[macWindow standardWindowButton:NSWindowMiniaturizeButton] + setEnabled:!!(newAttributes & kWindowCollapseBoxAttribute)]; + } + if ((changedAttributes & (kWindowResizableAttribute | + kWindowFullZoomAttribute)) || initial) { + [macWindow setShowsResizeIndicator: + !!(newAttributes & kWindowResizableAttribute)]; + [[macWindow standardWindowButton:NSWindowZoomButton] + setEnabled:(newAttributes & kWindowResizableAttribute) && + (newAttributes & kWindowFullZoomAttribute)]; + if (newAttributes & kWindowResizableAttribute) { + wmPtr->flags &= ~(WM_WIDTH_NOT_RESIZABLE | + WM_HEIGHT_NOT_RESIZABLE); + } else { + wmPtr->flags |= (WM_WIDTH_NOT_RESIZABLE | + WM_HEIGHT_NOT_RESIZABLE); + } + WmUpdateGeom(wmPtr, winPtr); + } + if ((changedAttributes & kWindowToolbarButtonAttribute) || initial) { + [macWindow setShowsToolbarButton: + !!(newAttributes & kWindowToolbarButtonAttribute)]; + if ((newAttributes & kWindowToolbarButtonAttribute) && + ![macWindow toolbar]) { + NSToolbar *toolbar = [[NSToolbar alloc] initWithIdentifier:@""]; + [toolbar setVisible:NO]; + [macWindow setToolbar:toolbar]; + [toolbar release]; + NSCell *toolbarButtonCell = [[macWindow standardWindowButton: + NSWindowToolbarButton] cell]; + [toolbarButtonCell setTarget:[macWindow contentView]]; + [toolbarButtonCell setAction:@selector(tkToolbarButton:)]; } - TkMacOSXInvalClipRgns((Tk_Window) winPtr); - TkMacOSXInvalidateWindow((MacDrawable *) winPtr->window, - TK_PARENT_WINDOW); + } + if ((changedAttributes & kWindowNoShadowAttribute) || initial) { + [macWindow setHasShadow: + !(newAttributes & kWindowNoShadowAttribute)]; + } + if ((changedAttributes & kWindowHideOnSuspendAttribute) || initial) { + [macWindow setHidesOnDeactivate: + !!(newAttributes & kWindowHideOnSuspendAttribute)]; + } + if ((changedAttributes & kWindowInWindowMenuAttribute) || initial) { + [macWindow setExcludedFromWindowsMenu: + !(newAttributes & kWindowInWindowMenuAttribute)]; + } + if ((changedAttributes & kWindowIgnoreClicksAttribute) || initial) { + [macWindow setIgnoresMouseEvents: + !!(newAttributes & kWindowIgnoreClicksAttribute)]; + } + if ((changedAttributes & tkWindowDoesNotHideAttribute) || initial) { + [macWindow setCanHide: + !(newAttributes & tkWindowDoesNotHideAttribute)]; + } + if ((changedAttributes & (kWindowDoesNotCycleAttribute | + tkCanJoinAllSpacesAttribute | tkMoveToActiveSpaceAttribute)) || + initial) { + NSWindowCollectionBehavior b = NSWindowCollectionBehaviorDefault; + if (newAttributes & tkCanJoinAllSpacesAttribute) { + b |= NSWindowCollectionBehaviorCanJoinAllSpaces; + } else if (newAttributes & tkMoveToActiveSpaceAttribute) { + b |= NSWindowCollectionBehaviorMoveToActiveSpace; + } +#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1060 + if (newAttributes & kWindowDoesNotCycleAttribute) { + b |= NSWindowCollectionBehaviorIgnoresCycle; + } else { + b |= NSWindowCollectionBehaviorParticipatesInCycle; + } +#endif + [macWindow setCollectionBehavior:b]; +#if MAC_OS_X_VERSION_MIN_REQUIRED < 1060 + if (((changedAttributes & kWindowDoesNotCycleAttribute) || initial) +#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1060 + && tkMacOSXMacOSXVersion < 1060 +#endif + ) { + [macWindow setCanCycle: + !(newAttributes & kWindowDoesNotCycleAttribute)]; + } +#endif + } + if ((wmPtr->flags & WM_TOPMOST) != (oldFlags & WM_TOPMOST)) { + [macWindow setLevel:(wmPtr->flags & WM_TOPMOST) ? + kCGUtilityWindowLevel : ([macWindow isKindOfClass: + [NSPanel class]] && [macWindow isFloatingPanel] ? + kCGFloatingWindowLevel : kCGNormalWindowLevel)]; } /* @@ -6028,16 +6065,14 @@ ApplyWindowClassAttributeChanges( * structure widths: */ - GetWindowStructureWidths(macWindow, &strWidths); - wmPtr->xInParent = strWidths.left; - wmPtr->yInParent = strWidths.top; - wmPtr->parentWidth = winPtr->changes.width + strWidths.left - + strWidths.right; - wmPtr->parentHeight = winPtr->changes.height + strWidths.top - + strWidths.bottom; + NSRect structureRect = [macWindow frameRectForContentRect:NSZeroRect]; + wmPtr->xInParent = -structureRect.origin.x; + wmPtr->yInParent = structureRect.origin.y + structureRect.size.height; + wmPtr->parentWidth = winPtr->changes.width + structureRect.size.width; + wmPtr->parentHeight = winPtr->changes.height + structureRect.size.height; } } - + /* *---------------------------------------------------------------------- * @@ -6057,28 +6092,28 @@ ApplyWindowClassAttributeChanges( static void ApplyMasterOverrideChanges( TkWindow *winPtr, - WindowRef macWindow) + NSWindow *macWindow) { WmInfo *wmPtr = winPtr->wmInfoPtr; - WindowClass oldClass = wmPtr->macClass; - WindowAttributes oldAttributes = wmPtr->attributes; + UInt64 oldAttributes = wmPtr->attributes; + int oldFlags = wmPtr->flags; /* * FIX: We need an UpdateWrapper equivalent to make this 100% correct */ if (winPtr->atts.override_redirect) { - if (oldClass == kDocumentWindowClass) { + if (wmPtr->macClass == kDocumentWindowClass) { wmPtr->macClass = kSimpleWindowClass; - wmPtr->attributes = kWindowNoAttributes; + wmPtr->attributes = macClassAttrs[kSimpleWindowClass].defaultAttrs; } wmPtr->attributes |= kWindowNoActivatesAttribute; } else { - if (oldClass == kSimpleWindowClass && + if (wmPtr->macClass == kSimpleWindowClass && oldAttributes == kWindowNoActivatesAttribute) { wmPtr->macClass = kDocumentWindowClass; - wmPtr->attributes = kWindowStandardDocumentAttributes - | kWindowLiveResizeAttribute; + wmPtr->attributes = + macClassAttrs[kDocumentWindowClass].defaultAttrs; } wmPtr->attributes &= ~kWindowNoActivatesAttribute; } @@ -6087,77 +6122,42 @@ ApplyMasterOverrideChanges( macWindow = TkMacOSXDrawableWindow(winPtr->window); } if (macWindow) { - WindowGroupRef group; - - ApplyWindowClassAttributeChanges(winPtr, macWindow, oldClass, - oldAttributes, 0); - if (winPtr->atts.override_redirect && wmPtr->master != None) { wmPtr->flags |= WM_TOPMOST; } else { wmPtr->flags &= ~WM_TOPMOST; } - group = WmGetWindowGroup(winPtr); - if (group && group != GetWindowGroup(macWindow)) { - ChkErr(SetWindowGroup, macWindow, group); - } - } -} - -/* - *---------------------------------------------------------------------- - * - * WmGetWindowGroup -- - * - * Gets the window group a toplevel should be placed in. - * - * Results: - * A WindowGroupRef. - * - * Side effects: - * A transient window group for the master (if any) may be created. - * - *---------------------------------------------------------------------- - */ - -static WindowGroupRef -WmGetWindowGroup( - TkWindow *winPtr) -{ - WmInfo *wmPtr = winPtr->wmInfoPtr; - WindowGroupRef group = NULL; - - if (wmPtr->flags & WM_TOPMOST) { - group = GetWindowGroupOfClass(kUtilityWindowClass); - } else if (wmPtr->master != None) { - TkDisplay *dispPtr = TkGetDisplayList(); - TkWindow *masterWinPtr = (TkWindow *) - Tk_IdToWindow(dispPtr->display, wmPtr->master); - - if (masterWinPtr && masterWinPtr->window != None && - TkMacOSXHostToplevelExists(masterWinPtr)) { - WindowRef masterMacWin = - TkMacOSXDrawableWindow(masterWinPtr->window); - - if (masterMacWin && GetWindowProperty(masterMacWin, 'Tk ', 'TsGp', - sizeof(group), NULL, &group) != noErr) { - ChkErr(CreateWindowGroup, 0, &group); - if (group) { - ChkErr(SetWindowGroupParent, group, - GetWindowGroup(masterMacWin)); - ChkErr(SetWindowGroupOwner, group, masterMacWin); - ChkErr(SetWindowProperty, masterMacWin, 'Tk ', 'TsGp', - sizeof(group), &group); + NSWindow *parentWindow = [macWindow parentWindow]; + if (wmPtr->master != None) { + TkDisplay *dispPtr = TkGetDisplayList(); + TkWindow *masterWinPtr = (TkWindow *) + Tk_IdToWindow(dispPtr->display, wmPtr->master); + + if (masterWinPtr && masterWinPtr->window != None && + TkMacOSXHostToplevelExists(masterWinPtr)) { + NSWindow *masterMacWin = + TkMacOSXDrawableWindow(masterWinPtr->window); + + if (masterMacWin && masterMacWin != parentWindow && + (winPtr->flags & TK_MAPPED)) { + if (parentWindow) { + [parentWindow removeChildWindow:macWindow]; + } + [masterMacWin addChildWindow:macWindow + ordered:NSWindowAbove]; + if (wmPtr->flags & WM_TOPMOST) { + [macWindow setLevel:kCGUtilityWindowLevel]; + } } } + } else if (parentWindow) { + [parentWindow removeChildWindow:macWindow]; } + ApplyWindowAttributeFlagChanges(winPtr, macWindow, oldAttributes, + oldFlags, 0, 0); } - if (!group) { - group = GetWindowGroupOfClass(wmPtr->macClass); - } - return group; } - + /* *---------------------------------------------------------------------- * @@ -6177,7 +6177,7 @@ WmGetWindowGroup( int TkMacOSXMakeFullscreen( TkWindow *winPtr, - WindowRef window, + NSWindow *window, int fullscreen, Tcl_Interp *interp) { @@ -6203,21 +6203,19 @@ TkMacOSXMakeFullscreen( result = TCL_ERROR; wmPtr->flags &= ~WM_FULLSCREEN; } else { - Rect bounds, screenBounds = {0, 0, screenHeight, screenWidth}; - - ChkErr(GetWindowBounds, window, kWindowContentRgn, &bounds); - if (!EqualRect(&bounds, &screenBounds)) { - if (!wasFullscreen) { - wmPtr->configX = wmPtr->x; - wmPtr->configY = wmPtr->y; - wmPtr->configAttributes = wmPtr->attributes; - wmPtr->attributes &= ~kWindowResizableAttribute; - ApplyWindowClassAttributeChanges(winPtr, window, - wmPtr->macClass, wmPtr->configAttributes, 0); - } + NSRect bounds = [window contentRectForFrameRect:[window frame]]; + NSRect screenBounds = NSMakeRect(0, 0, screenWidth, screenHeight); + + if (!NSEqualRects(bounds, screenBounds) && !wasFullscreen) { + wmPtr->configX = wmPtr->x; + wmPtr->configY = wmPtr->y; + wmPtr->configAttributes = wmPtr->attributes; + wmPtr->attributes &= ~kWindowResizableAttribute; + ApplyWindowAttributeFlagChanges(winPtr, window, + wmPtr->configAttributes, wmPtr->flags, 1, 0); wmPtr->flags |= WM_SYNC_PENDING; - ChkErr(SetWindowBounds, window, kWindowContentRgn, - &screenBounds); + [window setFrame:[window frameRectForContentRect: + screenBounds] display:YES]; wmPtr->flags &= ~WM_SYNC_PENDING; } wmPtr->flags |= WM_FULLSCREEN; @@ -6225,24 +6223,25 @@ TkMacOSXMakeFullscreen( } else { wmPtr->flags &= ~WM_FULLSCREEN; } + TkMacOSXEnterExitFullscreen(winPtr, [window isKeyWindow]); if (wasFullscreen && !(wmPtr->flags & WM_FULLSCREEN)) { - WindowAttributes oldAttributes = wmPtr->attributes; - Rect bounds = {wmPtr->configY, wmPtr->configX, - wmPtr->configY + wmPtr->yInParent + wmPtr->configHeight, - wmPtr->configX + wmPtr->xInParent + wmPtr->configWidth}; + UInt64 oldAttributes = wmPtr->attributes; + NSRect bounds = NSMakeRect(wmPtr->configX, tkMacOSXZeroScreenHeight - + (wmPtr->configY + wmPtr->yInParent + wmPtr->configHeight), + wmPtr->xInParent + wmPtr->configWidth, + wmPtr->yInParent + wmPtr->configHeight); wmPtr->attributes |= wmPtr->configAttributes & kWindowResizableAttribute; - ApplyWindowClassAttributeChanges(winPtr, window, wmPtr->macClass, - oldAttributes, 0); + ApplyWindowAttributeFlagChanges(winPtr, window, oldAttributes, + wmPtr->flags, 1, 0); wmPtr->flags |= WM_SYNC_PENDING; - ChkErr(SetWindowBounds, window, kWindowStructureRgn, &bounds); + [window setFrame:[window frameRectForContentRect:bounds] display:YES]; wmPtr->flags &= ~WM_SYNC_PENDING; } - TkMacOSXEnterExitFullscreen(winPtr, IsWindowActive(window)); return result; } - + /* *---------------------------------------------------------------------- * @@ -6265,24 +6264,25 @@ TkMacOSXEnterExitFullscreen( int active) { WmInfo *wmPtr = winPtr->wmInfoPtr; + NSWindow *window = TkMacOSXDrawableWindow(winPtr->window); SystemUIMode mode; SystemUIOptions options; GetSystemUIMode(&mode, &options); - if (wmPtr->flags & WM_FULLSCREEN && active) { + if (window && wmPtr && (wmPtr->flags & WM_FULLSCREEN) && active) { static SystemUIMode fullscreenMode = 0; static SystemUIOptions fullscreenOptions = 0; if (!fullscreenMode) { - TK_IF_HI_TOOLBOX (3, - fullscreenMode = kUIModeAllSuppressed; - ) TK_ELSE_HI_TOOLBOX (3, - fullscreenMode = kUIModeAllHidden; - fullscreenOptions = kUIOptionAutoShowMenuBar; - ) TK_ENDIF + fullscreenMode = kUIModeAllSuppressed; } if (mode != fullscreenMode) { ChkErr(SetSystemUIMode, fullscreenMode, fullscreenOptions); + wmPtr->flags |= WM_SYNC_PENDING; + [window setFrame:[window frameRectForContentRect:NSMakeRect(0, 0, + WidthOfScreen(Tk_Screen(winPtr)), + HeightOfScreen(Tk_Screen(winPtr)))] display:YES]; + wmPtr->flags &= ~WM_SYNC_PENDING; } } else { if (mode != kUIModeNormal) { @@ -6290,7 +6290,7 @@ TkMacOSXEnterExitFullscreen( } } } - + /* *---------------------------------------------------------------------- * @@ -6387,7 +6387,7 @@ GetMinSize( *minWidthPtr = minWidth; *minHeightPtr = minHeight; } - + /* *---------------------------------------------------------------------- * @@ -6418,12 +6418,12 @@ GetMaxSize( * of the window. */ { WmInfo *wmPtr = winPtr->wmInfoPtr; - Rect *maxBounds = (Rect*)(winPtr->display->screens->ext_data); + NSRect *maxBounds = (NSRect*)(winPtr->display->screens->ext_data); if (wmPtr->maxWidth > 0) { *maxWidthPtr = wmPtr->maxWidth; } else { - int maxWidth = maxBounds->right - maxBounds->left - wmPtr->xInParent; + int maxWidth = maxBounds->size.width - wmPtr->xInParent; if (wmPtr->gridWin != NULL) { maxWidth = wmPtr->reqGridWidth @@ -6434,7 +6434,7 @@ GetMaxSize( if (wmPtr->maxHeight > 0) { *maxHeightPtr = wmPtr->maxHeight; } else { - int maxHeight = maxBounds->bottom - maxBounds->top - wmPtr->yInParent; + int maxHeight = maxBounds->size.height - wmPtr->yInParent; if (wmPtr->gridWin != NULL) { maxHeight = wmPtr->reqGridHeight @@ -6443,7 +6443,7 @@ GetMaxSize( *maxHeightPtr = maxHeight; } } - + /* *---------------------------------------------------------------------- * @@ -6475,7 +6475,6 @@ RemapWindows( if (winPtr->window != None) { MacDrawable *macWin = (MacDrawable *) winPtr->window; - macWin->grafPtr = NULL; macWin->toplevel = parentWin->toplevel; winPtr->flags &= ~TK_MAPPED; #ifdef TK_REBUILD_TOPLEVEL @@ -6489,10 +6488,12 @@ RemapWindows( RemapWindows(childPtr, (MacDrawable *) winPtr->window); } } - + /* * Local Variables: - * fill-column: 78 + * mode: c * c-basic-offset: 4 + * fill-column: 79 + * coding: utf-8 * End: */ |