libdisplaydevice latest
C++ library to modify display devices.
display_device::WinDisplayDeviceInterface Class Referenceabstract

Higher level abstracted API for interacting Windows' display device(s). More...

#include <src/windows/include/display_device/windows/win_display_device_interface.h>

Inheritance diagram for display_device::WinDisplayDeviceInterface:
[legend]

Public Member Functions

virtual EnumeratedDeviceList enumAvailableDevices () const =0
 Enumerate the available (active and inactive) devices.
 
virtual DeviceDisplayModeMap getCurrentDisplayModes (const std::set< std::string > &device_ids) const =0
 Get current display modes for the devices.
 
virtual HdrStateMap getCurrentHdrStates (const std::set< std::string > &device_ids) const =0
 Get HDR state for the devices.
 
virtual ActiveTopology getCurrentTopology () const =0
 Get the active (current) topology.
 
virtual std::string getDisplayName (const std::string &device_id) const =0
 Get display name associated with the device.
 
virtual bool isApiAccessAvailable () const =0
 Check if the API for changing display settings is accessible.
 
virtual bool isPrimary (const std::string &device_id) const =0
 Check whether the specified device is primary.
 
virtual bool isTopologyTheSame (const ActiveTopology &lhs, const ActiveTopology &rhs) const =0
 Check if the topologies are close enough to be considered the same by the OS.
 
virtual bool isTopologyValid (const ActiveTopology &topology) const =0
 Verify if the active topology is valid.
 
virtual bool setAsPrimary (const std::string &device_id)=0
 Set the device as a primary display.
 
virtual bool setDisplayModes (const DeviceDisplayModeMap &modes)=0
 Set new display modes for the devices.
 
virtual bool setHdrStates (const HdrStateMap &states)=0
 Set HDR states for the devices.
 
virtual bool setTopology (const ActiveTopology &new_topology)=0
 Set a new active topology for the OS.
 
virtual ~WinDisplayDeviceInterface ()=default
 Default virtual destructor.
 

Detailed Description

Higher level abstracted API for interacting Windows' display device(s).

Member Function Documentation

◆ enumAvailableDevices()

virtual EnumeratedDeviceList display_device::WinDisplayDeviceInterface::enumAvailableDevices ( ) const
nodiscardpure virtual

Enumerate the available (active and inactive) devices.

Returns
A list of available devices. Empty list can also be returned if an error has occurred.

*Examples**

const auto devices { enumAvailableDevices() };
virtual EnumeratedDeviceList enumAvailableDevices() const =0
Enumerate the available (active and inactive) devices.

Implemented in display_device::WinDisplayDevice.

◆ getCurrentDisplayModes()

virtual DeviceDisplayModeMap display_device::WinDisplayDeviceInterface::getCurrentDisplayModes ( const std::set< std::string > & device_ids) const
nodiscardpure virtual

Get current display modes for the devices.

Parameters
device_idsA list of devices to get the modes for.
Returns
A map of device modes per a device or an empty map if a mode could not be found (e.g. device is inactive). Empty map can also be returned if an error has occurred.

*Examples**

const WinDisplayDeviceInterface* iface = getIface(...);
const std::set<std::string> device_ids { "DEVICE_ID_1", "DEVICE_ID_2" };
const auto current_modes = iface->getCurrentDisplayModes(device_ids);
Higher level abstracted API for interacting Windows' display device(s).
Definition win_display_device_interface.h:17
virtual DeviceDisplayModeMap getCurrentDisplayModes(const std::set< std::string > &device_ids) const =0
Get current display modes for the devices.

Implemented in display_device::WinDisplayDevice.

◆ getCurrentHdrStates()

virtual HdrStateMap display_device::WinDisplayDeviceInterface::getCurrentHdrStates ( const std::set< std::string > & device_ids) const
nodiscardpure virtual

Get HDR state for the devices.

Parameters
device_idsA list of devices to get the HDR states for.
Returns
A map of HDR states per a device or an empty map if an error has occurred.
Note
On Windows the state cannot be retrieved until the device is active even if it supports it.

*Examples**

const WinDisplayDeviceInterface* iface = getIface(...);
const std::unordered_set<std::string> device_ids { "DEVICE_ID_1", "DEVICE_ID_2" };
const auto current_hdr_states = iface->getCurrentHdrStates(device_ids);
virtual HdrStateMap getCurrentHdrStates(const std::set< std::string > &device_ids) const =0
Get HDR state for the devices.

Implemented in display_device::WinDisplayDevice.

◆ getCurrentTopology()

virtual ActiveTopology display_device::WinDisplayDeviceInterface::getCurrentTopology ( ) const
nodiscardpure virtual

Get the active (current) topology.

Returns
A list representing the current topology. Empty list can also be returned if an error has occurred.

*Examples**

const WinDisplayDeviceInterface* iface = getIface(...);
const auto current_topology { iface->getCurrentTopology() };
virtual ActiveTopology getCurrentTopology() const =0
Get the active (current) topology.

Implemented in display_device::WinDisplayDevice.

◆ getDisplayName()

virtual std::string display_device::WinDisplayDeviceInterface::getDisplayName ( const std::string & device_id) const
nodiscardpure virtual

Get display name associated with the device.

Parameters
device_idA device to get display name for.
Returns
A display name for the device, or an empty string if the device is inactive or not found. Empty string can also be returned if an error has occurred.

*Examples**

const std::string device_id { "MY_DEVICE_ID" };
const WinDisplayDeviceInterface* iface = getIface(...);
const std::string display_name = iface->getDisplayName(device_id);
virtual std::string getDisplayName(const std::string &device_id) const =0
Get display name associated with the device.

Implemented in display_device::WinDisplayDevice.

◆ isApiAccessAvailable()

virtual bool display_device::WinDisplayDeviceInterface::isApiAccessAvailable ( ) const
nodiscardpure virtual

Check if the API for changing display settings is accessible.

Returns
True if display settings can be changed, false otherwise.

*Examples**

const WinDisplayDeviceInterface* iface = getIface(...);
const bool have_access { iface->isApiAccessAvailable() };
virtual bool isApiAccessAvailable() const =0
Check if the API for changing display settings is accessible.

Implemented in display_device::WinDisplayDevice.

◆ isPrimary()

virtual bool display_device::WinDisplayDeviceInterface::isPrimary ( const std::string & device_id) const
nodiscardpure virtual

Check whether the specified device is primary.

Parameters
device_idA device to perform the check for.
Returns
True if the device is primary, false otherwise.

*Examples**

const WinDisplayDeviceInterface* iface = getIface(...);
const std::string device_id { "MY_DEVICE_ID" };
const bool is_primary = iface->isPrimary(device_id);
virtual bool isPrimary(const std::string &device_id) const =0
Check whether the specified device is primary.

Implemented in display_device::WinDisplayDevice.

◆ isTopologyTheSame()

virtual bool display_device::WinDisplayDeviceInterface::isTopologyTheSame ( const ActiveTopology & lhs,
const ActiveTopology & rhs ) const
nodiscardpure virtual

Check if the topologies are close enough to be considered the same by the OS.

Parameters
lhsFirst topology to compare.
rhsSecond topology to compare.
Returns
True if topologies are close enough, false otherwise.

*Examples**

const WinDisplayDeviceInterface* iface = getIface(...);
auto current_topology { iface->getCurrentTopology() };
auto new_topology { current_topology };
// Modify the new_topology
const bool is_the_same = iface->isTopologyTheSame(current_topology, new_topology);
virtual bool isTopologyTheSame(const ActiveTopology &lhs, const ActiveTopology &rhs) const =0
Check if the topologies are close enough to be considered the same by the OS.

Implemented in display_device::WinDisplayDevice.

◆ isTopologyValid()

virtual bool display_device::WinDisplayDeviceInterface::isTopologyValid ( const ActiveTopology & topology) const
nodiscardpure virtual

Verify if the active topology is valid.

This is mostly meant as a sanity check or to verify that it is still valid after a manual modification to an existing topology.

Parameters
topologyTopology to validate.
Returns
True if it is valid, false otherwise.

*Examples**

const WinDisplayDeviceInterface* iface = getIface(...);
auto current_topology { iface->getCurrentTopology() };
// Modify the current_topology
const bool is_valid = iface->isTopologyValid(current_topology);
virtual bool isTopologyValid(const ActiveTopology &topology) const =0
Verify if the active topology is valid.

Implemented in display_device::WinDisplayDevice.

◆ setAsPrimary()

virtual bool display_device::WinDisplayDeviceInterface::setAsPrimary ( const std::string & device_id)
nodiscardpure virtual

Set the device as a primary display.

Parameters
device_idA device to set as primary.
Returns
True if the device is or was set as primary, false otherwise.
Note
On Windows if the device is duplicated, the other duplicated device(-s) will also become a primary device.

*Examples**

WinDisplayDeviceInterface* iface = getIface(...);
const std::string device_id { "MY_DEVICE_ID" };
const bool success = iface->set_as_primary_device(device_id);

Implemented in display_device::WinDisplayDevice.

◆ setDisplayModes()

virtual bool display_device::WinDisplayDeviceInterface::setDisplayModes ( const DeviceDisplayModeMap & modes)
nodiscardpure virtual

Set new display modes for the devices.

Parameters
modesA map of modes to set.
Returns
True if modes were set, false otherwise.
Warning
if any of the specified devices are duplicated, modes be provided for duplicates too!

*Examples**

WinDisplayDeviceInterface* iface = getIface(...);
const std::string display_a { "MY_ID_1" };
const std::string display_b { "MY_ID_2" };
const auto success = iface->setDisplayModes({ { display_a, { { 1920, 1080 }, { 60, 1 } } },
{ display_b, { { 1920, 1080 }, { 120, 1 } } } });
virtual bool setDisplayModes(const DeviceDisplayModeMap &modes)=0
Set new display modes for the devices.

Implemented in display_device::WinDisplayDevice.

◆ setHdrStates()

virtual bool display_device::WinDisplayDeviceInterface::setHdrStates ( const HdrStateMap & states)
nodiscardpure virtual

Set HDR states for the devices.

Parameters
statesA map of HDR states to set.
Returns
True if HDR states were set, false otherwise.
Note
If unknown states are provided, they will be silently ignored and current state will not be changed.

*Examples**

WinDisplayDeviceInterface* iface = getIface(...);
const std::string display_a { "MY_ID_1" };
const std::string display_b { "MY_ID_2" };
const auto success = iface->setHdrStates({ { display_a, HdrState::Enabled },
{ display_b, HdrState::Disabled } });
virtual bool setHdrStates(const HdrStateMap &states)=0
Set HDR states for the devices.

Implemented in display_device::WinDisplayDevice.

◆ setTopology()

virtual bool display_device::WinDisplayDeviceInterface::setTopology ( const ActiveTopology & new_topology)
nodiscardpure virtual

Set a new active topology for the OS.

Parameters
new_topologyNew device topology to set.
Returns
True if the new topology has been set, false otherwise.

*Examples**

WinDisplayDeviceInterface* iface = getIface(...);
auto current_topology { iface->getCurrentTopology() };
// Modify the current_topology
const bool success = iface->setTopology(current_topology);
virtual bool setTopology(const ActiveTopology &new_topology)=0
Set a new active topology for the OS.

Implemented in display_device::WinDisplayDevice.


The documentation for this class was generated from the following file: