OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2014 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2014 The WebRTC project authors. All Rights Reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 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 | 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 | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
11 #include "webrtc/modules/desktop_capture/mac/full_screen_chrome_window_detector.
h" | 11 #include "webrtc/modules/desktop_capture/mac/full_screen_chrome_window_detector.
h" |
12 | 12 |
13 #include <assert.h> | 13 #include <assert.h> |
14 #include <libproc.h> | 14 #include <libproc.h> |
15 #include <string> | 15 #include <string> |
16 | 16 |
17 #include "webrtc/base/macutils.h" | 17 #include "webrtc/base/macutils.h" |
18 #include "webrtc/base/timeutils.h" | 18 #include "webrtc/base/timeutils.h" |
19 #include "webrtc/modules/desktop_capture/mac/window_list_utils.h" | 19 #include "webrtc/modules/desktop_capture/mac/window_list_utils.h" |
20 #include "webrtc/system_wrappers/include/logging.h" | |
21 | 20 |
22 | 21 |
23 namespace webrtc { | 22 namespace webrtc { |
24 | 23 |
25 namespace { | 24 namespace { |
26 | 25 |
27 const int64_t kUpdateIntervalMs = 500; | 26 const int64_t kUpdateIntervalMs = 500; |
28 | 27 |
29 std::string GetWindowTitle(CGWindowID id) { | 28 std::string GetWindowTitle(CGWindowID id) { |
30 CFArrayRef window_id_array = | 29 CFArrayRef window_id_array = |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
154 CGWindowID full_screen_window_id = | 153 CGWindowID full_screen_window_id = |
155 FindFullScreenWindowWithSamePidAndTitle(original_window); | 154 FindFullScreenWindowWithSamePidAndTitle(original_window); |
156 | 155 |
157 if (full_screen_window_id == kCGNullWindowID) | 156 if (full_screen_window_id == kCGNullWindowID) |
158 return kCGNullWindowID; | 157 return kCGNullWindowID; |
159 | 158 |
160 for (const auto& window : previous_window_list_) { | 159 for (const auto& window : previous_window_list_) { |
161 if (static_cast<CGWindowID>(window.id) != full_screen_window_id) | 160 if (static_cast<CGWindowID>(window.id) != full_screen_window_id) |
162 continue; | 161 continue; |
163 | 162 |
164 LOG(LS_WARNING) << "The full-screen window exists in the list."; | |
165 return kCGNullWindowID; | 163 return kCGNullWindowID; |
166 } | 164 } |
167 | 165 |
168 return full_screen_window_id; | 166 return full_screen_window_id; |
169 } | 167 } |
170 | 168 |
171 void FullScreenChromeWindowDetector::UpdateWindowListIfNeeded( | 169 void FullScreenChromeWindowDetector::UpdateWindowListIfNeeded( |
172 CGWindowID original_window) { | 170 CGWindowID original_window) { |
173 if (IsChromeWindow(original_window) && | 171 if (IsChromeWindow(original_window) && |
174 (rtc::TimeNanos() - last_update_time_ns_) / rtc::kNumNanosecsPerMillisec | 172 (rtc::TimeNanos() - last_update_time_ns_) / rtc::kNumNanosecsPerMillisec |
175 > kUpdateIntervalMs) { | 173 > kUpdateIntervalMs) { |
176 previous_window_list_.clear(); | 174 previous_window_list_.clear(); |
177 previous_window_list_.swap(current_window_list_); | 175 previous_window_list_.swap(current_window_list_); |
178 | 176 |
179 // No need to update the window list when the window is minimized. | 177 // No need to update the window list when the window is minimized. |
180 if (IsWindowMinimized(original_window)) { | 178 if (IsWindowMinimized(original_window)) { |
181 previous_window_list_.clear(); | 179 previous_window_list_.clear(); |
182 return; | 180 return; |
183 } | 181 } |
184 | 182 |
185 GetWindowList(¤t_window_list_, false); | 183 GetWindowList(¤t_window_list_, false); |
186 last_update_time_ns_ = rtc::TimeNanos(); | 184 last_update_time_ns_ = rtc::TimeNanos(); |
187 } | 185 } |
188 } | 186 } |
189 | 187 |
190 } // namespace webrtc | 188 } // namespace webrtc |
OLD | NEW |