jiayl@webrtc.org | c8ac17c | 2014-03-20 00:06:41 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2014 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 <windows.h> |
| 12 | |
| 13 | #include "webrtc/modules/desktop_capture/desktop_geometry.h" |
Edward Lemur | c20978e | 2017-07-06 19:44:34 +0200 | [diff] [blame] | 14 | #include "webrtc/rtc_base/constructormagic.h" |
jiayl@webrtc.org | c8ac17c | 2014-03-20 00:06:41 +0000 | [diff] [blame] | 15 | |
| 16 | namespace webrtc { |
| 17 | |
Zijie He | f9d7eca | 2017-08-22 14:18:37 -0700 | [diff] [blame] | 18 | // Outputs the window rect. The returned DesktopRect is in system coordinates, |
| 19 | // i.e. the primary monitor on the system always starts from (0, 0). This |
| 20 | // function returns false if native APIs fail. |
| 21 | bool GetWindowRect(HWND window, DesktopRect* result); |
| 22 | |
| 23 | // Outputs the window rect, with the left/right/bottom frame border cropped if |
jiayl@webrtc.org | c8ac17c | 2014-03-20 00:06:41 +0000 | [diff] [blame] | 24 | // the window is maximized. |cropped_rect| is the cropped rect relative to the |
| 25 | // desktop. |original_rect| is the original rect returned from GetWindowRect. |
Zijie He | 74544f9 | 2017-07-24 16:52:17 -0700 | [diff] [blame] | 26 | // Returns true if all API calls succeeded. The returned DesktopRect is in |
| 27 | // system coordinates, i.e. the primary monitor on the system always starts from |
Zijie He | f9d7eca | 2017-08-22 14:18:37 -0700 | [diff] [blame] | 28 | // (0, 0). |original_rect| can be nullptr. |
Zijie He | 4fe6607 | 2017-08-30 16:58:14 -0700 | [diff] [blame] | 29 | // |
| 30 | // TODO(zijiehe): Move this function to CroppingWindowCapturerWin after it has |
| 31 | // been removed from MouseCursorMonitorWin. |
| 32 | // This function should only be used by CroppingWindowCapturerWin. Instead a |
| 33 | // DesktopRect CropWindowRect(const DesktopRect& rect) |
| 34 | // should be added as a utility function to help CroppingWindowCapturerWin and |
| 35 | // WindowCapturerWin to crop out the borders or shadow according to their |
| 36 | // scenarios. But this function is too generic and easy to be misused. |
jiayl@webrtc.org | c8ac17c | 2014-03-20 00:06:41 +0000 | [diff] [blame] | 37 | bool GetCroppedWindowRect(HWND window, |
| 38 | DesktopRect* cropped_rect, |
| 39 | DesktopRect* original_rect); |
| 40 | |
Zijie He | f9d7eca | 2017-08-22 14:18:37 -0700 | [diff] [blame] | 41 | // Retrieves the rectangle of the content area of |window|. Usually it contains |
| 42 | // title bar and window client area, but borders or shadow are excluded. The |
| 43 | // returned DesktopRect is in system coordinates, i.e. the primary monitor on |
| 44 | // the system always starts from (0, 0). This function returns false if native |
| 45 | // APIs fail. |
| 46 | bool GetWindowContentRect(HWND window, DesktopRect* result); |
| 47 | |
Zijie He | dab31ce | 2017-08-23 11:21:09 -0700 | [diff] [blame] | 48 | // Returns the region type of the |window| and fill |rect| with the region of |
| 49 | // |window| if region type is SIMPLEREGION. |
| 50 | int GetWindowRegionTypeWithBoundary(HWND window, DesktopRect* result); |
| 51 | |
Zijie He | af5686a | 2017-08-25 11:36:52 -0700 | [diff] [blame] | 52 | // Retrieves the size of the |hdc|. This function returns false if native APIs |
| 53 | // fail. |
| 54 | bool GetDcSize(HDC hdc, DesktopSize* size); |
| 55 | |
Zijie He | 4fe6607 | 2017-08-30 16:58:14 -0700 | [diff] [blame] | 56 | // Retrieves whether the |window| is maximized and stores in |result|. This |
| 57 | // function returns false if native APIs fail. |
| 58 | bool IsWindowMaximized(HWND window, bool* result); |
| 59 | |
Jiayang Liu | d848d5e | 2015-07-16 08:49:38 -0700 | [diff] [blame] | 60 | typedef HRESULT (WINAPI *DwmIsCompositionEnabledFunc)(BOOL* enabled); |
| 61 | class AeroChecker { |
| 62 | public: |
| 63 | AeroChecker(); |
| 64 | ~AeroChecker(); |
| 65 | |
| 66 | bool IsAeroEnabled(); |
| 67 | |
| 68 | private: |
| 69 | HMODULE dwmapi_library_; |
| 70 | DwmIsCompositionEnabledFunc func_; |
| 71 | |
henrikg | 3c089d7 | 2015-09-16 05:37:44 -0700 | [diff] [blame] | 72 | RTC_DISALLOW_COPY_AND_ASSIGN(AeroChecker); |
Jiayang Liu | d848d5e | 2015-07-16 08:49:38 -0700 | [diff] [blame] | 73 | }; |
| 74 | |
jiayl@webrtc.org | c8ac17c | 2014-03-20 00:06:41 +0000 | [diff] [blame] | 75 | } // namespace webrtc |