Subject: [PATCH] Fix dumping stretch glyph when drawing s->next in NS port

From: Po Lu <[email-masked]>
Date: Sun, 07 Nov 2021 16:00:52 +0800

Otherwise, scrolling in a document with stretch glyphs can cause them to
overwrite parts of the mode line, in some cases.

>From 6a2449af61a6be75bd4d0945b8009320745b5ff2 Mon Sep 17 00:00:00 2001
From: Po Lu <[email-masked]>
Date: Sun, 7 Nov 2021 15:58:11 +0800
Subject: [PATCH] Set clipping when dumping stretch glyphs in some cases

* src/nsterm.m (ns_draw_glyph_string): Always focus even when dumping
stretch glyphs in s->next.
---
 src/nsterm.m | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/nsterm.m b/src/nsterm.m
index a63883cd08..4e84e130b8 100644
--- a/src/nsterm.m
+++ b/src/nsterm.m
@@ -3991,17 +3991,17 @@ Function modeled after x_draw_glyph_string_box ().
 	   width += next->width, next = next->next)
 	if (next->first_glyph->type != IMAGE_GLYPH)
           {
+	    n = ns_get_glyph_string_clip_rect (s->next, r);
+	    ns_focus (s->f, r, n);
             if (next->first_glyph->type != STRETCH_GLYPH)
               {
-                n = ns_get_glyph_string_clip_rect (s->next, r);
-                ns_focus (s->f, r, n);
                 ns_maybe_dumpglyphs_background (s->next, 1);
-                ns_unfocus (s->f);
               }
             else
               {
                 ns_dumpglyphs_stretch (s->next);
               }
+	    ns_unfocus (s->f);
             next->num_clips = 0;
           }
     }
-- 
2.31.1

Thanks.