summaryrefslogtreecommitdiffstats
path: root/macosx/tkMacOSXSubwindows.c
diff options
context:
space:
mode:
Diffstat (limited to 'macosx/tkMacOSXSubwindows.c')
-rw-r--r--macosx/tkMacOSXSubwindows.c49
1 files changed, 47 insertions, 2 deletions
diff --git a/macosx/tkMacOSXSubwindows.c b/macosx/tkMacOSXSubwindows.c
index 36d0b9d..afadb32 100644
--- a/macosx/tkMacOSXSubwindows.c
+++ b/macosx/tkMacOSXSubwindows.c
@@ -148,6 +148,8 @@ XMapWindow(
TkWindow *winPtr = macWin->winPtr;
NSWindow *win = TkMacOSXGetNSWindowForDrawable(window);
static Bool initialized = NO;
+ NSPoint mouse = [NSEvent mouseLocation];
+ int x = mouse.x, y = TkMacOSXZeroScreenHeight() - mouse.y;
/*
* Under certain situations it's possible for this function to be called
@@ -185,6 +187,16 @@ XMapWindow(
[win orderFrontRegardless];
}
}
+
+ /*
+ * Call Tk_UpdatePointer to tell Tk whether the pointer is in the
+ * new window.
+ */
+
+ NSPoint viewLocation = [view convertPoint:mouse fromView:nil];
+ if (NSPointInRect(viewLocation, NSInsetRect([view bounds], 2, 2))) {
+ Tk_UpdatePointer((Tk_Window) winPtr, x, y, [NSApp tkButtonState]);
+ }
} else {
TkWindow *contWinPtr = TkpGetOtherWindow(winPtr);
@@ -296,6 +308,9 @@ XUnmapWindow(
TkWindow *winPtr = macWin->winPtr;
TkWindow *parentPtr = winPtr->parentPtr;
NSWindow *win = TkMacOSXGetNSWindowForDrawable(window);
+ NSPoint mouse = [NSEvent mouseLocation];
+ int x = mouse.x, y = TkMacOSXZeroScreenHeight() - mouse.y;
+ int state = TkMacOSXButtonKeyState();
if (!window) {
return BadWindow;
@@ -303,12 +318,41 @@ XUnmapWindow(
display->request++;
if (Tk_IsTopLevel(winPtr)) {
if (!Tk_IsEmbedded(winPtr) &&
- winPtr->wmInfoPtr->hints.initial_state!=IconicState) {
- [win orderOut:nil];
+ winPtr->wmInfoPtr->hints.initial_state!=IconicState) {
[win setExcludedFromWindowsMenu:YES];
+ [win orderOut:NSApp];
+ if ([win isKeyWindow]) {
+
+ /*
+ * If we are unmapping the key window then we need to make sure
+ * that a new key window is assigned, if possible. This is
+ * supposed to happen when a key window is ordered out, but as
+ * noted in tkMacOSXWm.c this does not happen, in spite of
+ * Apple's claims to the contrary.
+ */
+
+ for (NSWindow *w in [NSApp orderedWindows]) {
+ TkWindow *winPtr2 = TkMacOSXGetTkWindow(w);
+ WmInfo *wmInfoPtr;
+
+ BOOL isOnScreen;
+
+ if (!winPtr2 || !winPtr2->wmInfoPtr) {
+ continue;
+ }
+ wmInfoPtr = winPtr2->wmInfoPtr;
+ isOnScreen = (wmInfoPtr->hints.initial_state != IconicState &&
+ wmInfoPtr->hints.initial_state != WithdrawnState);
+ if (w != win && isOnScreen && [w canBecomeKeyWindow]) {
+ [w makeKeyAndOrderFront:NSApp];
+ break;
+ }
+ }
+ }
}
TkMacOSXInvalClipRgns((Tk_Window)winPtr);
} else {
+
/*
* Rebuild the visRgn clip region for the parent so it will be allowed
* to draw in the space from which this subwindow was removed and then
@@ -327,6 +371,7 @@ XUnmapWindow(
if (view != [NSView focusView]) {
[view addTkDirtyRect:[view bounds]];
}
+ Tk_UpdatePointer(NULL, x, y, state);
return Success;
}