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/win/window_capture_utils.h" | 11 #include "webrtc/modules/desktop_capture/win/window_capture_utils.h" |
12 | 12 |
| 13 #include "webrtc/rtc_base/win32.h" |
| 14 |
13 namespace webrtc { | 15 namespace webrtc { |
14 | 16 |
15 bool | 17 bool |
16 GetCroppedWindowRect(HWND window, | 18 GetCroppedWindowRect(HWND window, |
17 DesktopRect* cropped_rect, | 19 DesktopRect* cropped_rect, |
18 DesktopRect* original_rect) { | 20 DesktopRect* original_rect) { |
19 RECT rect; | 21 RECT rect; |
20 if (!GetWindowRect(window, &rect)) { | 22 if (!GetWindowRect(window, &rect)) { |
21 return false; | 23 return false; |
22 } | 24 } |
23 WINDOWPLACEMENT window_placement; | 25 WINDOWPLACEMENT window_placement; |
24 window_placement.length = sizeof(window_placement); | 26 window_placement.length = sizeof(window_placement); |
25 if (!GetWindowPlacement(window, &window_placement)) { | 27 if (!GetWindowPlacement(window, &window_placement)) { |
26 return false; | 28 return false; |
27 } | 29 } |
28 | 30 |
29 *original_rect = DesktopRect::MakeLTRB( | 31 *original_rect = DesktopRect::MakeLTRB( |
30 rect.left, rect.top, rect.right, rect.bottom); | 32 rect.left, rect.top, rect.right, rect.bottom); |
31 | 33 |
32 if (window_placement.showCmd == SW_SHOWMAXIMIZED) { | 34 // After Windows8, transparent borders will be added by OS at |
| 35 // left/bottom/right sides of a window. If the cropped window |
| 36 // doesn't remove these borders, the background will be exposed a bit. |
| 37 if (rtc::IsWindows8OrLater() || |
| 38 window_placement.showCmd == SW_SHOWMAXIMIZED) { |
33 DesktopSize border = DesktopSize(GetSystemMetrics(SM_CXSIZEFRAME), | 39 DesktopSize border = DesktopSize(GetSystemMetrics(SM_CXSIZEFRAME), |
34 GetSystemMetrics(SM_CYSIZEFRAME)); | 40 GetSystemMetrics(SM_CYSIZEFRAME)); |
35 *cropped_rect = DesktopRect::MakeLTRB( | 41 *cropped_rect = DesktopRect::MakeLTRB( |
36 rect.left + border.width(), | 42 rect.left + border.width(), |
37 rect.top, | 43 rect.top, |
38 rect.right - border.width(), | 44 rect.right - border.width(), |
39 rect.bottom - border.height()); | 45 rect.bottom - border.height()); |
40 } else { | 46 } else { |
41 *cropped_rect = *original_rect; | 47 *cropped_rect = *original_rect; |
42 } | 48 } |
(...skipping 17 matching lines...) Expand all Loading... |
60 | 66 |
61 bool AeroChecker::IsAeroEnabled() { | 67 bool AeroChecker::IsAeroEnabled() { |
62 BOOL result = FALSE; | 68 BOOL result = FALSE; |
63 if (func_) { | 69 if (func_) { |
64 func_(&result); | 70 func_(&result); |
65 } | 71 } |
66 return result != FALSE; | 72 return result != FALSE; |
67 } | 73 } |
68 | 74 |
69 } // namespace webrtc | 75 } // namespace webrtc |
OLD | NEW |