37 {
38 if (!registry_->is_bound()) {
40 << "Lost connection to fuchsia.ui.pointerinjector.Registry";
41 return false;
42 }
43
44 auto method = request.FindMember("method");
45 if (method == request.MemberEnd() || !method->value.IsString()) {
46 FML_LOG(
ERROR) <<
"No method found in platform message.";
47 return false;
48 }
49
51 FML_LOG(
ERROR) <<
"Unexpected platform message method, expected "
52 "View.pointerinjector.inject.";
53 return false;
54 }
55
56 auto args_it = request.FindMember("args");
57 if (args_it == request.MemberEnd() || !args_it->value.IsObject()) {
58 FML_LOG(
ERROR) <<
"No arguments found in platform message's method";
59 return false;
60 }
61
62 const auto&
args = args_it->value;
63
64 auto view_id =
args.FindMember(
"viewId");
65 if (!view_id->value.IsUint64()) {
67 return false;
68 }
69
70 auto id = view_id->value.GetUint64();
71 if (valid_views_.count(id) == 0) {
72
73
74
75
76 Complete(std::move(response), "[0]");
77 return true;
78 }
79
80 auto phase =
args.FindMember(
"phase");
81 if (!phase->value.IsInt()) {
83 return false;
84 }
85
86 auto pointer_x =
args.FindMember(
"x");
87 if (!pointer_x->value.IsFloat() && !pointer_x->value.IsInt()) {
89 return false;
90 }
91
92 auto pointer_y =
args.FindMember(
"y");
93 if (!pointer_y->value.IsFloat() && !pointer_y->value.IsInt()) {
95 return false;
96 }
97
98 auto pointer_id =
args.FindMember(
"pointerId");
99 if (!pointer_id->value.IsUint()) {
100 FML_LOG(
ERROR) <<
"Argument 'pointerId' is not a uint32";
101 return false;
102 }
103
104 auto trace_flow_id =
args.FindMember(
"traceFlowId");
105 if (!trace_flow_id->value.IsInt()) {
106 FML_LOG(
ERROR) <<
"Argument 'traceFlowId' is not a int";
107 return false;
108 }
109
110 auto width =
args.FindMember(
"logicalWidth");
111 if (!
width->value.IsFloat() && !
width->value.IsInt()) {
112 FML_LOG(
ERROR) <<
"Argument 'logicalWidth' is not a float";
113 return false;
114 }
115
116 auto height =
args.FindMember(
"logicalHeight");
117 if (!
height->value.IsFloat() && !
height->value.IsInt()) {
118 FML_LOG(
ERROR) <<
"Argument 'logicalHeight' is not a float";
119 return false;
120 }
121
122 auto timestamp =
args.FindMember(
"timestamp");
123 if (!timestamp->value.IsInt() && !timestamp->value.IsUint64()) {
125 return false;
126 }
127
128 PointerInjectorRequest event = {
129 .x = pointer_x->value.GetFloat(),
130 .y = pointer_y->value.GetFloat(),
131 .pointer_id = pointer_id->value.GetUint(),
133 .trace_flow_id = trace_flow_id->value.GetUint64(),
134 .logical_size = {
width->value.GetFloat(),
height->value.GetFloat()},
135 .timestamp = timestamp->value.GetInt()};
136
137
138 valid_views_.at(
id).InjectEvent(std::move(
event));
139 Complete(std::move(response), "[0]");
140 return true;
141}
static constexpr auto kPointerInjectorMethodPrefix
G_BEGIN_DECLS G_MODULE_EXPORT FlValue * args
#define FML_LOG(severity)
fuchsia::ui::pointer::EventPhase fup_EventPhase