From: David Reitter Date: Tue, 10 Nov 2015 20:41:17 +0000 (-0500) Subject: Avoid creating notification objects when possible X-Git-Tag: emacs-25.0.90~847 X-Git-Url: https://code.delx.au/gnu-emacs/commitdiff_plain/0bba304045eec1b9e552c24fdf705646f24ec5a7 Avoid creating notification objects when possible * src/nsterm.m (windowWillEnterFullScreen, windowWillExitFullScreen:, windowDidEnterFullScreen, windowDidExitFullScreen): provide convenience functions that do not require a notification object. When needed, define NSWindowDidEnterFullScreenNotification to allow for compilation on OS X 10.6.8. --- diff --git a/src/nsterm.m b/src/nsterm.m index 5e6c748433..5c39d5c0e4 100644 --- a/src/nsterm.m +++ b/src/nsterm.m @@ -6866,12 +6866,26 @@ not_in_argv (NSString *arg) } #endif +#if !defined (NS_IMPL_COCOA) || MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_7 +#define NSWindowDidEnterFullScreenNotification "NSWindowDidEnterFullScreenNotification" +#endif + - (void)windowWillEnterFullScreen:(NSNotification *)notification +{ + [self windowWillEnterFullScreen]; +} +- (void)windowWillEnterFullScreen /* provided for direct calls */ { NSTRACE ("windowWillEnterFullScreen"); fs_before_fs = fs_state; } +- (void)windowDidEnterFullScreen /* provided for direct calls */ +{ + [self windowDidEnterFullScreen: + [NSNotification notificationWithName:NSWindowDidEnterFullScreenNotification + object:[self window]]]; +} - (void)windowDidEnterFullScreen:(NSNotification *)notification { NSTRACE ("windowDidEnterFullScreen"); @@ -6907,6 +6921,11 @@ not_in_argv (NSString *arg) } - (void)windowWillExitFullScreen:(NSNotification *)notification +{ + [self windowWillExitFullScreen]; +} + +- (void)windowWillExitFullScreen /* provided for direct calls */ { NSTRACE ("windowWillExitFullScreen"); if (!FRAME_LIVE_P (emacsframe)) @@ -6919,6 +6938,11 @@ not_in_argv (NSString *arg) } - (void)windowDidExitFullScreen:(NSNotification *)notification +{ + [self windowDidExitFullScreen]; +} + +- (void)windowDidExitFullScreen /* provided for direct calls */ { NSTRACE ("windowDidExitFullScreen"); if (!FRAME_LIVE_P (emacsframe)) @@ -7054,17 +7078,13 @@ not_in_argv (NSString *arg) nonfs_window = w; - [self windowWillEnterFullScreen: - [NSNotification notificationWithName:NSWindowWillEnterFullScreenNotification - object:[self window]]]; + [self windowWillEnterFullScreen]; [fw makeKeyAndOrderFront:NSApp]; [fw makeFirstResponder:self]; [w orderOut:self]; r = [fw frameRectForContentRect:[screen frame]]; [fw setFrame: r display:YES animate:ns_use_fullscreen_animation]; - [self windowDidEnterFullScreen: - [NSNotification notificationWithName:NSWindowDidEnterFullScreenNotification - object:[self window]]]; + [self windowDidEnterFullScreen]; [fw display]; } else @@ -7094,15 +7114,11 @@ not_in_argv (NSString *arg) // to do: consider using [NSNotificationCenter postNotificationName:] to send notifications. - [self windowWillExitFullScreen: - [NSNotification notificationWithName:NSWindowWillExitFullScreenNotification - object:[self window]]]; + [self windowWillExitFullScreen]; [fw setFrame: [w frame] display:YES animate:ns_use_fullscreen_animation]; [fw close]; [w makeKeyAndOrderFront:NSApp]; - [self windowDidExitFullScreen: - [NSNotification notificationWithName:NSWindowDidExitFullScreenNotification - object:[self window]]]; + [self windowDidExitFullScreen]; [self updateFrameSize:YES]; } }