nalika / rpms / grub2

Forked from rpms/grub2 2 years ago
Clone

Blame SOURCES/0063-grub-core-gfxmenu-view.c-init_terminal-Avoid-making-.patch

f96e0b
From 92e7e2d5571844ef1604386f442eaf1e4085ed64 Mon Sep 17 00:00:00 2001
f96e0b
From: "Dr. Tilmann Bubeck" <t.bubeck@reinform.de>
f96e0b
Date: Mon, 10 Dec 2012 16:14:12 +0100
f96e0b
Subject: [PATCH 063/482] 	* grub-core/gfxmenu/view.c (init_terminal):
f96e0b
 Avoid making terminal 	window too small.
f96e0b
f96e0b
---
f96e0b
 ChangeLog                |  5 +++++
f96e0b
 grub-core/gfxmenu/view.c | 31 +++++++++++++++++++++++++++----
f96e0b
 2 files changed, 32 insertions(+), 4 deletions(-)
f96e0b
f96e0b
diff --git a/ChangeLog b/ChangeLog
f96e0b
index 7617678..ce822ee 100644
f96e0b
--- a/ChangeLog
f96e0b
+++ b/ChangeLog
f96e0b
@@ -1,3 +1,8 @@
f96e0b
+2012-12-10  Dr. Tilmann Bubeck <t.bubeck@reinform.de>
f96e0b
+
f96e0b
+	* grub-core/gfxmenu/view.c (init_terminal): Avoid making terminal
f96e0b
+	window too small.
f96e0b
+
f96e0b
 2012-12-10  Vladimir Serbinenko  <phcoder@gmail.com>
f96e0b
 
f96e0b
 	* grub-core/term/gfxterm.c (grub_virtual_screen_setup): Get font as
f96e0b
diff --git a/grub-core/gfxmenu/view.c b/grub-core/gfxmenu/view.c
f96e0b
index c005773..1918ea4 100644
f96e0b
--- a/grub-core/gfxmenu/view.c
f96e0b
+++ b/grub-core/gfxmenu/view.c
f96e0b
@@ -361,8 +361,14 @@ grub_gfxmenu_draw_terminal_box (void)
f96e0b
 static void
f96e0b
 init_terminal (grub_gfxmenu_view_t view)
f96e0b
 {
f96e0b
+  const int border_width = 3;
f96e0b
+
f96e0b
   grub_font_t terminal_font;
f96e0b
 
f96e0b
+  unsigned int line_width;
f96e0b
+
f96e0b
+  struct grub_font_glyph *glyph;
f96e0b
+
f96e0b
   terminal_font = grub_font_get (view->terminal_font_name);
f96e0b
   if (!terminal_font)
f96e0b
     {
f96e0b
@@ -370,11 +376,27 @@ init_terminal (grub_gfxmenu_view_t view)
f96e0b
       return;
f96e0b
     }
f96e0b
 
f96e0b
-  term_rect.width = view->screen.width * 7 / 10;
f96e0b
+  glyph = grub_font_get_glyph (terminal_font, 'M');
f96e0b
+
f96e0b
+  line_width = ((glyph ? glyph->device_width : 8) * 80 + 2 * border_width);
f96e0b
+
f96e0b
+  if (view->screen.width <= line_width)
f96e0b
+    /* The screen is too small. Use all space, except a small border
f96e0b
+       to show the user, it is a window and not full screen: */
f96e0b
+    term_rect.width = view->screen.width - 6 * border_width;
f96e0b
+  else
f96e0b
+    {
f96e0b
+      /* The screen is big enough. Try 70% of the screen width: */
f96e0b
+      term_rect.width = view->screen.width * 7 / 10;
f96e0b
+      /* Make sure, that we use at least the line_width: */
f96e0b
+      if ( term_rect.width < line_width )
f96e0b
+	term_rect.width = line_width;
f96e0b
+    }
f96e0b
+
f96e0b
   term_rect.height = view->screen.height * 7 / 10;
f96e0b
 
f96e0b
-  term_rect.x = view->screen.x + view->screen.width * (10 - 7) / 10 / 2;
f96e0b
-  term_rect.y = view->screen.y + view->screen.height * (10 - 7) / 10 / 2;
f96e0b
+  term_rect.x = view->screen.x + (view->screen.width  - term_rect.width) / 2;
f96e0b
+  term_rect.y = view->screen.y + (view->screen.height - term_rect.height) / 2;
f96e0b
 
f96e0b
   term_view = view;
f96e0b
 
f96e0b
@@ -384,7 +406,8 @@ init_terminal (grub_gfxmenu_view_t view)
f96e0b
   grub_gfxterm_set_window (GRUB_VIDEO_RENDER_TARGET_DISPLAY, term_rect.x,
f96e0b
 			   term_rect.y,
f96e0b
 			   term_rect.width, term_rect.height,
f96e0b
-			   view->double_repaint, terminal_font, 3);
f96e0b
+			   view->double_repaint, terminal_font,
f96e0b
+			   border_width);
f96e0b
   grub_gfxterm_decorator_hook = grub_gfxmenu_draw_terminal_box;
f96e0b
 }
f96e0b
 
f96e0b
-- 
f96e0b
1.8.2.1
f96e0b