]> git.eshelyaron.com Git - emacs.git/commitdiff
Convert NS face colors to RGBA when comparing with frame values
authorRobert Pluim <rpluim@gmail.com>
Thu, 29 Nov 2018 14:26:44 +0000 (15:26 +0100)
committerRobert Pluim <rpluim@gmail.com>
Fri, 30 Nov 2018 07:55:02 +0000 (08:55 +0100)
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.

src/dispextern.h
src/nsgui.h
src/nsterm.m
src/xdisp.c

index 579665c2ff87e482812bad11163d08b2638e8100..776d14080e523c4df0ebcfadd931e8e4163ea422 100644 (file)
@@ -74,10 +74,13 @@ typedef HDC XImagePtr_or_DC;
 
 #ifdef HAVE_NS
 #include "nsgui.h"
+#define FACE_COLOR_TO_PIXEL(face_color, frame) ns_color_index_to_rgba(face_color, frame)
 /* Following typedef needed to accommodate the MSDOS port, believe it or not.  */
 typedef struct ns_display_info Display_Info;
 typedef Pixmap XImagePtr;
 typedef XImagePtr XImagePtr_or_DC;
+#else
+#define FACE_COLOR_TO_PIXEL(face_color, frame) face_color
 #endif
 
 #ifdef HAVE_WINDOW_SYSTEM
index 4e7d7d35daab490078ab1c1a30355eb5d4e8575f..f858fa7a14a67b786cb4d126e3c58afd537768e9 100644 (file)
@@ -73,6 +73,8 @@ typedef unichar XChar2b;
 #define XCHAR2B_BYTE2(chp) \
   (*(chp) & 0x00ff)
 
+/* Used in xdisp.c when comparing faces and frame colors.  */
+extern unsigned long ns_color_index_to_rgba(int idx, struct frame *f);
 
 /* XXX: xfaces requires these structures, but the question is are we
         forced to use them?  */
index 07978c0d3b8059fefa933d022415212f19ef8bb8..6ba867d27c002d8443f342bfd8636a244e92b3b2 100644 (file)
@@ -2332,6 +2332,22 @@ ns_lisp_to_color (Lisp_Object color, NSColor **col)
   return 1;
 }
 
+/* Convert an index into the color table into an RGBA value.  Used in
+   xdisp.c:extend_face_to_end_of_line when comparing faces and frame
+   color values.  */
+
+unsigned long
+ns_color_index_to_rgba(int idx, struct frame *f)
+{
+  NSColor *col;
+  col = ns_lookup_indexed_color (idx, f);
+
+  EmacsCGFloat r, g, b, a;
+  [col getRed: &r green: &g blue: &b alpha: &a];
+
+  return ARGB_TO_ULONG((int)(a*255),
+                       (int)(r*255), (int)(g*255), (int)(b*255));
+}
 
 void
 ns_query_color(void *col, XColor *color_def, int setPixel)
index a0113a05190434802883c50dc73275f19c519371..9a0752f26713e9b5db434be5861815f56fde77fb 100644 (file)
@@ -20287,7 +20287,7 @@ extend_face_to_end_of_line (struct it *it)
   if (FRAME_WINDOW_P (f)
       && MATRIX_ROW_DISPLAYS_TEXT_P (it->glyph_row)
       && face->box == FACE_NO_BOX
-      && face->background == FRAME_BACKGROUND_PIXEL (f)
+      && FACE_COLOR_TO_PIXEL (face->background, f) == FRAME_BACKGROUND_PIXEL (f)
 #ifdef HAVE_WINDOW_SYSTEM
       && !face->stipple
 #endif
@@ -20432,7 +20432,7 @@ extend_face_to_end_of_line (struct it *it)
          && (it->glyph_row->used[LEFT_MARGIN_AREA]
              < WINDOW_LEFT_MARGIN_WIDTH (it->w))
          && !it->glyph_row->mode_line_p
-         && default_face->background != FRAME_BACKGROUND_PIXEL (f))
+         && FACE_COLOR_TO_PIXEL (face->background, f) != FRAME_BACKGROUND_PIXEL (f))
        {
          struct glyph *g = it->glyph_row->glyphs[LEFT_MARGIN_AREA];
          struct glyph *e = g + it->glyph_row->used[LEFT_MARGIN_AREA];
@@ -20473,7 +20473,7 @@ extend_face_to_end_of_line (struct it *it)
          && (it->glyph_row->used[RIGHT_MARGIN_AREA]
              < WINDOW_RIGHT_MARGIN_WIDTH (it->w))
          && !it->glyph_row->mode_line_p
-         && default_face->background != FRAME_BACKGROUND_PIXEL (f))
+         && FACE_COLOR_TO_PIXEL (face->background, f) != FRAME_BACKGROUND_PIXEL (f))
        {
          struct glyph *g = it->glyph_row->glyphs[RIGHT_MARGIN_AREA];
          struct glyph *e = g + it->glyph_row->used[RIGHT_MARGIN_AREA];