Change cursor color on NS port when it matches the face background
* src/macfont.m (CG_SET_FILL_COLOR_WITH_FRAME_CURSOR): New macro. (CG_SET_FILL_COLOR_WITH_FRAME_BACKGROUND): New macro. (macfont_draw): When the cursor's color matches the face background, set the fill color of the cursor to the face foreground. * src/nsterm.m (ns_maybe_dumpglyphs_background): When dumping the background of a glyph string, apply the logic mentioned above. (Bug#62573)
This commit is contained in:
parent
96714c106b
commit
b36c21e27d
2 changed files with 47 additions and 23 deletions
|
@ -632,21 +632,35 @@ static void mac_font_get_glyphs_for_variants (CFDataRef, UTF32Char,
|
||||||
|
|
||||||
#define CG_SET_FILL_COLOR_WITH_FACE_FOREGROUND(context, face) \
|
#define CG_SET_FILL_COLOR_WITH_FACE_FOREGROUND(context, face) \
|
||||||
do { \
|
do { \
|
||||||
CGColorRef refcol_ = get_cgcolor (NS_FACE_FOREGROUND (face)); \
|
CGColorRef refcol = get_cgcolor (NS_FACE_FOREGROUND (face)); \
|
||||||
CGContextSetFillColorWithColor (context, refcol_) ; \
|
CGContextSetFillColorWithColor (context, refcol); \
|
||||||
CGColorRelease (refcol_); \
|
CGColorRelease (refcol); \
|
||||||
} while (0)
|
} while (0)
|
||||||
#define CG_SET_FILL_COLOR_WITH_FACE_BACKGROUND(context, face) \
|
#define CG_SET_FILL_COLOR_WITH_FACE_BACKGROUND(context, face) \
|
||||||
do { \
|
do { \
|
||||||
CGColorRef refcol_ = get_cgcolor (NS_FACE_BACKGROUND (face)); \
|
CGColorRef refcol = get_cgcolor (NS_FACE_BACKGROUND (face)); \
|
||||||
CGContextSetFillColorWithColor (context, refcol_); \
|
CGContextSetFillColorWithColor (context, refcol); \
|
||||||
CGColorRelease (refcol_); \
|
CGColorRelease (refcol); \
|
||||||
|
} while (0)
|
||||||
|
#define CG_SET_FILL_COLOR_WITH_FRAME_CURSOR(context, frame) \
|
||||||
|
do { \
|
||||||
|
CGColorRef refcol \
|
||||||
|
= get_cgcolor_from_nscolor (FRAME_CURSOR_COLOR (frame), frame); \
|
||||||
|
CGContextSetFillColorWithColor (context, refcol); \
|
||||||
|
CGColorRelease (refcol); \
|
||||||
|
} while (0)
|
||||||
|
#define CG_SET_FILL_COLOR_WITH_FRAME_BACKGROUND(context, frame) \
|
||||||
|
do { \
|
||||||
|
CGColorRef refcol \
|
||||||
|
= get_cgcolor_from_nscolor (FRAME_BACKGROUND_COLOR (frame), frame); \
|
||||||
|
CGContextSetFillColorWithColor (context, refcol); \
|
||||||
|
CGColorRelease (refcol); \
|
||||||
} while (0)
|
} while (0)
|
||||||
#define CG_SET_STROKE_COLOR_WITH_FACE_FOREGROUND(context, face) \
|
#define CG_SET_STROKE_COLOR_WITH_FACE_FOREGROUND(context, face) \
|
||||||
do { \
|
do { \
|
||||||
CGColorRef refcol_ = get_cgcolor (NS_FACE_FOREGROUND (face)); \
|
CGColorRef refcol = get_cgcolor (NS_FACE_FOREGROUND (face)); \
|
||||||
CGContextSetStrokeColorWithColor (context, refcol_); \
|
CGContextSetStrokeColorWithColor (context, refcol); \
|
||||||
CGColorRelease (refcol_); \
|
CGColorRelease (refcol); \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
|
|
||||||
|
@ -2933,9 +2947,12 @@ So we use CTFontDescriptorCreateMatchingFontDescriptor (no
|
||||||
{
|
{
|
||||||
if (s->hl == DRAW_CURSOR)
|
if (s->hl == DRAW_CURSOR)
|
||||||
{
|
{
|
||||||
CGColorRef colorref = get_cgcolor_from_nscolor (FRAME_CURSOR_COLOR (f), f);
|
if (face && (NS_FACE_BACKGROUND (face)
|
||||||
CGContextSetFillColorWithColor (context, colorref);
|
== [(NSColor *) FRAME_CURSOR_COLOR (f)
|
||||||
CGColorRelease (colorref);
|
unsignedLong]))
|
||||||
|
CG_SET_FILL_COLOR_WITH_FACE_FOREGROUND (context, face);
|
||||||
|
else
|
||||||
|
CG_SET_FILL_COLOR_WITH_FRAME_CURSOR (context, f);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
CG_SET_FILL_COLOR_WITH_FACE_BACKGROUND (context, face);
|
CG_SET_FILL_COLOR_WITH_FACE_BACKGROUND (context, face);
|
||||||
|
@ -2949,9 +2966,12 @@ So we use CTFontDescriptorCreateMatchingFontDescriptor (no
|
||||||
CGContextScaleCTM (context, 1, -1);
|
CGContextScaleCTM (context, 1, -1);
|
||||||
if (s->hl == DRAW_CURSOR)
|
if (s->hl == DRAW_CURSOR)
|
||||||
{
|
{
|
||||||
CGColorRef colorref = get_cgcolor_from_nscolor (FRAME_BACKGROUND_COLOR (f), f);
|
if (face && (NS_FACE_BACKGROUND (face)
|
||||||
CGContextSetFillColorWithColor (context, colorref);
|
== [(NSColor *) FRAME_CURSOR_COLOR (f)
|
||||||
CGColorRelease (colorref);
|
unsignedLong]))
|
||||||
|
CG_SET_FILL_COLOR_WITH_FACE_BACKGROUND (context, face);
|
||||||
|
else
|
||||||
|
CG_SET_FILL_COLOR_WITH_FRAME_BACKGROUND (context, f);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
CG_SET_FILL_COLOR_WITH_FACE_FOREGROUND (context, face);
|
CG_SET_FILL_COLOR_WITH_FACE_FOREGROUND (context, face);
|
||||||
|
|
20
src/nsterm.m
20
src/nsterm.m
|
@ -3750,14 +3750,18 @@ Function modeled after x_draw_glyph_string_box ().
|
||||||
{
|
{
|
||||||
struct face *face = s->face;
|
struct face *face = s->face;
|
||||||
if (!face->stipple)
|
if (!face->stipple)
|
||||||
{
|
{
|
||||||
if (s->hl != DRAW_CURSOR)
|
if (s->hl != DRAW_CURSOR)
|
||||||
[(NS_FACE_BACKGROUND (face) != 0
|
[(NS_FACE_BACKGROUND (face) != 0
|
||||||
? [NSColor colorWithUnsignedLong:NS_FACE_BACKGROUND (face)]
|
? [NSColor colorWithUnsignedLong:NS_FACE_BACKGROUND (face)]
|
||||||
: FRAME_BACKGROUND_COLOR (s->f)) set];
|
: FRAME_BACKGROUND_COLOR (s->f)) set];
|
||||||
else
|
else if (face && (NS_FACE_BACKGROUND (face)
|
||||||
[FRAME_CURSOR_COLOR (s->f) set];
|
== [(NSColor *) FRAME_CURSOR_COLOR (s->f)
|
||||||
}
|
unsignedLong]))
|
||||||
|
[[NSColor colorWithUnsignedLong:NS_FACE_FOREGROUND (face)] set];
|
||||||
|
else
|
||||||
|
[FRAME_CURSOR_COLOR (s->f) set];
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
struct ns_display_info *dpyinfo = FRAME_DISPLAY_INFO (s->f);
|
struct ns_display_info *dpyinfo = FRAME_DISPLAY_INFO (s->f);
|
||||||
|
|
Loading…
Add table
Reference in a new issue