Subject: bug#21862: Acknowledgement (24.5; Commit 35cd5181450 breaks nsterm.m on Mac OS X 10.6)

From: Anders Lindgren <[email-masked]>
Date: Sat, 14 Nov 2015 21:14:45 +0100

Hi,

here is another, cleaner, patch to the OS X 10.6.8 build problem. It adds a
non-notification version of windowDidBecomeKey, which
windowDidEnterFullScreen now calls. This mean that 1) all functions now use
the same pattern (the notification version calls the non-notification
version) and 2) there is no need for the locally defined symbol
NSWindowDidEnterFullScreenNotification any more.

David (R), if you think this is a good way to solve this, would you like to
commit this patch, or would you prefer me to do it?

    -- Anders

On Wed, Nov 11, 2015 at 7:56 AM, Anders Lindgren <[email-masked]> wrote:

> I don’t think you should unconditionally declare this one:
>>
>> +- (void)windowDidEnterFullScreen:(NSNotification *)notification;
>>
>
>> Only declare it for the 10.6 build, please.
>>
>
> Ah, yes, that seems correct. It is provided from 10.7 onwards.
>
> Alternatively, we can implement a non-notification variant of
> windowDidBecomeKey (it doesn't use the notification anyway), that way we
> can move the code from windowDidEnterFullScreen from the notification
> variant to the non-notification variant, and avoid a lot of the
> notification complexity.
>
>     -- Anders
>
>
>
diff --git a/src/nsterm.h b/src/nsterm.h
index 1b330f0..73b3d89 100644
--- a/src/nsterm.h
+++ b/src/nsterm.h
@@ -412,6 +412,11 @@ void nstrace_leave(int *);
 - (void)windowDidMove: (id)sender;
 #endif
 - (int)fullscreenState;
+- (void)windowWillEnterFullScreen;
+- (void)windowDidEnterFullScreen;
+- (void)windowWillExitFullScreen;
+- (void)windowDidExitFullScreen;
+- (void)windowDidBecomeKey;
 @end

diff --git a/src/nsterm.m b/src/nsterm.m
index 5c39d5c..397ade1 100644
--- a/src/nsterm.m
+++ b/src/nsterm.m
@@ -6440,6 +6440,12 @@ not_in_argv (NSString *arg)
 - (void)windowDidBecomeKey: (NSNotification *)notification
 /* cf. x_detect_focus_change(), x_focus_changed(), x_new_focus_frame() */
 {
+  [self windowDidBecomeKey];
+}
+
+
+- (void)windowDidBecomeKey      /* for direct calls */
+{
   struct ns_display_info *dpyinfo = FRAME_DISPLAY_INFO (emacsframe);
   struct frame *old_focus = dpyinfo->x_focus_frame;
 
@@ -6866,10 +6872,6 @@ 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];
@@ -6880,19 +6882,18 @@ not_in_argv (NSString *arg)
   fs_before_fs = fs_state;
 }
 
-- (void)windowDidEnterFullScreen /* provided for direct calls */
+- (void)windowDidEnterFullScreen:(NSNotification *)notification
 {
-  [self windowDidEnterFullScreen:
-	      [NSNotification notificationWithName:NSWindowDidEnterFullScreenNotification
-					    object:[self window]]];
+  [self windowDidEnterFullScreen];
 }
-- (void)windowDidEnterFullScreen:(NSNotification *)notification
+
+- (void)windowDidEnterFullScreen /* provided for direct calls */
 {
   NSTRACE ("windowDidEnterFullScreen");
   [self setFSValue: FULLSCREEN_BOTH];
   if (! [self fsIsNative])
     {
-      [self windowDidBecomeKey:notification];
+      [self windowDidBecomeKey];
       [nonfs_window orderOut:self];
     }
   else