Subject: bug#3347: 23.0.93; unnecessary display updates with mouse-drag-region

From: YAMAMOTO Mitsuharu <[email-masked]>
Date: Sat, 23 May 2009 11:00:13 +0900

>>>>> On Fri, 22 May 2009 11:54:58 +0900, YAMAMOTO Mitsuharu <[email-masked]> said:

> Mouse dragging over a text in the default face causes unnecessary
> updates in other windows displaying the same buffer.

> Steps to reproduce:

>   1. Invoke "Quartz Debug.app" on Mac OS X and check the "Flash screen
>      updates" button.
>   2. $ emacs -Q -D
>   3. C-x 2
>   4. Drag the mouse over the *scratch* buffer text in the first
>      window.

> Result:

>   The text not only in the first window but also the other one is
>   flashed whereas the latter doesn't need updates.  The flashed area
>   corresponds to the extended/shrunken part of the region in the first
>   window.

> The updates in the second window do not happen if the text is in
> non-default face (e.g., start with "emacs -Q" instead of "emacs -Q
> -D").

> I can't observe this phenomenon on Emacs 22.3.

I tried some older versions and found that the change below made the
difference.

				     YAMAMOTO Mitsuharu
				[email-masked]

2008-07-08  Chong Yidong  <[email-masked]>

	* xfaces.c (Finternal_merge_in_global_face): Save merged
	attributes for the default face back into the face vector.

--- xfaces.c	2008/07/06 03:51:06	1.404
+++ xfaces.c	2008/07/08 17:27:28	1.405
@@ -3966,7 +3966,7 @@
     else if (! UNSPECIFIEDP (gvec[i]))
       lvec[i] = gvec[i];
 
-  /* If the default face was changed, realize it again, and update the
+  /* If the default face was changed, update the face cache and the
      `font' frame parameter.  */
   if (EQ (face, Qdefault))
     {
@@ -3977,9 +3977,12 @@
       /* This can be NULL (e.g., in batch mode).  */
       if (oldface)
 	{
+	  /* Ensure that the face vector is fully specified by merging
+	     the previously-cached vector.  */
 	  bcopy (oldface->lface, attrs, sizeof attrs);
 	  merge_face_vectors (f, lvec, attrs, 0);
-	  newface = realize_face (c, attrs, DEFAULT_FACE_ID);
+	  bcopy (attrs, lvec, sizeof attrs);
+	  newface = realize_face (c, lvec, DEFAULT_FACE_ID);
 
 	  if ((! UNSPECIFIEDP (gvec[LFACE_FAMILY_INDEX])
 	       || ! UNSPECIFIEDP (gvec[LFACE_FOUNDRY_INDEX])