summaryrefslogtreecommitdiffstats
path: root/macosx
diff options
context:
space:
mode:
Diffstat (limited to 'macosx')
-rw-r--r--macosx/tkMacOSXWindowEvent.c40
-rw-r--r--macosx/tkMacOSXWm.c10
2 files changed, 41 insertions, 9 deletions
diff --git a/macosx/tkMacOSXWindowEvent.c b/macosx/tkMacOSXWindowEvent.c
index 8d57d83..368822e 100644
--- a/macosx/tkMacOSXWindowEvent.c
+++ b/macosx/tkMacOSXWindowEvent.c
@@ -116,6 +116,18 @@ extern NSString *NSWindowDidOrderOffScreenNotification;
GenerateActivateEvents(winPtr, true);
}
}
+ /*
+ * Make sure that the updated keyWindow is associated with the
+ * current TkEventTarget.
+ */
+
+ NSWindow *keyWin = [NSApp keyWindow];
+ if (keyWin) {
+ TkWindow *keyWinPtr = TkMacOSXGetTkWindow(keyWin);
+ if (keyWinPtr) {
+ [NSApp setTkEventTarget:keyWinPtr];
+ }
+ }
}
- (void) windowBoundsChanged: (NSNotification *) notification
@@ -245,9 +257,15 @@ extern NSString *NSWindowDidOrderOffScreenNotification;
#endif
NSWindow *w = [notification object];
TkWindow *winPtr = TkMacOSXGetTkWindow(w);
-
- if (winPtr && winPtr->wmInfoPtr->hints.initial_state != IconicState) {
- winPtr->wmInfoPtr->hints.initial_state = IconicState;
+ NSString *name = [notification name];
+ if (!winPtr) {
+ return;
+ }
+ if ([name isEqualToString:NSWindowWillMiniaturizeNotification]) {
+ if (winPtr && winPtr->wmInfoPtr->hints.initial_state != IconicState) {
+ winPtr->wmInfoPtr->hints.initial_state = IconicState;
+ }
+ } else {
TkWmUnmapWindow(winPtr);
}
}
@@ -344,6 +362,7 @@ extern NSString *NSWindowDidOrderOffScreenNotification;
observe(NSWindowDidResizeNotification, windowBoundsChanged:);
observe(NSWindowDidDeminiaturizeNotification, windowExpanded:);
observe(NSWindowDidMiniaturizeNotification, windowCollapsed:);
+ observe(NSWindowWillMiniaturizeNotification, windowCollapsed:);
observe(NSWindowWillOrderOnScreenNotification, windowMapped:);
observe(NSWindowDidOrderOnScreenNotification, windowBecameVisible:);
observe(NSWindowWillStartLiveResizeNotification, windowLiveResize:);
@@ -376,10 +395,12 @@ static void RefocusGrabWindow(void *data) {
- (void) applicationActivate: (NSNotification *) notification
{
- (void)notification;
+ NSWindow *iconifiedWindow = nil;
#ifdef TK_MAC_DEBUG_NOTIFICATIONS
TKLog(@"-[%@(%p) %s] %@", [self class], self, sel_getName(_cmd), notification);
+#else
+ (void) notification;
#endif
[NSApp tkCheckPasteboard];
@@ -403,10 +424,17 @@ static void RefocusGrabWindow(void *data) {
}
if (winPtr->dispPtr->grabWinPtr == winPtr) {
Tcl_DoWhenIdle(RefocusGrabWindow, winPtr);
- } else {
- [[self keyWindow] orderFront: self];
}
+ if (iconifiedWindow == nil && [win isMiniaturized]) {
+ iconifiedWindow = win;
+ }
+ }
+ if ([self keyWindow] == nil && iconifiedWindow != nil) {
+ [iconifiedWindow makeKeyAndOrderFront:self];
+ } else {
+ [[self keyWindow] orderFront:self];
}
+
}
- (void) applicationDeactivate: (NSNotification *) notification
diff --git a/macosx/tkMacOSXWm.c b/macosx/tkMacOSXWm.c
index 4ddac2bbc..d5a38fb 100644
--- a/macosx/tkMacOSXWm.c
+++ b/macosx/tkMacOSXWm.c
@@ -1311,9 +1311,6 @@ TkWmDeadWindow(
* preventing zombies is to set the key window to nil.
*/
- TkMacOSXAssignNewKeyWindow(Tk_Interp((Tk_Window) winPtr),
- deadNSWindow);
-
/*
* Prevent zombies on systems with a TouchBar.
*/
@@ -1322,6 +1319,13 @@ TkWmDeadWindow(
[NSApp _setKeyWindow:nil];
[NSApp _setMainWindow:nil];
}
+
+ /*
+ * Find a new keyWindow. It will be assinged as the new
+ * TkEventTarget when [NSApp WindowActivation] is called..
+ */
+
+ TkMacOSXAssignNewKeyWindow(Tk_Interp((Tk_Window) winPtr), deadNSWindow);
/*
* Avoid redrawing the view after it is released.