From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1UzWBM-0001f8-Ux for mharc-grub-devel@gnu.org; Wed, 17 Jul 2013 14:10:32 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44072) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UzWBJ-0001ZR-N3 for grub-devel@gnu.org; Wed, 17 Jul 2013 14:10:31 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UzWBI-0003XD-EV for grub-devel@gnu.org; Wed, 17 Jul 2013 14:10:29 -0400 Received: from collab.rosalab.ru ([195.19.76.181]:40096) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UzWBI-0003Wv-2f for grub-devel@gnu.org; Wed, 17 Jul 2013 14:10:28 -0400 Received: from localhost (localhost.localdomain [127.0.0.1]) by collab.rosalab.ru (Postfix) with ESMTP id 727A029C230 for ; Wed, 17 Jul 2013 22:10:27 +0400 (MSK) X-Virus-Scanned: amavisd-new at rosalab.ru Received: from collab.rosalab.ru ([127.0.0.1]) by localhost (collab.rosalab.ru [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id YgqoBuh7tghS for ; Wed, 17 Jul 2013 22:10:26 +0400 (MSK) Received: from icedphoenix.localnet (unknown [217.199.216.178]) by collab.rosalab.ru (Postfix) with ESMTPSA id DDDDE29C22F for ; Wed, 17 Jul 2013 22:10:26 +0400 (MSK) From: Vladimir Testov 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 Message-ID: <1655561.53qgImRCZs@icedphoenix> User-Agent: KMail/4.10.4 (Linux/3.8.0-26-generic; KDE/4.10.4; x86_64; ; ) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="nextPart1525405.WurxpKWHHE" Content-Transfer-Encoding: 7Bit X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 195.19.76.181 X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list Reply-To: The development of GNU GRUB List-Id: The development of GNU GRUB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 17 Jul 2013 18:10:31 -0000 This is a multi-part message in MIME format. --nextPart1525405.WurxpKWHHE Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" 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 --nextPart1525405.WurxpKWHHE Content-Disposition: attachment; filename="grub-list-scrollbar-thumb-sanity-checks.patch" Content-Transfer-Encoding: 7Bit Content-Type: text/x-patch; charset="UTF-8"; name="grub-list-scrollbar-thumb-sanity-checks.patch" 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) { --nextPart1525405.WurxpKWHHE--