public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [PATCH] ShellPkg/[hex]edit: Fix mouse freeze issue
@ 2018-03-13  7:40 Ruiyu Ni
  2018-03-13 14:52 ` Carsey, Jaben
  0 siblings, 1 reply; 2+ messages in thread
From: Ruiyu Ni @ 2018-03-13  7:40 UTC (permalink / raw)
  To: edk2-devel; +Cc: Jaben Carsey

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>
Cc: Jaben Carsey <jaben.carsey@intel.com>
---
 .../UefiShellDebug1CommandsLib/Edit/MainTextEditor.c     | 16 +++++++++-------
 .../UefiShellDebug1CommandsLib/HexEdit/MainHexEditor.c   | 16 +++++++++-------
 2 files changed, 18 insertions(+), 14 deletions(-)

diff --git a/ShellPkg/Library/UefiShellDebug1CommandsLib/Edit/MainTextEditor.c b/ShellPkg/Library/UefiShellDebug1CommandsLib/Edit/MainTextEditor.c
index 6832441e81..98e1331ac4 100644
--- a/ShellPkg/Library/UefiShellDebug1CommandsLib/Edit/MainTextEditor.c
+++ b/ShellPkg/Library/UefiShellDebug1CommandsLib/Edit/MainTextEditor.c
@@ -1840,7 +1840,6 @@ MainEditorKeyInput (
   EFI_KEY_DATA              KeyData;
   EFI_STATUS                Status;
   EFI_SIMPLE_POINTER_STATE  MouseState;
-  UINTN                     EventIndex;
   BOOLEAN                   NoShiftState;
 
   do {
@@ -1876,8 +1875,11 @@ MainEditorKeyInput (
       }
     }
 
-    Status = gBS->WaitForEvent (1, &MainEditor.TextInputEx->WaitForKeyEx, &EventIndex);
-    if (!EFI_ERROR (Status) && EventIndex == 0) {
+    //
+    // CheckEvent() returns Success when non-partial key is pressed.
+    //
+    Status = gBS->CheckEvent (MainEditor.TextInputEx->WaitForKeyEx);
+    if (!EFI_ERROR (Status)) {
       Status = MainEditor.TextInputEx->ReadKeyStrokeEx (MainEditor.TextInputEx, &KeyData);
       if (!EFI_ERROR (Status)) {
         //
@@ -1917,11 +1919,11 @@ MainEditorKeyInput (
         }
 
       }
-      //
-      // after handling, refresh editor
-      //
-      MainEditorRefresh ();
     }
+    //
+    // after handling, refresh editor
+    //
+    MainEditorRefresh ();
 
   } while (Status != EFI_OUT_OF_RESOURCES && !EditorExit);
 
diff --git a/ShellPkg/Library/UefiShellDebug1CommandsLib/HexEdit/MainHexEditor.c b/ShellPkg/Library/UefiShellDebug1CommandsLib/HexEdit/MainHexEditor.c
index a2e52ea39c..1a89d3d72a 100644
--- a/ShellPkg/Library/UefiShellDebug1CommandsLib/HexEdit/MainHexEditor.c
+++ b/ShellPkg/Library/UefiShellDebug1CommandsLib/HexEdit/MainHexEditor.c
@@ -2108,7 +2108,6 @@ HMainEditorKeyInput (
   EFI_KEY_DATA              KeyData;
   EFI_STATUS                Status;
   EFI_SIMPLE_POINTER_STATE  MouseState;
-  UINTN                     EventIndex;
   BOOLEAN                   NoShiftState;
   BOOLEAN                   LengthChange;
   UINTN                     Size;
@@ -2268,8 +2267,11 @@ HMainEditorKeyInput (
       }
     }
 
-    Status = gBS->WaitForEvent (1, &HMainEditor.TextInputEx->WaitForKeyEx, &EventIndex);
-    if (!EFI_ERROR (Status) && EventIndex == 0) {
+    //
+    // CheckEvent() returns Success when non-partial key is pressed.
+    //
+    Status = gBS->CheckEvent (HMainEditor.TextInputEx->WaitForKeyEx);
+    if (!EFI_ERROR (Status)) {
       Status = HMainEditor.TextInputEx->ReadKeyStrokeEx (HMainEditor.TextInputEx, &KeyData);
       if (!EFI_ERROR (Status)) {
         //
@@ -2351,11 +2353,11 @@ HMainEditorKeyInput (
           }
         }
       }
-      //
-      // after handling, refresh editor
-      //
-      HMainEditorRefresh ();
     }
+    //
+    // after handling, refresh editor
+    //
+    HMainEditorRefresh ();
 
   } while (Status != EFI_OUT_OF_RESOURCES && !HEditorExit);
 
-- 
2.16.1.windows.1



^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] ShellPkg/[hex]edit: Fix mouse freeze issue
  2018-03-13  7:40 [PATCH] ShellPkg/[hex]edit: Fix mouse freeze issue Ruiyu Ni
@ 2018-03-13 14:52 ` Carsey, Jaben
  0 siblings, 0 replies; 2+ messages in thread
From: Carsey, Jaben @ 2018-03-13 14:52 UTC (permalink / raw)
  To: Ni, Ruiyu, edk2-devel@lists.01.org

Reviewed-by: Jaben Carsey <jaben.carsey@intel.com>

> -----Original Message-----
> From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of
> Ruiyu Ni
> Sent: Tuesday, March 13, 2018 12:41 AM
> To: edk2-devel@lists.01.org
> Cc: Carsey, Jaben <jaben.carsey@intel.com>
> Subject: [edk2] [PATCH] ShellPkg/[hex]edit: Fix mouse freeze issue
> Importance: High
> 
> 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>
> Cc: Jaben Carsey <jaben.carsey@intel.com>
> ---
>  .../UefiShellDebug1CommandsLib/Edit/MainTextEditor.c     | 16 +++++++++-
> ------
>  .../UefiShellDebug1CommandsLib/HexEdit/MainHexEditor.c   | 16
> +++++++++-------
>  2 files changed, 18 insertions(+), 14 deletions(-)
> 
> diff --git
> a/ShellPkg/Library/UefiShellDebug1CommandsLib/Edit/MainTextEditor.c
> b/ShellPkg/Library/UefiShellDebug1CommandsLib/Edit/MainTextEditor.c
> index 6832441e81..98e1331ac4 100644
> --- a/ShellPkg/Library/UefiShellDebug1CommandsLib/Edit/MainTextEditor.c
> +++
> b/ShellPkg/Library/UefiShellDebug1CommandsLib/Edit/MainTextEditor.c
> @@ -1840,7 +1840,6 @@ MainEditorKeyInput (
>    EFI_KEY_DATA              KeyData;
>    EFI_STATUS                Status;
>    EFI_SIMPLE_POINTER_STATE  MouseState;
> -  UINTN                     EventIndex;
>    BOOLEAN                   NoShiftState;
> 
>    do {
> @@ -1876,8 +1875,11 @@ MainEditorKeyInput (
>        }
>      }
> 
> -    Status = gBS->WaitForEvent (1, &MainEditor.TextInputEx->WaitForKeyEx,
> &EventIndex);
> -    if (!EFI_ERROR (Status) && EventIndex == 0) {
> +    //
> +    // CheckEvent() returns Success when non-partial key is pressed.
> +    //
> +    Status = gBS->CheckEvent (MainEditor.TextInputEx->WaitForKeyEx);
> +    if (!EFI_ERROR (Status)) {
>        Status = MainEditor.TextInputEx->ReadKeyStrokeEx
> (MainEditor.TextInputEx, &KeyData);
>        if (!EFI_ERROR (Status)) {
>          //
> @@ -1917,11 +1919,11 @@ MainEditorKeyInput (
>          }
> 
>        }
> -      //
> -      // after handling, refresh editor
> -      //
> -      MainEditorRefresh ();
>      }
> +    //
> +    // after handling, refresh editor
> +    //
> +    MainEditorRefresh ();
> 
>    } while (Status != EFI_OUT_OF_RESOURCES && !EditorExit);
> 
> diff --git
> a/ShellPkg/Library/UefiShellDebug1CommandsLib/HexEdit/MainHexEditor.c
> b/ShellPkg/Library/UefiShellDebug1CommandsLib/HexEdit/MainHexEditor.c
> index a2e52ea39c..1a89d3d72a 100644
> ---
> a/ShellPkg/Library/UefiShellDebug1CommandsLib/HexEdit/MainHexEditor.c
> +++
> b/ShellPkg/Library/UefiShellDebug1CommandsLib/HexEdit/MainHexEditor.c
> @@ -2108,7 +2108,6 @@ HMainEditorKeyInput (
>    EFI_KEY_DATA              KeyData;
>    EFI_STATUS                Status;
>    EFI_SIMPLE_POINTER_STATE  MouseState;
> -  UINTN                     EventIndex;
>    BOOLEAN                   NoShiftState;
>    BOOLEAN                   LengthChange;
>    UINTN                     Size;
> @@ -2268,8 +2267,11 @@ HMainEditorKeyInput (
>        }
>      }
> 
> -    Status = gBS->WaitForEvent (1, &HMainEditor.TextInputEx-
> >WaitForKeyEx, &EventIndex);
> -    if (!EFI_ERROR (Status) && EventIndex == 0) {
> +    //
> +    // CheckEvent() returns Success when non-partial key is pressed.
> +    //
> +    Status = gBS->CheckEvent (HMainEditor.TextInputEx->WaitForKeyEx);
> +    if (!EFI_ERROR (Status)) {
>        Status = HMainEditor.TextInputEx->ReadKeyStrokeEx
> (HMainEditor.TextInputEx, &KeyData);
>        if (!EFI_ERROR (Status)) {
>          //
> @@ -2351,11 +2353,11 @@ HMainEditorKeyInput (
>            }
>          }
>        }
> -      //
> -      // after handling, refresh editor
> -      //
> -      HMainEditorRefresh ();
>      }
> +    //
> +    // after handling, refresh editor
> +    //
> +    HMainEditorRefresh ();
> 
>    } while (Status != EFI_OUT_OF_RESOURCES && !HEditorExit);
> 
> --
> 2.16.1.windows.1
> 
> _______________________________________________
> edk2-devel mailing list
> edk2-devel@lists.01.org
> https://lists.01.org/mailman/listinfo/edk2-devel


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2018-03-13 14:46 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-03-13  7:40 [PATCH] ShellPkg/[hex]edit: Fix mouse freeze issue Ruiyu Ni
2018-03-13 14:52 ` Carsey, Jaben

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox