• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 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 FOUNDATION_ACE_FRAMEWORKS_CORE_COMMON_EVENT_DUMP_H
17 #define FOUNDATION_ACE_FRAMEWORKS_CORE_COMMON_EVENT_DUMP_H
18 
19 #include <cstdint>
20 #include <list>
21 #include <map>
22 #include <string>
23 
24 #include "base/memory/ace_type.h"
25 #include "base/memory/referenced.h"
26 #include "base/geometry/ng/offset_t.h"
27 #include "base/geometry/ng/rect_t.h"
28 #include "core/event/touch_event.h"
29 
30 namespace OHOS::Ace::NG {
31 struct FrameNodeSnapshot {
32     void Dump(std::list<std::pair<int32_t, std::string>>& dumpList, int32_t depth) const;
33 
34     int32_t nodeId = -1;
35     int32_t parentNodeId = -1;
36     std::string tag;
37     std::string comId;
38     bool monopolizeEvents = false;
39     bool isHit = false;
40     int32_t hitTestMode = 0;
41     std::vector<RectF> responseRegionList;
42 };
43 
44 struct TouchPointSnapshot {
45     TouchPointSnapshot() = default;
46     TouchPointSnapshot(const TouchEvent& event);
47 
48     void Dump(std::list<std::pair<int32_t, std::string>>& dumpList, int32_t depth) const;
49 
50     int32_t id = -1;
51     OffsetF point;
52     OffsetF screenPoint;
53     TouchType type = TouchType::UNKNOWN;
54     int64_t timestamp = 0;
55     bool isInjected = false;
56 };
57 
58 struct EventTree {
59     std::list<TouchPointSnapshot> touchPoints;
60     std::list<FrameNodeSnapshot> hitTestTree;
61 
62     std::map<int32_t, std::list<RefPtr<GestureSnapshot>>> gestureTree;
63     std::map<uint64_t, RefPtr<GestureSnapshot>> gestureMap;
64 
65     int32_t touchDownCount = 0;
66     std::set<int32_t> downFingerIds_;
67 };
68 
69 struct EventTreeRecord {
70     void AddTouchPoint(const TouchEvent& event);
71 
72     void AddFrameNodeSnapshot(FrameNodeSnapshot&& node);
73 
74     void AddGestureSnapshot(int32_t finger, RefPtr<GestureSnapshot>&& gesture);
75 
76     void AddGestureProcedure(uint64_t id,
77         const std::string& procedure, const std::string& state, const std::string& disposal, int64_t timestamp = 0);
78 
79     void AddGestureProcedure(uint64_t id,
80         const TouchEvent& point, const std::string& state, const std::string& disposal, int64_t timestamp = 0);
81 
82     void Dump(std::list<std::pair<int32_t, std::string>>& dumpList, int32_t depth, int32_t startNumber = 0) const;
83 
84     std::list<EventTree> eventTreeList;
85 };
86 }
87 #endif
88