Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- diff --git a/dlls/win32u/menu.c b/dlls/win32u/menu.c
- index a6b7ec38003..99c60076a12 100644
- --- a/dlls/win32u/menu.c
- +++ b/dlls/win32u/menu.c
- @@ -4069,6 +4069,83 @@ static UINT find_item_by_key( HWND owner, HMENU hmenu, WCHAR key, BOOL force_men
- return -1;
- }
- +/* Recalculate the menu bar size if needed, eg. if the application
- + * modified the menu in the WM_INITMENU message.
- + * This tweak is taken (and tidied) from
- + * https://www.winehq.org/pipermail/wine-patches/2009-April/071602.html,
- + * complete with its original comments, and is simply ported to
- + * Wine 8.4 by me (@NoodleCollie). I don't know enough about the
- + * codebase to know if this is the best approach (the original
- + * author seemed troubled by it), but apparently it was used to
- + * generate an ancient "1.6-rc2-Reason5Menu" release, so it must be
- + * at least half-decent. */
- +static void recalc_menu_bar_if_needed( HWND hwnd, struct menu *menu, UINT flags )
- +{
- + RECT rc;
- + LONG style = 0;
- + LONG exstyle = 0;
- + HDC hdc = 0;
- + INT width = 0;
- + INT height = 0;
- +
- + if ( (flags & TPM_POPUPMENU) || !menu || menu->Height != 0 )
- + {
- + /* Recalculating size is not needed. */
- + return;
- + }
- +
- + style = NtUserGetWindowLongW( hwnd, GWL_STYLE );
- + exstyle = NtUserGetWindowLongW( hwnd, GWL_EXSTYLE );
- + hdc = NtUserGetDCEx( hwnd, 0, DCX_CACHE | DCX_WINDOW );
- +
- + NtGdiSelectFont( hdc, get_menu_font(FALSE));
- +
- + /* Original author:
- + * FIXME: calculations taken from nonclient.c and uitools.c
- + * unfortunately too intertwined with non-client redrawing
- + * I do not like to introduce another unneeded redraw here
- + * this code should probaby be put there */
- +
- + NtUserGetWindowRect( hwnd, &rc);
- + SetRect( &rc, 0, 0, rc.right - rc.left, 0);
- +
- + rc.top = NtUserGetSystemMetrics(SM_CYCAPTION);
- +
- + if ( style & WS_THICKFRAME )
- + {
- + width += NtUserGetSystemMetrics(SM_CXFRAME) - NtUserGetSystemMetrics(SM_CXDLGFRAME);
- + height += NtUserGetSystemMetrics(SM_CYFRAME) - NtUserGetSystemMetrics(SM_CYDLGFRAME);
- + }
- +
- + if ( (style & (WS_BORDER | WS_DLGFRAME)) || (exstyle & WS_EX_DLGMODALFRAME) )
- + {
- + width += NtUserGetSystemMetrics(SM_CXDLGFRAME) - NtUserGetSystemMetrics(SM_CXEDGE);
- + height += NtUserGetSystemMetrics(SM_CYDLGFRAME) - NtUserGetSystemMetrics(SM_CYEDGE);
- + }
- +
- + /* HAS_THICKFRAME */
- + if ( (style & WS_THICKFRAME) && !((style & (WS_DLGFRAME | WS_BORDER)) == WS_DLGFRAME) )
- + {
- + width++;
- + height++;
- + }
- +
- + /* HAS_BIGFRAME */
- + if ( (style & (WS_THICKFRAME | WS_DLGFRAME)) || (exstyle & WS_EX_DLGMODALFRAME) )
- + {
- + width++;
- + height++;
- + }
- +
- + rc.left += width;
- + rc.right -= width;
- + rc.top += height;
- + rc.bottom = rc.top + NtUserGetSystemMetrics(SM_CYMENU);
- +
- + calc_menu_bar_size( hdc, &rc, menu, hwnd );
- + NtUserReleaseDC( hwnd, hdc );
- +}
- +
- static BOOL track_menu( HMENU hmenu, UINT flags, int x, int y, HWND hwnd, const RECT *rect )
- {
- BOOL enter_idle_sent = FALSE;
- @@ -4096,6 +4173,8 @@ static BOOL track_menu( HMENU hmenu, UINT flags, int x, int y, HWND hwnd, const
- return FALSE;
- }
- + recalc_menu_bar_if_needed( hwnd, menu, flags );
- +
- if (flags & TPM_BUTTONDOWN)
- {
- /* Get the result in order to start the tracking or not */
- @@ -4383,7 +4462,8 @@ static BOOL init_tracking( HWND hwnd, HMENU handle, BOOL is_popup, UINT flags )
- {
- send_message( hwnd, WM_INITMENU, (WPARAM)handle, 0 );
- /* If an app changed/recreated menu bar entries in WM_INITMENU
- - * menu sizes will be recalculated once the menu created/shown. */
- + * menu sizes will be recalculated either in track_menu() or
- + * once the menu created/shown. */
- }
- return TRUE;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement