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 TOUCH_DRAWING_MANAGER_H 17 #define TOUCH_DRAWING_MANAGER_H 18 19 #include "singleton.h" 20 21 #include "i_touch_drawing_handler.h" 22 #include "component_manager.h" 23 #include "pointer_event.h" 24 #include "old_display_info.h" 25 26 namespace OHOS { 27 namespace MMI { 28 class DelegateInterface; 29 class TouchDrawingManager { 30 struct DevMode { 31 std::string SwitchName; 32 bool isShow { false }; 33 }; 34 35 DECLARE_DELAYED_SINGLETON(TouchDrawingManager); 36 37 public: 38 DISALLOW_COPY_AND_MOVE(TouchDrawingManager); 39 void Initialize(); 40 void TouchDrawHandler(std::shared_ptr<PointerEvent> pointerEvent); 41 void UpdateDisplayInfo(const OLD::DisplayInfo& displayInfo); 42 void GetOriginalTouchScreenCoordinates(Direction direction, int32_t width, int32_t height, 43 int32_t &physicalX, int32_t &physicalY); 44 void RotationScreen(); 45 void Dump(int32_t fd, const std::vector<std::string> &args); 46 bool IsWindowRotation() const; 47 void SetDelegateProxy(std::shared_ptr<DelegateInterface> proxy); 48 void SetMultiWindowScreenId(uint64_t screenId, uint64_t displayNodeScreenId); 49 void ResetTouchWindow(); 50 51 private: 52 void SetupSettingObserver(); 53 void CreateObserver(); 54 int32_t UpdateLabels(); 55 void RemoveUpdateLabelsTimer(); 56 void AddUpdateLabelsTimer(); 57 int32_t UpdateBubbleData(); 58 template <class T> 59 void CreateBubbleObserver(T& item); 60 template <class T> 61 void CreatePointerObserver(T& item); 62 ITouchDrawingHandler* LoadTouchDrawingHandler(); 63 ITouchDrawingHandler* GetTouchDrawingHandler() const; 64 void UnloadTouchDrawingHandler(); 65 66 private: 67 OLD::DisplayInfo displayInfo_ {}; 68 DevMode bubbleMode_; 69 DevMode pointerMode_; 70 bool hasBubbleObserver_{ false }; 71 bool hasPointerObserver_{ false }; 72 uint64_t windowScreenId_ { 0 }; 73 uint64_t displayNodeScreenId_ { 0 }; 74 std::shared_ptr<DelegateInterface> delegateProxy_ { nullptr }; 75 std::unique_ptr<ITouchDrawingHandler, ComponentManager::Component<ITouchDrawingHandler>> touchDrawingHandler_ { 76 nullptr, ComponentManager::Component<ITouchDrawingHandler>(nullptr, nullptr) }; 77 int32_t timerId_ { -1 }; 78 }; 79 80 #define TOUCH_DRAWING_MGR ::OHOS::DelayedSingleton<TouchDrawingManager>::GetInstance() 81 } // namespace MMI 82 } // namespace OHOS 83 #endif // TOUCH_DRAWING_MANAGER_H 84