>From 4c6509108bc2d3d9c37f88b1d915e8d04ce9a0c6 Mon Sep 17 00:00:00 2001 From: Alan Third Date: Mon, 14 Sep 2020 00:19:05 +0100 Subject: [PATCH] Fix NS cursor colors (bug#43381) * src/macfont.m (macfont_draw): Select the correct color when drawing a cursor. * src/nsterm.m (ns_draw_glyph_string): Don't fiddle with the face. --- src/macfont.m | 10 +++++++++- src/nsterm.m | 14 -------------- 2 files changed, 9 insertions(+), 15 deletions(-) diff --git a/src/macfont.m b/src/macfont.m index 904814647f..a73c1f01fe 100644 --- a/src/macfont.m +++ b/src/macfont.m @@ -2923,7 +2923,15 @@ So we use CTFontDescriptorCreateMatchingFontDescriptor (no CGAffineTransform atfm; CGContextScaleCTM (context, 1, -1); - CG_SET_FILL_COLOR_WITH_FACE_FOREGROUND (context, face, s->f); + + if (s->hl == DRAW_CURSOR && s->w->phys_cursor_type == FILLED_BOX_CURSOR) + { + struct face *frame_face = FRAME_DEFAULT_FACE (s->f); + CG_SET_FILL_COLOR_WITH_FACE_BACKGROUND (context, frame_face, s->f); + } + else + CG_SET_FILL_COLOR_WITH_FACE_FOREGROUND (context, face, s->f); + if (macfont_info->synthetic_italic_p) atfm = synthetic_italic_atfm; else diff --git a/src/nsterm.m b/src/nsterm.m index 26059ab67c..7e3fb4a0cb 100644 --- a/src/nsterm.m +++ b/src/nsterm.m @@ -4397,13 +4397,6 @@ overwriting cursor (usually when cursor on a tab) */ ns_maybe_dumpglyphs_background (s, s->first_glyph->type == COMPOSITE_GLYPH); - if (s->hl == DRAW_CURSOR && s->w->phys_cursor_type == FILLED_BOX_CURSOR) - { - unsigned long tmp = NS_FACE_BACKGROUND (s->face); - NS_FACE_BACKGROUND (s->face) = NS_FACE_FOREGROUND (s->face); - NS_FACE_FOREGROUND (s->face) = tmp; - } - { BOOL isComposite = s->first_glyph->type == COMPOSITE_GLYPH; @@ -4424,13 +4417,6 @@ overwriting cursor (usually when cursor on a tab) */ ns_draw_text_decoration (s, s->face, col, s->width, s->x); } - if (s->hl == DRAW_CURSOR && s->w->phys_cursor_type == FILLED_BOX_CURSOR) - { - unsigned long tmp = NS_FACE_BACKGROUND (s->face); - NS_FACE_BACKGROUND (s->face) = NS_FACE_FOREGROUND (s->face); - NS_FACE_FOREGROUND (s->face) = tmp; - } - ns_unfocus (s->f); break; -- 2.26.1