1 /* 2 * Copyright (C) 2025-2025 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 MAGNIFICATION_WINDOW_PROXY_H 17 #define MAGNIFICATION_WINDOW_PROXY_H 18 19 #include "hilog_wrapper.h" 20 #include "magnification_def.h" 21 22 namespace OHOS { 23 namespace Accessibility { 24 #define CHECK_PROXY_PTR_VOID() \ 25 if (windowProxy_ == nullptr) { \ 26 HILOG_ERROR("windowProxy_ is nullptr."); \ 27 return; \ 28 } 29 30 class MagnificationWindowProxy { 31 public: 32 MagnificationWindowProxy(); 33 ~MagnificationWindowProxy(); 34 static std::shared_ptr<MagnificationWindowProxy> GetInstance(); 35 36 // common 37 void EnableMagnification(uint32_t magnificationType, int32_t centerX, int32_t centerY); 38 void DisableMagnification(uint32_t magnificationType, bool needClear = false); 39 void SetScale(uint32_t magnificationType, float scaleSpan); 40 void MoveMagnification(uint32_t magnificationType, int32_t deltaX, int32_t deltaY); 41 PointerPos GetSourceCenter(); 42 void FollowFocuseElement(uint32_t magnificationType, int32_t centerX, int32_t centerY); 43 float GetScale(); 44 bool IsMagnificationWindowShow(uint32_t magnificationType); 45 void ShowMagnification(uint32_t magnificationType); 46 void RefreshWindowParam(uint32_t magnificationType, RotationType type); 47 PointerPos ConvertCoordinates(int32_t posX, int32_t posY); 48 void InitMagnificationParam(float scale); 49 50 // full magnification 51 PointerPos ConvertGesture(uint32_t type, PointerPos coordinates); 52 uint32_t CheckTapOnHotArea(int32_t posX, int32_t posY); 53 54 // window magnification 55 bool IsTapOnHotArea(int32_t posX, int32_t posY); 56 bool IsTapOnMagnificationWindow(int32_t posX, int32_t posY); 57 void FixSourceCenter(bool needFix); 58 59 // menu 60 void ShowMenuWindow(uint32_t mode); 61 void DisableMenuWindow(); 62 bool IsTapOnMenu(int32_t posX, int32_t posY); 63 void MoveMenuWindow(int32_t deltaX, int32_t deltaY); 64 void SetCurrentType(uint32_t type); 65 void AttachToEdge(); 66 void RefreshWindowParamMenu(); 67 uint32_t ChangeMode(); 68 bool IsMenuShown(); 69 70 // notification helper 71 int32_t PublishIgnoreRepeatClickReminder(); 72 void CancelNotification(); 73 int32_t RegisterTimers(uint64_t beginTime); 74 void DestoryTimers(); 75 int64_t GetWallTimeMs(); 76 77 private: 78 void* GetFunc(const std::string& funcName); 79 void* handle_ = nullptr; 80 }; 81 } // namespace Accessibility 82 } // namespace OHOS 83 #endif // MAGNIFICATION_WINDOW_PROXY_H