blob: 500d58d387dd22156526af2ff79f74852aec81a2 [file] [log] [blame]
jiayl@webrtc.orgc8ac17c2014-03-20 00:06:41 +00001/*
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 Lemurc20978e2017-07-06 19:44:34 +020014#include "webrtc/rtc_base/constructormagic.h"
jiayl@webrtc.orgc8ac17c2014-03-20 00:06:41 +000015
16namespace webrtc {
17
Zijie Hef9d7eca2017-08-22 14:18:37 -070018// 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.
21bool GetWindowRect(HWND window, DesktopRect* result);
22
23// Outputs the window rect, with the left/right/bottom frame border cropped if
jiayl@webrtc.orgc8ac17c2014-03-20 00:06:41 +000024// 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 He74544f92017-07-24 16:52:17 -070026// 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 Hef9d7eca2017-08-22 14:18:37 -070028// (0, 0). |original_rect| can be nullptr.
Zijie He4fe66072017-08-30 16:58:14 -070029//
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.orgc8ac17c2014-03-20 00:06:41 +000037bool GetCroppedWindowRect(HWND window,
38 DesktopRect* cropped_rect,
39 DesktopRect* original_rect);
40
Zijie Hef9d7eca2017-08-22 14:18:37 -070041// 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.
46bool GetWindowContentRect(HWND window, DesktopRect* result);
47
Zijie Hedab31ce2017-08-23 11:21:09 -070048// Returns the region type of the |window| and fill |rect| with the region of
49// |window| if region type is SIMPLEREGION.
50int GetWindowRegionTypeWithBoundary(HWND window, DesktopRect* result);
51
Zijie Heaf5686a2017-08-25 11:36:52 -070052// Retrieves the size of the |hdc|. This function returns false if native APIs
53// fail.
54bool GetDcSize(HDC hdc, DesktopSize* size);
55
Zijie He4fe66072017-08-30 16:58:14 -070056// Retrieves whether the |window| is maximized and stores in |result|. This
57// function returns false if native APIs fail.
58bool IsWindowMaximized(HWND window, bool* result);
59
Jiayang Liud848d5e2015-07-16 08:49:38 -070060typedef HRESULT (WINAPI *DwmIsCompositionEnabledFunc)(BOOL* enabled);
61class AeroChecker {
62 public:
63 AeroChecker();
64 ~AeroChecker();
65
66 bool IsAeroEnabled();
67
68 private:
69 HMODULE dwmapi_library_;
70 DwmIsCompositionEnabledFunc func_;
71
henrikg3c089d72015-09-16 05:37:44 -070072 RTC_DISALLOW_COPY_AND_ASSIGN(AeroChecker);
Jiayang Liud848d5e2015-07-16 08:49:38 -070073};
74
jiayl@webrtc.orgc8ac17c2014-03-20 00:06:41 +000075} // namespace webrtc