libdisplaydevice master
C++ library to modify display devices.
mac_display_device.h
Go to the documentation of this file.
1
5#pragma once
6
7// system includes
8#include <memory>
9#include <string_view>
10
11// local includes
14
15namespace display_device {
20 public:
25 explicit MacDisplayDevice(std::shared_ptr<MacApiLayerInterface> m_api);
26
30 [[nodiscard]] bool isApiAccessAvailable() const override;
31
35 [[nodiscard]] EnumeratedDeviceList enumAvailableDevices() const override;
36
40 [[nodiscard]] std::string getDisplayName(const std::string &device_id) const override;
41
45 [[nodiscard]] MacActiveTopology getCurrentTopology() const override;
46
50 [[nodiscard]] bool isTopologyValid(const MacActiveTopology &topology) const override;
51
55 [[nodiscard]] bool isTopologyTheSame(const MacActiveTopology &lhs, const MacActiveTopology &rhs) const override;
56
60 [[nodiscard]] bool setTopology(const MacActiveTopology &new_topology) override;
61
65 [[nodiscard]] MacDeviceDisplayModeMap getCurrentDisplayModes(const StringSet &device_ids) const override;
66
70 [[nodiscard]] bool setDisplayModes(const MacDeviceDisplayModeMap &modes) override;
71
75 [[nodiscard]] bool isPrimary(const std::string &device_id) const override;
76
80 [[nodiscard]] bool setAsPrimary(const std::string &device_id) override;
81
85 [[nodiscard]] MacHdrStateMap getCurrentHdrStates(const StringSet &device_ids) const override;
86
90 [[nodiscard]] bool setHdrStates(const MacHdrStateMap &states) override;
91
92 private:
99 [[nodiscard]] std::optional<MacDisplayId> getDisplayId(std::string_view device_id, MacQueryType query_type) const;
100
101 std::shared_ptr<MacApiLayerInterface> m_m_api;
102 };
103} // namespace display_device
Higher level abstracted API for interacting with macOS display devices.
Definition mac_display_device_interface.h:14
Default implementation for the MacDisplayDeviceInterface.
Definition mac_display_device.h:19
bool setDisplayModes(const MacDeviceDisplayModeMap &modes) override
Set new display modes for the devices.
Definition mac_display_device_modes.cpp:84
EnumeratedDeviceList enumAvailableDevices() const override
Enumerate the available display devices.
Definition mac_display_device_general.cpp:26
bool setAsPrimary(const std::string &device_id) override
Set the device as a primary display.
Definition mac_display_device_primary.cpp:14
bool isTopologyValid(const MacActiveTopology &topology) const override
Verify if the active topology is valid.
Definition mac_display_device_topology.cpp:44
bool isPrimary(const std::string &device_id) const override
Check whether the specified device is primary.
Definition mac_display_device_primary.cpp:9
bool setHdrStates(const MacHdrStateMap &states) override
Set HDR states for the devices.
Definition mac_display_device_hdr.cpp:21
std::string getDisplayName(const std::string &device_id) const override
Get the macOS capture selector associated with the device.
Definition mac_display_device_general.cpp:66
MacDeviceDisplayModeMap getCurrentDisplayModes(const StringSet &device_ids) const override
Get current display modes for the devices.
Definition mac_display_device_modes.cpp:58
MacActiveTopology getCurrentTopology() const override
Get the active topology.
Definition mac_display_device_topology.cpp:12
bool isApiAccessAvailable() const override
Check if the API for changing display settings is accessible.
Definition mac_display_device_general.cpp:22
MacHdrStateMap getCurrentHdrStates(const StringSet &device_ids) const override
Get HDR state for the devices.
Definition mac_display_device_hdr.cpp:12
MacDisplayDevice(std::shared_ptr< MacApiLayerInterface > m_api)
Default constructor for the class.
Definition mac_display_device_general.cpp:15
bool setTopology(const MacActiveTopology &new_topology) override
Set a new active topology.
Definition mac_display_device_topology.cpp:81
bool isTopologyTheSame(const MacActiveTopology &lhs, const MacActiveTopology &rhs) const override
Check if the topologies are close enough to be considered the same by macOS.
Definition mac_display_device_topology.cpp:65
std::vector< EnumeratedDevice > EnumeratedDeviceList
A list of EnumeratedDevice objects.
Definition types.h:208
std::set< std::string, std::less<> > StringSet
Ordered set keyed by strings with transparent comparisons.
Definition types.h:46
Declarations for the MacApiLayerInterface.
Declarations for the MacDisplayDeviceInterface.
StringMap< std::optional< HdrState > > MacHdrStateMap
Ordered map of [DEVICE_ID -> std::optional<HdrState>].
Definition types.h:87
StringMap< MacDisplayMode > MacDeviceDisplayModeMap
Ordered map of [DEVICE_ID -> MacDisplayMode].
Definition types.h:82
MacQueryType
Type of display list to query from macOS.
Definition types.h:48
std::vector< std::vector< std::string > > MacActiveTopology
A LIST[LIST[DEVICE_ID]] structure which represents active macOS display topology.
Definition types.h:59