Zijie He | 70fbbad | 2017-08-15 15:45:00 -0700 | [diff] [blame] | 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 "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 He | 77b7a1d | 2017-09-01 15:51:14 -0700 | [diff] [blame] | 16 | #include "webrtc/rtc_base/ptr_util.h" |
Zijie He | 70fbbad | 2017-08-15 15:45:00 -0700 | [diff] [blame] | 17 | |
| 18 | namespace webrtc { |
| 19 | |
| 20 | WindowFinderMac::WindowFinderMac() = default; |
| 21 | WindowFinderMac::~WindowFinderMac() = default; |
| 22 | |
| 23 | WindowId 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 He | 77b7a1d | 2017-09-01 15:51:14 -0700 | [diff] [blame] | 37 | // static |
| 38 | std::unique_ptr<WindowFinder> WindowFinder::Create( |
| 39 | const WindowFinder::Options& options) { |
| 40 | return rtc::MakeUnique<WindowFinderMac>(); |
| 41 | } |
| 42 | |
Zijie He | 70fbbad | 2017-08-15 15:45:00 -0700 | [diff] [blame] | 43 | } // namespace webrtc |