Changeset 285 for trunk/src


Ignore:
Timestamp:
Nov 3, 2009, 3:58:20 AM (16 years ago)
Author:
Dmitry A. Kuminov
Message:

3rdparty: os2/xsystray: Implemented xstQuerySysTrayIconRect() API call. Fixed the regression of the previous checkin (icons wouldn't be removed when the associated application crashed).

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

Legend:

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

    r282 r285  
    735735 *      to left.
    736736 *
    737  *      NOTE: This function must be keept in sync with FindIconDataAtPt() in
    738  *      terms of system tray geometry.
     737 *      NOTE: This function must be keept in sync with FindIconDataAtPt() and
     738 *      SYSTRAYCMD_QUERYRECT in terms of system tray geometry.
    739739 */
    740740/*
     
    13111311                }
    13121312
     1313                ++pSysTrayData->cIcons;
     1314
    13131315                WgtXSysTrayUpdateAfterIconAddRemove(pWidget);
    1314 
    1315                 ++pSysTrayData->cIcons;
    13161316
    13171317                xrc = XST_OK;
     
    14391439                }
    14401440
     1441                xrc = XST_OK;
     1442            }
     1443            else
     1444                LOGF((" Icon not found!\n"));
     1445        }
     1446        break;
     1447
     1448        case SYSTRAYCMD_QUERYRECT:
     1449        {
     1450            size_t i;
     1451            PICONDATA pData;
     1452
     1453            LOGF(("SYSTRAYCMD_QUERYRECT\n"));
     1454            LOGF((" hwnd  %x\n", pCtlData->hwndSender));
     1455            LOGF((" usId  %d\n", pCtlData->u.icon.usId));
     1456
     1457            pCtlData->bAcknowledged = TRUE;
     1458
     1459            pData = FindIconData(pSysTrayData, pCtlData->hwndSender,
     1460                                 pCtlData->u.icon.usId, &i);
     1461            if (pData)
     1462            {
     1463                // Refer to FindIconDataAtPt() for details
     1464
     1465                SWP     swp;
     1466                RECTL   rcl;
     1467                BOOL    bLeftToRight;
     1468                LONG    y, lIconStep;
     1469
     1470                WinQueryWindowPos(pWidget->hwndWidget, &swp);
     1471                WinQueryWindowRect(pWidget->pGlobals->hwndClient, &rcl);
     1472
     1473                y = (swp.cy - pSysTrayData->lIconHeight) / 2;
     1474
     1475                // detect the direction
     1476                bLeftToRight = swp.x + swp.cx / 2 < (rcl.xRight / 2);
     1477
     1478                lIconStep = pSysTrayData->lIconWidth + pSysTrayData->lIconPad;
     1479
     1480                pCtlData->u.rect.rclIcon.yBottom = y;
     1481                pCtlData->u.rect.rclIcon.yTop = y + pSysTrayData->lIconHeight;
     1482
     1483                if (bLeftToRight)
     1484                {
     1485                    pCtlData->u.rect.rclIcon.xLeft =
     1486                        pSysTrayData->lIconPad + (lIconStep) * i;
     1487                    pCtlData->u.rect.rclIcon.xRight =
     1488                        pCtlData->u.rect.rclIcon.xLeft +
     1489                        pSysTrayData->lIconWidth;
     1490                }
     1491                else
     1492                {
     1493                    pCtlData->u.rect.rclIcon.xLeft =
     1494                        swp.cx - (lIconStep) * (i + 1);
     1495                    pCtlData->u.rect.rclIcon.xRight =
     1496                        pCtlData->u.rect.rclIcon.xLeft +
     1497                        pSysTrayData->lIconWidth;
     1498                }
     1499
     1500                // convert to screen coordinates
     1501                WinMapWindowPoints(pWidget->hwndWidget, HWND_DESKTOP,
     1502                                   (PPOINTL)&pCtlData->u.rect.rclIcon, 2);
    14411503                xrc = XST_OK;
    14421504            }
  • trunk/src/3rdparty/os2/xsystray/xsystray.h

    r282 r285  
    5252    SYSTRAYCMD_SHOWBALLOON,
    5353    SYSTRAYCMD_HIDEBALLOON,
     54    SYSTRAYCMD_QUERYRECT,
    5455} SYSTRAYCMD;
    5556
     
    7677    HWND        hwndSender;
    7778                // sender window, a must for SYSTRAYCMD_ADDICON, _CHANGEICON,
    78                 // _REMOVEICON, _SETTOOLTIP, _SHOWBALLOON, _HIDEBALLOON
     79                // _REMOVEICON, _SETTOOLTIP, _SHOWBALLOON, _HIDEBALLOON,
     80                // _QUERYRECT
    7981    union
    8082    {
     
    9597        } icon;
    9698          // used by SYSTRAYCMD_ADDICON, _CHANGEICON, _REMOVEICON, _SETTOOLTIP
     99
     100        struct
     101        {
     102            RECTL rclIcon;
     103        } rect;
     104          // used by SYSTRAYCMD_QUERYRECT
    97105    } u;
    98106
  • trunk/src/3rdparty/os2/xsystray/xsystray_api.c

    r282 r285  
    569569    pData->u.icon.usId = usId;
    570570
    571 
    572571    if (!pcszToolTip)
    573572        pData->u.icon.szToolTip[0] = '\0';
     
    610609BOOL xstQuerySysTrayIconRect(HWND hwnd, USHORT usId, PRECTL prclRect)
    611610{
    612     // @todo implement
    613     return FALSE;
     611    BOOL brc;
     612    PSYSTRAYCTLDATA pData = AllocSysTrayCtlDataPtr();
     613    if (!pData)
     614        return FALSE;
     615
     616    pData->ulCommand = SYSTRAYCMD_QUERYRECT;
     617    pData->hwndSender = hwnd;
     618    pData->u.icon.usId = usId;
     619
     620    brc = SendSysTrayCtlMsg(pData) == XST_OK;
     621    if (brc)
     622    {
     623        *prclRect = pData->u.rect.rclIcon;
     624    }
     625
     626    FreeSysTrayCtlDataPtr(pData);
     627
     628    return brc;
    614629}
    615630
Note: See TracChangeset for help on using the changeset viewer.