Mac OS: simpler processing of window closing events.

git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@9161 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
This commit is contained in:
Manolo Gouy 2011-10-30 17:23:42 +00:00
parent c9345e7d01
commit 0cf73d4603

View File

@ -930,7 +930,7 @@ void fl_open_callback(void (*cb)(const char *)) {
- (void)windowDidBecomeMain:(NSNotification *)notif; - (void)windowDidBecomeMain:(NSNotification *)notif;
- (void)windowDidDeminiaturize:(NSNotification *)notif; - (void)windowDidDeminiaturize:(NSNotification *)notif;
- (void)windowDidMiniaturize:(NSNotification *)notif; - (void)windowDidMiniaturize:(NSNotification *)notif;
- (void)windowWillClose:(NSNotification *)notif; - (void)anyWindowWillClose:(NSNotification *)notif;
- (NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication*)sender; - (NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication*)sender;
- (void)applicationDidBecomeActive:(NSNotification *)notify; - (void)applicationDidBecomeActive:(NSNotification *)notify;
- (void)applicationDidChangeScreenParameters:(NSNotification *)aNotification; - (void)applicationDidChangeScreenParameters:(NSNotification *)aNotification;
@ -1017,7 +1017,7 @@ void fl_open_callback(void (*cb)(const char *)) {
Fl::handle(FL_HIDE, window); Fl::handle(FL_HIDE, window);
fl_unlock_function(); fl_unlock_function();
} }
- (void)windowWillClose:(NSNotification *)notif - (void)anyWindowWillClose:(NSNotification *)notif
{ {
fl_lock_function(); fl_lock_function();
if ([[notif object] isKeyWindow]) { if ([[notif object] isKeyWindow]) {
@ -1028,7 +1028,7 @@ void fl_open_callback(void (*cb)(const char *)) {
w = Fl::next_window(w); w = Fl::next_window(w);
} }
if (w) { if (w) {
[(FLWindow*)Fl_X::i(w)->xid makeKeyAndOrderFront:nil]; [(FLWindow*)Fl_X::i(w)->xid makeKeyWindow];
} }
} }
fl_unlock_function(); fl_unlock_function();
@ -1290,6 +1290,10 @@ void fl_open_display() {
if (![NSApp servicesMenu]) createAppleMenu(); if (![NSApp servicesMenu]) createAppleMenu();
fl_system_menu = [NSApp mainMenu]; fl_system_menu = [NSApp mainMenu];
main_screen_height = [[[NSScreen screens] objectAtIndex:0] frame].size.height; main_screen_height = [[[NSScreen screens] objectAtIndex:0] frame].size.height;
[[NSNotificationCenter defaultCenter] addObserver:[NSApp delegate]
selector:@selector(anyWindowWillClose:)
name:NSWindowWillCloseNotification
object:nil];
} }
} }
@ -2824,7 +2828,6 @@ void Fl_X::set_cursor(Fl_Cursor c)
} }
- (void)showPanel; - (void)showPanel;
- (void)printPanel; - (void)printPanel;
- (void)closePanel:(NSNotification *)notif;
@end @end
@implementation FLaboutItemTarget @implementation FLaboutItemTarget
- (void)showPanel - (void)showPanel
@ -2836,15 +2839,6 @@ void Fl_X::set_cursor(Fl_Cursor c)
FL_MAJOR_VERSION, FL_MINOR_VERSION ]] autorelease], @"Credits", FL_MAJOR_VERSION, FL_MINOR_VERSION ]] autorelease], @"Credits",
nil]; nil];
[NSApp orderFrontStandardAboutPanelWithOptions:options]; [NSApp orderFrontStandardAboutPanelWithOptions:options];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(closePanel:)
name:NSWindowWillCloseNotification
object:[NSApp keyWindow]];
}
- (void)closePanel:(NSNotification *)notif
{
[[NSApp delegate] windowWillClose:notif];
[[NSNotificationCenter defaultCenter] removeObserver:self];
} }
//#include <FL/Fl_PostScript.H> //#include <FL/Fl_PostScript.H>
- (void)printPanel - (void)printPanel