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.h

    r272 r273  
    1717#define XSYSTRAY_HEADER_INCLUDED
    1818
     19#include "xsystray_api.h"
     20
     21#include <sys/builtin.h>        // atomics
     22
    1923#define XSYSTRAY_VERSION_MAJOR 0
    2024#define XSYSTRAY_VERSION_MINOR 1
     
    2630#define INTCLASS_WIDGET_XSYSTRAY        "ExtendedSysTray"
    2731#define HUMANSTR_WIDGET_XSYSTRAY        "Extended system tray"
     32
     33#define WM_XST_CREATED_ATOM             "ExtendedSysTray.WM_XST_CREATED"
     34#define WM_XST_NOTIFY_ATOM              "ExtendedSysTray.WM_XST_NOTIFY"
    2835
    2936#define WM_XST_CONTROL  (WM_USER + 0)
     
    3845    SYSTRAYCMD_HIDEBALLOON,
    3946} SYSTRAYCMD;
     47
     48/*
     49 *@@ SYSTRAYCTLDATA:
     50 *      Structure holding information accompanying WM_XST_CONTROL messages sent
     51 *      to the system tray server by clients (windows associated with system
     52 *      tray icons).
     53 *
     54 *      NOTE: When you change the size of this structure, you may also need to
     55 *      change CLIENT_MEMORYPOOL_SIZE value (see the comments there for
     56 *      details).
     57 */
    4058
    4159typedef struct
     
    5876        struct
    5977        {
    60             ULONG       ulId;
     78            USHORT      usId;
    6179            HPOINTER    hIcon;
    6280            ULONG       ulMsgId;
     
    6684        struct
    6785        {
    68             ULONG   ulId;
     86            USHORT  usId;
    6987            CHAR    szText[512];
    7088        } tooltip;
     
    7795} SYSTRAYCTLDATA, *PSYSTRAYCTLDATA;
    7896
     97/*
     98 *@@ NOTIFYDATA:
     99 *      Structure holding information acompanying notification messages
     100 *      posted to clients (windows associated with system tray icons) about
     101 *      icon events. This structure unions all public notification code
     102 *      dependent structures defined in xsystray_api.h (starting with XST*).
     103 *
     104 *      All messages posted to the client have an ID corresponding to the
     105 *      WM_XST_NOTIFY_ATOM in the system atom table. The client-side API
     106 *      implementation intercepts these messages (using HK_INPUT), composes a
     107 *      new message given the information in NOTIFYDATA, frees the NOTIFYDATA
     108 *      pointer using FreeNotifyDataPtr() and then sends the composed message to
     109 *      the appropriate window.
     110 *
     111 *      The layout of the XST_NOTIFY message is as follows:
     112 *
     113 *          param1
     114 *              PNOTIFYDATA pNotifyData     pointer to the NOTIFYDATA structure
     115 *
     116 *          param2
     117 *              PVOID       pvMemoryPool    server memory pool (for the
     118 *                                          FreeNotifyDataPtr() call)
     119 *
     120 *      NOTE: When you change the size of this structure, you may also need to
     121 *      change SERVER_MEMORYPOOL_SIZE value in xsystray.c (see the comments
     122 *      there for details).
     123 */
     124
     125typedef struct
     126{
     127    ULONG   msg;
     128            // ID of the message that is to be sent to the target window
     129    MPARAM  mp1;
     130            // message parameter (usually: USHORT usIconId, USHORT usNotifyCode)
     131    MPARAM  mp2;
     132            // message parameter (usually, a pointer to a struct from the union)
     133    union
     134    {
     135        XSTMOUSEMSG     MouseMsg;
     136        XSTCONTEXTMSG   ContextMsg;
     137        XSTWHEELMSG     WheelMsg;
     138    } u;
     139
     140} NOTIFYDATA, *PNOTIFYDATA;
     141
     142// Header of the server-side memory pool
     143typedef struct
     144{
     145    volatile HWND   hwnd;        // owner of the block or NULLHANDLE if free
     146    NOTIFYDATA      NotifyData;  // data
     147
     148} MEMPOOLBLK, *PMEMPOOLBLK;
     149
     150// allocation unit in the server-side memory pool
     151typedef struct
     152{
     153    ULONG ulBeyond;         // address of the first byte beyond the memory pool
     154
     155    volatile ULONG ulNeedsCommit;   // address of the first decommitted byte
     156    volatile ULONG ulNext;          // address of next possibly free block
     157
     158    MEMPOOLBLK aBlocks[0];          // fake array for easier addressing
     159
     160} MEMPOOLHDR, *PMEMPOOLHDR;
     161
     162/*
     163 *@@ FreeNotifyDataPtr:
     164 *      Frees the NOTIFYDATA structure allocated by AllocNotifyDataPtr().
     165 *
     166 *      See AllocNotifyDataPtr() for more details about allocating these
     167 *      structures.dd
     168 */
     169
     170inline
     171VOID FreeNotifyDataPtr(PVOID pvMemoryPool,  // in: memory pool base address
     172                       HWND hwndOwner,      // in: owner of the struct to free
     173                       PNOTIFYDATA pData)   // in: address of the struct to free
     174{
     175    PMEMPOOLHDR pHdr = (PMEMPOOLHDR)pvMemoryPool;
     176    PMEMPOOLBLK pBlk = (PMEMPOOLBLK)((ULONG)pData - sizeof(HWND));
     177
     178    ULONG ulNext = pHdr->ulNext;
     179
     180    __atomic_cmpxchg32((uint32_t *)&pBlk->hwnd, NULLHANDLE, hwndOwner);
     181
     182    // if the next possible free block is greater than we just freed,
     183    // set it to us (to minimize the amount of committed pages)
     184    if (ulNext > (ULONG)pBlk)
     185        __atomic_cmpxchg32((uint32_t *)&pHdr->ulNext, (ULONG)pBlk, ulNext);
     186}
     187
    79188#endif // XSYSTRAY_HEADER_INCLUDED
    80189
Note: See TracChangeset for help on using the changeset viewer.