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