diff options
| author | Richard M. Stallman | 1994-08-31 20:45:41 +0000 |
|---|---|---|
| committer | Richard M. Stallman | 1994-08-31 20:45:41 +0000 |
| commit | e12d55b237ed2ca3b101e8bf2607fd9b3311da9f (patch) | |
| tree | 53b5af8ce87633aa75e6cb16690d019c6afd0509 /src | |
| parent | 2e71ec172705fd04afcb9658acae603d4cfb975c (diff) | |
| download | emacs-e12d55b237ed2ca3b101e8bf2607fd9b3311da9f.tar.gz emacs-e12d55b237ed2ca3b101e8bf2607fd9b3311da9f.zip | |
(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.
Diffstat (limited to 'src')
| -rw-r--r-- | src/xfns.c | 45 |
1 files changed, 34 insertions, 11 deletions
diff --git a/src/xfns.c b/src/xfns.c index b1c75d29f99..ea41cc8ea81 100644 --- a/src/xfns.c +++ b/src/xfns.c | |||
| @@ -666,12 +666,15 @@ x_report_frame_params (f, alistptr) | |||
| 666 | : FRAME_ICONIFIED_P (f) ? Qicon : Qnil)); | 666 | : FRAME_ICONIFIED_P (f) ? Qicon : Qnil)); |
| 667 | } | 667 | } |
| 668 | 668 | ||
| 669 | /* Decide if color named COLOR is valid for the display | 669 | /* Decide if color named COLOR is valid for the display associated with |
| 670 | associated with the selected frame. */ | 670 | the selected frame; if so, return the rgb values in COLOR_DEF. |
| 671 | If ALLOC is nonzero, allocate a new colormap cell. */ | ||
| 672 | |||
| 671 | int | 673 | int |
| 672 | defined_color (color, color_def) | 674 | defined_color (color, color_def, alloc) |
| 673 | char *color; | 675 | char *color; |
| 674 | Color *color_def; | 676 | Color *color_def; |
| 677 | int alloc; | ||
| 675 | { | 678 | { |
| 676 | register int foo; | 679 | register int foo; |
| 677 | Colormap screen_colormap; | 680 | Colormap screen_colormap; |
| @@ -681,11 +684,13 @@ defined_color (color, color_def) | |||
| 681 | screen_colormap | 684 | screen_colormap |
| 682 | = DefaultColormap (x_current_display, XDefaultScreen (x_current_display)); | 685 | = DefaultColormap (x_current_display, XDefaultScreen (x_current_display)); |
| 683 | 686 | ||
| 684 | foo = XParseColor (x_current_display, screen_colormap, | 687 | foo = XParseColor (x_current_display, screen_colormap, color, color_def); |
| 685 | color, color_def) | 688 | if (foo && alloc) |
| 686 | && XAllocColor (x_current_display, screen_colormap, color_def); | 689 | foo = XAllocColor (x_current_display, screen_colormap, color_def); |
| 687 | #else | 690 | #else |
| 688 | foo = XParseColor (color, color_def) && XGetHardwareColor (color_def); | 691 | foo = XParseColor (color, color_def); |
| 692 | if (foo && alloc) | ||
| 693 | foo = XGetHardwareColor (color_def); | ||
| 689 | #endif /* not HAVE_X11 */ | 694 | #endif /* not HAVE_X11 */ |
| 690 | UNBLOCK_INPUT; | 695 | UNBLOCK_INPUT; |
| 691 | 696 | ||
| @@ -722,7 +727,7 @@ x_decode_color (arg, def) | |||
| 722 | return def; | 727 | return def; |
| 723 | #endif | 728 | #endif |
| 724 | 729 | ||
| 725 | if (defined_color (XSTRING (arg)->data, &cdef)) | 730 | if (defined_color (XSTRING (arg)->data, &cdef, 1)) |
| 726 | return cdef.pixel; | 731 | return cdef.pixel; |
| 727 | else | 732 | else |
| 728 | Fsignal (Qundefined_color, Fcons (arg, Qnil)); | 733 | Fsignal (Qundefined_color, Fcons (arg, Qnil)); |
| @@ -2944,8 +2949,25 @@ even if they match PATTERN and FACE.") | |||
| 2944 | 2949 | ||
| 2945 | 2950 | ||
| 2946 | DEFUN ("x-color-defined-p", Fx_color_defined_p, Sx_color_defined_p, 1, 1, 0, | 2951 | DEFUN ("x-color-defined-p", Fx_color_defined_p, Sx_color_defined_p, 1, 1, 0, |
| 2947 | "Return non-nil if the X display supports the color named COLOR.\n\ | 2952 | "Return non-nil if the X display supports the color named COLOR.") |
| 2948 | The value is actually a list of integer RGB values--(RED GREEN BLUE).") | 2953 | (color) |
| 2954 | Lisp_Object color; | ||
| 2955 | { | ||
| 2956 | Color foo; | ||
| 2957 | |||
| 2958 | check_x (); | ||
| 2959 | CHECK_STRING (color, 0); | ||
| 2960 | |||
| 2961 | if (defined_color (XSTRING (color)->data, &foo, 0)) | ||
| 2962 | return Qt; | ||
| 2963 | else | ||
| 2964 | return Qnil; | ||
| 2965 | } | ||
| 2966 | |||
| 2967 | DEFUN ("x-color-values", Fx_color_values, Sx_color_values, 1, 1, 0, | ||
| 2968 | "Return a description of the color named COLOR.\n\ | ||
| 2969 | The value is a list of integer RGB values--(RED GREEN BLUE).\n\ | ||
| 2970 | These values appear to range from 0 to 65280; white is (65280 65280 65280).") | ||
| 2949 | (color) | 2971 | (color) |
| 2950 | Lisp_Object color; | 2972 | Lisp_Object color; |
| 2951 | { | 2973 | { |
| @@ -2954,7 +2976,7 @@ The value is actually a list of integer RGB values--(RED GREEN BLUE).") | |||
| 2954 | check_x (); | 2976 | check_x (); |
| 2955 | CHECK_STRING (color, 0); | 2977 | CHECK_STRING (color, 0); |
| 2956 | 2978 | ||
| 2957 | if (defined_color (XSTRING (color)->data, &foo)) | 2979 | if (defined_color (XSTRING (color)->data, &foo, 0)) |
| 2958 | { | 2980 | { |
| 2959 | Lisp_Object rgb[3]; | 2981 | Lisp_Object rgb[3]; |
| 2960 | 2982 | ||
| @@ -4467,6 +4489,7 @@ or when you set the mouse color."); | |||
| 4467 | defsubr (&Sx_display_color_p); | 4489 | defsubr (&Sx_display_color_p); |
| 4468 | defsubr (&Sx_list_fonts); | 4490 | defsubr (&Sx_list_fonts); |
| 4469 | defsubr (&Sx_color_defined_p); | 4491 | defsubr (&Sx_color_defined_p); |
| 4492 | defsubr (&Sx_color_values); | ||
| 4470 | defsubr (&Sx_server_max_request_size); | 4493 | defsubr (&Sx_server_max_request_size); |
| 4471 | defsubr (&Sx_server_vendor); | 4494 | defsubr (&Sx_server_vendor); |
| 4472 | defsubr (&Sx_server_version); | 4495 | defsubr (&Sx_server_version); |