blob: 73550ac37dadae307293cd8fd00091197990f1de [file] [log] [blame]
sergeyu@chromium.org3d34f662013-06-04 18:51:23 +00001/*
2 * Copyright (c) 2013 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#ifndef WEBRTC_MODULES_DESKTOP_CAPTURE_MAC_DESKTOP_CONFIGURATION_H_
12#define WEBRTC_MODULES_DESKTOP_CAPTURE_MAC_DESKTOP_CONFIGURATION_H_
13
14#include <ApplicationServices/ApplicationServices.h>
sergeyu@chromium.org3d34f662013-06-04 18:51:23 +000015#include <vector>
16
17#include "webrtc/typedefs.h"
18#include "webrtc/modules/desktop_capture/desktop_geometry.h"
19
20namespace webrtc {
21
22// Describes the configuration of a specific display.
23struct MacDisplayConfiguration {
24 MacDisplayConfiguration();
sergeyue1831212016-10-26 13:15:42 -070025 MacDisplayConfiguration(const MacDisplayConfiguration& other);
26 MacDisplayConfiguration(MacDisplayConfiguration&& other);
27 ~MacDisplayConfiguration();
28
29 MacDisplayConfiguration& operator=(const MacDisplayConfiguration& other);
30 MacDisplayConfiguration& operator=(MacDisplayConfiguration&& other);
sergeyu@chromium.org3d34f662013-06-04 18:51:23 +000031
32 // Cocoa identifier for this display.
sergeyue1831212016-10-26 13:15:42 -070033 CGDirectDisplayID id = 0;
sergeyu@chromium.org3d34f662013-06-04 18:51:23 +000034
35 // Bounds of this display in Density-Independent Pixels (DIPs).
36 DesktopRect bounds;
37
38 // Bounds of this display in physical pixels.
39 DesktopRect pixel_bounds;
40
41 // Scale factor from DIPs to physical pixels.
sergeyue1831212016-10-26 13:15:42 -070042 float dip_to_pixel_scale = 1.0f;
sergeyu@chromium.org3d34f662013-06-04 18:51:23 +000043};
44
45typedef std::vector<MacDisplayConfiguration> MacDisplayConfigurations;
46
47// Describes the configuration of the whole desktop.
48struct MacDesktopConfiguration {
49 // Used to request bottom-up or top-down coordinates.
50 enum Origin { BottomLeftOrigin, TopLeftOrigin };
51
52 MacDesktopConfiguration();
sergeyue1831212016-10-26 13:15:42 -070053 MacDesktopConfiguration(const MacDesktopConfiguration& other);
54 MacDesktopConfiguration(MacDesktopConfiguration&& other);
sergeyu@chromium.org3d34f662013-06-04 18:51:23 +000055 ~MacDesktopConfiguration();
56
sergeyue1831212016-10-26 13:15:42 -070057 MacDesktopConfiguration& operator=(const MacDesktopConfiguration& other);
58 MacDesktopConfiguration& operator=(MacDesktopConfiguration&& other);
59
Zijie He74544f92017-07-24 16:52:17 -070060 // Returns the desktop & display configurations.
61 // If BottomLeftOrigin is used, the output is in Cocoa-style "bottom-up"
sergeyu@chromium.org3d34f662013-06-04 18:51:23 +000062 // (the origin is the bottom-left of the primary monitor, and coordinates
Zijie He74544f92017-07-24 16:52:17 -070063 // increase as you move up the screen). Otherwise, the configuration will be
64 // converted to follow top-left coordinate system as Windows and X11.
sergeyu@chromium.org3d34f662013-06-04 18:51:23 +000065 static MacDesktopConfiguration GetCurrent(Origin origin);
66
jiayl@webrtc.orgcf1b51b2014-01-29 21:59:12 +000067 // Returns true if the given desktop configuration equals this one.
68 bool Equals(const MacDesktopConfiguration& other);
69
jiayl@webrtc.org1af5ea02014-02-01 02:03:24 +000070 // Returns the pointer to the display configuration with the specified id.
71 const MacDisplayConfiguration* FindDisplayConfigurationById(
72 CGDirectDisplayID id);
73
sergeyu@chromium.org3d9ec1f2014-04-19 00:25:35 +000074 // Bounds of the desktop excluding monitors with DPI settings different from
75 // the main monitor. In Density-Independent Pixels (DIPs).
sergeyu@chromium.org7d055a62014-04-18 23:45:38 +000076 DesktopRect bounds;
sergeyu@chromium.org3d34f662013-06-04 18:51:23 +000077
sergeyu@chromium.org3d9ec1f2014-04-19 00:25:35 +000078 // Same as bounds, but expressed in physical pixels.
sergeyu@chromium.org7d055a62014-04-18 23:45:38 +000079 DesktopRect pixel_bounds;
sergeyu@chromium.org3d34f662013-06-04 18:51:23 +000080
81 // Scale factor from DIPs to physical pixels.
sergeyue1831212016-10-26 13:15:42 -070082 float dip_to_pixel_scale = 1.0f;
sergeyu@chromium.org3d34f662013-06-04 18:51:23 +000083
84 // Configurations of the displays making up the desktop area.
85 MacDisplayConfigurations displays;
86};
87
88} // namespace webrtc
89
90#endif // WEBRTC_MODULES_DESKTOP_CAPTURE_MAC_DESKTOP_CONFIGURATION_H_