Skip to content

Commit c0543e1

Browse files
committed
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)
1 parent 00bf8cd commit c0543e1

2 files changed

Lines changed: 39 additions & 2 deletions

File tree

src/os_mswin.c

Lines changed: 37 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2324,6 +2324,41 @@ enumWindowsGetNames(HWND hwnd, LPARAM lparam)
23242324
return TRUE;
23252325
}
23262326

2327+
struct enum_windows_s
2328+
{
2329+
WNDENUMPROC lpEnumFunc;
2330+
LPARAM lParam;
2331+
};
2332+
2333+
static BOOL CALLBACK
2334+
enum_windows_child(HWND hwnd, LPARAM lParam)
2335+
{
2336+
struct enum_windows_s *ew = (struct enum_windows_s *)lParam;
2337+
2338+
return (ew->lpEnumFunc)(hwnd, ew->lParam);
2339+
}
2340+
2341+
static BOOL CALLBACK
2342+
enum_windows_toplevel(HWND hwnd, LPARAM lParam)
2343+
{
2344+
struct enum_windows_s *ew = (struct enum_windows_s *)lParam;
2345+
2346+
if ((ew->lpEnumFunc)(hwnd, ew->lParam) == FALSE)
2347+
return FALSE;
2348+
return EnumChildWindows(hwnd, enum_windows_child, lParam);
2349+
}
2350+
2351+
/* Enumerate all windows including children. */
2352+
static BOOL
2353+
enum_windows(WNDENUMPROC lpEnumFunc, LPARAM lParam)
2354+
{
2355+
struct enum_windows_s ew;
2356+
2357+
ew.lpEnumFunc = lpEnumFunc;
2358+
ew.lParam = lParam;
2359+
return EnumWindows(enum_windows_toplevel, (LPARAM)&ew);
2360+
}
2361+
23272362
static HWND
23282363
findServer(char_u *name)
23292364
{
@@ -2332,7 +2367,7 @@ findServer(char_u *name)
23322367
id.name = name;
23332368
id.hwnd = 0;
23342369

2335-
EnumWindows(enumWindowsGetServer, (LPARAM)(&id));
2370+
enum_windows(enumWindowsGetServer, (LPARAM)(&id));
23362371

23372372
return id.hwnd;
23382373
}
@@ -2395,7 +2430,7 @@ serverGetVimNames(void)
23952430

23962431
ga_init2(&ga, 1, 100);
23972432

2398-
EnumWindows(enumWindowsGetNames, (LPARAM)(&ga));
2433+
enum_windows(enumWindowsGetNames, (LPARAM)(&ga));
23992434
ga_append(&ga, NUL);
24002435

24012436
return ga.ga_data;

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -792,6 +792,8 @@ static char *(features[]) =
792792

793793
static int included_patches[] =
794794
{ /* Add new patch number below this line */
795+
/**/
796+
462,
795797
/**/
796798
461,
797799
/**/

0 commit comments

Comments
 (0)