Module: wine Branch: master Commit: 19a2af27673271a464172fb8f115ca4f811325e2 URL: https://source.winehq.org/git/wine.git/?a=commit;h=19a2af27673271a464172fb8f...
Author: Jacek Caban jacek@codeweavers.com Date: Wed Apr 20 15:57:02 2022 +0200
win32u: Move NtUserGetMenuItemRect implementation from user32.
Signed-off-by: Jacek Caban jacek@codeweavers.com Signed-off-by: Huw Davies huw@codeweavers.com Signed-off-by: Alexandre Julliard julliard@winehq.org
---
dlls/user32/menu.c | 49 ++----------------------------------------------- dlls/user32/user32.spec | 2 +- dlls/win32u/menu.c | 40 ++++++++++++++++++++++++++++++++++++++++ dlls/win32u/syscall.c | 1 + dlls/win32u/win32u.spec | 2 +- dlls/wow64win/syscall.h | 1 + dlls/wow64win/user.c | 10 ++++++++++ include/ntuser.h | 1 + 8 files changed, 57 insertions(+), 49 deletions(-)
diff --git a/dlls/user32/menu.c b/dlls/user32/menu.c index 8df665c9132..c62e0818e60 100644 --- a/dlls/user32/menu.c +++ b/dlls/user32/menu.c @@ -4262,13 +4262,13 @@ BOOL WINAPI GetMenuBarInfo( HWND hwnd, LONG idObject, LONG idItem, PMENUBARINFO } else if (idItem == 0) { - GetMenuItemRect(hwnd, hmenu, 0, &pmbi->rcBar); + NtUserGetMenuItemRect( hwnd, hmenu, 0, &pmbi->rcBar ); pmbi->rcBar.right = pmbi->rcBar.left + menu->Width; pmbi->rcBar.bottom = pmbi->rcBar.top + menu->Height; } else { - GetMenuItemRect(hwnd, hmenu, idItem - 1, &pmbi->rcBar); + NtUserGetMenuItemRect( hwnd, hmenu, idItem - 1, &pmbi->rcBar ); }
pmbi->hMenu = hmenu; @@ -5120,51 +5120,6 @@ BOOL WINAPI CheckMenuRadioItem(HMENU hMenu, UINT first, UINT last, }
-/********************************************************************** - * GetMenuItemRect (USER32.@) - * - * ATTENTION: Here, the returned values in rect are the screen - * coordinates of the item just like if the menu was - * always on the upper left side of the application. - * - */ -BOOL WINAPI GetMenuItemRect(HWND hwnd, HMENU hMenu, UINT uItem, RECT *rect) -{ - POPUPMENU *menu; - UINT pos; - RECT window_rect; - - TRACE("(%p,%p,%d,%p)\n", hwnd, hMenu, uItem, rect); - - if (!rect) - return FALSE; - - if (!(menu = find_menu_item(hMenu, uItem, MF_BYPOSITION, &pos))) - return FALSE; - - if (!hwnd) hwnd = menu->hWnd; - if (!hwnd) - { - release_menu_ptr(menu); - return FALSE; - } - - *rect = menu->items[pos].rect; - OffsetRect(rect, menu->items_rect.left, menu->items_rect.top); - - /* Popup menu item draws in the client area */ - if (menu->wFlags & MF_POPUP) MapWindowPoints(hwnd, 0, (POINT *)rect, 2); - else - { - /* Sysmenu draws in the non-client area */ - GetWindowRect(hwnd, &window_rect); - OffsetRect(rect, window_rect.left, window_rect.top); - } - - release_menu_ptr(menu); - return TRUE; -} - /********************************************************************** * SetMenuInfo (USER32.@) * diff --git a/dlls/user32/user32.spec b/dlls/user32/user32.spec index 8af07c49e98..6c54957795b 100644 --- a/dlls/user32/user32.spec +++ b/dlls/user32/user32.spec @@ -338,7 +338,7 @@ @ stdcall GetMenuItemID(long long) @ stdcall GetMenuItemInfoA(long long long ptr) @ stdcall GetMenuItemInfoW(long long long ptr) -@ stdcall GetMenuItemRect(long long long ptr) +@ stdcall GetMenuItemRect(long long long ptr) NtUserGetMenuItemRect @ stdcall GetMenuState(long long long) @ stdcall GetMenuStringA(long long ptr long long) @ stdcall GetMenuStringW(long long ptr long long) diff --git a/dlls/win32u/menu.c b/dlls/win32u/menu.c index fcb6b83b2e8..ef539d1ffdd 100644 --- a/dlls/win32u/menu.c +++ b/dlls/win32u/menu.c @@ -348,6 +348,46 @@ BOOL draw_menu_bar( HWND hwnd ) SWP_NOACTIVATE | SWP_NOZORDER | SWP_FRAMECHANGED ); }
+/********************************************************************** + * NtUserGetMenuItemRect (win32u.@) + */ +BOOL WINAPI NtUserGetMenuItemRect( HWND hwnd, HMENU handle, UINT item, RECT *rect ) +{ + POPUPMENU *menu; + UINT pos; + RECT window_rect; + + TRACE( "(%p,%p,%d,%p)\n", hwnd, handle, item, rect ); + + if (!rect) + return FALSE; + + if (!(menu = find_menu_item( handle, item, MF_BYPOSITION, &pos ))) + return FALSE; + + if (!hwnd) hwnd = menu->hWnd; + if (!hwnd) + { + release_menu_ptr( menu ); + return FALSE; + } + + *rect = menu->items[pos].rect; + OffsetRect( rect, menu->items_rect.left, menu->items_rect.top ); + + /* Popup menu item draws in the client area */ + if (menu->wFlags & MF_POPUP) map_window_points( hwnd, 0, (POINT *)rect, 2, get_thread_dpi() ); + else + { + /* Sysmenu draws in the non-client area */ + get_window_rect( hwnd, &window_rect, get_thread_dpi() ); + OffsetRect( rect, window_rect.left, window_rect.top ); + } + + release_menu_ptr(menu); + return TRUE; +} + /********************************************************************** * NtUserSetMenuContextHelpId (win32u.@) */ diff --git a/dlls/win32u/syscall.c b/dlls/win32u/syscall.c index 18204a34379..3ac03cef0d9 100644 --- a/dlls/win32u/syscall.c +++ b/dlls/win32u/syscall.c @@ -136,6 +136,7 @@ static void * const syscalls[] = NtUserGetKeyboardLayoutName, NtUserGetKeyboardState, NtUserGetLayeredWindowAttributes, + NtUserGetMenuItemRect, NtUserGetMouseMovePointsEx, NtUserGetObjectInformation, NtUserGetOpenClipboardWindow, diff --git a/dlls/win32u/win32u.spec b/dlls/win32u/win32u.spec index 4acb1dae455..44094a55b13 100644 --- a/dlls/win32u/win32u.spec +++ b/dlls/win32u/win32u.spec @@ -954,7 +954,7 @@ @ stub NtUserGetListBoxInfo @ stub NtUserGetMenuBarInfo @ stub NtUserGetMenuIndex -@ stub NtUserGetMenuItemRect +@ stdcall -syscall NtUserGetMenuItemRect(long long long ptr) @ stdcall NtUserGetMessage(ptr long long long) @ stdcall -syscall NtUserGetMouseMovePointsEx(long ptr ptr long long) @ stdcall -syscall NtUserGetObjectInformation(long long long long ptr) diff --git a/dlls/wow64win/syscall.h b/dlls/wow64win/syscall.h index fe1b2a2e2e1..52df3a4d67c 100644 --- a/dlls/wow64win/syscall.h +++ b/dlls/wow64win/syscall.h @@ -123,6 +123,7 @@ SYSCALL_ENTRY( NtUserGetKeyboardLayoutName ) \ SYSCALL_ENTRY( NtUserGetKeyboardState ) \ SYSCALL_ENTRY( NtUserGetLayeredWindowAttributes ) \ + SYSCALL_ENTRY( NtUserGetMenuItemRect ) \ SYSCALL_ENTRY( NtUserGetMouseMovePointsEx ) \ SYSCALL_ENTRY( NtUserGetObjectInformation ) \ SYSCALL_ENTRY( NtUserGetOpenClipboardWindow ) \ diff --git a/dlls/wow64win/user.c b/dlls/wow64win/user.c index 08c65e8a3df..f964b2d1b11 100644 --- a/dlls/wow64win/user.c +++ b/dlls/wow64win/user.c @@ -642,6 +642,16 @@ NTSTATUS WINAPI wow64_NtUserCheckMenuItem( UINT *args ) return NtUserCheckMenuItem( handle, id, flags ); }
+NTSTATUS WINAPI wow64_NtUserGetMenuItemRect( UINT *args ) +{ + HWND hwnd = get_handle( &args ); + HMENU handle = get_handle( &args ); + UINT item = get_ulong( &args ); + RECT *rect = get_ptr( &args ); + + return NtUserGetMenuItemRect( hwnd, handle, item, rect ); +} + NTSTATUS WINAPI wow64_NtUserSetMenuContextHelpId( UINT *args ) { HMENU menu = get_handle( &args ); diff --git a/include/ntuser.h b/include/ntuser.h index 7084dec19eb..47b6900619e 100644 --- a/include/ntuser.h +++ b/include/ntuser.h @@ -492,6 +492,7 @@ UINT WINAPI NtUserGetKeyboardLayoutList( INT size, HKL *layouts ); BOOL WINAPI NtUserGetKeyboardLayoutName( WCHAR *name ); BOOL WINAPI NtUserGetKeyboardState( BYTE *state ); BOOL WINAPI NtUserGetLayeredWindowAttributes( HWND hwnd, COLORREF *key, BYTE *alpha, DWORD *flags ); +BOOL WINAPI NtUserGetMenuItemRect( HWND hwnd, HMENU menu, UINT item, RECT *rect ); BOOL WINAPI NtUserGetMessage( MSG *msg, HWND hwnd, UINT first, UINT last ); int WINAPI NtUserGetMouseMovePointsEx( UINT size, MOUSEMOVEPOINT *ptin, MOUSEMOVEPOINT *ptout, int count, DWORD resolution );