blob: 4c6da9d74eb07c5096ff4e9bccd3a90cd8c9d57e [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_x11.h"
12
13#include "webrtc/modules/desktop_capture/x11/window_list_utils.h"
14#include "webrtc/rtc_base/checks.h"
15
16namespace webrtc {
17
18WindowFinderX11::WindowFinderX11(XAtomCache* cache)
19 : cache_(cache) {
20 RTC_DCHECK(cache_);
21}
22
23WindowFinderX11::~WindowFinderX11() = default;
24
25WindowId WindowFinderX11::GetWindowUnderPoint(DesktopVector point) {
26 WindowId id = kNullWindowId;
27 GetWindowList(cache_,
28 [&id, this, point](::Window window) {
29 DesktopRect rect;
30 if (GetWindowRect(this->cache_->display(), window, &rect) &&
31 rect.Contains(point)) {
32 id = window;
33 return false;
34 }
35 return true;
36 });
37 return id;
38}
39
40} // namespace webrtc