diff options
| author | Alexander Gramiak | 2019-04-13 08:59:07 -0600 |
|---|---|---|
| committer | Alexander Gramiak | 2019-04-26 16:55:39 -0600 |
| commit | 41e20ee4bc01576d23fb8fd4f875385ce57eb36a (patch) | |
| tree | c1432a0324447423c5cfbdea70a83fd09dd79991 /src | |
| parent | a411517faf624657aa58979f5463115115093309 (diff) | |
| download | emacs-41e20ee4bc01576d23fb8fd4f875385ce57eb36a.tar.gz emacs-41e20ee4bc01576d23fb8fd4f875385ce57eb36a.zip | |
Add terminal hook defined_color_hook
* src/termhooks.h (defined_color_hook): New terminal hook.
* src/xterm.c:
* src/nsterm.m:
* src/term.c:
* src/w32term.c: Set defined_color_hook.
* src/xfaces.c: Use defined_color_hook.
(defined_color): Remove.
* src/image.c: Remove redefinitions of x_defined_color, and use
defined_color_hook.
Diffstat (limited to 'src')
| -rw-r--r-- | src/dispextern.h | 3 | ||||
| -rw-r--r-- | src/image.c | 50 | ||||
| -rw-r--r-- | src/nsterm.m | 1 | ||||
| -rw-r--r-- | src/term.c | 2 | ||||
| -rw-r--r-- | src/termhooks.h | 12 | ||||
| -rw-r--r-- | src/w32fns.c | 10 | ||||
| -rw-r--r-- | src/w32term.c | 5 | ||||
| -rw-r--r-- | src/w32term.h | 4 | ||||
| -rw-r--r-- | src/xfaces.c | 58 | ||||
| -rw-r--r-- | src/xfns.c | 8 | ||||
| -rw-r--r-- | src/xterm.c | 1 | ||||
| -rw-r--r-- | src/xterm.h | 2 |
12 files changed, 89 insertions, 67 deletions
diff --git a/src/dispextern.h b/src/dispextern.h index 6c1cdf3e2d3..4d6d0371d38 100644 --- a/src/dispextern.h +++ b/src/dispextern.h | |||
| @@ -3413,6 +3413,9 @@ void x_free_colors (struct frame *, unsigned long *, int); | |||
| 3413 | 3413 | ||
| 3414 | void update_face_from_frame_parameter (struct frame *, Lisp_Object, | 3414 | void update_face_from_frame_parameter (struct frame *, Lisp_Object, |
| 3415 | Lisp_Object); | 3415 | Lisp_Object); |
| 3416 | extern bool tty_defined_color (struct frame *f, const char *, XColor *, bool, | ||
| 3417 | bool); | ||
| 3418 | |||
| 3416 | Lisp_Object tty_color_name (struct frame *, int); | 3419 | Lisp_Object tty_color_name (struct frame *, int); |
| 3417 | void clear_face_cache (bool); | 3420 | void clear_face_cache (bool); |
| 3418 | unsigned long load_color (struct frame *, struct face *, Lisp_Object, | 3421 | unsigned long load_color (struct frame *, struct face *, Lisp_Object, |
diff --git a/src/image.c b/src/image.c index 1cf90c88c5c..0023b9369c1 100644 --- a/src/image.c +++ b/src/image.c | |||
| @@ -89,8 +89,6 @@ typedef struct w32_bitmap_record Bitmap_Record; | |||
| 89 | #define PIX_MASK_RETAIN 0 | 89 | #define PIX_MASK_RETAIN 0 |
| 90 | #define PIX_MASK_DRAW 1 | 90 | #define PIX_MASK_DRAW 1 |
| 91 | 91 | ||
| 92 | #define x_defined_color w32_defined_color | ||
| 93 | |||
| 94 | #endif /* HAVE_NTGUI */ | 92 | #endif /* HAVE_NTGUI */ |
| 95 | 93 | ||
| 96 | #ifdef HAVE_NS | 94 | #ifdef HAVE_NS |
| @@ -101,8 +99,6 @@ typedef struct ns_bitmap_record Bitmap_Record; | |||
| 101 | 99 | ||
| 102 | #define PIX_MASK_RETAIN 0 | 100 | #define PIX_MASK_RETAIN 0 |
| 103 | 101 | ||
| 104 | #define x_defined_color(f, name, color_def, alloc) \ | ||
| 105 | ns_defined_color (f, name, color_def, alloc, 0) | ||
| 106 | #endif /* HAVE_NS */ | 102 | #endif /* HAVE_NS */ |
| 107 | 103 | ||
| 108 | #if (defined HAVE_X_WINDOWS \ | 104 | #if (defined HAVE_X_WINDOWS \ |
| @@ -1424,7 +1420,11 @@ image_alloc_image_color (struct frame *f, struct image *img, | |||
| 1424 | 1420 | ||
| 1425 | eassert (STRINGP (color_name)); | 1421 | eassert (STRINGP (color_name)); |
| 1426 | 1422 | ||
| 1427 | if (x_defined_color (f, SSDATA (color_name), &color, 1) | 1423 | if (FRAME_TERMINAL (f)->defined_color_hook (f, |
| 1424 | SSDATA (color_name), | ||
| 1425 | &color, | ||
| 1426 | true, | ||
| 1427 | false) | ||
| 1428 | && img->ncolors < min (min (PTRDIFF_MAX, SIZE_MAX) / sizeof *img->colors, | 1428 | && img->ncolors < min (min (PTRDIFF_MAX, SIZE_MAX) / sizeof *img->colors, |
| 1429 | INT_MAX)) | 1429 | INT_MAX)) |
| 1430 | { | 1430 | { |
| @@ -4470,8 +4470,8 @@ xpm_load_image (struct frame *f, | |||
| 4470 | { | 4470 | { |
| 4471 | if (xstrcasecmp (SSDATA (XCDR (specified_color)), "None") == 0) | 4471 | if (xstrcasecmp (SSDATA (XCDR (specified_color)), "None") == 0) |
| 4472 | color_val = Qt; | 4472 | color_val = Qt; |
| 4473 | else if (x_defined_color (f, SSDATA (XCDR (specified_color)), | 4473 | else if (FRAME_TERMINAL (f)->defined_color_hook |
| 4474 | &cdef, 0)) | 4474 | (f, SSDATA (XCDR (specified_color)), &cdef, false, false)) |
| 4475 | color_val = make_fixnum (cdef.pixel); | 4475 | color_val = make_fixnum (cdef.pixel); |
| 4476 | } | 4476 | } |
| 4477 | } | 4477 | } |
| @@ -4479,7 +4479,8 @@ xpm_load_image (struct frame *f, | |||
| 4479 | { | 4479 | { |
| 4480 | if (xstrcasecmp (max_color, "None") == 0) | 4480 | if (xstrcasecmp (max_color, "None") == 0) |
| 4481 | color_val = Qt; | 4481 | color_val = Qt; |
| 4482 | else if (x_defined_color (f, max_color, &cdef, 0)) | 4482 | else if (FRAME_TERMINAL (f)->defined_color_hook |
| 4483 | (f, max_color, &cdef, false, false)) | ||
| 4483 | color_val = make_fixnum (cdef.pixel); | 4484 | color_val = make_fixnum (cdef.pixel); |
| 4484 | } | 4485 | } |
| 4485 | if (!NILP (color_val)) | 4486 | if (!NILP (color_val)) |
| @@ -5681,7 +5682,11 @@ pbm_load (struct frame *f, struct image *img) | |||
| 5681 | #ifdef USE_CAIRO | 5682 | #ifdef USE_CAIRO |
| 5682 | if (! fmt[PBM_FOREGROUND].count | 5683 | if (! fmt[PBM_FOREGROUND].count |
| 5683 | || ! STRINGP (fmt[PBM_FOREGROUND].value) | 5684 | || ! STRINGP (fmt[PBM_FOREGROUND].value) |
| 5684 | || ! x_defined_color (f, SSDATA (fmt[PBM_FOREGROUND].value), &xfg, 0)) | 5685 | || ! FRAME_TERMINAL (f)->defined_color_hook (f, |
| 5686 | SSDATA (fmt[PBM_FOREGROUND].value), | ||
| 5687 | &xfg, | ||
| 5688 | false, | ||
| 5689 | false)) | ||
| 5685 | { | 5690 | { |
| 5686 | xfg.pixel = fg; | 5691 | xfg.pixel = fg; |
| 5687 | x_query_colors (f, &xfg, 1); | 5692 | x_query_colors (f, &xfg, 1); |
| @@ -5690,7 +5695,11 @@ pbm_load (struct frame *f, struct image *img) | |||
| 5690 | 5695 | ||
| 5691 | if (! fmt[PBM_BACKGROUND].count | 5696 | if (! fmt[PBM_BACKGROUND].count |
| 5692 | || ! STRINGP (fmt[PBM_BACKGROUND].value) | 5697 | || ! STRINGP (fmt[PBM_BACKGROUND].value) |
| 5693 | || ! x_defined_color (f, SSDATA (fmt[PBM_BACKGROUND].value), &xbg, 0)) | 5698 | || ! FRAME_TERMINAL (f)->defined_color_hook (f, |
| 5699 | SSDATA (fmt[PBM_BACKGROUND].value), | ||
| 5700 | &xbg, | ||
| 5701 | false, | ||
| 5702 | false)) | ||
| 5694 | { | 5703 | { |
| 5695 | xbg.pixel = bg; | 5704 | xbg.pixel = bg; |
| 5696 | x_query_colors (f, &xbg, 1); | 5705 | x_query_colors (f, &xbg, 1); |
| @@ -6349,7 +6358,11 @@ png_load_body (struct frame *f, struct image *img, struct png_load_context *c) | |||
| 6349 | current frame background, ignoring any default background | 6358 | current frame background, ignoring any default background |
| 6350 | color set by the image. */ | 6359 | color set by the image. */ |
| 6351 | if (STRINGP (specified_bg) | 6360 | if (STRINGP (specified_bg) |
| 6352 | ? x_defined_color (f, SSDATA (specified_bg), &color, false) | 6361 | ? FRAME_TERMINAL (f)->defined_color_hook (f, |
| 6362 | SSDATA (specified_bg), | ||
| 6363 | &color, | ||
| 6364 | false, | ||
| 6365 | false) | ||
| 6353 | : (image_query_frame_background_color (f, &color), true)) | 6366 | : (image_query_frame_background_color (f, &color), true)) |
| 6354 | /* The user specified `:background', use that. */ | 6367 | /* The user specified `:background', use that. */ |
| 6355 | { | 6368 | { |
| @@ -8036,7 +8049,8 @@ gif_load (struct frame *f, struct image *img) | |||
| 8036 | if (STRINGP (specified_bg)) | 8049 | if (STRINGP (specified_bg)) |
| 8037 | { | 8050 | { |
| 8038 | XColor color; | 8051 | XColor color; |
| 8039 | if (x_defined_color (f, SSDATA (specified_bg), &color, 0)) | 8052 | if (FRAME_TERMINAL (f)->defined_color_hook |
| 8053 | (f, SSDATA (specified_bg), &color, false, false)) | ||
| 8040 | { | 8054 | { |
| 8041 | uint32_t *dataptr = data32; | 8055 | uint32_t *dataptr = data32; |
| 8042 | int r = color.red/256; | 8056 | int r = color.red/256; |
| @@ -8797,7 +8811,11 @@ imagemagick_load_image (struct frame *f, struct image *img, | |||
| 8797 | 8811 | ||
| 8798 | specified_bg = image_spec_value (img->spec, QCbackground, NULL); | 8812 | specified_bg = image_spec_value (img->spec, QCbackground, NULL); |
| 8799 | if (!STRINGP (specified_bg) | 8813 | if (!STRINGP (specified_bg) |
| 8800 | || !x_defined_color (f, SSDATA (specified_bg), &bgcolor, 0)) | 8814 | || !FRAME_TERMINAL (f)->defined_color_hook (f, |
| 8815 | SSDATA (specified_bg), | ||
| 8816 | &bgcolor, | ||
| 8817 | false, | ||
| 8818 | false)) | ||
| 8801 | image_query_frame_background_color (f, &bgcolor); | 8819 | image_query_frame_background_color (f, &bgcolor); |
| 8802 | 8820 | ||
| 8803 | bg_wand = NewPixelWand (); | 8821 | bg_wand = NewPixelWand (); |
| @@ -9532,7 +9550,11 @@ svg_load_image (struct frame *f, struct image *img, char *contents, | |||
| 9532 | XColor background; | 9550 | XColor background; |
| 9533 | Lisp_Object specified_bg = image_spec_value (img->spec, QCbackground, NULL); | 9551 | Lisp_Object specified_bg = image_spec_value (img->spec, QCbackground, NULL); |
| 9534 | if (!STRINGP (specified_bg) | 9552 | if (!STRINGP (specified_bg) |
| 9535 | || !x_defined_color (f, SSDATA (specified_bg), &background, 0)) | 9553 | || !FRAME_TERMINAL (f)->defined_color_hook (f, |
| 9554 | SSDATA (specified_bg), | ||
| 9555 | &background, | ||
| 9556 | false, | ||
| 9557 | false)) | ||
| 9536 | image_query_frame_background_color (f, &background); | 9558 | image_query_frame_background_color (f, &background); |
| 9537 | 9559 | ||
| 9538 | /* SVG pixmaps specify transparency in the last byte, so right | 9560 | /* SVG pixmaps specify transparency in the last byte, so right |
diff --git a/src/nsterm.m b/src/nsterm.m index ae49b659b7a..1217eb8e189 100644 --- a/src/nsterm.m +++ b/src/nsterm.m | |||
| @@ -5232,6 +5232,7 @@ ns_create_terminal (struct ns_display_info *dpyinfo) | |||
| 5232 | terminal->update_end_hook = ns_update_end; | 5232 | terminal->update_end_hook = ns_update_end; |
| 5233 | terminal->read_socket_hook = ns_read_socket; | 5233 | terminal->read_socket_hook = ns_read_socket; |
| 5234 | terminal->frame_up_to_date_hook = ns_frame_up_to_date; | 5234 | terminal->frame_up_to_date_hook = ns_frame_up_to_date; |
| 5235 | terminal->defined_color_hook = ns_defined_color; | ||
| 5235 | terminal->mouse_position_hook = ns_mouse_position; | 5236 | terminal->mouse_position_hook = ns_mouse_position; |
| 5236 | terminal->get_focus_frame = ns_get_focus_frame; | 5237 | terminal->get_focus_frame = ns_get_focus_frame; |
| 5237 | terminal->focus_frame_hook = ns_focus_frame; | 5238 | terminal->focus_frame_hook = ns_focus_frame; |
diff --git a/src/term.c b/src/term.c index 2de0a0e6649..6a8fc2ee932 100644 --- a/src/term.c +++ b/src/term.c | |||
| @@ -3838,6 +3838,7 @@ clear_tty_hooks (struct terminal *terminal) | |||
| 3838 | terminal->update_begin_hook = 0; | 3838 | terminal->update_begin_hook = 0; |
| 3839 | terminal->update_end_hook = 0; | 3839 | terminal->update_end_hook = 0; |
| 3840 | terminal->set_terminal_window_hook = 0; | 3840 | terminal->set_terminal_window_hook = 0; |
| 3841 | terminal->defined_color_hook = 0; | ||
| 3841 | terminal->mouse_position_hook = 0; | 3842 | terminal->mouse_position_hook = 0; |
| 3842 | terminal->frame_rehighlight_hook = 0; | 3843 | terminal->frame_rehighlight_hook = 0; |
| 3843 | terminal->frame_raise_lower_hook = 0; | 3844 | terminal->frame_raise_lower_hook = 0; |
| @@ -3881,6 +3882,7 @@ set_tty_hooks (struct terminal *terminal) | |||
| 3881 | terminal->menu_show_hook = &tty_menu_show; | 3882 | terminal->menu_show_hook = &tty_menu_show; |
| 3882 | #endif | 3883 | #endif |
| 3883 | terminal->set_terminal_window_hook = &tty_set_terminal_window; | 3884 | terminal->set_terminal_window_hook = &tty_set_terminal_window; |
| 3885 | terminal->defined_color_hook = &tty_defined_color; /* xfaces.c */ | ||
| 3884 | terminal->read_socket_hook = &tty_read_avail_input; /* keyboard.c */ | 3886 | terminal->read_socket_hook = &tty_read_avail_input; /* keyboard.c */ |
| 3885 | terminal->delete_frame_hook = &tty_free_frame_resources; | 3887 | terminal->delete_frame_hook = &tty_free_frame_resources; |
| 3886 | terminal->delete_terminal_hook = &delete_tty; | 3888 | terminal->delete_terminal_hook = &delete_tty; |
diff --git a/src/termhooks.h b/src/termhooks.h index b66233cf1c5..fbc37261330 100644 --- a/src/termhooks.h +++ b/src/termhooks.h | |||
| @@ -24,6 +24,7 @@ along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>. */ | |||
| 24 | /* Miscellanea. */ | 24 | /* Miscellanea. */ |
| 25 | 25 | ||
| 26 | #include "lisp.h" | 26 | #include "lisp.h" |
| 27 | #include "dispextern.h" | ||
| 27 | #include "systime.h" /* for Time */ | 28 | #include "systime.h" /* for Time */ |
| 28 | 29 | ||
| 29 | struct glyph; | 30 | struct glyph; |
| @@ -488,6 +489,17 @@ struct terminal | |||
| 488 | void (*update_end_hook) (struct frame *); | 489 | void (*update_end_hook) (struct frame *); |
| 489 | void (*set_terminal_window_hook) (struct frame *, int); | 490 | void (*set_terminal_window_hook) (struct frame *, int); |
| 490 | 491 | ||
| 492 | /* Decide if color named COLOR_NAME is valid for the display | ||
| 493 | associated with the frame F; if so, return the RGB values in | ||
| 494 | COLOR_DEF. If ALLOC (and MAKEINDEX for NS), allocate a new | ||
| 495 | colormap cell. | ||
| 496 | |||
| 497 | If MAKEINDEX (on NS), set COLOR_DEF pixel to ARGB. */ | ||
| 498 | bool (*defined_color_hook) (struct frame *f, const char *color_name, | ||
| 499 | XColor *color_def, | ||
| 500 | bool alloc, | ||
| 501 | bool makeIndex); | ||
| 502 | |||
| 491 | /* Multi-frame and mouse support hooks. */ | 503 | /* Multi-frame and mouse support hooks. */ |
| 492 | 504 | ||
| 493 | /* Graphical window systems are expected to define all of the | 505 | /* Graphical window systems are expected to define all of the |
diff --git a/src/w32fns.c b/src/w32fns.c index 30e5479cdc8..525642bfaab 100644 --- a/src/w32fns.c +++ b/src/w32fns.c | |||
| @@ -1173,9 +1173,9 @@ gamma_correct (struct frame *f, COLORREF *color) | |||
| 1173 | the selected frame; if so, return the rgb values in COLOR_DEF. | 1173 | the selected frame; if so, return the rgb values in COLOR_DEF. |
| 1174 | If ALLOC is nonzero, allocate a new colormap cell. */ | 1174 | If ALLOC is nonzero, allocate a new colormap cell. */ |
| 1175 | 1175 | ||
| 1176 | int | 1176 | bool |
| 1177 | w32_defined_color (struct frame *f, const char *color, XColor *color_def, | 1177 | w32_defined_color (struct frame *f, const char *color, XColor *color_def, |
| 1178 | bool alloc_p) | 1178 | bool alloc_p, bool _makeIndex) |
| 1179 | { | 1179 | { |
| 1180 | register Lisp_Object tem; | 1180 | register Lisp_Object tem; |
| 1181 | COLORREF w32_color_ref; | 1181 | COLORREF w32_color_ref; |
| @@ -1262,7 +1262,7 @@ w32_decode_color (struct frame *f, Lisp_Object arg, int def) | |||
| 1262 | 1262 | ||
| 1263 | /* w32_defined_color is responsible for coping with failures | 1263 | /* w32_defined_color is responsible for coping with failures |
| 1264 | by looking for a near-miss. */ | 1264 | by looking for a near-miss. */ |
| 1265 | if (w32_defined_color (f, SSDATA (arg), &cdef, true)) | 1265 | if (w32_defined_color (f, SSDATA (arg), &cdef, true, false)) |
| 1266 | return cdef.pixel; | 1266 | return cdef.pixel; |
| 1267 | 1267 | ||
| 1268 | /* defined_color failed; return an ultimate default. */ | 1268 | /* defined_color failed; return an ultimate default. */ |
| @@ -6105,7 +6105,7 @@ DEFUN ("xw-color-defined-p", Fxw_color_defined_p, Sxw_color_defined_p, 1, 2, 0, | |||
| 6105 | 6105 | ||
| 6106 | CHECK_STRING (color); | 6106 | CHECK_STRING (color); |
| 6107 | 6107 | ||
| 6108 | if (w32_defined_color (f, SSDATA (color), &foo, false)) | 6108 | if (w32_defined_color (f, SSDATA (color), &foo, false, false)) |
| 6109 | return Qt; | 6109 | return Qt; |
| 6110 | else | 6110 | else |
| 6111 | return Qnil; | 6111 | return Qnil; |
| @@ -6120,7 +6120,7 @@ DEFUN ("xw-color-values", Fxw_color_values, Sxw_color_values, 1, 2, 0, | |||
| 6120 | 6120 | ||
| 6121 | CHECK_STRING (color); | 6121 | CHECK_STRING (color); |
| 6122 | 6122 | ||
| 6123 | if (w32_defined_color (f, SSDATA (color), &foo, false)) | 6123 | if (w32_defined_color (f, SSDATA (color), &foo, false, false)) |
| 6124 | return list3i ((GetRValue (foo.pixel) << 8) | GetRValue (foo.pixel), | 6124 | return list3i ((GetRValue (foo.pixel) << 8) | GetRValue (foo.pixel), |
| 6125 | (GetGValue (foo.pixel) << 8) | GetGValue (foo.pixel), | 6125 | (GetGValue (foo.pixel) << 8) | GetGValue (foo.pixel), |
| 6126 | (GetBValue (foo.pixel) << 8) | GetBValue (foo.pixel)); | 6126 | (GetBValue (foo.pixel) << 8) | GetBValue (foo.pixel)); |
diff --git a/src/w32term.c b/src/w32term.c index fca1ef96ad0..9d050984f78 100644 --- a/src/w32term.c +++ b/src/w32term.c | |||
| @@ -7159,6 +7159,7 @@ w32_create_terminal (struct w32_display_info *dpyinfo) | |||
| 7159 | terminal->update_end_hook = w32_update_end; | 7159 | terminal->update_end_hook = w32_update_end; |
| 7160 | terminal->read_socket_hook = w32_read_socket; | 7160 | terminal->read_socket_hook = w32_read_socket; |
| 7161 | terminal->frame_up_to_date_hook = w32_frame_up_to_date; | 7161 | terminal->frame_up_to_date_hook = w32_frame_up_to_date; |
| 7162 | terminal->defined_color_hook = w32_defined_color; | ||
| 7162 | terminal->query_colors = w32_query_colors; | 7163 | terminal->query_colors = w32_query_colors; |
| 7163 | terminal->mouse_position_hook = w32_mouse_position; | 7164 | terminal->mouse_position_hook = w32_mouse_position; |
| 7164 | terminal->get_focus_frame = w32_get_focus_frame; | 7165 | terminal->get_focus_frame = w32_get_focus_frame; |
| @@ -7262,8 +7263,8 @@ w32_term_init (Lisp_Object display_name, char *xrm_option, char *resource_name) | |||
| 7262 | /* initialize palette with white and black */ | 7263 | /* initialize palette with white and black */ |
| 7263 | { | 7264 | { |
| 7264 | XColor color; | 7265 | XColor color; |
| 7265 | w32_defined_color (0, "white", &color, 1); | 7266 | w32_defined_color (0, "white", &color, true, false); |
| 7266 | w32_defined_color (0, "black", &color, 1); | 7267 | w32_defined_color (0, "black", &color, true, false); |
| 7267 | } | 7268 | } |
| 7268 | 7269 | ||
| 7269 | #ifdef WINDOWSNT | 7270 | #ifdef WINDOWSNT |
diff --git a/src/w32term.h b/src/w32term.h index 6d2765961ce..d5bb08dc675 100644 --- a/src/w32term.h +++ b/src/w32term.h | |||
| @@ -241,8 +241,8 @@ extern void w32_set_scroll_bar_default_height (struct frame *); | |||
| 241 | 241 | ||
| 242 | extern struct w32_display_info *w32_term_init (Lisp_Object, | 242 | extern struct w32_display_info *w32_term_init (Lisp_Object, |
| 243 | char *, char *); | 243 | char *, char *); |
| 244 | extern int w32_defined_color (struct frame *f, const char *color, | 244 | extern bool w32_defined_color (struct frame *, const char *, XColor *, |
| 245 | XColor *color_def, bool alloc_p); | 245 | bool, bool); |
| 246 | extern int w32_display_pixel_height (struct w32_display_info *); | 246 | extern int w32_display_pixel_height (struct w32_display_info *); |
| 247 | extern int w32_display_pixel_width (struct w32_display_info *); | 247 | extern int w32_display_pixel_width (struct w32_display_info *); |
| 248 | extern void initialize_frame_menubar (struct frame *); | 248 | extern void initialize_frame_menubar (struct frame *); |
diff --git a/src/xfaces.c b/src/xfaces.c index 925c3d54ff2..7e04c0e9953 100644 --- a/src/xfaces.c +++ b/src/xfaces.c | |||
| @@ -893,11 +893,11 @@ tty_lookup_color (struct frame *f, Lisp_Object color, XColor *tty_color, | |||
| 893 | return false; | 893 | return false; |
| 894 | } | 894 | } |
| 895 | 895 | ||
| 896 | /* A version of defined_color for non-X frames. */ | 896 | /* An implementation of defined_color_hook for tty frames. */ |
| 897 | 897 | ||
| 898 | static bool | 898 | bool |
| 899 | tty_defined_color (struct frame *f, const char *color_name, | 899 | tty_defined_color (struct frame *f, const char *color_name, |
| 900 | XColor *color_def, bool alloc) | 900 | XColor *color_def, bool alloc, bool _makeIndex) |
| 901 | { | 901 | { |
| 902 | bool status = true; | 902 | bool status = true; |
| 903 | 903 | ||
| @@ -924,36 +924,6 @@ tty_defined_color (struct frame *f, const char *color_name, | |||
| 924 | return status; | 924 | return status; |
| 925 | } | 925 | } |
| 926 | 926 | ||
| 927 | |||
| 928 | /* Decide if color named COLOR_NAME is valid for the display | ||
| 929 | associated with the frame F; if so, return the rgb values in | ||
| 930 | COLOR_DEF. If ALLOC, allocate a new colormap cell. | ||
| 931 | |||
| 932 | This does the right thing for any type of frame. */ | ||
| 933 | |||
| 934 | static bool | ||
| 935 | defined_color (struct frame *f, const char *color_name, XColor *color_def, | ||
| 936 | bool alloc) | ||
| 937 | { | ||
| 938 | if (!FRAME_WINDOW_P (f)) | ||
| 939 | return tty_defined_color (f, color_name, color_def, alloc); | ||
| 940 | #ifdef HAVE_X_WINDOWS | ||
| 941 | else if (FRAME_X_P (f)) | ||
| 942 | return x_defined_color (f, color_name, color_def, alloc); | ||
| 943 | #endif | ||
| 944 | #ifdef HAVE_NTGUI | ||
| 945 | else if (FRAME_W32_P (f)) | ||
| 946 | return w32_defined_color (f, color_name, color_def, alloc); | ||
| 947 | #endif | ||
| 948 | #ifdef HAVE_NS | ||
| 949 | else if (FRAME_NS_P (f)) | ||
| 950 | return ns_defined_color (f, color_name, color_def, alloc, true); | ||
| 951 | #endif | ||
| 952 | else | ||
| 953 | emacs_abort (); | ||
| 954 | } | ||
| 955 | |||
| 956 | |||
| 957 | /* Given the index IDX of a tty color on frame F, return its name, a | 927 | /* Given the index IDX of a tty color on frame F, return its name, a |
| 958 | Lisp string. */ | 928 | Lisp string. */ |
| 959 | 929 | ||
| @@ -998,7 +968,8 @@ face_color_gray_p (struct frame *f, const char *color_name) | |||
| 998 | XColor color; | 968 | XColor color; |
| 999 | bool gray_p; | 969 | bool gray_p; |
| 1000 | 970 | ||
| 1001 | if (defined_color (f, color_name, &color, false)) | 971 | if (FRAME_TERMINAL (f)->defined_color_hook |
| 972 | (f, color_name, &color, false, true)) | ||
| 1002 | gray_p = (/* Any color sufficiently close to black counts as gray. */ | 973 | gray_p = (/* Any color sufficiently close to black counts as gray. */ |
| 1003 | (color.red < 5000 && color.green < 5000 && color.blue < 5000) | 974 | (color.red < 5000 && color.green < 5000 && color.blue < 5000) |
| 1004 | || | 975 | || |
| @@ -1038,7 +1009,7 @@ face_color_supported_p (struct frame *f, const char *color_name, | |||
| 1038 | && face_color_gray_p (f, color_name))) | 1009 | && face_color_gray_p (f, color_name))) |
| 1039 | : | 1010 | : |
| 1040 | #endif | 1011 | #endif |
| 1041 | tty_defined_color (f, color_name, ¬_used, false); | 1012 | tty_defined_color (f, color_name, ¬_used, false, false); |
| 1042 | } | 1013 | } |
| 1043 | 1014 | ||
| 1044 | 1015 | ||
| @@ -1082,9 +1053,10 @@ load_color2 (struct frame *f, struct face *face, Lisp_Object name, | |||
| 1082 | || target_index == LFACE_STRIKE_THROUGH_INDEX | 1053 | || target_index == LFACE_STRIKE_THROUGH_INDEX |
| 1083 | || target_index == LFACE_BOX_INDEX); | 1054 | || target_index == LFACE_BOX_INDEX); |
| 1084 | 1055 | ||
| 1085 | /* if the color map is full, defined_color will return a best match | 1056 | /* if the color map is full, defined_color_hook will return a best match |
| 1086 | to the values in an existing cell. */ | 1057 | to the values in an existing cell. */ |
| 1087 | if (!defined_color (f, SSDATA (name), color, true)) | 1058 | if (!FRAME_TERMINAL (f)->defined_color_hook |
| 1059 | (f, SSDATA (name), color, true, true)) | ||
| 1088 | { | 1060 | { |
| 1089 | add_to_log ("Unable to load color \"%s\"", name); | 1061 | add_to_log ("Unable to load color \"%s\"", name); |
| 1090 | 1062 | ||
| @@ -4235,11 +4207,19 @@ two lists of the form (RED GREEN BLUE) aforementioned. */) | |||
| 4235 | 4207 | ||
| 4236 | if (!(CONSP (color1) && parse_rgb_list (color1, &cdef1)) | 4208 | if (!(CONSP (color1) && parse_rgb_list (color1, &cdef1)) |
| 4237 | && !(STRINGP (color1) | 4209 | && !(STRINGP (color1) |
| 4238 | && defined_color (f, SSDATA (color1), &cdef1, false))) | 4210 | && FRAME_TERMINAL (f)->defined_color_hook (f, |
| 4211 | SSDATA (color1), | ||
| 4212 | &cdef1, | ||
| 4213 | false, | ||
| 4214 | true))) | ||
| 4239 | signal_error ("Invalid color", color1); | 4215 | signal_error ("Invalid color", color1); |
| 4240 | if (!(CONSP (color2) && parse_rgb_list (color2, &cdef2)) | 4216 | if (!(CONSP (color2) && parse_rgb_list (color2, &cdef2)) |
| 4241 | && !(STRINGP (color2) | 4217 | && !(STRINGP (color2) |
| 4242 | && defined_color (f, SSDATA (color2), &cdef2, false))) | 4218 | && FRAME_TERMINAL (f)->defined_color_hook (f, |
| 4219 | SSDATA (color2), | ||
| 4220 | &cdef2, | ||
| 4221 | false, | ||
| 4222 | true))) | ||
| 4243 | signal_error ("Invalid color", color2); | 4223 | signal_error ("Invalid color", color2); |
| 4244 | 4224 | ||
| 4245 | if (NILP (metric)) | 4225 | if (NILP (metric)) |
diff --git a/src/xfns.c b/src/xfns.c index c4bdb3f5cfb..2ceb55a30ad 100644 --- a/src/xfns.c +++ b/src/xfns.c | |||
| @@ -653,7 +653,7 @@ gamma_correct (struct frame *f, XColor *color) | |||
| 653 | 653 | ||
| 654 | bool | 654 | bool |
| 655 | x_defined_color (struct frame *f, const char *color_name, | 655 | x_defined_color (struct frame *f, const char *color_name, |
| 656 | XColor *color, bool alloc_p) | 656 | XColor *color, bool alloc_p, bool _makeIndex) |
| 657 | { | 657 | { |
| 658 | bool success_p = false; | 658 | bool success_p = false; |
| 659 | Colormap cmap = FRAME_X_COLORMAP (f); | 659 | Colormap cmap = FRAME_X_COLORMAP (f); |
| @@ -698,7 +698,7 @@ x_decode_color (struct frame *f, Lisp_Object color_name, int mono_color) | |||
| 698 | 698 | ||
| 699 | /* x_defined_color is responsible for coping with failures | 699 | /* x_defined_color is responsible for coping with failures |
| 700 | by looking for a near-miss. */ | 700 | by looking for a near-miss. */ |
| 701 | if (x_defined_color (f, SSDATA (color_name), &cdef, true)) | 701 | if (x_defined_color (f, SSDATA (color_name), &cdef, true, false)) |
| 702 | return cdef.pixel; | 702 | return cdef.pixel; |
| 703 | 703 | ||
| 704 | signal_error ("Undefined color", color_name); | 704 | signal_error ("Undefined color", color_name); |
| @@ -4110,7 +4110,7 @@ DEFUN ("xw-color-defined-p", Fxw_color_defined_p, Sxw_color_defined_p, 1, 2, 0, | |||
| 4110 | 4110 | ||
| 4111 | CHECK_STRING (color); | 4111 | CHECK_STRING (color); |
| 4112 | 4112 | ||
| 4113 | if (x_defined_color (f, SSDATA (color), &foo, false)) | 4113 | if (x_defined_color (f, SSDATA (color), &foo, false, false)) |
| 4114 | return Qt; | 4114 | return Qt; |
| 4115 | else | 4115 | else |
| 4116 | return Qnil; | 4116 | return Qnil; |
| @@ -4126,7 +4126,7 @@ DEFUN ("xw-color-values", Fxw_color_values, Sxw_color_values, 1, 2, 0, | |||
| 4126 | 4126 | ||
| 4127 | CHECK_STRING (color); | 4127 | CHECK_STRING (color); |
| 4128 | 4128 | ||
| 4129 | if (x_defined_color (f, SSDATA (color), &foo, false)) | 4129 | if (x_defined_color (f, SSDATA (color), &foo, false, false)) |
| 4130 | return list3i (foo.red, foo.green, foo.blue); | 4130 | return list3i (foo.red, foo.green, foo.blue); |
| 4131 | else | 4131 | else |
| 4132 | return Qnil; | 4132 | return Qnil; |
diff --git a/src/xterm.c b/src/xterm.c index a89f13955d3..d65ad98c4c6 100644 --- a/src/xterm.c +++ b/src/xterm.c | |||
| @@ -13271,6 +13271,7 @@ x_create_terminal (struct x_display_info *dpyinfo) | |||
| 13271 | terminal->read_socket_hook = XTread_socket; | 13271 | terminal->read_socket_hook = XTread_socket; |
| 13272 | terminal->frame_up_to_date_hook = XTframe_up_to_date; | 13272 | terminal->frame_up_to_date_hook = XTframe_up_to_date; |
| 13273 | terminal->buffer_flipping_unblocked_hook = XTbuffer_flipping_unblocked_hook; | 13273 | terminal->buffer_flipping_unblocked_hook = XTbuffer_flipping_unblocked_hook; |
| 13274 | terminal->defined_color_hook = x_defined_color; | ||
| 13274 | terminal->query_colors = x_query_colors; | 13275 | terminal->query_colors = x_query_colors; |
| 13275 | terminal->mouse_position_hook = XTmouse_position; | 13276 | terminal->mouse_position_hook = XTmouse_position; |
| 13276 | terminal->get_focus_frame = x_get_focus_frame; | 13277 | terminal->get_focus_frame = x_get_focus_frame; |
diff --git a/src/xterm.h b/src/xterm.h index 20d043e7172..f4007d6e7f3 100644 --- a/src/xterm.h +++ b/src/xterm.h | |||
| @@ -1222,7 +1222,7 @@ extern void destroy_frame_xic (struct frame *); | |||
| 1222 | extern void xic_set_preeditarea (struct window *, int, int); | 1222 | extern void xic_set_preeditarea (struct window *, int, int); |
| 1223 | extern void xic_set_statusarea (struct frame *); | 1223 | extern void xic_set_statusarea (struct frame *); |
| 1224 | extern void xic_set_xfontset (struct frame *, const char *); | 1224 | extern void xic_set_xfontset (struct frame *, const char *); |
| 1225 | extern bool x_defined_color (struct frame *, const char *, XColor *, bool); | 1225 | extern bool x_defined_color (struct frame *, const char *, XColor *, bool, bool); |
| 1226 | #ifdef HAVE_X_I18N | 1226 | #ifdef HAVE_X_I18N |
| 1227 | extern void free_frame_xic (struct frame *); | 1227 | extern void free_frame_xic (struct frame *); |
| 1228 | # if defined HAVE_X_WINDOWS && defined USE_X_TOOLKIT | 1228 | # if defined HAVE_X_WINDOWS && defined USE_X_TOOLKIT |