tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

window_finder_win.cc (1542B)


      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 #include "modules/desktop_capture/desktop_capture_types.h"
     18 #include "modules/desktop_capture/desktop_geometry.h"
     19 #include "modules/desktop_capture/window_finder.h"
     20 
     21 namespace webrtc {
     22 
     23 WindowFinderWin::WindowFinderWin() = default;
     24 WindowFinderWin::~WindowFinderWin() = default;
     25 
     26 WindowId WindowFinderWin::GetWindowUnderPoint(DesktopVector point) {
     27  HWND window = WindowFromPoint(POINT{point.x(), point.y()});
     28  if (!window) {
     29    return kNullWindowId;
     30  }
     31 
     32  // The difference between GA_ROOTOWNER and GA_ROOT can be found at
     33  // https://groups.google.com/a/chromium.org/forum/#!topic/chromium-dev/Hirr_DkuZdw.
     34  // In short, we should use GA_ROOT, since we only care about the root window
     35  // but not the owner.
     36  window = GetAncestor(window, GA_ROOT);
     37  if (!window) {
     38    return kNullWindowId;
     39  }
     40 
     41  return reinterpret_cast<WindowId>(window);
     42 }
     43 
     44 // static
     45 std::unique_ptr<WindowFinder> WindowFinder::Create(
     46    const WindowFinder::Options& options) {
     47  return std::make_unique<WindowFinderWin>();
     48 }
     49 
     50 }  // namespace webrtc