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