From f3e3c504236ff9b0306280e69b5e4cf236e7e84f Mon Sep 17 00:00:00 2001 From: Wenbo Hou Date: Wed, 22 Jan 2025 04:14:19 +0800 Subject: [PATCH] Fix event handling bug with touch and keyboard input (#620) ## Description Fixes #621 Fix the bug in event handling that occurs when alternating between touch and keyboard inputs, ensuring seamless interaction. - [x] Impacts functionality? - [ ] Impacts security? - [ ] Breaking change? - [ ] Includes tests? - [ ] Includes documentation? - [x] Backport to release branch? ## How This Was Tested Tested on Surface Laptop and Surface Pro. Booted to UEFI front page and alternated between Touchpad and Keyboard for operation. The interaction was seamless. ## Integration Instructions N/A --------- Co-authored-by: Wenbo Hou --- MsGraphicsPkg/DisplayEngineDxe/FormDisplay.c | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/MsGraphicsPkg/DisplayEngineDxe/FormDisplay.c b/MsGraphicsPkg/DisplayEngineDxe/FormDisplay.c index 73d1bd3ea5..2247ac516a 100644 --- a/MsGraphicsPkg/DisplayEngineDxe/FormDisplay.c +++ b/MsGraphicsPkg/DisplayEngineDxe/FormDisplay.c @@ -2187,7 +2187,7 @@ UiDisplayMenu ( // Check whether the event should be forwarded to the Master Frame instead of the form canvas. // - if (((SWM_INPUT_TYPE_TOUCH == InputState.InputType) && (InputState.State.TouchState.CurrentX < mMasterFrameWidth)) || + if (((SWM_INPUT_TYPE_TOUCH == InputState.InputType) && (FALSE == FormHasKeyFocus) && (InputState.State.TouchState.CurrentX < mMasterFrameWidth)) || ((SWM_INPUT_TYPE_KEY == InputState.InputType) && (FALSE == FormHasKeyFocus) && (CHAR_TAB != InputState.State.KeyState.Key.UnicodeChar))) { // If we're displaying the Top Menu highlight and the TAB or SHIFT+TAB is pressed, toggle the tab order highlight state. @@ -2196,6 +2196,8 @@ UiDisplayMenu ( // if (SWM_INPUT_TYPE_TOUCH == InputState.InputType) { MasterFrameSharedState->ShowTopMenuHighlight = FALSE; + } else if (SWM_INPUT_TYPE_KEY == InputState.InputType) { + MasterFrameSharedState->ShowTopMenuHighlight = TRUE; } gUserInput->Action = BROWSER_ACTION_FORM_EXIT; @@ -2292,9 +2294,24 @@ UiDisplayMenu ( { if (InputState.State.TouchState.CurrentX >= mMasterFrameWidth) { FormHasKeyFocus = TRUE; + } else { + FormHasKeyFocus = FALSE; } MasterFrameSharedState->ShowTopMenuHighlight = FALSE; + + gUserInput->Action = BROWSER_ACTION_FORM_EXIT; + + // Signal to the Top Menu to refresh to show the highlight. + // + MasterFrameSharedState->NotificationType = REDRAW; + CopyMem (&MasterFrameSharedState->InputState, &InputState, sizeof (SWM_INPUT_STATE)); + + // Signal FP that there's data for it to process. + // + gBS->SignalEvent (mMasterFrameNotifyEvent); + + break; } default: