1 /*
2  * Copyright (c) 2024 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 I_ANCO_CONSUMER_H
17 #define I_ANCO_CONSUMER_H
18 
19 #include "key_event.h"
20 #include "pointer_event.h"
21 #include "window_info.h"
22 
23 namespace OHOS {
24 namespace MMI {
25 
26 enum class ANCO_WINDOW_UPDATE_TYPE: uint32_t {
27     ALL = 0,
28     INCREMENT = 1,
29 };
30 
31 struct AncoWindowInfo {
32     /**
33      * Globally unique identifier of the window
34      */
35     int32_t id;
36 
37     /**
38      * A 32-bit flag that represents the window status. If the 0th bitt is 1,
39      * the window is untouchable; if the 0th bit is 0, the window is touchable.
40      */
41     uint32_t flags;
42 
43     /**
44      * Agent window ID
45      */
46     WINDOW_UPDATE_ACTION action { WINDOW_UPDATE_ACTION::UNKNOWN };
47 
48     /**
49      * Window display ID
50      */
51     int32_t displayId { DEFAULT_DISPLAY_ID };
52 
53     /**
54      * Window order in Z-index
55      */
56     float zOrder { 0.0f };
57 
58     /**
59      * Window transform for changing display x,y to window x,y.
60      */
61     std::vector<float> transform;
62 
63     /**
64      * Number of touch response areas (excluding the mouse response areas) in the window.
65      * The value cannot exceed the value of MAX_HOTAREA_COUNT.
66      */
67     std::vector<Rect> defaultHotAreas;
68 
69     /**
70      * Number of excluded touch response areas in the window.
71      */
72     std::vector<Rect> ancoExcludedAreas;
73 };
74 
75 struct AncoWindows {
76     ANCO_WINDOW_UPDATE_TYPE updateType;
77     int32_t focusWindowId;
78     std::vector<AncoWindowInfo> windows;
79 
80     static bool Marshalling(const AncoWindows &windows, Parcel &parcel);
81     static bool Unmarshalling(Parcel &parcel, AncoWindows &windows);
82 };
83 
84 class IAncoConsumer {
85 public:
86     IAncoConsumer() = default;
87     virtual ~IAncoConsumer() = default;
88 
89     virtual int32_t SyncInputEvent(std::shared_ptr<PointerEvent> pointerEvent) = 0;
90     virtual int32_t SyncInputEvent(std::shared_ptr<KeyEvent> keyEvent) = 0;
91     virtual int32_t UpdateWindowInfo(std::shared_ptr<AncoWindows> windows) = 0;
92 };
93 } // namespace MMI
94 } // namespace OHOS
95 #endif // I_ANCO_CONSUMER_H
96