• 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 #include "adapter/ohos/entrance/ace_view_ohos.h"
17 #include "pointer_event.h"
18 
19 #include <memory>
20 
21 #include "input_manager.h"
22 #include "adapter/ohos/entrance/ace_container.h"
23 #include "adapter/ohos/entrance/mmi_event_convertor.h"
24 #include "base/log/ace_trace.h"
25 #include "base/log/dump_log.h"
26 #include "base/log/event_report.h"
27 #include "base/log/log.h"
28 #include "base/utils/macros.h"
29 #include "base/utils/system_properties.h"
30 #include "base/utils/utils.h"
31 #include "core/common/ace_engine.h"
32 #include "core/components/theme/theme_manager.h"
33 #include "core/event/axis_event.h"
34 #include "core/event/key_event.h"
35 #include "core/event/mouse_event.h"
36 #include "core/event/focus_axis_event.h"
37 #include "core/event/non_pointer_event.h"
38 #include "core/event/pointer_event.h"
39 #include "core/event/touch_event.h"
40 
41 namespace OHOS::Ace::Platform {
42 namespace {
43 
44 constexpr int32_t ROTATION_DIVISOR = 64;
45 
IsMMIMouseScrollBegin(const AxisEvent & event)46 bool IsMMIMouseScrollBegin(const AxisEvent& event)
47 {
48     if (event.action != AxisAction::BEGIN ||
49         event.sourceType != SourceType::MOUSE ||
50         event.sourceTool != SourceTool::MOUSE) {
51         return false;
52     }
53     return !(NearZero(event.horizontalAxis) && NearZero(event.verticalAxis));
54 }
55 } // namespace
56 
CreateView(int32_t instanceId,bool useCurrentEventRunner,bool usePlatformThread)57 RefPtr<AceViewOhos> AceViewOhos::CreateView(int32_t instanceId, bool useCurrentEventRunner, bool usePlatformThread)
58 {
59     return AceType::MakeRefPtr<AceViewOhos>(
60         instanceId, ThreadModelImpl::CreateThreadModel(
61                         useCurrentEventRunner, !usePlatformThread, !SystemProperties::GetRosenBackendEnabled()));
62 }
63 
AceViewOhos(int32_t id,std::unique_ptr<ThreadModelImpl> threadModelImpl)64 AceViewOhos::AceViewOhos(int32_t id, std::unique_ptr<ThreadModelImpl> threadModelImpl)
65     : instanceId_(id), threadModelImpl_(std::move(threadModelImpl))
66 {}
67 
SurfaceCreated(const RefPtr<AceViewOhos> & view,OHOS::sptr<OHOS::Rosen::Window> window)68 void AceViewOhos::SurfaceCreated(const RefPtr<AceViewOhos>& view, OHOS::sptr<OHOS::Rosen::Window> window)
69 {
70     CHECK_NULL_VOID(window);
71     CHECK_NULL_VOID(view);
72 }
73 
ChangeViewSize(const RefPtr<AceViewOhos> & view,int32_t width,int32_t height)74 void AceViewOhos::ChangeViewSize(const RefPtr<AceViewOhos>& view, int32_t width, int32_t height)
75 {
76     CHECK_NULL_VOID(view);
77     view->ChangeSize(width, height);
78 }
79 
SurfaceChanged(const RefPtr<AceViewOhos> & view,int32_t width,int32_t height,int32_t orientation,WindowSizeChangeReason type,const std::shared_ptr<Rosen::RSTransaction> & rsTransaction)80 void AceViewOhos::SurfaceChanged(const RefPtr<AceViewOhos>& view, int32_t width, int32_t height, int32_t orientation,
81     WindowSizeChangeReason type, const std::shared_ptr<Rosen::RSTransaction>& rsTransaction)
82 {
83     CHECK_NULL_VOID(view);
84 
85     view->NotifySurfaceChanged(width, height, type, rsTransaction);
86 
87     auto instanceId = view->GetInstanceId();
88     auto container = Platform::AceContainer::GetContainer(instanceId);
89     if (container) {
90         auto pipelineContext = container->GetPipelineContext();
91         CHECK_NULL_VOID(pipelineContext);
92         pipelineContext->HideOverlays();
93     }
94 }
95 
SurfacePositionChanged(const RefPtr<AceViewOhos> & view,int32_t posX,int32_t posY)96 void AceViewOhos::SurfacePositionChanged(const RefPtr<AceViewOhos>& view, int32_t posX, int32_t posY)
97 {
98     CHECK_NULL_VOID(view);
99     view->NotifySurfacePositionChanged(posX, posY);
100 }
101 
SetViewportMetrics(const RefPtr<AceViewOhos> & view,const ViewportConfig & config)102 void AceViewOhos::SetViewportMetrics(const RefPtr<AceViewOhos>& view, const ViewportConfig& config)
103 {
104     CHECK_NULL_VOID(view);
105     view->NotifyDensityChanged(config.Density());
106 }
107 
TransformHintChanged(const RefPtr<AceViewOhos> & view,uint32_t transform)108 void AceViewOhos::TransformHintChanged(const RefPtr<AceViewOhos>& view, uint32_t transform)
109 {
110     CHECK_NULL_VOID(view);
111     view->NotifyTransformHintChanged(transform);
112 }
113 
IsAxisEvent(const std::shared_ptr<MMI::PointerEvent> & pointerEvent)114 bool IsAxisEvent(const std::shared_ptr<MMI::PointerEvent>& pointerEvent)
115 {
116     return pointerEvent->GetAxes() != 0;
117 }
118 
DispatchTouchEvent(const RefPtr<AceViewOhos> & view,const std::shared_ptr<MMI::PointerEvent> & pointerEvent,const RefPtr<OHOS::Ace::NG::FrameNode> & node,const std::function<void ()> & callback,bool isInjected)119 void AceViewOhos::DispatchTouchEvent(const RefPtr<AceViewOhos>& view,
120     const std::shared_ptr<MMI::PointerEvent>& pointerEvent, const RefPtr<OHOS::Ace::NG::FrameNode>& node,
121     const std::function<void()>& callback, bool isInjected)
122 {
123     if (!pointerEvent) {
124         TAG_LOGE(AceLogTag::ACE_INPUTTRACKING, "DispatchTouchEvent pointerEvent is null return.");
125         return;
126     }
127     if (!view) {
128         MMI::InputManager::GetInstance()->MarkProcessed(
129             pointerEvent->GetId(), pointerEvent->GetActionTime(), pointerEvent->IsMarkEnabled());
130         TAG_LOGE(AceLogTag::ACE_INPUTTRACKING, "DispatchTouchEvent eventId:%{public}d aceView is null return.",
131             pointerEvent->GetId());
132         return;
133     }
134     auto instanceId = view->GetInstanceId();
135     LogPointInfo(pointerEvent, instanceId);
136     DispatchEventToPerf(pointerEvent);
137     int32_t pointerAction = pointerEvent->GetPointerAction();
138     auto container = Platform::AceContainer::GetContainer(instanceId);
139     if (!container) {
140         MMI::InputManager::GetInstance()->MarkProcessed(
141             pointerEvent->GetId(), pointerEvent->GetActionTime(), pointerEvent->IsMarkEnabled());
142         TAG_LOGE(AceLogTag::ACE_INPUTTRACKING, "DispatchTouchEvent eventId:%{public}d container is null return.",
143             pointerEvent->GetId());
144         return;
145     }
146     container->SetCurPointerEvent(pointerEvent);
147     if (pointerEvent->GetSourceType() == MMI::PointerEvent::SOURCE_TYPE_JOYSTICK) {
148         view->ProcessFocusAxisEvent(pointerEvent);
149         return;
150     }
151 
152     if (pointerEvent->GetSourceType() == MMI::PointerEvent::SOURCE_TYPE_MOUSE) {
153         // mouse event
154         if ((pointerAction >= MMI::PointerEvent::POINTER_ACTION_AXIS_BEGIN &&
155             pointerAction <= MMI::PointerEvent::POINTER_ACTION_AXIS_END) ||
156             (pointerAction >= MMI::PointerEvent::POINTER_ACTION_ROTATE_BEGIN &&
157             pointerAction <= MMI::PointerEvent::POINTER_ACTION_ROTATE_END) ||
158             (pointerAction == MMI::PointerEvent::POINTER_ACTION_CANCEL && IsAxisEvent(pointerEvent))) {
159             view->ProcessAxisEvent(pointerEvent, node, isInjected);
160         } else {
161             view->ProcessDragEvent(pointerEvent, node);
162             view->ProcessMouseEvent(pointerEvent, node, isInjected);
163         }
164     } else {
165         // touch event
166         view->ProcessDragEvent(pointerEvent, node);
167         view->ProcessTouchEvent(pointerEvent, node, callback, isInjected);
168     }
169 }
170 
DispatchEventToPerf(const std::shared_ptr<MMI::PointerEvent> & pointerEvent)171 void AceViewOhos::DispatchEventToPerf(const std::shared_ptr<MMI::PointerEvent>& pointerEvent)
172 {
173     CHECK_NULL_VOID(pointerEvent);
174     static bool isFirstMove = false;
175     PerfMonitor* pMonitor = PerfMonitor::GetPerfMonitor();
176     if (pMonitor == nullptr) {
177         return;
178     }
179     uint64_t inputTime = pointerEvent->GetSensorInputTime() * US_TO_MS;
180     if (inputTime <= 0) {
181         inputTime = pointerEvent->GetActionTime() * US_TO_MS;
182     }
183     if (inputTime <= 0) {
184         return;
185     }
186     PerfActionType inputType = UNKNOWN_ACTION;
187     PerfSourceType sourceType = UNKNOWN_SOURCE;
188     if (pointerEvent->GetSourceType() == MMI::PointerEvent::SOURCE_TYPE_MOUSE) {
189         sourceType = PERF_MOUSE_EVENT;
190     } else if (pointerEvent->GetSourceType() == MMI::PointerEvent::SOURCE_TYPE_TOUCHSCREEN) {
191         sourceType = PERF_TOUCH_EVENT;
192     } else if (pointerEvent->GetSourceType() == MMI::PointerEvent::SOURCE_TYPE_TOUCHPAD) {
193         sourceType = PERF_TOUCH_PAD;
194     } else if (pointerEvent->GetSourceType() == MMI::PointerEvent::SOURCE_TYPE_JOYSTICK) {
195         sourceType = PERF_JOY_STICK;
196     }
197     int32_t pointerAction = pointerEvent->GetPointerAction();
198     if (pointerAction == MMI::PointerEvent::POINTER_ACTION_DOWN
199         || pointerAction == MMI::PointerEvent::POINTER_ACTION_BUTTON_DOWN
200         || pointerAction == MMI::PointerEvent::POINTER_ACTION_AXIS_BEGIN
201         || pointerAction == MMI::PointerEvent::POINTER_ACTION_ROTATE_BEGIN) {
202         inputType = LAST_DOWN;
203         isFirstMove = true;
204     } else if (pointerAction == MMI::PointerEvent::POINTER_ACTION_UP
205         || pointerAction == MMI::PointerEvent::POINTER_ACTION_BUTTON_UP
206         || pointerAction == MMI::PointerEvent::POINTER_ACTION_AXIS_END
207         || pointerAction == MMI::PointerEvent::POINTER_ACTION_ROTATE_END) {
208         inputType = LAST_UP;
209         isFirstMove = false;
210     } else if (isFirstMove && (pointerAction == MMI::PointerEvent::POINTER_ACTION_MOVE
211         || pointerAction == MMI::PointerEvent::POINTER_ACTION_AXIS_UPDATE
212         || pointerAction == MMI::PointerEvent::POINTER_ACTION_ROTATE_UPDATE)) {
213         inputType = FIRST_MOVE;
214         isFirstMove = false;
215     }
216     pMonitor->RecordInputEvent(inputType, sourceType, inputTime);
217 }
218 
DispatchEventToPerf(const std::shared_ptr<MMI::KeyEvent> & keyEvent)219 void AceViewOhos::DispatchEventToPerf(const std::shared_ptr<MMI::KeyEvent>& keyEvent)
220 {
221     CHECK_NULL_VOID(keyEvent);
222     int32_t keyCode = keyEvent->GetKeyCode();
223     if (keyCode != MMI::KeyEvent::KEYCODE_VOLUME_DOWN
224         && keyCode != MMI::KeyEvent::KEYCODE_VOLUME_UP
225         && keyCode != MMI::KeyEvent::KEYCODE_POWER
226         && keyCode != MMI::KeyEvent::KEYCODE_META_LEFT
227         && keyCode != MMI::KeyEvent::KEYCODE_ESCAPE) {
228         return;
229     }
230     PerfMonitor* pMonitor = PerfMonitor::GetPerfMonitor();
231     if (pMonitor == nullptr) {
232         return;
233     }
234     PerfActionType inputType = UNKNOWN_ACTION;
235     int32_t action = keyEvent->GetKeyAction();
236     if (action == MMI::KeyEvent::KEY_ACTION_UP) {
237         inputType = LAST_UP;
238     } else if (action == MMI::KeyEvent::KEY_ACTION_DOWN) {
239         inputType = LAST_DOWN;
240     }
241     PerfSourceType sourceType = PERF_KEY_EVENT;
242     int64_t inputTime = (keyEvent->GetKeyItem())->GetDownTime() * US_TO_MS;
243     pMonitor->RecordInputEvent(inputType, sourceType, inputTime);
244 }
245 
DispatchKeyEvent(const RefPtr<AceViewOhos> & view,const std::shared_ptr<MMI::KeyEvent> & keyEvent,bool isPreIme)246 bool AceViewOhos::DispatchKeyEvent(const RefPtr<AceViewOhos>& view,
247     const std::shared_ptr<MMI::KeyEvent>& keyEvent, bool isPreIme)
248 {
249     CHECK_NULL_RETURN(view, false);
250     DispatchEventToPerf(keyEvent);
251     return view->ProcessKeyEvent(keyEvent, isPreIme);
252 }
253 
DispatchRotationEvent(const RefPtr<AceViewOhos> & view,float rotationValue)254 bool AceViewOhos::DispatchRotationEvent(const RefPtr<AceViewOhos>& view, float rotationValue)
255 {
256     CHECK_NULL_RETURN(view, false);
257     return view->ProcessRotationEvent(rotationValue);
258 }
259 
RegisterTouchEventCallback(TouchEventCallback && callback)260 void AceViewOhos::RegisterTouchEventCallback(TouchEventCallback&& callback)
261 {
262     ACE_DCHECK(callback);
263     touchEventCallback_ = std::move(callback);
264 }
265 
RegisterDragEventCallback(DragEventCallBack && callback)266 void AceViewOhos::RegisterDragEventCallback(DragEventCallBack&& callback)
267 {
268     ACE_DCHECK(callback);
269     dragEventCallback_ = std::move(callback);
270 }
271 
RegisterKeyEventCallback(KeyEventCallback && callback)272 void AceViewOhos::RegisterKeyEventCallback(KeyEventCallback&& callback)
273 {
274     ACE_DCHECK(callback);
275     keyEventCallback_ = std::move(callback);
276 }
277 
RegisterNonPointerEventCallback(NonPointerEventCallback && callback)278 void AceViewOhos::RegisterNonPointerEventCallback(NonPointerEventCallback&& callback)
279 {
280     ACE_DCHECK(callback);
281     nonPointerEventCallback_ = std::move(callback);
282 }
283 
RegisterMouseEventCallback(MouseEventCallback && callback)284 void AceViewOhos::RegisterMouseEventCallback(MouseEventCallback&& callback)
285 {
286     ACE_DCHECK(callback);
287     mouseEventCallback_ = std::move(callback);
288 }
289 
RegisterAxisEventCallback(AxisEventCallback && callback)290 void AceViewOhos::RegisterAxisEventCallback(AxisEventCallback&& callback)
291 {
292     ACE_DCHECK(callback);
293     axisEventCallback_ = std::move(callback);
294 }
295 
RegisterRotationEventCallback(RotationEventCallBack && callback)296 void AceViewOhos::RegisterRotationEventCallback(RotationEventCallBack&& callback)
297 {
298     ACE_DCHECK(callback);
299     rotationEventCallBack_ = std::move(callback);
300 }
301 
Launch()302 void AceViewOhos::Launch()
303 {
304 }
305 
ProcessTouchEvent(const std::shared_ptr<MMI::PointerEvent> & pointerEvent,const RefPtr<OHOS::Ace::NG::FrameNode> & node,const std::function<void ()> & callback,bool isInjected)306 void AceViewOhos::ProcessTouchEvent(const std::shared_ptr<MMI::PointerEvent>& pointerEvent,
307     const RefPtr<OHOS::Ace::NG::FrameNode>& node, const std::function<void()>& callback, bool isInjected)
308 {
309     if (!pointerEvent) {
310         TAG_LOGE(AceLogTag::ACE_INPUTTRACKING, "ProcessTouchEvent pointerEvent is null return.");
311         return;
312     }
313     TouchEvent touchPoint = ConvertTouchEvent(pointerEvent);
314     touchPoint.SetIsInjected(isInjected);
315     if (SystemProperties::GetDebugEnabled()) {
316         ACE_SCOPED_TRACE("ProcessTouchEvent pointX=%f pointY=%f type=%d timeStamp=%lld id=%d eventId=%d", touchPoint.x,
317             touchPoint.y, (int)touchPoint.type, touchPoint.time.time_since_epoch().count(), touchPoint.id,
318             touchPoint.touchEventId);
319     }
320     auto markProcess = [touchPoint, finallyCallback = callback, enabled = pointerEvent->IsMarkEnabled()]() {
321         MMI::InputManager::GetInstance()->MarkProcessed(touchPoint.touchEventId,
322             std::chrono::duration_cast<std::chrono::microseconds>(touchPoint.time.time_since_epoch()).count(),
323             enabled);
324         if (finallyCallback) {
325             finallyCallback();
326         }
327     };
328     if (touchPoint.type != TouchType::UNKNOWN) {
329         if (touchEventCallback_) {
330             touchEventCallback_(touchPoint, markProcess, node);
331         }
332     }
333 }
334 
ProcessDragEvent(const std::shared_ptr<MMI::PointerEvent> & pointerEvent,const RefPtr<OHOS::Ace::NG::FrameNode> & node)335 void AceViewOhos::ProcessDragEvent(const std::shared_ptr<MMI::PointerEvent>& pointerEvent,
336     const RefPtr<OHOS::Ace::NG::FrameNode>& node)
337 {
338     DragEventAction action;
339     DragPointerEvent event;
340     ConvertPointerEvent(pointerEvent, event);
341     CHECK_NULL_VOID(dragEventCallback_);
342     int32_t orgAction = pointerEvent->GetPointerAction();
343     switch (orgAction) {
344         case OHOS::MMI::PointerEvent::POINTER_ACTION_PULL_MOVE: {
345             action = DragEventAction::DRAG_EVENT_MOVE;
346             dragEventCallback_(event, action, node);
347             break;
348         }
349         case OHOS::MMI::PointerEvent::POINTER_ACTION_PULL_UP: {
350             action = DragEventAction::DRAG_EVENT_END;
351             dragEventCallback_(event, action, node);
352             break;
353         }
354         case OHOS::MMI::PointerEvent::POINTER_ACTION_PULL_IN_WINDOW: {
355             action = DragEventAction::DRAG_EVENT_START;
356             dragEventCallback_(event, action, node);
357             break;
358         }
359         case OHOS::MMI::PointerEvent::POINTER_ACTION_PULL_OUT_WINDOW: {
360             action = DragEventAction::DRAG_EVENT_OUT;
361             dragEventCallback_(event, action, node);
362             break;
363         }
364         default:
365             break;
366     }
367 }
368 
ProcessDragEvent(int32_t x,int32_t y,const DragEventAction & action,const RefPtr<OHOS::Ace::NG::FrameNode> & node)369 void AceViewOhos::ProcessDragEvent(int32_t x, int32_t y, const DragEventAction& action,
370     const RefPtr<OHOS::Ace::NG::FrameNode>& node)
371 {
372     CHECK_NULL_VOID(dragEventCallback_);
373     dragEventCallback_(DragPointerEvent(x, y), action, node);
374 }
375 
ProcessMouseEvent(const std::shared_ptr<MMI::PointerEvent> & pointerEvent,const RefPtr<OHOS::Ace::NG::FrameNode> & node,bool isInjected)376 void AceViewOhos::ProcessMouseEvent(const std::shared_ptr<MMI::PointerEvent>& pointerEvent,
377     const RefPtr<OHOS::Ace::NG::FrameNode>& node, bool isInjected)
378 {
379     MouseEvent event;
380     bool markEnabled = true;
381     if (pointerEvent) {
382         auto container = Platform::AceContainer::GetContainer(instanceId_);
383         CHECK_NULL_VOID(container);
384         ConvertMouseEvent(pointerEvent, event, container->IsScenceBoardWindow());
385         markEnabled = pointerEvent->IsMarkEnabled();
386     }
387     event.isInjected = isInjected;
388     if (SystemProperties::GetDebugEnabled()) {
389         ACE_SCOPED_TRACE("ProcessMouseEvent pointX=%f pointY=%f type=%d timeStamp=%lld id=%d eventId=%d", event.x,
390             event.y, (int)event.action, event.time.time_since_epoch().count(), event.id, event.touchEventId);
391     }
392     auto markProcess = [event, markEnabled]() {
393         MMI::InputManager::GetInstance()->MarkProcessed(event.touchEventId,
394             std::chrono::duration_cast<std::chrono::microseconds>(event.time.time_since_epoch()).count(),
395             markEnabled);
396     };
397 
398     CHECK_NULL_VOID(mouseEventCallback_);
399     mouseEventCallback_(event, markProcess, node);
400 }
401 
ProcessAxisEvent(const std::shared_ptr<MMI::PointerEvent> & pointerEvent,const RefPtr<OHOS::Ace::NG::FrameNode> & node,bool isInjected)402 void AceViewOhos::ProcessAxisEvent(const std::shared_ptr<MMI::PointerEvent>& pointerEvent,
403     const RefPtr<OHOS::Ace::NG::FrameNode>& node, bool isInjected)
404 {
405     CHECK_NULL_VOID(axisEventCallback_);
406     AxisEvent event;
407     event.isInjected = isInjected;
408     if (!pointerEvent) {
409         axisEventCallback_(event, nullptr, node);
410         return;
411     }
412 
413     ConvertAxisEvent(pointerEvent, event);
414     auto markProcess = [event, enabled = pointerEvent->IsMarkEnabled()]() {
415         MMI::InputManager::GetInstance()->MarkProcessed(event.touchEventId,
416             std::chrono::duration_cast<std::chrono::microseconds>(event.time.time_since_epoch()).count(),
417             enabled);
418     };
419 
420     /* The first step of axis event of mouse is equivalent to touch event START + UPDATE.
421      * Create a fake UPDATE event here to adapt to axis event of mouse.
422      * e.g {START, END} turns into {START, UPDATE, END}.
423      */
424     if (IsMMIMouseScrollBegin(event)) {
425         auto fakeAxisStart = std::make_shared<MMI::PointerEvent>(*pointerEvent);
426         fakeAxisStart->SetAxisValue(MMI::PointerEvent::AxisType::AXIS_TYPE_SCROLL_VERTICAL, 0.0);
427         fakeAxisStart->SetAxisValue(MMI::PointerEvent::AxisType::AXIS_TYPE_SCROLL_HORIZONTAL, 0.0);
428         ConvertAxisEvent(fakeAxisStart, event);
429         axisEventCallback_(event, nullptr, node);
430 
431         auto fakeAxisUpdate = std::make_shared<MMI::PointerEvent>(*pointerEvent);
432         fakeAxisUpdate->SetPointerAction(MMI::PointerEvent::POINTER_ACTION_AXIS_UPDATE);
433         ConvertAxisEvent(fakeAxisUpdate, event);
434     }
435     axisEventCallback_(event, markProcess, node);
436 }
437 
ProcessKeyEvent(const std::shared_ptr<MMI::KeyEvent> & keyEvent,bool isPreIme)438 bool AceViewOhos::ProcessKeyEvent(const std::shared_ptr<MMI::KeyEvent>& keyEvent, bool isPreIme)
439 {
440     CHECK_NULL_RETURN(nonPointerEventCallback_, false);
441     KeyEvent event;
442     ConvertKeyEvent(keyEvent, event);
443     event.isPreIme = isPreIme;
444     return nonPointerEventCallback_(event, nullptr);
445 }
446 
ProcessFocusAxisEvent(const std::shared_ptr<MMI::PointerEvent> & pointerEvent)447 bool AceViewOhos::ProcessFocusAxisEvent(const std::shared_ptr<MMI::PointerEvent>& pointerEvent)
448 {
449     CHECK_NULL_RETURN(nonPointerEventCallback_, false);
450     NG::FocusAxisEvent event;
451     ConvertFocusAxisEvent(pointerEvent, event);
452     auto markProcess = [event, enabled = pointerEvent->IsMarkEnabled()]() {
453         MMI::InputManager::GetInstance()->MarkProcessed(event.touchEventId,
454             std::chrono::duration_cast<std::chrono::microseconds>(event.time.time_since_epoch()).count(),
455             enabled);
456     };
457     return nonPointerEventCallback_(event, std::move(markProcess));
458 }
459 
GetNativeWindowById(uint64_t textureId)460 const void* AceViewOhos::GetNativeWindowById(uint64_t textureId)
461 {
462     return nullptr;
463 }
464 
ProcessRotationEvent(float rotationValue)465 bool AceViewOhos::ProcessRotationEvent(float rotationValue)
466 {
467     CHECK_NULL_RETURN(rotationEventCallBack_, false);
468     RotationEvent event { .value = rotationValue * ROTATION_DIVISOR };
469     return rotationEventCallBack_(event);
470 }
471 
Dump(const std::vector<std::string> & params)472 bool AceViewOhos::Dump(const std::vector<std::string>& params)
473 {
474     if (params.empty() || params[0] != "-drawcmd") {
475         return false;
476     }
477     if (DumpLog::GetInstance().GetDumpFile()) {
478         DumpLog::GetInstance().AddDesc("Dump draw command not support on this version.");
479         DumpLog::GetInstance().Print(0, "Info:", 0);
480         return true;
481     }
482     return false;
483 }
484 
GetBackgroundColor()485 uint32_t AceViewOhos::GetBackgroundColor()
486 {
487     return Color::WHITE.GetValue();
488 }
489 
490 } // namespace OHOS::Ace::Platform
491