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