[255] | 1 | /*
|
---|
| 2 | * Extended system tray widget for XCenter/eCenter
|
---|
| 3 | *
|
---|
| 4 | * Internal declarations
|
---|
| 5 | *
|
---|
| 6 | * Made by netlabs.org
|
---|
| 7 | *
|
---|
| 8 | * Author: Dmitry A. Kuminov
|
---|
| 9 | *
|
---|
| 10 | * This software is public domain.
|
---|
| 11 | *
|
---|
| 12 | * WITHOUT ANY WARRANTY..., AT YOUR OWN RISC... ETC.
|
---|
| 13 | *
|
---|
| 14 | */
|
---|
| 15 |
|
---|
| 16 | #ifndef XSYSTRAY_HEADER_INCLUDED
|
---|
| 17 | #define XSYSTRAY_HEADER_INCLUDED
|
---|
| 18 |
|
---|
[273] | 19 | #include "xsystray_api.h"
|
---|
| 20 |
|
---|
| 21 | #include <sys/builtin.h> // atomics
|
---|
| 22 |
|
---|
[256] | 23 | #define XSYSTRAY_VERSION_MAJOR 0
|
---|
| 24 | #define XSYSTRAY_VERSION_MINOR 1
|
---|
| 25 | #define XSYSTRAY_VERSION_REVISION 0
|
---|
| 26 |
|
---|
[255] | 27 | #define WNDCLASS_WIDGET_XSYSTRAY_SERVER "XWPCenterExtendedSysTrayServer"
|
---|
| 28 |
|
---|
| 29 | #define WNDCLASS_WIDGET_XSYSTRAY "XWPCenterExtendedSysTray"
|
---|
| 30 | #define INTCLASS_WIDGET_XSYSTRAY "ExtendedSysTray"
|
---|
| 31 | #define HUMANSTR_WIDGET_XSYSTRAY "Extended system tray"
|
---|
| 32 |
|
---|
[273] | 33 | #define WM_XST_CREATED_ATOM "ExtendedSysTray.WM_XST_CREATED"
|
---|
| 34 | #define WM_XST_NOTIFY_ATOM "ExtendedSysTray.WM_XST_NOTIFY"
|
---|
| 35 |
|
---|
[255] | 36 | #define WM_XST_CONTROL (WM_USER + 0)
|
---|
| 37 |
|
---|
| 38 | typedef enum
|
---|
| 39 | {
|
---|
| 40 | SYSTRAYCMD_GETVERSION,
|
---|
| 41 | SYSTRAYCMD_ADDICON,
|
---|
| 42 | SYSTRAYCMD_REMOVEICON,
|
---|
| 43 | SYSTRAYCMD_SETTOOLTIP,
|
---|
| 44 | SYSTRAYCMD_SHOWBALLOON,
|
---|
| 45 | SYSTRAYCMD_HIDEBALLOON,
|
---|
| 46 | } SYSTRAYCMD;
|
---|
| 47 |
|
---|
[273] | 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 | */
|
---|
| 58 |
|
---|
[255] | 59 | typedef struct
|
---|
| 60 | {
|
---|
| 61 | SYSTRAYCMD ulCommand;
|
---|
| 62 | // command to execute, must always be set
|
---|
| 63 | HWND hwndSender;
|
---|
| 64 | // sender window, a must for SYSTRAYCMD_ADDICON, REMOVEICON,
|
---|
| 65 | // SETTOOLTIP, SHOWBALLOON, HIDEBALLOON
|
---|
| 66 | union
|
---|
| 67 | {
|
---|
| 68 | struct
|
---|
| 69 | {
|
---|
| 70 | ULONG ulMajor;
|
---|
| 71 | ULONG ulMinor;
|
---|
| 72 | ULONG ulRevision;
|
---|
| 73 | } version;
|
---|
| 74 | // used by SYSTRAYCMD_GETVERSION
|
---|
| 75 |
|
---|
| 76 | struct
|
---|
| 77 | {
|
---|
[273] | 78 | USHORT usId;
|
---|
[255] | 79 | HPOINTER hIcon;
|
---|
| 80 | ULONG ulMsgId;
|
---|
| 81 | } icon;
|
---|
| 82 | // used by SYSTRAYCMD_ADDICON, SYSTRAYCMD_REMOVEICON
|
---|
| 83 |
|
---|
| 84 | struct
|
---|
| 85 | {
|
---|
[273] | 86 | USHORT usId;
|
---|
[272] | 87 | CHAR szText[512];
|
---|
[255] | 88 | } tooltip;
|
---|
| 89 |
|
---|
| 90 | } u;
|
---|
| 91 |
|
---|
| 92 | BOOL bAcknowledged : 1;
|
---|
| 93 | // set to true by the recipient if it processes the message
|
---|
| 94 |
|
---|
[256] | 95 | } SYSTRAYCTLDATA, *PSYSTRAYCTLDATA;
|
---|
[255] | 96 |
|
---|
[273] | 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 |
|
---|
| 125 | typedef 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
|
---|
| 143 | typedef 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
|
---|
| 151 | typedef 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 |
|
---|
| 170 | inline
|
---|
| 171 | VOID 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 |
|
---|
[255] | 188 | #endif // XSYSTRAY_HEADER_INCLUDED
|
---|
| 189 |
|
---|
| 190 |
|
---|