Alexandre Julliard : explorer: Cleanup system tray icons when their owner is destroyed instead of polling.
Alexandre Julliard
julliard at wine.codeweavers.com
Fri Mar 27 08:55:17 CDT 2015
Module: wine
Branch: master
Commit: aceec41e932d92cfe5eeb6be0ee0dfabede645fc
URL: http://source.winehq.org/git/wine.git/?a=commit;h=aceec41e932d92cfe5eeb6be0ee0dfabede645fc
Author: Alexandre Julliard <julliard at winehq.org>
Date: Fri Mar 27 17:13:32 2015 +0900
explorer: Cleanup system tray icons when their owner is destroyed instead of polling.
---
programs/explorer/desktop.c | 4 ++++
programs/explorer/explorer_private.h | 11 ++++++-----
programs/explorer/systray.c | 21 +++++++++++----------
3 files changed, 21 insertions(+), 15 deletions(-)
diff --git a/programs/explorer/desktop.c b/programs/explorer/desktop.c
index 474e93e..29ef8d7 100644
--- a/programs/explorer/desktop.c
+++ b/programs/explorer/desktop.c
@@ -529,6 +529,10 @@ static LRESULT WINAPI desktop_wnd_proc( HWND hwnd, UINT message, WPARAM wp, LPAR
SystemParametersInfoW( SPI_SETDESKWALLPAPER, 0, NULL, FALSE );
return 0;
+ case WM_PARENTNOTIFY:
+ if (LOWORD(wp) == WM_DESTROY) cleanup_systray_window( (HWND)lp );
+ return 0;
+
case WM_LBUTTONDBLCLK:
if (!using_root)
{
diff --git a/programs/explorer/explorer_private.h b/programs/explorer/explorer_private.h
index 49400cd..dbe50be 100644
--- a/programs/explorer/explorer_private.h
+++ b/programs/explorer/explorer_private.h
@@ -21,10 +21,11 @@
#ifndef __WINE_EXPLORER_PRIVATE_H
#define __WINE_EXPLORER_PRIVATE_H
-extern void manage_desktop( WCHAR *arg );
-extern void initialize_systray( HMODULE graphics_driver, BOOL using_root, BOOL enable_shell );
-extern void initialize_appbar(void);
-extern void do_startmenu( HWND owner );
-extern LRESULT menu_wndproc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam);
+extern void manage_desktop( WCHAR *arg ) DECLSPEC_HIDDEN;
+extern void initialize_systray( HMODULE graphics_driver, BOOL using_root, BOOL enable_shell ) DECLSPEC_HIDDEN;
+extern void initialize_appbar(void) DECLSPEC_HIDDEN;
+extern void cleanup_systray_window( HWND hwnd ) DECLSPEC_HIDDEN;
+extern void do_startmenu( HWND owner ) DECLSPEC_HIDDEN;
+extern LRESULT menu_wndproc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) DECLSPEC_HIDDEN;
#endif /* __WINE_EXPLORER_PRIVATE_H */
diff --git a/programs/explorer/systray.c b/programs/explorer/systray.c
index 2a6ff14..beb0a88 100644
--- a/programs/explorer/systray.c
+++ b/programs/explorer/systray.c
@@ -97,11 +97,9 @@ static HWND start_button;
#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
@@ -430,7 +428,6 @@ static BOOL add_icon(NOTIFYICONDATAW *nid)
icon->owner = nid->hWnd;
icon->display = -1;
- if (list_empty( &icon_list )) SetTimer( tray_window, VALID_WIN_TIMER, VALID_WIN_TIMEOUT, NULL );
list_add_tail(&icon_list, &icon->entry);
return modify_icon( icon, nid );
@@ -443,17 +440,22 @@ static BOOL delete_icon(struct icon *icon)
list_remove(&icon->entry);
DestroyIcon(icon->image);
HeapFree(GetProcessHeap(), 0, icon);
- if (list_empty( &icon_list )) KillTimer( tray_window, VALID_WIN_TIMER );
return TRUE;
}
-/* cleanup icons belonging to windows that have been destroyed */
-static void cleanup_destroyed_windows(void)
+/* cleanup icons belonging to a window that has been destroyed */
+void cleanup_systray_window( HWND hwnd )
{
struct icon *icon, *next;
LIST_FOR_EACH_ENTRY_SAFE( icon, next, &icon_list, struct icon, entry )
- if (!IsWindow( icon->owner )) delete_icon( icon );
+ if (icon->owner == hwnd) delete_icon( icon );
+
+ if (wine_notify_icon)
+ {
+ NOTIFYICONDATAW nid = { sizeof(nid), hwnd };
+ wine_notify_icon( 0xdead, &nid );
+ }
}
static BOOL handle_incoming(HWND hwndSource, COPYDATASTRUCT *cds)
@@ -561,7 +563,6 @@ static LRESULT WINAPI tray_wndproc( HWND hwnd, UINT msg, WPARAM wparam, LPARAM l
case WM_TIMER:
switch (wparam)
{
- case VALID_WIN_TIMER: cleanup_destroyed_windows(); break;
case BALLOON_CREATE_TIMER: balloon_create_timer(); break;
case BALLOON_SHOW_TIMER: balloon_timer(); break;
}
More information about the wine-cvs
mailing list