Ignore:
Timestamp:
Nov 2, 2009, 3:10:29 AM (16 years ago)
Author:
Dmitry A. Kuminov
Message:

3rdparty: os2/xsystray: Use custom shared memory pool for structures posted by the server to the client windows. Process mouse/wheel and context menu messages in the icon area and post them to the respective client windows. Use smaller spacing between icons (one pad unit instead of two).

File:
1 edited

Legend:

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

    r272 r273  
    2828#include <sys/builtin.h>        // atomics
    2929
    30 static HWND G_hwndSysTray = NULLHANDLE;
    31             // window handle of the system tray server
    32 
    33 static PVOID G_pvMemoryPool = NULL;
    34              // memory pool for SYSTRAYCTLDATA structs used by WM_XST_CONTROL
    35              // messages. Note that once allocated, this memory is never freed:
    36              // it is intentional since the memory is assumed to be always in
    37              // need and that the system will free it when the application
    38              // terminates
    39 
    40 #define MEMORYPOOL_SIZE 65536
    41         // taking SYSTRAYCTLDATA size into account, this is enough for at least
    42         // 64 threads sending WM_XST_CONTROL simultaneously, which sounds sane
     30static
     31volatile HWND G_hwndSysTray = NULLHANDLE;
     32              // window handle of the system tray server
     33
     34static
     35volatile PVOID G_pvMemoryPool = NULL;
     36               // shared memory pool for SYSTRAYCTLDATA structs used by
     37               // WM_XST_CONTROL messages. Note that once allocated, this memory
     38               // is never freed: it is intentional since the memory is assumed
     39               // to be always in need and that the system will free it when the
     40               // application terminates
     41
     42#define CLIENT_MEMORYPOOL_SIZE 65536
     43        // taking SYSTRAYCTLDATA size into account (<=1024 B), this is enough
     44        // for at least 64 threads sending WM_XST_CONTROL simultaneously, which
     45        // sounds sane
    4346
    4447// @todo to be on the safe side with casting in __atomic_cmpxchg32() we need
     
    116119}
    117120
    118 // This function allocates a SYSTRAYCTLDATA struct in the pool of shared memory.
    119 // If there is no free space in the pool, it returns NULL. The allocated memory
    120 // must be freed by FreeSysTrayCtlDataPtr() when not needed.
     121/*
     122 *@@ AllocSysTrayCtlDataPtr:
     123 *      Allocates a SYSTRAYCTLDATA struct in the pool of shared memory.
     124 *
     125 *      If there is no free space in the pool, it returns NULL. The allocated
     126 *      memory must be freed by FreeSysTrayCtlDataPtr() when not needed.
     127 */
     128
    121129static PSYSTRAYCTLDATA AllocSysTrayCtlDataPtr()
    122130{
     
    128136    {
    129137        // Note: we don't PAG_COMMIT, DosSubAllocMem will do so when needed
    130         arc = DosAllocSharedMem((PVOID)&pvPool, NULL, MEMORYPOOL_SIZE,
     138        arc = DosAllocSharedMem((PVOID)&pvPool, NULL, MEMORYPOOL_SIZE,
    131139                                PAG_READ | PAG_WRITE | OBJ_GIVEABLE);
    132140        if (arc == NO_ERROR)
    133141            arc = DosSubSetMem(pvPool,
    134142                               DOSSUB_INIT | DOSSUB_SPARSE_OBJ,
    135                                MEMORYPOOL_SIZE);
     143                               MEMORYPOOL_SIZE);
    136144        if (!__atomic_cmpxchg32((uint32_t *)&G_pvMemoryPool,
    137145                                (uint32_t)pvPool, (uint32_t)NULL))
     
    149157    }
    150158
    151     arc = DosSubAllocMem(G_pvMemoryPool, (PVOID)&pData, sizeof(SYSTRAYCTLDATA));
     159    arc = DosSubAllocMem(G_pvMemoryPool, (PVOID)&pData, sizeof());
    152160    if (arc != NO_ERROR)
    153161        return NULL;
     
    158166static VOID FreeSysTrayCtlDataPtr(PSYSTRAYCTLDATA pData)
    159167{
    160     DosSubFreeMem(G_pvMemoryPool, pData, sizeof(SYSTRAYCTLDATA));
     168    DosSubFreeMem(G_pvMemoryPool, pData, sizeof());
    161169}
    162170
     
    220228 *
    221229 *          param1
    222  *              USHORT  usID        icon ID
    223  *              USHORT  usCode      notify code, one of XST_IN_ constants
     230 *              USHORT  usID        icon ID
     231 *              USHORT  us    notify code, one of XST_IN_ constants
    224232 *
    225233 *          param2
    226  *              PVOID   pData       notify code specific data (see below)
     234 *              PVOID   pData       notify code specific data (see below)
    227235 *
    228236 *      The following notify codes are currently recognized:
     
    232240 *              messages are recognized. param2 is a pointer to the XSTMOUSEMSG
    233241 *              structure containing full mouse message details.
     242
     243
     244
     245
     246
     247
     248
     249
    234250 */
    235251
    236252BOOL xstAddSysTrayIcon(HWND hwnd,       // in: window handle associated with the icon
    237                        ULONG ulId,      // in: icon ID to add
     253                       U     // in: icon ID to add
    238254                       HPOINTER hIcon,  // in: icon handle
    239255                       ULONG ulMsgId,   // in: message ID for notifications
     
    252268        pData->ulCommand = SYSTRAYCMD_ADDICON;
    253269        pData->hwndSender = hwnd;
    254         pData->u.icon.ulId = ulId;
     270        pData->u.icon.uId;
    255271        pData->u.icon.hIcon = hIcon;
    256272        pData->u.icon.ulMsgId = ulMsgId;
     
    278294
    279295BOOL xstRemoveSysTrayIcon(HWND hwnd,    // in: window handle associated with the icon
    280                           ULONG ulId)   // in: icon ID to remove
     296                          U  // in: icon ID to remove
    281297{
    282298    BOOL brc;
     
    287303    pData->ulCommand = SYSTRAYCMD_REMOVEICON;
    288304    pData->hwndSender = hwnd;
    289     pData->u.icon.ulId = ulId;
     305    pData->u.icon.uId;
    290306
    291307    brc = SendSysTrayCtlMsg(pData);
     
    314330
    315331BOOL xstSetSysTrayIconToolTip(HWND hwnd,    // in: window handle associated with the icon
    316                               ULONG ulId,   // in: icon ID to set the tooltip for
     332                              U  // in: icon ID to set the tooltip for
    317333                              PSZ pszText)  // in: tooltip text
    318334{
     
    324340    pData->ulCommand = SYSTRAYCMD_SETTOOLTIP;
    325341    pData->hwndSender = hwnd;
    326     pData->u.tooltip.ulId = ulId;
     342    pData->u.tooltip.uId;
    327343
    328344    if (pszText == NULL)
     
    343359}
    344360
    345 BOOL xstShowSysTrayIconBalloon(HWND hwnd, ULONG ulId, PSZ pszTitle, PSZ pszText,
     361BOOL xstShowSysTrayIconBalloon(HWND hwnd, UId, PSZ pszTitle, PSZ pszText,
    346362                               ULONG ulFlags, ULONG ulTimeout)
    347363{
     
    350366}
    351367
    352 BOOL xstHideSysTrayIconBalloon(HWND hwnd, ULONG ulId)
     368BOOL xstHideSysTrayIconBalloon(HWND hwnd, UId)
    353369{
    354370    // @todo implement
     
    364380 *      Returns TRUE on success and FALSE otherwise.
    365381 */
    366 BOOL xstQuerySysTrayIconRect(HWND hwnd, ULONG ulId, PRECTL prclRect)
     382BOOL xstQuerySysTrayIconRect(HWND hwnd, UId, PRECTL prclRect)
    367383{
    368384    // @todo implement
     
    384400ULONG xstGetSysTrayCreatedMsgId()
    385401{
    386     // NOTE: keep in sync with fnwpXSysTray()::WM_CREATED
    387 
    388402    static ULONG WM_XST_CREATED = 0;
    389403    if (WM_XST_CREATED == 0)
    390404        WM_XST_CREATED = WinAddAtom(WinQuerySystemAtomTable(),
    391                                     "ExtendedSysTray.WM_XST_CREATED");
     405                                    );
    392406    return WM_XST_CREATED;
    393407}
Note: See TracChangeset for help on using the changeset viewer.