user32: Limit the menu height to that of the work area.
Signed-off-by: Huw Davies <huw@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
1d4992282d
commit
3c0ddd5971
|
@ -1136,31 +1136,18 @@ static void MENU_CalcItemSize( HDC hdc, MENUITEM *lpitem, HWND hwndOwner,
|
||||||
TRACE("%s\n", wine_dbgstr_rect( &lpitem->rect));
|
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
|
* MENU_PopupMenuCalcSize
|
||||||
*
|
*
|
||||||
* Calculate the size of a popup menu.
|
* Calculate the size of a popup menu.
|
||||||
*/
|
*/
|
||||||
static void MENU_PopupMenuCalcSize( LPPOPUPMENU lppop )
|
static void MENU_PopupMenuCalcSize( LPPOPUPMENU lppop, UINT max_height )
|
||||||
{
|
{
|
||||||
MENUITEM *lpitem;
|
MENUITEM *lpitem;
|
||||||
HDC hdc;
|
HDC hdc;
|
||||||
UINT start, i;
|
UINT start, i;
|
||||||
BOOL textandbmp = FALSE, multi_col = FALSE;
|
BOOL textandbmp = FALSE, multi_col = FALSE;
|
||||||
int orgX, orgY, maxTab, maxTabWidth, maxHeight;
|
int orgX, orgY, maxTab, maxTabWidth;
|
||||||
|
|
||||||
lppop->Width = lppop->Height = 0;
|
lppop->Width = lppop->Height = 0;
|
||||||
SetRectEmpty(&lppop->items_rect);
|
SetRectEmpty(&lppop->items_rect);
|
||||||
|
@ -1230,10 +1217,9 @@ static void MENU_PopupMenuCalcSize( LPPOPUPMENU lppop )
|
||||||
lppop->Width = lppop->items_rect.right + MENU_MARGIN;
|
lppop->Width = lppop->items_rect.right + MENU_MARGIN;
|
||||||
|
|
||||||
/* Adjust popup height if it exceeds maximum */
|
/* Adjust popup height if it exceeds maximum */
|
||||||
maxHeight = MENU_GetMaxPopupHeight(lppop);
|
if (lppop->Height >= max_height)
|
||||||
if (lppop->Height >= maxHeight)
|
|
||||||
{
|
{
|
||||||
lppop->Height = maxHeight;
|
lppop->Height = max_height;
|
||||||
lppop->bScrolling = !multi_col;
|
lppop->bScrolling = !multi_col;
|
||||||
/* When the scroll arrows are present, don't add the top/bottom margin as well */
|
/* When the scroll arrows are present, don't add the top/bottom margin as well */
|
||||||
if (lppop->bScrolling)
|
if (lppop->bScrolling)
|
||||||
|
@ -1894,6 +1880,7 @@ static BOOL MENU_ShowPopup( HWND hwndOwner, HMENU hmenu, UINT id, UINT flags,
|
||||||
POINT pt;
|
POINT pt;
|
||||||
HMONITOR monitor;
|
HMONITOR monitor;
|
||||||
MONITORINFO info;
|
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",
|
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);
|
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->nScrollPos = 0;
|
||||||
MENU_PopupMenuCalcSize( menu );
|
|
||||||
|
|
||||||
/* adjust popup menu pos so that it fits within the desktop */
|
|
||||||
|
|
||||||
/* FIXME: should use item rect */
|
/* FIXME: should use item rect */
|
||||||
pt.x = x;
|
pt.x = x;
|
||||||
|
@ -1917,6 +1901,14 @@ static BOOL MENU_ShowPopup( HWND hwndOwner, HMENU hmenu, UINT id, UINT flags,
|
||||||
info.cbSize = sizeof(info);
|
info.cbSize = sizeof(info);
|
||||||
GetMonitorInfoW( monitor, &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)
|
if (flags & TPM_LAYOUTRTL)
|
||||||
flags ^= TPM_RIGHTALIGN;
|
flags ^= TPM_RIGHTALIGN;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue