]> granicus.if.org Git - vim/commitdiff
patch 8.1.0462: when using ConPTY Vim can be a child process v8.1.0462
authorBram Moolenaar <Bram@vim.org>
Sun, 7 Oct 2018 18:35:12 +0000 (20:35 +0200)
committerBram Moolenaar <Bram@vim.org>
Sun, 7 Oct 2018 18:35:12 +0000 (20:35 +0200)
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)

src/os_mswin.c
src/version.c

index 2112b0c2aa7ab19021ff80b0fdd44c25dc5b5404..bd38e9d3f1c249e9895ab2b735984e68276bef6d 100644 (file)
@@ -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;
index 93cbc30508bb97372c08ac5505cad2f5e6c3587c..103483a940ec4d4f993dadf3aee93019855c4fd7 100644 (file)
@@ -792,6 +792,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    462,
 /**/
     461,
 /**/