libdisplaydevice v2026.322.2407
C++ library to modify display devices.
settings_manager.h
Go to the documentation of this file.
1
5#pragma once
6
7// system includes
8#include <memory>
9
10// local includes
14#include "persistent_state.h"
15
16namespace display_device {
21 public:
29 explicit SettingsManager(
30 std::shared_ptr<WinDisplayDeviceInterface> dd_api,
31 std::shared_ptr<AudioContextInterface> audio_context_api,
32 std::unique_ptr<PersistentState> persistent_state,
33 WinWorkarounds workarounds
34 );
35
37 [[nodiscard]] EnumeratedDeviceList enumAvailableDevices() const override;
38
40 [[nodiscard]] std::string getDisplayName(const std::string &device_id) const override;
41
43 [[nodiscard]] ApplyResult applySettings(const SingleDisplayConfiguration &config) override;
44
46 [[nodiscard]] RevertResult revertSettings() override;
47
49 [[nodiscard]] bool resetPersistence() override;
50
51 protected:
60 [[nodiscard]] 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);
61
71 [[nodiscard]] bool preparePrimaryDevice(const SingleDisplayConfiguration &config, const std::string &device_to_configure, DdGuardFn &guard_fn, SingleDisplayConfigState &new_state, bool &system_settings_touched);
72
83 [[nodiscard]] 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);
84
95 [[nodiscard]] 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);
96
106 [[nodiscard]] RevertResult revertModifiedSettings(const ActiveTopology &current_topology, bool &system_settings_touched, bool *switched_topology = nullptr);
107
108 std::shared_ptr<WinDisplayDeviceInterface> m_dd_api;
109 std::shared_ptr<AudioContextInterface> m_audio_context_api;
110 std::unique_ptr<PersistentState> m_persistence_state;
111 WinWorkarounds m_workarounds;
112 };
113} // namespace display_device
Declarations for the AudioContextInterface.
A class for applying and reverting display device settings.
Definition settings_manager_interface.h:14
RevertResult
Outcome values when trying to revert settings.
Definition settings_manager_interface.h:32
ApplyResult
Outcome values when trying to apply settings.
Definition settings_manager_interface.h:19
Default implementation for the SettingsManagerInterface.
Definition settings_manager.h:20
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.
Definition settings_manager_apply.cpp:121
ApplyResult applySettings(const SingleDisplayConfiguration &config) override
Definition settings_manager_apply.cpp:26
SettingsManager(std::shared_ptr< WinDisplayDeviceInterface > dd_api, std::shared_ptr< AudioContextInterface > audio_context_api, std::unique_ptr< PersistentState > persistent_state, WinWorkarounds workarounds)
Definition settings_manager_general.cpp:14
RevertResult revertModifiedSettings(const ActiveTopology &current_topology, bool &system_settings_touched, bool *switched_topology=nullptr)
Try to revert the modified settings.
Definition settings_manager_revert.cpp:101
EnumeratedDeviceList enumAvailableDevices() const override
Definition settings_manager_general.cpp:40
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.
Definition settings_manager_apply.cpp:209
std::string getDisplayName(const std::string &device_id) const override
Definition settings_manager_general.cpp:44
bool resetPersistence() override
Definition settings_manager_general.cpp:48
RevertResult revertSettings() override
Definition settings_manager_revert.cpp:25
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.
Definition settings_manager_apply.cpp:265
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.
Definition settings_manager_apply.cpp:326
std::vector< EnumeratedDevice > EnumeratedDeviceList
A list of EnumeratedDevice objects.
Definition types.h:124
Declarations for the PersistentState.
Declarations for the SettingsManagerInterface.
Arbitrary data for making and undoing changes.
Definition types.h:114
Configuration centered around a single display.
Definition types.h:132
Settings for workarounds/hacks for Windows.
Definition types.h:174
Declarations for the WinDisplayDeviceInterface.
std::vector< std::vector< std::string > > ActiveTopology
A LIST[LIST[DEVICE_ID]] structure which represents an active topology.
Definition types.h:86
std::function< void()> DdGuardFn
Default function type used for cleanup/guard functions.
Definition types.h:169