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 50 void RegisterVisibleChangeCallback(int32_t nodeId, std::function<void(bool)> callback); 51 void UnRegisterVisibleChangeCallback(int32_t nodeId); 52 void HandleVisibleChangeCallback(bool visible); 53 CreateOverlayManager(bool isShow,const RefPtr<FrameNode> & target)54 void CreateOverlayManager(bool isShow, const RefPtr<FrameNode>& target) 55 { 56 if (!overlayManager_ && isShow) { 57 overlayManager_ = MakeRefPtr<OverlayManager>(target); 58 overlayManager_->SetIsAttachToCustomNode(true); 59 } 60 } 61 GetOverlayManager()62 const RefPtr<OverlayManager>& GetOverlayManager() 63 { 64 return overlayManager_; 65 } 66 DeleteOverlayManager()67 void DeleteOverlayManager() 68 { 69 overlayManager_.Reset(); 70 } 71 uint32_t GetWindowPatternType() const override; 72 73 protected: 74 void OnAttachToFrameNode() override; 75 void OnDetachFromFrameNode(FrameNode* frameNode) override; 76 std::function<void(const Rosen::Vector4f&)> boundsChangedCallback_; 77 sptr<Rosen::Session> session_; 78 79 private: 80 void OnAttachToMainTree() override; 81 void OnDetachFromMainTree() override; 82 83 void OnBoundsChanged(const Rosen::Vector4f& bounds); 84 void RegisterFocusCallback(); 85 void RegisterEventCallback(); 86 void RegisterResponseRegionCallback(); 87 void PostCheckContextTransparentTask(); 88 void PostFaultInjectTask(); 89 90 int32_t instanceId_ = Container::CurrentId(); 91 92 CancelableCallback<void()> checkContextTransparentTask_; 93 RefPtr<OverlayManager> overlayManager_; 94 std::map<int32_t, std::function<void(bool)>> visibleChangeCallbackMap_; 95 96 ACE_DISALLOW_COPY_AND_MOVE(SystemWindowScene); 97 }; 98 } // namespace OHOS::Ace::NG 99 100 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERN_SYSTEM_WINDOW_SCENE_H 101