1 /* 2 * Copyright (c) 2023-2024 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 OHOS_ROSEN_WINDOW_H 17 #define OHOS_ROSEN_WINDOW_H 18 19 #include <refbase.h> 20 #include <iremote_object.h> 21 #include "window_option.h" 22 23 namespace OHOS::MMI { 24 class PointerEvent; 25 class KeyEvent; 26 class AxisEvent; 27 } 28 29 namespace OHOS::Ace { 30 class UIContent; 31 class ViewportConfig; 32 } 33 34 namespace OHOS::AbilityRuntime { 35 class AbilityContext; 36 class Context; 37 } 38 39 namespace OHOS { 40 namespace Rosen { 41 using ContentInfoCallback = std::function<void(std::string contentInfo)>; 42 using SendRenderDataCallback = bool (*)(const void*, const size_t, const int32_t, const int32_t, const uint64_t); 43 44 class IIgnoreViewSafeAreaListener : virtual public RefBase { 45 public: SetIgnoreViewSafeArea(bool ignoreViewSafeArea)46 void SetIgnoreViewSafeArea(bool ignoreViewSafeArea) {} 47 }; 48 49 class IAvoidAreaChangedListener : virtual public RefBase { 50 public: OnAvoidAreaChanged(const AvoidArea avoidArea,AvoidAreaType type)51 void OnAvoidAreaChanged(const AvoidArea avoidArea, AvoidAreaType type) {} 52 }; 53 54 class IWindowSystemBarEnableListener : virtual public RefBase { 55 public: OnSetSpecificBarProperty(WindowType type,const SystemBarProperty & property)56 WMError OnSetSpecificBarProperty(WindowType type, const SystemBarProperty& property) 57 { 58 return WMError::WM_OK; 59 } 60 }; 61 62 static WMError DefaultCreateErrCode = WMError::WM_OK; 63 class Window : public RefBase { 64 public: 65 static sptr<Window> Create(const std::string& windowName, 66 sptr<WindowOption>& option, const std::shared_ptr<AbilityRuntime::Context>& context = nullptr, 67 WMError& errCode = DefaultCreateErrCode); 68 69 virtual WMError RegisterSystemBarEnableListener(const sptr<IWindowSystemBarEnableListener>& listener) = 0; 70 virtual WMError UnRegisterSystemBarEnableListener(const sptr<IWindowSystemBarEnableListener>& listener) = 0; 71 virtual void SetContentInfoCallback(const ContentInfoCallback& callback) = 0; 72 virtual void CreateSurfaceNode(const std::string name, const SendRenderDataCallback& callback) = 0; 73 virtual void SetViewportConfig(const Ace::ViewportConfig& config) = 0; 74 virtual void ConsumeKeyEvent(const std::shared_ptr<MMI::KeyEvent>& inputEvent) = 0; 75 virtual void ConsumePointerEvent(const std::shared_ptr<MMI::PointerEvent>& inputEvent) = 0; 76 virtual void UpdateAvoidArea(const sptr<AvoidArea>& avoidArea, AvoidAreaType type) = 0; 77 virtual SystemBarProperty GetSystemBarPropertyByType(WindowType type) const = 0; 78 }; 79 } 80 } 81 #endif // OHOS_ROSEN_WINDOW_H 82