1 /* 2 * Copyright (c) 2017 The WebRTC project authors. All Rights Reserved. 3 * 4 * Use of this source code is governed by a BSD-style license 5 * that can be found in the LICENSE file in the root of the source 6 * tree. An additional intellectual property rights grant can be found 7 * in the file PATENTS. All contributing project authors may 8 * be found in the AUTHORS file in the root of the source tree. 9 */ 10 11 #include "modules/desktop_capture/window_finder_win.h" 12 13 #include <windows.h> 14 15 #include <memory> 16 17 namespace webrtc { 18 19 WindowFinderWin::WindowFinderWin() = default; 20 WindowFinderWin::~WindowFinderWin() = default; 21 GetWindowUnderPoint(DesktopVector point)22WindowId WindowFinderWin::GetWindowUnderPoint(DesktopVector point) { 23 HWND window = WindowFromPoint(POINT{point.x(), point.y()}); 24 if (!window) { 25 return kNullWindowId; 26 } 27 28 // The difference between GA_ROOTOWNER and GA_ROOT can be found at 29 // https://groups.google.com/a/chromium.org/forum/#!topic/chromium-dev/Hirr_DkuZdw. 30 // In short, we should use GA_ROOT, since we only care about the root window 31 // but not the owner. 32 window = GetAncestor(window, GA_ROOT); 33 if (!window) { 34 return kNullWindowId; 35 } 36 37 return reinterpret_cast<WindowId>(window); 38 } 39 40 // static Create(const WindowFinder::Options & options)41std::unique_ptr<WindowFinder> WindowFinder::Create( 42 const WindowFinder::Options& options) { 43 return std::make_unique<WindowFinderWin>(); 44 } 45 46 } // namespace webrtc 47