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