systray in desktop mode
Martin Fuchs
martin-fuchs at gmx.net
Sat Mar 27 07:04:50 CST 2004
Changelog:
SHELL_NotifyIcon() implementation for Wine's desktop mode
Index: systray.c
===================================================================
RCS file: /home/wine/wine/dlls/shell32/systray.c,v
retrieving revision 1.26
diff -r1.26 systray.c
64a65,73
> /* copy data structure for tray notifications */
> typedef struct TrayNotifyCDS_Dummy {
> DWORD cookie;
> DWORD notify_code;
> DWORD nicon_data[1]; /* placeholder for NOTIFYICONDATA structure */
> } TrayNotifyCDS_Dummy;
>
> static BOOL SHELL_NotifyIconAW(DWORD dwMessage, void* pnid, HWND nid_hwnd, int nid_size, BOOL unicode);
>
363c372
< BOOL WINAPI Shell_NotifyIconA(DWORD dwMessage, PNOTIFYICONDATAA pnid )
---
> BOOL WINAPI Shell_NotifyIconA(DWORD dwMessage, PNOTIFYICONDATAA pnid)
365c374,375
< BOOL flag=FALSE;
---
> BOOL flag = FALSE;
>
367,376c377,392
< switch(dwMessage) {
< case NIM_ADD:
< flag = SYSTRAY_Add(pnid);
< break;
< case NIM_MODIFY:
< flag = SYSTRAY_Modify(pnid);
< break;
< case NIM_DELETE:
< flag = SYSTRAY_Delete(pnid);
< break;
---
>
> /* check for desktop mode */
> if (GetWindowThreadProcessId(GetDesktopWindow(), NULL)) {
> flag = SHELL_NotifyIconAW(dwMessage, pnid, pnid->hWnd, pnid->cbSize, FALSE);
> } else {
> switch(dwMessage) {
> case NIM_ADD:
> flag = SYSTRAY_Add(pnid);
> break;
> case NIM_MODIFY:
> flag = SYSTRAY_Modify(pnid);
> break;
> case NIM_DELETE:
> flag = SYSTRAY_Delete(pnid);
> break;
> }
377a394
>
378a396
>
385c403,427
< BOOL WINAPI Shell_NotifyIconW (DWORD dwMessage, PNOTIFYICONDATAW pnid )
---
> BOOL WINAPI Shell_NotifyIconW(DWORD dwMessage, PNOTIFYICONDATAW pnid)
> {
> BOOL ret;
>
> /* check for desktop mode */
> if (GetWindowThreadProcessId(GetDesktopWindow(), NULL)) {
> ret = SHELL_NotifyIconAW(dwMessage, pnid, pnid->hWnd, pnid->cbSize, FALSE);
> } else {
> PNOTIFYICONDATAA p = HeapAlloc(GetProcessHeap(),0,sizeof(NOTIFYICONDATAA));
>
> memcpy(p, pnid, sizeof(NOTIFYICONDATAA));
> WideCharToMultiByte(CP_ACP, 0, pnid->szTip, -1, p->szTip, sizeof(p->szTip), NULL, NULL);
> p->szTip[sizeof(p->szTip)-1] = 0;
>
> ret = Shell_NotifyIconA(dwMessage, p);
>
> HeapFree(GetProcessHeap(),0,p);
> }
>
> return ret;
> }
>
>
> /* The only difference between Shell_NotifyIconA and Shell_NotifyIconW is the call to SendMessageA/W. */
> static BOOL SHELL_NotifyIconAW(DWORD dwMessage, void* pnid, HWND nid_hwnd, int nid_size, BOOL unicode)
387c429,440
< BOOL ret;
---
> HWND hwnd;
> COPYDATASTRUCT data;
> WCHAR wszShellTrayClassName[] = {'S','h','e','l','l','_','T','r','a','y','W','n','d','\0'};
>
> BOOL ret = FALSE;
> int len = sizeof(TrayNotifyCDS_Dummy)-sizeof(DWORD)+nid_size;
>
> TrayNotifyCDS_Dummy* pnotify_data = (TrayNotifyCDS_Dummy*) alloca(len);
>
> pnotify_data->cookie = 1;
> pnotify_data->notify_code = dwMessage;
> memcpy(&pnotify_data->nicon_data, pnid, nid_size);
389,392c442,444
< PNOTIFYICONDATAA p = HeapAlloc(GetProcessHeap(),0,sizeof(NOTIFYICONDATAA));
< memcpy(p, pnid, sizeof(NOTIFYICONDATAA));
< WideCharToMultiByte( CP_ACP, 0, pnid->szTip, -1, p->szTip, sizeof(p->szTip), NULL, NULL );
< p->szTip[sizeof(p->szTip)-1] = 0;
---
> data.dwData = 1;
> data.cbData = len;
> data.lpData = pnotify_data;
394c446,448
< ret = Shell_NotifyIconA(dwMessage, p );
---
> for(hwnd=0; (hwnd=FindWindowExW(0, hwnd, wszShellTrayClassName, NULL)); )
> if ((unicode?SendMessageW:SendMessageA)(hwnd, WM_COPYDATA, (WPARAM)nid_hwnd, (LPARAM)&data))
> ret = TRUE;
396,397c450
< HeapFree(GetProcessHeap(),0,p);
< return ret;
---
> return ret;
More information about the wine-patches
mailing list