Improve checks for "child" windows of selected capture targets.

Previously windows other than the selected window will also be captured if they share the same process & thread, to allow child windows (e.g. popup menus) to be captured. This could result in child windows of other top-level windows run by the same process and thread being unintentionally captured. In attempt to err on the side of caution this check has been removed leaving some context menus and tooltips not recognized.

Bug: webrtc:11455
Change-Id: I66acc4b133baa51a128202727c655c63b07b19ab
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/176462
Reviewed-by: Jamie Walch <jamiewalch@chromium.org>
Reviewed-by: Wez <wez@google.com>
Commit-Queue: Jamie Walch <jamiewalch@chromium.org>
Cr-Commit-Position: refs/heads/master@{#32395}
diff --git a/modules/desktop_capture/win/selected_window_context.cc b/modules/desktop_capture/win/selected_window_context.cc
index 7445957..398ea1e 100644
--- a/modules/desktop_capture/win/selected_window_context.cc
+++ b/modules/desktop_capture/win/selected_window_context.cc
@@ -28,20 +28,19 @@
 }
 
 bool SelectedWindowContext::IsWindowOwnedBySelectedWindow(HWND hwnd) const {
-  // This check works for drop-down menus & dialog pop-up windows. It doesn't
-  // work for context menus or tooltips, which are handled differently below.
+  // This check works for drop-down menus & dialog pop-up windows.
   if (GetAncestor(hwnd, GA_ROOTOWNER) == selected_window_) {
     return true;
   }
 
-  // Some pop-up windows aren't owned (e.g. context menus, tooltips); treat
-  // windows that belong to the same thread as owned.
-  DWORD enumerated_window_process_id = 0;
-  DWORD enumerated_window_thread_id =
-      GetWindowThreadProcessId(hwnd, &enumerated_window_process_id);
-  return enumerated_window_thread_id != 0 &&
-         enumerated_window_process_id == selected_window_process_id_ &&
-         enumerated_window_thread_id == selected_window_thread_id_;
+  // Assume that all other windows are unrelated to the selected window.
+  // This will cause some windows that are actually related to be missed,
+  // e.g. context menus and tool-tips, but avoids the risk of capturing
+  // unrelated windows. Using heuristics such as matching the thread and
+  // process Ids suffers from false-positives, e.g. in multi-document
+  // applications.
+
+  return false;
 }
 
 bool SelectedWindowContext::IsWindowOverlappingSelectedWindow(HWND hwnd) const {