From xemacs-m  Thu Feb 27 16:41:50 1997
Received: from altair.xemacs.org (steve@xemacs.miranova.com [206.190.83.19])
	by xemacs.org (8.8.5/8.8.5) with ESMTP id QAA09771
	for <xemacs-beta@xemacs.org>; Thu, 27 Feb 1997 16:41:49 -0600 (CST)
Received: (from steve@localhost)
	by altair.xemacs.org (8.8.5/8.8.5) id OAA23953;
	Thu, 27 Feb 1997 14:53:32 -0800
Mail-Copies-To: never
To: xemacs-beta@xemacs.org
Subject: Re: 19.15b95: delayed redisplay bug [w/ PATCH]
References: <9702272040.AA37950@GS213.SP.CS.CMU.EDU>
X-Url: http://www.miranova.com/%7Esteve/
X-Face: #!T9!#9s-3o8)*uHlX{Ug[xW7E7Wr!*L46-OxqMu\xz23v|R9q}lH?cRS{rCNe^'[`^sr5"
 f8*@r4ipO6Jl!:Ccq<xoV[Qz2u8<8-+Vwf2gzJ44lf_/y9OaQ`@#Q65{U4/TC)i2`~/M&QI$X>p:9I
 OSS'2{-)-4wBnVeg0S\O4Al@)uC[pD|+
X-Attribution: sb
From: Steven L Baur <steve@miranova.com>
In-Reply-To: Darrell Kindred's message of Thu, 27 Feb 1997 15:40:05 -0500
Mime-Version: 1.0 (generated by tm-edit 7.105)
Content-Type: text/plain; charset=US-ASCII
Date: 27 Feb 1997 14:53:31 -0800
Message-ID: <m2zpwpoo7o.fsf@altair.xemacs.org>
Lines: 153
X-Mailer: Gnus v5.4.15/XEmacs 20.1

> In 19.15b95, I've noticed the following bug.  (I'm not sure
> whether it's been reported before.)

Thanks for the patch Darrell.

Darrell's patch corrects the problems I had that were introduced with
Jan's patch.  I don't like the `Attempt to delete the sole visible or
iconified frame' when another frame is open but situated on an
undisplayed virtual console, but I'll survive.

Here's a version of the patch for 20.1-b3:

Index: src/frame-x.c
===================================================================
RCS file: /usr/local/xemacs/xemacs-20.0/src/frame-x.c,v
retrieving revision 1.3
diff -u -r1.3 frame-x.c
--- frame-x.c	1997/02/27 06:08:44	1.3
+++ frame-x.c	1997/02/27 22:11:02
@@ -2287,18 +2287,8 @@
 			     XtWindow (FRAME_X_SHELL_WIDGET (f)),
 			     &xwa))
     result = 0;
-#ifdef 0
-  /* This is wrong. Under XEmacs visible means "Mapped" not really visible.
-     Under virtual window managers this causes freezes. JV
-
-     Fixme: This might be need to be changed, or another
-            frame->RealyVisible may need to be added to guide the actual
-	    redisplay. */
   else
     result = xwa.map_state == IsViewable;
-   For now this better.
-#endif
-    result = (xwa.map_state != IsUnmapped);
      
   f->visible = result;
   return result;

Index: src/event-Xt.c
===================================================================
RCS file: /usr/local/xemacs/xemacs-20.0/src/event-Xt.c,v
retrieving revision 1.7
diff -u -r1.7 event-Xt.c
--- event-Xt.c	1997/02/27 06:08:43	1.7
+++ event-Xt.c	1997/02/27 22:19:40
@@ -1101,6 +1101,37 @@
   handle_focus_event_1 (f, event->type == FocusIn);
 }
 
+/* both MapNotify and VisibilityNotify can cause this */
+static void
+change_frame_visibility (struct frame *f, int is_visible)
+{
+  Lisp_Object frame = Qnil;
+
+  XSETFRAME (frame, f);
+
+  if (!FRAME_VISIBLE_P (f) && is_visible)
+    {
+      FRAME_VISIBLE_P (f) = 1;
+      /* This improves the double flicker when uniconifying a frame
+	 some.  A lot of it is not showing a buffer which has changed
+	 while the frame was iconified.  To fix it further requires
+	 the good 'ol double redisplay structure. */
+      MARK_FRAME_WINDOWS_STRUCTURE_CHANGED (f);
+      va_run_hook_with_args (Qmap_frame_hook, 1, frame);
+#ifdef EPOCH
+      dispatch_epoch_event (f, event, Qx_map);
+#endif
+    }
+  else if (FRAME_VISIBLE_P (f) && !is_visible) 
+    {
+      FRAME_VISIBLE_P (f) = 0;
+      va_run_hook_with_args (Qunmap_frame_hook, 1, frame);
+#ifdef EPOCH
+      dispatch_epoch_event (f, event, Qx_unmap);
+#endif
+    }
+}
+
 static void
 handle_map_event (struct frame *f, XEvent *event)
 {
@@ -1157,34 +1188,14 @@
 	 rather than consulting some internal (and likely
 	 inaccurate) state flag.  Therefore, ignoring the MapNotify
 	 is correct. */
-      if (!f->visible && NILP (Fframe_iconified_p (frame)))
-#endif
-      if (!f->visible)
-	{
-	  f->visible = 1;
-	  /* This improves the double flicker when uniconifying a frame
-	     some.  A lot of it is not showing a buffer which has changed
-	     while the frame was iconified.  To fix it further requires
-	     the good 'ol double redisplay structure. */
-	  MARK_FRAME_WINDOWS_STRUCTURE_CHANGED (f);
-	  va_run_hook_with_args (Qmap_frame_hook, 1, frame);
-#ifdef EPOCH
-	  dispatch_epoch_event (f, event, Qx_map);
+      if (!FRAME_VISIBLE_P (f) && NILP (Fframe_iconified_p (frame)))
 #endif
-	}
+	change_frame_visibility (f, 1);
     }
   else
     {
       FRAME_X_TOTALLY_VISIBLE_P (f) = 0;
-      if (f->visible)
-	{
-	  f->visible = 0;
-	  va_run_hook_with_args (Qunmap_frame_hook, 1, frame);
-#ifdef EPOCH
-	  dispatch_epoch_event (f, event, Qx_unmap);
-#endif
-	}
-
+      change_frame_visibility (f, 0);
       /* Calling Fframe_iconified_p is the only way we have to
          correctly update FRAME_ICONIFIED_P */
       Fframe_iconified_p (frame);
@@ -1332,17 +1343,17 @@
     case VisibilityNotify: /* window visiblity has changed */
       if (event->xvisibility.window == XtWindow (FRAME_X_SHELL_WIDGET (f)))
 	{
-#if 0 /* This causes all kinds of strange behavior I don't like. -sb */
-	  /* Note that the fvwm pager only sends VisibilityNotify when
-	     changing pages. Is this all we need to do ? JV */
-	  FRAME_VISIBLE_P (f) =
-	    ( event->xvisibility.state != VisibilityFullyObscured);
-/* #else */
-	  FRAME_VISIBLE_P (f) && (FRAME_VISIBLE_P (f) =
-	    ( event->xvisibility.state != VisibilityFullyObscured));
-#endif
 	  FRAME_X_TOTALLY_VISIBLE_P (f) =
 	    (event->xvisibility.state == VisibilityUnobscured);
+	  /* Note that the fvwm pager only sends VisibilityNotify when
+	     changing pages. Is this all we need to do ? JV */
+	  /* Nope.  We must at least trigger a redisplay here.  
+	     Since this case seems similar to MapNotify, I've 
+	     factored out some code to change_frame_visibility(). 
+	     This triggers the necessary redisplay and runs
+	     (un)map-frame-hook.  - dkindred@cs.cmu.edu */
+	  change_frame_visibility (f, (event->xvisibility.state
+				       != VisibilityFullyObscured));
 	}
       break;
       

-- 
steve@miranova.com baur
Unsolicited commercial e-mail will be billed at $250/message.

