blob: 8bf7150bab5f6ef0fea5e7c772337c0ab9a394fc [file] [log] [blame]
Zijie He70fbbad2017-08-15 15:45:00 -07001/*
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 "webrtc/modules/desktop_capture/window_finder_mac.h"
12
13#include <CoreFoundation/CoreFoundation.h>
14
15#include "webrtc/modules/desktop_capture/mac/window_list_utils.h"
Zijie He77b7a1d2017-09-01 15:51:14 -070016#include "webrtc/rtc_base/ptr_util.h"
Zijie He70fbbad2017-08-15 15:45:00 -070017
18namespace webrtc {
19
20WindowFinderMac::WindowFinderMac() = default;
21WindowFinderMac::~WindowFinderMac() = default;
22
23WindowId WindowFinderMac::GetWindowUnderPoint(DesktopVector point) {
24 WindowId id = kNullWindowId;
25 GetWindowList([&id, point](CFDictionaryRef window) {
26 DesktopRect bounds = GetWindowBounds(window);
27 if (bounds.Contains(point)) {
28 id = GetWindowId(window);
29 return false;
30 }
31 return true;
32 },
33 true);
34 return id;
35}
36
Zijie He77b7a1d2017-09-01 15:51:14 -070037// static
38std::unique_ptr<WindowFinder> WindowFinder::Create(
39 const WindowFinder::Options& options) {
40 return rtc::MakeUnique<WindowFinderMac>();
41}
42
Zijie He70fbbad2017-08-15 15:45:00 -070043} // namespace webrtc