Skip to contentSkip to conversation

Fix terminal-box not displaying background

PATCH New Michael Chang 1 participant 2 messages Sep 7, 2012

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 Fix terminal-box not displaying background

This patch fixes the terminal-box's background (center image) not update with terminal window's dirty area updates. If black is set as font's background color, as it is designated as transparent color, the terminal-box background will be displayed instead of black color.

This makes terminal windows's background theme-able.

---
 grub-core/gfxmenu/view.c       |    2 ++
 grub-core/gfxmenu/widget-box.c |    7 +++++++
 grub-core/term/gfxterm.c       |   15 ++++++++++++++-
 include/grub/gfxterm.h         |    1 +
 include/grub/gfxwidgets.h      |    1 +
 5 files changed, 25 insertions(+), 1 deletions(-)
grub-core/gfxmenu/view.c +2 -0
index 9023fd3..81c696d 100644
@@ -356,6 +356,8 @@ grub_gfxmenu_draw_terminal_box (void)
   term_box->draw (term_box,
 		  term_rect.x - term_box->get_left_pad (term_box),
 		  term_rect.y - term_box->get_top_pad (term_box));
+
+  bitmap_hook = term_box->get_center_scaled_pixmap(term_box);
 }
 
 static void
grub-core/gfxmenu/widget-box.c +7 -0
index 18e2ef4..fe1a1ee 100644
@@ -172,6 +172,12 @@ set_content_size (grub_gfxmenu_box_t self,
     return;
 }
 
+static struct grub_video_bitmap*
+get_center_scaled_pixmap (grub_gfxmenu_box_t self)
+{
+  return (self->scaled_pixmaps[BOX_PIXMAP_CENTER]);
+}
+
 static int
 get_border_width (grub_gfxmenu_box_t self)
 {
@@ -329,6 +335,7 @@ grub_gfxmenu_create_box (const char *pixmaps_prefix,
 
   box->draw = draw;
   box->set_content_size = set_content_size;
+  box->get_center_scaled_pixmap = get_center_scaled_pixmap;
   box->get_border_width = get_border_width;
 
   box->get_left_pad = get_left_pad;
grub-core/term/gfxterm.c +14 -1
index c995b84..ecb8e22 100644
@@ -111,6 +111,7 @@ struct grub_gfxterm_window
 
 static struct grub_video_render_target *render_target;
 void (*grub_gfxterm_decorator_hook) (void) = NULL;
+struct grub_video_bitmap *bitmap_hook = NULL;
 static struct grub_gfxterm_window window;
 static struct grub_virtual_screen virtual_screen;
 static grub_gfxterm_repaint_callback_t repaint_callback;
@@ -347,6 +348,7 @@ grub_gfxterm_fullscreen (void)
     font_name = "";   /* Allow fallback to any font.  */
 
   grub_gfxterm_decorator_hook = NULL;
+  bitmap_hook = NULL;
 
   return grub_gfxterm_set_window (GRUB_VIDEO_RENDER_TARGET_DISPLAY,
 				  0, 0, mode_info.width, mode_info.height,
@@ -425,6 +427,17 @@ redraw_screen_rect (unsigned int x, unsigned int y,
                            (unsigned *) &saved_view.height);
   grub_video_set_viewport (window.x, window.y, window.width, window.height);
 
+  if (bitmap_hook)
+    {
+      /* Render bitmap as background.  */
+      grub_video_blit_bitmap (bitmap_hook, GRUB_VIDEO_BLIT_REPLACE, x, y,
+                              x - virtual_screen.offset_x,
+                              y - virtual_screen.offset_y,
+                              width, height);
+      blend_text_bg = 1;
+
+    }
+
   if (bitmap)
     {
       /* Render bitmap as background.  */
@@ -472,7 +485,7 @@ redraw_screen_rect (unsigned int x, unsigned int y,
 	  grub_video_fill_rect (color, x, ty, width, h);
         }
     }
-  else
+  else if (!bitmap_hook)
     {
       /* Render background layer.  */
       color = virtual_screen.bg_color_display;
include/grub/gfxterm.h +1 -0
index 3fc8d92..61e001a 100644
@@ -38,5 +38,6 @@ void grub_gfxterm_set_repaint_callback (grub_gfxterm_repaint_callback_t func);
 void EXPORT_FUNC (grub_gfxterm_schedule_repaint) (void);
 
 extern void (*EXPORT_VAR (grub_gfxterm_decorator_hook)) (void);
+extern struct grub_video_bitmap *EXPORT_VAR(bitmap_hook);
 
 #endif /* ! GRUB_GFXTERM_HEADER */
include/grub/gfxwidgets.h +1 -0
index 8ce666c..9cecf0e 100644
@@ -36,6 +36,7 @@ struct grub_gfxmenu_box
   void (*draw) (grub_gfxmenu_box_t self, int x, int y);
   void (*set_content_size) (grub_gfxmenu_box_t self,
                             int width, int height);
+  struct grub_video_bitmap* (*get_center_scaled_pixmap) (grub_gfxmenu_box_t self);
   int (*get_border_width) (grub_gfxmenu_box_t self);
   int (*get_left_pad) (grub_gfxmenu_box_t self);
   int (*get_top_pad) (grub_gfxmenu_box_t self);
Signature · 1 line
1.7.3.4
#1 lore raw

PATCH 2/2 Fix font color not set for booting message

The set color_normal= is not applied to booting message for loading kernel and initrd. It seems like the user terminal font color is errnously reset to default when performing new screen setup.

This patch tries to fix the issue by setting default value during structure initialize and not resetting afterwards. This ensures persistence of user's setting to terminal's font color.

---
 grub-core/term/gfxterm.c |   10 +++++++---
 1 files changed, 7 insertions(+), 3 deletions(-)
grub-core/term/gfxterm.c +7 -3
index ecb8e22..b978b27 100644
@@ -113,7 +113,7 @@ static struct grub_video_render_target *render_target;
 void (*grub_gfxterm_decorator_hook) (void) = NULL;
 struct grub_video_bitmap *bitmap_hook = NULL;
 static struct grub_gfxterm_window window;
-static struct grub_virtual_screen virtual_screen;
+static struct grub_virtual_screen virtual_screen = { .term_color = GRUB_TERM_DEFAULT_NORMAL_COLOR };
 static grub_gfxterm_repaint_callback_t repaint_callback;
 static int repaint_scheduled = 0;
 static int repaint_was_scheduled = 0;
@@ -187,13 +187,19 @@ clear_char (struct grub_colored_char *c)
 static void
 grub_virtual_screen_free (void)
 {
+  grub_uint8_t saved_term_color;
+
   /* If virtual screen has been allocated, free it.  */
   if (virtual_screen.text_buffer != 0)
     grub_free (virtual_screen.text_buffer);
 
+  saved_term_color = virtual_screen.term_color;
+
   /* Reset virtual screen data.  */
   grub_memset (&virtual_screen, 0, sizeof (virtual_screen));
 
+  virtual_screen.term_color = saved_term_color;
+
   /* Free render targets.  */
   grub_video_delete_render_target (text_layer);
   text_layer = 0;
@@ -254,8 +260,6 @@ grub_virtual_screen_setup (unsigned int x, unsigned int y,
 
   virtual_screen.standard_color_setting = DEFAULT_STANDARD_COLOR;
 
-  virtual_screen.term_color = GRUB_TERM_DEFAULT_NORMAL_COLOR;
-
   set_term_color (virtual_screen.term_color);
 
   grub_video_set_active_render_target (render_target);
Signature · 1 line
1.7.3.4