summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--macosx/tkMacOSXEmbed.c9
-rw-r--r--macosx/tkMacOSXKeyEvent.c9
-rw-r--r--macosx/tkMacOSXMouseEvent.c15
-rw-r--r--macosx/tkMacOSXSubwindows.c2
-rw-r--r--macosx/tkMacOSXWm.c4
5 files changed, 24 insertions, 15 deletions
diff --git a/macosx/tkMacOSXEmbed.c b/macosx/tkMacOSXEmbed.c
index 3494818..443b34f 100644
--- a/macosx/tkMacOSXEmbed.c
+++ b/macosx/tkMacOSXEmbed.c
@@ -437,6 +437,10 @@ TkMacOSXGetHostToplevel(
{
TkWindow *contWinPtr, *topWinPtr;
+ if (!(winPtr && winPtr->privatePtr)) {
+ return NULL;
+ }
+
topWinPtr = winPtr->privatePtr->toplevel->winPtr;
if (!Tk_IsEmbedded(topWinPtr)) {
return winPtr->privatePtr->toplevel;
@@ -447,9 +451,6 @@ TkMacOSXGetHostToplevel(
* TODO: Here we should handle out of process embedding.
*/
- if (!contWinPtr) {
- return NULL;
- }
return TkMacOSXGetHostToplevel(contWinPtr);
}
@@ -666,7 +667,7 @@ Tk_GetOtherWindow(
* process...
*/
- if (!(((TkWindow *)tkwin)->flags & TK_BOTH_HALVES)) {
+ if (!(tkwin && (((TkWindow*)tkwin)->flags & TK_BOTH_HALVES))) {
return NULL;
}
diff --git a/macosx/tkMacOSXKeyEvent.c b/macosx/tkMacOSXKeyEvent.c
index 3c71a16..d282427 100644
--- a/macosx/tkMacOSXKeyEvent.c
+++ b/macosx/tkMacOSXKeyEvent.c
@@ -670,9 +670,12 @@ setXEventPoint(
local.x -= contPtr->wmInfoPtr->xInParent;
local.y -= contPtr->wmInfoPtr->yInParent;
} else {
- TkWindow *topPtr = TkMacOSXGetHostToplevel(winPtr)->winPtr;
- local.x -= (topPtr->wmInfoPtr->xInParent + contPtr->changes.x);
- local.y -= (topPtr->wmInfoPtr->yInParent + contPtr->changes.y);
+ MacDrawable *topMacWin = TkMacOSXGetHostToplevel(winPtr);
+ if (topMacWin) {
+ TkWindow *topPtr = topMacWin->winPtr;
+ local.x -= (topPtr->wmInfoPtr->xInParent + contPtr->changes.x);
+ local.y -= (topPtr->wmInfoPtr->yInParent + contPtr->changes.y);
+ }
}
} else if (winPtr->wmInfoPtr != NULL) {
local.x -= winPtr->wmInfoPtr->xInParent;
diff --git a/macosx/tkMacOSXMouseEvent.c b/macosx/tkMacOSXMouseEvent.c
index 68f9344..d4ed5ad 100644
--- a/macosx/tkMacOSXMouseEvent.c
+++ b/macosx/tkMacOSXMouseEvent.c
@@ -319,6 +319,7 @@ enum {
if ([NSApp tkDragTarget]) {
TkWindow *dragPtr = (TkWindow *) [NSApp tkDragTarget];
TKWindow *dragWindow = nil;
+ MacDrawable *topMacWin;
if (dragPtr) {
dragWindow = (TKWindow *)TkMacOSXGetNSWindowForDrawable(
dragPtr->window);
@@ -328,7 +329,10 @@ enum {
target = NULL;
return theEvent;
}
- winPtr = TkMacOSXGetHostToplevel((TkWindow *) [NSApp tkDragTarget])->winPtr;
+ topMacWin = TkMacOSXGetHostToplevel(dragPtr);
+ if (topMacWin) {
+ winPtr = topMacWin->winPtr;
+ }
} else if (eventType == NSScrollWheel) {
winPtr = scrollTarget;
} else {
@@ -368,9 +372,12 @@ enum {
local.x -= contPtr->wmInfoPtr->xInParent;
local.y -= contPtr->wmInfoPtr->yInParent;
} else {
- TkWindow *topPtr = TkMacOSXGetHostToplevel(winPtr)->winPtr;
- local.x -= (topPtr->wmInfoPtr->xInParent + contPtr->changes.x);
- local.y -= (topPtr->wmInfoPtr->yInParent + contPtr->changes.y);
+ MacDrawable *topMacWin = TkMacOSXGetHostToplevel(winPtr);
+ if (topMacWin) {
+ TkWindow* topPtr = topMacWin->winPtr;
+ local.x -= (topPtr->wmInfoPtr->xInParent + contPtr->changes.x);
+ local.y -= (topPtr->wmInfoPtr->yInParent + contPtr->changes.y);
+ }
}
}
else {
diff --git a/macosx/tkMacOSXSubwindows.c b/macosx/tkMacOSXSubwindows.c
index ae2b149..b73729e 100644
--- a/macosx/tkMacOSXSubwindows.c
+++ b/macosx/tkMacOSXSubwindows.c
@@ -87,6 +87,7 @@ XDestroyWindow(
if (macWin->toplevel->referenceCount == 0) {
ckfree(macWin->toplevel);
}
+ macWin->winPtr->privatePtr = NULL;
ckfree(macWin);
return Success;
}
@@ -103,6 +104,7 @@ XDestroyWindow(
macWin->drawRgn = NULL;
}
macWin->view = nil;
+ macWin->winPtr->privatePtr = NULL;
/*
* Delay deletion of a toplevel data structure until all children have
diff --git a/macosx/tkMacOSXWm.c b/macosx/tkMacOSXWm.c
index 345d66e..8b72faf 100644
--- a/macosx/tkMacOSXWm.c
+++ b/macosx/tkMacOSXWm.c
@@ -1114,7 +1114,6 @@ TkWmDeadWindow(
{
WmInfo *wmPtr = winPtr->wmInfoPtr, *wmPtr2;
TKWindow *deadNSWindow;
- TkWindow *dragTarget = [NSApp tkDragTarget];
if (wmPtr == NULL) {
return;
@@ -1194,9 +1193,6 @@ TkWmDeadWindow(
* state which is recorded in the NSApplication object.
*/
- if (dragTarget && winPtr == TkMacOSXGetHostToplevel(dragTarget)->winPtr) {
- [NSApp setTkDragTarget:nil];
- }
if (winPtr == [NSApp tkPointerWindow]) {
NSWindow *w;
NSPoint mouse = [NSEvent mouseLocation];