emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] master 5d8b0fa 5/7: Add terminal hook query_frame_backgrou


From: Alexander Gramiak
Subject: [Emacs-diffs] master 5d8b0fa 5/7: Add terminal hook query_frame_background_color
Date: Fri, 26 Apr 2019 18:59:16 -0400 (EDT)

branch: master
commit 5d8b0fadeec373cd2861328aeb1cb4293cbc9ded
Author: Alexander Gramiak <address@hidden>
Commit: Alexander Gramiak <address@hidden>

    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.
---
 src/image.c     | 23 ++++-------------------
 src/nsterm.m    |  9 +++++++++
 src/termhooks.h |  4 ++++
 src/w32term.c   |  9 +++++++++
 src/xterm.c     |  9 +++++++++
 5 files changed, 35 insertions(+), 19 deletions(-)

diff --git a/src/image.c b/src/image.c
index 0023b93..bf59498 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
   return img->background_transparent;
 }
 
-#if defined (HAVE_PNG) || defined (HAVE_IMAGEMAGICK) || defined (HAVE_RSVG)
-
-/* Store F's background color into *BGCOLOR.  */
-static void
-image_query_frame_background_color (struct frame *f, XColor *bgcolor)
-{
-#ifndef HAVE_NS
-  bgcolor->pixel = FRAME_BACKGROUND_PIXEL (f);
-  x_query_color (f, bgcolor);
-#else
-  ns_query_color (FRAME_BACKGROUND_COLOR (f), bgcolor, 1);
-#endif
-}
-
-#endif /* HAVE_PNG || HAVE_IMAGEMAGICK || HAVE_RSVG */
-
 /***********************************************************************
                  Helper functions for X image types
  ***********************************************************************/
@@ -6363,7 +6347,8 @@ png_load_body (struct frame *f, struct image *img, struct 
png_load_context *c)
                                                     &color,
                                                     false,
                                                     false)
-         : (image_query_frame_background_color (f, &color), true))
+         : (FRAME_TERMINAL (f)->query_frame_background_color (f, &color),
+             true))
        /* The user specified `:background', use that.  */
        {
          int shift = bit_depth == 16 ? 0 : 8;
@@ -8816,7 +8801,7 @@ imagemagick_load_image (struct frame *f, struct image 
*img,
                                                     &bgcolor,
                                                     false,
                                                     false))
-      image_query_frame_background_color (f, &bgcolor);
+      FRAME_TERMINAL (f)->query_frame_background_color (f, &bgcolor);
 
     bg_wand = NewPixelWand ();
     PixelSetRed   (bg_wand, (double) bgcolor.red   / 65535);
@@ -9555,7 +9540,7 @@ svg_load_image (struct frame *f, struct image *img, char 
*contents,
                                                     &background,
                                                     false,
                                                     false))
-      image_query_frame_background_color (f, &background);
+      FRAME_TERMINAL (f)->query_frame_background_color (f, &background);
 
     /* SVG pixmaps specify transparency in the last byte, so right
        shift 8 bits to get rid of it, since emacs doesn't support
diff --git a/src/nsterm.m b/src/nsterm.m
index 1217eb8..cf1ff05 100644
--- a/src/nsterm.m
+++ b/src/nsterm.m
@@ -2447,6 +2447,14 @@ ns_defined_color (struct frame *f,
   return 1;
 }
 
+static void
+ns_query_frame_background_color (struct frame *f, XColor *bgcolor)
+/* --------------------------------------------------------------------------
+     External (hook): Store F's background color into *BGCOLOR
+   -------------------------------------------------------------------------- 
*/
+{
+  ns_query_color (FRAME_BACKGROUND_COLOR (f), bgcolor, true);
+}
 
 static void
 ns_set_frame_alpha (struct frame *f)
@@ -5233,6 +5241,7 @@ ns_create_terminal (struct ns_display_info *dpyinfo)
   terminal->read_socket_hook = ns_read_socket;
   terminal->frame_up_to_date_hook = ns_frame_up_to_date;
   terminal->defined_color_hook = ns_defined_color;
+  terminal->query_frame_background_color = ns_query_frame_background_color;
   terminal->mouse_position_hook = ns_mouse_position;
   terminal->get_focus_frame = ns_get_focus_frame;
   terminal->focus_frame_hook = ns_focus_frame;
diff --git a/src/termhooks.h b/src/termhooks.h
index fbc3726..54f09e0 100644
--- a/src/termhooks.h
+++ b/src/termhooks.h
@@ -513,6 +513,10 @@ struct terminal
 
    */
 
+  /* This hook is called to store the frame's background color into
+     BGCOLOR.  */
+  void (*query_frame_background_color) (struct frame *f, XColor *bgcolor);
+
 #if defined (HAVE_X_WINDOWS) || defined (HAVE_NTGUI)
   /* On frame F, translate pixel colors to RGB values for the NCOLORS
      colors in COLORS.  Use cached information, if available.  */
diff --git a/src/w32term.c b/src/w32term.c
index 9d05098..65c1baf 100644
--- a/src/w32term.c
+++ b/src/w32term.c
@@ -1608,6 +1608,14 @@ w32_query_colors (struct frame *f, XColor *colors, int 
ncolors)
     }
 }
 
+/* Store F's background color into *BGCOLOR.  */
+
+static void
+w32_query_frame_background_color (struct frame *f, XColor *bgcolor)
+{
+  bgcolor->pixel = FRAME_BACKGROUND_PIXEL (f);
+  w32_query_colors (f, bgcolor, 1);
+}
 
 /* Set up the foreground color for drawing relief lines of glyph
    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)
   terminal->read_socket_hook = w32_read_socket;
   terminal->frame_up_to_date_hook = w32_frame_up_to_date;
   terminal->defined_color_hook = w32_defined_color;
+  terminal->query_frame_background_color = w32_query_frame_background_color;
   terminal->query_colors = w32_query_colors;
   terminal->mouse_position_hook = w32_mouse_position;
   terminal->get_focus_frame = w32_get_focus_frame;
diff --git a/src/xterm.c b/src/xterm.c
index d65ad98..c710d1c 100644
--- a/src/xterm.c
+++ b/src/xterm.c
@@ -2325,6 +2325,14 @@ x_query_colors (struct frame *f, XColor *colors, int 
ncolors)
   XQueryColors (FRAME_X_DISPLAY (f), FRAME_X_COLORMAP (f), colors, ncolors);
 }
 
+/* Store F's background color into *BGCOLOR.  */
+
+static void
+x_query_frame_background_color (struct frame *f, XColor *bgcolor)
+{
+  bgcolor->pixel = FRAME_BACKGROUND_PIXEL (f);
+  x_query_colors (f, bgcolor, 1);
+}
 
 /* On frame F, translate the color name to RGB values.  Use cached
    information, if possible.
@@ -13272,6 +13280,7 @@ x_create_terminal (struct x_display_info *dpyinfo)
   terminal->frame_up_to_date_hook = XTframe_up_to_date;
   terminal->buffer_flipping_unblocked_hook = XTbuffer_flipping_unblocked_hook;
   terminal->defined_color_hook = x_defined_color;
+  terminal->query_frame_background_color = x_query_frame_background_color;
   terminal->query_colors = x_query_colors;
   terminal->mouse_position_hook = XTmouse_position;
   terminal->get_focus_frame = x_get_focus_frame;



reply via email to

[Prev in Thread] Current Thread [Next in Thread]