![]() |
libdisplaydevice latest
C++ library to modify display devices.
|
Shared "utility-level" code for Settings. More...
Functions | |
| void | blankHdrStates (WinDisplayDeviceInterface &win_dd, const std::optional< std::chrono::milliseconds > &delay) |
| Toggle enabled HDR states off and on again if quick succession. | |
| PathSourceIndexDataMap | collectSourceDataForMatchingPaths (const WinApiLayerInterface &w_api, const std::vector< DISPLAYCONFIG_PATH_INFO > &paths) |
| Collect arbitrary source data from provided paths. | |
| std::optional< SingleDisplayConfigState::Initial > | computeInitialState (const std::optional< SingleDisplayConfigState::Initial > &prev_state, const ActiveTopology &topology_before_changes, const EnumeratedDeviceList &devices) |
| Compute the new intial state from arbitrary data. | |
| DeviceDisplayModeMap | computeNewDisplayModes (const std::optional< Resolution > &resolution, const std::optional< FloatingPoint > &refresh_rate, bool configuring_primary_devices, const std::string &device_to_configure, const std::set< std::string > &additional_devices_to_configure, const DeviceDisplayModeMap &original_modes) |
| Compute new display modes from arbitrary data. | |
| HdrStateMap | computeNewHdrStates (const std::optional< HdrState > &hdr_state, bool configuring_primary_devices, const std::string &device_to_configure, const std::set< std::string > &additional_devices_to_configure, const HdrStateMap &original_states) |
| Compute new HDR states from arbitrary data. | |
| ActiveTopology | computeNewTopology (SingleDisplayConfiguration::DevicePreparation device_prep, bool configuring_primary_devices, const std::string &device_to_configure, const std::set< std::string > &additional_devices_to_configure, const ActiveTopology &initial_topology) |
| Compute new topology from arbitrary data. | |
| std::tuple< ActiveTopology, std::string, std::set< std::string > > | computeNewTopologyAndMetadata (SingleDisplayConfiguration::DevicePreparation device_prep, const std::string &device_id, const SingleDisplayConfigState::Initial &initial_state) |
| Compute new topology + metadata from config settings and initial state. | |
| ActiveTopology | createFullExtendedTopology (WinDisplayDeviceInterface &win_dd) |
| Create extended topology from all the available devices. | |
| std::set< std::string > | flattenTopology (const ActiveTopology &topology) |
| Get all the device ids in the topology. | |
| bool | fuzzyCompareModes (const DisplayMode &lhs, const DisplayMode &rhs) |
| Check if the display modes are almost equal. | |
| bool | fuzzyCompareRefreshRates (const Rational &lhs, const Rational &rhs) |
| Check if the refresh rates are almost equal. | |
| const DISPLAYCONFIG_PATH_INFO * | getActivePath (const WinApiLayerInterface &w_api, const std::string &device_id, const std::vector< DISPLAYCONFIG_PATH_INFO > &paths) |
| Get the active path matching the device id. | |
| DISPLAYCONFIG_PATH_INFO * | getActivePath (const WinApiLayerInterface &w_api, const std::string &device_id, std::vector< DISPLAYCONFIG_PATH_INFO > &paths) |
| std::set< std::string > | getAllDeviceIdsAndMatchingDuplicates (const WinApiLayerInterface &w_api, const std::set< std::string > &device_ids) |
| Get all the missing duplicate device ids for the provided device ids. | |
| std::optional< ValidatedDeviceInfo > | getDeviceInfoForValidPath (const WinApiLayerInterface &w_api, const DISPLAYCONFIG_PATH_INFO &path, ValidatedPathType type) |
| Validate the path and get the commonly used information from it. | |
| std::string | getPrimaryDevice (WinDisplayDeviceInterface &win_dd, const ActiveTopology &topology) |
| Get one primary device from the provided topology. | |
| std::optional< UINT32 > | getSourceIndex (const DISPLAYCONFIG_PATH_INFO &path, const std::vector< DISPLAYCONFIG_MODE_INFO > &modes) |
| Get the source mode index from the path. | |
| const DISPLAYCONFIG_SOURCE_MODE * | getSourceMode (const std::optional< UINT32 > &index, const std::vector< DISPLAYCONFIG_MODE_INFO > &modes) |
| Get the source mode from the list at the specified index. | |
| DISPLAYCONFIG_SOURCE_MODE * | getSourceMode (const std::optional< UINT32 > &index, std::vector< DISPLAYCONFIG_MODE_INFO > &modes) |
| DdGuardFn | hdrStateGuardFn (WinDisplayDeviceInterface &win_dd, const ActiveTopology &topology) |
| Make guard function for the HDR states. | |
| DdGuardFn | hdrStateGuardFn (WinDisplayDeviceInterface &win_dd, const HdrStateMap &states) |
| Make guard function for the HDR states. | |
| bool | isActive (const DISPLAYCONFIG_PATH_INFO &path) |
| Check if the display device path is marked as active. | |
| bool | isAvailable (const DISPLAYCONFIG_PATH_INFO &path) |
| Check if the display device path's target is available. | |
| bool | isPrimary (const DISPLAYCONFIG_SOURCE_MODE &mode) |
| Check if the display's source mode is primary - if the associated device is a primary display device. | |
| std::vector< DISPLAYCONFIG_PATH_INFO > | makePathsForNewTopology (const ActiveTopology &new_topology, const PathSourceIndexDataMap &path_source_data, const std::vector< DISPLAYCONFIG_PATH_INFO > &paths) |
| Select the best possible paths to be used for the requested topology based on the data that is available to us. | |
| DdGuardFn | modeGuardFn (WinDisplayDeviceInterface &win_dd, const ActiveTopology &topology) |
| Make guard function for the display modes. | |
| DdGuardFn | modeGuardFn (WinDisplayDeviceInterface &win_dd, const DeviceDisplayModeMap &modes) |
| Make guard function for the display modes. | |
| DdGuardFn | primaryGuardFn (WinDisplayDeviceInterface &win_dd, const ActiveTopology &topology) |
| Make guard function for the primary display. | |
| DdGuardFn | primaryGuardFn (WinDisplayDeviceInterface &win_dd, const std::string &primary_device) |
| Make guard function for the primary display. | |
| void | setActive (DISPLAYCONFIG_PATH_INFO &path) |
| Mark the display device path as active. | |
| void | setCloneGroupId (DISPLAYCONFIG_PATH_INFO &path, const std::optional< UINT32 > &id) |
| Set the clone group id in the path. | |
| void | setDesktopIndex (DISPLAYCONFIG_PATH_INFO &path, const std::optional< UINT32 > &index) |
| Set the desktop mode index in the path. | |
| void | setSourceIndex (DISPLAYCONFIG_PATH_INFO &path, const std::optional< UINT32 > &index) |
| Set the source mode index in the path. | |
| void | setTargetIndex (DISPLAYCONFIG_PATH_INFO &path, const std::optional< UINT32 > &index) |
| Set the target mode index in the path. | |
| std::optional< SingleDisplayConfigState::Initial > | stripInitialState (const SingleDisplayConfigState::Initial &initial_state, const EnumeratedDeviceList &devices) |
| Strip the initial state of non-existing devices. | |
| DdGuardFn | topologyGuardFn (WinDisplayDeviceInterface &win_dd, const ActiveTopology &topology) |
| Make guard function for the topology. | |
Shared "utility-level" code for Settings.
Shared "utility-level" code for Windows.
| void display_device::win_utils::blankHdrStates | ( | WinDisplayDeviceInterface & | win_dd, |
| const std::optional< std::chrono::milliseconds > & | delay ) |
Toggle enabled HDR states off and on again if quick succession.
This is a workaround for a HDR highcontrast color bug which prominently happens for IDD HDR displays, but also sometimes (very VERY rarely) for dongles.
The bug is cause my more or less any change to the display settings, such as enabling HDR display, enabling HDR state, changing display mode of OTHER device and so on.
The workaround is to simply turn of HDR, wait a little and then turn it back on.
This is what this function does, but only if there are HDR enabled displays at the moment.
| win_dd | Interface for interacting with the OS. |
| delay | Delay between OFF and ON states (ON -> OFF -> DELAY -> ON). If null optional is provided, the function does nothing. |
|
nodiscard |
Collect arbitrary source data from provided paths.
This function filters paths that can be used later on and collects for a quick lookup.
| w_api | Reference to the Windows API layer. |
| paths | List of paths. |
*Examples**
| std::optional< SingleDisplayConfigState::Initial > display_device::win_utils::computeInitialState | ( | const std::optional< SingleDisplayConfigState::Initial > & | prev_state, |
| const ActiveTopology & | topology_before_changes, | ||
| const EnumeratedDeviceList & | devices ) |
Compute the new intial state from arbitrary data.
| prev_state | Previous initial state if available. |
| topology_before_changes | Topology before any changes were made. |
| devices | Currently available device list. |
*Examples**
| DeviceDisplayModeMap display_device::win_utils::computeNewDisplayModes | ( | const std::optional< Resolution > & | resolution, |
| const std::optional< FloatingPoint > & | refresh_rate, | ||
| bool | configuring_primary_devices, | ||
| const std::string & | device_to_configure, | ||
| const std::set< std::string > & | additional_devices_to_configure, | ||
| const DeviceDisplayModeMap & | original_modes ) |
Compute new display modes from arbitrary data.
| resolution | Specify resolution that should be used to override the original modes. |
| refresh_rate | Specify refresh rate that should be used to override the original modes. |
| configuring_primary_devices | Specify whether the device_to_configure was unspecified (primary device was selected). |
| device_to_configure | Main device to be configured. |
| additional_devices_to_configure | Additional devices that belong to the same group as device_to_configure. |
| original_modes | Display modes to be used as a base onto which changes are made. |
| HdrStateMap display_device::win_utils::computeNewHdrStates | ( | const std::optional< HdrState > & | hdr_state, |
| bool | configuring_primary_devices, | ||
| const std::string & | device_to_configure, | ||
| const std::set< std::string > & | additional_devices_to_configure, | ||
| const HdrStateMap & | original_states ) |
Compute new HDR states from arbitrary data.
| hdr_state | Specify state that should be used to override the original states. |
| configuring_primary_devices | Specify whether the device_to_configure was unspecified (primary device was selected). |
| device_to_configure | Main device to be configured. |
| additional_devices_to_configure | Additional devices that belong to the same group as device_to_configure. |
| original_states | HDR states to be used as a base onto which changes are made. |
| ActiveTopology display_device::win_utils::computeNewTopology | ( | SingleDisplayConfiguration::DevicePreparation | device_prep, |
| bool | configuring_primary_devices, | ||
| const std::string & | device_to_configure, | ||
| const std::set< std::string > & | additional_devices_to_configure, | ||
| const ActiveTopology & | initial_topology ) |
Compute new topology from arbitrary data.
| device_prep | Specify how to compute the new topology. |
| configuring_primary_devices | Specify whether the device_to_configure was unspecified (primary device was selected). |
| device_to_configure | Main device to be configured. |
| additional_devices_to_configure | Additional devices that belong to the same group as device_to_configure. |
| initial_topology | The initial topology from computeInitialState(...). |
| std::tuple< ActiveTopology, std::string, std::set< std::string > > display_device::win_utils::computeNewTopologyAndMetadata | ( | SingleDisplayConfiguration::DevicePreparation | device_prep, |
| const std::string & | device_id, | ||
| const SingleDisplayConfigState::Initial & | initial_state ) |
Compute new topology + metadata from config settings and initial state.
| device_prep | Specify how to to compute the new topology. |
| device_id | Specify which device whould be used for computation (can be empty if primary device should be used). |
| initial_state | The initial topology from computeInitialState(...) or stripInitialState(...) (or both). |
| ActiveTopology display_device::win_utils::createFullExtendedTopology | ( | WinDisplayDeviceInterface & | win_dd | ) |
Create extended topology from all the available devices.
| win_dd | Interface for interacting with the OS. |
*Examples**
| std::set< std::string > display_device::win_utils::flattenTopology | ( | const ActiveTopology & | topology | ) |
Get all the device ids in the topology.
| topology | Topology to be "flattened". |
*Examples**
|
nodiscard |
Check if the display modes are almost equal.
| lhs | First mode. |
| rhs | Second mode. |
*Examples**
|
nodiscard |
Check if the refresh rates are almost equal.
| lhs | First refresh rate. |
| rhs | Second refresh rate. |
*Examples**
|
nodiscard |
Get the active path matching the device id.
| w_api | Reference to the Windows API layer. |
| device_id | Id to search for in the the list. |
| paths | List to be searched. |
*Examples**
|
nodiscard |
|
nodiscard |
Get all the missing duplicate device ids for the provided device ids.
| w_api | Reference to the Windows API layer. |
| device_ids | Device ids to find the missing duplicate ids for. |
*Examples**
|
nodiscard |
Validate the path and get the commonly used information from it.
This a convenience function to ensure that our concept of "valid path" remains the same throughout the code.
Currently, for use, a valid path is:
| w_api | Reference to the Windows API layer. |
| path | Path to validate and get info for. |
| type | Additional constraints for the path. |
*Examples**
| std::string display_device::win_utils::getPrimaryDevice | ( | WinDisplayDeviceInterface & | win_dd, |
| const ActiveTopology & | topology ) |
Get one primary device from the provided topology.
| win_dd | Interface for interacting with the OS. |
| topology | Topology to be searched. |
*Examples**
|
nodiscard |
Get the source mode index from the path.
It performs sanity checks on the modes list that the index is indeed correct.
| path | Path to get the source mode index for. |
| modes | A list of various modes (source, target, desktop and probably more in the future). |
*Examples**
|
nodiscard |
Get the source mode from the list at the specified index.
This function does additional sanity checks for the modes list and ensures that the mode at the specified index is indeed a source mode.
| index | Index to get the mode for. It is of boost::optional type as the function is intended to be used with getSourceIndex function. |
| modes | List to get the mode from. |
*Examples**
|
nodiscard |
| DdGuardFn display_device::win_utils::hdrStateGuardFn | ( | WinDisplayDeviceInterface & | win_dd, |
| const ActiveTopology & | topology ) |
Make guard function for the HDR states.
| win_dd | Interface for interacting with the OS. |
| topology | Topology to be used when making a guard. |
*Examples**
| DdGuardFn display_device::win_utils::hdrStateGuardFn | ( | WinDisplayDeviceInterface & | win_dd, |
| const HdrStateMap & | states ) |
Make guard function for the HDR states.
| win_dd | Interface for interacting with the OS. |
| states | HDR states to restore when the guard is executed. |
*Examples**
|
nodiscard |
Check if the display device path is marked as active.
| path | Path to check. |
*Examples**
|
nodiscard |
Check if the display device path's target is available.
In most cases this this would mean physically connected to the system, but it also possible force the path to persist. It is not clear if it be counted as available or not.
| path | Path to check. |
*Examples**
| bool display_device::win_utils::isPrimary | ( | const DISPLAYCONFIG_SOURCE_MODE & | mode | ) |
Check if the display's source mode is primary - if the associated device is a primary display device.
| mode | Mode to check. |
*Examples**
|
nodiscard |
Select the best possible paths to be used for the requested topology based on the data that is available to us.
If the paths will be used for a completely new topology (Windows has never had it set), we need to take into account the source id availability per the adapter - duplicated displays must share the same source id (if they belong to the same adapter) and have different ids if they are not duplicated displays.
There are limited amount of available ids (see comments in the code) so we will abort early if we are out of ids.
The paths for a topology that already exists (Windows has set it at least once) does not have to follow the mentioned "source id" rule. Windows can simply ignore them (we will ask it later) and select paths that were previously configured (that might differ in source ids) based on the paths that we provide.
| new_topology | Topology that we want to have in the end. |
| path_source_data | Collected source data from paths. |
| paths | Display paths that were used for collecting source data. |
| DdGuardFn display_device::win_utils::modeGuardFn | ( | WinDisplayDeviceInterface & | win_dd, |
| const ActiveTopology & | topology ) |
Make guard function for the display modes.
| win_dd | Interface for interacting with the OS. |
| topology | Topology to be used when making a guard. |
*Examples**
| DdGuardFn display_device::win_utils::modeGuardFn | ( | WinDisplayDeviceInterface & | win_dd, |
| const DeviceDisplayModeMap & | modes ) |
Make guard function for the display modes.
| win_dd | Interface for interacting with the OS. |
| modes | Display modes to restore when the guard is executed. |
*Examples**
| DdGuardFn display_device::win_utils::primaryGuardFn | ( | WinDisplayDeviceInterface & | win_dd, |
| const ActiveTopology & | topology ) |
Make guard function for the primary display.
| win_dd | Interface for interacting with the OS. |
| topology | Topology to be used when making a guard. |
*Examples**
| DdGuardFn display_device::win_utils::primaryGuardFn | ( | WinDisplayDeviceInterface & | win_dd, |
| const std::string & | primary_device ) |
Make guard function for the primary display.
| win_dd | Interface for interacting with the OS. |
| primary_device | Primary device to restore when the guard is executed. |
*Examples**
| void display_device::win_utils::setActive | ( | DISPLAYCONFIG_PATH_INFO & | path | ) |
Mark the display device path as active.
| path | Path to mark. |
*Examples**
| void display_device::win_utils::setCloneGroupId | ( | DISPLAYCONFIG_PATH_INFO & | path, |
| const std::optional< UINT32 > & | id ) |
Set the clone group id in the path.
| path | Path to modify. |
| id | Id value to set or empty optional to mark the id as invalid. |
*Examples**
| void display_device::win_utils::setDesktopIndex | ( | DISPLAYCONFIG_PATH_INFO & | path, |
| const std::optional< UINT32 > & | index ) |
Set the desktop mode index in the path.
| path | Path to modify. |
| index | Index value to set or empty optional to mark the index as invalid. |
*Examples**
| void display_device::win_utils::setSourceIndex | ( | DISPLAYCONFIG_PATH_INFO & | path, |
| const std::optional< UINT32 > & | index ) |
Set the source mode index in the path.
| path | Path to modify. |
| index | Index value to set or empty optional to mark the index as invalid. |
*Examples**
| void display_device::win_utils::setTargetIndex | ( | DISPLAYCONFIG_PATH_INFO & | path, |
| const std::optional< UINT32 > & | index ) |
Set the target mode index in the path.
| path | Path to modify. |
| index | Index value to set or empty optional to mark the index as invalid. |
*Examples**
| std::optional< SingleDisplayConfigState::Initial > display_device::win_utils::stripInitialState | ( | const SingleDisplayConfigState::Initial & | initial_state, |
| const EnumeratedDeviceList & | devices ) |
Strip the initial state of non-existing devices.
| initial_state | State to be stripped. |
| devices | Currently available device list. |
| DdGuardFn display_device::win_utils::topologyGuardFn | ( | WinDisplayDeviceInterface & | win_dd, |
| const ActiveTopology & | topology ) |
Make guard function for the topology.
| win_dd | Interface for interacting with the OS. |
| topology | Topology to be used when making a guard. |
*Examples**