0
0
mirror of https://github.com/vim/vim.git synced 2025-10-04 05:25:06 -04:00

patch 8.1.0462: when using ConPTY Vim can be a child process

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)
This commit is contained in:
Bram Moolenaar
2018-10-07 20:35:12 +02:00
parent 00bf8cd211
commit c0543e145f
2 changed files with 39 additions and 2 deletions

View File

@@ -2324,6 +2324,41 @@ enumWindowsGetNames(HWND hwnd, LPARAM lparam)
return TRUE; 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 static HWND
findServer(char_u *name) findServer(char_u *name)
{ {
@@ -2332,7 +2367,7 @@ findServer(char_u *name)
id.name = name; id.name = name;
id.hwnd = 0; id.hwnd = 0;
EnumWindows(enumWindowsGetServer, (LPARAM)(&id)); enum_windows(enumWindowsGetServer, (LPARAM)(&id));
return id.hwnd; return id.hwnd;
} }
@@ -2395,7 +2430,7 @@ serverGetVimNames(void)
ga_init2(&ga, 1, 100); ga_init2(&ga, 1, 100);
EnumWindows(enumWindowsGetNames, (LPARAM)(&ga)); enum_windows(enumWindowsGetNames, (LPARAM)(&ga));
ga_append(&ga, NUL); ga_append(&ga, NUL);
return ga.ga_data; return ga.ga_data;

View File

@@ -792,6 +792,8 @@ static char *(features[]) =
static int included_patches[] = static int included_patches[] =
{ /* Add new patch number below this line */ { /* Add new patch number below this line */
/**/
462,
/**/ /**/
461, 461,
/**/ /**/