Bug 1202087 - Filter out non-shareable application for win8 or greater. r=jesup
authorAlexandros Chronopoulos <achronop@gmail.com>
Wed, 11 Nov 2015 14:01:27 +0200
changeset 309016 95853027847262e97e52f57497206a87a3e0681b
parent 309015 427dc5894094f29a6613908769582c5fdf4c509a
child 309017 e925caf848fa63ed3fb36671bbd524735669e585
push id5513
push userraliiev@mozilla.com
push dateMon, 25 Jan 2016 13:55:34 +0000
treeherdermozilla-beta@5ee97dd05b5c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjesup
bugs1202087
milestone45.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1202087 - Filter out non-shareable application for win8 or greater. r=jesup
media/webrtc/trunk/webrtc/modules/desktop_capture/win/desktop_device_info_win.cc
media/webrtc/trunk/webrtc/modules/desktop_capture/window_capturer_win.cc
--- a/media/webrtc/trunk/webrtc/modules/desktop_capture/win/desktop_device_info_win.cc
+++ b/media/webrtc/trunk/webrtc/modules/desktop_capture/win/desktop_device_info_win.cc
@@ -2,16 +2,17 @@
  * License, v. 2.0. If a copy of the MPL was not distributed with this file,
  * You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "webrtc/modules/desktop_capture/win/desktop_device_info_win.h"
 #include "webrtc/modules/desktop_capture/win/screen_capture_utils.h"
 #include "webrtc/modules/desktop_capture/win/win_shared.h"
 #include <inttypes.h>
 #include <stdio.h>
+#include <VersionHelpers.h>
 
 // Duplicating declaration so that it always resolves in decltype use
 // typedef BOOL (WINAPI *QueryFullProcessImageNameProc)(HANDLE hProcess, DWORD dwFlags, LPTSTR lpExeName, PDWORD lpdwSize);
 BOOL WINAPI QueryFullProcessImageName(HANDLE hProcess, DWORD dwFlags, LPTSTR lpExeName, PDWORD lpdwSize);
 
 // Duplicating declaration so that it always resolves in decltype use
 // typedoef DWORD (WINAPI *GetProcessImageFileNameProc)(HANDLE hProcess, LPTSTR lpImageFileName, DWORD nSize);
 DWORD WINAPI GetProcessImageFileName(HANDLE hProcess, LPTSTR lpImageFileName, DWORD nSize);
@@ -87,16 +88,27 @@ void DesktopDeviceInfoWin::InitializeApp
     DWORD dwProcessId = 0;
     GetWindowThreadProcessId(hWnd, &dwProcessId);
 
     // filter out non-process, current process
     if (dwProcessId == 0 || dwProcessId == GetCurrentProcessId()) {
       continue;
     }
 
+    // Win8 introduced "Modern Apps" whose associated window is
+    // non-shareable. We want to filter them out.
+    const int classLength = 256;
+    WCHAR class_name[classLength] = {0};
+    GetClassName(hWnd, class_name, classLength);
+    if (IsWindows8OrGreater() &&
+        (wcscmp(class_name, L"ApplicationFrameWindow") == 0 ||
+         wcscmp(class_name, L"Windows.UI.Core.CoreWindow") == 0)) {
+      continue;
+    }
+
     // filter out already-seen processes, after updating the window count
     DesktopApplicationList::iterator itr = desktop_application_list_.find(dwProcessId);
     if (itr != desktop_application_list_.end()) {
       itr->second->setWindowCount(itr->second->getWindowCount() + 1);
       continue;
     }
 
     // Add one application
--- a/media/webrtc/trunk/webrtc/modules/desktop_capture/window_capturer_win.cc
+++ b/media/webrtc/trunk/webrtc/modules/desktop_capture/window_capturer_win.cc
@@ -12,16 +12,17 @@
 
 #include <assert.h>
 
 #include "webrtc/base/scoped_ptr.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"
 #include "webrtc/system_wrappers/interface/logging.h"
+#include <VersionHelpers.h>
 
 namespace webrtc {
 
 namespace {
 
 typedef HRESULT (WINAPI *DwmIsCompositionEnabledFunc)(BOOL* enabled);
 
 BOOL CALLBACK WindowsEnumerationHandler(HWND hwnd, LPARAM param) {
@@ -44,16 +45,24 @@ BOOL CALLBACK WindowsEnumerationHandler(
   WCHAR class_name[kClassLength];
   GetClassName(hwnd, class_name, kClassLength);
   // 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;
 
+  // Win8 introduced "Modern Apps" whose associated window is
+  // non-shareable. We want to filter them out.
+  if (IsWindows8OrGreater() &&
+      (wcscmp(class_name, L"ApplicationFrameWindow") == 0 ||
+       wcscmp(class_name, L"Windows.UI.Core.CoreWindow") == 0)) {
+    return TRUE;
+  }
+
   WindowCapturer::Window window;
   window.id = reinterpret_cast<WindowCapturer::WindowId>(hwnd);
 
   const size_t kTitleLength = 500;
   WCHAR window_title[kTitleLength];
   // Truncate the title if it's longer than kTitleLength.
   GetWindowText(hwnd, window_title, kTitleLength);
   window.title = rtc::ToUtf8(window_title);