libdisplaydevice latest
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
10// local includes
12
32 [[nodiscard]] bool isAvailable(const DISPLAYCONFIG_PATH_INFO &path);
33
44 [[nodiscard]] bool isActive(const DISPLAYCONFIG_PATH_INFO &path);
45
57 void setActive(DISPLAYCONFIG_PATH_INFO &path);
58
69 bool isPrimary(const DISPLAYCONFIG_SOURCE_MODE &mode);
70
87 [[nodiscard]] std::optional<UINT32> getSourceIndex(const DISPLAYCONFIG_PATH_INFO &path, const std::vector<DISPLAYCONFIG_MODE_INFO> &modes);
88
100 void setSourceIndex(DISPLAYCONFIG_PATH_INFO &path, const std::optional<UINT32> &index);
101
113 void setTargetIndex(DISPLAYCONFIG_PATH_INFO &path, const std::optional<UINT32> &index);
114
126 void setDesktopIndex(DISPLAYCONFIG_PATH_INFO &path, const std::optional<UINT32> &index);
127
139 void setCloneGroupId(DISPLAYCONFIG_PATH_INFO &path, const std::optional<UINT32> &id);
140
159 [[nodiscard]] const DISPLAYCONFIG_SOURCE_MODE *getSourceMode(const std::optional<UINT32> &index, const std::vector<DISPLAYCONFIG_MODE_INFO> &modes);
160
164 [[nodiscard]] DISPLAYCONFIG_SOURCE_MODE *getSourceMode(const std::optional<UINT32> &index, std::vector<DISPLAYCONFIG_MODE_INFO> &modes);
165
190 [[nodiscard]] std::optional<ValidatedDeviceInfo> getDeviceInfoForValidPath(const WinApiLayerInterface &w_api, const DISPLAYCONFIG_PATH_INFO &path, ValidatedPathType type);
191
205 [[nodiscard]] const DISPLAYCONFIG_PATH_INFO *getActivePath(const WinApiLayerInterface &w_api, const std::string &device_id, const std::vector<DISPLAYCONFIG_PATH_INFO> &paths);
206
210 [[nodiscard]] DISPLAYCONFIG_PATH_INFO *getActivePath(const WinApiLayerInterface &w_api, const std::string &device_id, std::vector<DISPLAYCONFIG_PATH_INFO> &paths);
211
228 [[nodiscard]] PathSourceIndexDataMap collectSourceDataForMatchingPaths(const WinApiLayerInterface &w_api, const std::vector<DISPLAYCONFIG_PATH_INFO> &paths);
229
249 [[nodiscard]] std::vector<DISPLAYCONFIG_PATH_INFO> makePathsForNewTopology(const ActiveTopology &new_topology, const PathSourceIndexDataMap &path_source_data, const std::vector<DISPLAYCONFIG_PATH_INFO> &paths);
250
262 [[nodiscard]] std::set<std::string> getAllDeviceIdsAndMatchingDuplicates(const WinApiLayerInterface &w_api, const std::set<std::string> &device_ids);
263
274 [[nodiscard]] bool fuzzyCompareRefreshRates(const Rational &lhs, const Rational &rhs);
275
288 [[nodiscard]] bool fuzzyCompareModes(const DisplayMode &lhs, const DisplayMode &rhs);
289} // namespace display_device::win_utils
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:126
void setSourceIndex(DISPLAYCONFIG_PATH_INFO &path, const std::optional< UINT32 > &index)
Set the source mode index in the path.
Definition win_api_utils.cpp:96
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:293
bool isActive(const DISPLAYCONFIG_PATH_INFO &path)
Check if the display device path is marked as active.
Definition win_api_utils.cpp:63
bool fuzzyCompareModes(const DisplayMode &lhs, const DisplayMode &rhs)
Check if the display modes are almost equal.
Definition win_api_utils.cpp:465
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.
Definition win_api_utils.cpp:399
bool fuzzyCompareRefreshRates(const Rational &lhs, const Rational &rhs)
Check if the refresh rates are almost equal.
Definition win_api_utils.cpp:455
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:228
void setCloneGroupId(DISPLAYCONFIG_PATH_INFO &path, const std::optional< UINT32 > &id)
Set the clone group id in the path.
Definition win_api_utils.cpp:141
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:156
void setTargetIndex(DISPLAYCONFIG_PATH_INFO &path, const std::optional< UINT32 > &index)
Set the target mode index in the path.
Definition win_api_utils.cpp:111
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:75
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:179
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.
Definition win_api_utils.cpp:209
void setActive(DISPLAYCONFIG_PATH_INFO &path)
Mark the display device path as active.
Definition win_api_utils.cpp:67
bool isAvailable(const DISPLAYCONFIG_PATH_INFO &path)
Check if the display device path's target is available.
Definition win_api_utils.cpp:59
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:71
Declarations for the WinApiLayerInterface.
std::map< std::string, PathSourceIndexData > PathSourceIndexDataMap
Ordered map of [DEVICE_ID -> PathSourceIndexData].
Definition types.h:70