static void
x_set_foreground_color (struct frame *f, Lisp_Object arg, Lisp_Object oldval)
{
- Emacs_Color col;
-
- /* Must block_input, because pgtk_lisp_to_color does block/unblock_input
- which means that col may be deallocated in its unblock_input if there
- is user input, unless we also block_input. */
- block_input ();
- if (pgtk_lisp_to_color (arg, &col))
- {
- store_frame_param (f, Qforeground_color, oldval);
- unblock_input ();
- error ("Unknown color");
- }
+ unsigned long fg;
- FRAME_X_OUTPUT(f)->foreground_color = col.pixel;
-
- FRAME_FOREGROUND_PIXEL (f) = col.pixel;
+ fg = x_decode_color (f, arg, BLACK_PIX_DEFAULT (f));
+ FRAME_FOREGROUND_PIXEL (f) = fg;
+ FRAME_X_OUTPUT(f)->foreground_color = fg;
if (FRAME_GTK_WIDGET (f))
{
if (FRAME_VISIBLE_P (f))
SET_FRAME_GARBAGED (f);
}
- unblock_input ();
}
static void
x_set_background_color (struct frame *f, Lisp_Object arg, Lisp_Object oldval)
{
- Emacs_Color col;
+ unsigned long bg;
- block_input ();
- if (pgtk_lisp_to_color (arg, &col))
- {
- store_frame_param (f, Qbackground_color, oldval);
- unblock_input ();
- error ("Unknown color");
- }
+ bg = x_decode_color (f, arg, WHITE_PIX_DEFAULT (f));
+ FRAME_BACKGROUND_PIXEL (f) = bg;
/* clear the frame */
if (FRAME_VISIBLE_P (f))
pgtk_clear_frame (f);
- PGTK_TRACE("x_set_background_color: col.pixel=%08lx.", col.pixel);
- FRAME_X_OUTPUT(f)->background_color = col.pixel;
- FRAME_BACKGROUND_PIXEL (f) =
- ARGB_TO_ULONG ((unsigned int)(0xff), (unsigned int)(col.red>>8), (unsigned int)(col.green>>8), (unsigned int)(col.blue>>8));
+ PGTK_TRACE("x_set_background_color: col.pixel=%08lx.", bg);
+ FRAME_X_OUTPUT(f)->background_color = bg;
- xg_set_background_color(f, col.pixel);
+ xg_set_background_color(f, bg);
update_face_from_frame_parameter (f, Qbackground_color, arg);
PGTK_TRACE("visible_p=%d.", FRAME_VISIBLE_P(f));
if (FRAME_VISIBLE_P (f))
SET_FRAME_GARBAGED (f);
-
- unblock_input ();
}
static void
{
unsigned long fore_pixel, pixel;
struct pgtk_output *x = f->output_data.pgtk;
- Emacs_Color col;
if (!NILP (Vx_cursor_fore_pixel))
{
- if (pgtk_lisp_to_color(Vx_cursor_fore_pixel, &col))
- signal_error ("Undefined color", Vx_cursor_fore_pixel);
- fore_pixel = col.pixel;
+ fore_pixel = x_decode_color (f, Vx_cursor_fore_pixel,
+ WHITE_PIX_DEFAULT (f));
}
else
fore_pixel = FRAME_BACKGROUND_PIXEL (f);
- if (pgtk_lisp_to_color(arg, &col))
- signal_error ("Undefined color", arg);
- pixel = col.pixel;
+ pixel = x_decode_color (f, arg, BLACK_PIX_DEFAULT (f));
/* Make sure that the cursor color differs from the background color. */
if (pixel == FRAME_BACKGROUND_PIXEL (f))
} else if (STRINGP (new_value)) {
Emacs_Color rgb;
- if (!pgtk_parse_color (SSDATA (new_value), &rgb))
+ if (!pgtk_parse_color (f, SSDATA (new_value), &rgb))
error ("Unknown color.");
char css[64];
} else if (STRINGP (new_value)) {
Emacs_Color rgb;
- if (!pgtk_parse_color (SSDATA (new_value), &rgb))
+ if (!pgtk_parse_color (f, SSDATA (new_value), &rgb))
error ("Unknown color.");
char css[64];
(Lisp_Object color, Lisp_Object frame)
{
Emacs_Color col;
- return pgtk_lisp_to_color (color, &col) ? Qnil : Qt;
+ struct frame *f = decode_window_system_frame (frame);
+
+ CHECK_STRING (color);
+
+ if (pgtk_defined_color (f, SSDATA (color), &col, false, false))
+ return Qt;
+ else
+ return Qnil;
}
(Lisp_Object color, Lisp_Object frame)
{
Emacs_Color col;
+ struct frame *f = decode_window_system_frame (frame);
CHECK_STRING (color);
- block_input ();
-
- if (pgtk_lisp_to_color (color, &col))
- {
- unblock_input ();
- return Qnil;
- }
-
- unblock_input ();
-
- return list3i (col.red, col.green, col.blue);
+ if (pgtk_defined_color (f, SSDATA (color), &col, false, false))
+ return list3i (col.red, col.green, col.blue);
+ else
+ return Qnil;
}
int r;
block_input ();
- r = pgtk_parse_color (name, color_def);
+ r = xg_check_special_colors(f, name, color_def);
+ if (!r)
+ r = pgtk_parse_color (f, name, color_def);
unblock_input ();
return r;
}
and names we've actually looked up; list-colors-display is probably
the most color-intensive case we're likely to hit. */
-int pgtk_parse_color (const char *color_name, Emacs_Color *color)
+int pgtk_parse_color (struct frame *f, const char *color_name, Emacs_Color *color)
{
PGTK_TRACE("pgtk_parse_color: %s", color_name);
return 0;
}
-int
-pgtk_lisp_to_color (Lisp_Object color, Emacs_Color *col)
-/* --------------------------------------------------------------------------
- Convert a Lisp string object to a NS color
- -------------------------------------------------------------------------- */
-{
- PGTK_TRACE("pgtk_lisp_to_color");
- if (STRINGP (color))
- return !pgtk_parse_color (SSDATA (color), col);
- else if (SYMBOLP (color))
- return !pgtk_parse_color (SSDATA (SYMBOL_NAME (color)), col);
- return 1;
-}
-
/* On frame F, translate pixel colors to RGB values for the NCOLORS
colors in COLORS. On W32, we no longer try to map colors to
a palette. */