summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordas <das>2009-08-24 00:55:08 (GMT)
committerdas <das>2009-08-24 00:55:08 (GMT)
commite928c2afeba4b75ce577a9ec8917d7aff091b8b0 (patch)
tree814cc84017c4d8ab0299eb4eeef5973e3d6552ee
parent5ca9bf47bc58fbe5915c7e37dc842f8cf93a4be6 (diff)
downloadtk-e928c2afeba4b75ce577a9ec8917d7aff091b8b0.zip
tk-e928c2afeba4b75ce577a9ec8917d7aff091b8b0.tar.gz
tk-e928c2afeba4b75ce577a9ec8917d7aff091b8b0.tar.bz2
* macosx/tkMacOSXWindowEvent.c: Allow WM_DELETE_WINDOW handlers to
prevent window closure by generating WM destroy event earlier (from window delegate's -windowShouldClose:). [Bug 2821084]
-rw-r--r--macosx/tkMacOSXWindowEvent.c15
1 files changed, 10 insertions, 5 deletions
diff --git a/macosx/tkMacOSXWindowEvent.c b/macosx/tkMacOSXWindowEvent.c
index 91fed49..3e98ced 100644
--- a/macosx/tkMacOSXWindowEvent.c
+++ b/macosx/tkMacOSXWindowEvent.c
@@ -10,7 +10,7 @@
* See the file "license.terms" for information on usage and redistribution of
* this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tkMacOSXWindowEvent.c,v 1.37 2009/07/06 20:29:21 dkf Exp $
+ * RCS: @(#) $Id: tkMacOSXWindowEvent.c,v 1.38 2009/08/24 00:55:08 das Exp $
*/
#include "tkMacOSXPrivate.h"
@@ -154,17 +154,23 @@ extern NSString *NSWindowDidOrderOffScreenNotification;
}
}
-- (void) windowClosed: (NSNotification *) notification
+- (BOOL) windowShouldClose: (NSWindow *) w
{
#ifdef TK_MAC_DEBUG_NOTIFICATIONS
- TKLog(@"-[%@(%p) %s] %@", [self class], self, _cmd, notification);
+ TKLog(@"-[%@(%p) %s] %@", [self class], self, _cmd, w);
#endif
- NSWindow *w = [notification object];
TkWindow *winPtr = TkMacOSXGetTkWindow(w);
if (winPtr) {
TkGenWMDestroyEvent((Tk_Window) winPtr);
}
+
+ /*
+ * If necessary, TkGenWMDestroyEvent() handles [close]ing the window,
+ * so can always return NO from -windowShouldClose: for a Tk window.
+ */
+
+ return (winPtr ? NO : YES);
}
#ifdef TK_MAC_DEBUG_NOTIFICATIONS
@@ -220,7 +226,6 @@ extern NSString *NSWindowDidOrderOffScreenNotification;
observe(NSWindowDidResizeNotification, windowBoundsChanged:);
observe(NSWindowDidDeminiaturizeNotification, windowExpanded:);
observe(NSWindowDidMiniaturizeNotification, windowCollapsed:);
- observe(NSWindowWillCloseNotification, windowClosed:);
#ifdef TK_MAC_DEBUG_NOTIFICATIONS
observe(NSWindowWillMoveNotification, windowDragStart:);
observe(NSWindowWillStartLiveResizeNotification, windowLiveResize:);