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