]> git.proxmox.com Git - mirror_edk2.git/commitdiff
ShellPkg/[hex]edit: Fix mouse freeze issue
authorRuiyu Ni <ruiyu.ni@intel.com>
Tue, 13 Mar 2018 07:39:47 +0000 (15:39 +0800)
committerRuiyu Ni <ruiyu.ni@intel.com>
Wed, 14 Mar 2018 03:25:44 +0000 (11:25 +0800)
In edit or hexedit, the mouse cursor doesn't move when moving
the mouse.
The root cause is 5563281fa2b31093a1cbd415553b9264c5136e89
* ShellPkg/[hex]edit: use SimpleTextInEx to read console
wrongly uses WaitForEvent() to listen keyboard input.
It blocks the code execution when there is no keyboard input.
While the same function also polls the mouse move status,
the mouse movement cannot be reflected to the screen when
there is no keyboard input.

The patch fixes the issue by use CheckEvent() instead of
WaitForEvent().

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
Reviewed-by: Jaben Carsey <jaben.carsey@intel.com>
ShellPkg/Library/UefiShellDebug1CommandsLib/Edit/MainTextEditor.c
ShellPkg/Library/UefiShellDebug1CommandsLib/HexEdit/MainHexEditor.c

index 6832441e8161c07205f59ab9074450e2aa38a500..98e1331ac453267334d1766b9c621d43952192b6 100644 (file)
@@ -1840,7 +1840,6 @@ MainEditorKeyInput (
   EFI_KEY_DATA              KeyData;\r
   EFI_STATUS                Status;\r
   EFI_SIMPLE_POINTER_STATE  MouseState;\r
-  UINTN                     EventIndex;\r
   BOOLEAN                   NoShiftState;\r
 \r
   do {\r
@@ -1876,8 +1875,11 @@ MainEditorKeyInput (
       }\r
     }\r
 \r
-    Status = gBS->WaitForEvent (1, &MainEditor.TextInputEx->WaitForKeyEx, &EventIndex);\r
-    if (!EFI_ERROR (Status) && EventIndex == 0) {\r
+    //\r
+    // CheckEvent() returns Success when non-partial key is pressed.\r
+    //\r
+    Status = gBS->CheckEvent (MainEditor.TextInputEx->WaitForKeyEx);\r
+    if (!EFI_ERROR (Status)) {\r
       Status = MainEditor.TextInputEx->ReadKeyStrokeEx (MainEditor.TextInputEx, &KeyData);\r
       if (!EFI_ERROR (Status)) {\r
         //\r
@@ -1917,11 +1919,11 @@ MainEditorKeyInput (
         }\r
 \r
       }\r
-      //\r
-      // after handling, refresh editor\r
-      //\r
-      MainEditorRefresh ();\r
     }\r
+    //\r
+    // after handling, refresh editor\r
+    //\r
+    MainEditorRefresh ();\r
 \r
   } while (Status != EFI_OUT_OF_RESOURCES && !EditorExit);\r
 \r
index a2e52ea39c10a5ecc9190be1d5ae41c5a896f338..1a89d3d72a95525ed30d5ba58ab5919ff5b6a39d 100644 (file)
@@ -2108,7 +2108,6 @@ HMainEditorKeyInput (
   EFI_KEY_DATA              KeyData;\r
   EFI_STATUS                Status;\r
   EFI_SIMPLE_POINTER_STATE  MouseState;\r
-  UINTN                     EventIndex;\r
   BOOLEAN                   NoShiftState;\r
   BOOLEAN                   LengthChange;\r
   UINTN                     Size;\r
@@ -2268,8 +2267,11 @@ HMainEditorKeyInput (
       }\r
     }\r
 \r
-    Status = gBS->WaitForEvent (1, &HMainEditor.TextInputEx->WaitForKeyEx, &EventIndex);\r
-    if (!EFI_ERROR (Status) && EventIndex == 0) {\r
+    //\r
+    // CheckEvent() returns Success when non-partial key is pressed.\r
+    //\r
+    Status = gBS->CheckEvent (HMainEditor.TextInputEx->WaitForKeyEx);\r
+    if (!EFI_ERROR (Status)) {\r
       Status = HMainEditor.TextInputEx->ReadKeyStrokeEx (HMainEditor.TextInputEx, &KeyData);\r
       if (!EFI_ERROR (Status)) {\r
         //\r
@@ -2351,11 +2353,11 @@ HMainEditorKeyInput (
           }\r
         }\r
       }\r
-      //\r
-      // after handling, refresh editor\r
-      //\r
-      HMainEditorRefresh ();\r
     }\r
+    //\r
+    // after handling, refresh editor\r
+    //\r
+    HMainEditorRefresh ();\r
 \r
   } while (Status != EFI_OUT_OF_RESOURCES && !HEditorExit);\r
 \r