libdisplaydevice master
C++ library to modify display devices.
win_api_layer_interface.h
Go to the documentation of this file.
1
5#pragma once
6
7// system includes
8#include <string_view>
9
10// local includes
11#include "types.h"
12
13namespace display_device {
18 public:
22 virtual ~WinApiLayerInterface() = default;
23
33 [[nodiscard]] virtual std::string getErrorString(LONG error_code) const = 0;
34
44 [[nodiscard]] virtual std::optional<PathAndModeData> queryDisplayConfig(QueryType type) const = 0;
45
55 [[nodiscard]] virtual bool wakeDisplay(std::chrono::milliseconds timeout) = 0;
56
61 [[nodiscard]] virtual bool keepDisplayAwake() = 0;
62
67 [[nodiscard]] virtual bool restorePowerRequest() = 0;
68
111 [[nodiscard]] virtual std::string getDeviceId(const DISPLAYCONFIG_PATH_INFO &path) const = 0;
112
118 [[nodiscard]] virtual std::vector<std::byte> getEdid(const DISPLAYCONFIG_PATH_INFO &path) const = 0;
119
134 [[nodiscard]] virtual std::string getMonitorDevicePath(const DISPLAYCONFIG_PATH_INFO &path) const = 0;
135
148 [[nodiscard]] virtual std::string getFriendlyName(const DISPLAYCONFIG_PATH_INFO &path) const = 0;
149
167 [[nodiscard]] virtual std::string getDisplayName(const DISPLAYCONFIG_PATH_INFO &path) const = 0;
168
184 [[nodiscard]] virtual LONG setDisplayConfig(std::vector<DISPLAYCONFIG_PATH_INFO> paths, std::vector<DISPLAYCONFIG_MODE_INFO> modes, UINT32 flags) = 0;
185
196 [[nodiscard]] virtual std::optional<HdrState> getHdrState(const DISPLAYCONFIG_PATH_INFO &path) const = 0;
197
209 [[nodiscard]] virtual bool setHdrState(const DISPLAYCONFIG_PATH_INFO &path, HdrState state) = 0;
210
224 [[nodiscard]] virtual std::optional<Rational> getDisplayScale(std::string_view display_name, const DISPLAYCONFIG_SOURCE_MODE &source_mode) const = 0;
225 };
226} // namespace display_device
Lowest level Windows API wrapper for easy mocking.
Definition win_api_layer_interface.h:17
virtual std::string getDisplayName(const DISPLAYCONFIG_PATH_INFO &path) const =0
Get the logical display name for the path.
virtual LONG setDisplayConfig(std::vector< DISPLAYCONFIG_PATH_INFO > paths, std::vector< DISPLAYCONFIG_MODE_INFO > modes, UINT32 flags)=0
Direct wrapper around the SetDisplayConfig WinAPI.
virtual bool wakeDisplay(std::chrono::milliseconds timeout)=0
Ask Windows to wake the display and wait before retrying detection.
virtual std::optional< Rational > getDisplayScale(std::string_view display_name, const DISPLAYCONFIG_SOURCE_MODE &source_mode) const =0
Get the scaling value for the display.
virtual ~WinApiLayerInterface()=default
Default virtual destructor.
virtual bool keepDisplayAwake()=0
Request that Windows keep the current thread's display awake.
virtual std::string getDeviceId(const DISPLAYCONFIG_PATH_INFO &path) const =0
Get a stable and persistent device id for the path.
virtual bool setHdrState(const DISPLAYCONFIG_PATH_INFO &path, HdrState state)=0
Set the HDR state for the path.
virtual std::string getMonitorDevicePath(const DISPLAYCONFIG_PATH_INFO &path) const =0
Get a string that represents a path from the adapter to the display target.
virtual std::vector< std::byte > getEdid(const DISPLAYCONFIG_PATH_INFO &path) const =0
Get EDID byte array for the path.
virtual bool restorePowerRequest()=0
Clear the current thread's display keep-awake request.
virtual std::string getFriendlyName(const DISPLAYCONFIG_PATH_INFO &path) const =0
Get the user-friendly name for the path.
virtual std::optional< PathAndModeData > queryDisplayConfig(QueryType type) const =0
Query Windows for the device paths and associated modes.
virtual std::string getErrorString(LONG error_code) const =0
Stringify the error code from Windows API.
virtual std::optional< HdrState > getHdrState(const DISPLAYCONFIG_PATH_INFO &path) const =0
Get the HDR state the path.
HdrState
The device's HDR state in the operating system.
Definition types.h:68
Declarations for Windows specific types.
QueryType
Type of query the OS should perform while searching for display devices.
Definition types.h:26