systray: Properly track errors.
This commit is contained in:
parent
7df3ed5f44
commit
b391b8af58
|
@ -104,6 +104,7 @@ BOOL WINAPI Shell_NotifyIconW(DWORD dwMessage, PNOTIFYICONDATAW nid)
|
||||||
HWND tray;
|
HWND tray;
|
||||||
COPYDATASTRUCT cds;
|
COPYDATASTRUCT cds;
|
||||||
char *buffer = NULL;
|
char *buffer = NULL;
|
||||||
|
BOOL ret;
|
||||||
|
|
||||||
TRACE("dwMessage = %d, nid->cbSize=%d\n", dwMessage, nid->cbSize);
|
TRACE("dwMessage = %d, nid->cbSize=%d\n", dwMessage, nid->cbSize);
|
||||||
|
|
||||||
|
@ -185,11 +186,11 @@ noicon:
|
||||||
cds.lpData = nid;
|
cds.lpData = nid;
|
||||||
}
|
}
|
||||||
|
|
||||||
SendMessageW(tray, WM_COPYDATA, (WPARAM)nid->hWnd, (LPARAM)&cds);
|
ret = SendMessageW(tray, WM_COPYDATA, (WPARAM)nid->hWnd, (LPARAM)&cds);
|
||||||
|
|
||||||
/* FIXME: if statement only needed because we don't support interprocess
|
/* FIXME: if statement only needed because we don't support interprocess
|
||||||
* icon handles */
|
* icon handles */
|
||||||
HeapFree(GetProcessHeap(), 0, buffer);
|
HeapFree(GetProcessHeap(), 0, buffer);
|
||||||
|
|
||||||
return TRUE;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
|
@ -52,8 +52,7 @@ void test_cbsize(void)
|
||||||
ok(pShell_NotifyIconW(NIM_DELETE, &nidW), "NIM_DELETE failed!\n");
|
ok(pShell_NotifyIconW(NIM_DELETE, &nidW), "NIM_DELETE failed!\n");
|
||||||
/* as icon doesn't exist anymore - now there will be an error */
|
/* as icon doesn't exist anymore - now there will be an error */
|
||||||
nidW.cbSize = sizeof(nidW);
|
nidW.cbSize = sizeof(nidW);
|
||||||
/* wine currently doesn't return error code put prints an ERR(...) */
|
ok(!pShell_NotifyIconW(NIM_DELETE, &nidW), "The icon was not deleted\n");
|
||||||
todo_wine ok(!pShell_NotifyIconW(NIM_DELETE, &nidW), "The icon was not deleted\n");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* same for Shell_NotifyIconA */
|
/* same for Shell_NotifyIconA */
|
||||||
|
@ -73,8 +72,7 @@ void test_cbsize(void)
|
||||||
ok(Shell_NotifyIconA(NIM_DELETE, &nidA), "NIM_DELETE failed!\n");
|
ok(Shell_NotifyIconA(NIM_DELETE, &nidA), "NIM_DELETE failed!\n");
|
||||||
/* as icon doesn't exist anymore - now there will be an error */
|
/* as icon doesn't exist anymore - now there will be an error */
|
||||||
nidA.cbSize = sizeof(nidA);
|
nidA.cbSize = sizeof(nidA);
|
||||||
/* wine currently doesn't return error code put prints an ERR(...) */
|
ok(!Shell_NotifyIconA(NIM_DELETE, &nidA), "The icon was not deleted\n");
|
||||||
todo_wine ok(!Shell_NotifyIconA(NIM_DELETE, &nidA), "The icon was not deleted\n");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
START_TEST(systray)
|
START_TEST(systray)
|
||||||
|
|
|
@ -182,7 +182,7 @@ static void set_tooltip(struct icon *icon, WCHAR *szTip, BOOL modify)
|
||||||
SendMessageW(icon->tooltip, TTM_ADDTOOLW, 0, (LPARAM)&ti);
|
SendMessageW(icon->tooltip, TTM_ADDTOOLW, 0, (LPARAM)&ti);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void modify_icon(NOTIFYICONDATAW *nid, BOOL modify_tooltip)
|
static BOOL modify_icon(NOTIFYICONDATAW *nid, BOOL modify_tooltip)
|
||||||
{
|
{
|
||||||
struct icon *icon;
|
struct icon *icon;
|
||||||
|
|
||||||
|
@ -193,7 +193,7 @@ static void modify_icon(NOTIFYICONDATAW *nid, BOOL modify_tooltip)
|
||||||
if (!icon)
|
if (!icon)
|
||||||
{
|
{
|
||||||
WINE_WARN("Invalid icon ID (0x%x) for HWND %p\n", nid->uID, nid->hWnd);
|
WINE_WARN("Invalid icon ID (0x%x) for HWND %p\n", nid->uID, nid->hWnd);
|
||||||
return;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (nid->uFlags & NIF_ICON)
|
if (nid->uFlags & NIF_ICON)
|
||||||
|
@ -216,9 +216,10 @@ static void modify_icon(NOTIFYICONDATAW *nid, BOOL modify_tooltip)
|
||||||
{
|
{
|
||||||
WINE_FIXME("balloon tip title %s, message %s\n", wine_dbgstr_w(nid->szInfoTitle), wine_dbgstr_w(nid->szInfo));
|
WINE_FIXME("balloon tip title %s, message %s\n", wine_dbgstr_w(nid->szInfoTitle), wine_dbgstr_w(nid->szInfo));
|
||||||
}
|
}
|
||||||
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void add_icon(NOTIFYICONDATAW *nid)
|
static BOOL add_icon(NOTIFYICONDATAW *nid)
|
||||||
{
|
{
|
||||||
HMODULE x11drv = GetModuleHandleA( "winex11.drv" );
|
HMODULE x11drv = GetModuleHandleA( "winex11.drv" );
|
||||||
RECT rect;
|
RECT rect;
|
||||||
|
@ -231,13 +232,13 @@ static void add_icon(NOTIFYICONDATAW *nid)
|
||||||
if ((icon = get_icon(nid->hWnd, nid->uID)))
|
if ((icon = get_icon(nid->hWnd, nid->uID)))
|
||||||
{
|
{
|
||||||
WINE_WARN("duplicate tray icon add, buggy app?\n");
|
WINE_WARN("duplicate tray icon add, buggy app?\n");
|
||||||
return;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(icon = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*icon))))
|
if (!(icon = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*icon))))
|
||||||
{
|
{
|
||||||
WINE_ERR("out of memory\n");
|
WINE_ERR("out of memory\n");
|
||||||
return;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
icon->id = nid->uID;
|
icon->id = nid->uID;
|
||||||
|
@ -289,10 +290,10 @@ static void add_icon(NOTIFYICONDATAW *nid)
|
||||||
|
|
||||||
list_add_tail(&tray.icons, &icon->entry);
|
list_add_tail(&tray.icons, &icon->entry);
|
||||||
|
|
||||||
modify_icon(nid, FALSE);
|
return modify_icon(nid, FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void delete_icon(const NOTIFYICONDATAW *nid)
|
static BOOL delete_icon(const NOTIFYICONDATAW *nid)
|
||||||
{
|
{
|
||||||
struct icon *icon = get_icon(nid->hWnd, nid->uID);
|
struct icon *icon = get_icon(nid->hWnd, nid->uID);
|
||||||
|
|
||||||
|
@ -300,22 +301,24 @@ static void delete_icon(const NOTIFYICONDATAW *nid)
|
||||||
|
|
||||||
if (!icon)
|
if (!icon)
|
||||||
{
|
{
|
||||||
WINE_ERR("invalid tray icon ID specified: %u\n", nid->uID);
|
WINE_WARN("invalid tray icon ID specified: %u\n", nid->uID);
|
||||||
return;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
DestroyWindow(icon->tooltip);
|
DestroyWindow(icon->tooltip);
|
||||||
DestroyWindow(icon->window);
|
DestroyWindow(icon->window);
|
||||||
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void handle_incoming(HWND hwndSource, COPYDATASTRUCT *cds)
|
static BOOL handle_incoming(HWND hwndSource, COPYDATASTRUCT *cds)
|
||||||
{
|
{
|
||||||
NOTIFYICONDATAW nid;
|
NOTIFYICONDATAW nid;
|
||||||
DWORD cbSize;
|
DWORD cbSize;
|
||||||
|
BOOL ret = FALSE;
|
||||||
|
|
||||||
if (cds->cbData < NOTIFYICONDATAW_V1_SIZE) return;
|
if (cds->cbData < NOTIFYICONDATAW_V1_SIZE) return FALSE;
|
||||||
cbSize = ((PNOTIFYICONDATA)cds->lpData)->cbSize;
|
cbSize = ((PNOTIFYICONDATA)cds->lpData)->cbSize;
|
||||||
if (cbSize < NOTIFYICONDATAW_V1_SIZE) return;
|
if (cbSize < NOTIFYICONDATAW_V1_SIZE) return FALSE;
|
||||||
|
|
||||||
ZeroMemory(&nid, sizeof(nid));
|
ZeroMemory(&nid, sizeof(nid));
|
||||||
memcpy(&nid, cds->lpData, min(sizeof(nid), cbSize));
|
memcpy(&nid, cds->lpData, min(sizeof(nid), cbSize));
|
||||||
|
@ -343,14 +346,14 @@ static void handle_incoming(HWND hwndSource, COPYDATASTRUCT *cds)
|
||||||
if (cds->cbData < nid.cbSize + 2 * sizeof(BITMAP) + cbMaskBits + cbColourBits)
|
if (cds->cbData < nid.cbSize + 2 * sizeof(BITMAP) + cbMaskBits + cbColourBits)
|
||||||
{
|
{
|
||||||
WINE_ERR("buffer underflow\n");
|
WINE_ERR("buffer underflow\n");
|
||||||
return;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* sanity check */
|
/* sanity check */
|
||||||
if ((bmColour.bmWidth != bmMask.bmWidth) || (bmColour.bmHeight != bmMask.bmHeight))
|
if ((bmColour.bmWidth != bmMask.bmWidth) || (bmColour.bmHeight != bmMask.bmHeight))
|
||||||
{
|
{
|
||||||
WINE_ERR("colour and mask bitmaps aren't consistent\n");
|
WINE_ERR("colour and mask bitmaps aren't consistent\n");
|
||||||
return;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
nid.hIcon = CreateIcon(NULL, bmColour.bmWidth, bmColour.bmHeight,
|
nid.hIcon = CreateIcon(NULL, bmColour.bmWidth, bmColour.bmHeight,
|
||||||
|
@ -361,13 +364,13 @@ static void handle_incoming(HWND hwndSource, COPYDATASTRUCT *cds)
|
||||||
switch (cds->dwData)
|
switch (cds->dwData)
|
||||||
{
|
{
|
||||||
case NIM_ADD:
|
case NIM_ADD:
|
||||||
add_icon(&nid);
|
ret = add_icon(&nid);
|
||||||
break;
|
break;
|
||||||
case NIM_DELETE:
|
case NIM_DELETE:
|
||||||
delete_icon(&nid);
|
ret = delete_icon(&nid);
|
||||||
break;
|
break;
|
||||||
case NIM_MODIFY:
|
case NIM_MODIFY:
|
||||||
modify_icon(&nid, TRUE);
|
ret = modify_icon(&nid, TRUE);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
WINE_FIXME("unhandled tray message: %ld\n", cds->dwData);
|
WINE_FIXME("unhandled tray message: %ld\n", cds->dwData);
|
||||||
|
@ -378,13 +381,15 @@ static void handle_incoming(HWND hwndSource, COPYDATASTRUCT *cds)
|
||||||
* icon handles */
|
* icon handles */
|
||||||
if (nid.uFlags & NIF_ICON)
|
if (nid.uFlags & NIF_ICON)
|
||||||
DestroyIcon(nid.hIcon);
|
DestroyIcon(nid.hIcon);
|
||||||
|
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static LRESULT WINAPI listener_wndproc(HWND window, UINT msg,
|
static LRESULT WINAPI listener_wndproc(HWND window, UINT msg,
|
||||||
WPARAM wparam, LPARAM lparam)
|
WPARAM wparam, LPARAM lparam)
|
||||||
{
|
{
|
||||||
if (msg == WM_COPYDATA)
|
if (msg == WM_COPYDATA)
|
||||||
handle_incoming((HWND)wparam, (COPYDATASTRUCT *)lparam);
|
return handle_incoming((HWND)wparam, (COPYDATASTRUCT *)lparam);
|
||||||
|
|
||||||
return DefWindowProc(window, msg, wparam, lparam);
|
return DefWindowProc(window, msg, wparam, lparam);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue