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 FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERN_SYSTEM_WINDOW_SCENE_H 17 #define FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERN_SYSTEM_WINDOW_SCENE_H 18 19 #include "common/rs_vector4.h" 20 #include "session/host/include/session.h" 21 22 #include "core/common/container.h" 23 #include "core/components_ng/manager/focus/focus_view.h" 24 #include "core/components_ng/pattern/stack/stack_pattern.h" 25 26 namespace OHOS::Ace::NG { 27 class SystemWindowScene : public StackPattern, public FocusView { 28 DECLARE_ACE_TYPE(SystemWindowScene, StackPattern, FocusView); 29 30 public: 31 explicit SystemWindowScene(const sptr<Rosen::Session>& session); 32 ~SystemWindowScene() override = default; 33 GetContextParam()34 std::optional<RenderContext::ContextParam> GetContextParam() const override 35 { 36 return RenderContext::ContextParam { RenderContext::ContextType::EXTERNAL }; 37 } 38 39 sptr<Rosen::Session> GetSession(); 40 41 void OnVisibleChange(bool visible) override; 42 GetRouteOfFirstScope()43 std::list<int32_t> GetRouteOfFirstScope() override 44 { 45 return { 0 }; 46 } 47 48 void LostViewFocus() override; 49 CreateOverlayManager(bool isShow,const RefPtr<FrameNode> & target)50 void CreateOverlayManager(bool isShow, const RefPtr<FrameNode>& target) 51 { 52 if (!overlayManager_ && isShow) { 53 overlayManager_ = MakeRefPtr<OverlayManager>(target); 54 overlayManager_->SetIsAttachToCustomNode(true); 55 } 56 } 57 GetOverlayManager()58 const RefPtr<OverlayManager>& GetOverlayManager() 59 { 60 return overlayManager_; 61 } 62 DeleteOverlayManager()63 void DeleteOverlayManager() 64 { 65 overlayManager_.Reset(); 66 } 67 uint32_t GetWindowPatternType() const override; 68 69 protected: 70 void OnAttachToFrameNode() override; 71 void OnDetachFromFrameNode(FrameNode* frameNode) override; 72 std::function<void(const Rosen::Vector4f&)> boundsChangedCallback_; 73 sptr<Rosen::Session> session_; 74 75 private: 76 void OnAttachToMainTree() override; 77 void OnDetachFromMainTree() override; 78 79 void OnBoundsChanged(const Rosen::Vector4f& bounds); 80 void RegisterFocusCallback(); 81 void RegisterEventCallback(); 82 void RegisterResponseRegionCallback(); 83 void PostCheckContextTransparentTask(); 84 void PostFaultInjectTask(); 85 86 int32_t instanceId_ = Container::CurrentId(); 87 88 CancelableCallback<void()> checkContextTransparentTask_; 89 RefPtr<OverlayManager> overlayManager_; 90 91 ACE_DISALLOW_COPY_AND_MOVE(SystemWindowScene); 92 }; 93 } // namespace OHOS::Ace::NG 94 95 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERN_SYSTEM_WINDOW_SCENE_H 96