comparison src/os_mswin.c @ 14901:014d916ab258 v8.1.0462

patch 8.1.0462: when using ConPTY Vim can be a child process commit https://github.com/vim/vim/commit/c0543e145fdd29739ac887e71ab96c50282066cd Author: Bram Moolenaar <Bram@vim.org> Date: Sun Oct 7 20:35:12 2018 +0200 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)
author Bram Moolenaar <Bram@vim.org>
date Sun, 07 Oct 2018 20:45:04 +0200
parents 3375a8cbb442
children 497009f367ea
comparison
equal deleted inserted replaced
14900:caf64d01a0d6 14901:014d916ab258
2322 ga_concat(ga, (char_u *)server); 2322 ga_concat(ga, (char_u *)server);
2323 ga_concat(ga, (char_u *)"\n"); 2323 ga_concat(ga, (char_u *)"\n");
2324 return TRUE; 2324 return TRUE;
2325 } 2325 }
2326 2326
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
2327 static HWND 2362 static HWND
2328 findServer(char_u *name) 2363 findServer(char_u *name)
2329 { 2364 {
2330 struct server_id id; 2365 struct server_id id;
2331 2366
2332 id.name = name; 2367 id.name = name;
2333 id.hwnd = 0; 2368 id.hwnd = 0;
2334 2369
2335 EnumWindows(enumWindowsGetServer, (LPARAM)(&id)); 2370 enum_windows(enumWindowsGetServer, (LPARAM)(&id));
2336 2371
2337 return id.hwnd; 2372 return id.hwnd;
2338 } 2373 }
2339 2374
2340 void 2375 void
2393 { 2428 {
2394 garray_T ga; 2429 garray_T ga;
2395 2430
2396 ga_init2(&ga, 1, 100); 2431 ga_init2(&ga, 1, 100);
2397 2432
2398 EnumWindows(enumWindowsGetNames, (LPARAM)(&ga)); 2433 enum_windows(enumWindowsGetNames, (LPARAM)(&ga));
2399 ga_append(&ga, NUL); 2434 ga_append(&ga, NUL);
2400 2435
2401 return ga.ga_data; 2436 return ga.ga_data;
2402 } 2437 }
2403 2438