1 /* 2 * Copyright (C) 2022 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 ACCESSIBILITY_MOUSE_AUTOCLICK_H 17 #define ACCESSIBILITY_MOUSE_AUTOCLICK_H 18 19 #include "accessibility_event_transmission.h" 20 #include "event_handler.h" 21 22 namespace OHOS { 23 namespace Accessibility { 24 class AccessibilityMouseAutoclick : public EventTransmission { 25 public: 26 /** 27 * @brief A constructor used to create a AccessibilityMouseAutoclick instance. 28 */ 29 AccessibilityMouseAutoclick(); 30 31 /** 32 * @brief A destructor used to delete the AccessibilityMouseAutoclick instance. 33 */ 34 virtual ~AccessibilityMouseAutoclick(); 35 36 /** 37 * @brief Handle mouse events from previous event stream node. 38 * @param event the pointer event from Multimodal 39 * @return true: the event has been processed and does not need to be passed to the next node; 40 * false: the event is not processed. 41 */ 42 bool OnPointerEvent(MMI::PointerEvent &event) override; 43 44 void SendMouseClickEvent(); 45 void ResetAutoclickInfo(); 46 47 /** 48 * @brief Destroy the events. 49 */ 50 void DestroyEvents() override; 51 52 private: 53 class MouseAutoclickEventHandler : public AppExecFwk::EventHandler { 54 public: 55 /** 56 * @brief A constructor used to create a MouseAutoclickEventHandler instance. 57 */ 58 MouseAutoclickEventHandler(const std::shared_ptr<AppExecFwk::EventRunner> &runner, 59 AccessibilityMouseAutoclick &mouseAutoclick); 60 virtual ~MouseAutoclickEventHandler() = default; 61 62 /** 63 * @brief Process the event of install system bundles. 64 * @param event Indicates the event to be processed. 65 */ 66 virtual void ProcessEvent(const AppExecFwk::InnerEvent::Pointer &event) override; 67 68 private: 69 AccessibilityMouseAutoclick &mouseAutoclick_; 70 }; 71 72 void CancelAutoclick(); 73 void RecognizeAutoclick(MMI::PointerEvent &event); 74 bool IsMouseMovement(MMI::PointerEvent &event); 75 int64_t GetSystemTime(); 76 int64_t GetDelayTime(); 77 78 std::shared_ptr<MouseAutoclickEventHandler> timeoutHandler_ = nullptr; 79 std::shared_ptr<MMI::PointerEvent> lastMouseEvent_ = nullptr; 80 }; 81 } // namespace Accessibility 82 } // namespace OHOS 83 #endif // ACCESSIBILITY_MOUSE_AUTOCLICK_H