]> code.delx.au - gnu-emacs/commitdiff
Avoid creating notification objects when possible
authorDavid Reitter <david.reitter@gmail.com>
Tue, 10 Nov 2015 20:41:17 +0000 (15:41 -0500)
committerDavid Reitter <david.reitter@gmail.com>
Tue, 10 Nov 2015 20:53:20 +0000 (15:53 -0500)
* 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.

src/nsterm.m

index 5e6c748433103b0abe977d46b130620dcffcc48e..5c39d5c0e4d1bf1d156705309edfd740ce82415d 100644 (file)
@@ -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];
     }
 }