To: vim_dev@googlegroups.com Subject: Patch 8.1.0462 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.1.0462 Problem: When using ConPTY Vim can be a child process. Solution: To find a Vim window use both EnumWindows() and EnumChildWindows(). (Nobuhiro Takasaki, closes #3521) Files: src/os_mswin.c *** ../vim-8.1.0461/src/os_mswin.c 2018-08-07 22:30:26.674240818 +0200 --- src/os_mswin.c 2018-10-07 20:32:20.655313848 +0200 *************** *** 2324,2329 **** --- 2324,2364 ---- return TRUE; } + struct enum_windows_s + { + WNDENUMPROC lpEnumFunc; + LPARAM lParam; + }; + + static BOOL CALLBACK + enum_windows_child(HWND hwnd, LPARAM lParam) + { + struct enum_windows_s *ew = (struct enum_windows_s *)lParam; + + return (ew->lpEnumFunc)(hwnd, ew->lParam); + } + + static BOOL CALLBACK + enum_windows_toplevel(HWND hwnd, LPARAM lParam) + { + struct enum_windows_s *ew = (struct enum_windows_s *)lParam; + + if ((ew->lpEnumFunc)(hwnd, ew->lParam) == FALSE) + return FALSE; + return EnumChildWindows(hwnd, enum_windows_child, lParam); + } + + /* Enumerate all windows including children. */ + static BOOL + enum_windows(WNDENUMPROC lpEnumFunc, LPARAM lParam) + { + struct enum_windows_s ew; + + ew.lpEnumFunc = lpEnumFunc; + ew.lParam = lParam; + return EnumWindows(enum_windows_toplevel, (LPARAM)&ew); + } + static HWND findServer(char_u *name) { *************** *** 2332,2338 **** id.name = name; id.hwnd = 0; ! EnumWindows(enumWindowsGetServer, (LPARAM)(&id)); return id.hwnd; } --- 2367,2373 ---- id.name = name; id.hwnd = 0; ! enum_windows(enumWindowsGetServer, (LPARAM)(&id)); return id.hwnd; } *************** *** 2395,2401 **** ga_init2(&ga, 1, 100); ! EnumWindows(enumWindowsGetNames, (LPARAM)(&ga)); ga_append(&ga, NUL); return ga.ga_data; --- 2430,2436 ---- ga_init2(&ga, 1, 100); ! enum_windows(enumWindowsGetNames, (LPARAM)(&ga)); ga_append(&ga, NUL); return ga.ga_data; *** ../vim-8.1.0461/src/version.c 2018-10-07 20:26:15.834185143 +0200 --- src/version.c 2018-10-07 20:34:15.754398574 +0200 *************** *** 794,795 **** --- 794,797 ---- { /* Add new patch number below this line */ + /**/ + 462, /**/ -- hundred-and-one symptoms of being an internet addict: 170. You introduce your wife as "my_lady@home.wife" and refer to your children as "forked processes." /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\ \\\ an exciting new programming language -- http://www.Zimbu.org /// \\\ help me help AIDS victims -- http://ICCF-Holland.org ///