[USER32]
* Fix what I think is a wrong behaviour of storing MF_POPUP in the fType of the menu. Now it relies on hSubMenu being != NULL as an indicator of the presence of a submenu.
* Resource submenus are not supposed to get the hSubMenu as a wID, as far as I can tell.
* From the user point of view, it matches Windows better. Needs review and testing, as I don't know if I updated everything correctly.

svn path=/branches/shell-experiments/; revision=62415
This commit is contained in:
David Quintana 2014-03-03 16:12:39 +00:00
parent 7fe9315c7e
commit d21bce9206
2 changed files with 18 additions and 39 deletions

View file

@ -529,7 +529,7 @@ IntGetMenuItemByFlag(PMENU_OBJECT Menu, UINT uSearchBy, UINT fFlag,
} }
else else
{ {
if(CurItem->fType & MF_POPUP) if(CurItem->hSubMenu)
{ {
PMENU_OBJECT NewMenu = UserGetMenuObject(CurItem->hSubMenu); PMENU_OBJECT NewMenu = UserGetMenuObject(CurItem->hSubMenu);
if(NewMenu) if(NewMenu)
@ -653,8 +653,7 @@ IntGetMenuItemInfo(PMENU_OBJECT Menu, /* UNUSED PARAM!! */
BOOL FASTCALL BOOL FASTCALL
IntSetMenuItemInfo(PMENU_OBJECT MenuObject, PMENU_ITEM MenuItem, PROSMENUITEMINFO lpmii) IntSetMenuItemInfo(PMENU_OBJECT MenuObject, PMENU_ITEM MenuItem, PROSMENUITEMINFO lpmii)
{ {
PMENU_OBJECT SubMenuObject; UINT fTypeMask = (MFT_BITMAP | MFT_MENUBARBREAK | MFT_MENUBREAK | MFT_OWNERDRAW | MFT_RADIOCHECK | MFT_RIGHTJUSTIFY | MFT_SEPARATOR);
UINT fTypeMask = (MFT_BITMAP | MFT_MENUBARBREAK | MFT_MENUBREAK | MFT_OWNERDRAW | MFT_RADIOCHECK | MFT_RIGHTJUSTIFY | MFT_SEPARATOR | MF_POPUP);
if(!MenuItem || !MenuObject || !lpmii) if(!MenuItem || !MenuObject || !lpmii)
{ {
@ -735,24 +734,6 @@ IntSetMenuItemInfo(PMENU_OBJECT MenuObject, PMENU_ITEM MenuItem, PROSMENUITEMINF
if(lpmii->fMask & MIIM_SUBMENU) if(lpmii->fMask & MIIM_SUBMENU)
{ {
MenuItem->hSubMenu = lpmii->hSubMenu; MenuItem->hSubMenu = lpmii->hSubMenu;
/* Make sure the submenu is marked as a popup menu */
if (MenuItem->hSubMenu)
{
SubMenuObject = UserGetMenuObject(MenuItem->hSubMenu);
if (SubMenuObject != NULL)
{
SubMenuObject->MenuInfo.Flags |= MF_POPUP;
MenuItem->fType |= MF_POPUP;
}
else
{
MenuItem->fType &= ~MF_POPUP;
}
}
else
{
MenuItem->fType &= ~MF_POPUP;
}
} }
if ((lpmii->fMask & MIIM_STRING) || if ((lpmii->fMask & MIIM_STRING) ||
@ -1469,7 +1450,7 @@ UINT FASTCALL IntFindSubMenu(HMENU *hMenu, HMENU hSubTarget )
return NO_SELECTED_ITEM; return NO_SELECTED_ITEM;
} }
if (!(mi->fType & MF_POPUP)) continue; if (!(mi->hSubMenu)) continue;
if (mi->hSubMenu == hSubTarget) if (mi->hSubMenu == hSubTarget)
{ {
@ -2038,7 +2019,7 @@ NtUserGetMenuItemRect(
if (!(ReferenceWnd = UserGetWindowObject(hWnd))) RETURN( FALSE); if (!(ReferenceWnd = UserGetWindowObject(hWnd))) RETURN( FALSE);
if(MenuItem->fType & MF_POPUP) if(MenuItem->hSubMenu)
{ {
XMove = ReferenceWnd->rcClient.left; XMove = ReferenceWnd->rcClient.left;
YMove = ReferenceWnd->rcClient.top; YMove = ReferenceWnd->rcClient.top;

View file

@ -396,7 +396,7 @@ static UINT FASTCALL MenuFindSubMenu(HMENU *hmenu, HMENU hSubTarget )
MenuCleanupRosMenuItemInfo(&item); MenuCleanupRosMenuItemInfo(&item);
return NO_SELECTED_ITEM; return NO_SELECTED_ITEM;
} }
if (!(item.fType & MF_POPUP)) continue; if (!(item.hSubMenu)) continue;
if (item.hSubMenu == hSubTarget) { if (item.hSubMenu == hSubTarget) {
MenuCleanupRosMenuItemInfo(&item); MenuCleanupRosMenuItemInfo(&item);
return i; return i;
@ -1207,7 +1207,7 @@ static void FASTCALL MenuDrawMenuItem(HWND hWnd, PROSMENUINFO MenuInfo, HWND Wnd
dis.rcItem.bottom); dis.rcItem.bottom);
SendMessageW(WndOwner, WM_DRAWITEM, 0, (LPARAM) &dis); SendMessageW(WndOwner, WM_DRAWITEM, 0, (LPARAM) &dis);
/* Draw the popup-menu arrow */ /* Draw the popup-menu arrow */
if (lpitem->fType & MF_POPUP) if (lpitem->hSubMenu)
{ {
RECT rectTemp; RECT rectTemp;
CopyRect(&rectTemp, &rect); CopyRect(&rectTemp, &rect);
@ -1345,7 +1345,7 @@ static void FASTCALL MenuDrawMenuItem(HWND hWnd, PROSMENUINFO MenuInfo, HWND Wnd
} }
} }
/* Draw the popup-menu arrow */ /* Draw the popup-menu arrow */
if (lpitem->fType & MF_POPUP) if (lpitem->hSubMenu)
{ {
RECT rectTemp; RECT rectTemp;
CopyRect(&rectTemp, &rect); CopyRect(&rectTemp, &rect);
@ -1694,7 +1694,7 @@ static void FASTCALL MenuSelectItem(HWND hwndOwner, PROSMENUINFO hmenu, UINT wIn
if (sendMenuSelect) if (sendMenuSelect)
{ {
SendMessageW(hwndOwner, WM_MENUSELECT, SendMessageW(hwndOwner, WM_MENUSELECT,
MAKELONG(ItemInfo.fType & MF_POPUP ? wIndex : ItemInfo.wID, MAKELONG(ItemInfo.hSubMenu ? wIndex : ItemInfo.wID,
ItemInfo.fType | ItemInfo.fState | MF_MOUSESELECT | ItemInfo.fType | ItemInfo.fState | MF_MOUSESELECT |
(hmenu->Flags & MF_SYSMENU)), (LPARAM) hmenu->Self); (hmenu->Flags & MF_SYSMENU)), (LPARAM) hmenu->Self);
} }
@ -2114,8 +2114,7 @@ static LPCSTR MENUEX_ParseResource(LPCSTR res, HMENU hMenu)
return NULL; return NULL;
} }
mii.fMask |= MIIM_SUBMENU; mii.fMask |= MIIM_SUBMENU;
mii.fType |= MF_POPUP; /*mii.wID = (UINT)mii.hSubMenu;*/
mii.wID = (UINT)mii.hSubMenu;
} }
else if (!mii.dwTypeData[0]) else if (!mii.dwTypeData[0])
mii.fType |= MF_SEPARATOR; mii.fType |= MF_SEPARATOR;
@ -2315,7 +2314,7 @@ MenuShowSubPopup(HWND WndOwner, PROSMENUINFO MenuInfo, BOOL SelectFirst, UINT Fl
MenuCleanupRosMenuItemInfo(&ItemInfo); MenuCleanupRosMenuItemInfo(&ItemInfo);
return MenuInfo->Self; return MenuInfo->Self;
} }
if (0 == (ItemInfo.fType & MF_POPUP) || 0 != (ItemInfo.fState & (MF_GRAYED | MF_DISABLED))) if (0 == (ItemInfo.hSubMenu) || 0 != (ItemInfo.fState & (MF_GRAYED | MF_DISABLED)))
{ {
MenuCleanupRosMenuItemInfo(&ItemInfo); MenuCleanupRosMenuItemInfo(&ItemInfo);
return MenuInfo->Self; return MenuInfo->Self;
@ -2447,7 +2446,7 @@ MenuHideSubPopups(HWND WndOwner, PROSMENUINFO MenuInfo,
MenuInitRosMenuItemInfo(&ItemInfo); MenuInitRosMenuItemInfo(&ItemInfo);
ItemInfo.fMask |= MIIM_FTYPE | MIIM_STATE; ItemInfo.fMask |= MIIM_FTYPE | MIIM_STATE;
if (! MenuGetRosMenuItemInfo(MenuInfo->Self, MenuInfo->FocusedItem, &ItemInfo) if (! MenuGetRosMenuItemInfo(MenuInfo->Self, MenuInfo->FocusedItem, &ItemInfo)
|| 0 == (ItemInfo.fType & MF_POPUP) || 0 == (ItemInfo.hSubMenu)
|| 0 == (ItemInfo.fState & MF_MOUSESELECT)) || 0 == (ItemInfo.fState & MF_MOUSESELECT))
{ {
MenuCleanupRosMenuItemInfo(&ItemInfo); MenuCleanupRosMenuItemInfo(&ItemInfo);
@ -2532,7 +2531,7 @@ MenuExecFocusedItem(MTRACKER *Mt, PROSMENUINFO MenuInfo, UINT Flags)
TRACE("%p %08x %p\n", MenuInfo, ItemInfo.wID, ItemInfo.hSubMenu); TRACE("%p %08x %p\n", MenuInfo, ItemInfo.wID, ItemInfo.hSubMenu);
if (0 == (ItemInfo.fType & MF_POPUP)) if (0 == (ItemInfo.hSubMenu))
{ {
if (0 == (ItemInfo.fState & (MF_GRAYED | MF_DISABLED)) if (0 == (ItemInfo.fState & (MF_GRAYED | MF_DISABLED))
&& 0 == (ItemInfo.fType & MF_SEPARATOR)) && 0 == (ItemInfo.fType & MF_SEPARATOR))
@ -2663,7 +2662,7 @@ MenuButtonUp(MTRACKER *Mt, HMENU PtMenu, UINT Flags)
if (0 <= Id && MenuGetRosMenuItemInfo(MenuInfo.Self, Id, &ItemInfo) && if (0 <= Id && MenuGetRosMenuItemInfo(MenuInfo.Self, Id, &ItemInfo) &&
MenuInfo.FocusedItem == Id) MenuInfo.FocusedItem == Id)
{ {
if (0 == (ItemInfo.fType & MF_POPUP)) if (0 == (ItemInfo.hSubMenu))
{ {
INT ExecutedMenuId = MenuExecFocusedItem(Mt, &MenuInfo, Flags); INT ExecutedMenuId = MenuExecFocusedItem(Mt, &MenuInfo, Flags);
MenuCleanupRosMenuItemInfo(&ItemInfo); MenuCleanupRosMenuItemInfo(&ItemInfo);
@ -2712,7 +2711,7 @@ MenuPtMenu(HMENU Menu, POINT Pt)
{ {
MenuInitRosMenuItemInfo(&ItemInfo); MenuInitRosMenuItemInfo(&ItemInfo);
if (MenuGetRosMenuItemInfo(MenuInfo.Self, MenuInfo.FocusedItem, &ItemInfo) && if (MenuGetRosMenuItemInfo(MenuInfo.Self, MenuInfo.FocusedItem, &ItemInfo) &&
0 != (ItemInfo.fType & MF_POPUP) && 0 != (ItemInfo.hSubMenu) &&
0 != (ItemInfo.fState & MF_MOUSESELECT)) 0 != (ItemInfo.fState & MF_MOUSESELECT))
{ {
Ret = MenuPtMenu(ItemInfo.hSubMenu, Pt); Ret = MenuPtMenu(ItemInfo.hSubMenu, Pt);
@ -2826,7 +2825,7 @@ MenuGetSubPopup(HMENU Menu)
MenuCleanupRosMenuItemInfo(&ItemInfo); MenuCleanupRosMenuItemInfo(&ItemInfo);
return NULL; return NULL;
} }
if (0 != (ItemInfo.fType & MF_POPUP) && 0 != (ItemInfo.fState & MF_MOUSESELECT)) if (0 != (ItemInfo.hSubMenu) && 0 != (ItemInfo.fState & MF_MOUSESELECT))
{ {
MenuCleanupRosMenuItemInfo(&ItemInfo); MenuCleanupRosMenuItemInfo(&ItemInfo);
return ItemInfo.hSubMenu; return ItemInfo.hSubMenu;
@ -3885,7 +3884,6 @@ MenuSetItemData(
if(Flags & MF_POPUP) if(Flags & MF_POPUP)
{ {
mii->fType |= MF_POPUP;
mii->fMask |= MIIM_SUBMENU; mii->fMask |= MIIM_SUBMENU;
mii->hSubMenu = (HMENU)IDNewItem; mii->hSubMenu = (HMENU)IDNewItem;
} }
@ -3995,7 +3993,7 @@ MenuCheckMenuRadioItem(HMENU hMenu, UINT idFirst, UINT idLast, UINT idCheck, UIN
if (0 != (Items[i].fType & MF_MENUBARBREAK)) continue; if (0 != (Items[i].fType & MF_MENUBARBREAK)) continue;
if (0 != (Items[i].fType & MF_SEPARATOR)) continue; if (0 != (Items[i].fType & MF_SEPARATOR)) continue;
if ((Items[i].fType & MF_POPUP) && (uFlags == MF_BYCOMMAND)) if ((Items[i].hSubMenu) && (uFlags == MF_BYCOMMAND))
{ {
MenuCheckMenuRadioItem(Items[i].hSubMenu, idFirst, idLast, idCheck, uFlags, bCheck, pChecked, pUnchecked, pMenuChanged); MenuCheckMenuRadioItem(Items[i].hSubMenu, idFirst, idLast, idCheck, uFlags, bCheck, pChecked, pUnchecked, pMenuChanged);
continue; continue;
@ -4899,7 +4897,7 @@ ModifyMenuA(
if(!MenuGetRosMenuItemInfo( hMnu, uPosition, &rmii)) return FALSE; if(!MenuGetRosMenuItemInfo( hMnu, uPosition, &rmii)) return FALSE;
if ((rmii.fType & MF_POPUP) && (uFlags & MF_POPUP) && (rmii.hSubMenu != (HMENU)uIDNewItem)) if ((rmii.hSubMenu) && (uFlags & MF_POPUP) && (rmii.hSubMenu != (HMENU)uIDNewItem))
NtUserDestroyMenu( rmii.hSubMenu ); /* ModifyMenu() spec */ NtUserDestroyMenu( rmii.hSubMenu ); /* ModifyMenu() spec */
MenuCleanupRosMenuItemInfo( &rmii ); MenuCleanupRosMenuItemInfo( &rmii );
@ -4946,7 +4944,7 @@ ModifyMenuW(
if(!MenuGetRosMenuItemInfo( hMnu, uPosition, &rmii)) return FALSE; if(!MenuGetRosMenuItemInfo( hMnu, uPosition, &rmii)) return FALSE;
if ((rmii.fType & MF_POPUP) && (uFlags & MF_POPUP) && (rmii.hSubMenu != (HMENU)uIDNewItem)) if ((rmii.hSubMenu) && (uFlags & MF_POPUP) && (rmii.hSubMenu != (HMENU)uIDNewItem))
NtUserDestroyMenu( rmii.hSubMenu ); /* ModifyMenu() spec */ NtUserDestroyMenu( rmii.hSubMenu ); /* ModifyMenu() spec */
MenuCleanupRosMenuItemInfo( &rmii ); MenuCleanupRosMenuItemInfo( &rmii );