libdisplaydevice v2026.322.2407
C++ library to modify display devices.
display_device::SettingsManager Class Reference

Default implementation for the SettingsManagerInterface. More...

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

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

Public Member Functions

ApplyResult applySettings (const SingleDisplayConfiguration &config) override
 
EnumeratedDeviceList enumAvailableDevices () const override
 
std::string getDisplayName (const std::string &device_id) const override
 
bool resetPersistence () override
 
RevertResult revertSettings () override
 
 SettingsManager (std::shared_ptr< WinDisplayDeviceInterface > dd_api, std::shared_ptr< AudioContextInterface > audio_context_api, std::unique_ptr< PersistentState > persistent_state, WinWorkarounds workarounds)
 
- Public Member Functions inherited from display_device::SettingsManagerInterface
virtual ~SettingsManagerInterface ()=default
 Default virtual destructor.
 

Protected Member Functions

bool prepareDisplayModes (const SingleDisplayConfiguration &config, const std::string &device_to_configure, const std::set< std::string > &additional_devices_to_configure, DdGuardFn &guard_fn, SingleDisplayConfigState &new_state, bool &system_settings_touched)
 Changes or restores the display modes based on the cached state, new state and configuration.
 
bool prepareHdrStates (const SingleDisplayConfiguration &config, const std::string &device_to_configure, const std::set< std::string > &additional_devices_to_configure, DdGuardFn &guard_fn, SingleDisplayConfigState &new_state, bool &system_settings_touched)
 Changes or restores the HDR states based on the cached state, new state and configuration.
 
bool preparePrimaryDevice (const SingleDisplayConfiguration &config, const std::string &device_to_configure, DdGuardFn &guard_fn, SingleDisplayConfigState &new_state, bool &system_settings_touched)
 Changes or restores the primary device based on the cached state, new state and configuration.
 
std::optional< std::tuple< SingleDisplayConfigState, std::string, std::set< std::string > > > prepareTopology (const SingleDisplayConfiguration &config, const ActiveTopology &topology_before_changes, bool &release_context, bool &system_settings_touched)
 Preps the topology so that the further settings could be applied.
 
RevertResult revertModifiedSettings (const ActiveTopology &current_topology, bool &system_settings_touched, bool *switched_topology=nullptr)
 Try to revert the modified settings.
 

Protected Attributes

std::shared_ptr< AudioContextInterfacem_audio_context_api
 
std::shared_ptr< WinDisplayDeviceInterfacem_dd_api
 
std::unique_ptr< PersistentStatem_persistence_state
 
WinWorkarounds m_workarounds
 

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 implementation for the SettingsManagerInterface.

Constructor & Destructor Documentation

◆ SettingsManager()

display_device::SettingsManager::SettingsManager ( std::shared_ptr< WinDisplayDeviceInterface > dd_api,
std::shared_ptr< AudioContextInterface > audio_context_api,
std::unique_ptr< PersistentState > persistent_state,
WinWorkarounds workarounds )
explicit

Default constructor for the class.

Parameters
dd_apiA pointer to the Windows Display Device interface. Will throw on nullptr!
audio_context_api[Optional] A pointer to the Audio Context interface.
persistent_stateA pointer to a class for managing persistence.
workaroundsWorkaround settings for the APIs.

Member Function Documentation

◆ applySettings()

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

◆ enumAvailableDevices()

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

◆ getDisplayName()

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

◆ prepareDisplayModes()

bool display_device::SettingsManager::prepareDisplayModes ( const SingleDisplayConfiguration & config,
const std::string & device_to_configure,
const std::set< std::string > & additional_devices_to_configure,
DdGuardFn & guard_fn,
SingleDisplayConfigState & new_state,
bool & system_settings_touched )
nodiscardprotected

Changes or restores the display modes based on the cached state, new state and configuration.

Parameters
configConfiguration to be used for preparing display modes.
device_to_configureThe main device to be used for preparation.
additional_devices_to_configureAdditional devices that should be configured.
guard_fnReference to the guard function which will be set to restore original state (if needed) in case something else fails down the line.
new_stateReference to the new state which is to be updated accordingly.
system_settings_touchedInticates whether a "write" operation could have been performed on the OS.
Returns
True if no errors have occured, false otherwise.

◆ prepareHdrStates()

bool display_device::SettingsManager::prepareHdrStates ( const SingleDisplayConfiguration & config,
const std::string & device_to_configure,
const std::set< std::string > & additional_devices_to_configure,
DdGuardFn & guard_fn,
SingleDisplayConfigState & new_state,
bool & system_settings_touched )
nodiscardprotected

Changes or restores the HDR states based on the cached state, new state and configuration.

Parameters
configConfiguration to be used for preparing HDR states.
device_to_configureThe main device to be used for preparation.
additional_devices_to_configureAdditional devices that should be configured.
guard_fnReference to the guard function which will be set to restore original state (if needed) in case something else fails down the line.
new_stateReference to the new state which is to be updated accordingly.
system_settings_touchedInticates whether a "write" operation could have been performed on the OS.
Returns
True if no errors have occured, false otherwise.

◆ preparePrimaryDevice()

bool display_device::SettingsManager::preparePrimaryDevice ( const SingleDisplayConfiguration & config,
const std::string & device_to_configure,
DdGuardFn & guard_fn,
SingleDisplayConfigState & new_state,
bool & system_settings_touched )
nodiscardprotected

Changes or restores the primary device based on the cached state, new state and configuration.

Parameters
configConfiguration to be used for preparing primary device.
device_to_configureThe main device to be used for preparation.
guard_fnReference to the guard function which will be set to restore original state (if needed) in case something else fails down the line.
new_stateReference to the new state which is to be updated accordingly.
system_settings_touchedInticates whether a "write" operation could have been performed on the OS.
Returns
True if no errors have occured, false otherwise.

◆ prepareTopology()

std::optional< std::tuple< SingleDisplayConfigState, std::string, std::set< std::string > > > display_device::SettingsManager::prepareTopology ( const SingleDisplayConfiguration & config,
const ActiveTopology & topology_before_changes,
bool & release_context,
bool & system_settings_touched )
nodiscardprotected

Preps the topology so that the further settings could be applied.

Parameters
configConfiguration to be used for preparing topology.
topology_before_changesThe current topology before any changes.
release_contextSpecifies whether the audio context should be released at the very end IF everything else has succeeded.
system_settings_touchedInticates whether a "write" operation could have been performed on the OS.
Returns
A tuple of (new_state that is to be updated/persisted, device_to_configure, additional_devices_to_configure).

◆ resetPersistence()

bool display_device::SettingsManager::resetPersistence ( )
nodiscardoverridevirtual

◆ revertModifiedSettings()

SettingsManager::RevertResult display_device::SettingsManager::revertModifiedSettings ( const ActiveTopology & current_topology,
bool & system_settings_touched,
bool * switched_topology = nullptr )
nodiscardprotected

Try to revert the modified settings.

Parameters
current_topologyTopology before this method is called.
system_settings_touchedIndicates whether a "write" operation could have been performed on the OS.
switched_topology[Optional] Indicates whether the current topology was switched to revert settings.
Returns
Result enum indicating success or failure.
Warning
The method assumes that the caller will ensure restoring the topology in case of a failure!

◆ revertSettings()

SettingsManager::RevertResult display_device::SettingsManager::revertSettings ( )
nodiscardoverridevirtual

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