1 /* 2 * Copyright (c) 2021-2023 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 DISPLAY_INFO_H 17 #define DISPLAY_INFO_H 18 19 #include <string> 20 #include <vector> 21 22 namespace OHOS { 23 namespace MMI { 24 inline constexpr int32_t GLOBAL_WINDOW_ID = -1; 25 26 inline constexpr int32_t DEFAULT_DISPLAY_ID = -1; 27 28 enum SecureFlag { 29 DEFAULT_MODE = 0, 30 PRIVACY_MODE = 1, 31 }; 32 33 /** 34 * @brief Enumerates the fold display mode. 35 */ 36 enum class DisplayMode: uint32_t { 37 /** 38 * The default display mode 39 * 40 * @since 9 41 */ 42 UNKNOWN = 0, 43 44 /** 45 * The full display mode 46 * 47 * @since 9 48 */ 49 FULL = 1, 50 51 /** 52 * The main display mode 53 * 54 * @since 9 55 */ 56 MAIN = 2, 57 58 /** 59 * The sub display mode 60 * 61 * @since 9 62 */ 63 SUB = 3, 64 65 /** 66 * The coordination display mode 67 * 68 * @since 9 69 */ 70 COORDINATION = 4, 71 }; 72 73 enum class WINDOW_UPDATE_ACTION: uint32_t { 74 /** 75 * The default window update action 76 * 77 * @since 9 78 */ 79 UNKNOWN = 0, 80 81 /** 82 * Add the window action 83 * 84 * @since 9 85 */ 86 ADD = 1, 87 88 /** 89 * Delete the window action 90 * 91 * @since 9 92 */ 93 DEL = 2, 94 95 /** 96 * Change the window action 97 * 98 * @since 9 99 */ 100 CHANGE = 3, 101 102 /** 103 * Add the window action end 104 * 105 * @since 9 106 */ 107 ADD_END = 4, 108 }; 109 110 enum Direction { 111 /** 112 * Rotating the display clockwise by 0 degree 113 * 114 * @since 9 115 */ 116 DIRECTION0, 117 118 /** 119 * Rotating the display clockwise by 90 degrees 120 * 121 * @since 9 122 */ 123 DIRECTION90, 124 125 /** 126 * Rotating the display clockwise by 180 degrees 127 * 128 * @since 9 129 */ 130 DIRECTION180, 131 132 /** 133 * Rotating the display clockwise by 270 degrees 134 * 135 * @since 9 136 */ 137 DIRECTION270 138 }; 139 140 struct Rect { 141 /** 142 * X coordinate of the upper left corner 143 * 144 * @since 9 145 */ 146 int32_t x; 147 148 /** 149 * Y coordinate of the upper left corner 150 * 151 * @since 9 152 */ 153 int32_t y; 154 155 /** 156 * Width 157 * 158 * @since 9 159 */ 160 int32_t width; 161 162 /** 163 * Height 164 * 165 * @since 9 166 */ 167 int32_t height; 168 }; 169 170 enum class WindowInputType : uint8_t { 171 NORMAL = 0, 172 TRANSMIT_ALL = 1, 173 TRANSMIT_EXCEPT_MOVE = 2, 174 ANTI_MISTAKE_TOUCH = 3, 175 TRANSMIT_AXIS_MOVE = 4, 176 TRANSMIT_MOUSE_MOVE = 5, 177 TRANSMIT_LEFT_RIGHT = 6, 178 TRANSMIT_BUTTOM = 7, 179 MIX_LEFT_RIGHT_ANTI_AXIS_MOVE = 18, 180 MIX_BUTTOM_ANTI_AXIS_MOVE = 19 181 }; 182 183 struct WindowInfo { 184 /** 185 * Maximum number of hot areas 186 * 187 * @since 9 188 */ 189 static constexpr int32_t MAX_HOTAREA_COUNT = 50; 190 191 static constexpr int32_t DEFAULT_HOTAREA_COUNT = 10; 192 193 /** 194 * The number of pointer change areas 195 * 196 * @since 9 197 */ 198 static constexpr int32_t POINTER_CHANGEAREA_COUNT = 8; 199 200 /** 201 * The size of window transform, which create a 3*3 matrix 202 * 203 * @since 9 204 */ 205 static constexpr int32_t WINDOW_TRANSFORM_SIZE = 9; 206 207 /** 208 * Untouchable window 209 * 210 * @since 9 211 */ 212 static constexpr uint32_t FLAG_BIT_UNTOUCHABLE = 1; 213 214 /** 215 * Only handwriting window 216 * 217 * @since 12 218 */ 219 static constexpr uint32_t FLAG_BIT_HANDWRITING = 2; 220 221 /** 222 * Globally unique identifier of the window 223 * 224 * @since 9 225 */ 226 int32_t id; 227 228 /** 229 * ID of the process where the window is located 230 * 231 * @since 9 232 */ 233 int32_t pid; 234 235 /** 236 * UID of the process where the window is located 237 * 238 * @since 9 239 */ 240 int32_t uid; 241 242 /** 243 * Window display area 244 * 245 * @since 9 246 */ 247 Rect area; 248 249 /** 250 * Number of touch response areas (excluding the mouse response areas) in the window. 251 * The value cannot exceed the value of MAX_HOTAREA_COUNT. 252 * 253 * @since 9 254 */ 255 std::vector<Rect> defaultHotAreas; 256 257 /** 258 * Number of mouse response areas in the window. The value cannot exceed the value of MAX_HOTAREA_COUNT. 259 * 260 * @since 9 261 */ 262 std::vector<Rect> pointerHotAreas; 263 264 /** 265 * Agent window ID 266 * 267 * @since 9 268 */ 269 int32_t agentWindowId; 270 271 /** 272 * A 32-bit flag that represents the window status. If the 0th bit is 1, 273 * the window is untouchable; if the 0th bit is 0, the window is touchable. 274 * 275 * @since 9 276 */ 277 uint32_t flags; 278 279 /** 280 * Agent window ID 281 * 282 * @since 9 283 */ 284 WINDOW_UPDATE_ACTION action { WINDOW_UPDATE_ACTION::UNKNOWN }; 285 286 /** 287 * Window display ID 288 * 289 * @since 9 290 */ 291 int32_t displayId { DEFAULT_DISPLAY_ID }; 292 293 /** 294 * Window order in Z-index 295 * 296 * @since 9 297 */ 298 float zOrder { 0.0f }; 299 300 /** 301 * Number of mouse style change areas in the window. The value must be POINTER_CHANGEAREA_COUNT. 302 * 303 * @since 9 304 */ 305 std::vector<int32_t> pointerChangeAreas; 306 307 /** 308 * Number of transform in the window which is used to calculate the window x and window y by logic x and window y. 309 * The value must be POINTER_CHANGEAREA_COUNT. 310 * 311 * @since 9 312 */ 313 std::vector<float> transform; 314 315 /** 316 * pixelMap Indicates the special-shaped window. Its actual type must be OHOS::Media::PixelMap*, 317 * which is used to determine whether an event is dispatched to the current window. 318 * 319 * @since 12 320 */ 321 void* pixelMap { nullptr }; 322 323 WindowInputType windowInputType { WindowInputType::NORMAL }; 324 325 SecureFlag privacyMode { SecureFlag::DEFAULT_MODE }; 326 327 int32_t windowType; 328 329 bool privacyUIFlag { false }; 330 331 std::vector<WindowInfo> uiExtentionWindowInfo; 332 333 bool rectChangeBySystem { false }; 334 }; 335 336 /** 337 * Physical screen information 338 * 339 * @since 9 340 */ 341 struct DisplayInfo { 342 /** 343 * Unique ID of the physical display 344 * 345 * @since 9 346 */ 347 int32_t id; 348 349 /** 350 * X coordinate of the upper left corner on the logical screen 351 * 352 * @since 9 353 */ 354 int32_t x; 355 356 /** 357 * Y coordinate of the upper left corner on the logical screen 358 * 359 * @since 9 360 */ 361 int32_t y; 362 363 /** 364 * Display width, which is the logical width of the original screen when the rotation angle is 0. 365 * The value remains unchanged even if the display screen is rotated. 366 * 367 * @since 9 368 */ 369 int32_t width; 370 371 /** 372 * Display height, which is the logical height of the original screen when the rotation angle is 0. 373 * The value remains unchanged even if the display screen is rotated. 374 * 375 * @since 9 376 */ 377 int32_t height; 378 379 /** 380 * Pixel density, which indicates the number of pixels in an inch 381 * 382 * @since 10 383 */ 384 int32_t dpi; 385 386 /** 387 * Name of the physical display, which is used for debugging 388 * 389 * @since 9 390 */ 391 std::string name; 392 393 /** 394 * Unique screen ID, which is used to associate the corresponding touchscreen. The default value is default0. 395 * 396 * @since 9 397 */ 398 std::string uniq; 399 400 /** 401 * Orientation of the physical display 402 * 403 * @since 9 404 */ 405 Direction direction; 406 407 Direction displayDirection; 408 409 /** 410 * DisplayMode of the display 411 * 412 * @since 9 413 */ 414 DisplayMode displayMode { DisplayMode::UNKNOWN }; 415 416 /** 417 * Number of transform in the screen which is used to calculate the display x and display y by logic x and logic y. 418 * The value must be POINTER_CHANGEAREA_COUNT. 419 * 420 * @since 12 421 */ 422 std::vector<float> transform; 423 }; 424 425 /** 426 * Logical screen information 427 * 428 * @since 9 429 */ 430 struct DisplayGroupInfo { 431 /** 432 * Width of the logical display 433 * 434 * @since 9 435 */ 436 int32_t width; 437 438 /** 439 * Height of the logical display 440 * 441 * @since 9 442 */ 443 int32_t height; 444 445 /** 446 * ID of the focus window 447 * 448 * @since 9 449 */ 450 int32_t focusWindowId; 451 452 int32_t currentUserId { -1 }; 453 454 /** 455 * List of window information of the logical display arranged in Z order, with the top window at the top 456 * 457 * @since 9 458 */ 459 std::vector<WindowInfo> windowsInfo; 460 461 /** 462 * Physical screen information list 463 * 464 * @since 9 465 */ 466 std::vector<DisplayInfo> displaysInfo; 467 }; 468 469 struct WindowGroupInfo { 470 /** 471 * ID of the focus window 472 * 473 * @since 9 474 */ 475 int32_t focusWindowId { GLOBAL_WINDOW_ID }; 476 477 /** 478 * Window display ID 479 * 480 * @since 9 481 */ 482 int32_t displayId { DEFAULT_DISPLAY_ID }; 483 484 /** 485 * List of window information of the logical display arranged in Z order, with the top window at the top 486 * 487 * @since 9 488 */ 489 std::vector<WindowInfo> windowsInfo; 490 }; 491 492 struct DisplayBindInfo { 493 int32_t inputDeviceId { -1 }; 494 std::string inputDeviceName; 495 int32_t displayId { -1 }; 496 std::string displayName; 497 }; 498 enum class WindowArea: int32_t { 499 ENTER = 0, 500 EXIT, 501 FOCUS_ON_INNER, 502 FOCUS_ON_TOP, 503 FOCUS_ON_BOTTOM, 504 FOCUS_ON_LEFT, 505 FOCUS_ON_RIGHT, 506 FOCUS_ON_TOP_LEFT, 507 FOCUS_ON_TOP_RIGHT, 508 FOCUS_ON_BOTTOM_LEFT, 509 FOCUS_ON_BOTTOM_RIGHT, 510 TOP_LEFT_LIMIT, 511 TOP_RIGHT_LIMIT, 512 TOP_LIMIT, 513 LEFT_LIMIT, 514 RIGHT_LIMIT, 515 BOTTOM_LEFT_LIMIT, 516 BOTTOM_LIMIT, 517 BOTTOM_RIGHT_LIMIT 518 }; 519 520 using DisplayBindInfos = std::vector<DisplayBindInfo>; 521 } // namespace MMI 522 } // namespace OHOS 523 #endif // DISPLAY_INFO_H 524