From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=192.55.52.93; helo=mga11.intel.com; envelope-from=ruiyu.ni@intel.com; receiver=edk2-devel@lists.01.org Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 57096224488A1 for ; Tue, 13 Mar 2018 00:34:41 -0700 (PDT) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 13 Mar 2018 00:41:02 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.47,464,1515484800"; d="scan'208";a="23828716" Received: from ray-dev.ccr.corp.intel.com ([10.239.9.4]) by fmsmga007.fm.intel.com with ESMTP; 13 Mar 2018 00:41:01 -0700 From: Ruiyu Ni To: edk2-devel@lists.01.org Cc: Jaben Carsey Date: Tue, 13 Mar 2018 15:40:59 +0800 Message-Id: <20180313074059.98580-1-ruiyu.ni@intel.com> X-Mailer: git-send-email 2.16.1.windows.1 In-Reply-To: References: Subject: [PATCH] ShellPkg/[hex]edit: Fix mouse freeze issue X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 13 Mar 2018 07:34:41 -0000 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 Cc: Jaben Carsey --- .../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