• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 MODULES_DESKTOP_CAPTURE_MAC_DESKTOP_CONFIGURATION_H_
12 #define MODULES_DESKTOP_CAPTURE_MAC_DESKTOP_CONFIGURATION_H_
13 
14 #include <ApplicationServices/ApplicationServices.h>
15 
16 #include <vector>
17 
18 #include "modules/desktop_capture/desktop_geometry.h"
19 #include "rtc_base/system/rtc_export.h"
20 
21 namespace webrtc {
22 
23 // Describes the configuration of a specific display.
24 struct MacDisplayConfiguration {
25   MacDisplayConfiguration();
26   MacDisplayConfiguration(const MacDisplayConfiguration& other);
27   MacDisplayConfiguration(MacDisplayConfiguration&& other);
28   ~MacDisplayConfiguration();
29 
30   MacDisplayConfiguration& operator=(const MacDisplayConfiguration& other);
31   MacDisplayConfiguration& operator=(MacDisplayConfiguration&& other);
32 
33   // Cocoa identifier for this display.
34   CGDirectDisplayID id = 0;
35 
36   // Bounds of this display in Density-Independent Pixels (DIPs).
37   DesktopRect bounds;
38 
39   // Bounds of this display in physical pixels.
40   DesktopRect pixel_bounds;
41 
42   // Scale factor from DIPs to physical pixels.
43   float dip_to_pixel_scale = 1.0f;
44 
45   // Display type, built-in or external.
46   bool is_builtin;
47 };
48 
49 typedef std::vector<MacDisplayConfiguration> MacDisplayConfigurations;
50 
51 // Describes the configuration of the whole desktop.
52 struct RTC_EXPORT MacDesktopConfiguration {
53   // Used to request bottom-up or top-down coordinates.
54   enum Origin { BottomLeftOrigin, TopLeftOrigin };
55 
56   MacDesktopConfiguration();
57   MacDesktopConfiguration(const MacDesktopConfiguration& other);
58   MacDesktopConfiguration(MacDesktopConfiguration&& other);
59   ~MacDesktopConfiguration();
60 
61   MacDesktopConfiguration& operator=(const MacDesktopConfiguration& other);
62   MacDesktopConfiguration& operator=(MacDesktopConfiguration&& other);
63 
64   // Returns the desktop & display configurations.
65   // If BottomLeftOrigin is used, the output is in Cocoa-style "bottom-up"
66   // (the origin is the bottom-left of the primary monitor, and coordinates
67   // increase as you move up the screen). Otherwise, the configuration will be
68   // converted to follow top-left coordinate system as Windows and X11.
69   static MacDesktopConfiguration GetCurrent(Origin origin);
70 
71   // Returns true if the given desktop configuration equals this one.
72   bool Equals(const MacDesktopConfiguration& other);
73 
74   // If |id| corresponds to the built-in display, return its configuration,
75   // otherwise return the configuration for the display with the specified id,
76   // or nullptr if no such display exists.
77   const MacDisplayConfiguration* FindDisplayConfigurationById(
78       CGDirectDisplayID id);
79 
80   // Bounds of the desktop excluding monitors with DPI settings different from
81   // the main monitor. In Density-Independent Pixels (DIPs).
82   DesktopRect bounds;
83 
84   // Same as bounds, but expressed in physical pixels.
85   DesktopRect pixel_bounds;
86 
87   // Scale factor from DIPs to physical pixels.
88   float dip_to_pixel_scale = 1.0f;
89 
90   // Configurations of the displays making up the desktop area.
91   MacDisplayConfigurations displays;
92 };
93 
94 }  // namespace webrtc
95 
96 #endif  // MODULES_DESKTOP_CAPTURE_MAC_DESKTOP_CONFIGURATION_H_
97