Huw Davies : user32: Limit the menu height to that of the work area.

Alexandre Julliard julliard at winehq.org
Thu Mar 30 15:18:03 CDT 2017


Module: wine
Branch: master
Commit: 3c0ddd59716dab6408a540c90f4cef19c6d2f1d6
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=3c0ddd59716dab6408a540c90f4cef19c6d2f1d6

Author: Huw Davies <huw at codeweavers.com>
Date:   Thu Mar 30 10:58:33 2017 +0100

user32: Limit the menu height to that of the work area.

Signed-off-by: Huw Davies <huw at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/user32/menu.c | 34 +++++++++++++---------------------
 1 file changed, 13 insertions(+), 21 deletions(-)

diff --git a/dlls/user32/menu.c b/dlls/user32/menu.c
index 543e0c1..e2ab09c 100644
--- a/dlls/user32/menu.c
+++ b/dlls/user32/menu.c
@@ -1136,31 +1136,18 @@ static void MENU_CalcItemSize( HDC hdc, MENUITEM *lpitem, HWND hwndOwner,
     TRACE("%s\n", wine_dbgstr_rect( &lpitem->rect));
 }
 
-
-/***********************************************************************
- *           MENU_GetMaxPopupHeight
- */
-static UINT
-MENU_GetMaxPopupHeight(const POPUPMENU *lppop)
-{
-    if (lppop->cyMax)
-        return lppop->cyMax;
-    return GetSystemMetrics(SM_CYSCREEN) - GetSystemMetrics(SM_CYBORDER);
-}
-
-
 /***********************************************************************
  *           MENU_PopupMenuCalcSize
  *
  * Calculate the size of a popup menu.
  */
-static void MENU_PopupMenuCalcSize( LPPOPUPMENU lppop )
+static void MENU_PopupMenuCalcSize( LPPOPUPMENU lppop, UINT max_height )
 {
     MENUITEM *lpitem;
     HDC hdc;
     UINT start, i;
     BOOL textandbmp = FALSE, multi_col = FALSE;
-    int orgX, orgY, maxTab, maxTabWidth, maxHeight;
+    int orgX, orgY, maxTab, maxTabWidth;
 
     lppop->Width = lppop->Height = 0;
     SetRectEmpty(&lppop->items_rect);
@@ -1230,10 +1217,9 @@ static void MENU_PopupMenuCalcSize( LPPOPUPMENU lppop )
     lppop->Width = lppop->items_rect.right + MENU_MARGIN;
 
     /* Adjust popup height if it exceeds maximum */
-    maxHeight = MENU_GetMaxPopupHeight(lppop);
-    if (lppop->Height >= maxHeight)
+    if (lppop->Height >= max_height)
     {
-        lppop->Height = maxHeight;
+        lppop->Height = max_height;
         lppop->bScrolling = !multi_col;
         /* When the scroll arrows are present, don't add the top/bottom margin as well */
         if (lppop->bScrolling)
@@ -1894,6 +1880,7 @@ static BOOL MENU_ShowPopup( HWND hwndOwner, HMENU hmenu, UINT id, UINT flags,
     POINT pt;
     HMONITOR monitor;
     MONITORINFO info;
+    UINT max_height;
 
     TRACE("owner=%p hmenu=%p id=0x%04x x=0x%04x y=0x%04x xa=0x%04x ya=0x%04x\n",
           hwndOwner, hmenu, id, x, y, xanchor, yanchor);
@@ -1906,9 +1893,6 @@ static BOOL MENU_ShowPopup( HWND hwndOwner, HMENU hmenu, UINT id, UINT flags,
     }
 
     menu->nScrollPos = 0;
-    MENU_PopupMenuCalcSize( menu );
-
-    /* adjust popup menu pos so that it fits within the desktop */
 
     /* FIXME: should use item rect */
     pt.x = x;
@@ -1917,6 +1901,14 @@ static BOOL MENU_ShowPopup( HWND hwndOwner, HMENU hmenu, UINT id, UINT flags,
     info.cbSize = sizeof(info);
     GetMonitorInfoW( monitor, &info );
 
+    max_height = info.rcWork.bottom - info.rcWork.top;
+    if (menu->cyMax)
+        max_height = min( max_height, menu->cyMax );
+
+    MENU_PopupMenuCalcSize( menu, max_height );
+
+    /* adjust popup menu pos so that it fits within the desktop */
+
     if (flags & TPM_LAYOUTRTL)
         flags ^= TPM_RIGHTALIGN;
 




More information about the wine-cvs mailing list