From b87eba81515bd2b86fa3a3ddfcc5fba30b7b827d Mon Sep 17 00:00:00 2001 From: Alan Third Date: Fri, 6 Jun 2025 21:45:20 +0100 Subject: [PATCH] Fix incorrectly nested ns_focus/ns_unfocus calls * src/nsterm.m (ns_draw_fringe_bitmap): Move the call to ns_focus out of the if for overlay_p and rename the rect from clearRect to bmpRect to make it's purpose clearer. (cherry picked from commit e3380669ed6db7a1c1574c4b39d58f9200a3ffab) --- src/nsterm.m | 35 ++++++++++++++++------------------- 1 file changed, 16 insertions(+), 19 deletions(-) diff --git a/src/nsterm.m b/src/nsterm.m index 38e49406d66..1d86fab3db5 100644 --- a/src/nsterm.m +++ b/src/nsterm.m @@ -3035,35 +3035,32 @@ ns_draw_fringe_bitmap (struct window *w, struct glyph_row *row, struct frame *f = XFRAME (WINDOW_FRAME (w)); struct face *face = p->face; - NSRect clearRect = NSZeroRect; + NSRect bmpRect = NSZeroRect; NSRect rowRect = ns_row_rect (w, row, ANY_AREA); NSTRACE_WHEN (NSTRACE_GROUP_FRINGE, "ns_draw_fringe_bitmap"); NSTRACE_MSG ("which:%d cursor:%d overlay:%d width:%d height:%d period:%d", p->which, p->cursor_p, p->overlay_p, p->wd, p->h, p->dh); - /* Clear screen unless overlay. */ - if (!p->overlay_p) - { - /* Work out the rectangle we will need to clear. */ - clearRect = NSMakeRect (p->x, p->y, p->wd, p->h); + /* Work out the rectangle we will need to clear. */ + bmpRect = NSMakeRect (p->x, p->y, p->wd, p->h); - if (p->bx >= 0) - clearRect = NSUnionRect (clearRect, NSMakeRect (p->bx, p->by, p->nx, p->ny)); + if (p->bx >= 0) + bmpRect = NSUnionRect (bmpRect, NSMakeRect (p->bx, p->by, p->nx, p->ny)); - /* Handle partially visible rows. */ - clearRect = NSIntersectionRect (clearRect, rowRect); + /* Handle partially visible rows. */ + bmpRect = NSIntersectionRect (bmpRect, rowRect); - /* The visible portion of imageRect will always be contained - within clearRect. */ - ns_focus (f, &clearRect, 1); - if (!NSIsEmptyRect (clearRect)) - { - NSTRACE_RECT ("clearRect", clearRect); + /* Clip to the bitmap's area. */ + ns_focus (f, &bmpRect, 1); - [[NSColor colorWithUnsignedLong:face->background] set]; - NSRectFill (clearRect); - } + /* Clear screen unless overlay. */ + if (!p->overlay_p && !NSIsEmptyRect (clearRect)) + { + NSTRACE_RECT ("clearRect", clearRect); + + [[NSColor colorWithUnsignedLong:face->background] set]; + NSRectFill (clearRect); } NSBezierPath *bmp = [fringe_bmp objectForKey:[NSNumber numberWithInt:p->which]]; -- 2.39.5