diff options
Diffstat (limited to 'macosx/tkMacOSXWm.c')
| -rw-r--r-- | macosx/tkMacOSXWm.c | 329 |
1 files changed, 191 insertions, 138 deletions
diff --git a/macosx/tkMacOSXWm.c b/macosx/tkMacOSXWm.c index 9b4db14..8c1f508 100644 --- a/macosx/tkMacOSXWm.c +++ b/macosx/tkMacOSXWm.c @@ -112,7 +112,7 @@ static const struct { .forceOnAttrs = kWindowNoTitleBarAttribute | kWindowDoesNotCycleAttribute, .flags = WM_TOPMOST, - .styleMask = 0}, + .styleMask = 0}, [kSheetWindowClass] = { .validAttrs = kWindowResizableAttribute, .forceOnAttrs = kWindowNoTitleBarAttribute | @@ -291,6 +291,7 @@ static void syncLayout(NSWindow *macWindow) contentRect.size.width; wmPtr->parentHeight = winPtr->changes.height + frameRect.size.height - contentRect.size.height; + TkMacOSXInvalClipRgns((Tk_Window)winPtr); } } #endif @@ -555,16 +556,6 @@ static void placeAsTab(TKWindow *macWindow) { @implementation NSWindow(TKWm) -#if MAC_OS_X_VERSION_MIN_REQUIRED < 1070 -- (NSPoint) tkConvertPointToScreen: (NSPoint) point -{ - return [self convertBaseToScreen:point]; -} -- (NSPoint) tkConvertPointFromScreen: (NSPoint)point -{ - return [self convertScreenToBase:point]; -} -#else - (NSPoint) tkConvertPointToScreen: (NSPoint) point { NSRect pointrect = {point, {0,0}}; @@ -576,7 +567,6 @@ static void placeAsTab(TKWindow *macWindow) { NSRect pointrect = {point, {0,0}}; return [self convertRectFromScreen:pointrect].origin; } -#endif @end #pragma mark - @@ -587,6 +577,7 @@ static void placeAsTab(TKWindow *macWindow) { - (void) tkLayoutChanged { syncLayout(self); + [[self contentView] setNeedsDisplay:YES]; } @end @@ -606,6 +597,7 @@ static void placeAsTab(TKWindow *macWindow) { - (void) tkLayoutChanged { syncLayout(self); + [[self contentView] setNeedsDisplay:YES]; } #if MAC_OS_X_VERSION_MAX_ALLOWED >= 101300 @@ -621,7 +613,7 @@ static void placeAsTab(TKWindow *macWindow) { #endif - (NSSize)windowWillResize:(NSWindow *)sender - toSize:(NSSize)frameSize + toSize:(NSSize)frameSize { NSRect currentFrame = [sender frame]; TkWindow *winPtr = TkMacOSXGetTkWindow(sender); @@ -818,30 +810,29 @@ FrontWindowAtPoint( int y) { NSPoint p = NSMakePoint(x, TkMacOSXZeroScreenHeight() - y); - NSArray *windows = [NSApp orderedWindows]; - TkWindow *winPtr = NULL; - for (NSWindow *w in windows) { - winPtr = TkMacOSXGetTkWindow(w); + for (NSWindow *w in [NSApp orderedWindows]) { + TkWindow *winPtr = TkMacOSXGetTkWindow(w); if (winPtr) { - WmInfo *wmPtr = winPtr->wmInfoPtr; NSRect windowFrame = [w frame]; - NSRect contentFrame = [w frame]; + NSRect contentFrame = windowFrame; - contentFrame.size.height = [[w contentView] frame].size.height; /* * For consistency with other platforms, points in the * title bar are not considered to be contained in the * window. */ - if ((wmPtr->hints.initial_state == NormalState || - wmPtr->hints.initial_state == ZoomState)) { - if (NSMouseInRect(p, contentFrame, NO)) { - return winPtr; - } else if (NSMouseInRect(p, windowFrame, NO)) { - return NULL; - } + contentFrame.size.height = [[w contentView] frame].size.height; + if (NSMouseInRect(p, contentFrame, NO)) { + return winPtr; + } else if (NSMouseInRect(p, windowFrame, NO)) { + /* + * The pointer is in the title bar of the highest NSWindow + * containing it, and therefore it should not be considered + * to be contained in any Tk window. + */ + return NULL; } } } @@ -1100,12 +1091,15 @@ TkWmUnmapWindow( * * This procedure is invoked when a top-level window is about to be * deleted. It cleans up the wm-related data structures for the window. + * If the dead window contains the pointer, TkUpdatePointer is called + * to tell Tk which window will be the new pointer window. * * Results: * None. * * Side effects: - * The WmInfo structure for winPtr gets freed up. + * The WmInfo structure for winPtr gets freed. Tk's cached pointer + * window may change. * *---------------------------------------------------------------------- */ @@ -1114,13 +1108,15 @@ void TkWmDeadWindow( TkWindow *winPtr) /* Top-level window that's being deleted. */ { + TkWindow *winPtr2; + NSWindow *w; WmInfo *wmPtr = winPtr->wmInfoPtr, *wmPtr2; - TKWindow *deadNSWindow; - - if (wmPtr == NULL) { - return; + TKWindow *deadNSWindow = NULL; + if (Tk_WindowId(winPtr) == None) { + fprintf(stderr, "TkWmDeadWindow: no window id\n"); + } else { + deadNSWindow = (TKWindow *)TkMacOSXGetNSWindowForDrawable(Tk_WindowId(winPtr)); } - /* *If the dead window is a transient, remove it from the container's list. */ @@ -1172,11 +1168,10 @@ TkWmDeadWindow( for (Transient *transientPtr = wmPtr->transientPtr; transientPtr != NULL; transientPtr = transientPtr->nextPtr) { - TkWindow *winPtr2 = transientPtr->winPtr; - TkWindow *containerPtr = (TkWindow *)TkMacOSXGetContainer(winPtr2); - + TkWindow *containerPtr = (TkWindow *)TkMacOSXGetContainer( + transientPtr->winPtr); if (containerPtr == winPtr) { - wmPtr2 = winPtr2->wmInfoPtr; + wmPtr2 = transientPtr->winPtr->wmInfoPtr; wmPtr2->container = NULL; } } @@ -1188,29 +1183,48 @@ TkWmDeadWindow( ckfree(transientPtr); } - deadNSWindow = (TKWindow *)wmPtr->window; - /* * Remove references to the Tk window from the mouse event processing - * state which is recorded in the NSApplication object. + * state which is recorded in the NSApplication object and notify Tk + * of the new pointer window. */ - if (winPtr == [NSApp tkPointerWindow]) { - NSWindow *w; - NSPoint mouse = [NSEvent mouseLocation]; - [NSApp setTkPointerWindow:nil]; - for (w in [NSApp orderedWindows]) { - if (w == deadNSWindow) { - continue; - } - if (NSPointInRect(mouse, [w frame])) { - TkWindow *winPtr2 = TkMacOSXGetTkWindow(w); - int x = mouse.x, y = TkMacOSXZeroScreenHeight() - mouse.y; - [NSApp setTkPointerWindow:winPtr2]; - Tk_UpdatePointer((Tk_Window) winPtr2, x, y, - [NSApp tkButtonState]); - break; - } + NSPoint mouse = [NSEvent mouseLocation]; + [NSApp setTkPointerWindow:nil]; + winPtr2 = NULL; + + for (w in [NSApp orderedWindows]) { + if (w == deadNSWindow || w == NULL) { + continue; + } + winPtr2 = TkMacOSXGetTkWindow(w); + if (winPtr2 == NULL) { + continue; + } + if (NSPointInRect(mouse, [w frame])) { + [NSApp setTkPointerWindow: winPtr2]; + break; + } + } + if (winPtr2) { + /* + * We now know which toplevel will contain the pointer when the window + * is destroyed. We need to know which Tk window within the + * toplevel will contain the pointer. + */ + NSPoint local = [w tkConvertPointFromScreen: mouse]; + int top_x = floor(local.x), + top_y = floor(w.frame.size.height - local.y); + int root_x = floor(mouse.x), + root_y = floor(TkMacOSXZeroScreenHeight() - mouse.y); + int win_x, win_y; + Tk_Window target = Tk_TopCoordsToWindow((Tk_Window) winPtr2, top_x, top_y, &win_x, &win_y); + /* + * A non-toplevel window can have a NULL parent while it is in the process of + * being destroyed. We should not call Tk_UpdatePointer in that case. + */ + if (Tk_Parent(target) != NULL || Tk_IsTopLevel(target)) { + Tk_UpdatePointer(target, root_x, root_y, [NSApp tkButtonState]); } } @@ -1223,9 +1237,9 @@ TkWmDeadWindow( if (deadNSWindow && !Tk_IsEmbedded(winPtr)) { NSWindow *parent = [deadNSWindow parentWindow]; [deadNSWindow setTkWindow:None]; - if (winPtr->window) { - ((MacDrawable *)winPtr->window)->view = nil; - } + if (winPtr->window) { + ((MacDrawable *)winPtr->window)->view = nil; + } wmPtr->window = NULL; if (parent) { @@ -1262,9 +1276,10 @@ TkWmDeadWindow( * set tkEventTarget to NULL when there is no window to send Tk events to. */ TkWindow *newTkEventTarget = NULL; + winPtr2 = NULL; - for (NSWindow *w in [NSApp orderedWindows]) { - TkWindow *winPtr2 = TkMacOSXGetTkWindow(w); + for (w in [NSApp orderedWindows]) { + winPtr2 = TkMacOSXGetTkWindow(w); BOOL isOnScreen; if (!winPtr2 || !winPtr2->wmInfoPtr) { @@ -1290,6 +1305,14 @@ TkWmDeadWindow( [NSApp _setKeyWindow:nil]; [NSApp _setMainWindow:nil]; } + + /* + * Avoid redrawing the view after it is released. + */ + + TKContentView *deadView = [deadNSWindow contentView]; + Tcl_CancelIdleCall(TkMacOSXRedrawViewIdleTask,(void *) deadView); + CGContextRelease(deadView.tkLayerBitmapContext); [deadNSWindow close]; #if MAC_OS_X_VERSION_MAX_ALLOWED >= 101400 NSUserDefaults *preferences = [NSUserDefaults standardUserDefaults]; @@ -1704,11 +1727,7 @@ WmSetAttribute( return TCL_ERROR; } if (boolValue != (([macWindow styleMask] & NSFullScreenWindowMask) != 0)) { -#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1070 [macWindow toggleFullScreen:macWindow]; -#else - TKLog(@"The fullscreen attribute is ignored on this system."); -#endif } break; case WMATT_MODIFIED: @@ -1749,7 +1768,7 @@ WmSetAttribute( } else if (![macWindow isKindOfClass: [NSPanel class]] && styleMaskBits[index].allowed == NSWindowClass_panel) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( - "styleMask bit \"%s\" can only be used with an NSPanel", + "styleMask bit \"%s\" can only be used with an NSPanel", styleMaskBits[index].bitname)); Tcl_SetErrorCode(interp, "TK", "INVALID_STYLEMASK_BIT", NULL); return TCL_ERROR; @@ -1794,15 +1813,15 @@ WmSetAttribute( fprintf(stderr, "Current styleMask: %lx\n", [macWindow styleMask]); fprintf(stderr, "Setting styleMask to %lx\n", styleMaskValue); #endif - macWindow.styleMask = (unsigned long) styleMaskValue; + macWindow.styleMask = (unsigned long) styleMaskValue; NSRect newFrame = [macWindow frame]; int heightDiff = newFrame.size.height - oldFrame.size.height; int newHeight = heightDiff < 0 ? newFrame.size.height : newFrame.size.height - heightDiff; [(TKWindow *)macWindow tkLayoutChanged]; if (heightDiff) { - //Calling XMoveResizeWindow twice is a hack to force a relayout - //of the window. + // Calling XMoveResizeWindow twice is a hack to force a relayout + // of the window. XMoveResizeWindow(winPtr->display, winPtr->window, winPtr->changes.x, winPtr->changes.y, newFrame.size.width, newHeight - 1); @@ -2390,8 +2409,7 @@ WmDeiconifyCmd( Tcl_Obj *const objv[]) /* Argument objects. */ { WmInfo *wmPtr = winPtr->wmInfoPtr; - NSWindow *win = TkMacOSXGetNSWindowForDrawable(winPtr->window); - + NSWindow *win = nil; if (objc != 3) { Tcl_WrongNumArgs(interp, 2, objv, "window"); return TCL_ERROR; @@ -2410,11 +2428,17 @@ WmDeiconifyCmd( return TCL_ERROR; } + if (winPtr->window) { + win = TkMacOSXGetNSWindowForDrawable(winPtr->window); + } TkpWmSetState(winPtr, TkMacOSXIsWindowZoomed(winPtr) ? ZoomState : NormalState); - [win setExcludedFromWindowsMenu:NO]; - TkMacOSXApplyWindowAttributes(winPtr, win); - [win orderFront:NSApp]; + if (win) { + [win setExcludedFromWindowsMenu:NO]; + TkMacOSXApplyWindowAttributes(winPtr, win); + [win orderFront:NSApp]; + [[win contentView] setNeedsDisplay:YES]; + } if (wmPtr->icon) { Tk_UnmapWindow((Tk_Window)wmPtr->icon); } @@ -2439,8 +2463,7 @@ WmDeiconifyCmd( } } - [[win contentView] setNeedsDisplay:YES]; - Tcl_DoWhenIdle(TkMacOSXDrawAllViews, NULL); + //Tcl_DoWhenIdle(TkMacOSXDrawAllViews, NULL); return TCL_OK; } @@ -2541,19 +2564,18 @@ WmForgetCmd( macWin->toplevel->referenceCount++; macWin->flags &= ~TK_HOST_EXISTS; - TkWmDeadWindow(winPtr); RemapWindows(winPtr, (MacDrawable *)winPtr->parentPtr->window); - /* - * Make sure wm no longer manages this window - */ - Tk_ManageGeometry(frameWin, NULL, NULL); + /* + * Make sure wm no longer manages this window + */ + Tk_ManageGeometry(frameWin, NULL, NULL); winPtr->flags &= ~(TK_TOP_HIERARCHY|TK_TOP_LEVEL|TK_HAS_WRAPPER|TK_WIN_MANAGED); /* - * Flags (above) must be cleared before calling TkMapTopFrame (below). - */ + * Flags (above) must be cleared before calling TkMapTopFrame (below). + */ TkMapTopFrame(frameWin); } else { @@ -2632,11 +2654,13 @@ WmGeometryCmd( Tcl_Obj *const objv[]) /* Argument objects. */ { WmInfo *wmPtr = winPtr->wmInfoPtr; - NSWindow *win = TkMacOSXGetNSWindowForDrawable(winPtr->window); + NSWindow *win = nil; char xSign = '+', ySign = '+'; int width, height, x = wmPtr->x, y= wmPtr->y; char *argv3; - + if (winPtr && winPtr->window) { + win = TkMacOSXGetNSWindowForDrawable(winPtr->window); + } if ((objc != 3) && (objc != 4)) { Tcl_WrongNumArgs(interp, 2, objv, "window ?newGeometry?"); return TCL_ERROR; @@ -2962,7 +2986,7 @@ WmIconbitmapCmd( wmPtr->hints.flags &= ~IconPixmapHint; } } else { - pixmap = Tk_GetBitmap(interp, (Tk_Window)winPtr, Tk_GetUid(str)); + pixmap = Tk_GetBitmap(interp, (Tk_Window)winPtr, str); if (pixmap == None) { return TCL_ERROR; } @@ -3382,18 +3406,23 @@ WmIconwindowCmd( return TCL_ERROR; } if (wmPtr->icon != NULL) { + NSWindow *win = nil; TkWindow *oldIcon = (TkWindow *)wmPtr->icon; - WmInfo *wmPtr3 = oldIcon->wmInfoPtr; - NSWindow *win = TkMacOSXGetNSWindowForDrawable(oldIcon->window); - + if (winPtr && winPtr->window) { + win = TkMacOSXGetNSWindowForDrawable(winPtr->window); + } /* * The old icon should be withdrawn. */ - - TkpWmSetState(oldIcon, WithdrawnState); + if (oldIcon) { + WmInfo *wmPtr3 = oldIcon->wmInfoPtr; + TkpWmSetState(oldIcon, WithdrawnState); + if (wmPtr3) { + wmPtr3->iconFor = NULL; + } + } [win orderOut:NSApp]; - [win setExcludedFromWindowsMenu:YES]; - wmPtr3->iconFor = NULL; + [win setExcludedFromWindowsMenu:YES]; } Tk_MakeWindowExist(tkwin2); wmPtr->hints.icon_window = Tk_WindowId(tkwin2); @@ -3488,6 +3517,7 @@ WmManageCmd( } else if (Tk_IsTopLevel(frameWin)) { /* Already managed by wm - ignore it */ } + Tk_ManageGeometry((Tk_Window)winPtr, &wmMgrType, NULL); return TCL_OK; } @@ -3626,7 +3656,11 @@ WmOverrideredirectCmd( { Bool boolValue; XSetWindowAttributes atts; - TKWindow *win = (TKWindow *)TkMacOSXGetNSWindowForDrawable(winPtr->window); + NSWindow *win = nil; + if (winPtr && winPtr->window) { + win = TkMacOSXGetNSWindowForDrawable(winPtr->window); + } + if ((objc != 3) && (objc != 4)) { Tcl_WrongNumArgs(interp, 2, objv, "window ?boolean?"); @@ -3750,8 +3784,6 @@ WmProtocolCmd( WmInfo *wmPtr = winPtr->wmInfoPtr; ProtocolHandler *protPtr, *prevPtr; Atom protocol; - char *cmd; - Tcl_Size cmdLength; Tcl_Obj *resultObj; if ((objc < 3) || (objc > 5)) { @@ -3783,8 +3815,7 @@ WmProtocolCmd( for (protPtr = wmPtr->protPtr; protPtr != NULL; protPtr = protPtr->nextPtr) { if (protPtr->protocol == protocol) { - Tcl_SetObjResult(interp, - Tcl_NewStringObj(protPtr->command, TCL_INDEX_NONE)); + Tcl_SetObjResult(interp, protPtr->commandObj); return TCL_OK; } } @@ -3804,21 +3835,20 @@ WmProtocolCmd( } else { prevPtr->nextPtr = protPtr->nextPtr; } - if (protPtr->command) - ckfree(protPtr->command); + if (protPtr->commandObj) + Tcl_DecrRefCount(protPtr->commandObj); Tcl_EventuallyFree(protPtr, TCL_DYNAMIC); break; } } - cmd = Tcl_GetStringFromObj(objv[4], &cmdLength); - if (cmdLength > 0) { + if (Tcl_GetString(objv[4])[0]) { protPtr = (ProtocolHandler *)ckalloc(sizeof(ProtocolHandler)); protPtr->protocol = protocol; protPtr->nextPtr = wmPtr->protPtr; wmPtr->protPtr = protPtr; protPtr->interp = interp; - protPtr->command = (char *)ckalloc(cmdLength+1); - strcpy(protPtr->command, cmd); + protPtr->commandObj = objv[4]; + Tcl_IncrRefCount(protPtr->commandObj); } return TCL_OK; } @@ -4311,12 +4341,12 @@ WmTransientCmd( RemoveTransient(winPtr); containerPtr = (TkWindow*) container; while (!Tk_TopWinHierarchy(containerPtr)) { - /* - * Ensure that the container window is actually a Tk toplevel. - */ + /* + * Ensure that the container window is actually a Tk toplevel. + */ - containerPtr = containerPtr->parentPtr; - } + containerPtr = containerPtr->parentPtr; + } Tk_MakeWindowExist((Tk_Window)containerPtr); if (wmPtr->iconFor != NULL) { @@ -5216,7 +5246,7 @@ Tk_GetRootCoords( */ winPtr = otherPtr; - continue; + continue; } winPtr = winPtr->parentPtr; } @@ -5619,6 +5649,15 @@ Tk_MoveToplevelWindow( * *---------------------------------------------------------------------- */ +#define PRINT_STACK \ + for (NSWindow *w in [NSApp orderedWindows]) { \ + TkWindow *winPtr2 = TkMacOSXGetTkWindow(w); \ + if (winPtr2) { \ + fprintf(stderr, "%s ", Tk_PathName(winPtr2)); \ + } \ + } \ + fprintf(stderr, "\n"); \ + fflush(stderr) void TkWmRestackToplevel( @@ -5676,8 +5715,14 @@ TkWmRestackToplevel( * Just let the Mac window manager deal with all the subtleties of keeping * track of off-screen windows, etc. */ - +#if 0 + fprintf(stderr, "window order: "); PRINT_STACK; +#endif [macWindow orderWindow:macAboveBelow relativeTo:otherNumber]; +#if 0 + fprintf(stderr, "new window order: "); PRINT_STACK; +#endif +#undef PRINT_STACK } /* @@ -6027,7 +6072,7 @@ Tk_Window TkMacOSXGetContainer( TkWindow *winPtr) { - if (winPtr->wmInfoPtr != NULL) { + if (Tk_PathName(winPtr)) { return (Tk_Window)winPtr->wmInfoPtr->container; } return NULL; @@ -6072,7 +6117,7 @@ TkMacOSXGetXWindow( * void*. * * Results: - * A Tk_Window, or NULL if the NSWindow is not associated with + * A Tk_Window, or None if the NSWindow is not associated with * any Tk window. * * Side effects: @@ -6088,13 +6133,12 @@ Tk_MacOSXGetTkWindow( Window window = None; if ([(NSWindow *)w respondsToSelector: @selector (tkWindow)]) { window = [(TKWindow *)w tkWindow]; - } - if (window) { TkDisplay *dispPtr = TkGetDisplayList(); - return Tk_IdToWindow(dispPtr->display, window); - } else { - return NULL; + if (window && dispPtr && dispPtr->display) { + return Tk_IdToWindow(dispPtr->display, window); + } } + return NULL; } /* @@ -6119,7 +6163,10 @@ MODULE_SCOPE int TkMacOSXIsWindowZoomed( TkWindow *winPtr) { - NSWindow *macWindow = TkMacOSXGetNSWindowForDrawable(winPtr->window); + NSWindow *macWindow = nil; + if (winPtr && winPtr->window) { + macWindow = TkMacOSXGetNSWindowForDrawable(winPtr->window); + } return [macWindow isZoomed]; } @@ -6240,7 +6287,7 @@ TkUnsupported1ObjCmd( case TKMWS_APPEARANCE: if ([NSApp macOSVersion] < 100900) { Tcl_SetObjResult(interp, Tcl_NewStringObj( - "Window appearances did not exist until OSX 10.9.", TCL_INDEX_NONE)); + "Window appearances did not exist until OSX 10.9.", TCL_INDEX_NONE)); Tcl_SetErrorCode(interp, "TK", "WINDOWSTYLE", "APPEARANCE", NULL); return TCL_ERROR; } @@ -6794,7 +6841,7 @@ TkMacOSXMakeRealWindowExist( } if ((styleMask & (NSTexturedBackgroundWindowMask|NSHUDWindowMask)) && !(styleMask & NSDocModalWindowMask)) { - /* + /* * Workaround for [Bug 2824538]: Textured windows are draggable from * opaque content. */ @@ -6832,9 +6879,11 @@ TkMacOSXMakeRealWindowExist( * * TkpRedrawWidget -- * - * Mark the bounding rectangle of this widget as needing display so the - * widget will be drawn by [NSView drawRect:]. If this is called within - * the drawRect method, do nothing. + * This is a stub called only from tkTextDisp.c. It was introduced + * to deal with an issue in macOS 10.14 and is not needed + * even for that OS with updateLayer in use. It would add the widget bounds + * to the dirtyRect, which is not currently used, and set the + * TkNeedsDisplay flag. Now it is a no-op. * * Results: * None. @@ -6847,15 +6896,16 @@ TkMacOSXMakeRealWindowExist( void TkpRedrawWidget(Tk_Window tkwin) { + (void) tkwin; +#if 0 TkWindow *winPtr = (TkWindow *)tkwin; - NSWindow *w; + NSWindow *w = nil; Rect tkBounds; NSRect bounds; - if ([NSApp isDrawing]) { - return; + if (winPtr && winPtr->window) { + w = TkMacOSXGetNSWindowForDrawable(winPtr->window); } - w = TkMacOSXGetNSWindowForDrawable(winPtr->window); if (w) { TKContentView *view = [w contentView]; TkMacOSXWinBounds(winPtr, &tkBounds); @@ -6863,8 +6913,9 @@ TkpRedrawWidget(Tk_Window tkwin) { [view bounds].size.height - tkBounds.bottom, tkBounds.right - tkBounds.left, tkBounds.bottom - tkBounds.top); - [view addTkDirtyRect:bounds]; + [view setNeedsDisplay:YES]; } +#endif } @@ -6987,14 +7038,15 @@ TkpWmSetState( * or WithdrawnState. */ { WmInfo *wmPtr = winPtr->wmInfoPtr; - NSWindow *macWin; + NSWindow *macWin = nil; wmPtr->hints.initial_state = state; if (wmPtr->flags & WM_NEVER_MAPPED) { goto setStateEnd; } - - macWin = TkMacOSXGetNSWindowForDrawable(winPtr->window); + if (winPtr && winPtr->window) { + macWin = TkMacOSXGetNSWindowForDrawable(winPtr->window); + } /* * Make sure windows are updated before the state change. As an exception, @@ -7181,7 +7233,10 @@ TkpChangeFocus( * didn't originally belong to topLevelPtr's * application. */ { - if (winPtr->atts.override_redirect) { + if (!winPtr || + (winPtr->flags & TK_ALREADY_DEAD) || + !Tk_IsMapped(winPtr) || + winPtr->atts.override_redirect) { return 0; } @@ -7382,8 +7437,6 @@ ApplyWindowAttributeFlagChanges( } if ((changedAttributes & (kWindowResizableAttribute | kWindowFullZoomAttribute)) || initial) { - [macWindow setShowsResizeIndicator: - !!(newAttributes & kWindowResizableAttribute)]; [[macWindow standardWindowButton:NSWindowZoomButton] setEnabled:(newAttributes & kWindowResizableAttribute) && (newAttributes & kWindowFullZoomAttribute)]; @@ -7570,9 +7623,9 @@ ApplyContainerOverrideChanges( wmPtr->attributes &= ~kWindowNoActivatesAttribute; if ([NSApp macOSVersion] == 100600) { styleMask = NSTitledWindowMask | - NSClosableWindowMask | - NSMiniaturizableWindowMask | - NSResizableWindowMask; + NSClosableWindowMask | + NSMiniaturizableWindowMask | + NSResizableWindowMask; } else { styleMask |= NSTitledWindowMask; } |
