sergeyu@chromium.org | 3d34f66 | 2013-06-04 18:51:23 +0000 | [diff] [blame] | 1 | /* |
| 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.org | 3d34f66 | 2013-06-04 18:51:23 +0000 | [diff] [blame] | 15 | #include <vector> |
| 16 | |
| 17 | #include "webrtc/typedefs.h" |
| 18 | #include "webrtc/modules/desktop_capture/desktop_geometry.h" |
| 19 | |
| 20 | namespace webrtc { |
| 21 | |
| 22 | // Describes the configuration of a specific display. |
| 23 | struct MacDisplayConfiguration { |
| 24 | MacDisplayConfiguration(); |
sergeyu | e183121 | 2016-10-26 13:15:42 -0700 | [diff] [blame] | 25 | MacDisplayConfiguration(const MacDisplayConfiguration& other); |
| 26 | MacDisplayConfiguration(MacDisplayConfiguration&& other); |
| 27 | ~MacDisplayConfiguration(); |
| 28 | |
| 29 | MacDisplayConfiguration& operator=(const MacDisplayConfiguration& other); |
| 30 | MacDisplayConfiguration& operator=(MacDisplayConfiguration&& other); |
sergeyu@chromium.org | 3d34f66 | 2013-06-04 18:51:23 +0000 | [diff] [blame] | 31 | |
| 32 | // Cocoa identifier for this display. |
sergeyu | e183121 | 2016-10-26 13:15:42 -0700 | [diff] [blame] | 33 | CGDirectDisplayID id = 0; |
sergeyu@chromium.org | 3d34f66 | 2013-06-04 18:51:23 +0000 | [diff] [blame] | 34 | |
| 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. |
sergeyu | e183121 | 2016-10-26 13:15:42 -0700 | [diff] [blame] | 42 | float dip_to_pixel_scale = 1.0f; |
sergeyu@chromium.org | 3d34f66 | 2013-06-04 18:51:23 +0000 | [diff] [blame] | 43 | }; |
| 44 | |
| 45 | typedef std::vector<MacDisplayConfiguration> MacDisplayConfigurations; |
| 46 | |
| 47 | // Describes the configuration of the whole desktop. |
| 48 | struct MacDesktopConfiguration { |
| 49 | // Used to request bottom-up or top-down coordinates. |
| 50 | enum Origin { BottomLeftOrigin, TopLeftOrigin }; |
| 51 | |
| 52 | MacDesktopConfiguration(); |
sergeyu | e183121 | 2016-10-26 13:15:42 -0700 | [diff] [blame] | 53 | MacDesktopConfiguration(const MacDesktopConfiguration& other); |
| 54 | MacDesktopConfiguration(MacDesktopConfiguration&& other); |
sergeyu@chromium.org | 3d34f66 | 2013-06-04 18:51:23 +0000 | [diff] [blame] | 55 | ~MacDesktopConfiguration(); |
| 56 | |
sergeyu | e183121 | 2016-10-26 13:15:42 -0700 | [diff] [blame] | 57 | MacDesktopConfiguration& operator=(const MacDesktopConfiguration& other); |
| 58 | MacDesktopConfiguration& operator=(MacDesktopConfiguration&& other); |
| 59 | |
Zijie He | 74544f9 | 2017-07-24 16:52:17 -0700 | [diff] [blame] | 60 | // Returns the desktop & display configurations. |
| 61 | // If BottomLeftOrigin is used, the output is in Cocoa-style "bottom-up" |
sergeyu@chromium.org | 3d34f66 | 2013-06-04 18:51:23 +0000 | [diff] [blame] | 62 | // (the origin is the bottom-left of the primary monitor, and coordinates |
Zijie He | 74544f9 | 2017-07-24 16:52:17 -0700 | [diff] [blame] | 63 | // 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.org | 3d34f66 | 2013-06-04 18:51:23 +0000 | [diff] [blame] | 65 | static MacDesktopConfiguration GetCurrent(Origin origin); |
| 66 | |
jiayl@webrtc.org | cf1b51b | 2014-01-29 21:59:12 +0000 | [diff] [blame] | 67 | // Returns true if the given desktop configuration equals this one. |
| 68 | bool Equals(const MacDesktopConfiguration& other); |
| 69 | |
jiayl@webrtc.org | 1af5ea0 | 2014-02-01 02:03:24 +0000 | [diff] [blame] | 70 | // Returns the pointer to the display configuration with the specified id. |
| 71 | const MacDisplayConfiguration* FindDisplayConfigurationById( |
| 72 | CGDirectDisplayID id); |
| 73 | |
sergeyu@chromium.org | 3d9ec1f | 2014-04-19 00:25:35 +0000 | [diff] [blame] | 74 | // Bounds of the desktop excluding monitors with DPI settings different from |
| 75 | // the main monitor. In Density-Independent Pixels (DIPs). |
sergeyu@chromium.org | 7d055a6 | 2014-04-18 23:45:38 +0000 | [diff] [blame] | 76 | DesktopRect bounds; |
sergeyu@chromium.org | 3d34f66 | 2013-06-04 18:51:23 +0000 | [diff] [blame] | 77 | |
sergeyu@chromium.org | 3d9ec1f | 2014-04-19 00:25:35 +0000 | [diff] [blame] | 78 | // Same as bounds, but expressed in physical pixels. |
sergeyu@chromium.org | 7d055a6 | 2014-04-18 23:45:38 +0000 | [diff] [blame] | 79 | DesktopRect pixel_bounds; |
sergeyu@chromium.org | 3d34f66 | 2013-06-04 18:51:23 +0000 | [diff] [blame] | 80 | |
| 81 | // Scale factor from DIPs to physical pixels. |
sergeyu | e183121 | 2016-10-26 13:15:42 -0700 | [diff] [blame] | 82 | float dip_to_pixel_scale = 1.0f; |
sergeyu@chromium.org | 3d34f66 | 2013-06-04 18:51:23 +0000 | [diff] [blame] | 83 | |
| 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_ |