desktop_configuration.h 3.4 KB

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