CroppingWindowCapturerWin: filter out cloaked window.

A cloaked window is composited but not visible to the user.
When Win10 feature 'Cortana' is enabled it creates a window
that is always invisible and its z-order is top most. Because
of that the cropping capturer detects occlusion everywhere
preventing it from capturing anything.

The solution is to ignore all cloaked windows like if
::IsWindowVisible would return false.

Bug: chromium:978885
Change-Id: Id5aa8dc81dcf4979ffb30dd808fa2a553934c6e6
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/143980
Commit-Queue: Julien Isorce <julien.isorce@chromium.org>
Reviewed-by: Sergey Ulanov <sergeyu@chromium.org>
Reviewed-by: Guido Urdaneta <guidou@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#28510}
This commit is contained in:
Julien Isorce
2019-07-08 11:35:18 -07:00
committed by Commit Bot
parent a0eefc17f7
commit 5e25facefd
2 changed files with 36 additions and 8 deletions

View File

@ -60,6 +60,10 @@ bool GetDcSize(HDC hdc, DesktopSize* size);
bool IsWindowMaximized(HWND window, bool* result);
typedef HRESULT(WINAPI* DwmIsCompositionEnabledFunc)(BOOL* enabled);
typedef HRESULT(WINAPI* DwmGetWindowAttributeFunc)(HWND hwnd,
DWORD dwAttribute,
PVOID pvAttribute,
DWORD cbAttribute);
class WindowCaptureHelperWin {
public:
WindowCaptureHelperWin();
@ -73,13 +77,16 @@ class WindowCaptureHelperWin {
const DesktopRect& selected_window_rect);
bool IsWindowOnCurrentDesktop(HWND hwnd);
bool IsWindowVisibleOnCurrentDesktop(HWND hwnd);
bool IsWindowCloaked(HWND hwnd);
private:
HMODULE dwmapi_library_;
DwmIsCompositionEnabledFunc func_;
HMODULE dwmapi_library_ = nullptr;
DwmIsCompositionEnabledFunc func_ = nullptr;
DwmGetWindowAttributeFunc dwm_get_window_attribute_func_ = nullptr;
// Only used on Win10+.
Microsoft::WRL::ComPtr<IVirtualDesktopManager> virtual_desktop_manager_;
Microsoft::WRL::ComPtr<IVirtualDesktopManager> virtual_desktop_manager_ =
nullptr;
RTC_DISALLOW_COPY_AND_ASSIGN(WindowCaptureHelperWin);
};