代码拉取完成,页面将自动刷新
同步操作将从 src-anolis-os/grub2 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Hans de Goede <[email protected]>
Date: Mon, 26 Mar 2018 16:15:53 +0200
Subject: [PATCH] Accept ESC, F8 and holding SHIFT as user interrupt keys
On some devices the ESC key is the hotkey to enter the BIOS/EFI setup
screen, making it really hard to time pressing it right. Besides that
ESC is also pretty hard to discover for a user who does not know it
will unhide the menu.
This commit makes F8, which used to be the hotkey to show the Windows
boot menu during boot for a long long time, also interrupt sleeps /
stop the menu countdown.
This solves the ESC gets into the BIOS setup and also somewhat solves
the discoverability issue, but leaves the timing issue unresolved.
This commit fixes the timing issue by also adding support for keeping
SHIFT pressed during boot to stop the menu countdown. This matches
what Ubuntu is doing, which should also help with discoverability.
Signed-off-by: Hans de Goede <[email protected]>
---
grub-core/commands/sleep.c | 2 +-
grub-core/kern/term.c | 16 ++++++++++++++++
grub-core/normal/menu.c | 2 +-
include/grub/term.h | 1 +
4 files changed, 19 insertions(+), 2 deletions(-)
diff --git a/grub-core/commands/sleep.c b/grub-core/commands/sleep.c
index e77e7900f..a1370b710 100644
--- a/grub-core/commands/sleep.c
+++ b/grub-core/commands/sleep.c
@@ -55,7 +55,7 @@ grub_interruptible_millisleep (grub_uint32_t ms)
start = grub_get_time_ms ();
while (grub_get_time_ms () - start < ms)
- if (grub_getkey_noblock () == GRUB_TERM_ESC)
+ if (grub_key_is_interrupt (grub_getkey_noblock ()))
return 1;
return 0;
diff --git a/grub-core/kern/term.c b/grub-core/kern/term.c
index 93bd3378d..6cae4c23e 100644
--- a/grub-core/kern/term.c
+++ b/grub-core/kern/term.c
@@ -138,6 +138,22 @@ grub_getkeystatus (void)
return status;
}
+int
+grub_key_is_interrupt (int key)
+{
+ /* ESC sometimes is the BIOS setup hotkey and may be hard to discover, also
+ check F8, which was the key to get the Windows bootmenu for a long time. */
+ if (key == GRUB_TERM_ESC || key == GRUB_TERM_KEY_F8)
+ return 1;
+
+ /* Pressing keys at the right time during boot is hard to time, also allow
+ interrupting sleeps / the menu countdown by keeping shift pressed. */
+ if (grub_getkeystatus() & (GRUB_TERM_STATUS_LSHIFT|GRUB_TERM_STATUS_RSHIFT))
+ return 1;
+
+ return 0;
+}
+
void
grub_refresh (void)
{
diff --git a/grub-core/normal/menu.c b/grub-core/normal/menu.c
index 5e2f5283d..6cb2a0714 100644
--- a/grub-core/normal/menu.c
+++ b/grub-core/normal/menu.c
@@ -655,7 +655,7 @@ run_menu (grub_menu_t menu, int nested, int *auto_boot)
if (entry >= 0)
break;
}
- if (key == GRUB_TERM_ESC)
+ if (grub_key_is_interrupt (key))
{
timeout = -1;
break;
diff --git a/include/grub/term.h b/include/grub/term.h
index c21513338..2b079c29b 100644
--- a/include/grub/term.h
+++ b/include/grub/term.h
@@ -328,6 +328,7 @@ void grub_putcode (grub_uint32_t code, struct grub_term_output *term);
int EXPORT_FUNC(grub_getkey) (void);
int EXPORT_FUNC(grub_getkey_noblock) (void);
int EXPORT_FUNC(grub_getkeystatus) (void);
+int EXPORT_FUNC(grub_key_is_interrupt) (int key);
void grub_cls (void);
void EXPORT_FUNC(grub_refresh) (void);
void grub_puts_terminal (const char *str, struct grub_term_output *term);
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。