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 OHOS_ROSEN_INNER_WINDOW_H 17 #define OHOS_ROSEN_INNER_WINDOW_H 18 19 #include "window.h" 20 #include "wm_common_inner.h" 21 #include "wm_single_instance.h" 22 23 namespace OHOS { 24 namespace Rosen { 25 class IInnerWindow : virtual public RefBase { 26 public: 27 virtual void Create(std::string name, DisplayId displyId, Rect rect, WindowMode mode) = 0; 28 virtual void Update(uint32_t width, uint32_t height) = 0; 29 virtual void Destroy() = 0; 30 }; 31 32 class PlaceholderWindowListener : public IWindowLifeCycle, public ITouchOutsideListener { 33 public: 34 // touch outside listener 35 virtual void OnTouchOutside() const; 36 // lifecycle listener 37 virtual void AfterUnfocused(); 38 // lifecycle do nothing AfterForeground()39 virtual void AfterForeground() {}; AfterBackground()40 virtual void AfterBackground() {}; AfterFocused()41 virtual void AfterFocused() {}; AfterInactive()42 virtual void AfterInactive() {}; 43 }; 44 45 class PlaceholderInputEventConsumer : public IInputEventConsumer { 46 public: 47 ~PlaceholderInputEventConsumer() override = default; 48 virtual bool OnInputEvent(const std::shared_ptr<MMI::KeyEvent>& keyEvent) const override; 49 virtual bool OnInputEvent(const std::shared_ptr<MMI::PointerEvent>& pointerEvent) const override; 50 virtual bool OnInputEvent(const std::shared_ptr<MMI::AxisEvent>& axisEvent) const override; 51 }; 52 53 class PlaceHolderWindow : public IInnerWindow { 54 WM_DECLARE_SINGLE_INSTANCE(PlaceHolderWindow); 55 public: 56 virtual void Create(std::string name, DisplayId displyId, Rect rect, WindowMode mode); Update(uint32_t width,uint32_t height)57 virtual void Update(uint32_t width, uint32_t height) {}; 58 virtual void Destroy(); 59 60 private: 61 void RegisterWindowListener(); 62 void UnRegisterWindowListener(); 63 void SetInputEventConsumer(); 64 65 private: 66 sptr<OHOS::Rosen::Window> window_; 67 sptr<PlaceholderWindowListener> windowListener_; 68 std::shared_ptr<IInputEventConsumer> inputEventConsumer_; 69 }; 70 } // namespace Rosen 71 } // namespace OHOS 72 #endif // OHOS_ROSEN_INNER_WINDOW_H