• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021-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 #ifndef DISPLAY_INFO_H
17 #define DISPLAY_INFO_H
18 
19 #include "parcel.h"
20 #include <string>
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 inline constexpr int32_t DEFAULT_GROUP_ID = 0;
28 constexpr uint32_t MAX_DISPLAY_GROUP_SIZE = 100;
29 constexpr uint32_t MAX_DISPLAY_SIZE = 1000;
30 constexpr uint32_t MAX_SCREEN_SIZE = 1000;
31 constexpr uint32_t MAX_WINDOWS_SIZE = 1000;
32 constexpr uint32_t MAX_UI_EXTENSION_SIZE = 1000;
33 constexpr uint32_t MAX_WINDOW_GROUP_INFO_SIZE = 1000;
34 
35 enum SecureFlag {
36     DEFAULT_MODE = 0,
37     PRIVACY_MODE = 1,
38 };
39 
40 /**
41  * @brief Enumerates the fold display mode.
42  */
43 enum class DisplayMode: uint32_t {
44     /**
45      * The default display mode
46      *
47      * @since 9
48      */
49     UNKNOWN = 0,
50 
51     /**
52      * The full display mode
53      *
54      * @since 9
55      */
56     FULL = 1,
57 
58     /**
59      * The main display mode
60      *
61      * @since 9
62      */
63     MAIN = 2,
64 
65     /**
66      * The sub display mode
67      *
68      * @since 9
69      */
70     SUB = 3,
71 
72     /**
73      * The coordination display mode
74      *
75      * @since 9
76      */
77     COORDINATION = 4,
78 };
79 
80 enum class WINDOW_UPDATE_ACTION: uint32_t {
81     /**
82      * The default window update action
83      *
84      * @since 9
85      */
86     UNKNOWN = 0,
87 
88     /**
89      * Add the window action
90      *
91      * @since 9
92      */
93     ADD = 1,
94 
95     /**
96      * Delete the window action
97      *
98      * @since 9
99      */
100     DEL = 2,
101 
102      /**
103      * Change the window action
104      *
105      * @since 9
106      */
107     CHANGE = 3,
108 
109     /**
110      * Add the window action end
111      *
112      * @since 9
113      */
114     ADD_END = 4,
115 };
116 
117 enum Direction {
118     /**
119      * Rotating the display clockwise by 0 degree
120      *
121      * @since 9
122      */
123     DIRECTION0,
124 
125     /**
126      * Rotating the display clockwise by 90 degrees
127      *
128      * @since 9
129      */
130     DIRECTION90,
131 
132     /**
133      * Rotating the display clockwise by 180 degrees
134      *
135      * @since 9
136      */
137     DIRECTION180,
138 
139     /**
140      * Rotating the display clockwise by 270 degrees
141      *
142      * @since 9
143      */
144     DIRECTION270
145 };
146 
147 struct Rect {
148     /**
149      * X coordinate of the upper left corner
150      *
151      * @since 9
152      */
153     int32_t x;
154 
155     /**
156      * Y coordinate of the upper left corner
157      *
158      * @since 9
159      */
160     int32_t y;
161 
162     /**
163      * Width
164      *
165      * @since 9
166      */
167     int32_t width;
168 
169     /**
170      * Height
171      *
172      * @since 9
173      */
174     int32_t height;
175 };
176 
177 enum class WindowInputType : uint8_t {
178     NORMAL = 0,
179     TRANSMIT_ALL = 1,
180     TRANSMIT_EXCEPT_MOVE = 2,
181     ANTI_MISTAKE_TOUCH = 3,
182     TRANSMIT_AXIS_MOVE = 4,
183     TRANSMIT_MOUSE_MOVE = 5,
184     TRANSMIT_LEFT_RIGHT = 6,
185     TRANSMIT_BUTTOM = 7,
186     MIX_LEFT_RIGHT_ANTI_AXIS_MOVE = 18,
187     MIX_BUTTOM_ANTI_AXIS_MOVE = 19,
188     SLID_TOUCH_WINDOW = 40,
189     TRANSMIT_ANTI_AXIS_MOVE = 50,
190     DUALTRIGGER_TOUCH = 60
191 };
192 
193 struct WindowInfo {
194     /**
195      * Maximum number of hot areas
196      *
197      * @since 9
198      */
199     static constexpr int32_t MAX_HOTAREA_COUNT = 50;
200 
201     static constexpr int32_t DEFAULT_HOTAREA_COUNT = 10;
202 
203     /**
204      * The number of pointer change areas
205      *
206      * @since 9
207      */
208     static constexpr int32_t POINTER_CHANGEAREA_COUNT = 8;
209 
210     /**
211      * The size of window transform, which create a 3*3 matrix
212      *
213      * @since 9
214      */
215     static constexpr int32_t WINDOW_TRANSFORM_SIZE = 9;
216 
217     /**
218      * Untouchable window
219      *
220      * @since 9
221      */
222     static constexpr uint32_t FLAG_BIT_UNTOUCHABLE = 1;
223 
224     /**
225      * Only handwriting window
226      *
227      * @since 12
228      */
229     static constexpr uint32_t FLAG_BIT_HANDWRITING = 2;
230 
231     /**
232      * Globally unique identifier of the window
233      *
234      * @since 9
235      */
236     int32_t id;
237 
238     /**
239      * ID of the process where the window is located
240      *
241      * @since 9
242      */
243     int32_t pid;
244 
245     /**
246      * UID of the process where the window is located
247      *
248      * @since 9
249      */
250     int32_t uid;
251 
252     /**
253      * Window display area
254      *
255      * @since 9
256      */
257     Rect area;
258 
259     /**
260      * Number of touch response areas (excluding the mouse response areas) in the window.
261      * The value cannot exceed the value of MAX_HOTAREA_COUNT.
262      *
263      * @since 9
264      */
265     std::vector<Rect> defaultHotAreas;
266 
267     /**
268      * Number of mouse response areas in the window. The value cannot exceed the value of MAX_HOTAREA_COUNT.
269      *
270      * @since 9
271      */
272     std::vector<Rect> pointerHotAreas;
273 
274     /**
275      * Agent window ID
276      *
277      * @since 9
278      */
279     int32_t agentWindowId;
280 
281     /**
282      * A 32-bit flag that represents the window status. If the 0th bit is 1,
283      * the window is untouchable; if the 0th bit is 0, the window is touchable.
284      *
285      * @since 9
286      */
287     uint32_t flags;
288 
289     /**
290      * Agent window ID
291      *
292      * @since 9
293      */
294     WINDOW_UPDATE_ACTION action { WINDOW_UPDATE_ACTION::UNKNOWN };
295 
296     /**
297      * Window display ID
298      *
299      * @since 9
300      */
301     int32_t displayId { DEFAULT_DISPLAY_ID };
302 
303     /**
304      * display group ID
305      *
306      * @since 19
307      */
308     int32_t groupId { DEFAULT_GROUP_ID };
309 
310     /**
311      * Window order in Z-index
312      *
313      * @since 9
314      */
315     float zOrder { 0.0f };
316 
317     /**
318      * Number of mouse style change areas in the window. The value must be POINTER_CHANGEAREA_COUNT.
319      *
320      * @since 9
321      */
322     std::vector<int32_t> pointerChangeAreas;
323 
324     /**
325      * Number of transform in the window which is used to calculate the window x and window y by logic x and window y.
326      * The value must be POINTER_CHANGEAREA_COUNT.
327      *
328      * @since 9
329      */
330     std::vector<float> transform;
331 
332     /**
333      * pixelMap Indicates the special-shaped window. Its actual type must be OHOS::Media::PixelMap*,
334      * which is used to determine whether an event is dispatched to the current window.
335      *
336      * @since 12
337      */
338     void* pixelMap { nullptr };
339 
340     WindowInputType windowInputType { WindowInputType::NORMAL };
341 
342     SecureFlag privacyMode { SecureFlag::DEFAULT_MODE };
343 
344     int32_t windowType;
345 
346     bool privacyUIFlag { false };
347 
348     std::vector<WindowInfo> uiExtentionWindowInfo;
349 
350     bool rectChangeBySystem { false };
351 
352     bool isDisplayCoord { false };
353 
354     bool isSkipSelfWhenShowOnVirtualScreen { false };
355 
356     int32_t windowNameType;
357 };
358 
359 /**
360  * Physical screen information
361  *
362  * @since 9
363  */
364 enum class DisplaySourceMode : uint32_t {
365     SCREEN_ALONE,
366     SCREEN_EXPAND,
367 
368     /**
369      * mirror screen
370      *
371      * @since 20
372      */
373     SCREEN_MIRROR,
374 
375     /**
376      * different source screen
377      *
378      * @since 20
379      */
380     SCREEN_UNIQUE,
381 
382     /**
383      * extend screen
384      *
385      * @since 20
386      */
387     SCREEN_EXTEND,
388 
389     /**
390      * main screen
391      *
392      * @since 20
393      */
394     SCREEN_MAIN
395 };
396 
397 /**
398 * The area of ​​the logical screen on the physical screen
399 * Based on screen 0°, not affected by display rotation angle
400 * @since 20
401 */
402 struct ScreenArea {
403     /**
404      * The unique ID of the physical screen.
405      *
406      * @since 20
407      */
408     int32_t id;
409 
410     /**
411      * The area of ​​the logical screen on the physical screen
412      * The upper left corner of the screen is the origin
413      * Based on screen 0°, not affected by display rotation angle
414      * @since 20
415      */
416     Rect area;
417 };
418 
419 struct DisplayInfo {
420     /**
421      * Unique ID of the logical display, this value is greater than or equal to 0 and is unique in user space.
422      *
423      * @since 9 20
424      */
425     int32_t id;
426 
427     /**
428      * The x offset of the upper left corner of the current rotation angle of the screen relative to the upper
429      * left corner of the main screen, in px, changes with the rotation
430      * @since 9 20
431      */
432     int32_t x;
433 
434     /**
435      * The y offset of the upper left corner of the current rotation angle of the screen relative to the upper
436      * left corner of the main screen, changes with the rotation. in px.
437      *
438      * @since 9 20
439      */
440     int32_t y;
441 
442     /**
443      * Display width, which is the logical width of the original screen when the rotation angle is 0.
444      * The value remains unchanged even if the display screen is rotated. in px.
445      *
446      * @since 9 20
447      */
448     int32_t width;
449 
450     /**
451      * Display height, which is the logical height of the original screen when the rotation angle is 0.
452      * The value changed if the display screen is rotated. in px.
453      *
454      * @since 9
455      */
456     int32_t height;
457 
458     /**
459      * Pixel density, which indicates the number of pixels in an inch,changes with resolution adjustment
460      *
461      * @since 10
462      */
463     int32_t dpi;
464 
465     /**
466      * Name of the logical display, which is used for debugging
467      *
468      * @since 9
469      */
470     std::string name;
471 
472     /**
473      * The angle increment from the logical screen orientation of 0° clockwise to the current screen orientation.
474      *
475      * @since 9 20
476      */
477     Direction direction;
478 
479     /**
480      * The angle increment from the current rotation angle of the logical screen to the rotation angle of
481      * its window content display clockwise.
482      * @since 20
483      */
484     Direction displayDirection;
485 
486     /**
487      * DisplayMode of the display
488      *
489      * @since 9
490      */
491     DisplayMode displayMode { DisplayMode::UNKNOWN };
492 
493     /**
494      * Number of transform in the screen which is used to calculate the display x and display y by logic x and logic y.
495      * The value must be POINTER_CHANGEAREA_COUNT.
496      *
497      * @since 12
498      */
499     std::vector<float> transform;
500 
501     /**
502      * Scale percent of oneHand rect to display rect.
503      * If 'scalePercent < 100', it means one hand mode.
504      * If 'scalePercent == 100', it means not in one hand mode.
505      */
506     int32_t scalePercent = 100;
507 
508     /**
509      * Expand height from bottom.
510      */
511     int32_t expandHeight = 0;
512 
513     /**
514      * Use for off screen policy
515      *
516      * @since 12
517      */
518     bool isCurrentOffScreenRendering = false;
519 
520     /**
521      * logical screen mode
522      *
523      * @since 12 20
524      */
525     DisplaySourceMode displaySourceMode = DisplaySourceMode::SCREEN_MAIN;
526 
527     /**
528      * Coordinate of the upper left corner of the virtual screen in one-hand mode.
529      * If oneHandX is 0, the virtual screen is in the lower left corner.
530      * If oneHandX is greater than 0, the virtual screen is in the lower right corner.
531      */
532     int32_t oneHandX = 0;
533     int32_t oneHandY = 0;
534 
535     /**
536     * The area of ​​the logical screen on the physical screen
537     * Based on screen 0°, not affected by display rotation angle
538     * @since 20
539     */
540     ScreenArea screenArea;
541 
542     /**
543      * rs id.
544      *
545      * @since 20
546      */
547     uint64_t rsId;
548 
549     /**
550      * The x coordinate of the valid area relative to the entire logical screen
551      *
552      * @since 20
553      */
554     int32_t offsetX = 0;
555     /**
556      * The y coordinate of the valid area relative to the entire logical screen
557      *
558      * @since 12
559      */
560     int32_t offsetY = 0;
561     /**
562      * The Pointer Active Width
563      *
564      * @since 12
565      */
566     int32_t pointerActiveWidth { 0 };
567 
568     /**
569      * The Pointer Active Height
570      *
571      * @since 12
572      */
573     int32_t pointerActiveHeight { 0 };
574 };
575 /**
576 * Screen type.
577 *
578 * @since 20
579 */
580 enum class ScreenType : uint32_t {
581     UNDEFINED,
582     /**
583      * real screen.
584      *
585      * @since 20
586      */
587     REAL,
588 
589     /**
590      * virtual screen.
591      *
592      * @since 20
593      */
594     VIRTUAL
595 };
596 
597 /**
598 * The angle of the physical screen relative to the sensor 0 degrees.
599 *
600 * @since 20
601 */
602 enum class Rotation : uint32_t {
603     ROTATION_0,
604     ROTATION_90,
605     ROTATION_180,
606     ROTATION_270,
607 };
608 
609 /**
610  * physical screen information
611  *
612  * @since 20
613  */
614 struct ScreenInfo {
615     /**
616      * The unique ID of the physical screen.
617      *
618      * @since 20
619      */
620     int32_t id;
621 
622     /**
623      * Unique screen ID, which is used to associate the corresponding touchscreen.
624      * The default value is default0.
625      *
626      * @since 20
627      */
628     std::string uniqueId;
629 
630     /**
631      * Screen type.
632      *
633      * @since 20
634      */
635     ScreenType screenType { ScreenType::REAL };
636 
637     /**
638      * The width of the physical screen, in px. Does not follow rotation. Does not change for
639      * the same physical screen.
640      *
641      * @since 20
642      */
643     int32_t width;
644 
645     /**
646      * The height of the physical screen, in px. Does not follow rotation. Does not change for
647      * the same physical screen.
648      *
649      * @since 20
650      */
651     int32_t height;
652 
653     /**
654      * The width of the physical screen, in mm. Does not follow the rotation. Does not change for
655      * the same physical screen.
656      *
657      * @since 20
658      */
659     int32_t physicalWidth;
660     /**
661      * The width of the physical height, in mm. Does not follow the rotation. Does not change for
662      *  the same physical screen.
663      *
664      * @since 20
665      */
666     int32_t physicalHeight;
667 
668     /**
669      * The angle from the screen default origin to the TP origin clockwise.
670      *
671      * @since 20
672      */
673     Direction tpDirection;
674 
675     /**
676      * Physical pixel density does not change with resolution.
677      *
678      * @since 20
679      */
680     int32_t dpi;
681 
682     /**
683      * The number of pixels per inch is a physical property and does not change.
684      *
685      * @since 20
686      */
687     int32_t ppi;
688 
689     /**
690      * The angle of the physical screen relative to the sensor 0 degrees.
691      *
692      * @since 20
693      */
694     Rotation rotation;
695 };
696 
697 /**
698  * Logical screen group type
699  *
700  * @since 20
701  */
702 enum GroupType {
703     /**
704     * The default group, the group that receives input events. This group can only have one
705     *
706     * @since 20
707     */
708     GROUP_DEFAULT = 0,
709 
710     /**
711     * The special group, the group can have multiple.
712     *
713     * @since 20
714     */
715     GROUP_SPECIAL = 1,
716 };
717 /**
718  * Logical screen information
719  *
720  * @since 9 20
721  */
722 struct DisplayGroupInfo {
723     /**
724      * Logical screen group id, at least the user space level guarantees uniqueness.
725      * The range is greater than or equal to 0
726      *
727      * @since 20
728      */
729     int32_t id;
730 
731     /**
732      * Logical screen group name
733      *
734      * @since 20
735      */
736     std::string name;
737 
738     /**
739      * Logical screen group type
740      *
741      * @since 20
742      */
743     GroupType type;
744 
745     /**
746      * The main logical screen ID. The logical screen with this ID must be in the displaysInfo.
747      *
748      * @since 20
749      */
750     int32_t mainDisplayId;
751 
752     /**
753      * ID of the focus window, The value -1 indicates that there is no focused window in the current screen group.
754      * The default screen group must have a focused window.
755      *
756      * @since 9 20
757      */
758     int32_t focusWindowId;
759 
760     /**
761      * List of window information of the logical display arranged in Z order, with the top window at the top
762      *
763      * @since 9
764      */
765     std::vector<WindowInfo> windowsInfo;
766 
767     /**
768      * logical screen information list
769      *
770      * @since 9 20
771      */
772     std::vector<DisplayInfo> displaysInfo;
773 };
774 
775 /**
776  * user's screen information
777  *
778  * @since 20
779  */
780 struct UserScreenInfo {
781     /**
782      * user id.
783      *
784      * @since 20
785      */
786     int32_t userId;
787 
788     /**
789      * Physical screen information.
790      *
791      * @since 20
792      */
793     std::vector<ScreenInfo> screens;
794 
795     /**
796      * Logical screen information.
797      *
798      * @since 20
799      */
800     std::vector<DisplayGroupInfo> displayGroups;
801 };
802 
803 struct WindowGroupInfo {
804     /**
805      * ID of the focus window
806      *
807      * @since 9
808      */
809     int32_t focusWindowId { GLOBAL_WINDOW_ID };
810 
811     /**
812      * Window display ID
813      *
814      * @since 9
815      */
816     int32_t displayId { DEFAULT_DISPLAY_ID };
817 
818     /**
819      * List of window information of the logical display arranged in Z order, with the top window at the top
820      *
821      * @since 9
822      */
823     std::vector<WindowInfo> windowsInfo;
824 };
825 
826 struct DisplayBindInfo : public Parcelable {
827     int32_t inputDeviceId { -1 };
828     std::string inputDeviceName;
829     int32_t displayId { -1 };
830     std::string displayName;
831 
MarshallingDisplayBindInfo832     bool Marshalling(Parcel &parcel) const
833     {
834         if (!parcel.WriteInt32(inputDeviceId)) {
835             return false;
836         }
837         if (!parcel.WriteString(inputDeviceName)) {
838             return false;
839         }
840         if (!parcel.WriteInt32(displayId)) {
841             return false;
842         }
843         if (!parcel.WriteString(displayName)) {
844             return false;
845         }
846         return true;
847     };
848 
ReadFromParcelDisplayBindInfo849     bool ReadFromParcel(Parcel &parcel)
850     {
851         return (
852             parcel.ReadInt32(inputDeviceId) &&
853             parcel.ReadString(inputDeviceName) &&
854             parcel.ReadInt32(displayId) &&
855             parcel.ReadString(displayName)
856         );
857     }
858 
UnmarshallingDisplayBindInfo859     static DisplayBindInfo* Unmarshalling(Parcel &parcel)
860     {
861         auto obj = new (std::nothrow) DisplayBindInfo();
862         if (obj && !obj->ReadFromParcel(parcel)) {
863             delete obj;
864             obj = nullptr;
865         }
866         return obj;
867     };
868 };
869 enum class WindowArea: int32_t {
870     ENTER = 0,
871     EXIT,
872     FOCUS_ON_INNER,
873     FOCUS_ON_TOP,
874     FOCUS_ON_BOTTOM,
875     FOCUS_ON_LEFT,
876     FOCUS_ON_RIGHT,
877     FOCUS_ON_TOP_LEFT,
878     FOCUS_ON_TOP_RIGHT,
879     FOCUS_ON_BOTTOM_LEFT,
880     FOCUS_ON_BOTTOM_RIGHT,
881     TOP_LEFT_LIMIT,
882     TOP_RIGHT_LIMIT,
883     TOP_LIMIT,
884     LEFT_LIMIT,
885     RIGHT_LIMIT,
886     BOTTOM_LEFT_LIMIT,
887     BOTTOM_LIMIT,
888     BOTTOM_RIGHT_LIMIT
889 };
890 
891 using DisplayBindInfos = std::vector<DisplayBindInfo>;
892 } // namespace MMI
893 } // namespace OHOS
894 #endif // DISPLAY_INFO_H
895