source: trunk/src/3rdparty/os2/xsystray/xsystray.h@ 282

Last change on this file since 282 was 282, checked in by Dmitry A. Kuminov, 16 years ago

3rdparty: os2/xsystray: Added new xstReplaceSysTrayIcon() API call, implemented xstSetSysTrayIconToolTip() API call.

  • Property svn:eol-style set to native
  • Property svn:executable set to *
  • Property svn:keywords set to Date Revision Author Id
File size: 6.6 KB
Line 
1
2/*
3 *@@sourcefile xsystray.h:
4 * Extended system tray widget for XCenter/eCenter.
5 *
6 * Private declarations.
7 *
8 * Copyright (C) 2009 Dmitry A. Kuminov
9 *
10 * This file is part of the Extended system tray widget source package.
11 * Extended system tray widget is free software; you can redistribute it
12 * and/or modify it under the terms of the GNU General Public License as
13 * published by the Free Software Foundation, in version 2 as it comes in
14 * the "COPYING" file of the Extended system tray widget distribution. This
15 * program is distributed in the hope that it will be useful, but WITHOUT
16 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
17 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
18 * more details.
19 */
20
21#ifndef XSYSTRAY_HEADER_INCLUDED
22#define XSYSTRAY_HEADER_INCLUDED
23
24#include "xsystray_api.h"
25
26#include <sys/builtin.h> // atomics
27
28#define XSYSTRAY_VERSION_MAJOR 0
29#define XSYSTRAY_VERSION_MINOR 1
30#define XSYSTRAY_VERSION_REVISION 0
31
32#define WNDCLASS_WIDGET_XSYSTRAY_SERVER "XWPCenterExtendedSysTrayServer"
33
34#define WNDCLASS_WIDGET_XSYSTRAY "XWPCenterExtendedSysTray"
35#define INTCLASS_WIDGET_XSYSTRAY "ExtendedSysTray"
36#define HUMANSTR_WIDGET_XSYSTRAY "Extended system tray"
37
38#define WM_XST_CREATED_ATOM "ExtendedSysTray.WM_XST_CREATED"
39#define WM_XST_NOTIFY_ATOM "ExtendedSysTray.WM_XST_NOTIFY"
40
41#define WM_XST_CONTROL (WM_USER + 0)
42 // message sent to the system tray server to request an action
43
44// server action commands
45typedef enum
46{
47 SYSTRAYCMD_GETVERSION,
48 SYSTRAYCMD_ADDICON,
49 SYSTRAYCMD_REPLACEICON,
50 SYSTRAYCMD_REMOVEICON,
51 SYSTRAYCMD_SETTOOLTIP,
52 SYSTRAYCMD_SHOWBALLOON,
53 SYSTRAYCMD_HIDEBALLOON,
54} SYSTRAYCMD;
55
56// server responses to WM_XST_CONTROL
57#define XST_OK 0 // command succeeded
58#define XST_FAIL 1 // command failed
59#define XST_REPLACED 2 // SYSTRAYCMD_ADDICON replaced the existing icon
60
61/*
62 *@@ SYSTRAYCTLDATA:
63 * Structure holding information accompanying WM_XST_CONTROL messages sent
64 * to the system tray server by clients (windows associated with system
65 * tray icons).
66 *
67 * NOTE: When you change the size of this structure, you may also need to
68 * change CLIENT_MEMORYPOOL_SIZE value (see the comments there for
69 * details).
70 */
71
72typedef struct
73{
74 SYSTRAYCMD ulCommand;
75 // command to execute, must always be set
76 HWND hwndSender;
77 // sender window, a must for SYSTRAYCMD_ADDICON, _CHANGEICON,
78 // _REMOVEICON, _SETTOOLTIP, _SHOWBALLOON, _HIDEBALLOON
79 union
80 {
81 struct
82 {
83 ULONG ulMajor;
84 ULONG ulMinor;
85 ULONG ulRevision;
86 } version;
87 // used by SYSTRAYCMD_GETVERSION
88
89 struct
90 {
91 USHORT usId;
92 HPOINTER hIcon;
93 CHAR szToolTip[512];
94 ULONG ulMsgId;
95 } icon;
96 // used by SYSTRAYCMD_ADDICON, _CHANGEICON, _REMOVEICON, _SETTOOLTIP
97 } u;
98
99 BOOL bAcknowledged : 1;
100 // set to true by the recipient if it processes the message
101
102} SYSTRAYCTLDATA, *PSYSTRAYCTLDATA;
103
104/*
105 *@@ NOTIFYDATA:
106 * Structure holding information acompanying notification messages
107 * posted to clients (windows associated with system tray icons) about
108 * icon events. This structure unions all public notification code
109 * dependent structures defined in xsystray_api.h (starting with XST*).
110 *
111 * All messages posted to the client have an ID corresponding to the
112 * WM_XST_NOTIFY_ATOM in the system atom table. The client-side API
113 * implementation intercepts these messages (using HK_INPUT), composes a
114 * new message given the information in NOTIFYDATA, frees the NOTIFYDATA
115 * pointer using FreeNotifyDataPtr() and then sends the composed message to
116 * the appropriate window.
117 *
118 * The layout of the XST_NOTIFY message is as follows:
119 *
120 * param1
121 * PNOTIFYDATA pNotifyData pointer to the NOTIFYDATA structure
122 *
123 * param2
124 * PVOID pvMemoryPool server memory pool (for the
125 * FreeNotifyDataPtr() call)
126 *
127 * NOTE: Structures in the union should only contain values; passing
128 * pointers to arbitrary data to the client side is not supported (yet).
129 *
130 * NOTE: When you change the size of this structure, you may also need to
131 * change SERVER_MEMORYPOOL_SIZE value in xsystray.c (see the comments
132 * there for details).
133 */
134
135typedef struct
136{
137 ULONG msg;
138 // ID of the message that is to be sent to the target window
139 MPARAM mp1;
140 // message parameter (usually: USHORT usIconId, USHORT usNotifyCode)
141 MPARAM mp2;
142 // message parameter (usually, a pointer to a struct from the union)
143 union
144 {
145 XSTMOUSEMSG MouseMsg;
146 XSTCONTEXTMSG ContextMsg;
147 XSTWHEELMSG WheelMsg;
148 } u;
149
150} NOTIFYDATA, *PNOTIFYDATA;
151
152// Header of the server-side memory pool
153typedef struct
154{
155 volatile HWND hwnd; // owner of the block or NULLHANDLE if free
156 NOTIFYDATA NotifyData; // data
157
158} MEMPOOLBLK, *PMEMPOOLBLK;
159
160// allocation unit in the server-side memory pool
161typedef struct
162{
163 ULONG ulBeyond; // address of the first byte beyond the memory pool
164
165 volatile ULONG ulNeedsCommit; // address of the first decommitted byte
166 volatile ULONG ulNext; // address of next possibly free block
167
168 MEMPOOLBLK aBlocks[0]; // fake array for easier addressing
169
170} MEMPOOLHDR, *PMEMPOOLHDR;
171
172/*
173 *@@ FreeNotifyDataPtr:
174 * Frees the NOTIFYDATA structure allocated by AllocNotifyDataPtr().
175 *
176 * See AllocNotifyDataPtr() for more details about allocating these
177 * structures.dd
178 */
179
180inline
181VOID FreeNotifyDataPtr(PVOID pvMemoryPool, // in: memory pool base address
182 HWND hwndOwner, // in: owner of the struct to free
183 PNOTIFYDATA pData) // in: address of the struct to free
184{
185 PMEMPOOLHDR pHdr = (PMEMPOOLHDR)pvMemoryPool;
186 PMEMPOOLBLK pBlk = (PMEMPOOLBLK)((ULONG)pData - sizeof(HWND));
187
188 ULONG ulNext = pHdr->ulNext;
189
190 __atomic_cmpxchg32((uint32_t *)&pBlk->hwnd, NULLHANDLE, hwndOwner);
191
192 // if the next possible free block is greater than we just freed,
193 // set it to us (to minimize the amount of committed pages)
194 if (ulNext > (ULONG)pBlk)
195 __atomic_cmpxchg32((uint32_t *)&pHdr->ulNext, (ULONG)pBlk, ulNext);
196}
197
198#endif // XSYSTRAY_HEADER_INCLUDED
199
200
Note: See TracBrowser for help on using the repository browser.