changeset 103296:a23e4364bf6e

Ensure NS frames remain hidden when invisible * nsterm.m (ns_raise_frame): only raise frame if visible. (x_make_frame_visible): move frame to front rather than calling ns_raise_frame(). (keyDown:) do not swallow events that aren't re-sent if frame isn't key window. (drawRect:) do not set visibility/iconified flags because drawRect may be called by NSView even if the frame is hidden. * nsfns.m (Fx_create_frame): follow other ports in determining visibility; default to t. Ensure async_visible is set.
author David Reitter <david.reitter@gmail.com>
date Tue, 26 May 2009 18:14:14 +0000
parents 578359a0fca6
children 1120e729d920
files src/ChangeLog src/nsfns.m src/nsterm.m
diffstat 3 files changed, 48 insertions(+), 14 deletions(-) [+]
line wrap: on
line diff
--- a/src/ChangeLog	Tue May 26 14:37:51 2009 +0000
+++ b/src/ChangeLog	Tue May 26 18:14:14 2009 +0000
@@ -1,3 +1,16 @@
+2009-05-25  David Reitter  <david.reitter@gmail.com>
+
+	* nsterm.m (ns_raise_frame): only raise frame if visible.
+	(x_make_frame_visible): move frame to front rather than calling
+	ns_raise_frame().
+	(keyDown:) do not swallow events that aren't re-sent if frame
+	isn't key window.
+	(drawRect:) do not set visibility/iconified flags because
+	drawRect may be called by NSView even if the frame is hidden.
+
+	* nsfns.m (Fx_create_frame): follow other ports in
+	determining visibility; default to t. Ensure async_visible is set.
+
 2009-05-23  Eli Zaretskii  <eliz@gnu.org>
 
 	* dired.c (Ffile_attributes): Doc fix.
--- a/src/nsfns.m	Tue May 26 14:37:51 2009 +0000
+++ b/src/nsfns.m	Tue May 26 18:14:14 2009 +0000
@@ -1317,13 +1317,20 @@
 
   if (! f->output_data.ns->explicit_parent)
     {
-        tem = x_get_arg (dpyinfo, parms, Qvisibility, 0, 0, RES_TYPE_BOOLEAN);
-        if (EQ (tem, Qunbound))
-            tem = Qnil;
-
-        x_set_visibility (f, tem, Qnil);
-        if (EQ (tem, Qt))
-            [[FRAME_NS_VIEW (f) window] makeKeyWindow];
+      tem = x_get_arg (dpyinfo, parms, Qvisibility, 0, 0, RES_TYPE_SYMBOL);
+      if (EQ (tem, Qunbound))
+	tem = Qt;
+      x_set_visibility (f, tem, Qnil);
+      if (EQ (tem, Qicon))
+	x_iconify_frame (f);
+      else if (! NILP (tem))
+	{
+	  x_make_frame_visible (f);
+	  f->async_visible = 1;
+	  [[FRAME_NS_VIEW (f) window] makeKeyWindow];
+	}
+      else
+	  f->async_visible = 0;
     }
 
   if (FRAME_HAS_MINIBUF_P (f)
--- a/src/nsterm.m	Tue May 26 14:37:51 2009 +0000
+++ b/src/nsterm.m	Tue May 26 18:14:14 2009 +0000
@@ -896,7 +896,11 @@
   NSView *view = FRAME_NS_VIEW (f);
   check_ns ();
   BLOCK_INPUT;
-  [[view window] makeKeyAndOrderFront: NSApp];
+  FRAME_SAMPLE_VISIBILITY (f);
+  if (FRAME_VISIBLE_P (f))
+    {
+      [[view window] makeKeyAndOrderFront: NSApp];
+    }
   UNBLOCK_INPUT;
 }
 
@@ -983,7 +987,10 @@
      called this (frame.c:Fraise_frame ()) also called raise_lower;
      if this ends up the case again, comment this out again. */
   if (!FRAME_VISIBLE_P (f))
-    ns_raise_frame (f);
+    {
+      f->async_visible = 1;
+      ns_raise_frame (f);
+    }
 }
 
 
@@ -4461,7 +4468,8 @@
   if (!emacs_event)
     return;
 
- if (![[self window] isKeyWindow])
+ if (![[self window] isKeyWindow]
+     && [[theEvent window] isKindOfClass: [EmacsWindow class]])
    {
      /* XXX: There is an occasional condition in which, when Emacs display
          updates a different frame from the current one, and temporarily
@@ -4469,8 +4477,7 @@
          (dispnew.c:3878), OS will send the event to the correct NSWindow, but
          for some reason that window has its first responder set to the NSView
          most recently updated (I guess), which is not the correct one. */
-     if ([[theEvent window] isKindOfClass: [EmacsWindow class]])
-         [(EmacsView *)[[theEvent window] delegate] keyDown: theEvent];
+     [(EmacsView *)[[theEvent window] delegate] keyDown: theEvent];
      return;
    }
 
@@ -5466,8 +5473,15 @@
 
   ns_clear_frame_area (emacsframe, x, y, width, height);
   expose_frame (emacsframe, x, y, width, height);
-  emacsframe->async_visible = 1;
-  emacsframe->async_iconified = 0;
+
+  /*
+    drawRect: may be called (at least in OS X 10.5) for invisible
+    views as well for some reason.  Thus, do not infer visibility 
+    here.
+
+    emacsframe->async_visible = 1;
+    emacsframe->async_iconified = 0;
+  */
 }