1 /* 2 * Copyright (c) 2025 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 * @file oh_window.h 18 * 19 * @brief Declares APIs for window 20 * 21 * @syscap SystemCapability.Window.SessionManager 22 * @library libnative_window_manager.so 23 * @kit ArkUI 24 * @since 15 25 */ 26 #ifndef OH_WINDOW_H 27 #define OH_WINDOW_H 28 29 #include <stdint.h> 30 #include "oh_window_comm.h" 31 #include "wm_common.h" 32 33 #ifdef __cplusplus 34 extern "C" { 35 #endif 36 37 /** 38 * @brief Set whether to show status bar. 39 * 40 * @param windowId WindowId when window is created. 41 * @param enabled If true, the status bar is displayed. If false, the status bar is hidden. 42 * @param enableAnimation If true, the status bar is displayed and hidden with animation. 43 * If false, the status bar is displayed and hidden with no animation. 44 * @return Return the result code. 45 * {@link OK} the function call is successful. 46 * {@link WINDOW_MANAGER_ERRORCODE_INVALID_PARAM} parameter error. 47 * {@link WINDOW_MANAGER_ERRORCODE_DEVICE_NOT_SUPPORTED} capability not supported. 48 * {@link WINDOW_MANAGER_ERRORCODE_STATE_ABNORMAL} this window state is abnormal. 49 * {@link WINDOW_MANAGER_ERRORCODE_SYSTEM_ABNORMAL} the window manager service works abnormal. 50 * @since 15 51 */ 52 int32_t OH_WindowManager_SetWindowStatusBarEnabled(int32_t windowId, bool enabled, bool enableAnimation); 53 54 /** 55 * @brief Set status bar content color. 56 * 57 * @param windowId WindowId when window is created. 58 * @param color The color value to set, the format is ARGB. 59 * @return Return the result code. 60 * {@link OK} the function call is successful. 61 * {@link WINDOW_MANAGER_ERRORCODE_INVALID_PARAM} parameter error. 62 * {@link WINDOW_MANAGER_ERRORCODE_DEVICE_NOT_SUPPORTED} capability not supported. 63 * {@link WINDOW_MANAGER_ERRORCODE_STATE_ABNORMAL} this window state is abnormal. 64 * {@link WINDOW_MANAGER_ERRORCODE_SYSTEM_ABNORMAL} the window manager service works abnormal. 65 * @since 15 66 */ 67 int32_t OH_WindowManager_SetWindowStatusBarColor(int32_t windowId, int32_t color); 68 69 /** 70 * @brief Set whether to show navigation bar. 71 * 72 * @param windowId WindowId when window is created. 73 * @param enabled If true, the navigation bar is displayed. If false, the navigation bar is hidden. 74 * @param enableAnimation If true, the navigation bar is displayed and hidden with animation. 75 * If false, the navigation bar is displayed and hidden with no animation. 76 * @return Return the result code. 77 * {@link OK} the function call is successful. 78 * {@link WINDOW_MANAGER_ERRORCODE_INVALID_PARAM} parameter error. 79 * {@link WINDOW_MANAGER_ERRORCODE_DEVICE_NOT_SUPPORTED} capability not supported. 80 * {@link WINDOW_MANAGER_ERRORCODE_STATE_ABNORMAL} this window state is abnormal. 81 * {@link WINDOW_MANAGER_ERRORCODE_SYSTEM_ABNORMAL} the window manager service works abnormal. 82 * @since 15 83 */ 84 int32_t OH_WindowManager_SetWindowNavigationBarEnabled(int32_t windowId, bool enabled, bool enableAnimation); 85 86 /** 87 * @brief Get the avoid area 88 * 89 * @param windowId WindowId when window is created. 90 * @param type Type of the avoid area. 91 * @param avoidArea Indicates the pointer to a WindowManager_AvoidArea object. 92 * @return Returns the status code of the execution. 93 * @return Return the result code. 94 * {@link OK} the function call is successful, return avoid area ptr in avoidArea. 95 * {@link WINDOW_MANAGER_ERRORCODE_INVALID_PARAM} parameter error. 96 * {@link WINDOW_MANAGER_ERRORCODE_STATE_ABNORMAL} this window state is abnormal. 97 * {@link WINDOW_MANAGER_ERRORCODE_SYSTEM_ABNORMAL} the window manager service works abnormal. 98 * @since 15 99 */ 100 int32_t OH_WindowManager_GetWindowAvoidArea( 101 int32_t windowId, WindowManager_AvoidAreaType type, WindowManager_AvoidArea* avoidArea); 102 103 /** 104 * @brief Checks whether the window is displayed. 105 * 106 * @param windowId WindowId when window is created. 107 * @param isShow Whether the window is displayed. The value true means that the window is displayed, 108 and false means the opposite. 109 * @return Returns the result code. 110 * {@link OK} the function call is successful. 111 * {@link WINDOW_MANAGER_ERRORCODE_INVALID_PARAM} parameter error. 112 * {@link WINDOW_MANAGER_ERRORCODE_STATE_ABNORMAL} this window state is abnormal. 113 * @since 15 114 */ 115 int32_t OH_WindowManager_IsWindowShown(int32_t windowId, bool* isShow); 116 117 /** 118 * @brief Show window. 119 * 120 * @param windowId WindowId when window is created. 121 * @return Returns the result code. 122 * {@link OK} the function call is successful. 123 * {@link WINDOW_MANAGER_ERRORCODE_INVALID_PARAM} parameter error. 124 * {@link WINDOW_MANAGER_ERRORCODE_STATE_ABNORMAL} this window state is abnormal. 125 * {@link WINDOW_MANAGER_ERRORCODE_SYSTEM_ABNORMAL} the window manager service works abnormally. 126 * @since 15 127 */ 128 int32_t OH_WindowManager_ShowWindow(int32_t windowId); 129 130 /** 131 * @brief Sets the background color of window. 132 * 133 * @param windowId WindowId when window is created. 134 * @param color the specified color. 135 * @return Return the result code. 136 * {@link OK} the function call is successful. 137 * {@link WINDOW_MANAGER_ERRORCODE_INVALID_PARAM} parameter error. 138 * {@link WINDOW_MANAGER_ERRORCODE_STATE_ABNORMAL} this window state is abnormal. 139 * @since 16 140 */ 141 int32_t OH_WindowManager_SetWindowBackgroundColor(int32_t windowId, const char* color); 142 143 /** 144 * @brief Sets the brightness of window. 145 * 146 * @param windowId WindowId when window is created. 147 * @param brightness the specified brightness value. 148 * @return Return the result code. 149 * {@link OK} the function call is successful. 150 * {@link WINDOW_MANAGER_ERRORCODE_INVALID_PARAM} parameter error. 151 * {@link WINDOW_MANAGER_ERRORCODE_STATE_ABNORMAL} this window state is abnormal. 152 * {@link WINDOW_MANAGER_ERRORCODE_SYSTEM_ABNORMAL} the window manager service works abnormal. 153 * @since 16 154 */ 155 int32_t OH_WindowManager_SetWindowBrightness(int32_t windowId, float brightness); 156 157 /** 158 * @brief Sets whether keep screen on or not. 159 * 160 * @param windowId WindowId when window is created. 161 * @param isKeepScreenOn keep screen on if true, or not if false. 162 * @return Return the result code. 163 * {@link OK} the function call is successful. 164 * {@link WINDOW_MANAGER_ERRORCODE_INVALID_PARAM} parameter error. 165 * {@link WINDOW_MANAGER_ERRORCODE_STATE_ABNORMAL} this window state is abnormal. 166 * {@link WINDOW_MANAGER_ERRORCODE_SYSTEM_ABNORMAL} the window manager service works abnormal. 167 * @since 16 168 */ 169 int32_t OH_WindowManager_SetWindowKeepScreenOn(int32_t windowId, bool isKeepScreenOn); 170 171 /** 172 * @brief Sets whether is private mode or not. 173 * 174 * @permission {@code ohos.permission.PRIVACY_WINDOW} 175 * @param windowId WindowId when window is created. 176 * @param isPrivacy In private mode if true, or not if false. 177 * @return Returns the result code. 178 * {@link OK} the function call is successful. 179 * {@link WINDOW_MANAGER_ERRORCODE_INVALID_PARAM} parameter error. 180 * {@link WINDOW_MANAGER_ERRORCODE_STATE_ABNORMAL} this window state is abnormal. 181 * {@link WINDOW_MANAGER_ERRORCODE_SYSTEM_ABNORMAL} the window manager service works abnormally. 182 * {@link WINDOW_MANAGER_ERRORCODE_NO_PERMISSION} permission verification failed. 183 * @since 16 184 */ 185 int32_t OH_WindowManager_SetWindowPrivacyMode(int32_t windowId, bool isPrivacy); 186 187 /** 188 * @brief Get the properties of current window. 189 * 190 * @param windowId WindowId when window is created. 191 * @param windowProperties Properties of current window. 192 * @return Return the result code. 193 * {@link OK} the function call is successful, return window properties ptr in windowProperties. 194 * {@link WINDOW_MANAGER_ERRORCODE_INVALID_PARAM} parameter error. 195 * {@link WINDOW_MANAGER_ERRORCODE_STATE_ABNORMAL} this window state is abnormal. 196 * {@link WINDOW_MANAGER_ERRORCODE_SYSTEM_ABNORMAL} the window manager service works abnormal. 197 * @since 16 198 */ 199 int32_t OH_WindowManager_GetWindowProperties( 200 int32_t windowId, WindowManager_WindowProperties* windowProperties); 201 202 /** 203 * @brief Obtains snapshot of window. 204 * 205 * @param windowId windowId when window is created. 206 * @param pixelMap snapshot of window. 207 * @return Return the result code. 208 * {@link OK} the function call is successful, return pixel map ptr in pixelMap. 209 * {@link WINDOW_MANAGER_ERRORCODE_INVALID_PARAM} parameter error. 210 * {@link WINDOW_MANAGER_ERRORCODE_STATE_ABNORMAL} this window state is abnormal. 211 * {@link WINDOW_MANAGER_ERRORCODE_SYSTEM_ABNORMAL} the window manager service works abnormal. 212 * @since 16 213 */ 214 int32_t OH_WindowManager_Snapshot(int32_t windowId, OH_PixelmapNative* pixelMap); 215 216 /** 217 * @brief set window touchable status. 218 * 219 * @param windowId windowId when window is created. 220 * @param touchable window touchable status. 221 * @return Return the result code. 222 * {@link OK} the function call is successful. 223 * {@link WINDOW_MANAGER_ERRORCODE_INVALID_PARAM} parameter error. 224 * {@link WINDOW_MANAGER_ERRORCODE_STATE_ABNORMAL} this window state is abnormal. 225 * {@link WINDOW_MANAGER_ERRORCODE_SYSTEM_ABNORMAL} the window manager service works abnormal. 226 * @since 16 227 */ 228 int32_t OH_WindowManager_SetWindowTouchable(int32_t windowId, bool touchable); 229 230 /** 231 * @brief Set focusable property of window. 232 * 233 * @param windowId WindowId when window is created. 234 * @param isFocusable Window can be focused or not. 235 * @return Returns the result code. 236 * {@link OK} the function call is successful. 237 * {@link WINDOW_MANAGER_ERRORCODE_INVALID_PARAM} parameter error. 238 * {@link WINDOW_MANAGER_ERRORCODE_STATE_ABNORMAL} this window state is abnormal. 239 * {@link WINDOW_MANAGER_ERRORCODE_SYSTEM_ABNORMAL} the window manager service works abnormally. 240 * @since 16 241 */ 242 int32_t OH_WindowManager_SetWindowFocusable(int32_t windowId, bool isFocusable); 243 244 /** 245 * @brief Get Layout info of all windows on the selected display. 246 * 247 * @param display IdIndicate the id of display. 248 * @param windowLayoutInfo Pointer to the layout information of the visible windows on the specified screen. 249 * @param windowLayoutInfoSize Pointer to the size of the array of layout information of the visible windows on the 250 * specified screen. 251 * @return Returns the result code. 252 * {@link OK} the function call is successful, return window layout info list. 253 * {@link WINDOW_MANAGER_ERRORCODE_INVALID_PARAM} parameter error. 254 * {@link WINDOW_MANAGER_ERRORCODE_DEVICE_NOT_SUPPORTED} capability not supported. 255 * {@link WINDOW_MANAGER_ERRORCODE_SYSTEM_ABNORMAL} the window manager service works abnormally. 256 * @since 17 257 */ 258 int32_t OH_WindowManager_GetAllWindowLayoutInfoList( 259 int64_t displayId, WindowManager_Rect** windowLayoutInfoList, size_t* windowLayoutInfoSize); 260 261 /** 262 * @brief Release the memory of window layout info list. 263 * 264 * @param windowLayoutInfo Pointer to the layout information of the visible windows on the specified screen. 265 * @since 17 266 */ 267 void OH_WindowManager_ReleaseAllWindowLayoutInfoList(WindowManager_Rect* windowLayoutInfoList); 268 #ifdef __cplusplus 269 } 270 #endif 271 #endif // OH_WINDOW_H