]> git.ipfire.org Git - thirdparty/grub.git/commitdiff
* grub-core/gfxmenu/gui_list.c: Scrollbar sanity checks added.
authorVladimir Testov <vladimir.testov@rosalab.ru>
Tue, 15 Oct 2013 14:16:06 +0000 (18:16 +0400)
committerVladimir Testov <vladimir.testov@rosalab.ru>
Tue, 15 Oct 2013 14:16:06 +0000 (18:16 +0400)
ChangeLog
grub-core/gfxmenu/gui_list.c

index 838cd7a7b899e9a2a6cf5a4a98aa1ba55f272833..47ea279bfa966cd8fd76e499f7d3151626e0dd7b 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2013-10-16  Vladimir Testov  <vladimir.testov@rosalab.ru>
+
+       * grub-core/gfxmenu/gui_list.c: Scrollbar sanity checks added.
+
 2013-10-16  Vladimir Testov  <vladimir.testov@rosalab.ru>
 
        * grub-core/gfxmenu/gui_list.c: New option `item_pixmap_style`.
index ec1a5513f504804567df8a43fb830a1b3bead1b2..5f7f47a436714bdae08438dd49002f00ba6d9267 100644 (file)
@@ -176,7 +176,34 @@ check_scrollbar (list_impl_t self)
       self->need_to_recreate_scrollbar = 0;
     }
 
-  return (self->scrollbar_frame != 0 && self->scrollbar_thumb != 0);
+  if (self->scrollbar_frame == 0 || self->scrollbar_thumb == 0)
+    return 0;
+
+  /* Sanity checks. */
+  grub_gfxmenu_box_t frame = self->scrollbar_frame;
+  grub_gfxmenu_box_t thumb = self->scrollbar_thumb;
+  grub_gfxmenu_box_t menu = self->menu_box;
+  int min_width = frame->get_left_pad (frame)
+                  + frame->get_right_pad (frame);
+  int min_height = frame->get_top_pad (frame)
+                   + frame->get_bottom_pad (frame)
+                   + self->scrollbar_top_pad + self->scrollbar_bottom_pad
+                   + menu->get_top_pad (menu)
+                   + menu->get_bottom_pad (menu);
+  if (!self->scrollbar_thumb_overlay)
+    {
+      min_width += thumb->get_left_pad (thumb)
+                   + thumb->get_right_pad (thumb);
+      min_height += thumb->get_top_pad (thumb)
+                    + thumb->get_bottom_pad (thumb);
+    }
+  if (min_width <= self->scrollbar_width
+      && min_height <= (int) self->bounds.height)
+    return 1;
+
+  /* Unprintable dimenstions. */
+  self->draw_scrollbar = 0;
+  return 0;
 }
 
 static const char *