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/cropping_window_capturer.h" | 11 #include "webrtc/modules/desktop_capture/cropping_window_capturer.h" |
12 | 12 |
13 #include "webrtc/base/win32.h" | 13 #include "webrtc/base/win32.h" |
14 #include "webrtc/modules/desktop_capture/win/scoped_gdi_object.h" | 14 #include "webrtc/modules/desktop_capture/win/scoped_gdi_object.h" |
15 #include "webrtc/modules/desktop_capture/win/screen_capture_utils.h" | 15 #include "webrtc/modules/desktop_capture/win/screen_capture_utils.h" |
16 #include "webrtc/modules/desktop_capture/win/window_capture_utils.h" | 16 #include "webrtc/modules/desktop_capture/win/window_capture_utils.h" |
17 #include "webrtc/system_wrappers/include/logging.h" | |
18 | 17 |
19 namespace webrtc { | 18 namespace webrtc { |
20 | 19 |
21 namespace { | 20 namespace { |
22 | 21 |
23 // Used to pass input/output data during the EnumWindow call for verifying if | 22 // Used to pass input/output data during the EnumWindow call for verifying if |
24 // the selected window is on top. | 23 // the selected window is on top. |
25 struct TopWindowVerifierContext { | 24 struct TopWindowVerifierContext { |
26 TopWindowVerifierContext(HWND selected_window, HWND excluded_window) | 25 TopWindowVerifierContext(HWND selected_window, HWND excluded_window) |
27 : selected_window(selected_window), | 26 : selected_window(selected_window), |
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
188 // windows, context menus, and |excluded_window_|. | 187 // windows, context menus, and |excluded_window_|. |
189 EnumWindows(&TopWindowVerifier, reinterpret_cast<LPARAM>(&context)); | 188 EnumWindows(&TopWindowVerifier, reinterpret_cast<LPARAM>(&context)); |
190 return context.is_top_window; | 189 return context.is_top_window; |
191 } | 190 } |
192 | 191 |
193 DesktopRect CroppingWindowCapturerWin::GetWindowRectInVirtualScreen() { | 192 DesktopRect CroppingWindowCapturerWin::GetWindowRectInVirtualScreen() { |
194 DesktopRect original_rect; | 193 DesktopRect original_rect; |
195 DesktopRect window_rect; | 194 DesktopRect window_rect; |
196 HWND hwnd = reinterpret_cast<HWND>(selected_window()); | 195 HWND hwnd = reinterpret_cast<HWND>(selected_window()); |
197 if (!GetCroppedWindowRect(hwnd, &window_rect, &original_rect)) { | 196 if (!GetCroppedWindowRect(hwnd, &window_rect, &original_rect)) { |
198 LOG(LS_WARNING) << "Failed to get window info: " << GetLastError(); | |
199 return window_rect; | 197 return window_rect; |
200 } | 198 } |
201 window_rect.IntersectWith(window_region_rect_); | 199 window_rect.IntersectWith(window_region_rect_); |
202 | 200 |
203 // Convert |window_rect| to be relative to the top-left of the virtual screen. | 201 // Convert |window_rect| to be relative to the top-left of the virtual screen. |
204 DesktopRect screen_rect(GetScreenRect(kFullDesktopScreenId, L"")); | 202 DesktopRect screen_rect(GetScreenRect(kFullDesktopScreenId, L"")); |
205 window_rect.IntersectWith(screen_rect); | 203 window_rect.IntersectWith(screen_rect); |
206 window_rect.Translate(-screen_rect.left(), -screen_rect.top()); | 204 window_rect.Translate(-screen_rect.left(), -screen_rect.top()); |
207 return window_rect; | 205 return window_rect; |
208 } | 206 } |
209 | 207 |
210 } // namespace | 208 } // namespace |
211 | 209 |
212 // static | 210 // static |
213 std::unique_ptr<DesktopCapturer> CroppingWindowCapturer::CreateCapturer( | 211 std::unique_ptr<DesktopCapturer> CroppingWindowCapturer::CreateCapturer( |
214 const DesktopCaptureOptions& options) { | 212 const DesktopCaptureOptions& options) { |
215 return std::unique_ptr<DesktopCapturer>( | 213 return std::unique_ptr<DesktopCapturer>( |
216 new CroppingWindowCapturerWin(options)); | 214 new CroppingWindowCapturerWin(options)); |
217 } | 215 } |
218 | 216 |
219 } // namespace webrtc | 217 } // namespace webrtc |
OLD | NEW |