diff options
author | Berke Viktor <berkeviktor@aol.com> | 2012-06-03 14:22:51 +0200 |
---|---|---|
committer | Berke Viktor <berkeviktor@aol.com> | 2012-06-03 14:22:51 +0200 |
commit | 9f7f85fa5dba59951a6d24e4721875a4bc2db18c (patch) | |
tree | 83f79658a6f39cbf166e2978250feccb97d29423 /src/common/xchat.c | |
parent | 58ca1966c86650b38fa12ddfe07c2f6bd3f6b131 (diff) |
Also check for executable name when restoring from tray via shortcut
Diffstat (limited to 'src/common/xchat.c')
-rw-r--r-- | src/common/xchat.c | 27 |
1 files changed, 17 insertions, 10 deletions
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 |