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