This avoids clashing with the XColor struct from X.
* src/dispextern [HAVE_X_WINDOWS]: Define Emacs_Color alias.
[!HAVE_X_WINDOWS]: Rename XColor compatibility struct to
Emacs_Color. Remove unused fields.
* src/gtkutil.c:
* src/gtkutil.h:
* src/image.c:
* src/nsterm.h:
* src/nsterm.m:
* src/termhooks.h:
* src/w32fns.c:
* src/w32term.c:
* src/w32term.h:
* src/xfaces.c:
* src/xfns.c:
* src/xterm.h: Use Emacs_Color over XColor outside of X-specific
sections.
#ifdef HAVE_XRENDER
# include <X11/extensions/Xrender.h>
#endif
+
+typedef XColor Emacs_Color;
#else /* !HAVE_X_WINDOWS */
-/* X-related stuff used by non-X gui code. */
+/* XColor-like struct used by non-X code. */
-typedef struct {
+typedef struct
+{
unsigned long pixel;
unsigned short red, green, blue;
- char flags;
- char pad;
-} XColor;
+} Emacs_Color;
#endif /* HAVE_X_WINDOWS */
void update_face_from_frame_parameter (struct frame *, Lisp_Object,
Lisp_Object);
-extern bool tty_defined_color (struct frame *f, const char *, XColor *, bool,
- bool);
+extern bool tty_defined_color (struct frame *, const char *, Emacs_Color *,
+ bool, bool);
Lisp_Object tty_color_name (struct frame *, int);
void clear_face_cache (bool);
bool
xg_check_special_colors (struct frame *f,
const char *color_name,
- XColor *color)
+ Emacs_Color *color)
{
bool success_p = 0;
bool get_bg = strcmp ("gtk_selection_bg_color", color_name) == 0;
extern void xg_set_background_color (struct frame *f, unsigned long bg);
extern bool xg_check_special_colors (struct frame *f,
const char *color_name,
- XColor *color);
+ Emacs_Color *color);
extern void xg_set_frame_icon (struct frame *f,
Pixmap icon_pixmap,
#ifdef USE_CAIRO
static uint32_t
-xcolor_to_argb32 (XColor xc)
+emacs_color_to_argb32 (Emacs_Color *ec)
{
- return ((0xffu << 24) | ((xc.red / 256) << 16)
- | ((xc.green / 256) << 8) | (xc.blue / 256));
+ return ((0xffu << 24) | ((ec->red / 256) << 16)
+ | ((ec->green / 256) << 8) | (ec->blue / 256));
}
static uint32_t
struct frame *f)
{
uint32_t bgcolor = 0;
- XColor xbgcolor;
+ Emacs_Color xbgcolor;
Lisp_Object bg = image_spec_value (img->spec, QCbackground, NULL);
if (STRINGP (bg) && x_parse_color (f, SSDATA (bg), &xbgcolor))
- bgcolor = xcolor_to_argb32 (xbgcolor);
+ bgcolor = emacs_color_to_argb32 (&xbgcolor);
return bgcolor;
}
image_alloc_image_color (struct frame *f, struct image *img,
Lisp_Object color_name, unsigned long dflt)
{
- XColor color;
+ Emacs_Color color;
unsigned long result;
eassert (STRINGP (color_name));
char *color, *max_color;
int key, next_key, max_key = 0;
Lisp_Object symbol_color = Qnil, color_val;
- XColor cdef;
+ Emacs_Color cdef;
expect (XPM_TK_STRING);
if (len <= chars_per_pixel || len >= BUFSIZ + chars_per_pixel)
#define COLOR_INTENSITY(R, G, B) ((2 * (R) + 3 * (G) + (B)) / 6)
-/* On frame F, return an array of XColor structures describing image
- IMG->pixmap. Each XColor structure has its pixel color set. RGB_P
- means also fill the red/green/blue members of the XColor
- structures. Value is a pointer to the array of XColors structures,
+/* On frame F, return an array of Emacs_Color structures describing image
+ IMG->pixmap. Each Emacs_Color structure has its pixel color set. RGB_P
+ means also fill the red/green/blue members of the Emacs_Color
+ structures. Value is a pointer to the array of Emacs_Color structures,
allocated with xmalloc; it must be freed by the caller. */
-static XColor *
-image_to_xcolors (struct frame *f, struct image *img, bool rgb_p)
+static Emacs_Color *
+image_to_emacs_colors (struct frame *f, struct image *img, bool rgb_p)
{
int x, y;
- XColor *colors, *p;
+ Emacs_Color *colors, *p;
XImagePtr_or_DC ximg;
ptrdiff_t nbytes;
#ifdef HAVE_NTGUI
/* Get the X image or create a memory device context for IMG. */
ximg = image_get_x_image_or_dc (f, img, 0, &prev);
- /* Fill the `pixel' members of the XColor array. I wished there
+ /* Fill the `pixel' members of the Emacs_Color array. I wished there
were an easy and portable way to circumvent XGetPixel. */
p = colors;
for (y = 0; y < img->height; ++y)
{
#if defined (HAVE_X_WINDOWS) || defined (HAVE_NTGUI)
- XColor *row = p;
+ Emacs_Color *row = p;
for (x = 0; x < img->width; ++x, ++p)
p->pixel = GET_PIXEL (ximg, x, y);
if (rgb_p)
#endif /* HAVE_NTGUI */
-/* Create IMG->pixmap from an array COLORS of XColor structures, whose
+/* Create IMG->pixmap from an array COLORS of Emacs_Color structures, whose
RGB members are set. F is the frame on which this all happens.
COLORS will be freed; an existing IMG->pixmap will be freed, too. */
static void
-image_from_xcolors (struct frame *f, struct image *img, XColor *colors)
+image_from_emacs_colors (struct frame *f, struct image *img, Emacs_Color *colors)
{
int x, y;
XImagePtr oimg = NULL;
- XColor *p;
+ Emacs_Color *p;
init_color_table ();
image_detect_edges (struct frame *f, struct image *img,
int *matrix, int color_adjust)
{
- XColor *colors = image_to_xcolors (f, img, 1);
- XColor *new, *p;
+ Emacs_Color *colors = image_to_emacs_colors (f, img, 1);
+ Emacs_Color *new, *p;
int x, y, i, sum;
ptrdiff_t nbytes;
for (xx = x - 1; xx < x + 2; ++xx, ++i)
if (matrix[i])
{
- XColor *t = COLOR (colors, xx, yy);
+ Emacs_Color *t = COLOR (colors, xx, yy);
r += matrix[i] * t->red;
g += matrix[i] * t->green;
b += matrix[i] * t->blue;
}
xfree (colors);
- image_from_xcolors (f, img, new);
+ image_from_emacs_colors (f, img, new);
#undef COLOR
}
/* Color (or grayscale). Convert to gray, and equalize. Just
drawing such images with a stipple can look very odd, so
we're using this method instead. */
- XColor *colors = image_to_xcolors (f, img, 1);
- XColor *p, *end;
+ Emacs_Color *colors = image_to_emacs_colors (f, img, 1);
+ Emacs_Color *p, *end;
const int h = 15000;
const int l = 30000;
p->red = p->green = p->blue = i2;
}
- image_from_xcolors (f, img, colors);
+ image_from_emacs_colors (f, img, colors);
}
/* Draw a cross over the disabled image, if we must or if we
unsigned long fg = FRAME_FOREGROUND_PIXEL (f);
unsigned long bg = FRAME_BACKGROUND_PIXEL (f);
#ifdef USE_CAIRO
- XColor xfg, xbg;
+ Emacs_Color xfg, xbg;
int fga32, bga32;
#endif
/* Parse the image specification. */
xfg.pixel = fg;
x_query_colors (f, &xfg, 1);
}
- fga32 = xcolor_to_argb32 (xfg);
+ fga32 = emacs_color_to_argb32 (&xfg);
if (! fmt[PBM_BACKGROUND].count
|| ! STRINGP (fmt[PBM_BACKGROUND].value)
xbg.pixel = bg;
x_query_colors (f, &xbg, 1);
}
- bga32 = xcolor_to_argb32 (xbg);
+ bga32 = emacs_color_to_argb32 (&xbg);
#else
if (fmt[PBM_FOREGROUND].count
&& STRINGP (fmt[PBM_FOREGROUND].value))
/* png_color_16 *image_bg; */
Lisp_Object specified_bg
= image_spec_value (img->spec, QCbackground, NULL);
- XColor color;
+ Emacs_Color color;
/* If the user specified a color, try to use it; if not, use the
current frame background, ignoring any default background
uint32_t *data32 = (uint32_t *) cairo_image_surface_get_data (surface);
if (STRINGP (specified_bg))
{
- XColor color;
+ Emacs_Color color;
if (FRAME_TERMINAL (f)->defined_color_hook
(f, SSDATA (specified_bg), &color, false, false))
{
/* Retrieve the frame's background color, for use later. */
{
- XColor bgcolor;
+ Emacs_Color bgcolor;
Lisp_Object specified_bg;
specified_bg = image_spec_value (img->spec, QCbackground, NULL);
/* Handle alpha channel by combining the image with a background
color. */
- XColor background;
+ Emacs_Color background;
Lisp_Object specified_bg = image_spec_value (img->spec, QCbackground, NULL);
if (!STRINGP (specified_bg)
|| !FRAME_TERMINAL (f)->defined_color_hook (f,
#define No_Cursor (0)
-#ifdef __OBJC__
-typedef NSColor * Color;
-#else
-typedef void * Color;
-#endif
typedef int Window;
extern bool
ns_defined_color (struct frame *f,
const char *name,
- XColor *color_def, bool alloc,
+ Emacs_Color *color_def, bool alloc,
bool makeIndex);
extern void
-ns_query_color (void *col, XColor *color_def, bool setPixel);
+ns_query_color (void *col, Emacs_Color *color_def, bool setPixel);
#ifdef __OBJC__
extern int ns_lisp_to_color (Lisp_Object color, NSColor **col);
}
void
-ns_query_color(void *col, XColor *color_def, bool setPixel)
+ns_query_color(void *col, Emacs_Color *color_def, bool setPixel)
/* --------------------------------------------------------------------------
Get ARGB values out of NSColor col and put them into color_def.
If setPixel, set the pixel to a concatenated version.
bool
ns_defined_color (struct frame *f,
const char *name,
- XColor *color_def,
+ Emacs_Color *color_def,
bool alloc,
bool makeIndex)
/* --------------------------------------------------------------------------
}
static void
-ns_query_frame_background_color (struct frame *f, XColor *bgcolor)
+ns_query_frame_background_color (struct frame *f, Emacs_Color *bgcolor)
/* --------------------------------------------------------------------------
External (hook): Store F's background color into *BGCOLOR
-------------------------------------------------------------------------- */
If MAKEINDEX (on NS), set COLOR_DEF pixel to ARGB. */
bool (*defined_color_hook) (struct frame *f, const char *color_name,
- XColor *color_def,
+ Emacs_Color *color_def,
bool alloc,
bool makeIndex);
/* This hook is called to store the frame's background color into
BGCOLOR. */
- void (*query_frame_background_color) (struct frame *f, XColor *bgcolor);
+ void (*query_frame_background_color) (struct frame *f, Emacs_Color *bgcolor);
#if defined (HAVE_X_WINDOWS) || defined (HAVE_NTGUI)
/* On frame F, translate pixel colors to RGB values for the NCOLORS
colors in COLORS. Use cached information, if available. */
- void (*query_colors) (struct frame *f, XColor *colors, int ncolors);
+ void (*query_colors) (struct frame *f, Emacs_Color *colors, int ncolors);
#endif
/* Return the current position of the mouse.
If ALLOC is nonzero, allocate a new colormap cell. */
bool
-w32_defined_color (struct frame *f, const char *color, XColor *color_def,
+w32_defined_color (struct frame *f, const char *color, Emacs_Color *color_def,
bool alloc_p, bool _makeIndex)
{
register Lisp_Object tem;
static int
w32_decode_color (struct frame *f, Lisp_Object arg, int def)
{
- XColor cdef;
+ Emacs_Color cdef;
CHECK_STRING (arg);
doc: /* SKIP: real doc in xfns.c. */)
(Lisp_Object color, Lisp_Object frame)
{
- XColor foo;
+ Emacs_Color foo;
struct frame *f = decode_window_system_frame (frame);
CHECK_STRING (color);
doc: /* SKIP: real doc in xfns.c. */)
(Lisp_Object color, Lisp_Object frame)
{
- XColor foo;
+ Emacs_Color foo;
struct frame *f = decode_window_system_frame (frame);
CHECK_STRING (color);
typedef HBITMAP Bitmap;
typedef XGCValues * GC;
-typedef COLORREF Color;
typedef HWND Window;
typedef HDC Display; /* HDC so it doesn't conflict with xpm lib. */
typedef HCURSOR Cursor;
colors in COLORS. On W32, we no longer try to map colors to
a palette. */
static void
-w32_query_colors (struct frame *f, XColor *colors, int ncolors)
+w32_query_colors (struct frame *f, Emacs_Color *colors, int ncolors)
{
int i;
/* Store F's background color into *BGCOLOR. */
static void
-w32_query_frame_background_color (struct frame *f, XColor *bgcolor)
+w32_query_frame_background_color (struct frame *f, Emacs_Color *bgcolor)
{
bgcolor->pixel = FRAME_BACKGROUND_PIXEL (f);
w32_query_colors (f, bgcolor, 1);
/* initialize palette with white and black */
{
- XColor color;
+ Emacs_Color color;
w32_defined_color (0, "white", &color, true, false);
w32_defined_color (0, "black", &color, true, false);
}
extern struct w32_display_info *w32_term_init (Lisp_Object,
char *, char *);
-extern bool w32_defined_color (struct frame *, const char *, XColor *,
+extern bool w32_defined_color (struct frame *, const char *, Emacs_Color *,
bool, bool);
extern int w32_display_pixel_height (struct w32_display_info *);
extern int w32_display_pixel_width (struct w32_display_info *);
extern BOOL parse_button (int, int, int *, int *);
extern void w32_sys_ring_bell (struct frame *f);
-extern void w32_query_color (struct frame *, XColor *);
+extern void w32_query_color (struct frame *, Emacs_Color *);
extern void w32_delete_display (struct w32_display_info *dpyinfo);
#define FILE_NOTIFICATIONS_SIZE 16384
static bool merge_face_ref (struct window *w,
struct frame *, Lisp_Object, Lisp_Object *,
bool, struct named_merge_point *);
-static int color_distance (XColor *x, XColor *y);
+static int color_distance (Emacs_Color *x, Emacs_Color *y);
#ifdef HAVE_WINDOW_SYSTEM
static void set_font_frame_param (Lisp_Object, Lisp_Object);
\f
/***********************************************************************
- X Colors
+ Color Handling
***********************************************************************/
/* Parse RGB_LIST, and fill in the RGB fields of COLOR.
Return true iff RGB_LIST is OK. */
static bool
-parse_rgb_list (Lisp_Object rgb_list, XColor *color)
+parse_rgb_list (Lisp_Object rgb_list, Emacs_Color *color)
{
#define PARSE_RGB_LIST_FIELD(field) \
if (CONSP (rgb_list) && FIXNUMP (XCAR (rgb_list))) \
returned in it. */
static bool
-tty_lookup_color (struct frame *f, Lisp_Object color, XColor *tty_color,
- XColor *std_color)
+tty_lookup_color (struct frame *f, Lisp_Object color, Emacs_Color *tty_color,
+ Emacs_Color *std_color)
{
Lisp_Object frame, color_desc;
bool
tty_defined_color (struct frame *f, const char *color_name,
- XColor *color_def, bool alloc, bool _makeIndex)
+ Emacs_Color *color_def, bool alloc, bool _makeIndex)
{
bool status = true;
static bool
face_color_gray_p (struct frame *f, const char *color_name)
{
- XColor color;
+ Emacs_Color color;
bool gray_p;
if (FRAME_TERMINAL (f)->defined_color_hook
bool background_p)
{
Lisp_Object frame;
- XColor not_used;
+ Emacs_Color not_used;
XSETFRAME (frame, f);
return
static unsigned long
load_color2 (struct frame *f, struct face *face, Lisp_Object name,
- enum lface_attribute_index target_index, XColor *color)
+ enum lface_attribute_index target_index, Emacs_Color *color)
{
eassert (STRINGP (name));
eassert (target_index == LFACE_FOREGROUND_INDEX
load_color (struct frame *f, struct face *face, Lisp_Object name,
enum lface_attribute_index target_index)
{
- XColor color;
+ Emacs_Color color;
return load_color2 (f, face, name, target_index, &color);
}
Lisp_Object attrs[LFACE_VECTOR_SIZE])
{
Lisp_Object fg, bg, dfg;
- XColor xfg, xbg;
+ Emacs_Color xfg, xbg;
bg = attrs[LFACE_BACKGROUND_INDEX];
fg = attrs[LFACE_FOREGROUND_INDEX];
/* Returns the `distance' between the colors X and Y. */
static int
-color_distance (XColor *x, XColor *y)
+color_distance (Emacs_Color *x, Emacs_Color *y)
{
/* This formula is from a paper titled `Colour metric' by Thiadmer Riemersma.
Quoting from that paper:
Lisp_Object metric)
{
struct frame *f = decode_live_frame (frame);
- XColor cdef1, cdef2;
+ Emacs_Color cdef1, cdef2;
if (!(CONSP (color1) && parse_rgb_list (color1, &cdef1))
&& !(STRINGP (color1)
{
int weight, slant;
Lisp_Object val, fg, bg;
- XColor fg_tty_color, fg_std_color;
- XColor bg_tty_color, bg_std_color;
+ Emacs_Color fg_tty_color, fg_std_color;
+ Emacs_Color bg_tty_color, bg_std_color;
unsigned test_caps = 0;
Lisp_Object *def_attrs = def_face->lface;
else
/* Make sure the color is really different than the default. */
{
- XColor def_fg_color;
+ Emacs_Color def_fg_color;
if (tty_lookup_color (f, def_fg, &def_fg_color, 0)
&& (color_distance (&fg_tty_color, &def_fg_color)
<= TTY_SAME_COLOR_THRESHOLD))
else
/* Make sure the color is really different than the default. */
{
- XColor def_bg_color;
+ Emacs_Color def_bg_color;
if (tty_lookup_color (f, def_bg, &def_bg_color, 0)
&& (color_distance (&bg_tty_color, &def_bg_color)
<= TTY_SAME_COLOR_THRESHOLD))
bool
x_defined_color (struct frame *f, const char *color_name,
- XColor *color, bool alloc_p, bool _makeIndex)
+ Emacs_Color *color, bool alloc_p, bool _makeIndex)
{
bool success_p = false;
Colormap cmap = FRAME_X_COLORMAP (f);
extern void xic_set_preeditarea (struct window *, int, int);
extern void xic_set_statusarea (struct frame *);
extern void xic_set_xfontset (struct frame *, const char *);
-extern bool x_defined_color (struct frame *, const char *, XColor *, bool, bool);
+extern bool x_defined_color (struct frame *, const char *, Emacs_Color *,
+ bool, bool);
#ifdef HAVE_X_I18N
extern void free_frame_xic (struct frame *);
# if defined HAVE_X_WINDOWS && defined USE_X_TOOLKIT