libdisplaydevice master
C++ library to modify display devices.
display_device::MacApiLayerInterface Class Referenceabstract

Lowest level macOS API wrapper for easy mocking. More...

#include <src/macos/include/display_device/macos/mac_api_layer_interface.h>

Inheritance diagram for display_device::MacApiLayerInterface:
[legend]

Public Member Functions

virtual std::optional< MacPowerAssertionIdcreateDisplaySleepAssertion (const std::string &reason)=0
 Create a power assertion that prevents user-idle display sleep.
 
virtual std::optional< MacPowerAssertionIddeclareUserActivity (const std::string &reason)=0
 Tell macOS that the user is active and displays should wake.
 
virtual std::optional< MacDisplayModegetCurrentDisplayMode (MacDisplayId display_id) const =0
 Get the current display mode.
 
virtual std::string getDeviceId (MacDisplayId display_id) const =0
 Get the library device id for a display.
 
virtual MacDisplayIdList getDisplayIds (MacQueryType type) const =0
 Query macOS for display identifiers.
 
virtual MacDisplayModeList getDisplayModes (MacDisplayId display_id) const =0
 Get available display modes for a display.
 
virtual std::string getDisplayName (MacDisplayId display_id) const =0
 Get the macOS capture selector for a display.
 
virtual std::optional< RationalgetDisplayScale (MacDisplayId display_id) const =0
 Get the display scale value.
 
virtual std::vector< std::byte > getEdid (MacDisplayId display_id) const =0
 Get EDID byte array for a display.
 
virtual std::string getErrorString (MacApiError error_code) const =0
 Stringify a macOS display API error code.
 
virtual std::string getFriendlyName (MacDisplayId display_id) const =0
 Get a human-readable display name.
 
virtual MacDisplayId getMirrorMaster (MacDisplayId display_id) const =0
 Get the display mirrored by the specified display.
 
virtual std::optional< PointgetOriginPoint (MacDisplayId display_id) const =0
 Get the display origin point.
 
virtual bool isActive (MacDisplayId display_id) const =0
 Check whether a display is active.
 
virtual bool isApiAccessAvailable () const =0
 Check if display configuration APIs are accessible.
 
virtual bool isMainDisplay (MacDisplayId display_id) const =0
 Check whether a display is the main display.
 
virtual bool isOnline (MacDisplayId display_id) const =0
 Check whether a display is online.
 
virtual bool releasePowerAssertion (MacPowerAssertionId assertion_id)=0
 Release a macOS power assertion.
 
virtual bool setDisplayMode (MacDisplayId display_id, const MacDisplayMode &mode)=0
 Set the display mode for a display.
 
virtual bool setMirror (MacDisplayId display_id, MacDisplayId master_display_id)=0
 Set a display as a mirror of another display.
 
virtual bool setOriginPoint (MacDisplayId display_id, const Point &origin)=0
 Set the origin point for a display.
 
virtual ~MacApiLayerInterface ()=default
 Default virtual destructor.
 

Detailed Description

Lowest level macOS API wrapper for easy mocking.

Member Function Documentation

◆ createDisplaySleepAssertion()

virtual std::optional< MacPowerAssertionId > display_device::MacApiLayerInterface::createDisplaySleepAssertion ( const std::string & reason)
nodiscardpure virtual

Create a power assertion that prevents user-idle display sleep.

Parameters
reasonShort human-readable reason for the assertion.
Returns
Power assertion id to release later, or empty optional on failure.

Implemented in display_device::MacApiLayer.

◆ declareUserActivity()

virtual std::optional< MacPowerAssertionId > display_device::MacApiLayerInterface::declareUserActivity ( const std::string & reason)
nodiscardpure virtual

Tell macOS that the user is active and displays should wake.

Parameters
reasonShort human-readable reason for the wake assertion.
Returns
Power assertion id to release later, or empty optional on failure.

Implemented in display_device::MacApiLayer.

◆ getCurrentDisplayMode()

virtual std::optional< MacDisplayMode > display_device::MacApiLayerInterface::getCurrentDisplayMode ( MacDisplayId display_id) const
nodiscardpure virtual

Get the current display mode.

Parameters
display_idDisplay to query.
Returns
Current display mode, or empty optional if unavailable.

Implemented in display_device::MacApiLayer.

◆ getDeviceId()

virtual std::string display_device::MacApiLayerInterface::getDeviceId ( MacDisplayId display_id) const
nodiscardpure virtual

Get the library device id for a display.

Parameters
display_idDisplay to query.
Returns
Stable best-effort device id, or empty string if unavailable.

Implemented in display_device::MacApiLayer.

◆ getDisplayIds()

virtual MacDisplayIdList display_device::MacApiLayerInterface::getDisplayIds ( MacQueryType type) const
nodiscardpure virtual

Query macOS for display identifiers.

Parameters
typeDisplay list type to query.
Returns
Display identifiers matching the query.

Implemented in display_device::MacApiLayer.

◆ getDisplayModes()

virtual MacDisplayModeList display_device::MacApiLayerInterface::getDisplayModes ( MacDisplayId display_id) const
nodiscardpure virtual

Get available display modes for a display.

Parameters
display_idDisplay to query.
Returns
Available display modes.

Implemented in display_device::MacApiLayer.

◆ getDisplayName()

virtual std::string display_device::MacApiLayerInterface::getDisplayName ( MacDisplayId display_id) const
nodiscardpure virtual

Get the macOS capture selector for a display.

Parameters
display_idDisplay to query.
Returns
Decimal CoreGraphics display id string, or empty string if unavailable.

Implemented in display_device::MacApiLayer.

◆ getDisplayScale()

virtual std::optional< Rational > display_device::MacApiLayerInterface::getDisplayScale ( MacDisplayId display_id) const
nodiscardpure virtual

Get the display scale value.

Parameters
display_idDisplay to query.
Returns
Display scale, or empty optional if unavailable.

Implemented in display_device::MacApiLayer.

◆ getEdid()

virtual std::vector< std::byte > display_device::MacApiLayerInterface::getEdid ( MacDisplayId display_id) const
nodiscardpure virtual

Get EDID byte array for a display.

Parameters
display_idDisplay to query.
Returns
EDID byte array, or an empty array if unavailable.

Implemented in display_device::MacApiLayer.

◆ getErrorString()

virtual std::string display_device::MacApiLayerInterface::getErrorString ( MacApiError error_code) const
nodiscardpure virtual

Stringify a macOS display API error code.

Parameters
error_codeError code to stringify.
Returns
String containing a readable error description.

Implemented in display_device::MacApiLayer.

◆ getFriendlyName()

virtual std::string display_device::MacApiLayerInterface::getFriendlyName ( MacDisplayId display_id) const
nodiscardpure virtual

Get a human-readable display name.

Parameters
display_idDisplay to query.
Returns
Friendly display name or empty string if unavailable.

Implemented in display_device::MacApiLayer.

◆ getMirrorMaster()

virtual MacDisplayId display_device::MacApiLayerInterface::getMirrorMaster ( MacDisplayId display_id) const
nodiscardpure virtual

Get the display mirrored by the specified display.

Parameters
display_idDisplay to query.
Returns
Master display id, or zero if the display is not a secondary mirror.

Implemented in display_device::MacApiLayer.

◆ getOriginPoint()

virtual std::optional< Point > display_device::MacApiLayerInterface::getOriginPoint ( MacDisplayId display_id) const
nodiscardpure virtual

Get the display origin point.

Parameters
display_idDisplay to query.
Returns
Display origin, or empty optional if unavailable.

Implemented in display_device::MacApiLayer.

◆ isActive()

virtual bool display_device::MacApiLayerInterface::isActive ( MacDisplayId display_id) const
nodiscardpure virtual

Check whether a display is active.

Parameters
display_idDisplay to check.
Returns
True if the display is active, false otherwise.

Implemented in display_device::MacApiLayer.

◆ isApiAccessAvailable()

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

Check if display configuration APIs are accessible.

Returns
True if macOS display APIs can be called, false otherwise.

Implemented in display_device::MacApiLayer.

◆ isMainDisplay()

virtual bool display_device::MacApiLayerInterface::isMainDisplay ( MacDisplayId display_id) const
nodiscardpure virtual

Check whether a display is the main display.

Parameters
display_idDisplay to check.
Returns
True if the display is main, false otherwise.

Implemented in display_device::MacApiLayer.

◆ isOnline()

virtual bool display_device::MacApiLayerInterface::isOnline ( MacDisplayId display_id) const
nodiscardpure virtual

Check whether a display is online.

Parameters
display_idDisplay to check.
Returns
True if the display is online, false otherwise.

Implemented in display_device::MacApiLayer.

◆ releasePowerAssertion()

virtual bool display_device::MacApiLayerInterface::releasePowerAssertion ( MacPowerAssertionId assertion_id)
nodiscardpure virtual

Release a macOS power assertion.

Parameters
assertion_idAssertion id returned by declareUserActivity or createDisplaySleepAssertion.
Returns
True if the assertion was released, false otherwise.

Implemented in display_device::MacApiLayer.

◆ setDisplayMode()

virtual bool display_device::MacApiLayerInterface::setDisplayMode ( MacDisplayId display_id,
const MacDisplayMode & mode )
nodiscardpure virtual

Set the display mode for a display.

Parameters
display_idDisplay to modify.
modeMode to apply.
Returns
True if the display mode was applied, false otherwise.

Implemented in display_device::MacApiLayer.

◆ setMirror()

virtual bool display_device::MacApiLayerInterface::setMirror ( MacDisplayId display_id,
MacDisplayId master_display_id )
nodiscardpure virtual

Set a display as a mirror of another display.

Parameters
display_idDisplay to modify.
master_display_idMaster display to mirror.
Returns
True if mirroring was applied, false otherwise.

Implemented in display_device::MacApiLayer.

◆ setOriginPoint()

virtual bool display_device::MacApiLayerInterface::setOriginPoint ( MacDisplayId display_id,
const Point & origin )
nodiscardpure virtual

Set the origin point for a display.

Parameters
display_idDisplay to modify.
originOrigin point to apply.
Returns
True if the origin was applied, false otherwise.

Implemented in display_device::MacApiLayer.


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