Commit e12d55b2 authored by Richard M. Stallman's avatar Richard M. Stallman
Browse files

(defined_color): New arg ALLOC--optionally don't allocate the color.

(x_decode_color, Fx_color_defined_p): Pass new arg.
(Fx_color_values): New function.
parent 2e71ec17
...@@ -666,12 +666,15 @@ x_report_frame_params (f, alistptr) ...@@ -666,12 +666,15 @@ x_report_frame_params (f, alistptr)
: FRAME_ICONIFIED_P (f) ? Qicon : Qnil)); : FRAME_ICONIFIED_P (f) ? Qicon : Qnil));
} }
/* Decide if color named COLOR is valid for the display /* Decide if color named COLOR is valid for the display associated with
associated with the selected frame. */ the selected frame; if so, return the rgb values in COLOR_DEF.
If ALLOC is nonzero, allocate a new colormap cell. */
int int
defined_color (color, color_def) defined_color (color, color_def, alloc)
char *color; char *color;
Color *color_def; Color *color_def;
int alloc;
{ {
register int foo; register int foo;
Colormap screen_colormap; Colormap screen_colormap;
...@@ -681,11 +684,13 @@ defined_color (color, color_def) ...@@ -681,11 +684,13 @@ defined_color (color, color_def)
screen_colormap screen_colormap
= DefaultColormap (x_current_display, XDefaultScreen (x_current_display)); = DefaultColormap (x_current_display, XDefaultScreen (x_current_display));
foo = XParseColor (x_current_display, screen_colormap, foo = XParseColor (x_current_display, screen_colormap, color, color_def);
color, color_def) if (foo && alloc)
&& XAllocColor (x_current_display, screen_colormap, color_def); foo = XAllocColor (x_current_display, screen_colormap, color_def);
#else #else
foo = XParseColor (color, color_def) && XGetHardwareColor (color_def); foo = XParseColor (color, color_def);
if (foo && alloc)
foo = XGetHardwareColor (color_def);
#endif /* not HAVE_X11 */ #endif /* not HAVE_X11 */
UNBLOCK_INPUT; UNBLOCK_INPUT;
...@@ -722,7 +727,7 @@ x_decode_color (arg, def) ...@@ -722,7 +727,7 @@ x_decode_color (arg, def)
return def; return def;
#endif #endif
if (defined_color (XSTRING (arg)->data, &cdef)) if (defined_color (XSTRING (arg)->data, &cdef, 1))
return cdef.pixel; return cdef.pixel;
else else
Fsignal (Qundefined_color, Fcons (arg, Qnil)); Fsignal (Qundefined_color, Fcons (arg, Qnil));
...@@ -2944,8 +2949,25 @@ even if they match PATTERN and FACE.") ...@@ -2944,8 +2949,25 @@ even if they match PATTERN and FACE.")
DEFUN ("x-color-defined-p", Fx_color_defined_p, Sx_color_defined_p, 1, 1, 0, DEFUN ("x-color-defined-p", Fx_color_defined_p, Sx_color_defined_p, 1, 1, 0,
"Return non-nil if the X display supports the color named COLOR.\n\ "Return non-nil if the X display supports the color named COLOR.")
The value is actually a list of integer RGB values--(RED GREEN BLUE).") (color)
Lisp_Object color;
{
Color foo;
check_x ();
CHECK_STRING (color, 0);
if (defined_color (XSTRING (color)->data, &foo, 0))
return Qt;
else
return Qnil;
}
DEFUN ("x-color-values", Fx_color_values, Sx_color_values, 1, 1, 0,
"Return a description of the color named COLOR.\n\
The value is a list of integer RGB values--(RED GREEN BLUE).\n\
These values appear to range from 0 to 65280; white is (65280 65280 65280).")
(color) (color)
Lisp_Object color; Lisp_Object color;
{ {
...@@ -2954,7 +2976,7 @@ The value is actually a list of integer RGB values--(RED GREEN BLUE).") ...@@ -2954,7 +2976,7 @@ The value is actually a list of integer RGB values--(RED GREEN BLUE).")
check_x (); check_x ();
CHECK_STRING (color, 0); CHECK_STRING (color, 0);
if (defined_color (XSTRING (color)->data, &foo)) if (defined_color (XSTRING (color)->data, &foo, 0))
{ {
Lisp_Object rgb[3]; Lisp_Object rgb[3];
...@@ -4467,6 +4489,7 @@ or when you set the mouse color."); ...@@ -4467,6 +4489,7 @@ or when you set the mouse color.");
defsubr (&Sx_display_color_p); defsubr (&Sx_display_color_p);
defsubr (&Sx_list_fonts); defsubr (&Sx_list_fonts);
defsubr (&Sx_color_defined_p); defsubr (&Sx_color_defined_p);
defsubr (&Sx_color_values);
defsubr (&Sx_server_max_request_size); defsubr (&Sx_server_max_request_size);
defsubr (&Sx_server_vendor); defsubr (&Sx_server_vendor);
defsubr (&Sx_server_version); defsubr (&Sx_server_version);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment