From 371dc7e5601f05015d4816ed2624cc8f5f01d19a Mon Sep 17 00:00:00 2001 From: gyzhou Date: Fri, 2 Oct 2015 15:36:30 -0700 Subject: [PATCH] WebRtc Win Desktop capture: ignore Win8+ Modern Apps' windows. Microsoft introduced modern app from win8. Modern apps can be used cross Microsoft's platforms. It was confirmed from Microsoft that there is no support for modern app's window capture. BUG=526883 Review URL: https://codereview.webrtc.org/1371383003 Cr-Commit-Position: refs/heads/master@{#10154} --- .../desktop_capture/window_capturer_win.cc | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/webrtc/modules/desktop_capture/window_capturer_win.cc b/webrtc/modules/desktop_capture/window_capturer_win.cc index ba45eaa9d1..322a5340c9 100644 --- a/webrtc/modules/desktop_capture/window_capturer_win.cc +++ b/webrtc/modules/desktop_capture/window_capturer_win.cc @@ -13,6 +13,7 @@ #include #include "webrtc/base/scoped_ptr.h" +#include "webrtc/base/checks.h" #include "webrtc/base/win32.h" #include "webrtc/modules/desktop_capture/desktop_frame_win.h" #include "webrtc/modules/desktop_capture/win/window_capture_utils.h" @@ -39,13 +40,26 @@ BOOL CALLBACK WindowsEnumerationHandler(HWND hwnd, LPARAM param) { // Skip the Program Manager window and the Start button. const size_t kClassLength = 256; WCHAR class_name[kClassLength]; - GetClassName(hwnd, class_name, kClassLength); + const int class_name_length = GetClassName(hwnd, class_name, kClassLength); + RTC_DCHECK(class_name_length) + << "Error retrieving the application's class name"; + // Skip Program Manager window and the Start button. This is the same logic // that's used in Win32WindowPicker in libjingle. Consider filtering other // windows as well (e.g. toolbars). if (wcscmp(class_name, L"Progman") == 0 || wcscmp(class_name, L"Button") == 0) return TRUE; + // Windows 8 introduced a "Modern App" identified by their class name being + // either ApplicationFrameWindow or windows.UI.Core.coreWindow. The + // associated windows cannot be captured, so we skip them. + // http://crbug.com/526883. + if (rtc::IsWindows8OrLater() && + (wcscmp(class_name, L"ApplicationFrameWindow") == 0 || + wcscmp(class_name, L"Windows.UI.Core.CoreWindow") == 0)) { + return TRUE; + } + WindowCapturer::Window window; window.id = reinterpret_cast(hwnd);