Received: from list by lists.gnu.org with archive (Exim 4.71) id 1f1CPR-0000D2-95 for mharc-grub-devel@gnu.org; Wed, 28 Mar 2018 10:50:41 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45714) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f1CPO-0000C5-Kp for grub-devel@gnu.org; Wed, 28 Mar 2018 10:50:39 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1f1CPM-0007eD-Pd for grub-devel@gnu.org; Wed, 28 Mar 2018 10:50:38 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:57888 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1f1CPM-0007cs-Kq for grub-devel@gnu.org; Wed, 28 Mar 2018 10:50:36 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id BD333F7FA2; Wed, 28 Mar 2018 14:50:30 +0000 (UTC) Received: from shalem.localdomain.com (ovpn-117-140.ams2.redhat.com [10.36.117.140]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2A5152026DFD; Wed, 28 Mar 2018 14:50:30 +0000 (UTC) From: Hans de Goede To: grub-devel@gnu.org Cc: Daniel Kiper , Hans de Goede Subject: [PATCH 2/4] Accept Both ESC and F8 as user interrupt keys Date: Wed, 28 Mar 2018 16:50:26 +0200 Message-Id: <20180328145028.21555-3-hdegoede@redhat.com> In-Reply-To: <20180328145028.21555-1-hdegoede@redhat.com> References: <20180328145028.21555-1-hdegoede@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.1]); Wed, 28 Mar 2018 14:50:30 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.1]); Wed, 28 Mar 2018 14:50:30 +0000 (UTC) for IP:'10.11.54.4' DOMAIN:'int-mx04.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'hdegoede@redhat.com' RCPT:'' X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.187.233.73 X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: The development of GNU GRUB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 28 Mar 2018 14:50:39 -0000 On most Bay Trail, Cherry Trail and Apollo Lake devices the ESC key is the hotkey to enter the BIOS/EFI setup screen. This makes it hard for the user to show the grub-menu when it is hidden and a short timeout is used, because pressing ESC too early leads to the user entering the BIOS/EFI setup screen. F8 is (almost?) always free (on X86/PC platforms) as Windows uses this for its boot menu, so also accept F8 as interrupt/show-menu key. As an added advantage this is also more discoverable / easier for users coming from Windows. Signed-off-by: Hans de Goede --- grub-core/commands/sleep.c | 8 ++++++-- grub-core/normal/menu.c | 7 ++++--- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/grub-core/commands/sleep.c b/grub-core/commands/sleep.c index e77e7900f..9f16956e0 100644 --- a/grub-core/commands/sleep.c +++ b/grub-core/commands/sleep.c @@ -51,12 +51,16 @@ static int grub_interruptible_millisleep (grub_uint32_t ms) { grub_uint64_t start; + int key; start = grub_get_time_ms (); - while (grub_get_time_ms () - start < ms) - if (grub_getkey_noblock () == GRUB_TERM_ESC) + while (grub_get_time_ms () - start < ms) { + key = grub_getkey_noblock (); + /* ESC sometimes is the BIOS setup hotkey, also allow F8 as intr. */ + if (key == GRUB_TERM_ESC || key == GRUB_TERM_KEY_F8) return 1; + } return 0; } diff --git a/grub-core/normal/menu.c b/grub-core/normal/menu.c index e7a83c2d6..d813fade1 100644 --- a/grub-core/normal/menu.c +++ b/grub-core/normal/menu.c @@ -610,8 +610,8 @@ run_menu (grub_menu_t menu, int nested, int *auto_boot) print_countdown (pos, timeout); } - /* Enter interruptible sleep until Escape or a menu hotkey is pressed, - or the timeout expires. */ + /* Sleep until a menu hotkey is pressed, we are interrupted by an ESC/F8 + keypress, or the timeout expires. */ saved_time = grub_get_time_ms (); while (1) { @@ -624,7 +624,8 @@ run_menu (grub_menu_t menu, int nested, int *auto_boot) if (entry >= 0) break; } - if (key == GRUB_TERM_ESC) + /* ESC sometimes is the BIOS setup hotkey, also allow F8 as intr. */ + if (key == GRUB_TERM_ESC || key == GRUB_TERM_KEY_F8) { timeout = -1; break; -- 2.17.0.rc1