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
Types
| Name | Description |
|---|---|
| typedef void(* OH_NativeDisplayManager_DisplayChangeCallback) (uint64_t displayId) | Defines a callback function to listen for status changes of a display. |
| typedef void(* OH_NativeDisplayManager_FoldDisplayModeChangeCallback) (NativeDisplayManager_FoldDisplayMode displayMode) | Defines a callback function used to listen for folded/unfolded state changes of a display. |
Callback
| Name | Description |
|---|---|
| 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 that are displayed horizontally per inch on the default display. |
| NativeDisplayManager_ErrorCode OH_NativeDisplayManager_GetDefaultDisplayDensityYdpi (float *yDpi) | Obtains the number of physical pixels that are displayed vertically per inch on the default display. |
| NativeDisplayManager_ErrorCode OH_NativeDisplayManager_CreateDefaultDisplayCutoutInfo (NativeDisplayManager_CutoutInfo **cutoutInfo) | Obtains the unusable area of the default display, including punch hole, notch, or curved area of a waterfall screen. |
| NativeDisplayManager_ErrorCode OH_NativeDisplayManager_DestroyDefaultDisplayCutoutInfo (NativeDisplayManager_CutoutInfo *cutoutInfo) | Destroys the unusable area of the default display, including punch hole, notch, or curved area of a waterfall screen. |
| 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. |
| NativeDisplayManager_ErrorCode OH_NativeDisplayManager_RegisterDisplayChangeListener (OH_NativeDisplayManager_DisplayChangeCallback displayChangeCallback, uint32_t *listenerIndex) | Registers a listener for status changes (such as rotation, refresh rate, DPI, and resolution changes) of the display. |
| NativeDisplayManager_ErrorCode OH_NativeDisplayManager_UnregisterDisplayChangeListener (uint32_t listenerIndex) | Cancels the listening for status 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) | Cancels the listening 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. |