From 9f7f85fa5dba59951a6d24e4721875a4bc2db18c Mon Sep 17 00:00:00 2001 From: Berke Viktor Date: Sun, 3 Jun 2012 14:22:51 +0200 Subject: Also check for executable name when restoring from tray via shortcut --- src/common/xchat.c | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) (limited to 'src') diff --git a/src/common/xchat.c b/src/common/xchat.c index 0cfd422e..845f262b 100644 --- a/src/common/xchat.c +++ b/src/common/xchat.c @@ -914,24 +914,31 @@ xchat_restore_window (HWND xchat_window) BOOL CALLBACK enum_windows_impl (HWND current_window, LPARAM lParam) { - TCHAR buffer[10]; - ZeroMemory (&buffer, sizeof (buffer)); + TCHAR window_name[10]; + TCHAR module_path[1024]; + ZeroMemory (&window_name, sizeof (window_name)); if (!current_window) { return TRUE; } - GetWindowText (current_window, buffer, 10); - if (stricmp (buffer, "xchat-wdk") == 0) /* We've found it, stop */ + GetWindowText (current_window, window_name, 10); + if (stricmp (window_name, "xchat-wdk") == 0) { - xchat_restore_window (current_window); - return FALSE; - } - else /* Keep searching */ - { - return TRUE; + /* use a separate if block, this way we don't have to call GetWindowModuleFileName() for each hit */ + ZeroMemory (&module_path, sizeof (module_path)); + GetWindowModuleFileName (current_window, module_path, sizeof (module_path)); + + if (strstr (module_path, "xchat.exe")) /* We've found it, stop */ + { + xchat_restore_window (current_window); + return FALSE; + } } + + return TRUE; /* Keep searching */ + } #endif -- cgit 1.4.1