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 23namespace OHOS::MMI { 24class PointerEvent; 25class KeyEvent; 26class AxisEvent; 27} 28 29namespace OHOS::Ace { 30class UIContent; 31class ViewportConfig; 32} 33 34namespace OHOS::AbilityRuntime { 35class AbilityContext; 36class Context; 37} 38 39namespace OHOS { 40namespace Rosen { 41using ContentInfoCallback = std::function<void(std::string contentInfo)>; 42using SendRenderDataCallback = bool (*)(const void*, const size_t, const int32_t, const int32_t, const uint64_t); 43 44class IIgnoreViewSafeAreaListener : virtual public RefBase { 45public: 46 void SetIgnoreViewSafeArea(bool ignoreViewSafeArea) {} 47}; 48 49class IAvoidAreaChangedListener : virtual public RefBase { 50public: 51 void OnAvoidAreaChanged(const AvoidArea avoidArea, AvoidAreaType type) {} 52}; 53 54class IWindowSystemBarEnableListener : virtual public RefBase { 55public: 56 WMError OnSetSpecificBarProperty(WindowType type, const SystemBarProperty& property) 57 { 58 return WMError::WM_OK; 59 } 60}; 61 62static WMError DefaultCreateErrCode = WMError::WM_OK; 63class Window : public RefBase { 64public: 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