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" |
| 16 | |
| 17 | namespace webrtc { |
| 18 | |
| 19 | WindowFinderMac::WindowFinderMac() = default; |
| 20 | WindowFinderMac::~WindowFinderMac() = default; |
| 21 | |
| 22 | WindowId WindowFinderMac::GetWindowUnderPoint(DesktopVector point) { |
| 23 | WindowId id = kNullWindowId; |
| 24 | GetWindowList([&id, point](CFDictionaryRef window) { |
| 25 | DesktopRect bounds = GetWindowBounds(window); |
| 26 | if (bounds.Contains(point)) { |
| 27 | id = GetWindowId(window); |
| 28 | return false; |
| 29 | } |
| 30 | return true; |
| 31 | }, |
| 32 | true); |
| 33 | return id; |
| 34 | } |
| 35 | |
| 36 | } // namespace webrtc |