libdisplaydevice master
C++ library to modify display devices.
mac_api_layer_interface.h
Go to the documentation of this file.
1
5#pragma once
6
7// local includes
8#include "types.h"
9
10namespace display_device {
15 public:
19 virtual ~MacApiLayerInterface() = default;
20
25 [[nodiscard]] virtual bool isApiAccessAvailable() const = 0;
26
32 [[nodiscard]] virtual std::string getErrorString(MacApiError error_code) const = 0;
33
39 [[nodiscard]] virtual MacDisplayIdList getDisplayIds(MacQueryType type) const = 0;
40
46 [[nodiscard]] virtual std::optional<MacPowerAssertionId> declareUserActivity(const std::string &reason) = 0;
47
53 [[nodiscard]] virtual std::optional<MacPowerAssertionId> createDisplaySleepAssertion(const std::string &reason) = 0;
54
60 [[nodiscard]] virtual bool releasePowerAssertion(MacPowerAssertionId assertion_id) = 0;
61
67 [[nodiscard]] virtual std::string getDeviceId(MacDisplayId display_id) const = 0;
68
74 [[nodiscard]] virtual std::optional<MacDisplayMode> getCurrentDisplayMode(MacDisplayId display_id) const = 0;
75
81 [[nodiscard]] virtual MacDisplayModeList getDisplayModes(MacDisplayId display_id) const = 0;
82
88 [[nodiscard]] virtual std::string getDisplayName(MacDisplayId display_id) const = 0;
89
95 [[nodiscard]] virtual std::string getFriendlyName(MacDisplayId display_id) const = 0;
96
102 [[nodiscard]] virtual std::vector<std::byte> getEdid(MacDisplayId display_id) const = 0;
103
109 [[nodiscard]] virtual std::optional<Rational> getDisplayScale(MacDisplayId display_id) const = 0;
110
116 [[nodiscard]] virtual std::optional<Point> getOriginPoint(MacDisplayId display_id) const = 0;
117
123 [[nodiscard]] virtual bool isMainDisplay(MacDisplayId display_id) const = 0;
124
130 [[nodiscard]] virtual bool isActive(MacDisplayId display_id) const = 0;
131
137 [[nodiscard]] virtual bool isOnline(MacDisplayId display_id) const = 0;
138
144 [[nodiscard]] virtual MacDisplayId getMirrorMaster(MacDisplayId display_id) const = 0;
145
152 [[nodiscard]] virtual bool setDisplayMode(MacDisplayId display_id, const MacDisplayMode &mode) = 0;
153
160 [[nodiscard]] virtual bool setOriginPoint(MacDisplayId display_id, const Point &origin) = 0;
161
168 [[nodiscard]] virtual bool setMirror(MacDisplayId display_id, MacDisplayId master_display_id) = 0;
169 };
170} // namespace display_device
Lowest level macOS API wrapper for easy mocking.
Definition mac_api_layer_interface.h:14
virtual bool setDisplayMode(MacDisplayId display_id, const MacDisplayMode &mode)=0
Set the display mode for a display.
virtual ~MacApiLayerInterface()=default
Default virtual destructor.
virtual std::optional< MacPowerAssertionId > declareUserActivity(const std::string &reason)=0
Tell macOS that the user is active and displays should wake.
virtual bool isApiAccessAvailable() const =0
Check if display configuration APIs are accessible.
virtual std::optional< Rational > getDisplayScale(MacDisplayId display_id) const =0
Get the display scale value.
virtual std::optional< MacPowerAssertionId > createDisplaySleepAssertion(const std::string &reason)=0
Create a power assertion that prevents user-idle display sleep.
virtual bool isOnline(MacDisplayId display_id) const =0
Check whether a display is online.
virtual std::optional< MacDisplayMode > getCurrentDisplayMode(MacDisplayId display_id) const =0
Get the current display mode.
virtual bool isActive(MacDisplayId display_id) const =0
Check whether a display is active.
virtual std::optional< Point > getOriginPoint(MacDisplayId display_id) const =0
Get the display origin point.
virtual std::string getDeviceId(MacDisplayId display_id) const =0
Get the library device id for a display.
virtual bool isMainDisplay(MacDisplayId display_id) const =0
Check whether a display is the main display.
virtual bool setMirror(MacDisplayId display_id, MacDisplayId master_display_id)=0
Set a display as a mirror of another display.
virtual std::vector< std::byte > getEdid(MacDisplayId display_id) const =0
Get EDID byte array for a display.
virtual bool releasePowerAssertion(MacPowerAssertionId assertion_id)=0
Release a macOS power assertion.
virtual MacDisplayModeList getDisplayModes(MacDisplayId display_id) const =0
Get available display modes for a display.
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::string getErrorString(MacApiError error_code) const =0
Stringify a macOS display API error code.
virtual MacDisplayIdList getDisplayIds(MacQueryType type) const =0
Query macOS for display identifiers.
virtual std::string getDisplayName(MacDisplayId display_id) const =0
Get the macOS capture selector for a display.
virtual bool setOriginPoint(MacDisplayId display_id, const Point &origin)=0
Set the origin point for a display.
Declarations for macOS specific display device types.
std::uint32_t MacPowerAssertionId
macOS power assertion identifier.
Definition types.h:38
std::vector< MacDisplayId > MacDisplayIdList
A list of CoreGraphics display identifiers.
Definition types.h:43
MacQueryType
Type of display list to query from macOS.
Definition types.h:48
std::uint32_t MacDisplayId
CoreGraphics display identifier.
Definition types.h:29
int MacApiError
Error code returned by macOS display APIs.
Definition types.h:20
std::vector< MacDisplayMode > MacDisplayModeList
A list of macOS display modes.
Definition types.h:77
Display mode data used by the macOS backend.
Definition types.h:64
An arbitrary point object.
Definition types.h:91