1 /* 2 * Copyright (C) 2022 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 ACCESSIBILITY_WINDOW_INFO_H 17 #define ACCESSIBILITY_WINDOW_INFO_H 18 19 #include <vector> 20 #include "accessibility_element_info.h" 21 22 namespace OHOS { 23 namespace Accessibility { 24 class AccessibilityWindowInfo { 25 public: 26 /** 27 * @brief Construct 28 * @since 3 29 * @sysCap Accessibility 30 */ 31 AccessibilityWindowInfo(); 32 33 /** 34 * @brief Get the window type. 35 * @return The accessibility window type. Refer to [AccessibilityWindowType]. 36 * @since 3 37 * @sysCap Accessibility 38 */ 39 AccessibilityWindowType GetAccessibilityWindowType() const; 40 41 /** 42 * @brief Set the window type. 43 * @param type The accessibility window type. Refer to [AccessibilityWindowType]. 44 * @since 3 45 * @sysCap Accessibility 46 */ 47 void SetAccessibilityWindowType(const AccessibilityWindowType type); 48 49 /** 50 * @brief Get The window layer 51 * @return The layer of window 52 * @since 3 53 * @sysCap Accessibility 54 */ 55 int32_t GetWindowLayer() const; 56 57 /** 58 * @brief Set The window layer 59 * @param layer The window layer 60 * @since 3 61 * @sysCap Accessibility 62 */ 63 void SetWindowLayer(const int32_t layer); 64 65 /** 66 * @brief Get the window id of current window. 67 * @return The window id of current window. 68 * @since 3 69 * @sysCap Accessibility 70 */ 71 int32_t GetWindowId() const; 72 73 /** 74 * @brief Set the window id of current window. 75 * @param id The window id of current window. 76 * @since 3 77 * @sysCap Accessibility 78 */ 79 void SetWindowId(const int32_t id); 80 81 /** 82 * @brief Get the screen pixel coordinates 83 * @return The screen pixel coordinates 84 * @since 3 85 * @sysCap Accessibility 86 */ 87 const Rect &GetRectInScreen() const; 88 89 /** 90 * @brief Set the screen pixel coordinates 91 * @param bounds The screen pixel coordinates 92 * @since 3 93 * @sysCap Accessibility 94 */ 95 void SetRectInScreen(const Rect &bounds); 96 97 /** 98 * @brief Check whether the window is active or not. 99 * @return true: the window is active, otherwise is not. 100 * @since 3 101 * @sysCap Accessibility 102 */ 103 bool IsActive() const; 104 105 /** 106 * @brief Set whether the window is active or not. 107 * @param active true: the window is active, otherwise is not. 108 * @since 3 109 * @sysCap Accessibility 110 */ 111 void SetActive(bool active); 112 113 /** 114 * @brief Checks whether this window has gained focus. 115 * @return true: the window has gained focus, otherwise is not. 116 * @since 3 117 * @sysCap Accessibility 118 */ 119 bool IsFocused() const; 120 121 /** 122 * @brief Set whether this window has gained focus. 123 * @param focused true: the window has gained focus, otherwise is not. 124 * @since 3 125 * @sysCap Accessibility 126 */ 127 void SetFocused(bool focused); 128 129 /** 130 * @brief Checks whether this window has gained accessibility focus. 131 * @return true: this window has gained accessibility focus, otherwise is not. 132 * @since 3 133 * @sysCap Accessibility 134 */ 135 bool IsAccessibilityFocused() const; 136 137 /** 138 * @brief Set whether this window has gained accessibility focus. 139 * @param accessibilityFocused true: this window has gained accessibility focus, otherwise is not. 140 * @since 3 141 * @sysCap Accessibility 142 */ 143 void SetAccessibilityFocused(const bool accessibilityFocused); 144 145 /** 146 * @brief Set the display id 147 * @param displayId the display id of the window 148 * @sysCap Accessibility 149 */ 150 void SetDisplayId(const uint64_t displayId); 151 152 /** 153 * @brief Get the display id 154 * @return Return the display id of the window. 155 * @sysCap Accessibility 156 */ 157 uint64_t GetDisplayId() const; 158 159 /** 160 * @brief Get window type 161 * @return The type of window. Refer to [OHOS::Rosen::WindowType]. 162 * @sysCap Accessibility 163 */ 164 uint32_t GetWindowType() const; 165 166 /** 167 * @brief Set window type 168 * @param type The type of window. Refer to [OHOS::Rosen::WindowType]. 169 * @sysCap Accessibility 170 */ 171 void SetWindowType(const uint32_t type); 172 173 /** 174 * @brief Get window mode 175 * @return The mode of window. Refer to [OHOS::Rosen::WindowMode]. 176 * @sysCap Accessibility 177 */ 178 uint32_t GetWindowMode() const; 179 180 /** 181 * @brief Set window mode 182 * @param mode The mode of window. Refer to [OHOS::Rosen::WindowMode]. 183 * @sysCap Accessibility 184 */ 185 void SetWindowMode(const uint32_t mode); 186 187 /** 188 * @brief Get whether the decoration state is enabled 189 * @return true:the decoration is enabled; false:the decoration is disabled 190 * @sysCap Accessibility 191 */ 192 bool IsDecorEnable() const; 193 194 /** 195 * @brief Set the decoration state 196 * @param isDecorEnable true:enable decoration; false:disable decoration 197 * @sysCap Accessibility 198 */ 199 void SetDecorEnable(const bool isDecorEnable); 200 201 /** 202 * @brief Set inner window id 203 * @param innerWid inner window id 204 * @sysCap Accessibility 205 */ 206 void SetInnerWid(const int32_t innerWid); 207 208 /** 209 * @brief Get inner window id 210 * @return Inner window id 211 * @sysCap Accessibility 212 */ 213 int32_t GetInnerWid() const; 214 215 /** 216 * @brief Set arkui node id 217 * @param nodeId Arkui node id 218 * @sysCap Accessibility 219 */ 220 void SetUiNodeId(const int64_t nodeId); 221 222 /** 223 * @brief Get arkui node id 224 * @return Arkui node id 225 * @sysCap Accessibility 226 */ 227 int64_t GetUiNodeId() const; 228 229 /** 230 * @brief Set window scale val 231 * @param scaleVal_ WMS scale Val 232 * @sysCap Accessibility 233 */ 234 void SetScaleVal(const float scaleVal); 235 236 /** 237 * @brief Get window scale val 238 * @return window scale val 239 * @sysCap Accessibility 240 */ 241 float GetScaleVal() const; 242 243 /** 244 * @brief Set window scale x 245 * @param scaleX_ WMS scale x 246 * @sysCap Accessibility 247 */ 248 void SetScaleX(const float scaleX); 249 250 /** 251 * @brief Get window Scale X 252 * @return window Scale X 253 * @sysCap Accessibility 254 */ 255 float GetScaleX() const; 256 257 /** 258 * @brief Set window scale Y 259 * @param scaleY_ WMS scale Y 260 * @sysCap Accessibility 261 */ 262 void SetScaleY(const float scaleY); 263 264 /** 265 * @brief Get window scale Y 266 * @return window scale Y 267 * @sysCap Accessibility 268 */ 269 float GetScaleY() const; 270 271 /** 272 * @brief Set window bundle name 273 * @param bundleName_ WMS bundle name 274 * @sysCap Accessibility 275 */ 276 void SetBundleName(const std::string bundleName); 277 278 /** 279 * @brief Get window bundle name 280 * @return window bundle name 281 * @sysCap Accessibility 282 */ 283 std::string GetBundleName(); 284 285 /** 286 * @brief Set window touch hot areas 287 * @param touchHotAreas_ WMS touch hot areas 288 * @sysCap Accessibility 289 */ 290 void SetTouchHotAreas(const std::vector<Rect> &touchHotAreas); 291 292 /** 293 * @brief Get window touch hot areas 294 * @return window touch hot areas 295 * @sysCap Accessibility 296 */ 297 std::vector<Rect> GetTouchHotAreas(); 298 299 /** 300 * @brief Get the main window id of current window. 301 * @return The main window id of current window. 302 * @sysCap Accessibility 303 */ 304 int32_t GetMainWindowId() const; 305 306 /** 307 * @brief Set the main window id of current window. 308 * @param id The main window id of current window. 309 * @sysCap Accessibility 310 */ 311 void SetMainWindowId(const int32_t id); 312 313 protected: 314 uint64_t displayId_ = 0; 315 uint32_t windowMode_ = 0; 316 uint32_t windowType_ = 0; 317 AccessibilityWindowType accessibilityWindowType_ = TYPE_WINDOW_INVALID; 318 int32_t windowLayer_ = INVALID_WINDOW_ID; 319 int32_t windowId_ = INVALID_WINDOW_ID; 320 bool active_ = false; 321 bool focused_ = false; 322 bool accessibilityFocused_ = false; 323 Rect boundsInScreen_ {}; 324 bool isDecorEnable_ = false; 325 int32_t innerWid_ = 0; // used for window id 1, scene board 326 int64_t uiNodeId_ = 0; // used for window id 1, scene board 327 float scaleVal_ = 0.0; 328 float scaleX_ = 0.0; 329 float scaleY_ = 0.0; 330 std::string bundleName_ = ""; 331 std::vector<Rect> touchHotAreas_ = {}; 332 int32_t mainWindowId_ = INVALID_WINDOW_ID; 333 }; 334 } // namespace Accessibility 335 } // namespace OHOS 336 #endif // ACCESSIBILITY_WINDOW_INFO_H