diff options
| author | Yuuki Harano | 2020-05-12 22:39:15 +0900 |
|---|---|---|
| committer | Jeff Walsh | 2020-11-24 12:24:40 +1100 |
| commit | d68633bfa1124e32f6aa6a288a9c7b2098a39bd8 (patch) | |
| tree | cff14bac6d7ece318d90b72e2e1919a195798c72 /src | |
| parent | fe2297ce7aa0e400f4a80484e2872dcee0de1391 (diff) | |
| download | emacs-d68633bfa1124e32f6aa6a288a9c7b2098a39bd8.tar.gz emacs-d68633bfa1124e32f6aa6a288a9c7b2098a39bd8.zip | |
* src/pgtkterm.c (pgtk_defined_color): support gtk special colors
Color functions take the frame
* src/gtkutil.c (xg_check_special_colors): pass frame as argument.
* src/pgtkfns.c (x_set_foreground_color, x_set_background_color,
x_set_cursor_color, pgtk_set_scroll_bar_foreground,
pgtk_set_scroll_bar_background, Fxw_color_defined_p,
Fxw_color_values): pass frame as argument.
* src/pgtkterm.c (pgtk_parse_color): take frame as argument.
(pgtk_lisp_to_color): take frame as argument, and pass it.
Remove pgtk_lisp_to_color
* src/pgtkfns.c (x_set_foreground_color, x_set_background_color,
x_set_cursor_color): use x_decode_color instead of pgtk_lisp_to_color.
(Fxw_color_defined_p, Fxw_color_values):
use pgtk_defined_color instead of pgtk_lisp_to_color.
* src/pgtkterm.c (pgtk_lisp_to_color): remove.
* src/gtkutil.c (xg_check_special_colors): change color format
* src/pgtkterm.h: remove pgtk_lisp_to_color declaration
Diffstat (limited to 'src')
| -rw-r--r-- | src/gtkutil.c | 5 | ||||
| -rw-r--r-- | src/pgtkfns.c | 80 | ||||
| -rw-r--r-- | src/pgtkterm.c | 20 | ||||
| -rw-r--r-- | src/pgtkterm.h | 3 |
4 files changed, 36 insertions, 72 deletions
diff --git a/src/gtkutil.c b/src/gtkutil.c index 16fac6cc08d..ce08ffec375 100644 --- a/src/gtkutil.c +++ b/src/gtkutil.c | |||
| @@ -710,11 +710,12 @@ xg_check_special_colors (struct frame *f, | |||
| 710 | r = col.red * 65535, | 710 | r = col.red * 65535, |
| 711 | g = col.green * 65535, | 711 | g = col.green * 65535, |
| 712 | b = col.blue * 65535; | 712 | b = col.blue * 65535; |
| 713 | sprintf (buf, "rgb:%04x/%04x/%04x", r, g, b); | ||
| 714 | #ifndef HAVE_PGTK | 713 | #ifndef HAVE_PGTK |
| 714 | sprintf (buf, "rgb:%04x/%04x/%04x", r, g, b); | ||
| 715 | success_p = x_parse_color (f, buf, color) != 0; | 715 | success_p = x_parse_color (f, buf, color) != 0; |
| 716 | #else | 716 | #else |
| 717 | success_p = pgtk_parse_color (buf, color) != 0; | 717 | sprintf (buf, "#%04x%04x%04x", r, g, b); |
| 718 | success_p = pgtk_parse_color (f, buf, color) != 0; | ||
| 718 | #endif | 719 | #endif |
| 719 | #else | 720 | #else |
| 720 | GtkStyle *gsty = gtk_widget_get_style (FRAME_GTK_WIDGET (f)); | 721 | GtkStyle *gsty = gtk_widget_get_style (FRAME_GTK_WIDGET (f)); |
diff --git a/src/pgtkfns.c b/src/pgtkfns.c index 79c9aab1a22..feda0933848 100644 --- a/src/pgtkfns.c +++ b/src/pgtkfns.c | |||
| @@ -133,22 +133,11 @@ pgtk_display_info_for_name (Lisp_Object name) | |||
| 133 | static void | 133 | static void |
| 134 | x_set_foreground_color (struct frame *f, Lisp_Object arg, Lisp_Object oldval) | 134 | x_set_foreground_color (struct frame *f, Lisp_Object arg, Lisp_Object oldval) |
| 135 | { | 135 | { |
| 136 | Emacs_Color col; | 136 | unsigned long fg; |
| 137 | |||
| 138 | /* Must block_input, because pgtk_lisp_to_color does block/unblock_input | ||
| 139 | which means that col may be deallocated in its unblock_input if there | ||
| 140 | is user input, unless we also block_input. */ | ||
| 141 | block_input (); | ||
| 142 | if (pgtk_lisp_to_color (arg, &col)) | ||
| 143 | { | ||
| 144 | store_frame_param (f, Qforeground_color, oldval); | ||
| 145 | unblock_input (); | ||
| 146 | error ("Unknown color"); | ||
| 147 | } | ||
| 148 | 137 | ||
| 149 | FRAME_X_OUTPUT(f)->foreground_color = col.pixel; | 138 | fg = x_decode_color (f, arg, BLACK_PIX_DEFAULT (f)); |
| 150 | 139 | FRAME_FOREGROUND_PIXEL (f) = fg; | |
| 151 | FRAME_FOREGROUND_PIXEL (f) = col.pixel; | 140 | FRAME_X_OUTPUT(f)->foreground_color = fg; |
| 152 | 141 | ||
| 153 | if (FRAME_GTK_WIDGET (f)) | 142 | if (FRAME_GTK_WIDGET (f)) |
| 154 | { | 143 | { |
| @@ -157,40 +146,30 @@ x_set_foreground_color (struct frame *f, Lisp_Object arg, Lisp_Object oldval) | |||
| 157 | if (FRAME_VISIBLE_P (f)) | 146 | if (FRAME_VISIBLE_P (f)) |
| 158 | SET_FRAME_GARBAGED (f); | 147 | SET_FRAME_GARBAGED (f); |
| 159 | } | 148 | } |
| 160 | unblock_input (); | ||
| 161 | } | 149 | } |
| 162 | 150 | ||
| 163 | 151 | ||
| 164 | static void | 152 | static void |
| 165 | x_set_background_color (struct frame *f, Lisp_Object arg, Lisp_Object oldval) | 153 | x_set_background_color (struct frame *f, Lisp_Object arg, Lisp_Object oldval) |
| 166 | { | 154 | { |
| 167 | Emacs_Color col; | 155 | unsigned long bg; |
| 168 | 156 | ||
| 169 | block_input (); | 157 | bg = x_decode_color (f, arg, WHITE_PIX_DEFAULT (f)); |
| 170 | if (pgtk_lisp_to_color (arg, &col)) | 158 | FRAME_BACKGROUND_PIXEL (f) = bg; |
| 171 | { | ||
| 172 | store_frame_param (f, Qbackground_color, oldval); | ||
| 173 | unblock_input (); | ||
| 174 | error ("Unknown color"); | ||
| 175 | } | ||
| 176 | 159 | ||
| 177 | /* clear the frame */ | 160 | /* clear the frame */ |
| 178 | if (FRAME_VISIBLE_P (f)) | 161 | if (FRAME_VISIBLE_P (f)) |
| 179 | pgtk_clear_frame (f); | 162 | pgtk_clear_frame (f); |
| 180 | 163 | ||
| 181 | PGTK_TRACE("x_set_background_color: col.pixel=%08lx.", col.pixel); | 164 | PGTK_TRACE("x_set_background_color: col.pixel=%08lx.", bg); |
| 182 | FRAME_X_OUTPUT(f)->background_color = col.pixel; | 165 | FRAME_X_OUTPUT(f)->background_color = bg; |
| 183 | FRAME_BACKGROUND_PIXEL (f) = | ||
| 184 | ARGB_TO_ULONG ((unsigned int)(0xff), (unsigned int)(col.red>>8), (unsigned int)(col.green>>8), (unsigned int)(col.blue>>8)); | ||
| 185 | 166 | ||
| 186 | xg_set_background_color(f, col.pixel); | 167 | xg_set_background_color(f, bg); |
| 187 | update_face_from_frame_parameter (f, Qbackground_color, arg); | 168 | update_face_from_frame_parameter (f, Qbackground_color, arg); |
| 188 | 169 | ||
| 189 | PGTK_TRACE("visible_p=%d.", FRAME_VISIBLE_P(f)); | 170 | PGTK_TRACE("visible_p=%d.", FRAME_VISIBLE_P(f)); |
| 190 | if (FRAME_VISIBLE_P (f)) | 171 | if (FRAME_VISIBLE_P (f)) |
| 191 | SET_FRAME_GARBAGED (f); | 172 | SET_FRAME_GARBAGED (f); |
| 192 | |||
| 193 | unblock_input (); | ||
| 194 | } | 173 | } |
| 195 | 174 | ||
| 196 | static void | 175 | static void |
| @@ -209,20 +188,16 @@ x_set_cursor_color (struct frame *f, Lisp_Object arg, Lisp_Object oldval) | |||
| 209 | { | 188 | { |
| 210 | unsigned long fore_pixel, pixel; | 189 | unsigned long fore_pixel, pixel; |
| 211 | struct pgtk_output *x = f->output_data.pgtk; | 190 | struct pgtk_output *x = f->output_data.pgtk; |
| 212 | Emacs_Color col; | ||
| 213 | 191 | ||
| 214 | if (!NILP (Vx_cursor_fore_pixel)) | 192 | if (!NILP (Vx_cursor_fore_pixel)) |
| 215 | { | 193 | { |
| 216 | if (pgtk_lisp_to_color(Vx_cursor_fore_pixel, &col)) | 194 | fore_pixel = x_decode_color (f, Vx_cursor_fore_pixel, |
| 217 | signal_error ("Undefined color", Vx_cursor_fore_pixel); | 195 | WHITE_PIX_DEFAULT (f)); |
| 218 | fore_pixel = col.pixel; | ||
| 219 | } | 196 | } |
| 220 | else | 197 | else |
| 221 | fore_pixel = FRAME_BACKGROUND_PIXEL (f); | 198 | fore_pixel = FRAME_BACKGROUND_PIXEL (f); |
| 222 | 199 | ||
| 223 | if (pgtk_lisp_to_color(arg, &col)) | 200 | pixel = x_decode_color (f, arg, BLACK_PIX_DEFAULT (f)); |
| 224 | signal_error ("Undefined color", arg); | ||
| 225 | pixel = col.pixel; | ||
| 226 | 201 | ||
| 227 | /* Make sure that the cursor color differs from the background color. */ | 202 | /* Make sure that the cursor color differs from the background color. */ |
| 228 | if (pixel == FRAME_BACKGROUND_PIXEL (f)) | 203 | if (pixel == FRAME_BACKGROUND_PIXEL (f)) |
| @@ -817,7 +792,7 @@ pgtk_set_scroll_bar_foreground (struct frame *f, Lisp_Object new_value, Lisp_Obj | |||
| 817 | } else if (STRINGP (new_value)) { | 792 | } else if (STRINGP (new_value)) { |
| 818 | Emacs_Color rgb; | 793 | Emacs_Color rgb; |
| 819 | 794 | ||
| 820 | if (!pgtk_parse_color (SSDATA (new_value), &rgb)) | 795 | if (!pgtk_parse_color (f, SSDATA (new_value), &rgb)) |
| 821 | error ("Unknown color."); | 796 | error ("Unknown color."); |
| 822 | 797 | ||
| 823 | char css[64]; | 798 | char css[64]; |
| @@ -838,7 +813,7 @@ pgtk_set_scroll_bar_background (struct frame *f, Lisp_Object new_value, Lisp_Obj | |||
| 838 | } else if (STRINGP (new_value)) { | 813 | } else if (STRINGP (new_value)) { |
| 839 | Emacs_Color rgb; | 814 | Emacs_Color rgb; |
| 840 | 815 | ||
| 841 | if (!pgtk_parse_color (SSDATA (new_value), &rgb)) | 816 | if (!pgtk_parse_color (f, SSDATA (new_value), &rgb)) |
| 842 | error ("Unknown color."); | 817 | error ("Unknown color."); |
| 843 | 818 | ||
| 844 | char css[64]; | 819 | char css[64]; |
| @@ -2149,7 +2124,14 @@ DEFUN ("xw-color-defined-p", Fxw_color_defined_p, Sxw_color_defined_p, 1, 2, 0, | |||
| 2149 | (Lisp_Object color, Lisp_Object frame) | 2124 | (Lisp_Object color, Lisp_Object frame) |
| 2150 | { | 2125 | { |
| 2151 | Emacs_Color col; | 2126 | Emacs_Color col; |
| 2152 | return pgtk_lisp_to_color (color, &col) ? Qnil : Qt; | 2127 | struct frame *f = decode_window_system_frame (frame); |
| 2128 | |||
| 2129 | CHECK_STRING (color); | ||
| 2130 | |||
| 2131 | if (pgtk_defined_color (f, SSDATA (color), &col, false, false)) | ||
| 2132 | return Qt; | ||
| 2133 | else | ||
| 2134 | return Qnil; | ||
| 2153 | } | 2135 | } |
| 2154 | 2136 | ||
| 2155 | 2137 | ||
| @@ -2158,20 +2140,14 @@ DEFUN ("xw-color-values", Fxw_color_values, Sxw_color_values, 1, 2, 0, | |||
| 2158 | (Lisp_Object color, Lisp_Object frame) | 2140 | (Lisp_Object color, Lisp_Object frame) |
| 2159 | { | 2141 | { |
| 2160 | Emacs_Color col; | 2142 | Emacs_Color col; |
| 2143 | struct frame *f = decode_window_system_frame (frame); | ||
| 2161 | 2144 | ||
| 2162 | CHECK_STRING (color); | 2145 | CHECK_STRING (color); |
| 2163 | 2146 | ||
| 2164 | block_input (); | 2147 | if (pgtk_defined_color (f, SSDATA (color), &col, false, false)) |
| 2165 | 2148 | return list3i (col.red, col.green, col.blue); | |
| 2166 | if (pgtk_lisp_to_color (color, &col)) | 2149 | else |
| 2167 | { | 2150 | return Qnil; |
| 2168 | unblock_input (); | ||
| 2169 | return Qnil; | ||
| 2170 | } | ||
| 2171 | |||
| 2172 | unblock_input (); | ||
| 2173 | |||
| 2174 | return list3i (col.red, col.green, col.blue); | ||
| 2175 | } | 2151 | } |
| 2176 | 2152 | ||
| 2177 | 2153 | ||
diff --git a/src/pgtkterm.c b/src/pgtkterm.c index 2d1a990483f..ef8daba720a 100644 --- a/src/pgtkterm.c +++ b/src/pgtkterm.c | |||
| @@ -6436,7 +6436,9 @@ pgtk_defined_color (struct frame *f, | |||
| 6436 | int r; | 6436 | int r; |
| 6437 | 6437 | ||
| 6438 | block_input (); | 6438 | block_input (); |
| 6439 | r = pgtk_parse_color (name, color_def); | 6439 | r = xg_check_special_colors(f, name, color_def); |
| 6440 | if (!r) | ||
| 6441 | r = pgtk_parse_color (f, name, color_def); | ||
| 6440 | unblock_input (); | 6442 | unblock_input (); |
| 6441 | return r; | 6443 | return r; |
| 6442 | } | 6444 | } |
| @@ -6449,7 +6451,7 @@ pgtk_defined_color (struct frame *f, | |||
| 6449 | and names we've actually looked up; list-colors-display is probably | 6451 | and names we've actually looked up; list-colors-display is probably |
| 6450 | the most color-intensive case we're likely to hit. */ | 6452 | the most color-intensive case we're likely to hit. */ |
| 6451 | 6453 | ||
| 6452 | int pgtk_parse_color (const char *color_name, Emacs_Color *color) | 6454 | int pgtk_parse_color (struct frame *f, const char *color_name, Emacs_Color *color) |
| 6453 | { | 6455 | { |
| 6454 | PGTK_TRACE("pgtk_parse_color: %s", color_name); | 6456 | PGTK_TRACE("pgtk_parse_color: %s", color_name); |
| 6455 | 6457 | ||
| @@ -6468,20 +6470,6 @@ int pgtk_parse_color (const char *color_name, Emacs_Color *color) | |||
| 6468 | return 0; | 6470 | return 0; |
| 6469 | } | 6471 | } |
| 6470 | 6472 | ||
| 6471 | int | ||
| 6472 | pgtk_lisp_to_color (Lisp_Object color, Emacs_Color *col) | ||
| 6473 | /* -------------------------------------------------------------------------- | ||
| 6474 | Convert a Lisp string object to a NS color | ||
| 6475 | -------------------------------------------------------------------------- */ | ||
| 6476 | { | ||
| 6477 | PGTK_TRACE("pgtk_lisp_to_color"); | ||
| 6478 | if (STRINGP (color)) | ||
| 6479 | return !pgtk_parse_color (SSDATA (color), col); | ||
| 6480 | else if (SYMBOLP (color)) | ||
| 6481 | return !pgtk_parse_color (SSDATA (SYMBOL_NAME (color)), col); | ||
| 6482 | return 1; | ||
| 6483 | } | ||
| 6484 | |||
| 6485 | /* On frame F, translate pixel colors to RGB values for the NCOLORS | 6473 | /* On frame F, translate pixel colors to RGB values for the NCOLORS |
| 6486 | colors in COLORS. On W32, we no longer try to map colors to | 6474 | colors in COLORS. On W32, we no longer try to map colors to |
| 6487 | a palette. */ | 6475 | a palette. */ |
diff --git a/src/pgtkterm.h b/src/pgtkterm.h index 706198aa8a4..b92a2cd1d19 100644 --- a/src/pgtkterm.h +++ b/src/pgtkterm.h | |||
| @@ -534,8 +534,7 @@ extern bool pgtk_defined_color (struct frame *f, | |||
| 534 | bool makeIndex); | 534 | bool makeIndex); |
| 535 | extern void pgtk_query_color (struct frame *f, Emacs_Color *color); | 535 | extern void pgtk_query_color (struct frame *f, Emacs_Color *color); |
| 536 | extern void pgtk_query_colors (struct frame *f, Emacs_Color *colors, int ncolors); | 536 | extern void pgtk_query_colors (struct frame *f, Emacs_Color *colors, int ncolors); |
| 537 | extern int pgtk_parse_color (const char *color_name, Emacs_Color *color); | 537 | extern int pgtk_parse_color (struct frame *f, const char *color_name, Emacs_Color *color); |
| 538 | extern int pgtk_lisp_to_color (Lisp_Object color, Emacs_Color *col); | ||
| 539 | 538 | ||
| 540 | /* Implemented in pgtkterm.c */ | 539 | /* Implemented in pgtkterm.c */ |
| 541 | extern void pgtk_clear_area (struct frame *f, int x, int y, int width, int height); | 540 | extern void pgtk_clear_area (struct frame *f, int x, int y, int width, int height); |