libdisplaydevice master
C++ library to modify display devices.
win_api_layer.h
Go to the documentation of this file.
1
5#pragma once
6
7// system includes
8#include <string_view>
9
10// local includes
12
13namespace display_device {
18 public:
22 [[nodiscard]] std::string getErrorString(LONG error_code) const override;
23
27 [[nodiscard]] std::optional<PathAndModeData> queryDisplayConfig(QueryType type) const override;
28
32 [[nodiscard]] bool wakeDisplay(std::chrono::milliseconds timeout) override;
33
37 [[nodiscard]] bool keepDisplayAwake() override;
38
42 [[nodiscard]] bool restorePowerRequest() override;
43
47 [[nodiscard]] std::string getDeviceId(const DISPLAYCONFIG_PATH_INFO &path) const override;
48
52 [[nodiscard]] std::vector<std::byte> getEdid(const DISPLAYCONFIG_PATH_INFO &path) const override;
53
57 [[nodiscard]] std::string getMonitorDevicePath(const DISPLAYCONFIG_PATH_INFO &path) const override;
58
62 [[nodiscard]] std::string getFriendlyName(const DISPLAYCONFIG_PATH_INFO &path) const override;
63
67 [[nodiscard]] std::string getDisplayName(const DISPLAYCONFIG_PATH_INFO &path) const override;
68
72 [[nodiscard]] LONG setDisplayConfig(std::vector<DISPLAYCONFIG_PATH_INFO> paths, std::vector<DISPLAYCONFIG_MODE_INFO> modes, UINT32 flags) override;
73
77 [[nodiscard]] std::optional<HdrState> getHdrState(const DISPLAYCONFIG_PATH_INFO &path) const override;
78
82 [[nodiscard]] bool setHdrState(const DISPLAYCONFIG_PATH_INFO &path, HdrState state) override;
83
87 [[nodiscard]] std::optional<Rational> getDisplayScale(std::string_view display_name, const DISPLAYCONFIG_SOURCE_MODE &source_mode) const override;
88 };
89} // namespace display_device
Lowest level Windows API wrapper for easy mocking.
Definition win_api_layer_interface.h:17
Default implementation for the WinApiLayerInterface.
Definition win_api_layer.h:17
bool setHdrState(const DISPLAYCONFIG_PATH_INFO &path, HdrState state) override
Set the HDR state for the path.
Definition win_api_layer.cpp:701
std::string getDisplayName(const DISPLAYCONFIG_PATH_INFO &path) const override
Get the logical display name for the path.
Definition win_api_layer.cpp:635
std::optional< PathAndModeData > queryDisplayConfig(QueryType type) const override
Query Windows for the device paths and associated modes.
Definition win_api_layer.cpp:490
std::optional< Rational > getDisplayScale(std::string_view display_name, const DISPLAYCONFIG_SOURCE_MODE &source_mode) const override
Get the scaling value for the display.
Definition win_api_layer.cpp:735
std::vector< std::byte > getEdid(const DISPLAYCONFIG_PATH_INFO &path) const override
Get EDID byte array for the path.
Definition win_api_layer.cpp:604
std::string getFriendlyName(const DISPLAYCONFIG_PATH_INFO &path) const override
Get the user-friendly name for the path.
Definition win_api_layer.cpp:619
std::string getErrorString(LONG error_code) const override
Stringify the error code from Windows API.
Definition win_api_layer.cpp:460
LONG setDisplayConfig(std::vector< DISPLAYCONFIG_PATH_INFO > paths, std::vector< DISPLAYCONFIG_MODE_INFO > modes, UINT32 flags) override
Direct wrapper around the SetDisplayConfig WinAPI.
Definition win_api_layer.cpp:650
std::string getDeviceId(const DISPLAYCONFIG_PATH_INFO &path) const override
Get a stable and persistent device id for the path.
Definition win_api_layer.cpp:564
bool keepDisplayAwake() override
Request that Windows keep the current thread's display awake.
Definition win_api_layer.cpp:546
bool wakeDisplay(std::chrono::milliseconds timeout) override
Ask Windows to wake the display and wait before retrying detection.
Definition win_api_layer.cpp:532
std::string getMonitorDevicePath(const DISPLAYCONFIG_PATH_INFO &path) const override
Get a string that represents a path from the adapter to the display target.
Definition win_api_layer.cpp:615
std::optional< HdrState > getHdrState(const DISPLAYCONFIG_PATH_INFO &path) const override
Get the HDR state the path.
Definition win_api_layer.cpp:661
bool restorePowerRequest() override
Clear the current thread's display keep-awake request.
Definition win_api_layer.cpp:555
HdrState
The device's HDR state in the operating system.
Definition types.h:68
Declarations for the WinApiLayerInterface.
QueryType
Type of query the OS should perform while searching for display devices.
Definition types.h:26