From 86748a8480d846c500c42e3e6f03e628111d4da6 Mon Sep 17 00:00:00 2001 From: Alexandre Julliard Date: Fri, 27 Mar 2015 17:14:16 +0900 Subject: [PATCH] winex11: Cleanup system tray icons when their owner is destroyed instead of polling. --- dlls/winex11.drv/systray.c | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/dlls/winex11.drv/systray.c b/dlls/winex11.drv/systray.c index a694610a86a..c7e7013b1dd 100644 --- a/dlls/winex11.drv/systray.c +++ b/dlls/winex11.drv/systray.c @@ -85,11 +85,9 @@ Atom systray_atom = 0; #define MIN_DISPLAYED 8 #define ICON_BORDER 2 -#define VALID_WIN_TIMER 1 -#define BALLOON_CREATE_TIMER 2 -#define BALLOON_SHOW_TIMER 3 +#define BALLOON_CREATE_TIMER 1 +#define BALLOON_SHOW_TIMER 2 -#define VALID_WIN_TIMEOUT 2000 #define BALLOON_CREATE_TIMEOUT 2000 #define BALLOON_SHOW_MIN_TIMEOUT 10000 #define BALLOON_SHOW_MAX_TIMEOUT 30000 @@ -453,10 +451,6 @@ static LRESULT WINAPI tray_icon_wndproc(HWND hwnd, UINT msg, WPARAM wparam, LPAR switch (msg) { - case WM_CREATE: - SetTimer( hwnd, VALID_WIN_TIMER, VALID_WIN_TIMEOUT, NULL ); - break; - case WM_SIZE: if (icon->window && icon->layered) repaint_tray_icon( icon ); break; @@ -507,9 +501,6 @@ static LRESULT WINAPI tray_icon_wndproc(HWND hwnd, UINT msg, WPARAM wparam, LPAR case WM_TIMER: switch (wparam) { - case VALID_WIN_TIMER: - if (!IsWindow( icon->owner )) delete_icon( icon ); - break; case BALLOON_CREATE_TIMER: balloon_create_timer( icon ); break; @@ -811,6 +802,15 @@ static BOOL delete_icon( struct tray_icon *icon ) return TRUE; } +/* cleanup all icons for a given window */ +static void cleanup_icons( HWND owner ) +{ + struct tray_icon *this, *next; + + LIST_FOR_EACH_ENTRY_SAFE( this, next, &icon_list, struct tray_icon, entry ) + if (this->owner == owner) delete_icon( this ); +} + /*********************************************************************** * wine_notify_icon (X11DRV.@) @@ -834,6 +834,9 @@ int CDECL wine_notify_icon( DWORD msg, NOTIFYICONDATAW *data ) case NIM_MODIFY: if ((icon = get_icon( data->hWnd, data->uID ))) ret = modify_icon( icon, data ); break; + case 0xdead: /* Wine extension: owner window has died */ + cleanup_icons( data->hWnd ); + break; default: FIXME( "unhandled tray message: %u\n", msg ); break; -- 2.11.4.GIT