aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRobert Pluim2018-11-29 15:26:44 +0100
committerRobert Pluim2018-11-30 08:55:02 +0100
commit5f67353da7af3ebb8fdf7bc4953e112fe1a33689 (patch)
tree2467748be3324b6c89f958cfbbe2d14f1b09b487
parent3b852da52fda327302956d263a3f916e3363cdd4 (diff)
downloademacs-5f67353da7af3ebb8fdf7bc4953e112fe1a33689.tar.gz
emacs-5f67353da7af3ebb8fdf7bc4953e112fe1a33689.zip
Convert NS face colors to RGBA when comparing with frame values
The NS port uses indexes into a color table to specify the colors of faces, whereas frames use RGBA pixel values. In extend_face_to_end_of_line the two needed to be compared to ensure that the backgrounds of certain faces are not extended to the edge of the window, which was failing because of this difference, thus causing a visual difference with other platforms. Convert from index to RGBA when doing such comparisons. * src/dispextern.h (FACE_COLOR_TO_PIXEL) [HAVE_NS]: New macro. Call ns_color_index_to_rgba under NS only. * src/nsgui.h: Add prototype for ns_color_index_to_rgba. * src/nsterm.m (ns_color_index_to_rgba): New function. Converts a color_table entry to corresponding RGBA pixel value. * src/xdisp.c (extend_face_to_end_of_line): Call FACE_COLOR_TO_PIXEL on face background color when comparing with frame color.
-rw-r--r--src/dispextern.h3
-rw-r--r--src/nsgui.h2
-rw-r--r--src/nsterm.m16
-rw-r--r--src/xdisp.c6
4 files changed, 24 insertions, 3 deletions
diff --git a/src/dispextern.h b/src/dispextern.h
index 579665c2ff8..776d14080e5 100644
--- a/src/dispextern.h
+++ b/src/dispextern.h
@@ -74,10 +74,13 @@ typedef HDC XImagePtr_or_DC;
74 74
75#ifdef HAVE_NS 75#ifdef HAVE_NS
76#include "nsgui.h" 76#include "nsgui.h"
77#define FACE_COLOR_TO_PIXEL(face_color, frame) ns_color_index_to_rgba(face_color, frame)
77/* Following typedef needed to accommodate the MSDOS port, believe it or not. */ 78/* Following typedef needed to accommodate the MSDOS port, believe it or not. */
78typedef struct ns_display_info Display_Info; 79typedef struct ns_display_info Display_Info;
79typedef Pixmap XImagePtr; 80typedef Pixmap XImagePtr;
80typedef XImagePtr XImagePtr_or_DC; 81typedef XImagePtr XImagePtr_or_DC;
82#else
83#define FACE_COLOR_TO_PIXEL(face_color, frame) face_color
81#endif 84#endif
82 85
83#ifdef HAVE_WINDOW_SYSTEM 86#ifdef HAVE_WINDOW_SYSTEM
diff --git a/src/nsgui.h b/src/nsgui.h
index 4e7d7d35daa..f858fa7a14a 100644
--- a/src/nsgui.h
+++ b/src/nsgui.h
@@ -73,6 +73,8 @@ typedef unichar XChar2b;
73#define XCHAR2B_BYTE2(chp) \ 73#define XCHAR2B_BYTE2(chp) \
74 (*(chp) & 0x00ff) 74 (*(chp) & 0x00ff)
75 75
76/* Used in xdisp.c when comparing faces and frame colors. */
77extern unsigned long ns_color_index_to_rgba(int idx, struct frame *f);
76 78
77/* XXX: xfaces requires these structures, but the question is are we 79/* XXX: xfaces requires these structures, but the question is are we
78 forced to use them? */ 80 forced to use them? */
diff --git a/src/nsterm.m b/src/nsterm.m
index 07978c0d3b8..6ba867d27c0 100644
--- a/src/nsterm.m
+++ b/src/nsterm.m
@@ -2332,6 +2332,22 @@ ns_lisp_to_color (Lisp_Object color, NSColor **col)
2332 return 1; 2332 return 1;
2333} 2333}
2334 2334
2335/* Convert an index into the color table into an RGBA value. Used in
2336 xdisp.c:extend_face_to_end_of_line when comparing faces and frame
2337 color values. */
2338
2339unsigned long
2340ns_color_index_to_rgba(int idx, struct frame *f)
2341{
2342 NSColor *col;
2343 col = ns_lookup_indexed_color (idx, f);
2344
2345 EmacsCGFloat r, g, b, a;
2346 [col getRed: &r green: &g blue: &b alpha: &a];
2347
2348 return ARGB_TO_ULONG((int)(a*255),
2349 (int)(r*255), (int)(g*255), (int)(b*255));
2350}
2335 2351
2336void 2352void
2337ns_query_color(void *col, XColor *color_def, int setPixel) 2353ns_query_color(void *col, XColor *color_def, int setPixel)
diff --git a/src/xdisp.c b/src/xdisp.c
index a0113a05190..9a0752f2671 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -20287,7 +20287,7 @@ extend_face_to_end_of_line (struct it *it)
20287 if (FRAME_WINDOW_P (f) 20287 if (FRAME_WINDOW_P (f)
20288 && MATRIX_ROW_DISPLAYS_TEXT_P (it->glyph_row) 20288 && MATRIX_ROW_DISPLAYS_TEXT_P (it->glyph_row)
20289 && face->box == FACE_NO_BOX 20289 && face->box == FACE_NO_BOX
20290 && face->background == FRAME_BACKGROUND_PIXEL (f) 20290 && FACE_COLOR_TO_PIXEL (face->background, f) == FRAME_BACKGROUND_PIXEL (f)
20291#ifdef HAVE_WINDOW_SYSTEM 20291#ifdef HAVE_WINDOW_SYSTEM
20292 && !face->stipple 20292 && !face->stipple
20293#endif 20293#endif
@@ -20432,7 +20432,7 @@ extend_face_to_end_of_line (struct it *it)
20432 && (it->glyph_row->used[LEFT_MARGIN_AREA] 20432 && (it->glyph_row->used[LEFT_MARGIN_AREA]
20433 < WINDOW_LEFT_MARGIN_WIDTH (it->w)) 20433 < WINDOW_LEFT_MARGIN_WIDTH (it->w))
20434 && !it->glyph_row->mode_line_p 20434 && !it->glyph_row->mode_line_p
20435 && default_face->background != FRAME_BACKGROUND_PIXEL (f)) 20435 && FACE_COLOR_TO_PIXEL (face->background, f) != FRAME_BACKGROUND_PIXEL (f))
20436 { 20436 {
20437 struct glyph *g = it->glyph_row->glyphs[LEFT_MARGIN_AREA]; 20437 struct glyph *g = it->glyph_row->glyphs[LEFT_MARGIN_AREA];
20438 struct glyph *e = g + it->glyph_row->used[LEFT_MARGIN_AREA]; 20438 struct glyph *e = g + it->glyph_row->used[LEFT_MARGIN_AREA];
@@ -20473,7 +20473,7 @@ extend_face_to_end_of_line (struct it *it)
20473 && (it->glyph_row->used[RIGHT_MARGIN_AREA] 20473 && (it->glyph_row->used[RIGHT_MARGIN_AREA]
20474 < WINDOW_RIGHT_MARGIN_WIDTH (it->w)) 20474 < WINDOW_RIGHT_MARGIN_WIDTH (it->w))
20475 && !it->glyph_row->mode_line_p 20475 && !it->glyph_row->mode_line_p
20476 && default_face->background != FRAME_BACKGROUND_PIXEL (f)) 20476 && FACE_COLOR_TO_PIXEL (face->background, f) != FRAME_BACKGROUND_PIXEL (f))
20477 { 20477 {
20478 struct glyph *g = it->glyph_row->glyphs[RIGHT_MARGIN_AREA]; 20478 struct glyph *g = it->glyph_row->glyphs[RIGHT_MARGIN_AREA];
20479 struct glyph *e = g + it->glyph_row->used[RIGHT_MARGIN_AREA]; 20479 struct glyph *e = g + it->glyph_row->used[RIGHT_MARGIN_AREA];