libdisplaydevice master
C++ library to modify display devices.
display_device::MacSettingsManager Class Reference

Default macOS implementation for the SettingsManagerInterface. More...

#include <src/macos/include/display_device/macos/settings_manager.h>

Inheritance diagram for display_device::MacSettingsManager:
[legend]
Collaboration diagram for display_device::MacSettingsManager:
[legend]

Public Member Functions

ApplyResult applySettings (const SingleDisplayConfiguration &config) override
 Apply the provided configuration to the system.
 
EnumeratedDeviceList enumAvailableDevices () const override
 Enumerate the available (active and inactive) devices.
 
const std::shared_ptr< AudioContextInterface > & getAudioContextApi () const
 Get the audio context API.
 
std::string getDisplayName (const std::string &device_id) const override
 Get the platform-specific display name associated with the device.
 
 MacSettingsManager (std::shared_ptr< MacDisplayDeviceInterface > dd_api, std::shared_ptr< AudioContextInterface > audio_context_api, std::unique_ptr< MacPersistentState > persistent_state, MacWorkarounds workarounds)
 Default constructor for the class.
 
bool resetPersistence () override
 Reset the persistence in case the settings cannot be reverted.
 
RevertResult revertSettings () override
 Revert the applied configuration and restore the previous settings.
 
- Public Member Functions inherited from display_device::SettingsManagerInterface
virtual ~SettingsManagerInterface ()=default
 Default virtual destructor.
 

Additional Inherited Members

- Public Types inherited from display_device::SettingsManagerInterface
enum class  ApplyResult {
  Ok , ApiTemporarilyUnavailable , DevicePrepFailed , PrimaryDevicePrepFailed ,
  DisplayModePrepFailed , HdrStatePrepFailed , PersistenceSaveFailed
}
 Outcome values when trying to apply settings. More...
 
enum class  RevertResult {
  Ok , ApiTemporarilyUnavailable , TopologyIsInvalid , SwitchingTopologyFailed ,
  RevertingPrimaryDeviceFailed , RevertingDisplayModesFailed , RevertingHdrStatesFailed , PersistenceSaveFailed
}
 Outcome values when trying to revert settings. More...
 

Detailed Description

Default macOS implementation for the SettingsManagerInterface.

macOS v1a supports SingleDisplayConfiguration::DevicePreparation::VerifyOnly with active-display resolution and refresh-rate changes. HDR writes and topology preparation modes such as EnsureActive, EnsurePrimary, and EnsureOnlyDisplay fail explicitly.

Constructor & Destructor Documentation

◆ MacSettingsManager()

display_device::MacSettingsManager::MacSettingsManager ( std::shared_ptr< MacDisplayDeviceInterface > dd_api,
std::shared_ptr< AudioContextInterface > audio_context_api,
std::unique_ptr< MacPersistentState > persistent_state,
MacWorkarounds workarounds )
explicit

Default constructor for the class.

Parameters
dd_apiA pointer to the macOS Display Device interface. Will throw on nullptr.
audio_context_apiOptional Audio Context interface.
persistent_stateA pointer to a class for managing persistence.
workaroundsWorkaround settings for the APIs.

Member Function Documentation

◆ applySettings()

MacSettingsManager::ApplyResult display_device::MacSettingsManager::applySettings ( const SingleDisplayConfiguration & config)
nodiscardoverridevirtual

Apply the provided configuration to the system.

Parameters
configA desired configuration for the display device.
Returns
The apply result.

*Examples**

SettingsManagerInterface* iface = getIface(...);
const auto result = iface->applySettings(config);
A class for applying and reverting display device settings.
Definition settings_manager_interface.h:14
virtual ApplyResult applySettings(const SingleDisplayConfiguration &config)=0
Apply the provided configuration to the system.
Configuration centered around a single display.
Definition types.h:216

Implements display_device::SettingsManagerInterface.

◆ enumAvailableDevices()

EnumeratedDeviceList display_device::MacSettingsManager::enumAvailableDevices ( ) const
nodiscardoverridevirtual

Enumerate the available (active and inactive) devices.

Returns
A list of available devices. Empty list can also be returned if an error has occurred.

*Examples**

const SettingsManagerInterface* iface = getIface(...);
const auto devices { iface->enumAvailableDevices() };
virtual EnumeratedDeviceList enumAvailableDevices() const =0
Enumerate the available (active and inactive) devices.

Implements display_device::SettingsManagerInterface.

◆ getAudioContextApi()

const std::shared_ptr< AudioContextInterface > & display_device::MacSettingsManager::getAudioContextApi ( ) const
nodiscard

Get the audio context API.

Returns
Audio context API.

◆ getDisplayName()

std::string display_device::MacSettingsManager::getDisplayName ( const std::string & device_id) const
nodiscardoverridevirtual

Get the platform-specific display name associated with the device.

Parameters
device_idA device to get display name for.
Returns
A display name or capture selector for the device, or an empty string if the device is inactive or not found. Empty string can also be returned if an error has occurred.

*Examples**

const std::string device_id { "MY_DEVICE_ID" };
const SettingsManagerInterface* iface = getIface(...);
const std::string display_name = iface->getDisplayName(device_id);
virtual std::string getDisplayName(const std::string &device_id) const =0
Get the platform-specific display name associated with the device.

Implements display_device::SettingsManagerInterface.

◆ resetPersistence()

bool display_device::MacSettingsManager::resetPersistence ( )
nodiscardoverridevirtual

Reset the persistence in case the settings cannot be reverted.

Returns
True if persistence was reset, false otherwise.

In case the settings cannot be reverted, because the display is turned or some other reason, this allows to "accept" the current state and start from scratch, but only if the persistence was cleared successfully.

*Examples**

SettingsManagerInterface* iface = getIface(...);
auto result = iface->applySettings(config);
if (result == ApplyResult::Ok) {
// Wait for some time
if (iface->revertSettings() != RevertResult::Ok) {
// Wait for user input
const bool user_wants_reset { true };
if (user_wants_reset) {
iface->resetPersistence();
}
}
}
virtual bool resetPersistence()=0
Reset the persistence in case the settings cannot be reverted.
virtual RevertResult revertSettings()=0
Revert the applied configuration and restore the previous settings.
@ Ok
Settings were reverted successfully.
@ Ok
Settings were applied successfully.

Implements display_device::SettingsManagerInterface.

◆ revertSettings()

MacSettingsManager::RevertResult display_device::MacSettingsManager::revertSettings ( )
nodiscardoverridevirtual

Revert the applied configuration and restore the previous settings.

Returns
True if settings were reverted or there was nothing to revert, false otherwise.

*Examples**

SettingsManagerInterface* iface = getIface(...);
const auto result = iface->revertSettings();

Implements display_device::SettingsManagerInterface.


The documentation for this class was generated from the following files: