openharmony 鸿蒙 capi-oh-display-manager-h

2025-06-12 浏览 (1)

oh_display_manager.h

Overview

The oh_display_manager.h file declares the functions for basic display management. You can call the functions to obtain various information about the default display and listen for display status changes, such as rotation, folding, and unfolding.

File to include: <window_manager/oh_display_manager.h>

Library: libnative_display_manager.so

System capability: SystemCapability.WindowManager.WindowManager.Core

Since: 12

Related module: OH_DisplayManager

Summary

Functions

Nametypedef KeywordDescription
NativeDisplayManager_ErrorCode OH_NativeDisplayManager_GetDefaultDisplayId(uint64_t *displayId)-Obtains the ID of the default display.
NativeDisplayManager_ErrorCode OH_NativeDisplayManager_GetDefaultDisplayWidth(int32_t *displayWidth)-Obtains the width of the default display.
NativeDisplayManager_ErrorCode OH_NativeDisplayManager_GetDefaultDisplayHeight(int32_t *displayHeight)-Obtains the height of the default display.
NativeDisplayManager_ErrorCode OH_NativeDisplayManager_GetDefaultDisplayRotation(NativeDisplayManager_Rotation *displayRotation)-Obtains the clockwise rotation angle of the default display.
NativeDisplayManager_ErrorCode OH_NativeDisplayManager_GetDefaultDisplayOrientation(NativeDisplayManager_Orientation *displayOrientation)-Obtains the orientation of the default display.
NativeDisplayManager_ErrorCode OH_NativeDisplayManager_GetDefaultDisplayVirtualPixelRatio(float *virtualPixels)-Obtains the virtual pixel ratio of the default display.
NativeDisplayManager_ErrorCode OH_NativeDisplayManager_GetDefaultDisplayRefreshRate(uint32_t *refreshRate)-Obtains the refresh rate of the default display.
NativeDisplayManager_ErrorCode OH_NativeDisplayManager_GetDefaultDisplayDensityDpi(int32_t *densityDpi)-Obtains the physical pixel density of the default display.
NativeDisplayManager_ErrorCode OH_NativeDisplayManager_GetDefaultDisplayDensityPixels(float *densityPixels)-Obtains the logical pixel density of the default display.
NativeDisplayManager_ErrorCode OH_NativeDisplayManager_GetDefaultDisplayScaledDensity(float *scaledDensity)-Obtains the scale factor of fonts displayed on the default display.
NativeDisplayManager_ErrorCode OH_NativeDisplayManager_GetDefaultDisplayDensityXdpi(float *xDpi)-Obtains the number of physical pixels per inch on the default display in the X dimension.
NativeDisplayManager_ErrorCode OH_NativeDisplayManager_GetDefaultDisplayDensityYdpi(float *yDpi)-Obtains the number of physical pixels per inch on the default display in the Y dimension.
NativeDisplayManager_ErrorCode OH_NativeDisplayManager_CreateDefaultDisplayCutoutInfo(NativeDisplayManager_CutoutInfo **cutoutInfo)-Obtains the unusable area of the default display, including punch hole, notch, and curved area of a waterfall display.
NativeDisplayManager_ErrorCode OH_NativeDisplayManager_DestroyDefaultDisplayCutoutInfo(NativeDisplayManager_CutoutInfo *cutoutInfo)-Destroys the unusable area of the default display, including punch hole, notch, and curved area of a waterfall display.
bool OH_NativeDisplayManager_IsFoldable()-Checks whether the current device is foldable.
NativeDisplayManager_ErrorCode OH_NativeDisplayManager_GetFoldDisplayMode(NativeDisplayManager_FoldDisplayMode *displayMode)-Obtains the display mode of the foldable device.
typedef void (*OH_NativeDisplayManager_DisplayChangeCallback)(uint64_t displayId)OH_NativeDisplayManager_DisplayChangeCallbackDefines a callback function to listen for display status changes.
NativeDisplayManager_ErrorCode OH_NativeDisplayManager_RegisterDisplayChangeListener(OH_NativeDisplayManager_DisplayChangeCallback displayChangeCallback, uint32_t *listenerIndex)-Registers a listener for display status changes (such as rotation, refresh rate, DPI, and resolution changes).
NativeDisplayManager_ErrorCode OH_NativeDisplayManager_UnregisterDisplayChangeListener(uint32_t listenerIndex)-Unregisters a listener for display status changes.
typedef void (*OH_NativeDisplayManager_FoldDisplayModeChangeCallback)(NativeDisplayManager_FoldDisplayMode displayMode)OH_NativeDisplayManager_FoldDisplayModeChangeCallbackDefines a callback function to listen for folded/unfolded state changes of the display.
NativeDisplayManager_ErrorCode OH_NativeDisplayManager_RegisterFoldDisplayModeChangeListener(OH_NativeDisplayManager_FoldDisplayModeChangeCallback displayModeChangeCallback, uint32_t *listenerIndex)-Registers a listener for folded/unfolded state changes of the display.
NativeDisplayManager_ErrorCode OH_NativeDisplayManager_UnregisterFoldDisplayModeChangeListener(uint32_t listenerIndex)-Unregisters a listener for folded/unfolded state changes of the display.
NativeDisplayManager_ErrorCode OH_NativeDisplayManager_CreateAllDisplays(NativeDisplayManager_DisplaysInfo **allDisplays)-Obtains the object that contains the information about all displays.
void OH_NativeDisplayManager_DestroyAllDisplays(NativeDisplayManager_DisplaysInfo *allDisplays)-Destroys the object that contains the information about all displays.
NativeDisplayManager_ErrorCode OH_NativeDisplayManager_CreateDisplayById(uint32_t displayId,NativeDisplayManager_DisplayInfo **displayInfo)-Obtains the object that contains the information about a display.
void OH_NativeDisplayManager_DestroyDisplay(NativeDisplayManager_DisplayInfo *displayInfo)-Destroys the object that contains the information about a display.
NativeDisplayManager_ErrorCode OH_NativeDisplayManager_CreatePrimaryDisplay(NativeDisplayManager_DisplayInfo **displayInfo)-Obtains the object that contains the information about the primary display. For devices other than 2-in-1 devices, the displayInfo object obtained contains information about the built-in screen. For 2-in-1 devices with an external screen, the displayInfo object obtained contains information about the current primary screen. For 2-in-1 devices without an external screen, the displayInfo object obtained contains information about the built-in screen.
typedef void (*OH_NativeDisplayManager_AvailableAreaChangeCallback)(uint64_t displayId)OH_NativeDisplayManager_AvailableAreaChangeCallbackDefines a callback function to listen for available area changes of a display.
NativeDisplayManager_ErrorCode OH_NativeDisplayManager_RegisterAvailableAreaChangeListener(OH_NativeDisplayManager_AvailableAreaChangeCallback availableAreaChangeCallback, uint32_t *listenerIndex)-Registers a listener for available area changes of the display.
NativeDisplayManager_ErrorCode OH_NativeDisplayManager_UnregisterAvailableAreaChangeListener(uint32_t listenerIndex)-Unregisters a listener for available area changes of the display.
NativeDisplayManager_ErrorCode OH_NativeDisplayManager_CreateAvailableArea(uint64_t displayId, NativeDisplayManager_Rect **availableArea)-Obtains the available area of a display.
NativeDisplayManager_ErrorCode OH_NativeDisplayManager_DestroyAvailableArea(NativeDisplayManager_Rect *availableArea)-Destroys the available area of a display.
typedef void (*OH_NativeDisplayManager_DisplayAddCallback)(uint64_t displayId)OH_NativeDisplayManager_DisplayAddCallbackDefines a callback function to listen for display addition events.
NativeDisplayManager_ErrorCode OH_NativeDisplayManager_RegisterDisplayAddListener(OH_NativeDisplayManager_DisplayAddCallback displayAddCallback, uint32_t *listenerIndex)-Registers a listener for display addition events (for example, monitor inserted).
NativeDisplayManager_ErrorCode OH_NativeDisplayManager_UnregisterDisplayAddListener(uint32_t listenerIndex)-Unregisters a listener for display addition events.
typedef void (*OH_NativeDisplayManager_DisplayRemoveCallback)(uint64_t displayId)OH_NativeDisplayManager_DisplayRemoveCallbackDefines a callback function to listen for display removal events.
NativeDisplayManager_ErrorCode OH_NativeDisplayManager_RegisterDisplayRemoveListener(OH_NativeDisplayManager_DisplayRemoveCallback displayRemoveCallback, uint32_t *listenerIndex)-Registers a listener for display removal events (for example, monitor removed).
NativeDisplayManager_ErrorCode OH_NativeDisplayManager_UnregisterDisplayRemoveListener(uint32_t listenerIndex)-Unregisters a listener for display removal events.
NativeDisplayManager_ErrorCode OH_NativeDisplayManager_GetDisplaySourceMode(uint64_t displayId, NativeDisplayManager_SourceMode *sourceMode)-Obtains the source mode of a display.
NativeDisplayManager_ErrorCode OH_NativeDisplayManager_GetDisplayPosition(uint64_t displayId, int32_t *x, int32_t *y)-Obtains the position of a display.

Function Description

OH_NativeDisplayManager_GetDefaultDisplayId()

NativeDisplayManager_ErrorCode OH_NativeDisplayManager_GetDefaultDisplayId(uint64_t *displayId)

Description

Obtains the ID of the default display.

System capability: SystemCapability.WindowManager.WindowManager.Core

Since: 12

Parameters

ParameterDescription
uint64_t *displayIdPointer to the display ID. The value is a non-negative integer.

Return value

TypeDescription
NativeDisplayManager_ErrorCodeStatus code defined in NativeDisplayManager_ErrorCode.

OH_NativeDisplayManager_GetDefaultDisplayWidth()

NativeDisplayManager_ErrorCode OH_NativeDisplayManager_GetDefaultDisplayWidth(int32_t *displayWidth)

Description

Obtains the width of the default display.

System capability: SystemCapability.WindowManager.WindowManager.Core

Since: 12

Parameters

ParameterDescription
int32_t *displayWidthPointer to the width, in px. The value is an integer.

Return value

TypeDescription
NativeDisplayManager_ErrorCodeStatus code defined in NativeDisplayManager_ErrorCode.

OH_NativeDisplayManager_GetDefaultDisplayHeight()

NativeDisplayManager_ErrorCode OH_NativeDisplayManager_GetDefaultDisplayHeight(int32_t *displayHeight)

Description

Obtains the height of the default display.

System capability: SystemCapability.WindowManager.WindowManager.Core

Since: 12

Parameters

ParameterDescription
int32_t *displayHeightPointer to the height, in px. The value is an integer.

Return value

TypeDescription
NativeDisplayManager_ErrorCodeStatus code defined in NativeDisplayManager_ErrorCode.

OH_NativeDisplayManager_GetDefaultDisplayRotation()

NativeDisplayManager_ErrorCode OH_NativeDisplayManager_GetDefaultDisplayRotation(NativeDisplayManager_Rotation *displayRotation)

Description

Obtains the clockwise rotation angle of the default display.

System capability: SystemCapability.WindowManager.WindowManager.Core

Since: 12

Parameters

ParameterDescription
NativeDisplayManager_Rotation *displayRotationPointer to the clockwise rotation angle. For details about the available options, see NativeDisplayManager_Rotation.

Return value

TypeDescription
NativeDisplayManager_ErrorCodeStatus code defined in NativeDisplayManager_ErrorCode.

OH_NativeDisplayManager_GetDefaultDisplayOrientation()

NativeDisplayManager_ErrorCode OH_NativeDisplayManager_GetDefaultDisplayOrientation(NativeDisplayManager_Orientation *displayOrientation)

Description

Obtains the orientation of the default display.

System capability: SystemCapability.WindowManager.WindowManager.Core

Since: 12

Parameters

ParameterDescription
NativeDisplayManager_Orientation *displayOrientationPointer to the orientation. For details about the available options, see NativeDisplayManager_Orientation.

Return value

TypeDescription
NativeDisplayManager_ErrorCodeStatus code defined in NativeDisplayManager_ErrorCode.

OH_NativeDisplayManager_GetDefaultDisplayVirtualPixelRatio()

NativeDisplayManager_ErrorCode OH_NativeDisplayManager_GetDefaultDisplayVirtualPixelRatio(float *virtualPixels)

Description

Obtains the virtual pixel ratio of the default display.

System capability: SystemCapability.WindowManager.WindowManager.Core

Since: 12

Parameters

ParameterDescription
float *virtualPixelsPointer to the virtual pixel ratio. The value is a floating-point number, and it is usually the same as that of densityPixels.

Return value

TypeDescription
NativeDisplayManager_ErrorCodeStatus code defined in NativeDisplayManager_ErrorCode.

OH_NativeDisplayManager_GetDefaultDisplayRefreshRate()

NativeDisplayManager_ErrorCode OH_NativeDisplayManager_GetDefaultDisplayRefreshRate(uint32_t *refreshRate)

Description

Obtains the refresh rate of the default display.

System capability: SystemCapability.WindowManager.WindowManager.Core

Since: 12

Parameters

ParameterDescription
uint32_t *refreshRatePointer to the refresh rate. The value is an integer, in Hz.

Return value

TypeDescription
NativeDisplayManager_ErrorCodeStatus code defined in NativeDisplayManager_ErrorCode.

OH_NativeDisplayManager_GetDefaultDisplayDensityDpi()

NativeDisplayManager_ErrorCode OH_NativeDisplayManager_GetDefaultDisplayDensityDpi(int32_t *densityDpi)

Description

Obtains the physical pixel density of the default display.

System capability: SystemCapability.WindowManager.WindowManager.Core

Since: 12

Parameters

ParameterDescription
int32_t *densityDpiPointer to the physical pixel density, that is, the number of pixels per inch. The value is an integer, in px. The actual value depends on the options provided in device settings.

Return value

TypeDescription
NativeDisplayManager_ErrorCodeStatus code defined in NativeDisplayManager_ErrorCode.

OH_NativeDisplayManager_GetDefaultDisplayDensityPixels()

NativeDisplayManager_ErrorCode OH_NativeDisplayManager_GetDefaultDisplayDensityPixels(float *densityPixels)

Description

Obtains the logical pixel density of the default display.

System capability: SystemCapability.WindowManager.WindowManager.Core

Since: 12

Parameters

ParameterDescription
float *densityPixelsPointer to the logical pixel density, which indicates the scaling coefficient of the physical pixels and logical pixels. The value is a floating point number in the range [0.5, 4.0]. Generally, the value is 1.0 or 3.0. The actual value depends on the density DPI provided by the device in use.

Return value

TypeDescription
NativeDisplayManager_ErrorCodeStatus code defined in NativeDisplayManager_ErrorCode.

OH_NativeDisplayManager_GetDefaultDisplayScaledDensity()

NativeDisplayManager_ErrorCode OH_NativeDisplayManager_GetDefaultDisplayScaledDensity(float *scaledDensity)

Description

Obtains the scale factor of fonts displayed on the default display.

System capability: SystemCapability.WindowManager.WindowManager.Core

Since: 12

Parameters

ParameterDescription
float *scaledDensityPointer to the scale factor. The value is a floating-point number, and it is usually the same as that of densityPixels.

Return value

TypeDescription
NativeDisplayManager_ErrorCodeStatus code defined in NativeDisplayManager_ErrorCode.

OH_NativeDisplayManager_GetDefaultDisplayDensityXdpi()

NativeDisplayManager_ErrorCode OH_NativeDisplayManager_GetDefaultDisplayDensityXdpi(float *xDpi)

Description

Obtains the number of physical pixels per inch on the default display in the X dimension.

System capability: SystemCapability.WindowManager.WindowManager.Core

Since: 12

Parameters

ParameterDescription
float *xDpiPointer to the number of physical pixels per inch in the X dimension. The value is a floating point number.

Return value

TypeDescription
NativeDisplayManager_ErrorCodeStatus code defined in NativeDisplayManager_ErrorCode.

OH_NativeDisplayManager_GetDefaultDisplayDensityYdpi()

NativeDisplayManager_ErrorCode OH_NativeDisplayManager_GetDefaultDisplayDensityYdpi(float *yDpi)

Description

Obtains the number of physical pixels per inch on the default display in the Y dimension.

System capability: SystemCapability.WindowManager.WindowManager.Core

Since: 12

Parameters

ParameterDescription
float *yDpiPointer to the number of physical pixels per inch in the Y dimension. The value is a floating point number.

Return value

TypeDescription
NativeDisplayManager_ErrorCodeStatus code defined in NativeDisplayManager_ErrorCode.

OH_NativeDisplayManager_CreateDefaultDisplayCutoutInfo()

NativeDisplayManager_ErrorCode OH_NativeDisplayManager_CreateDefaultDisplayCutoutInfo(NativeDisplayManager_CutoutInfo **cutoutInfo)

Description

Obtains the unusable area of the default display, including punch hole, notch, and curved area of a waterfall display.

System capability: SystemCapability.WindowManager.WindowManager.Core

Since: 12

Parameters

ParameterDescription
NativeDisplayManager_CutoutInfo **cutoutInfoDouble pointer to the unusable area information, which is encapsulated in NativeDisplayManager_CutoutInfo.

Return value

TypeDescription
NativeDisplayManager_ErrorCodeStatus code defined in NativeDisplayManager_ErrorCode.

OH_NativeDisplayManager_DestroyDefaultDisplayCutoutInfo()

NativeDisplayManager_ErrorCode OH_NativeDisplayManager_DestroyDefaultDisplayCutoutInfo(NativeDisplayManager_CutoutInfo *cutoutInfo)

Description

Destroys the unusable area of the default display, including punch hole, notch, and curved area of a waterfall display.

System capability: SystemCapability.WindowManager.WindowManager.Core

Since: 12

Parameters

ParameterDescription
NativeDisplayManager_CutoutInfo *cutoutInfoPointer to the unusable area information object, which is obtained by calling OH_NativeDisplayManager_CreateDefaultDisplayCutoutInfo. For details, see NativeDisplayManager_CutoutInfo.

Return value

TypeDescription
NativeDisplayManager_ErrorCodeStatus code defined in NativeDisplayManager_ErrorCode.

OH_NativeDisplayManager_IsFoldable()

bool OH_NativeDisplayManager_IsFoldable()

Description

Checks whether the current device is foldable.

System capability: SystemCapability.WindowManager.WindowManager.Core

Since: 12

Return value

TypeDescription
boolCheck result. The value true means that the device is foldable, and false means the opposite.

OH_NativeDisplayManager_GetFoldDisplayMode()

NativeDisplayManager_ErrorCode OH_NativeDisplayManager_GetFoldDisplayMode(NativeDisplayManager_FoldDisplayMode *displayMode)

Description

Obtains the display mode of the foldable device.

System capability: SystemCapability.Window.SessionManager

Since: 12

Parameters

ParameterDescription
NativeDisplayManager_FoldDisplayMode *displayModePointer to the display mode. For details about the available options, see NativeDisplayManager_FoldDisplayMode.

Return value

TypeDescription
NativeDisplayManager_ErrorCodeStatus code defined in NativeDisplayManager_ErrorCode.

OH_NativeDisplayManager_DisplayChangeCallback()

typedef void (*OH_NativeDisplayManager_DisplayChangeCallback)(uint64_t displayId)

Description

Defines a callback function to listen for display status changes.

System capability: SystemCapability.Window.SessionManager

Since: 12

Parameters

ParameterDescription
uint64_t displayIdID of the display.

OH_NativeDisplayManager_RegisterDisplayChangeListener()

NativeDisplayManager_ErrorCode OH_NativeDisplayManager_RegisterDisplayChangeListener(OH_NativeDisplayManager_DisplayChangeCallback displayChangeCallback, uint32_t *listenerIndex)

Description

Registers a listener for display status changes (such as rotation, refresh rate, DPI, and resolution changes).

System capability: SystemCapability.WindowManager.WindowManager.Core

Since: 12

Parameters

ParameterDescription
OH_NativeDisplayManager_DisplayChangeCallback displayChangeCallbackCallback function triggered when the display status is changed. For details, see OH_NativeDisplayManager_DisplayChangeCallback.
uint32_t *listenerIndexPointer to the index of the listener registered. It can be used as an input parameter of OH_NativeDisplayManager_UnregisterDisplayChangeListener.

Return value

TypeDescription
NativeDisplayManager_ErrorCodeStatus code defined in NativeDisplayManager_ErrorCode.

OH_NativeDisplayManager_UnregisterDisplayChangeListener()

NativeDisplayManager_ErrorCode OH_NativeDisplayManager_UnregisterDisplayChangeListener(uint32_t listenerIndex)

Description

Unregisters a listener for display status changes.

System capability: SystemCapability.WindowManager.WindowManager.Core

Since: 12

Parameters

ParameterDescription
uint32_t listenerIndexIndex of the listener returned when OH_NativeDisplayManager_RegisterDisplayChangeListener is called.

Return value

TypeDescription
NativeDisplayManager_ErrorCodeStatus code defined in NativeDisplayManager_ErrorCode.

OH_NativeDisplayManager_FoldDisplayModeChangeCallback()

typedef void (*OH_NativeDisplayManager_FoldDisplayModeChangeCallback)(NativeDisplayManager_FoldDisplayMode displayMode)

Description

Defines a callback function to listen for folded/unfolded state changes of the display.

System capability: SystemCapability.Window.SessionManager

Since: 12

Parameters

ParameterDescription
NativeDisplayManager_FoldDisplayMode displayModeFolded or unfolded state of the display. For details about the available options, see NativeDisplayManager_FoldDisplayMode.

OH_NativeDisplayManager_RegisterFoldDisplayModeChangeListener()

NativeDisplayManager_ErrorCode OH_NativeDisplayManager_RegisterFoldDisplayModeChangeListener(OH_NativeDisplayManager_FoldDisplayModeChangeCallback displayModeChangeCallback, uint32_t *listenerIndex)

Description

Registers a listener for folded/unfolded state changes of the display.

System capability: SystemCapability.Window.SessionManager

Since: 12

Parameters

ParameterDescription
OH_NativeDisplayManager_FoldDisplayModeChangeCallback displayModeChangeCallbackCallback function triggered when the folded/unfolded state of the display is changed. For details, see OH_NativeDisplayManager_FoldDisplayModeChangeCallback.
uint32_t *listenerIndexPointer to the index of the listener registered. It can be used as an input parameter of OH_NativeDisplayManager_UnregisterFoldDisplayModeChangeListener.

Return value

TypeDescription
NativeDisplayManager_ErrorCodeStatus code defined in NativeDisplayManager_ErrorCode.

OH_NativeDisplayManager_UnregisterFoldDisplayModeChangeListener()

NativeDisplayManager_ErrorCode OH_NativeDisplayManager_UnregisterFoldDisplayModeChangeListener(uint32_t listenerIndex)

Description

Unregisters a listener for folded/unfolded state changes of the display.

System capability: SystemCapability.Window.SessionManager

Since: 12

Parameters

ParameterDescription
uint32_t listenerIndexIndex of the listener returned when OH_NativeDisplayManager_RegisterFoldDisplayModeChangeListener is called.

Return value

TypeDescription
NativeDisplayManager_ErrorCodeStatus code defined in NativeDisplayManager_ErrorCode.

OH_NativeDisplayManager_CreateAllDisplays()

NativeDisplayManager_ErrorCode OH_NativeDisplayManager_CreateAllDisplays(NativeDisplayManager_DisplaysInfo **allDisplays)

Description

Obtains the object that contains the information about all displays.

System capability: SystemCapability.Window.SessionManager.Core

Since: 14

Parameters

ParameterDescription
NativeDisplayManager_DisplaysInfo **allDisplaysDouble pointer to the display information, which is encapsulated in NativeDisplayManager_DisplaysInfo.

Return value

TypeDescription
NativeDisplayManager_ErrorCodeStatus code defined in NativeDisplayManager_ErrorCode.

OH_NativeDisplayManager_DestroyAllDisplays()

void OH_NativeDisplayManager_DestroyAllDisplays(NativeDisplayManager_DisplaysInfo *allDisplays)

Description

Destroys the object that contains the information about all displays.

System capability: SystemCapability.Window.SessionManager.Core

Since: 14

Parameters

ParameterDescription
NativeDisplayManager_DisplaysInfo *allDisplaysPointer to the display information object, which is obtained by calling OH_NativeDisplayManager_CreateAllDisplays. For details, see NativeDisplayManager_DisplaysInfo.

OH_NativeDisplayManager_CreateDisplayById()

NativeDisplayManager_ErrorCode OH_NativeDisplayManager_CreateDisplayById(uint32_t displayId,NativeDisplayManager_DisplayInfo **displayInfo)

Description

Obtains the object that contains the information about a display.

System capability: SystemCapability.Window.SessionManager.Core

Since: 14

Parameters

ParameterDescription
uint32_t displayIdID of the display. The value must be a non-negative integer.
NativeDisplayManager_DisplayInfo **displayInfoDouble pointer to the display information, which is encapsulated in NativeDisplayManager_DisplayInfo.

Return value

TypeDescription
NativeDisplayManager_ErrorCodeStatus code defined in NativeDisplayManager_ErrorCode.

OH_NativeDisplayManager_DestroyDisplay()

void OH_NativeDisplayManager_DestroyDisplay(NativeDisplayManager_DisplayInfo *displayInfo)

Description

Destroys the object that contains the information about a display.

System capability: SystemCapability.Window.SessionManager.Core

Since: 14

Parameters

ParameterDescription
NativeDisplayManager_DisplayInfo *displayInfoPointer to the display information object, which is obtained by calling OH_NativeDisplayManager_CreateDisplayById or OH_NativeDisplayManager_CreatePrimaryDisplay. For details, see NativeDisplayManager_DisplayInfo.

OH_NativeDisplayManager_CreatePrimaryDisplay()

NativeDisplayManager_ErrorCode OH_NativeDisplayManager_CreatePrimaryDisplay(NativeDisplayManager_DisplayInfo **displayInfo)

Description

Obtains the object that contains the information about the primary display. For devices other than 2-in-1 devices, the displayInfo object obtained contains information about the built-in screen. For 2-in-1 devices with an external screen, the displayInfo object obtained contains information about the current primary screen. For 2-in-1 devices without an external screen, the displayInfo object obtained contains information about the built-in screen.

System capability: SystemCapability.Window.SessionManager.Core

Since: 14

Parameters

ParameterDescription
NativeDisplayManager_DisplayInfo **displayInfoDouble pointer to the display information, which is encapsulated in NativeDisplayManager_DisplayInfo.

Return value

TypeDescription
NativeDisplayManager_ErrorCodeStatus code defined in NativeDisplayManager_ErrorCode.

OH_NativeDisplayManager_AvailableAreaChangeCallback()

typedef void (*OH_NativeDisplayManager_AvailableAreaChangeCallback)(uint64_t displayId)

Description

Defines a callback function to listen for available area changes of a display.

Since: 20

Parameters

ParameterDescription
uint64_t displayIdDisplay ID, which is a non-negative integer.

OH_NativeDisplayManager_RegisterAvailableAreaChangeListener()

NativeDisplayManager_ErrorCode OH_NativeDisplayManager_RegisterAvailableAreaChangeListener(OH_NativeDisplayManager_AvailableAreaChangeCallback availableAreaChangeCallback, uint32_t *listenerIndex)

Description

Registers a listener for available area changes of the display.

Since: 20

Parameters

ParameterDescription
OH_NativeDisplayManager_AvailableAreaChangeCallback availableAreaChangeCallbackCallback function triggered when the available area of the display changes.
For details, see OH_NativeDisplayManager_AvailableAreaChangeCallback.
uint32_t *listenerIndexPointer to the index of the listener registered.
It can be used as an input parameter of OH_NativeDisplayManager_UnregisterAvailableAreaChangeListener.

Return value

TypeDescription
NativeDisplayManager_ErrorCodeStatus code defined in NativeDisplayManager_ErrorCode.

OH_NativeDisplayManager_UnregisterAvailableAreaChangeListener()

NativeDisplayManager_ErrorCode OH_NativeDisplayManager_UnregisterAvailableAreaChangeListener(uint32_t listenerIndex)

Description

Unregisters a listener for available area changes of the display.

Since: 20

Parameters

ParameterDescription
uint32_t listenerIndexIndex of the listener returned
when OH_NativeDisplayManager_RegisterAvailableAreaChangeListener is called.

Return value

TypeDescription
NativeDisplayManager_ErrorCodeStatus code defined in NativeDisplayManager_ErrorCode.

OH_NativeDisplayManager_CreateAvailableArea()

NativeDisplayManager_ErrorCode OH_NativeDisplayManager_CreateAvailableArea(uint64_t displayId, NativeDisplayManager_Rect **availableArea)

Description

Obtains the available area of a display. This function can be used only on 2-in-1 devices.

Since: 20

Parameters

ParameterDescription
uint64_t displayIdDisplay ID, which is a non-negative integer.
NativeDisplayManager_Rect **availableAreaDouble pointer to the available area of the display. For details, see NativeDisplayManager_Rect.

Return value

TypeDescription
NativeDisplayManager_ErrorCodeStatus code defined in NativeDisplayManager_ErrorCode.

OH_NativeDisplayManager_DestroyAvailableArea()

NativeDisplayManager_ErrorCode OH_NativeDisplayManager_DestroyAvailableArea(NativeDisplayManager_Rect *availableArea)

Description

Destroys the available area of a display. This function can be used only on 2-in-1 devices.

Since: 20

Parameters

ParameterDescription
NativeDisplayManager_Rect *availableAreaPointer to the available area, which is obtained by calling OH_NativeDisplayManager_CreateAvailableArea.
For details about the available area, see NativeDisplayManager_Rect.

Return value

TypeDescription
NativeDisplayManager_ErrorCodeStatus code defined in NativeDisplayManager_ErrorCode.

OH_NativeDisplayManager_DisplayAddCallback()

typedef void (*OH_NativeDisplayManager_DisplayAddCallback)(uint64_t displayId)

Description

Defines a callback function to listen for display addition events.

Since: 20

Parameters

ParameterDescription
uint64_t displayIdDisplay ID, which is a non-negative integer.

OH_NativeDisplayManager_RegisterDisplayAddListener()

NativeDisplayManager_ErrorCode OH_NativeDisplayManager_RegisterDisplayAddListener(OH_NativeDisplayManager_DisplayAddCallback displayAddCallback, uint32_t *listenerIndex)

Description

Registers a listener for display addition events (for example, monitor inserted).

Since: 20

Parameters

ParameterDescription
OH_NativeDisplayManager_DisplayAddCallback displayAddCallbackCallback function triggered when a display is added. For details, see OH_NativeDisplayManager_DisplayAddCallback.
uint32_t *listenerIndexPointer to the index of the listener registered.
It can be used as an input parameter of OH_NativeDisplayManager_UnregisterDisplayAddListener.

Return value

TypeDescription
NativeDisplayManager_ErrorCodeStatus code defined in NativeDisplayManager_ErrorCode.

OH_NativeDisplayManager_UnregisterDisplayAddListener()

NativeDisplayManager_ErrorCode OH_NativeDisplayManager_UnregisterDisplayAddListener(uint32_t listenerIndex)

Description

Unregisters a listener for display addition events.

Since: 20

Parameters

ParameterDescription
uint32_t listenerIndexIndex of the listener returned when OH_NativeDisplayManager_RegisterDisplayAddListener is called.

Return value

TypeDescription
NativeDisplayManager_ErrorCodeStatus code defined in NativeDisplayManager_ErrorCode.

OH_NativeDisplayManager_DisplayRemoveCallback()

typedef void (*OH_NativeDisplayManager_DisplayRemoveCallback)(uint64_t displayId)

Description

Defines a callback function to listen for display removal events.

Since: 20

Parameters

ParameterDescription
uint64_t displayIdDisplay ID, which is a non-negative integer.

OH_NativeDisplayManager_RegisterDisplayRemoveListener()

NativeDisplayManager_ErrorCode OH_NativeDisplayManager_RegisterDisplayRemoveListener(OH_NativeDisplayManager_DisplayRemoveCallback displayRemoveCallback, uint32_t *listenerIndex)

Description

Registers a listener for display removal events (for example, monitor removed).

Since: 20

Parameters

ParameterDescription
OH_NativeDisplayManager_DisplayRemoveCallback displayRemoveCallbackCallback function triggered when a display is removed. For details, see OH_NativeDisplayManager_DisplayRemoveCallback.
uint32_t *listenerIndexPointer to the index of the listener registered.
It can be used as an input parameter of OH_NativeDisplayManager_UnregisterDisplayRemoveListener.

Return value

TypeDescription
NativeDisplayManager_ErrorCodeStatus code defined in NativeDisplayManager_ErrorCode.

OH_NativeDisplayManager_UnregisterDisplayRemoveListener()

NativeDisplayManager_ErrorCode OH_NativeDisplayManager_UnregisterDisplayRemoveListener(uint32_t listenerIndex)

Description

Unregisters the listener for display removal events.

Since: 20

Parameters

ParameterDescription
uint32_t listenerIndexIndex of the listener returned when OH_NativeDisplayManager_RegisterDisplayRemoveListener is called.

Return value

TypeDescription
NativeDisplayManager_ErrorCodeStatus code defined in NativeDisplayManager_ErrorCode.

OH_NativeDisplayManager_GetDisplaySourceMode()

NativeDisplayManager_ErrorCode OH_NativeDisplayManager_GetDisplaySourceMode(uint64_t displayId, NativeDisplayManager_SourceMode *sourceMode)

Description

Obtains the source mode of a display.

Since: 20

Parameters

ParameterDescription
uint64_t displayIdDisplay ID, which is a non-negative integer.
NativeDisplayManager_SourceMode *sourceModePointer to the source mode. For details about the available options, see NativeDisplayManager_SourceMode.

Return value

TypeDescription
NativeDisplayManager_ErrorCodeStatus code defined in NativeDisplayManager_ErrorCode.

OH_NativeDisplayManager_GetDisplayPosition()

NativeDisplayManager_ErrorCode OH_NativeDisplayManager_GetDisplayPosition(uint64_t displayId, int32_t *x, int32_t *y)

Description

Obtains the position of a display.

Since: 20

Parameters

ParameterDescription
uint64_t displayIdDisplay ID, which is a non-negative integer.
int32_t *xPointer to the X coordinate of the upper left corner of the primary screen.
int32_t *yPointer to the Y coordinate of the upper left corner of the primary screen.

Return value

TypeDescription
NativeDisplayManager_ErrorCodeStatus code defined in NativeDisplayManager_ErrorCode.
Currently, only the primary screen and extended screen support position information query. Queries for other screens return DISPLAY_MANAGER_ERROR_ILLEGAL_PARAM.

你可能感兴趣的鸿蒙文章

harmony 鸿蒙ArkUI

harmony 鸿蒙ARKUI_TextPickerCascadeRangeContent

harmony 鸿蒙ARKUI_TextPickerRangeContent

harmony 鸿蒙ArkUI_AnimateCompleteCallback

harmony 鸿蒙ArkUI_AttributeItem

harmony 鸿蒙ArkUI_ColorStop

harmony 鸿蒙ArkUI_ContextCallback

harmony 鸿蒙ArkUI_EventModule

harmony 鸿蒙ArkUI_ExpectedFrameRateRange

harmony 鸿蒙ArkUI_IntOffset

  • 所属分类: 后端技术
  • 本文标签: 鸿蒙 软件
  • 版权声明: 本文链接 https://seaxiang.com/blog/rJhfu7