summaryrefslogtreecommitdiffstats
path: root/macosx/tkMacOSXWm.c
diff options
context:
space:
mode:
authorculler <culler>2024-06-11 15:20:31 (GMT)
committerculler <culler>2024-06-11 15:20:31 (GMT)
commitc2f33a40bb917cd5394b6e5ea77d14564e7003c8 (patch)
tree862ee0f17d63b2daea3720dc0cdd5bd0e4f27a3a /macosx/tkMacOSXWm.c
parent180726bd1446284f52fd95270a21be7d04e573ef (diff)
downloadtk-c2f33a40bb917cd5394b6e5ea77d14564e7003c8.zip
tk-c2f33a40bb917cd5394b6e5ea77d14564e7003c8.tar.gz
tk-c2f33a40bb917cd5394b6e5ea77d14564e7003c8.tar.bz2
Deal with some testing issues.
Diffstat (limited to 'macosx/tkMacOSXWm.c')
-rw-r--r--macosx/tkMacOSXWm.c85
1 files changed, 53 insertions, 32 deletions
diff --git a/macosx/tkMacOSXWm.c b/macosx/tkMacOSXWm.c
index c01d506..c1c7f92 100644
--- a/macosx/tkMacOSXWm.c
+++ b/macosx/tkMacOSXWm.c
@@ -1123,10 +1123,11 @@ TkWmDeadWindow(
TkWindow *winPtr2;
NSWindow *w;
WmInfo *wmPtr = winPtr->wmInfoPtr, *wmPtr2;
- TKWindow *deadNSWindow = (TKWindow *)TkMacOSXGetNSWindowForDrawable(
- Tk_WindowId(winPtr));
- if (deadNSWindow == 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.
@@ -2416,8 +2417,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;
@@ -2436,11 +2436,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);
}
@@ -2465,7 +2471,6 @@ WmDeiconifyCmd(
}
}
- [[win contentView] setNeedsDisplay:YES];
Tcl_DoWhenIdle(TkMacOSXDrawAllViews, NULL);
return TCL_OK;
}
@@ -2657,11 +2662,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;
@@ -3407,18 +3414,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);
@@ -3652,8 +3664,12 @@ 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?");
return TCL_ERROR;
@@ -6098,7 +6114,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:
@@ -6114,13 +6130,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;
}
/*
@@ -6145,7 +6160,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];
}
@@ -6874,11 +6892,13 @@ TkMacOSXMakeRealWindowExist(
void
TkpRedrawWidget(Tk_Window tkwin) {
TkWindow *winPtr = (TkWindow *)tkwin;
- NSWindow *w;
+ NSWindow *w = nil;
Rect tkBounds;
NSRect bounds;
- w = TkMacOSXGetNSWindowForDrawable(winPtr->window);
+ if (winPtr && winPtr->window) {
+ w = TkMacOSXGetNSWindowForDrawable(winPtr->window);
+ }
if (w) {
TKContentView *view = [w contentView];
TkMacOSXWinBounds(winPtr, &tkBounds);
@@ -7010,14 +7030,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,