From: Vladimir Testov <vladimir.testov@rosalab.ru>
To: grub-devel@gnu.org
Subject: [PATCH] [6/?] grub-core/gfxmenu/gui_list.c - sanity checks for the scrollbar
Date: Wed, 17 Jul 2013 22:10:26 +0400 [thread overview]
Message-ID: <1655561.53qgImRCZs@icedphoenix> (raw)
[-- Attachment #1: Type: text/plain, Size: 568 bytes --]
some needed checks so we won't see error messages during the boot process
also the patch handles rare cases: when we have too many menu entries and / or
too small scrollbar height, the scrollbar thumb's height could be less than
it's vertical padding (height of north slice + height of south slice). So the
scrollbar thumb will be drawn incorrectly.
In this case we set the height of the thumb to it's vertical padding and
recount the position of the thumb.
--
With best regards,
_______________________________
Vladimir Testov, ROSA Laboratory.
www.rosalab.ru
[-- Attachment #2: grub-list-scrollbar-thumb-sanity-checks.patch --]
[-- Type: text/x-patch, Size: 2866 bytes --]
diff -Naur grub-new5/grub-core/gfxmenu/gui_list.c grub-new6/grub-core/gfxmenu/gui_list.c
--- grub-new5/grub-core/gfxmenu/gui_list.c 2013-07-17 18:57:56.597740755 +0400
+++ grub-new6/grub-core/gfxmenu/gui_list.c 2013-07-17 20:07:37.664064169 +0400
@@ -148,6 +148,33 @@
self->theme_dir);
self->need_to_recreate_scrollbar = 0;
+
+ /* Sanity checks. */
+ if (self->scrollbar_frame != 0 && self->scrollbar_thumb != 0)
+ {
+ grub_gfxmenu_box_t box = self->menu_box;
+ grub_gfxmenu_box_t frame = self->scrollbar_frame;
+ grub_gfxmenu_box_t thumb = self->scrollbar_thumb;
+ int box_vertical_pad = (box->get_top_pad (box)
+ + box->get_bottom_pad (box));
+ int frame_horizontal_pad = (frame->get_left_pad (frame)
+ + frame->get_right_pad (frame));
+ int frame_vertical_pad = (frame->get_top_pad (frame)
+ + frame->get_bottom_pad (frame));
+ int thumb_horizontal_pad = (thumb->get_left_pad (thumb)
+ + thumb->get_right_pad (thumb));
+ int thumb_vertical_pad = (thumb->get_top_pad (thumb)
+ + thumb->get_bottom_pad (thumb));
+ int scrollbar_height = self->bounds.height - box_vertical_pad;
+
+ if (self->scrollbar_width < frame_horizontal_pad
+ + thumb_horizontal_pad
+ || scrollbar_height < frame_vertical_pad + thumb_vertical_pad)
+ {
+ self->draw_scrollbar = 0;
+ return 0;
+ }
+ }
}
return (self->scrollbar_frame != 0 && self->scrollbar_thumb != 0);
@@ -228,8 +255,18 @@
frame->set_content_size (frame,
scrollbar_width - frame_horizontal_pad,
tracklen);
- int thumby = tracktop + tracklen * (value - min) / (max - min);
+ int thumby;
int thumbheight = tracklen * extent / (max - min) + 1;
+ if (thumbheight >= thumb_vertical_pad)
+ {
+ thumby = tracktop + tracklen * (value - min) / (max - min);
+ }
+ else /* Rare occasion. Thumb height is too low. */
+ {
+ thumbheight = thumb_vertical_pad;
+ thumby = tracktop + ((tracklen - thumb_vertical_pad) * (value - min)
+ / (max - extent));
+ }
thumb->set_content_size (thumb,
scrollbar_width - frame_horizontal_pad
- thumb_horizontal_pad,
@@ -584,7 +621,7 @@
}
else if (grub_strcmp (name, "scrollbar_width") == 0)
{
- self->scrollbar_width = grub_strtol (value, 0, 10);
+ self->scrollbar_width = grub_strtoul (value, 0, 10);
}
else if (grub_strcmp (name, "scrollbar") == 0)
{
reply other threads:[~2013-07-17 18:10 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1655561.53qgImRCZs@icedphoenix \
--to=vladimir.testov@rosalab.ru \
--cc=grub-devel@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.