1# OH_DisplayManager
2
3
4## Overview
5
6The OH_DisplayManager module provides the display management capability.
7
8**System capability**: SystemCapability.WindowManager.WindowManager.Core
9
10**Since**: 12
11
12## Summary
13
14### Files
15
16| Name| Description|
17| -------- | -------- |
18| [oh_display_capture.h](oh__display__capture_8h.md) | Declares the capability to take screenshots.|
19| [oh_display_info.h](oh__display__info_8h.md) | Declares the common enums and definitions of the display.|
20| [oh_display_manager.h](oh__display__manager_8h.md) | 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.|
21
22
23### Structs
24
25| Name| Description|
26| -------- | -------- |
27| struct  [NativeDisplayManager_Rect](_native_display_manager___rect.md) | Describes a rectangle.|
28| struct  [NativeDisplayManager_WaterfallDisplayAreaRects](ive_display_manager___waterfall_display_area_rects.md) | Describes the curved area on a waterfall display.|
29| struct  [NativeDisplayManager_CutoutInfo](_native_display_manager___cutout_info.md) | Describes the unusable area of a display, including punch hole, notch, and curved area of a waterfall display.|
30| struct  [NativeDisplayManager_DisplayHdrFormat](_native_display_manager___display_hdr_format.md) | Describes all the HDR formats supported by a display.|
31| struct  [NativeDisplayManager_DisplayColorSpace](_native_display_manager___display_color_space.md) | Describes all the color spaces supported by a display.|
32| struct  [NativeDisplayManager_DisplayInfo](_native_display_manager___display_info.md) | Encapsulates the information about a display.|
33| struct  [NativeDisplayManager_DisplaysInfo](_native_display_manager___displays_info.md) | Encapsulates the information about displays of a device with multiple screens.|
34
35
36### Types
37
38| Name| Description|
39| -------- | -------- |
40| typedef enum [NativeDisplayManager_Rotation](#nativedisplaymanager_rotation) [NativeDisplayManager_Rotation](#nativedisplaymanager_rotation) | Defines an enum for the clockwise rotation angles of a display.|
41| typedef enum [NativeDisplayManager_Orientation](#nativedisplaymanager_orientation) [NativeDisplayManager_Orientation](#nativedisplaymanager_orientation) | Defines an enum for the orientations of a display.|
42| typedef enum [NativeDisplayManager_ErrorCode](#nativedisplaymanager_errorcode) [NativeDisplayManager_ErrorCode](#nativedisplaymanager_errorcode) | Defines an enum for the status codes returned by the display manager interface.|
43| typedef enum [NativeDisplayManager_FoldDisplayMode](#nativedisplaymanager_folddisplaymode) [NativeDisplayManager_FoldDisplayMode](#nativedisplaymanager_folddisplaymode) | Defines an enum for the display modes of a foldable device.|
44| typedef struct [NativeDisplayManager_Rect](_native_display_manager___rect.md) [NativeDisplayManager_Rect](#nativedisplaymanager_rect) | Defines a struct for a rectangle.|
45| typedef struct [NativeDisplayManager_WaterfallDisplayAreaRects](ive_display_manager___waterfall_display_area_rects.md) [NativeDisplayManager_WaterfallDisplayAreaRects](#nativedisplaymanager_waterfalldisplayarearects) | Defines a struct for the curved area on a waterfall display.|
46| typedef struct [NativeDisplayManager_CutoutInfo](_native_display_manager___cutout_info.md) [NativeDisplayManager_CutoutInfo](#nativedisplaymanager_cutoutinfo) | Defines a struct for the unusable area of a display, including punch hole, notch, and curved area of a waterfall display.|
47| typedef enum [NativeDisplayManager_DisplayState](#nativedisplaymanager_displaystate) [NativeDisplayManager_DisplayState](#nativedisplaymanager_displaystate) | Defines an enum for the states of a display.|
48| typedef struct [NativeDisplayManager_DisplayHdrFormat](_native_display_manager___display_hdr_format.md) [NativeDisplayManager_DisplayHdrFormat](#nativedisplaymanager_displayhdrformat) | Defines a struct for all the HDR formats supported by a display.|
49| typedef struct [NativeDisplayManager_DisplayColorSpace](_native_display_manager___display_color_space.md) [NativeDisplayManager_DisplayColorSpace](#nativedisplaymanager_displaycolorspace) | Defines a struct for all the color spaces supported by a display.|
50| typedef struct [NativeDisplayManager_DisplayInfo](_native_display_manager___display_info.md) [NativeDisplayManager_DisplayInfo](#nativedisplaymanager_displayinfo) | Defines a struct that encapsulates the information about a display.|
51| typedef struct [NativeDisplayManager_DisplaysInfo](_native_display_manager___displays_info.md) [NativeDisplayManager_DisplaysInfo](#nativedisplaymanager_displaysinfo) | Defines a struct that encapsulates the information about displays of a device with multiple screens.|
52| typedef void(\* [OH_NativeDisplayManager_DisplayChangeCallback](#oh_nativedisplaymanager_displaychangecallback)) (uint64_t displayId) | Defines a callback function to listen for status changes of a display.|
53| typedef void(\* [OH_NativeDisplayManager_FoldDisplayModeChangeCallback](#oh_nativedisplaymanager_folddisplaymodechangecallback)) ([NativeDisplayManager_FoldDisplayMode](#nativedisplaymanager_folddisplaymode) displayMode) | Defines a callback function to listen for folded/unfolded state changes of a display.|
54
55
56### Enums
57
58| Name| Description|
59| -------- | -------- |
60| [NativeDisplayManager_Rotation](#nativedisplaymanager_rotation-1) { DISPLAY_MANAGER_ROTATION_0 = 0, DISPLAY_MANAGER_ROTATION_90 = 1, DISPLAY_MANAGER_ROTATION_180 = 2, DISPLAY_MANAGER_ROTATION_270 = 3 } | Enumerates the clockwise rotation angles of a display.|
61| [NativeDisplayManager_Orientation](#nativedisplaymanager_orientation-1) {<br>DISPLAY_MANAGER_PORTRAIT = 0, DISPLAY_MANAGER_LANDSCAPE = 1, DISPLAY_MANAGER_PORTRAIT_INVERTED = 2, DISPLAY_MANAGER_LANDSCAPE_INVERTED = 3,<br>DISPLAY_MANAGER_UNKNOWN<br>} | Enumerates the orientations of a display.|
62| [NativeDisplayManager_ErrorCode](#nativedisplaymanager_errorcode-1) {<br>DISPLAY_MANAGER_OK = 0, DISPLAY_MANAGER_ERROR_NO_PERMISSION = 201, DISPLAY_MANAGER_ERROR_NOT_SYSTEM_APP = 202, DISPLAY_MANAGER_ERROR_INVALID_PARAM = 401,<br>DISPLAY_MANAGER_ERROR_DEVICE_NOT_SUPPORTED = 801, DISPLAY_MANAGER_ERROR_INVALID_SCREEN = 1400001, DISPLAY_MANAGER_ERROR_INVALID_CALL = 1400002, DISPLAY_MANAGER_ERROR_SYSTEM_ABNORMAL = 1400003<br>} | Enumerates the status codes returned by the display manager interface.|
63| [NativeDisplayManager_FoldDisplayMode](#nativedisplaymanager_folddisplaymode-1) {<br>DISPLAY_MANAGER_FOLD_DISPLAY_MODE_UNKNOWN = 0, DISPLAY_MANAGER_FOLD_DISPLAY_MODE_FULL = 1, DISPLAY_MANAGER_FOLD_DISPLAY_MODE_MAIN = 2, DISPLAY_MANAGER_FOLD_DISPLAY_MODE_SUB = 3,<br>DISPLAY_MANAGER_FOLD_DISPLAY_MODE_COORDINATION = 4<br>} | Enumerates the display modes of a foldable device.|
64| [NativeDisplayManager_DisplayState](#nativedisplaymanager_displaystate-1) {<br>DISPLAY_MANAGER_DISPLAY_STATE_UNKNOWN = 0, DISPLAY_MANAGER_DISPLAY_STATE_OFF = 1, DISPLAY_MANAGER_DISPLAY_STATE_ON = 2, DISPLAY_MANAGER_DISPLAY_STATE_DOZE = 3,<br>DISPLAY_MANAGER_DISPLAY_STATE_DOZE_SUSPEND = 4, DISPLAY_MANAGER_DISPLAY_STATE_VR = 5, DISPLAY_MANAGER_DISPLAY_STATE_ON_SUSPEND = 6<br>} | Enumerates the states of a display.|
65
66
67### Functions
68
69| Name| Description|
70| -------- | -------- |
71| [NativeDisplayManager_ErrorCode](#nativedisplaymanager_errorcode) [OH_NativeDisplayManager_CaptureScreenPixelmap](#oh_nativedisplaymanager_capturescreenpixelmap) (uint32_t displayId, OH_PixelmapNative \*\*pixelMap) | Takes a screenshot of the entire screen. This function can be used only on tablets and 2-in-1 devices. It can be used to capture a full-screen screenshot on the specified display.|
72| [NativeDisplayManager_ErrorCode](#nativedisplaymanager_errorcode) [OH_NativeDisplayManager_GetDefaultDisplayId](#oh_nativedisplaymanager_getdefaultdisplayid) (uint64_t \*displayId) | Obtains the ID of the default display.|
73| [NativeDisplayManager_ErrorCode](#nativedisplaymanager_errorcode) [OH_NativeDisplayManager_GetDefaultDisplayWidth](#oh_nativedisplaymanager_getdefaultdisplaywidth) (int32_t \*displayWidth) | Obtains the width of the default display.|
74| [NativeDisplayManager_ErrorCode](#nativedisplaymanager_errorcode) [OH_NativeDisplayManager_GetDefaultDisplayHeight](#oh_nativedisplaymanager_getdefaultdisplayheight) (int32_t \*displayHeight) | Obtains the height of the default display.|
75| [NativeDisplayManager_ErrorCode](#nativedisplaymanager_errorcode) [OH_NativeDisplayManager_GetDefaultDisplayRotation](#oh_nativedisplaymanager_getdefaultdisplayrotation) ([NativeDisplayManager_Rotation](#nativedisplaymanager_rotation) \*displayRotation) | Obtains the clockwise rotation angle of the default display.|
76| [NativeDisplayManager_ErrorCode](#nativedisplaymanager_errorcode) [OH_NativeDisplayManager_GetDefaultDisplayOrientation](#oh_nativedisplaymanager_getdefaultdisplayorientation) ([NativeDisplayManager_Orientation](#nativedisplaymanager_orientation) \*displayOrientation) | Obtains the orientation of the default display.|
77| [NativeDisplayManager_ErrorCode](#nativedisplaymanager_errorcode) [OH_NativeDisplayManager_GetDefaultDisplayVirtualPixelRatio](#oh_nativedisplaymanager_getdefaultdisplayvirtualpixelratio) (float \*virtualPixels) | Obtains the virtual pixel ratio of the default display.|
78| [NativeDisplayManager_ErrorCode](#nativedisplaymanager_errorcode) [OH_NativeDisplayManager_GetDefaultDisplayRefreshRate](#oh_nativedisplaymanager_getdefaultdisplayrefreshrate) (uint32_t \*refreshRate) | Obtains the refresh rate of the default display.|
79| [NativeDisplayManager_ErrorCode](#nativedisplaymanager_errorcode) [OH_NativeDisplayManager_GetDefaultDisplayDensityDpi](#oh_nativedisplaymanager_getdefaultdisplaydensitydpi) (int32_t \*densityDpi) | Obtains the physical pixel density of the default display.|
80| [NativeDisplayManager_ErrorCode](#nativedisplaymanager_errorcode) [OH_NativeDisplayManager_GetDefaultDisplayDensityPixels](#oh_nativedisplaymanager_getdefaultdisplaydensitypixels) (float \*densityPixels) | Obtains the logical pixel density of the default display.|
81| [NativeDisplayManager_ErrorCode](#nativedisplaymanager_errorcode) [OH_NativeDisplayManager_GetDefaultDisplayScaledDensity](#oh_nativedisplaymanager_getdefaultdisplayscaleddensity) (float \*scaledDensity) | Obtains the scale factor of fonts displayed on the default display.|
82| [NativeDisplayManager_ErrorCode](#nativedisplaymanager_errorcode) [OH_NativeDisplayManager_GetDefaultDisplayDensityXdpi](#oh_nativedisplaymanager_getdefaultdisplaydensityxdpi) (float \*xDpi) | Obtains the number of physical pixels per inch on the default display in the X dimension.|
83| [NativeDisplayManager_ErrorCode](#nativedisplaymanager_errorcode) [OH_NativeDisplayManager_GetDefaultDisplayDensityYdpi](#oh_nativedisplaymanager_getdefaultdisplaydensityydpi) (float \*yDpi) | Obtains the number of physical pixels per inch on the default display in the Y dimension.|
84| [NativeDisplayManager_ErrorCode](#nativedisplaymanager_errorcode) [OH_NativeDisplayManager_CreateDefaultDisplayCutoutInfo](#oh_nativedisplaymanager_createdefaultdisplaycutoutinfo) ([NativeDisplayManager_CutoutInfo](_native_display_manager___cutout_info.md) \*\*cutoutInfo) | Obtains the unusable area of the default display, including punch hole, notch, and curved area of a waterfall display.|
85| [NativeDisplayManager_ErrorCode](#nativedisplaymanager_errorcode) [OH_NativeDisplayManager_DestroyDefaultDisplayCutoutInfo](#oh_nativedisplaymanager_destroydefaultdisplaycutoutinfo) ([NativeDisplayManager_CutoutInfo](_native_display_manager___cutout_info.md) \*cutoutInfo) | Destroys the unusable area of the default display, including punch hole, notch, and curved area of a waterfall display.|
86| bool [OH_NativeDisplayManager_IsFoldable](#oh_nativedisplaymanager_isfoldable) () | Checks whether the current device is foldable.|
87| [NativeDisplayManager_ErrorCode](#nativedisplaymanager_errorcode) [OH_NativeDisplayManager_GetFoldDisplayMode](#oh_nativedisplaymanager_getfolddisplaymode) ([NativeDisplayManager_FoldDisplayMode](#nativedisplaymanager_folddisplaymode) \*displayMode) | Obtains the display mode of the foldable device.|
88| [NativeDisplayManager_ErrorCode](#nativedisplaymanager_errorcode) [OH_NativeDisplayManager_RegisterDisplayChangeListener](#oh_nativedisplaymanager_registerdisplaychangelistener) ([OH_NativeDisplayManager_DisplayChangeCallback](#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.|
89| [NativeDisplayManager_ErrorCode](#nativedisplaymanager_errorcode) [OH_NativeDisplayManager_UnregisterDisplayChangeListener](#oh_nativedisplaymanager_unregisterdisplaychangelistener) (uint32_t listenerIndex) | Cancels the listening for status changes of the display.|
90| [NativeDisplayManager_ErrorCode](#nativedisplaymanager_errorcode) [OH_NativeDisplayManager_RegisterFoldDisplayModeChangeListener](#oh_nativedisplaymanager_registerfolddisplaymodechangelistener) ([OH_NativeDisplayManager_FoldDisplayModeChangeCallback](#oh_nativedisplaymanager_folddisplaymodechangecallback) displayModeChangeCallback, uint32_t \*listenerIndex) | Registers a listener for folded/unfolded state changes of the display.|
91| [NativeDisplayManager_ErrorCode](#nativedisplaymanager_errorcode) [OH_NativeDisplayManager_UnregisterFoldDisplayModeChangeListener](#oh_nativedisplaymanager_unregisterfolddisplaymodechangelistener) (uint32_t listenerIndex) | Cancels the listening for folded/unfolded state changes of the display.|
92| [NativeDisplayManager_ErrorCode](#nativedisplaymanager_errorcode) [OH_NativeDisplayManager_CreateAllDisplays](#oh_nativedisplaymanager_createalldisplays) ([NativeDisplayManager_DisplaysInfo](_native_display_manager___displays_info.md) \*\*allDisplays) | Obtains the object that contains the information about all displays.|
93| void [OH_NativeDisplayManager_DestroyAllDisplays](#oh_nativedisplaymanager_destroyalldisplays) ([NativeDisplayManager_DisplaysInfo](_native_display_manager___displays_info.md) \*allDisplays) | Destroys the object that contains the information about all displays.|
94| [NativeDisplayManager_ErrorCode](#nativedisplaymanager_errorcode) [OH_NativeDisplayManager_CreateDisplayById](#oh_nativedisplaymanager_createdisplaybyid) (uint32_t displayId, [NativeDisplayManager_DisplayInfo](_native_display_manager___display_info.md) \*\*displayInfo) | Obtains the object that contains the information about a display.|
95| void [OH_NativeDisplayManager_DestroyDisplay](#oh_nativedisplaymanager_destroydisplay) ([NativeDisplayManager_DisplayInfo](_native_display_manager___display_info.md) \*displayInfo) | Destroys the object that contains the information about a display.|
96| [NativeDisplayManager_ErrorCode](#nativedisplaymanager_errorcode) [OH_NativeDisplayManager_CreatePrimaryDisplay](#oh_nativedisplaymanager_createprimarydisplay) ([NativeDisplayManager_DisplayInfo](_native_display_manager___display_info.md) \*\*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.|
97
98
99## Type Description
100
101### NativeDisplayManager_DisplayColorSpace
102
103```
104typedef struct NativeDisplayManager_DisplayColorSpace NativeDisplayManager_DisplayColorSpace
105```
106
107**Description**
108
109Defines a struct for all the color spaces supported by a display.
110
111**Since**: 14
112
113
114### NativeDisplayManager_DisplayHdrFormat
115
116```
117typedef struct NativeDisplayManager_DisplayHdrFormat NativeDisplayManager_DisplayHdrFormat
118```
119
120**Description**
121
122Defines a struct for all the HDR formats supported by a display.
123
124**Since**: 14
125
126
127### NativeDisplayManager_DisplayInfo
128
129```
130typedef struct NativeDisplayManager_DisplayInfo NativeDisplayManager_DisplayInfo
131```
132
133**Description**
134
135Defines a struct that encapsulates the information about a display.
136
137**Since**: 14
138
139
140### NativeDisplayManager_DisplaysInfo
141
142```
143typedef struct NativeDisplayManager_DisplaysInfo NativeDisplayManager_DisplaysInfo
144```
145
146**Description**
147
148Defines a struct that encapsulates the information about displays of a device with multiple screens.
149
150**Since**: 14
151
152
153### NativeDisplayManager_DisplayState
154
155```
156typedef enum NativeDisplayManager_DisplayState NativeDisplayManager_DisplayState
157```
158
159**Description**
160
161Defines an enum for the states of a display.
162
163**Since**: 14
164
165### NativeDisplayManager_CutoutInfo
166
167```
168typedef struct NativeDisplayManager_CutoutInfo NativeDisplayManager_CutoutInfo
169```
170
171**Description**
172
173Defines a struct for the unusable area of a display, including punch hole, notch, and curved area of a waterfall display.
174
175**System capability**: SystemCapability.WindowManager.WindowManager.Core
176
177**Since**: 12
178
179
180### NativeDisplayManager_ErrorCode
181
182```
183typedef enum NativeDisplayManager_ErrorCode NativeDisplayManager_ErrorCode
184```
185
186**Description**
187
188Defines an enum for the status codes returned by the display manager interface.
189
190**System capability**: SystemCapability.WindowManager.WindowManager.Core
191
192**Since**: 12
193
194
195### NativeDisplayManager_FoldDisplayMode
196
197```
198typedef enum NativeDisplayManager_FoldDisplayMode NativeDisplayManager_FoldDisplayMode
199```
200
201**Description**
202
203Defines an enum for the display modes of a foldable device.
204
205**System capability**: SystemCapability.WindowManager.WindowManager.Core
206
207**Since**: 12
208
209
210### NativeDisplayManager_Orientation
211
212```
213typedef enum NativeDisplayManager_Orientation NativeDisplayManager_Orientation
214```
215
216**Description**
217
218Defines an enum for the orientations of a display.
219
220**System capability**: SystemCapability.WindowManager.WindowManager.Core
221
222**Since**: 12
223
224
225### NativeDisplayManager_Rect
226
227```
228typedef struct NativeDisplayManager_Rect NativeDisplayManager_Rect
229```
230
231**Description**
232
233Defines a struct for a rectangle.
234
235**System capability**: SystemCapability.WindowManager.WindowManager.Core
236
237**Since**: 12
238
239
240### NativeDisplayManager_Rotation
241
242```
243typedef enum NativeDisplayManager_Rotation NativeDisplayManager_Rotation
244```
245
246**Description**
247
248Defines an enum for the clockwise rotation angles of a display.
249
250**System capability**: SystemCapability.WindowManager.WindowManager.Core
251
252**Since**: 12
253
254
255### NativeDisplayManager_WaterfallDisplayAreaRects
256
257```
258typedef struct NativeDisplayManager_WaterfallDisplayAreaRects NativeDisplayManager_WaterfallDisplayAreaRects
259```
260
261**Description**
262
263Defines a struct for the curved area on a waterfall display.
264
265**System capability**: SystemCapability.WindowManager.WindowManager.Core
266
267**Since**: 12
268
269
270### OH_NativeDisplayManager_DisplayChangeCallback
271
272```
273typedef void(* OH_NativeDisplayManager_DisplayChangeCallback) (uint64_t displayId)
274```
275
276**Description**
277
278Defines a callback function to listen for status changes of a display.
279
280**System capability**: SystemCapability.Window.SessionManager
281
282**Since**: 12
283
284**Parameters**
285
286| Name| Description|
287| -------- | -------- |
288| displayId | ID of the display.|
289
290
291### OH_NativeDisplayManager_FoldDisplayModeChangeCallback
292
293```
294typedef void(* OH_NativeDisplayManager_FoldDisplayModeChangeCallback) (NativeDisplayManager_FoldDisplayMode displayMode)
295```
296
297**Description**
298
299Defines a callback function to listen for folded/unfolded state changes of a display.
300
301**System capability**: SystemCapability.Window.SessionManager
302
303**Since**: 12
304
305**Parameters**
306
307| Name| Description|
308| -------- | -------- |
309| displayMode | Folded or unfolded state of the display. For details about the available options, see [NativeDisplayManager_FoldDisplayMode](#nativedisplaymanager_folddisplaymode).|
310
311
312## Enum Description
313
314### NativeDisplayManager_DisplayState
315
316```
317enum NativeDisplayManager_DisplayState
318```
319
320**Description**
321
322Enumerates the states of a display.
323
324**Since**: 14
325
326| Value| Description|
327| -------- | -------- |
328| DISPLAY_MANAGER_DISPLAY_STATE_UNKNOWN | Unknown.|
329| DISPLAY_MANAGER_DISPLAY_STATE_OFF | The display is shut down.|
330| DISPLAY_MANAGER_DISPLAY_STATE_ON | The display is powered on.|
331| DISPLAY_MANAGER_DISPLAY_STATE_DOZE | The display is in sleep mode.|
332| DISPLAY_MANAGER_DISPLAY_STATE_DOZE_SUSPEND | The display is in sleep mode, and the CPU is suspended.|
333| DISPLAY_MANAGER_DISPLAY_STATE_VR | The display is in VR mode.|
334| DISPLAY_MANAGER_DISPLAY_STATE_ON_SUSPEND | The display is powered on, and the CPU is suspended.|
335
336### NativeDisplayManager_ErrorCode
337
338```
339enum NativeDisplayManager_ErrorCode
340```
341
342**Description**
343
344Enumerates the status codes returned by the display manager interface.
345
346**System capability**: SystemCapability.WindowManager.WindowManager.Core
347
348**Since**: 12
349
350| Value| Description|
351| -------- | -------- |
352| DISPLAY_MANAGER_OK | The operation is successful.|
353| DISPLAY_MANAGER_ERROR_NO_PERMISSION | Permission verification failed. The application does not have the permission to use the API.|
354| DISPLAY_MANAGER_ERROR_NOT_SYSTEM_APP | Permission verification failed. A non-system application attempts to call a system API.|
355| DISPLAY_MANAGER_ERROR_INVALID_PARAM | Parameter check fails.|
356| DISPLAY_MANAGER_ERROR_DEVICE_NOT_SUPPORTED | The device does not support the API.|
357| DISPLAY_MANAGER_ERROR_INVALID_SCREEN | The display is invalid.|
358| DISPLAY_MANAGER_ERROR_INVALID_CALL | The current operation object does not have the operation permission.|
359| DISPLAY_MANAGER_ERROR_SYSTEM_ABNORMAL | The system service is abnormal.|
360
361
362### NativeDisplayManager_FoldDisplayMode
363
364```
365enum NativeDisplayManager_FoldDisplayMode
366```
367
368**Description**
369
370Enumerates the display modes of a foldable device.
371
372**System capability**: SystemCapability.WindowManager.WindowManager.Core
373
374**Since**: 12
375
376| Value| Description|
377| -------- | -------- |
378| DISPLAY_MANAGER_FOLD_DISPLAY_MODE_UNKNOWN | The display mode of the device is unknown.|
379| DISPLAY_MANAGER_FOLD_DISPLAY_MODE_FULL | The device is displayed in full screen.|
380| DISPLAY_MANAGER_FOLD_DISPLAY_MODE_MAIN | The main screen of the device is displayed.|
381| DISPLAY_MANAGER_FOLD_DISPLAY_MODE_SUB | The subscreen of the device is displayed.|
382| DISPLAY_MANAGER_FOLD_DISPLAY_MODE_COORDINATION | Both screens of the device are displayed in collaborative mode.|
383
384
385### NativeDisplayManager_Orientation
386
387```
388enum NativeDisplayManager_Orientation
389```
390
391**Description**
392
393Enumerates the orientations of a display.
394
395**System capability**: SystemCapability.WindowManager.WindowManager.Core
396
397**Since**: 12
398
399| Value| Description|
400| -------- | -------- |
401| DISPLAY_MANAGER_PORTRAIT | The display is in portrait mode.|
402| DISPLAY_MANAGER_LANDSCAPE | The display is in landscape mode.|
403| DISPLAY_MANAGER_PORTRAIT_INVERTED | The display is in reverse portrait mode.|
404| DISPLAY_MANAGER_LANDSCAPE_INVERTED | The display is in reverse landscape mode.|
405| DISPLAY_MANAGER_UNKNOWN | The screen orientation is unknown.|
406
407
408### NativeDisplayManager_Rotation
409
410```
411enum NativeDisplayManager_Rotation
412```
413
414**Description**
415
416Enumerates the clockwise rotation angles of a display.
417
418**System capability**: SystemCapability.WindowManager.WindowManager.Core
419
420**Since**: 12
421
422| Value| Description|
423| -------- | -------- |
424| DISPLAY_MANAGER_ROTATION_0 | The display is rotated clockwise by 0 degrees.|
425| DISPLAY_MANAGER_ROTATION_90 | The display is rotated clockwise by 90 degrees.|
426| DISPLAY_MANAGER_ROTATION_180 | The display is rotated clockwise by 180 degrees.|
427| DISPLAY_MANAGER_ROTATION_270 | The display is rotated clockwise by 270 degrees.|
428
429
430## Function Description
431
432
433### OH_NativeDisplayManager_CaptureScreenPixelmap()
434
435```
436NativeDisplayManager_ErrorCode OH_NativeDisplayManager_CaptureScreenPixelmap (uint32_t displayId, OH_PixelmapNative **pixelMap )
437```
438
439**Description**
440
441Takes a screenshot of the entire screen. This function can be used only on tablets and 2-in-1 devices. It can be used to capture a full-screen screenshot on the specified display.
442
443**Required permissions**
444
445ohos.permission.CUSTOM_SCREEN_CAPTURE
446
447**System capability**: SystemCapability.Window.SessionManager.Core
448
449**Since**: 14
450
451**Parameters**
452
453| Name| Description|
454| -------- | -------- |
455| displayId | ID of the display. The value must be a non-negative integer.|
456| pixelMap | Double pointer to an **OH_PixelmapNative** object, which is the screenshot taken.|
457
458**Returns**
459
460Returns a status code defined in [NativeDisplayManager_ErrorCode](#nativedisplaymanager_errorcode).
461
462
463### OH_NativeDisplayManager_CreateAllDisplays()
464
465```
466NativeDisplayManager_ErrorCode OH_NativeDisplayManager_CreateAllDisplays (NativeDisplayManager_DisplaysInfo **allDisplays)
467```
468
469**Description**
470
471Obtains the object that contains the information about all displays.
472
473**System capability**: SystemCapability.Window.SessionManager.Core
474
475**Since**: 14
476
477**Parameters**
478
479| Name| Description|
480| -------- | -------- |
481| allDisplays | Double pointer to the display information, which is encapsulated in [NativeDisplayManager_DisplaysInfo](_native_display_manager___displays_info.md).|
482
483**Returns**
484
485Returns a status code defined in [NativeDisplayManager_ErrorCode](#nativedisplaymanager_errorcode).
486
487
488### OH_NativeDisplayManager_CreateDisplayById()
489
490```
491NativeDisplayManager_ErrorCode OH_NativeDisplayManager_CreateDisplayById (uint32_t displayId, NativeDisplayManager_DisplayInfo **displayInfo )
492```
493
494**Description**
495
496Obtains the object that contains the information about a display.
497
498**System capability**: SystemCapability.Window.SessionManager.Core
499
500**Since**: 14
501
502**Parameters**
503
504| Name| Description|
505| -------- | -------- |
506| displayId | ID of the display. The value must be a non-negative integer.|
507| displayInfo | Double pointer to the display information, which is encapsulated in [NativeDisplayManager_DisplayInfo](_native_display_manager___display_info.md).|
508
509**Returns**
510
511Returns a status code defined in [NativeDisplayManager_ErrorCode](#nativedisplaymanager_errorcode).
512
513
514### OH_NativeDisplayManager_CreatePrimaryDisplay()
515
516```
517NativeDisplayManager_ErrorCode OH_NativeDisplayManager_CreatePrimaryDisplay (NativeDisplayManager_DisplayInfo **displayInfo)
518```
519
520**Description**
521
522Obtains 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.
523
524**System capability**: SystemCapability.Window.SessionManager.Core
525
526**Since**: 14
527
528**Parameters**
529
530| Name| Description|
531| -------- | -------- |
532| displayInfo | Double pointer to the display information, which is encapsulated in [NativeDisplayManager_DisplayInfo](_native_display_manager___display_info.md).|
533
534**Returns**
535
536Returns a status code defined in [NativeDisplayManager_ErrorCode](#nativedisplaymanager_errorcode).
537
538
539### OH_NativeDisplayManager_DestroyAllDisplays()
540
541```
542void OH_NativeDisplayManager_DestroyAllDisplays (NativeDisplayManager_DisplaysInfo *allDisplays)
543```
544
545**Description**
546
547Destroys the object that contains the information about all displays.
548
549**System capability**: SystemCapability.Window.SessionManager.Core
550
551**Since**: 14
552
553**Parameters**
554
555| Name| Description|
556| -------- | -------- |
557| allDisplays | Pointer to the display information object, which is obtained by calling [OH_NativeDisplayManager_CreateAllDisplays](#oh_nativedisplaymanager_createalldisplays). For details, see [NativeDisplayManager_DisplaysInfo](_native_display_manager___displays_info.md).|
558
559
560### OH_NativeDisplayManager_DestroyDisplay()
561
562```
563void OH_NativeDisplayManager_DestroyDisplay (NativeDisplayManager_DisplayInfo *displayInfo)
564```
565
566**Description**
567
568Destroys the object that contains the information about a display.
569
570**System capability**: SystemCapability.Window.SessionManager.Core
571
572**Since**: 14
573
574**Parameters**
575
576| Name| Description|
577| -------- | -------- |
578| displayInfo | Pointer to the display information object, which is obtained by calling [OH_NativeDisplayManager_CreateDisplayById](#oh_nativedisplaymanager_createdisplaybyid) or [OH_NativeDisplayManager_CreatePrimaryDisplay](#oh_nativedisplaymanager_createprimarydisplay). For details, see [NativeDisplayManager_DisplayInfo](_native_display_manager___display_info.md).|
579
580### OH_NativeDisplayManager_CreateDefaultDisplayCutoutInfo()
581
582```
583NativeDisplayManager_ErrorCode OH_NativeDisplayManager_CreateDefaultDisplayCutoutInfo (NativeDisplayManager_CutoutInfo **cutoutInfo)
584```
585
586**Description**
587
588Obtains the unusable area of the default display, including punch hole, notch, and curved area of a waterfall display.
589
590**System capability**: SystemCapability.WindowManager.WindowManager.Core
591
592**Since**: 12
593
594**Parameters**
595
596| Name| Description|
597| -------- | -------- |
598| cutoutInfo | Double pointer to the unusable area information, which is encapsulated in [NativeDisplayManager_CutoutInfo](_native_display_manager___cutout_info.md).|
599
600**Returns**
601
602Returns a status code defined in [NativeDisplayManager_ErrorCode](#nativedisplaymanager_errorcode).
603
604
605### OH_NativeDisplayManager_DestroyDefaultDisplayCutoutInfo()
606
607```
608NativeDisplayManager_ErrorCode OH_NativeDisplayManager_DestroyDefaultDisplayCutoutInfo (NativeDisplayManager_CutoutInfo *cutoutInfo)
609```
610
611**Description**
612
613Destroys the unusable area of the default display, including punch hole, notch, and curved area of a waterfall display.
614
615**System capability**: SystemCapability.WindowManager.WindowManager.Core
616
617**Since**: 12
618
619**Parameters**
620
621| Name| Description|
622| -------- | -------- |
623| cutoutInfo | Pointer to the unusable area information object, which is obtained by calling [OH_NativeDisplayManager_CreateDefaultDisplayCutoutInfo](#oh_nativedisplaymanager_createdefaultdisplaycutoutinfo). For details, see [NativeDisplayManager_CutoutInfo](_native_display_manager___cutout_info.md).|
624
625**Returns**
626
627Returns a status code defined in [NativeDisplayManager_ErrorCode](#nativedisplaymanager_errorcode).
628
629
630### OH_NativeDisplayManager_GetDefaultDisplayDensityDpi()
631
632```
633NativeDisplayManager_ErrorCode OH_NativeDisplayManager_GetDefaultDisplayDensityDpi (int32_t *densityDpi)
634```
635
636**Description**
637
638Obtains the physical pixel density of the default display.
639
640**System capability**: SystemCapability.WindowManager.WindowManager.Core
641
642**Since**: 12
643
644**Parameters**
645
646| Name| Description|
647| -------- | -------- |
648| densityDpi | Pointer 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.  |
649
650**Returns**
651
652Returns a status code defined in [NativeDisplayManager_ErrorCode](#nativedisplaymanager_errorcode).
653
654
655### OH_NativeDisplayManager_GetDefaultDisplayDensityPixels()
656
657```
658NativeDisplayManager_ErrorCode OH_NativeDisplayManager_GetDefaultDisplayDensityPixels (float *densityPixels)
659```
660
661**Description**
662
663Obtains the logical pixel density of the default display.
664
665**System capability**: SystemCapability.WindowManager.WindowManager.Core
666
667**Since**: 12
668
669**Parameters**
670
671| Name| Description|
672| -------- | -------- |
673| densityPixels | Pointer 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.  |
674
675**Returns**
676
677Returns a status code defined in [NativeDisplayManager_ErrorCode](#nativedisplaymanager_errorcode).
678
679
680### OH_NativeDisplayManager_GetDefaultDisplayDensityXdpi()
681
682```
683NativeDisplayManager_ErrorCode OH_NativeDisplayManager_GetDefaultDisplayDensityXdpi (float *xDpi)
684```
685
686**Description**
687
688Obtains the number of physical pixels per inch on the default display in the X dimension.
689
690**System capability**: SystemCapability.WindowManager.WindowManager.Core
691
692**Since**: 12
693
694**Parameters**
695
696| Name| Description|
697| -------- | -------- |
698| xDpi | Pointer to the number of physical pixels per inch in the X dimension. The value is a floating point number.|
699
700**Returns**
701
702Returns a status code defined in [NativeDisplayManager_ErrorCode](#nativedisplaymanager_errorcode).
703
704
705### OH_NativeDisplayManager_GetDefaultDisplayDensityYdpi()
706
707```
708NativeDisplayManager_ErrorCode OH_NativeDisplayManager_GetDefaultDisplayDensityYdpi (float *yDpi)
709```
710
711**Description**
712
713Obtains the number of physical pixels per inch on the default display in the Y dimension.
714
715**System capability**: SystemCapability.WindowManager.WindowManager.Core
716
717**Since**: 12
718
719**Parameters**
720
721| Name| Description|
722| -------- | -------- |
723| yDpi | Pointer to the number of physical pixels per inch in the Y dimension. The value is a floating point number.|
724
725**Returns**
726
727Returns a status code defined in [NativeDisplayManager_ErrorCode](#nativedisplaymanager_errorcode).
728
729
730### OH_NativeDisplayManager_GetDefaultDisplayHeight()
731
732```
733NativeDisplayManager_ErrorCode OH_NativeDisplayManager_GetDefaultDisplayHeight (int32_t *displayHeight)
734```
735
736**Description**
737
738Obtains the height of the default display.
739
740**System capability**: SystemCapability.WindowManager.WindowManager.Core
741
742**Since**: 12
743
744**Parameters**
745
746| Name| Description|
747| -------- | -------- |
748| displayHeight | Pointer to the height, in px. The value is an integer.|
749
750**Returns**
751
752Returns a status code defined in [NativeDisplayManager_ErrorCode](#nativedisplaymanager_errorcode).
753
754
755### OH_NativeDisplayManager_GetDefaultDisplayId()
756
757```
758NativeDisplayManager_ErrorCode OH_NativeDisplayManager_GetDefaultDisplayId (uint64_t *displayId)
759```
760
761**Description**
762
763Obtains the ID of the default display.
764
765**System capability**: SystemCapability.WindowManager.WindowManager.Core
766
767**Since**: 12
768
769**Parameters**
770
771| Name| Description|
772| -------- | -------- |
773| displayId | Pointer to the display ID. The value is a non-negative integer.|
774
775**Returns**
776
777Returns a status code defined in [NativeDisplayManager_ErrorCode](#nativedisplaymanager_errorcode).
778
779
780### OH_NativeDisplayManager_GetDefaultDisplayOrientation()
781
782```
783NativeDisplayManager_ErrorCode OH_NativeDisplayManager_GetDefaultDisplayOrientation (NativeDisplayManager_Orientation *displayOrientation)
784```
785
786**Description**
787
788Obtains the orientation of the default display.
789
790**System capability**: SystemCapability.WindowManager.WindowManager.Core
791
792**Since**: 12
793
794**Parameters**
795
796| Name| Description|
797| -------- | -------- |
798| displayOrientation | Pointer to the orientation. For details about the available options, see [NativeDisplayManager_Orientation](#nativedisplaymanager_orientation).|
799
800**Returns**
801
802Returns a status code defined in [NativeDisplayManager_ErrorCode](#nativedisplaymanager_errorcode).
803
804
805### OH_NativeDisplayManager_GetDefaultDisplayRefreshRate()
806
807```
808NativeDisplayManager_ErrorCode OH_NativeDisplayManager_GetDefaultDisplayRefreshRate (uint32_t *refreshRate)
809```
810
811**Description**
812
813Obtains the refresh rate of the default display.
814
815**System capability**: SystemCapability.WindowManager.WindowManager.Core
816
817**Since**: 12
818
819**Parameters**
820
821| Name| Description|
822| -------- | -------- |
823| refreshRate | Pointer to the refresh rate. The value is an integer, in Hz.|
824
825**Returns**
826
827Returns a status code defined in [NativeDisplayManager_ErrorCode](#nativedisplaymanager_errorcode).
828
829
830### OH_NativeDisplayManager_GetDefaultDisplayRotation()
831
832```
833NativeDisplayManager_ErrorCode OH_NativeDisplayManager_GetDefaultDisplayRotation (NativeDisplayManager_Rotation *displayRotation)
834```
835
836**Description**
837
838Obtains the clockwise rotation angle of the default display.
839
840**System capability**: SystemCapability.WindowManager.WindowManager.Core
841
842**Since**: 12
843
844**Parameters**
845
846| Name| Description|
847| -------- | -------- |
848| displayRotation | Pointer to the clockwise rotation angle. For details about the available options, see [NativeDisplayManager_Rotation](#nativedisplaymanager_rotation).|
849
850**Returns**
851
852Returns a status code defined in [NativeDisplayManager_ErrorCode](#nativedisplaymanager_errorcode).
853
854
855### OH_NativeDisplayManager_GetDefaultDisplayScaledDensity()
856
857```
858NativeDisplayManager_ErrorCode OH_NativeDisplayManager_GetDefaultDisplayScaledDensity (float *scaledDensity)
859```
860
861**Description**
862
863Obtains the scale factor of fonts displayed on the default display.
864
865**System capability**: SystemCapability.WindowManager.WindowManager.Core
866
867**Since**: 12
868
869**Parameters**
870
871| Name| Description|
872| -------- | -------- |
873| scaledDensity | Pointer to the scale factor. The value is a floating-point number, and it is usually the same as that of **densityPixels**.|
874
875**Returns**
876
877Returns a status code defined in [NativeDisplayManager_ErrorCode](#nativedisplaymanager_errorcode).
878
879
880### OH_NativeDisplayManager_GetDefaultDisplayVirtualPixelRatio()
881
882```
883NativeDisplayManager_ErrorCode OH_NativeDisplayManager_GetDefaultDisplayVirtualPixelRatio (float *virtualPixels)
884```
885
886**Description**
887
888Obtains the virtual pixel ratio of the default display.
889
890**System capability**: SystemCapability.WindowManager.WindowManager.Core
891
892**Since**: 12
893
894**Parameters**
895
896| Name| Description|
897| -------- | -------- |
898| virtualPixels | Pointer to the virtual pixel ratio. The value is a floating-point number, and it is usually the same as that of **densityPixels**.|
899
900**Returns**
901
902Returns a status code defined in [NativeDisplayManager_ErrorCode](#nativedisplaymanager_errorcode).
903
904
905### OH_NativeDisplayManager_GetDefaultDisplayWidth()
906
907```
908NativeDisplayManager_ErrorCode OH_NativeDisplayManager_GetDefaultDisplayWidth (int32_t *displayWidth)
909```
910
911**Description**
912
913Obtains the width of the default display.
914
915**System capability**: SystemCapability.WindowManager.WindowManager.Core
916
917**Since**: 12
918
919**Parameters**
920
921| Name| Description|
922| -------- | -------- |
923| displayWidth | Pointer to the width, in px. The value is an integer.|
924
925**Returns**
926
927Returns a status code defined in [NativeDisplayManager_ErrorCode](#nativedisplaymanager_errorcode).
928
929
930### OH_NativeDisplayManager_GetFoldDisplayMode()
931
932```
933NativeDisplayManager_ErrorCode OH_NativeDisplayManager_GetFoldDisplayMode (NativeDisplayManager_FoldDisplayMode *displayMode)
934```
935
936**Description**
937
938Obtains the display mode of the foldable device.
939
940**System capability**: SystemCapability.Window.SessionManager
941
942**Since**: 12
943
944**Parameters**
945
946| Name| Description|
947| -------- | -------- |
948| displayMode | Pointer to the display mode. For details about the available options, see [NativeDisplayManager_FoldDisplayMode](#nativedisplaymanager_folddisplaymode).|
949
950**Returns**
951
952Returns a status code defined in [NativeDisplayManager_ErrorCode](#nativedisplaymanager_errorcode).
953
954
955### OH_NativeDisplayManager_IsFoldable()
956
957```
958bool OH_NativeDisplayManager_IsFoldable ()
959```
960
961**Description**
962
963Checks whether the current device is foldable.
964
965**System capability**: SystemCapability.WindowManager.WindowManager.Core
966
967**Since**: 12
968
969**Returns**
970
971Returns the check result. The value **true** means that the device is foldable, and **false** means the opposite.
972
973
974### OH_NativeDisplayManager_RegisterDisplayChangeListener()
975
976```
977NativeDisplayManager_ErrorCode OH_NativeDisplayManager_RegisterDisplayChangeListener (OH_NativeDisplayManager_DisplayChangeCallback displayChangeCallback, uint32_t *listenerIndex )
978```
979
980**Description**
981
982Registers a listener for status changes (such as rotation, refresh rate, DPI, and resolution changes) of the display.
983
984**System capability**: SystemCapability.WindowManager.WindowManager.Core
985
986**Since**: 12
987
988**Parameters**
989
990| Name| Description|
991| -------- | -------- |
992| displayChangeCallback | Callback function triggered when the display status is changed. For details, see [OH_NativeDisplayManager_DisplayChangeCallback](#oh_nativedisplaymanager_displaychangecallback).|
993| listenerIndex | Pointer to the index of the listener registered. It can be used as an input parameter of [OH_NativeDisplayManager_UnregisterDisplayChangeListener](#oh_nativedisplaymanager_unregisterdisplaychangelistener).|
994
995**Returns**
996
997Returns a status code defined in [NativeDisplayManager_ErrorCode](#nativedisplaymanager_errorcode).
998
999
1000### OH_NativeDisplayManager_RegisterFoldDisplayModeChangeListener()
1001
1002```
1003NativeDisplayManager_ErrorCode OH_NativeDisplayManager_RegisterFoldDisplayModeChangeListener (OH_NativeDisplayManager_FoldDisplayModeChangeCallback displayModeChangeCallback, uint32_t *listenerIndex )
1004```
1005
1006**Description**
1007
1008Registers a listener for folded/unfolded state changes of the display.
1009
1010**System capability**: SystemCapability.Window.SessionManager
1011
1012**Since**: 12
1013
1014**Parameters**
1015
1016| Name| Description|
1017| -------- | -------- |
1018| displayModeChangeCallback | Callback function triggered when the folded/unfolded state of the display is changed. For details, see [OH_NativeDisplayManager_FoldDisplayModeChangeCallback](#oh_nativedisplaymanager_folddisplaymodechangecallback).|
1019| listenerIndex | Pointer to the index of the listener registered. It can be used as an input parameter of [OH_NativeDisplayManager_UnregisterFoldDisplayModeChangeListener](#oh_nativedisplaymanager_unregisterfolddisplaymodechangelistener).|
1020
1021**Returns**
1022
1023Returns a status code defined in [NativeDisplayManager_ErrorCode](#nativedisplaymanager_errorcode).
1024
1025
1026### OH_NativeDisplayManager_UnregisterDisplayChangeListener()
1027
1028```
1029NativeDisplayManager_ErrorCode OH_NativeDisplayManager_UnregisterDisplayChangeListener (uint32_t listenerIndex)
1030```
1031
1032**Description**
1033
1034Cancels the listening for status changes of the display.
1035
1036**System capability**: SystemCapability.WindowManager.WindowManager.Core
1037
1038**Since**: 12
1039
1040**Parameters**
1041
1042| Name| Description|
1043| -------- | -------- |
1044| listenerIndex | Index of the listener returned when [OH_NativeDisplayManager_RegisterDisplayChangeListener](#oh_nativedisplaymanager_registerdisplaychangelistener) is called.|
1045
1046**Returns**
1047
1048Returns a status code defined in [NativeDisplayManager_ErrorCode](#nativedisplaymanager_errorcode).
1049
1050
1051### OH_NativeDisplayManager_UnregisterFoldDisplayModeChangeListener()
1052
1053```
1054NativeDisplayManager_ErrorCode OH_NativeDisplayManager_UnregisterFoldDisplayModeChangeListener (uint32_t listenerIndex)
1055```
1056
1057**Description**
1058
1059Cancels the listening for folded/unfolded state changes of the display.
1060
1061**System capability**: SystemCapability.Window.SessionManager
1062
1063**Since**: 12
1064
1065**Parameters**
1066
1067| Name| Description|
1068| -------- | -------- |
1069| listenerIndex | Index of the listener returned when [OH_NativeDisplayManager_RegisterFoldDisplayModeChangeListener](#oh_nativedisplaymanager_registerfolddisplaymodechangelistener) is called.|
1070
1071**Returns**
1072
1073Returns a status code defined in [NativeDisplayManager_ErrorCode](#nativedisplaymanager_errorcode).
1074