Subject: Re: NS: mouse-face flicker

From: David Reitter <[email-masked]>
Date: Wed, 3 Jun 2009 17:11:25 -0400

Some analysis suggests that the mouse face is generally cleared when t- 
m-m is on, whether really needed or not.  With the patch below (not  
meant as a bug fix) applied, the bug goes away.

Without the patch, try_window_reusing_current_matrix is not used in t- 
m-m with a region visible.
I guess that dpyinfo->mouse_face_window is then set to Qnil, the mouse  
face text cleared and redrawn at a later point in time outside of the  
update_begin/end bracket.

The double-redraws are inefficient, and I don't quite understand why  
they are necessary.

I suspect that this only shows up in NS because the frame is flushed  
every time we have an update_window_end().

Help, please!

diff --git a/src/xdisp.c b/src/xdisp.c
index ac989d3..9db30f8 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -14162,11 +14162,13 @@ try_window_reusing_current_matrix (w)
      return 0;

    /* Can't do this if region may have changed.  */
+  /*
    if ((!NILP (Vtransient_mark_mode)
         && !NILP (current_buffer->mark_active))
        || !NILP (w->region_showing)
        || !NILP (Vshow_trailing_whitespace))
      return 0;
+  */

    /* If top-line visibility has changed, give up.  */
    if (WINDOW_WANTS_HEADER_LINE_P (w)
@@ -23672,9 +23674,9 @@ note_mouse_highlight (f, x, y)

    /* If we were displaying active text in another window, clear that.
       Also clear if we move out of text area in same window.  */
-  if (! EQ (window, dpyinfo->mouse_face_window)
-      || (part != ON_TEXT && part != ON_MODE_LINE && part !=  
ON_HEADER_LINE
-	  && !NILP (dpyinfo->mouse_face_window)))
+  if ((! EQ (window, dpyinfo->mouse_face_window)
+       || (part != ON_TEXT && part != ON_MODE_LINE && part !=  
ON_HEADER_LINE))
+	  && !NILP (dpyinfo->mouse_face_window))
      clear_mouse_face (dpyinfo);

    /* Not on a window -> return.  */