• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2024 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 /**
17  * @addtogroup OH_DisplayManager
18  * @{
19  *
20  * @brief Defines the data structures for the C APIs of the display module.
21  *
22  * @syscap SystemCapability.WindowManager.WindowManager.Core
23  * @since 12
24  * @version 1.0
25  */
26 
27 /**
28  * @file oh_display_manager.h
29  *
30  * @brief Defines the data structures for the C APIs of the display module.
31  *
32  * @kit ArkUI
33  * @library libnative_display_manager.so
34  * @syscap SystemCapability.WindowManager.WindowManager.Core
35  * @since 12
36  * @version 1.0
37  */
38 
39 #ifndef OH_NATIVE_DISPLAY_MANAGER_H
40 #define OH_NATIVE_DISPLAY_MANAGER_H
41 
42 
43 #include "oh_display_info.h"
44 
45 #ifdef __cplusplus
46 extern "C" {
47 #endif
48 
49 /**
50  * @brief Obtain the default display Id.
51  *
52  * @param displayId Indicates the pointer to an <b>uint64_t</b> object.
53  * @return { @link DISPLAY_MANAGER_OK } If the operation is successful
54  *         { @link DISPLAY_MANAGER_ERROR_INVALID_PARAM } If Parameter error.
55  *         { @link DISPLAY_MANAGER_ERROR_SYSTEM_ABNORMAL } If display manager service works abnormally.
56  * @syscap SystemCapability.WindowManager.WindowManager.Core
57  * @since 12
58  */
59 NativeDisplayManager_ErrorCode OH_NativeDisplayManager_GetDefaultDisplayId(uint64_t *displayId);
60 
61 /**
62  * @brief Obtain the default display width.
63  *
64  * @param displayWidth Indicates the pointer to an <b>int32_t</b> object.
65  * @return { @link DISPLAY_MANAGER_OK } If the operation is successful
66  *         { @link DISPLAY_MANAGER_ERROR_INVALID_PARAM } If Parameter error.
67  *         { @link DISPLAY_MANAGER_ERROR_SYSTEM_ABNORMAL } If display manager service works abnormally.
68  * @syscap SystemCapability.WindowManager.WindowManager.Core
69  * @since 12
70  */
71 NativeDisplayManager_ErrorCode OH_NativeDisplayManager_GetDefaultDisplayWidth(int32_t *displayWidth);
72 
73 /**
74  * @brief Obtain the default display height.
75  *
76  * @param displayHeight Indicates the pointer to an <b>int32_t</b> object.
77  * @return { @link DISPLAY_MANAGER_OK } If the operation is successful
78  *         { @link DISPLAY_MANAGER_ERROR_INVALID_PARAM } If Parameter error.
79  *         { @link DISPLAY_MANAGER_ERROR_SYSTEM_ABNORMAL } If display manager service works abnormally.
80  * @syscap SystemCapability.WindowManager.WindowManager.Core
81  * @since 12
82  */
83 NativeDisplayManager_ErrorCode OH_NativeDisplayManager_GetDefaultDisplayHeight(int32_t *displayHeight);
84 
85 /**
86  * @brief Obtain the default display rotation.
87  *
88  * @param displayRotation Indicates the pointer to an <b>NativeDisplayManager_Rotation</b> object.
89  * @return { @link DISPLAY_MANAGER_OK } If the operation is successful
90  *         { @link DISPLAY_MANAGER_ERROR_INVALID_PARAM } If Parameter error.
91  *         { @link DISPLAY_MANAGER_ERROR_SYSTEM_ABNORMAL } If display manager service works abnormally.
92  * @syscap SystemCapability.WindowManager.WindowManager.Core
93  * @since 12
94  */
95 NativeDisplayManager_ErrorCode OH_NativeDisplayManager_GetDefaultDisplayRotation(
96     NativeDisplayManager_Rotation *displayRotation);
97 
98 /**
99  * @brief Obtain the default display orientation.
100  *
101  * @param displayOrientation Indicates the pointer to an <b>NativeDisplayManager_Orientation</b> object.
102  * @return { @link DISPLAY_MANAGER_OK } If the operation is successful
103  *         { @link DISPLAY_MANAGER_ERROR_INVALID_PARAM } If Parameter error.
104  *         { @link DISPLAY_MANAGER_ERROR_SYSTEM_ABNORMAL } If display manager service works abnormally.
105  * @syscap SystemCapability.WindowManager.WindowManager.Core
106  * @since 12
107  */
108 NativeDisplayManager_ErrorCode OH_NativeDisplayManager_GetDefaultDisplayOrientation(
109     NativeDisplayManager_Orientation *displayOrientation);
110 
111 /**
112  * @brief Obtain the default display virtualPixels.
113  *
114  * @param virtualPixels Indicates the pointer to an <b>float</b> object.
115  * @return { @link DISPLAY_MANAGER_OK } If the operation is successful
116  *         { @link DISPLAY_MANAGER_ERROR_INVALID_PARAM } If Parameter error.
117  *         { @link DISPLAY_MANAGER_ERROR_SYSTEM_ABNORMAL } If display manager service works abnormally.
118  * @syscap SystemCapability.WindowManager.WindowManager.Core
119  * @since 12
120  */
121 NativeDisplayManager_ErrorCode OH_NativeDisplayManager_GetDefaultDisplayVirtualPixelRatio(float *virtualPixels);
122 
123 /**
124  * @brief Obtain the default display refreshRate.
125  *
126  * @param refreshRate Indicates the pointer to an <b>uint32_t</b> object.
127  * @return { @link DISPLAY_MANAGER_OK } If the operation is successful
128  *         { @link DISPLAY_MANAGER_ERROR_INVALID_PARAM } If Parameter error.
129  *         { @link DISPLAY_MANAGER_ERROR_SYSTEM_ABNORMAL } If display manager service works abnormally.
130  * @syscap SystemCapability.WindowManager.WindowManager.Core
131  * @since 12
132  */
133 NativeDisplayManager_ErrorCode OH_NativeDisplayManager_GetDefaultDisplayRefreshRate(uint32_t *refreshRate);
134 
135 /**
136  * @brief Obtain the default display densityDpi.
137  *
138  * @param densityDpi Indicates the pointer to an <b>int32_t</b> object.
139  * @return { @link DISPLAY_MANAGER_OK } If the operation is successful
140  *         { @link DISPLAY_MANAGER_ERROR_INVALID_PARAM } If Parameter error.
141  *         { @link DISPLAY_MANAGER_ERROR_SYSTEM_ABNORMAL } If display manager service works abnormally.
142  * @syscap SystemCapability.WindowManager.WindowManager.Core
143  * @since 12
144  */
145 NativeDisplayManager_ErrorCode OH_NativeDisplayManager_GetDefaultDisplayDensityDpi(int32_t *densityDpi);
146 
147 /**
148  * @brief Obtain the default display densityPixels.
149  *
150  * @param densityPixels Indicates the pointer to an <b>float</b> object.
151  * @return { @link DISPLAY_MANAGER_OK } If the operation is successful
152  *         { @link DISPLAY_MANAGER_ERROR_INVALID_PARAM } If Parameter error.
153  *         { @link DISPLAY_MANAGER_ERROR_SYSTEM_ABNORMAL } If display manager service works abnormally.
154  * @syscap SystemCapability.WindowManager.WindowManager.Core
155  * @since 12
156  */
157 NativeDisplayManager_ErrorCode OH_NativeDisplayManager_GetDefaultDisplayDensityPixels(float *densityPixels);
158 
159 /**
160  * @brief Obtain the default display scaledDensity.
161  *
162  * @param scaledDensity Indicates the pointer to an <b>float</b> object.
163  * @return { @link DISPLAY_MANAGER_OK } If the operation is successful
164  *         { @link DISPLAY_MANAGER_ERROR_INVALID_PARAM } If Parameter error.
165  *         { @link DISPLAY_MANAGER_ERROR_SYSTEM_ABNORMAL } If display manager service works abnormally.
166  * @syscap SystemCapability.WindowManager.WindowManager.Core
167  * @since 12
168  */
169 NativeDisplayManager_ErrorCode OH_NativeDisplayManager_GetDefaultDisplayScaledDensity(float *scaledDensity);
170 
171 /**
172  * @brief Obtain the default display xDpi.
173  *
174  * @param xDpi Indicates the pointer to an <b>float</b> object.
175  * @return { @link DISPLAY_MANAGER_OK } If the operation is successful
176  *         { @link DISPLAY_MANAGER_ERROR_INVALID_PARAM } If Parameter error.
177  *         { @link DISPLAY_MANAGER_ERROR_SYSTEM_ABNORMAL } If display manager service works abnormally.
178  * @syscap SystemCapability.WindowManager.WindowManager.Core
179  * @since 12
180  */
181 NativeDisplayManager_ErrorCode OH_NativeDisplayManager_GetDefaultDisplayDensityXdpi(float *xDpi);
182 
183 /**
184  * @brief Obtain the default display yDpi.
185  *
186  * @param yDpi Indicates the pointer to an <b>float</b> object.
187  * @return { @link DISPLAY_MANAGER_OK } If the operation is successful
188  *         { @link DISPLAY_MANAGER_ERROR_INVALID_PARAM } If Parameter error.
189  *         { @link DISPLAY_MANAGER_ERROR_SYSTEM_ABNORMAL } If display manager service works abnormally.
190  * @syscap SystemCapability.WindowManager.WindowManager.Core
191  * @since 12
192  */
193 NativeDisplayManager_ErrorCode OH_NativeDisplayManager_GetDefaultDisplayDensityYdpi(float *yDpi);
194 
195 /**
196  * @brief Create the cutout info of the device.
197  *
198  * @param cutoutInfo Indicates the pointer to an <b>NativeDisplayManager_CutoutInfo</b> object.
199  * @return { @link DISPLAY_MANAGER_OK } If the operation is successful
200  *         { @link DISPLAY_MANAGER_ERROR_INVALID_PARAM } If Parameter error.
201  *         { @link DISPLAY_MANAGER_ERROR_SYSTEM_ABNORMAL } If display manager service works abnormally.
202  * @syscap SystemCapability.WindowManager.WindowManager.Core
203  * @since 12
204  */
205 NativeDisplayManager_ErrorCode OH_NativeDisplayManager_CreateDefaultDisplayCutoutInfo(
206     NativeDisplayManager_CutoutInfo **cutoutInfo);
207 
208 /**
209  * @brief Destroy an <b>NativeDisplayManager_CutoutInfo</b> object and reclaims the memory occupied by the object.
210  *
211  * @param cutoutInfo Indicates the pointer to an <b>NativeDisplayManager_CutoutInfo</b> object.
212  * @return { @link DISPLAY_MANAGER_OK } If the operation is successful
213  *         { @link DISPLAY_MANAGER_ERROR_INVALID_PARAM } If Parameter error.
214  * @syscap SystemCapability.WindowManager.WindowManager.Core
215  * @since 12
216  */
217 NativeDisplayManager_ErrorCode OH_NativeDisplayManager_DestroyDefaultDisplayCutoutInfo(
218     NativeDisplayManager_CutoutInfo *cutoutInfo);
219 
220 /**
221  * @brief Check whether the device is foldable.
222  *
223  * @return { bool } true means the device is foldable.
224  * @syscap SystemCapability.WindowManager.WindowManager.Core
225  * @since 12
226  */
227 bool OH_NativeDisplayManager_IsFoldable();
228 
229 /**
230  * @brief Get the display mode of the foldable device.
231  *
232  * @param displayMode Indicates the pointer to an <b>NativeDisplayManager_FoldDisplayMode</b> object.
233  * @return { @link DISPLAY_MANAGER_OK } If the operation is successful
234  *         { @link DISPLAY_MANAGER_ERROR_INVALID_PARAM } If Parameter error.
235  *         { @link DISPLAY_MANAGER_ERROR_DEVICE_NOT_SUPPORTED } device not support.
236  * @syscap SystemCapability.Window.SessionManager
237  * @since 12
238  */
239 NativeDisplayManager_ErrorCode OH_NativeDisplayManager_GetFoldDisplayMode(
240     NativeDisplayManager_FoldDisplayMode *displayMode);
241 
242 /**
243  * @brief the callback function type when display change.
244  *
245  * @param displayId change display id.
246  * @syscap SystemCapability.Window.SessionManager
247  * @since 12
248  */
249 typedef void (*OH_NativeDisplayManager_DisplayChangeCallback)(uint64_t displayId);
250 
251 /**
252  * @brief Register the callback for display change listener.
253  *
254  * @param displayChangeCallback display change callback.
255  * @param listenerIndex Indicates the pointer to an <b>uint32_t</b> object. used in unregister call.
256  * @return { @link DISPLAY_MANAGER_OK } If the operation is successful
257  *         { @link DISPLAY_MANAGER_ERROR_INVALID_PARAM } If Parameter error.
258  *         { @link DISPLAY_MANAGER_ERROR_SYSTEM_ABNORMAL } If display manager service works abnormally.
259  * @syscap SystemCapability.WindowManager.WindowManager.Core
260  * @since 12
261  */
262 NativeDisplayManager_ErrorCode OH_NativeDisplayManager_RegisterDisplayChangeListener(
263     OH_NativeDisplayManager_DisplayChangeCallback displayChangeCallback, uint32_t *listenerIndex);
264 
265 /**
266  * @brief Unregister the callback for display changes listener.
267  *
268  * @param listenerIndex display changed listener index.
269  * @return { @link DISPLAY_MANAGER_OK } If the operation is successful
270  *         { @link DISPLAY_MANAGER_ERROR_INVALID_PARAM } If Parameter error.
271  *         { @link DISPLAY_MANAGER_ERROR_SYSTEM_ABNORMAL } If display manager service works abnormally.
272  * @syscap SystemCapability.WindowManager.WindowManager.Core
273  * @since 12
274  */
275 NativeDisplayManager_ErrorCode OH_NativeDisplayManager_UnregisterDisplayChangeListener(uint32_t listenerIndex);
276 
277 /**
278  * @brief the callback function type when display fold change.
279  *
280  * @param displayMode current fold display mode.
281  * @syscap SystemCapability.Window.SessionManager
282  * @since 12
283  */
284 typedef void (*OH_NativeDisplayManager_FoldDisplayModeChangeCallback)(
285     NativeDisplayManager_FoldDisplayMode displayMode);
286 
287 /**
288  * @brief Register the callback for display mode change listener.
289  *
290  * @param displayModeChangeCallback display mode change callback.
291  * @param listenerIndex Indicates the pointer to an <b>uint32_t</b> object. used in unregister call.
292  * @return { @link DISPLAY_MANAGER_OK } If the operation is successful
293  *         { @link DISPLAY_MANAGER_ERROR_INVALID_PARAM } If Parameter error.
294  *         { @link DISPLAY_MANAGER_ERROR_DEVICE_NOT_SUPPORTED } device not support.
295  *         { @link DISPLAY_MANAGER_ERROR_SYSTEM_ABNORMAL } If display manager service works abnormally.
296  * @syscap SystemCapability.Window.SessionManager
297  * @since 12
298  */
299 NativeDisplayManager_ErrorCode OH_NativeDisplayManager_RegisterFoldDisplayModeChangeListener(
300     OH_NativeDisplayManager_FoldDisplayModeChangeCallback displayModeChangeCallback, uint32_t *listenerIndex);
301 
302 /**
303  * @brief Unregister the callback for display mode change listener.
304  *
305  * @param listenerIndex display mode change listener index.
306  * @return { @link DISPLAY_MANAGER_OK } If the operation is successful
307  *         { @link DISPLAY_MANAGER_ERROR_INVALID_PARAM } If Parameter error.
308  *         { @link DISPLAY_MANAGER_ERROR_DEVICE_NOT_SUPPORTED } device not support.
309  *         { @link DISPLAY_MANAGER_ERROR_SYSTEM_ABNORMAL } If display manager service works abnormally.
310  * @syscap SystemCapability.Window.SessionManager
311  * @since 12
312  */
313 NativeDisplayManager_ErrorCode OH_NativeDisplayManager_UnregisterFoldDisplayModeChangeListener(uint32_t listenerIndex);
314 
315 /**
316  * @brief Create all displays.
317  *
318  * @param allDisplays Output parameter for all displays information.
319  * @return { @link DISPLAY_MANAGER_OK } If the operation is successful.
320  *         { @link DISPLAY_MANAGER_ERROR_INVALID_PARAM } If Parameter error.
321  *         { @link DISPLAY_MANAGER_ERROR_SYSTEM_ABNORMAL } If display manager service works abnormally.
322  * @syscap SystemCapability.Window.SessionManager.Core
323  * @since 14
324  */
325 NativeDisplayManager_ErrorCode OH_NativeDisplayManager_CreateAllDisplays(
326     NativeDisplayManager_DisplaysInfo **allDisplays);
327 
328 /**
329  * @brief Destroy all displays.
330  *
331  * @param allDisplays all displays to be free.
332  * @syscap SystemCapability.Window.SessionManager.Core
333  * @since 14
334  */
335 void OH_NativeDisplayManager_DestroyAllDisplays(NativeDisplayManager_DisplaysInfo *allDisplays);
336 
337 /**
338  * @brief Create display information by display id.
339  *
340  * @param displayId The display id.
341  * @param displayInfo The pointer to the display information.
342  * @return { @link DISPLAY_MANAGER_OK } If the operation is successful.
343  *         { @link DISPLAY_MANAGER_ERROR_INVALID_PARAM } If Parameter error.
344  *         { @link DISPLAY_MANAGER_ERROR_SYSTEM_ABNORMAL } If display manager service works abnormally.
345  * @syscap SystemCapability.Window.SessionManager.Core
346  * @since 14
347  */
348 NativeDisplayManager_ErrorCode OH_NativeDisplayManager_CreateDisplayById(uint32_t displayId,
349     NativeDisplayManager_DisplayInfo **displayInfo);
350 
351 /**
352  * @brief Destroy the display information.
353  *
354  * @param displayInfo the target display to be free.
355  * @syscap SystemCapability.Window.SessionManager.Core
356  * @since 14
357  */
358 void OH_NativeDisplayManager_DestroyDisplay(NativeDisplayManager_DisplayInfo *displayInfo);
359 
360 /**
361  * @brief Create a primary display.
362  *
363  * @param displayInfo The information of the created display.
364  * @return { @link DISPLAY_MANAGER_OK } If the operation is successful.
365  *         { @link DISPLAY_MANAGER_ERROR_INVALID_PARAM } If Parameter error.
366  *         { @link DISPLAY_MANAGER_ERROR_SYSTEM_ABNORMAL } If display manager service works abnormally.
367  * @syscap SystemCapability.Window.SessionManager.Core
368  * @since 14
369  */
370 NativeDisplayManager_ErrorCode OH_NativeDisplayManager_CreatePrimaryDisplay(
371     NativeDisplayManager_DisplayInfo **displayInfo);
372 
373 #ifdef __cplusplus
374 }
375 #endif
376 /** @} */
377 #endif // OH_NATIVE_DISPLAY_MANAGER_H
378