Subject: bug#8470: ns_dumpglyphs_stretch creates display artifacts

From: Alp Aker <[email-masked]>
Date: Sun, 10 Apr 2011 19:32:55 -0400 (EDT)

ns_dumpglyphs_stretch (in nsterm.m) checks to make sure that it doesn't 
overwrite a window's right fringe or scroll bar.  It doesn't perform an 
analogous check for overruns on the left.  This can cause display 
artifacts to appear when a window is horizontally scrolled.  Here is a 
screenshot showing an extreme example of what can happen:

http://www.pitt.edu/~aker/screenshot.png

The problem has been around since at least 23.2.1 and still exists in the 
trunk.

The following patch (against the latest nsterm.m) appears to fix the 
problem:

*** nsterm.m	2011-04-10 19:21:28.000000000 -0400
--- nsterm-rev.m	2011-04-10 19:23:54.000000000 -0400
***************
*** 2981,2986 ****
--- 2981,2995 ----
                                     - (WINDOW_BOX_RIGHT_EDGE_X (s->w)
                                       - WINDOW_RIGHT_FRINGE_WIDTH (s->w)));
                 r[i].size.width -= overrun;
+
+               /* truncate to avoid overwriting to left of the window box */
+               int leftoverrun = (WINDOW_BOX_LEFT_EDGE_X (s->w)
+                                  + WINDOW_LEFT_FRINGE_WIDTH (s->w)) - s->x;
+               if (0 < leftoverrun)
+                 {
+                   r[i].origin.x += leftoverrun;
+                   r[i].size.width -= leftoverrun;
+                 }

                 /* XXX: Try to work between problem where a stretch glyph on
                    a partially-visible bottom row will clear part of the