[Window capture] filter out sibling windows with same title.
On Windows, some app windows (i.e. Window Media Player) seems consisting of several sibling windows, with same window title as the main window and from same process. Currently CroppingWindowCapturerWin will think the selected window is overlapped by those windows and switch to GDI capture method, which is not well supported by many Apps on Win10 and will fail the window capture. This cl is to extend the current null title check to include the case that window has same title as the selected window. Bug: chromium:865193 Change-Id: Id16b21596ab3b870197758679e5406138ac1a432 Reviewed-on: https://webrtc-review.googlesource.com/89501 Commit-Queue: Brave Yao <braveyao@webrtc.org> Reviewed-by: Jamie Walch <jamiewalch@chromium.org> Cr-Commit-Position: refs/heads/master@{#24046}
This commit is contained in:
@ -20,6 +20,8 @@ namespace webrtc {
|
||||
|
||||
namespace {
|
||||
|
||||
const size_t kTitleLength = 256;
|
||||
|
||||
// Used to pass input/output data during the EnumWindow call for verifying if
|
||||
// the selected window is on top.
|
||||
struct TopWindowVerifierContext {
|
||||
@ -33,12 +35,17 @@ struct TopWindowVerifierContext {
|
||||
window_capture_helper(window_capture_helper),
|
||||
is_top_window(false) {
|
||||
RTC_DCHECK_NE(selected_window, excluded_window);
|
||||
|
||||
GetWindowText(selected_window, selected_window_title, kTitleLength);
|
||||
GetWindowThreadProcessId(selected_window, &selected_window_process_id);
|
||||
}
|
||||
|
||||
const HWND selected_window;
|
||||
const HWND excluded_window;
|
||||
const DesktopRect selected_window_rect;
|
||||
WindowCaptureHelperWin* window_capture_helper;
|
||||
WCHAR selected_window_title[kTitleLength];
|
||||
DWORD selected_window_process_id;
|
||||
bool is_top_window;
|
||||
};
|
||||
|
||||
@ -90,21 +97,20 @@ BOOL CALLBACK TopWindowVerifier(HWND hwnd, LPARAM param) {
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
// If |hwnd| has no title and belongs to the same process, assume it's a
|
||||
// tooltip or context menu from the selected window and ignore it.
|
||||
// If |hwnd| has no title or has same title as the selected window (i.e.
|
||||
// Window Media Player consisting of several sibling windows) and belongs to
|
||||
// the same process, assume it's a tooltip or context menu or sibling window
|
||||
// from the selected window and ignore it.
|
||||
// TODO(zijiehe): This check cannot cover the case where tooltip or context
|
||||
// menu of the child-window is covering the main window. See
|
||||
// https://bugs.chromium.org/p/webrtc/issues/detail?id=8062 for details.
|
||||
const size_t kTitleLength = 32;
|
||||
WCHAR window_title[kTitleLength];
|
||||
GetWindowText(hwnd, window_title, kTitleLength);
|
||||
if (wcsnlen_s(window_title, kTitleLength) == 0) {
|
||||
if (wcsnlen_s(window_title, kTitleLength) == 0 ||
|
||||
wcscmp(window_title, context->selected_window_title) == 0) {
|
||||
DWORD enumerated_window_process_id;
|
||||
DWORD selected_window_process_id;
|
||||
GetWindowThreadProcessId(hwnd, &enumerated_window_process_id);
|
||||
GetWindowThreadProcessId(context->selected_window,
|
||||
&selected_window_process_id);
|
||||
if (selected_window_process_id == enumerated_window_process_id) {
|
||||
if (context->selected_window_process_id == enumerated_window_process_id) {
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user