[edk2] [patch] MdeModulePkg/DisplayEngine: Fix incorrect display issue

Dandan Bi posted 1 patch 6 years, 8 months ago
Failed in applying to current master (apply log)
There is a newer version of this series
.../Universal/DisplayEngineDxe/FormDisplay.c       | 43 +++++++++++++++++++---
1 file changed, 37 insertions(+), 6 deletions(-)
[edk2] [patch] MdeModulePkg/DisplayEngine: Fix incorrect display issue
Posted by Dandan Bi 6 years, 8 months ago
In a form, some new menus may be dynamically inserted between highlight
menu and previous top of screen menu when some question are refreshed.
So the highlight menu and previous top of screen menu perhaps can't be
shown in one page. Existing codes miss to handle this case then will
cause incorrect display.This patch is to fix this display issue.

Cc: Eric Dong <eric.dong@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Dandan Bi <dandan.bi@intel.com>
---
 .../Universal/DisplayEngineDxe/FormDisplay.c       | 43 +++++++++++++++++++---
 1 file changed, 37 insertions(+), 6 deletions(-)

diff --git a/MdeModulePkg/Universal/DisplayEngineDxe/FormDisplay.c b/MdeModulePkg/Universal/DisplayEngineDxe/FormDisplay.c
index dc4ae4b..f4025e9 100644
--- a/MdeModulePkg/Universal/DisplayEngineDxe/FormDisplay.c
+++ b/MdeModulePkg/Universal/DisplayEngineDxe/FormDisplay.c
@@ -1759,10 +1759,41 @@ FindTopOfScreenMenuOption (
 
   return NewPos;
 }
 
 /**
+  Calculate the distance between two menus and include the skip value of StartMenu.
+
+  @param  StartMenu             The link_entry pointer to startt menu.
+  @param  EndMenu               The link_entry pointer to end menu.
+
+**/
+UINTN
+GetDistanceBetweenMenus(
+  IN LIST_ENTRY  *StartMenu,
+  IN LIST_ENTRY  *EndMenu
+)
+{
+  LIST_ENTRY                 *Link;
+  UI_MENU_OPTION             *MenuOption;
+  UINTN                      Distance;
+
+  Distance = 0;
+
+  Link = StartMenu;
+  while (Link != EndMenu) {
+    MenuOption = MENU_OPTION_FROM_LINK (Link);
+    if (MenuOption->Row == 0) {
+      UpdateOptionSkipLines (MenuOption);
+    }
+    Distance += MenuOption->Skip;
+    Link = Link->BackLink;
+  }
+  return Distance;
+}
+
+/**
   Find the first menu which will be show at the top.
 
   @param  FormData               The data info for this form.
   @param  TopOfScreen            The link_entry pointer to top menu.
   @param  HighlightMenu          The menu which will be highlight.
@@ -1804,25 +1835,25 @@ FindTopMenu (
 
       //
       // Found the last time highlight menu.
       //
       *TopOfScreen = FindTopOfScreenMenuOption();
-      if (*TopOfScreen != NULL) {
+      if (*TopOfScreen != NULL && (GetDistanceBetweenMenus (*HighlightMenu,*TopOfScreen) + 1 <= BottomRow - TopRow)) {
         //
-        // Found the last time selectable top of screen menu.
+        // Found the last time selectable top of screen menu, and the highlight menu and top of screen menu or part of the screen menu can be shown in one page.
         //
         AdjustDateAndTimePosition(TRUE, TopOfScreen);
         MenuOption = MENU_OPTION_FROM_LINK (*TopOfScreen);
         UpdateOptionSkipLines (MenuOption);
 
         *SkipValue = gHighligthMenuInfo.SkipValue;
       } else {
         //
-        // Not found last time top of screen menu, so base on current highlight menu
-        // to find the new top of screen menu.
-        // Make the current highlight menu at the bottom of the form to calculate the
-        // top of screen menu.
+        // Case1:not found last time top of screen menu.
+        // Case2:the distance between highlight menu and top of screen menu are beyond the screen scope, such as some menus are inserted when question is refreshed.
+        // so base on current highlight menu to find the new top of screen menu.
+        // Make the current highlight menu at the bottom of the form to calculate the top of screen menu.
         //
         if (MenuOption->Skip >= BottomRow - TopRow) {
           *TopOfScreen = *HighlightMenu;
           TmpValue     = 0;
         } else {
-- 
1.9.5.msysgit.1

_______________________________________________
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel