Ignore:
Timestamp:
Aug 9, 2011, 10:34:15 AM (14 years ago)
Author:
Dmitry A. Kuminov
Message:

OS/2: xsystray: Paint empty box for NULL icon.

This is what tray widgets on Windows and Linux do. Previously,
xsystray would leave an old icon if NULL icon was sent to it,
which was totally confusing.

Location:
trunk/src/3rdparty/os2/xsystray
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/3rdparty/os2/xsystray/apilib/xsystray.c

    r841 r951  
    316316
    317317    // give all processes temporary access to hIcon
    318     brc = WinSetPointerOwner(hIcon, 0, FALSE);
     318    brc = ;
    319319    if (brc)
    320320    {
     
    340340
    341341        // revoke temporary access to hIcon
    342         DosGetInfoBlocks(NULL, &ppib);
    343         WinSetPointerOwner(hIcon, ppib->pib_ulpid, TRUE);
     342        if (hIcon != NULLHANDLE)
     343        {
     344            DosGetInfoBlocks(NULL, &ppib);
     345            WinSetPointerOwner(hIcon, ppib->pib_ulpid, TRUE);
     346        }
    344347    }
    345348
     
    402405
    403406    // give all processes temporary access to hIcon
    404     brc = WinSetPointerOwner(hIcon, 0, FALSE);
     407    brc = ;
    405408    if (brc)
    406409    {
     
    414417
    415418        // revoke temporary access to hIcon
    416         DosGetInfoBlocks(NULL, &ppib);
    417         WinSetPointerOwner(hIcon, ppib->pib_ulpid, TRUE);
     419        if (hIcon != NULLHANDLE)
     420        {
     421            DosGetInfoBlocks(NULL, &ppib);
     422            WinSetPointerOwner(hIcon, ppib->pib_ulpid, TRUE);
     423        }
    418424    }
    419425
  • trunk/src/3rdparty/os2/xsystray/plugin/w_xsystray.c

    r842 r951  
    828828                break;
    829829
    830             DrawPointer(hps, x, y, pSysTrayData->pIcons[i].hIcon, DP_MINI);
     830            // just leave an empty box if the icon is NULL, this is what
     831            // Windows and Linux tray widgets do
     832            if (pSysTrayData->pIcons[i].hIcon != NULLHANDLE)
     833                DrawPointer(hps, x, y, pSysTrayData->pIcons[i].hIcon, DP_MINI);
    831834            x += lIconStep;
    832835        }
     
    12101213            // make a private copy of the provided icon (it will get lost after
    12111214            // we return from this message)
    1212             brc = WinQueryPointerInfo(pCtlData->u.icon.hIcon, &Info);
    1213             if (!brc)
    1214                 break;
    1215             hIcon = WinCreatePointerIndirect(HWND_DESKTOP, &Info);
    1216             if (hIcon == NULLHANDLE)
    1217                 break;
     1215            if (pCtlData->u.icon.hIcon != NULLHANDLE)
     1216            {
     1217                brc = WinQueryPointerInfo(pCtlData->u.icon.hIcon, &Info);
     1218                if (!brc)
     1219                    break;
     1220                hIcon = WinCreatePointerIndirect(HWND_DESKTOP, &Info);
     1221                if (hIcon == NULLHANDLE)
     1222                    break;
     1223            }
    12181224
    12191225            pData = FindIconData(pSysTrayData, pCtlData->hwndSender,
     
    12311237                    if (!pData->pszToolTip)
    12321238                    {
    1233                         WinDestroyPointer(hIcon);
     1239                        if (hIcon != NULLHANDLE)
     1240                            WinDestroyPointer(hIcon);
    12341241                        break;
    12351242                    }
     
    12511258
    12521259                // now update the icon
    1253                 WinDestroyPointer(pData->hIcon);
     1260                if (pData->hIcon != NULLHANDLE)
     1261                    WinDestroyPointer(pData->hIcon);
    12541262                pData->hIcon = hIcon;
    12551263                pData->ulMsgId = pCtlData->u.icon.ulMsgId;
     
    12761284                    if (pNewIcons == NULL)
    12771285                    {
    1278                         WinDestroyPointer(hIcon);
     1286                        if (hIcon != NULLHANDLE)
     1287                            WinDestroyPointer(hIcon);
    12791288                        break;
    12801289                    }
     
    12991308                    if (!pData->pszToolTip)
    13001309                    {
    1301                         WinDestroyPointer(hIcon);
     1310                        if (hIcon != NULLHANDLE)
     1311                            WinDestroyPointer(hIcon);
    13021312                        break;
    13031313                    }
     
    13281338            // make a private copy of the provided icon (it will get lost after
    13291339            // we return from this message)
    1330             brc = WinQueryPointerInfo(pCtlData->u.icon.hIcon, &Info);
    1331             if (!brc)
    1332                 break;
    1333             hIcon = WinCreatePointerIndirect(HWND_DESKTOP, &Info);
    1334             if (hIcon == NULLHANDLE)
    1335                 break;
     1340            if (pCtlData->u.icon.hIcon != NULLHANDLE)
     1341            {
     1342                brc = WinQueryPointerInfo(pCtlData->u.icon.hIcon, &Info);
     1343                if (!brc)
     1344                    break;
     1345                hIcon = WinCreatePointerIndirect(HWND_DESKTOP, &Info);
     1346                if (hIcon == NULLHANDLE)
     1347                    break;
     1348            }
    13361349
    13371350            pData = FindIconData(pSysTrayData, pCtlData->hwndSender,
     
    13411354                LOGF((" Replacing with hIcon %x\n", hIcon));
    13421355
    1343                 WinDestroyPointer(pData->hIcon);
     1356                if (pData->hIcon != NULLHANDLE)
     1357                    WinDestroyPointer(pData->hIcon);
    13441358                pData->hIcon = hIcon;
    13451359                pData->ulMsgId = pCtlData->u.icon.ulMsgId;
Note: See TracChangeset for help on using the changeset viewer.