Ignore:
Timestamp:
Feb 2, 2012, 9:42:06 PM (14 years ago)
Author:
dmik
Message:

Support MIIM_FTYPE/MIIM_STRING flags properly in InsertMenuItem/SetMenuItemInfo.

The old Wine code doesn't seem to be aware of them. This in particular fixes the
broken context menu of newer Flash (see Flash ticket #42).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/user32/menu.c

    r21916 r21961  
    10341034    maxX = (TWEAK_WineLook == WIN31_LOOK) ? GetSystemMetrics(SM_CXBORDER) : 2+1 ;
    10351035
     1036    dprintf(("*** 1 lppop->nItems %d", lppop->nItems));
    10361037    while (start < lppop->nItems)
    10371038    {
    1038     lpitem = &lppop->items[start];
    1039     orgX = maxX;
    1040     orgY = (TWEAK_WineLook == WIN31_LOOK) ? GetSystemMetrics(SM_CYBORDER) : 2;
    1041 
    1042     maxTab = maxTabWidth = 0;
    1043 
    1044       /* Parse items until column break or end of menu */
    1045     for (i = start; i < lppop->nItems; i++, lpitem++)
    1046     {
    1047         if ((i != start) &&
    1048         (lpitem->fType & (MF_MENUBREAK | MF_MENUBARBREAK))) break;
    1049 
    1050         MENU_CalcItemSize( hdc, lpitem, hwndOwner, orgX, orgY, FALSE );
    1051 
    1052         if (lpitem->fType & MF_MENUBARBREAK) orgX++;
    1053         maxX = max( maxX, lpitem->rect.right );
    1054         orgY = lpitem->rect.bottom;
    1055         if (IS_STRING_ITEM(lpitem->fType) && lpitem->xTab)
    1056         {
    1057         maxTab = max( maxTab, lpitem->xTab );
    1058         maxTabWidth = max(maxTabWidth,lpitem->rect.right-lpitem->xTab);
    1059         }
    1060     }
    1061 
    1062       /* Finish the column (set all items to the largest width found) */
    1063     maxX = max( maxX, maxTab + maxTabWidth );
    1064     for (lpitem = &lppop->items[start]; start < i; start++, lpitem++)
    1065     {
    1066         lpitem->rect.right = maxX;
    1067         if (IS_STRING_ITEM(lpitem->fType) && lpitem->xTab)
    1068         lpitem->xTab = maxTab;
    1069 
    1070     }
    1071     lppop->Height = max( lppop->Height, orgY );
     1039        lpitem = &lppop->items[start];
     1040        dprintf(("*** 1 lpitem=%x %x [%S] %x", lpitem, lpitem->fType, lpitem->text, lpitem->hSubMenu));
     1041        orgX = maxX;
     1042        orgY = (TWEAK_WineLook == WIN31_LOOK) ? GetSystemMetrics(SM_CYBORDER) : 2;
     1043
     1044        maxTab = maxTabWidth = 0;
     1045
     1046        /* Parse items until column break or end of menu */
     1047        for (i = start; i < lppop->nItems; i++, lpitem++)
     1048        {
     1049            if ((i != start) &&
     1050                (lpitem->fType & (MF_MENUBREAK | MF_MENUBARBREAK))) break;
     1051
     1052            dprintf(("*** 2 lpitem=%x %x [%S] %x", lpitem, lpitem->fType, lpitem->text, lpitem->hSubMenu));
     1053            MENU_CalcItemSize( hdc, lpitem, hwndOwner, orgX, orgY, FALSE );
     1054            dprintf(("*** 2 rect %d %d %d %d", lpitem->rect.left, lpitem->rect.top, lpitem->rect.right, lpitem->rect.bottom));
     1055
     1056            if (lpitem->fType & MF_MENUBARBREAK) orgX++;
     1057            maxX = max( maxX, lpitem->rect.right );
     1058            orgY = lpitem->rect.bottom;
     1059            if (IS_STRING_ITEM(lpitem->fType) && lpitem->xTab)
     1060            {
     1061                maxTab = max( maxTab, lpitem->xTab );
     1062                maxTabWidth = max(maxTabWidth,lpitem->rect.right-lpitem->xTab);
     1063            }
     1064        }
     1065
     1066        /* Finish the column (set all items to the largest width found) */
     1067        maxX = max( maxX, maxTab + maxTabWidth );
     1068        for (lpitem = &lppop->items[start]; start < i; start++, lpitem++)
     1069        {
     1070            lpitem->rect.right = maxX;
     1071            if (IS_STRING_ITEM(lpitem->fType) && lpitem->xTab)
     1072                lpitem->xTab = maxTab;
     1073
     1074        }
     1075        lppop->Height = max( lppop->Height, orgY );
    10721076    }
    10731077
     
    10771081    if(TWEAK_WineLook > WIN31_LOOK)
    10781082    {
    1079     lppop->Height += 2;
    1080     lppop->Width += 2;
    1081     }
     1083        lppop->Height += 2;
     1084        lppop->Width += 2;
     1085    }
     1086
     1087    dprintf(("*** 1 lppop->Height %d", lppop->Height));
     1088    dprintf(("*** 1 lppop->Width  %d", lppop->Width));
    10821089
    10831090#ifdef __WIN32OS2__
     
    45304537    }
    45314538
     4539    // In the latest Win versions (2000+?) MIIM_TYPE is superceded by separate
     4540    // MIIM_BITMAP, MIIM_FTYPE, and MIIM_STRING flags. However, the old Wine
     4541    // code seems to be not aware of that. Fix it on our own here.
     4542    // NOTE: This should go away once the new Wine is merged in.
     4543    MENUITEMINFOA mii;
     4544    if (lpmii->fMask & (MIIM_FTYPE | MIIM_STRING) == MIIM_FTYPE | MIIM_STRING)
     4545    {
     4546        mii = *lpmii;
     4547        lpmii = &mii;
     4548        mii.fMask |= MIIM_TYPE;
     4549    }
     4550
    45324551    return SetMenuItemInfo_common(MENU_FindItem(&hmenu, &item, bypos? MF_BYPOSITION : 0),
    45334552                    (const MENUITEMINFOW *)lpmii, FALSE);
     
    45404559                                 const MENUITEMINFOW *lpmii)
    45414560{
     4561    // In the latest Win versions (2000+?) MIIM_TYPE is superceded by separate
     4562    // MIIM_BITMAP, MIIM_FTYPE, and MIIM_STRING flags. However, the old Wine
     4563    // code seems to be not aware of that. Fix it on our own here.
     4564    // NOTE: This should go away once the new Wine is merged in.
     4565    MENUITEMINFOW mii;
     4566    if (lpmii->fMask & (MIIM_FTYPE | MIIM_STRING) == MIIM_FTYPE | MIIM_STRING)
     4567    {
     4568        mii = *lpmii;
     4569        lpmii = &mii;
     4570        mii.fMask |= MIIM_TYPE;
     4571    }
     4572
    45424573    return SetMenuItemInfo_common(MENU_FindItem(&hmenu, &item, bypos? MF_BYPOSITION : 0),
    45434574                    lpmii, TRUE);
     
    46414672                                const MENUITEMINFOA *lpmii)
    46424673{
     4674    // In the latest Win versions (2000+?) MIIM_TYPE is superceded by separate
     4675    // MIIM_BITMAP, MIIM_FTYPE, and MIIM_STRING flags. However, the old Wine
     4676    // code seems to be not aware of that. Fix it on our own here.
     4677    // NOTE: This should go away once the new Wine is merged in.
     4678    MENUITEMINFOA mii;
     4679    if (lpmii->fMask & (MIIM_FTYPE | MIIM_STRING) == MIIM_FTYPE | MIIM_STRING)
     4680    {
     4681        mii = *lpmii;
     4682        lpmii = &mii;
     4683        mii.fMask |= MIIM_TYPE;
     4684    }
     4685
    46434686    MENUITEM *item = MENU_InsertItem(hMenu, uItem, bypos ? MF_BYPOSITION : 0 );
    46444687    return SetMenuItemInfo_common(item, (const MENUITEMINFOW *)lpmii, FALSE);
     
    46524695                                const MENUITEMINFOW *lpmii)
    46534696{
     4697    dprintf(("*** InsertMenuItem: %d %x %x [%S]", uItem, lpmii->fMask, lpmii->fType, lpmii->fType == MFT_STRING ? lpmii->dwTypeData : 0));
     4698
     4699    // In the latest Win versions (2000+?) MIIM_TYPE is superceded by separate
     4700    // MIIM_BITMAP, MIIM_FTYPE, and MIIM_STRING flags. However, the old Wine
     4701    // code seems to be not aware of that. Fix it on our own here.
     4702    // NOTE: This should go away once the new Wine is merged in.
     4703    MENUITEMINFOW mii;
     4704    if (lpmii->fMask & (MIIM_FTYPE | MIIM_STRING) == MIIM_FTYPE | MIIM_STRING)
     4705    {
     4706        mii = *lpmii;
     4707        lpmii = &mii;
     4708        mii.fMask |= MIIM_TYPE;
     4709    }
     4710
    46544711    MENUITEM *item = MENU_InsertItem(hMenu, uItem, bypos ? MF_BYPOSITION : 0 );
    4655     return SetMenuItemInfo_common(item, lpmii, TRUE);
     4712    dprintf(("*** InsertMenuItem 1: lpitem=%x %x [%S] %x", item, item->fType, item->text, item->hSubMenu));
     4713
     4714    BOOL b = SetMenuItemInfo_common(item, lpmii, TRUE);
     4715    dprintf(("*** InsertMenuItem 2: lpitem=%x %x [%S] %x", item, item->fType, item->text, item->hSubMenu));
     4716    return b;
    46564717}
    46574718
Note: See TracChangeset for help on using the changeset viewer.