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