aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAlexander Gramiak2019-04-13 20:41:31 -0600
committerAlexander Gramiak2019-04-26 16:55:39 -0600
commit5d8b0fadeec373cd2861328aeb1cb4293cbc9ded (patch)
treec1db5270ae236a1437660b486e6c74fbee4733ff /src
parent41e20ee4bc01576d23fb8fd4f875385ce57eb36a (diff)
downloademacs-5d8b0fadeec373cd2861328aeb1cb4293cbc9ded.tar.gz
emacs-5d8b0fadeec373cd2861328aeb1cb4293cbc9ded.zip
Add terminal hook query_frame_background_color
* src/termhooks.c (query_frame_background_color): New terminal hook. * src/image.c (image_query_frame_background_color): Remove. Use the terminal hook instead. * src/nsterm.m: * src/w32term.c: * src/xterm.c: Implement and set the new terminal hook.
Diffstat (limited to 'src')
-rw-r--r--src/image.c23
-rw-r--r--src/nsterm.m9
-rw-r--r--src/termhooks.h4
-rw-r--r--src/w32term.c9
-rw-r--r--src/xterm.c9
5 files changed, 35 insertions, 19 deletions
diff --git a/src/image.c b/src/image.c
index 0023b9369c1..bf594987eb8 100644
--- a/src/image.c
+++ b/src/image.c
@@ -1306,22 +1306,6 @@ image_background_transparent (struct image *img, struct frame *f, XImagePtr_or_D
1306 return img->background_transparent; 1306 return img->background_transparent;
1307} 1307}
1308 1308
1309#if defined (HAVE_PNG) || defined (HAVE_IMAGEMAGICK) || defined (HAVE_RSVG)
1310
1311/* Store F's background color into *BGCOLOR. */
1312static void
1313image_query_frame_background_color (struct frame *f, XColor *bgcolor)
1314{
1315#ifndef HAVE_NS
1316 bgcolor->pixel = FRAME_BACKGROUND_PIXEL (f);
1317 x_query_color (f, bgcolor);
1318#else
1319 ns_query_color (FRAME_BACKGROUND_COLOR (f), bgcolor, 1);
1320#endif
1321}
1322
1323#endif /* HAVE_PNG || HAVE_IMAGEMAGICK || HAVE_RSVG */
1324
1325/*********************************************************************** 1309/***********************************************************************
1326 Helper functions for X image types 1310 Helper functions for X image types
1327 ***********************************************************************/ 1311 ***********************************************************************/
@@ -6363,7 +6347,8 @@ png_load_body (struct frame *f, struct image *img, struct png_load_context *c)
6363 &color, 6347 &color,
6364 false, 6348 false,
6365 false) 6349 false)
6366 : (image_query_frame_background_color (f, &color), true)) 6350 : (FRAME_TERMINAL (f)->query_frame_background_color (f, &color),
6351 true))
6367 /* The user specified `:background', use that. */ 6352 /* The user specified `:background', use that. */
6368 { 6353 {
6369 int shift = bit_depth == 16 ? 0 : 8; 6354 int shift = bit_depth == 16 ? 0 : 8;
@@ -8816,7 +8801,7 @@ imagemagick_load_image (struct frame *f, struct image *img,
8816 &bgcolor, 8801 &bgcolor,
8817 false, 8802 false,
8818 false)) 8803 false))
8819 image_query_frame_background_color (f, &bgcolor); 8804 FRAME_TERMINAL (f)->query_frame_background_color (f, &bgcolor);
8820 8805
8821 bg_wand = NewPixelWand (); 8806 bg_wand = NewPixelWand ();
8822 PixelSetRed (bg_wand, (double) bgcolor.red / 65535); 8807 PixelSetRed (bg_wand, (double) bgcolor.red / 65535);
@@ -9555,7 +9540,7 @@ svg_load_image (struct frame *f, struct image *img, char *contents,
9555 &background, 9540 &background,
9556 false, 9541 false,
9557 false)) 9542 false))
9558 image_query_frame_background_color (f, &background); 9543 FRAME_TERMINAL (f)->query_frame_background_color (f, &background);
9559 9544
9560 /* SVG pixmaps specify transparency in the last byte, so right 9545 /* SVG pixmaps specify transparency in the last byte, so right
9561 shift 8 bits to get rid of it, since emacs doesn't support 9546 shift 8 bits to get rid of it, since emacs doesn't support
diff --git a/src/nsterm.m b/src/nsterm.m
index 1217eb8e189..cf1ff055304 100644
--- a/src/nsterm.m
+++ b/src/nsterm.m
@@ -2447,6 +2447,14 @@ ns_defined_color (struct frame *f,
2447 return 1; 2447 return 1;
2448} 2448}
2449 2449
2450static void
2451ns_query_frame_background_color (struct frame *f, XColor *bgcolor)
2452/* --------------------------------------------------------------------------
2453 External (hook): Store F's background color into *BGCOLOR
2454 -------------------------------------------------------------------------- */
2455{
2456 ns_query_color (FRAME_BACKGROUND_COLOR (f), bgcolor, true);
2457}
2450 2458
2451static void 2459static void
2452ns_set_frame_alpha (struct frame *f) 2460ns_set_frame_alpha (struct frame *f)
@@ -5233,6 +5241,7 @@ ns_create_terminal (struct ns_display_info *dpyinfo)
5233 terminal->read_socket_hook = ns_read_socket; 5241 terminal->read_socket_hook = ns_read_socket;
5234 terminal->frame_up_to_date_hook = ns_frame_up_to_date; 5242 terminal->frame_up_to_date_hook = ns_frame_up_to_date;
5235 terminal->defined_color_hook = ns_defined_color; 5243 terminal->defined_color_hook = ns_defined_color;
5244 terminal->query_frame_background_color = ns_query_frame_background_color;
5236 terminal->mouse_position_hook = ns_mouse_position; 5245 terminal->mouse_position_hook = ns_mouse_position;
5237 terminal->get_focus_frame = ns_get_focus_frame; 5246 terminal->get_focus_frame = ns_get_focus_frame;
5238 terminal->focus_frame_hook = ns_focus_frame; 5247 terminal->focus_frame_hook = ns_focus_frame;
diff --git a/src/termhooks.h b/src/termhooks.h
index fbc37261330..54f09e03033 100644
--- a/src/termhooks.h
+++ b/src/termhooks.h
@@ -513,6 +513,10 @@ struct terminal
513 513
514 */ 514 */
515 515
516 /* This hook is called to store the frame's background color into
517 BGCOLOR. */
518 void (*query_frame_background_color) (struct frame *f, XColor *bgcolor);
519
516#if defined (HAVE_X_WINDOWS) || defined (HAVE_NTGUI) 520#if defined (HAVE_X_WINDOWS) || defined (HAVE_NTGUI)
517 /* On frame F, translate pixel colors to RGB values for the NCOLORS 521 /* On frame F, translate pixel colors to RGB values for the NCOLORS
518 colors in COLORS. Use cached information, if available. */ 522 colors in COLORS. Use cached information, if available. */
diff --git a/src/w32term.c b/src/w32term.c
index 9d050984f78..65c1baf20f6 100644
--- a/src/w32term.c
+++ b/src/w32term.c
@@ -1608,6 +1608,14 @@ w32_query_colors (struct frame *f, XColor *colors, int ncolors)
1608 } 1608 }
1609} 1609}
1610 1610
1611/* Store F's background color into *BGCOLOR. */
1612
1613static void
1614w32_query_frame_background_color (struct frame *f, XColor *bgcolor)
1615{
1616 bgcolor->pixel = FRAME_BACKGROUND_PIXEL (f);
1617 w32_query_colors (f, bgcolor, 1);
1618}
1611 1619
1612/* Set up the foreground color for drawing relief lines of glyph 1620/* Set up the foreground color for drawing relief lines of glyph
1613 string S. RELIEF is a pointer to a struct relief containing the GC 1621 string S. RELIEF is a pointer to a struct relief containing the GC
@@ -7160,6 +7168,7 @@ w32_create_terminal (struct w32_display_info *dpyinfo)
7160 terminal->read_socket_hook = w32_read_socket; 7168 terminal->read_socket_hook = w32_read_socket;
7161 terminal->frame_up_to_date_hook = w32_frame_up_to_date; 7169 terminal->frame_up_to_date_hook = w32_frame_up_to_date;
7162 terminal->defined_color_hook = w32_defined_color; 7170 terminal->defined_color_hook = w32_defined_color;
7171 terminal->query_frame_background_color = w32_query_frame_background_color;
7163 terminal->query_colors = w32_query_colors; 7172 terminal->query_colors = w32_query_colors;
7164 terminal->mouse_position_hook = w32_mouse_position; 7173 terminal->mouse_position_hook = w32_mouse_position;
7165 terminal->get_focus_frame = w32_get_focus_frame; 7174 terminal->get_focus_frame = w32_get_focus_frame;
diff --git a/src/xterm.c b/src/xterm.c
index d65ad98c4c6..c710d1c918b 100644
--- a/src/xterm.c
+++ b/src/xterm.c
@@ -2325,6 +2325,14 @@ x_query_colors (struct frame *f, XColor *colors, int ncolors)
2325 XQueryColors (FRAME_X_DISPLAY (f), FRAME_X_COLORMAP (f), colors, ncolors); 2325 XQueryColors (FRAME_X_DISPLAY (f), FRAME_X_COLORMAP (f), colors, ncolors);
2326} 2326}
2327 2327
2328/* Store F's background color into *BGCOLOR. */
2329
2330static void
2331x_query_frame_background_color (struct frame *f, XColor *bgcolor)
2332{
2333 bgcolor->pixel = FRAME_BACKGROUND_PIXEL (f);
2334 x_query_colors (f, bgcolor, 1);
2335}
2328 2336
2329/* On frame F, translate the color name to RGB values. Use cached 2337/* On frame F, translate the color name to RGB values. Use cached
2330 information, if possible. 2338 information, if possible.
@@ -13272,6 +13280,7 @@ x_create_terminal (struct x_display_info *dpyinfo)
13272 terminal->frame_up_to_date_hook = XTframe_up_to_date; 13280 terminal->frame_up_to_date_hook = XTframe_up_to_date;
13273 terminal->buffer_flipping_unblocked_hook = XTbuffer_flipping_unblocked_hook; 13281 terminal->buffer_flipping_unblocked_hook = XTbuffer_flipping_unblocked_hook;
13274 terminal->defined_color_hook = x_defined_color; 13282 terminal->defined_color_hook = x_defined_color;
13283 terminal->query_frame_background_color = x_query_frame_background_color;
13275 terminal->query_colors = x_query_colors; 13284 terminal->query_colors = x_query_colors;
13276 terminal->mouse_position_hook = XTmouse_position; 13285 terminal->mouse_position_hook = XTmouse_position;
13277 terminal->get_focus_frame = x_get_focus_frame; 13286 terminal->get_focus_frame = x_get_focus_frame;