libdisplaydevice master
C++ library to modify display devices.
win_api_utils.h
Go to the documentation of this file.
1
5#pragma once
6
7// system includes
8#include <set>
9#include <string_view>
10
11// local includes
13
33 [[nodiscard]] bool isAvailable(const DISPLAYCONFIG_PATH_INFO &path);
34
45 [[nodiscard]] bool isActive(const DISPLAYCONFIG_PATH_INFO &path);
46
58 void setActive(DISPLAYCONFIG_PATH_INFO &path);
59
70 bool isPrimary(const DISPLAYCONFIG_SOURCE_MODE &mode);
71
88 [[nodiscard]] std::optional<UINT32> getSourceIndex(const DISPLAYCONFIG_PATH_INFO &path, const std::vector<DISPLAYCONFIG_MODE_INFO> &modes);
89
101 void setSourceIndex(DISPLAYCONFIG_PATH_INFO &path, const std::optional<UINT32> &index);
102
114 void setTargetIndex(DISPLAYCONFIG_PATH_INFO &path, const std::optional<UINT32> &index);
115
127 void setDesktopIndex(DISPLAYCONFIG_PATH_INFO &path, const std::optional<UINT32> &index);
128
140 void setCloneGroupId(DISPLAYCONFIG_PATH_INFO &path, const std::optional<UINT32> &id);
141
160 [[nodiscard]] const DISPLAYCONFIG_SOURCE_MODE *getSourceMode(const std::optional<UINT32> &index, const std::vector<DISPLAYCONFIG_MODE_INFO> &modes);
161
165 [[nodiscard]] DISPLAYCONFIG_SOURCE_MODE *getSourceMode(const std::optional<UINT32> &index, std::vector<DISPLAYCONFIG_MODE_INFO> &modes);
166
191 [[nodiscard]] std::optional<ValidatedDeviceInfo> getDeviceInfoForValidPath(const WinApiLayerInterface &w_api, const DISPLAYCONFIG_PATH_INFO &path, ValidatedPathType type);
192
206 [[nodiscard]] const DISPLAYCONFIG_PATH_INFO *getActivePath(const WinApiLayerInterface &w_api, std::string_view device_id, const std::vector<DISPLAYCONFIG_PATH_INFO> &paths);
207
224 [[nodiscard]] PathSourceIndexDataMap collectSourceDataForMatchingPaths(const WinApiLayerInterface &w_api, const std::vector<DISPLAYCONFIG_PATH_INFO> &paths);
225
245 [[nodiscard]] std::vector<DISPLAYCONFIG_PATH_INFO> makePathsForNewTopology(const ActiveTopology &new_topology, const PathSourceIndexDataMap &path_source_data, const std::vector<DISPLAYCONFIG_PATH_INFO> &paths);
246
258 [[nodiscard]] StringSet getAllDeviceIdsAndMatchingDuplicates(const WinApiLayerInterface &w_api, const StringSet &device_ids);
259
270 [[nodiscard]] bool fuzzyCompareRefreshRates(const Rational &lhs, const Rational &rhs);
271
284 [[nodiscard]] bool fuzzyCompareModes(const DisplayMode &lhs, const DisplayMode &rhs);
285} // namespace display_device::win_utils
std::set< std::string, std::less<> > StringSet
Ordered set keyed by strings with transparent comparisons.
Definition types.h:46
Shared "utility-level" code for Settings.
Definition settings_utils.h:18
void setDesktopIndex(DISPLAYCONFIG_PATH_INFO &path, const std::optional< UINT32 > &index)
Set the desktop mode index in the path.
Definition win_api_utils.cpp:153
const DISPLAYCONFIG_PATH_INFO * getActivePath(const WinApiLayerInterface &w_api, std::string_view device_id, const std::vector< DISPLAYCONFIG_PATH_INFO > &paths)
Get the active path matching the device id.
Definition win_api_utils.cpp:218
void setSourceIndex(DISPLAYCONFIG_PATH_INFO &path, const std::optional< UINT32 > &index)
Set the source mode index in the path.
Definition win_api_utils.cpp:123
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 availa...
Definition win_api_utils.cpp:448
bool isActive(const DISPLAYCONFIG_PATH_INFO &path)
Check if the display device path is marked as active.
Definition win_api_utils.cpp:90
bool fuzzyCompareModes(const DisplayMode &lhs, const DisplayMode &rhs)
Check if the display modes are almost equal.
Definition win_api_utils.cpp:540
StringSet getAllDeviceIdsAndMatchingDuplicates(const WinApiLayerInterface &w_api, const StringSet &device_ids)
Get all the missing duplicate device ids for the provided device ids.
Definition win_api_utils.cpp:474
bool fuzzyCompareRefreshRates(const Rational &lhs, const Rational &rhs)
Check if the refresh rates are almost equal.
Definition win_api_utils.cpp:530
PathSourceIndexDataMap collectSourceDataForMatchingPaths(const WinApiLayerInterface &w_api, const std::vector< DISPLAYCONFIG_PATH_INFO > &paths)
Collect arbitrary source data from provided paths.
Definition win_api_utils.cpp:293
void setCloneGroupId(DISPLAYCONFIG_PATH_INFO &path, const std::optional< UINT32 > &id)
Set the clone group id in the path.
Definition win_api_utils.cpp:168
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.
Definition win_api_utils.cpp:183
void setTargetIndex(DISPLAYCONFIG_PATH_INFO &path, const std::optional< UINT32 > &index)
Set the target mode index in the path.
Definition win_api_utils.cpp:138
std::optional< UINT32 > getSourceIndex(const DISPLAYCONFIG_PATH_INFO &path, const std::vector< DISPLAYCONFIG_MODE_INFO > &modes)
Get the source mode index from the path.
Definition win_api_utils.cpp:102
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.
Definition win_api_utils.cpp:191
void setActive(DISPLAYCONFIG_PATH_INFO &path)
Mark the display device path as active.
Definition win_api_utils.cpp:94
bool isAvailable(const DISPLAYCONFIG_PATH_INFO &path)
Check if the display device path's target is available.
Definition win_api_utils.cpp:86
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.
Definition win_api_utils.cpp:98
Declarations for the WinApiLayerInterface.
StringMap< PathSourceIndexData > PathSourceIndexDataMap
Ordered map of [DEVICE_ID -> PathSourceIndexData].
Definition types.h:80