diff options
author | Bram Moolenaar <Bram@vim.org> | 2018-10-07 20:35:12 +0200 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2018-10-07 20:35:12 +0200 |
commit | c0543e145fdd29739ac887e71ab96c50282066cd (patch) | |
tree | 53d43d714d8b5b55fdf6eb0ac7ee22a493d2e18a /src | |
parent | 00bf8cd2115be7c14258aee48c0a7568147c9cd7 (diff) | |
download | vim-git-c0543e145fdd29739ac887e71ab96c50282066cd.tar.gz |
patch 8.1.0462: when using ConPTY Vim can be a child processv8.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)
Diffstat (limited to 'src')
-rw-r--r-- | src/os_mswin.c | 39 | ||||
-rw-r--r-- | src/version.c | 2 |
2 files changed, 39 insertions, 2 deletions
diff --git a/src/os_mswin.c b/src/os_mswin.c index 2112b0c2a..bd38e9d3f 100644 --- a/src/os_mswin.c +++ b/src/os_mswin.c @@ -2324,6 +2324,41 @@ enumWindowsGetNames(HWND hwnd, LPARAM lparam) 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,7 +2367,7 @@ findServer(char_u *name) id.name = name; id.hwnd = 0; - EnumWindows(enumWindowsGetServer, (LPARAM)(&id)); + enum_windows(enumWindowsGetServer, (LPARAM)(&id)); return id.hwnd; } @@ -2395,7 +2430,7 @@ serverGetVimNames(void) ga_init2(&ga, 1, 100); - EnumWindows(enumWindowsGetNames, (LPARAM)(&ga)); + enum_windows(enumWindowsGetNames, (LPARAM)(&ga)); ga_append(&ga, NUL); return ga.ga_data; diff --git a/src/version.c b/src/version.c index 93cbc3050..103483a94 100644 --- a/src/version.c +++ b/src/version.c @@ -793,6 +793,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 462, +/**/ 461, /**/ 460, |