libdisplaydevice master
C++ library to modify display devices.
display_device::MacApiLayer Class Reference

Default implementation for the MacApiLayerInterface. More...

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

Inheritance diagram for display_device::MacApiLayer:
[legend]
Collaboration diagram for display_device::MacApiLayer:
[legend]

Public Member Functions

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

Detailed Description

Default implementation for the MacApiLayerInterface.

Member Function Documentation

◆ createDisplaySleepAssertion()

std::optional< MacPowerAssertionId > display_device::MacApiLayer::createDisplaySleepAssertion ( const std::string & reason)
nodiscardoverridevirtual

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.

Implements display_device::MacApiLayerInterface.

◆ declareUserActivity()

std::optional< MacPowerAssertionId > display_device::MacApiLayer::declareUserActivity ( const std::string & reason)
nodiscardoverridevirtual

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.

Implements display_device::MacApiLayerInterface.

◆ getCurrentDisplayMode()

std::optional< MacDisplayMode > display_device::MacApiLayer::getCurrentDisplayMode ( MacDisplayId display_id) const
nodiscardoverridevirtual

Get the current display mode.

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

Implements display_device::MacApiLayerInterface.

◆ getDeviceId()

std::string display_device::MacApiLayer::getDeviceId ( MacDisplayId display_id) const
nodiscardoverridevirtual

Get the library device id for a display.

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

Implements display_device::MacApiLayerInterface.

◆ getDisplayIds()

MacDisplayIdList display_device::MacApiLayer::getDisplayIds ( MacQueryType type) const
nodiscardoverridevirtual

Query macOS for display identifiers.

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

Implements display_device::MacApiLayerInterface.

◆ getDisplayModes()

MacDisplayModeList display_device::MacApiLayer::getDisplayModes ( MacDisplayId display_id) const
nodiscardoverridevirtual

Get available display modes for a display.

Parameters
display_idDisplay to query.
Returns
Available display modes.

Implements display_device::MacApiLayerInterface.

◆ getDisplayName()

std::string display_device::MacApiLayer::getDisplayName ( MacDisplayId display_id) const
nodiscardoverridevirtual

Get the macOS capture selector for a display.

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

Implements display_device::MacApiLayerInterface.

◆ getDisplayScale()

std::optional< Rational > display_device::MacApiLayer::getDisplayScale ( MacDisplayId display_id) const
nodiscardoverridevirtual

Get the display scale value.

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

Implements display_device::MacApiLayerInterface.

◆ getEdid()

std::vector< std::byte > display_device::MacApiLayer::getEdid ( MacDisplayId display_id) const
nodiscardoverridevirtual

Get EDID byte array for a display.

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

Implements display_device::MacApiLayerInterface.

◆ getErrorString()

std::string display_device::MacApiLayer::getErrorString ( MacApiError error_code) const
nodiscardoverridevirtual

Stringify a macOS display API error code.

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

Implements display_device::MacApiLayerInterface.

◆ getFriendlyName()

std::string display_device::MacApiLayer::getFriendlyName ( MacDisplayId display_id) const
nodiscardoverridevirtual

Get a human-readable display name.

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

Implements display_device::MacApiLayerInterface.

◆ getMirrorMaster()

MacDisplayId display_device::MacApiLayer::getMirrorMaster ( MacDisplayId display_id) const
nodiscardoverridevirtual

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.

Implements display_device::MacApiLayerInterface.

◆ getOriginPoint()

std::optional< Point > display_device::MacApiLayer::getOriginPoint ( MacDisplayId display_id) const
nodiscardoverridevirtual

Get the display origin point.

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

Implements display_device::MacApiLayerInterface.

◆ isActive()

bool display_device::MacApiLayer::isActive ( MacDisplayId display_id) const
nodiscardoverridevirtual

Check whether a display is active.

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

Implements display_device::MacApiLayerInterface.

◆ isApiAccessAvailable()

bool display_device::MacApiLayer::isApiAccessAvailable ( ) const
nodiscardoverridevirtual

Check if display configuration APIs are accessible.

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

Implements display_device::MacApiLayerInterface.

◆ isMainDisplay()

bool display_device::MacApiLayer::isMainDisplay ( MacDisplayId display_id) const
nodiscardoverridevirtual

Check whether a display is the main display.

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

Implements display_device::MacApiLayerInterface.

◆ isOnline()

bool display_device::MacApiLayer::isOnline ( MacDisplayId display_id) const
nodiscardoverridevirtual

Check whether a display is online.

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

Implements display_device::MacApiLayerInterface.

◆ releasePowerAssertion()

bool display_device::MacApiLayer::releasePowerAssertion ( MacPowerAssertionId assertion_id)
nodiscardoverridevirtual

Release a macOS power assertion.

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

Implements display_device::MacApiLayerInterface.

◆ setDisplayMode()

bool display_device::MacApiLayer::setDisplayMode ( MacDisplayId display_id,
const MacDisplayMode & mode )
nodiscardoverridevirtual

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.

Implements display_device::MacApiLayerInterface.

◆ setMirror()

bool display_device::MacApiLayer::setMirror ( MacDisplayId display_id,
MacDisplayId master_display_id )
nodiscardoverridevirtual

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.

Implements display_device::MacApiLayerInterface.

◆ setOriginPoint()

bool display_device::MacApiLayer::setOriginPoint ( MacDisplayId display_id,
const Point & origin )
nodiscardoverridevirtual

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.

Implements display_device::MacApiLayerInterface.


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