In current case, if one key already registered and it is registered again for 
another hot key, browser will override old hot key with new one. This behavior 
is not user friendly.
Now update the logic, return EFI_ALREADY_STARTED for this case. If user still 
want to override it, he must unregistered it first.

V2: Refine the function header, add new return type.

Cc: Liming Gao <[email protected]>
Cc: Jiewen Yao <[email protected]>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Eric Dong <[email protected]>
---
 MdeModulePkg/Universal/SetupBrowserDxe/Setup.c | 24 ++++++++++++------------
 MdeModulePkg/Universal/SetupBrowserDxe/Setup.h |  1 +
 2 files changed, 13 insertions(+), 12 deletions(-)

diff --git a/MdeModulePkg/Universal/SetupBrowserDxe/Setup.c 
b/MdeModulePkg/Universal/SetupBrowserDxe/Setup.c
index 5793962..43cfc87 100644
--- a/MdeModulePkg/Universal/SetupBrowserDxe/Setup.c
+++ b/MdeModulePkg/Universal/SetupBrowserDxe/Setup.c
@@ -5888,10 +5888,11 @@ SetScope (
   
   @retval EFI_SUCCESS            Hot key is registered or unregistered.
   @retval EFI_INVALID_PARAMETER  KeyData is NULL or HelpString is NULL on 
register.
   @retval EFI_NOT_FOUND          KeyData is not found to be unregistered.
   @retval EFI_UNSUPPORTED        Key represents a printable character. It is 
conflicted with Browser.
+  @retval EFI_ALREADY_STARTED    Key already been registered for one hot key.
 **/
 EFI_STATUS
 EFIAPI
 RegisterHotKey (
   IN EFI_INPUT_KEY *KeyData,
@@ -5933,24 +5934,23 @@ RegisterHotKey (
       // The registered HotKey is not found. 
       //
       return EFI_NOT_FOUND;
     }
   }
-  
+
+  if (HotKey != NULL) {
+    return EFI_ALREADY_STARTED;
+  }
+
   //
-  // Register HotKey into List.
+  // Create new Key, and add it into List.
   //
-  if (HotKey == NULL) {
-    //
-    // Create new Key, and add it into List.
-    //
-    HotKey = AllocateZeroPool (sizeof (BROWSER_HOT_KEY));
-    ASSERT (HotKey != NULL);
-    HotKey->Signature = BROWSER_HOT_KEY_SIGNATURE;
-    HotKey->KeyData   = AllocateCopyPool (sizeof (EFI_INPUT_KEY), KeyData);
-    InsertTailList (&gBrowserHotKeyList, &HotKey->Link);
-  }
+  HotKey = AllocateZeroPool (sizeof (BROWSER_HOT_KEY));
+  ASSERT (HotKey != NULL);
+  HotKey->Signature = BROWSER_HOT_KEY_SIGNATURE;
+  HotKey->KeyData   = AllocateCopyPool (sizeof (EFI_INPUT_KEY), KeyData);
+  InsertTailList (&gBrowserHotKeyList, &HotKey->Link);
 
   //
   // Fill HotKey information.
   //
   HotKey->Action     = Action;
diff --git a/MdeModulePkg/Universal/SetupBrowserDxe/Setup.h 
b/MdeModulePkg/Universal/SetupBrowserDxe/Setup.h
index 1238197..61e706a 100644
--- a/MdeModulePkg/Universal/SetupBrowserDxe/Setup.h
+++ b/MdeModulePkg/Universal/SetupBrowserDxe/Setup.h
@@ -1306,10 +1306,11 @@ SetScope (
   
   @retval EFI_SUCCESS            Hot key is registered or unregistered.
   @retval EFI_INVALID_PARAMETER  KeyData is NULL.
   @retval EFI_NOT_FOUND          KeyData is not found to be unregistered.
   @retval EFI_UNSUPPORTED        Key represents a printable character. It is 
conflicted with Browser.
+  @retval EFI_ALREADY_STARTED    Key already been registered for one hot key.
 **/
 EFI_STATUS
 EFIAPI
 RegisterHotKey (
   IN EFI_INPUT_KEY *KeyData,
-- 
1.9.5.msysgit.1

_______________________________________________
edk2-devel mailing list
[email protected]
https://lists.01.org/mailman/listinfo/edk2-devel

Reply via email to