• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 OHOS_ROSEN_WINDOW_SESSION_IMPL_H
17 #define OHOS_ROSEN_WINDOW_SESSION_IMPL_H
18 
19 #include <atomic>
20 #include <optional>
21 #include <shared_mutex>
22 #include <ability_context.h>
23 #include <event_handler.h>
24 #include <i_input_event_consumer.h>
25 #include <refbase.h>
26 #include <ui_content.h>
27 #include <ui/rs_surface_node.h>
28 #include "display_manager.h"
29 #include "singleton_container.h"
30 
31 #include "common/include/window_session_property.h"
32 #include "display_info.h"
33 #include "future_callback.h"
34 #include "interfaces/include/ws_common.h"
35 #include "interfaces/include/ws_common_inner.h"
36 #include "session/container/include/zidl/session_stage_stub.h"
37 #include "session/host/include/zidl/session_interface.h"
38 #include "vsync_station.h"
39 #include "window.h"
40 #include "window_option.h"
41 #include "wm_common.h"
42 
43 namespace OHOS {
44 namespace Rosen {
45 namespace {
46 template<typename T1, typename T2, typename Ret>
47 using EnableIfSame = typename std::enable_if<std::is_same_v<T1, T2>, Ret>::type;
48 
49 /*
50  * DFX
51  */
52 const std::string SET_UICONTENT_TIMEOUT_LISTENER_TASK_NAME = "SetUIContentTimeoutListener";
53 constexpr int64_t SET_UICONTENT_TIMEOUT_TIME_MS = 4000;
54 }
55 
56 struct WindowTitleVisibleFlags {
57     bool isMaximizeVisible = true;
58     bool isMinimizeVisible = true;
59     bool isSplitVisible = true;
60 };
61 
62 class WindowSessionImpl : public Window, public virtual SessionStageStub {
63 public:
64     explicit WindowSessionImpl(const sptr<WindowOption>& option);
65     ~WindowSessionImpl();
66     void ConsumePointerEvent(const std::shared_ptr<MMI::PointerEvent>& pointerEvent) override;
67     void ConsumeKeyEvent(std::shared_ptr<MMI::KeyEvent>& inputEvent) override;
68     bool PreNotifyKeyEvent(const std::shared_ptr<MMI::KeyEvent>& keyEvent) override;
69     virtual bool NotifyOnKeyPreImeEvent(const std::shared_ptr<MMI::KeyEvent>& keyEvent) override;
70     static sptr<Window> Find(const std::string& name);
71     static std::vector<sptr<Window>> GetSubWindow(int parentId);
72     // inherits from window
73     virtual WMError Create(const std::shared_ptr<AbilityRuntime::Context>& context,
74         const sptr<Rosen::ISession>& iSession, const std::string& identityToken = "");
75     WMError Show(uint32_t reason = 0, bool withAnimation = false, bool withFocus = true) override;
76     WMError Hide(uint32_t reason = 0, bool withAnimation = false, bool isFromInnerkits = true) override;
77     WMError Destroy() override;
78     virtual WMError Destroy(bool needNotifyServer, bool needClearListener = true);
79     WMError NapiSetUIContent(const std::string& contentInfo, napi_env env,
80         napi_value storage, bool isdistributed, sptr<IRemoteObject> token, AppExecFwk::Ability* ability) override;
81     WMError SetUIContentByName(const std::string& contentInfo, napi_env env, napi_value storage,
82         AppExecFwk::Ability* ability) override;
83     WMError SetUIContentByAbc(const std::string& abcPath, napi_env env, napi_value storage,
84         AppExecFwk::Ability* ability) override;
85     std::shared_ptr<RSSurfaceNode> GetSurfaceNode() const override;
86     const std::shared_ptr<AbilityRuntime::Context> GetContext() const override;
87     Rect GetRequestRect() const override;
88     WindowType GetType() const override;
89     const std::string& GetWindowName() const override;
90     WindowState GetWindowState() const override;
91     WindowState GetRequestWindowState() const;
92     WMError SetFocusable(bool isFocusable) override;
93     WMError SetTouchable(bool isTouchable) override;
94     WMError SetTopmost(bool topmost) override;
95     bool IsTopmost() const override;
96     WMError SetResizeByDragEnabled(bool dragEnabled) override;
97     WMError SetRaiseByClickEnabled(bool raiseEnabled) override;
98     WMError HideNonSystemFloatingWindows(bool shouldHide) override;
99     WMError SetSingleFrameComposerEnabled(bool enable) override;
100     bool IsFloatingWindowAppType() const override;
101     bool IsPcOrPadCapabilityEnabled() const override;
102     WMError SetWindowType(WindowType type) override;
103     WMError SetBrightness(float brightness) override;
104     virtual float GetBrightness() const override;
105     void SetRequestedOrientation(Orientation orientation) override;
106     bool GetTouchable() const override;
107     uint32_t GetWindowId() const override;
108     uint64_t GetDisplayId() const override;
109     Rect GetRect() const override;
110     bool GetFocusable() const override;
111     std::string GetContentInfo() override;
112     Ace::UIContent* GetUIContent() const override;
113     std::shared_ptr<Ace::UIContent> GetUIContentSharedPtr() const;
114     Ace::UIContent* GetUIContentWithId(uint32_t winId) const override;
115     void OnNewWant(const AAFwk::Want& want) override;
116     WMError SetAPPWindowLabel(const std::string& label) override;
117     WMError SetAPPWindowIcon(const std::shared_ptr<Media::PixelMap>& icon) override;
118     void RequestVsync(const std::shared_ptr<VsyncCallback>& vsyncCallback) override;
119     int64_t GetVSyncPeriod() override;
120     void FlushFrameRate(uint32_t rate, int32_t animatorExpectedFrameRate, uint32_t rateType = 0) override;
121     // inherits from session stage
122     WSError SetActive(bool active) override;
123     WSError UpdateRect(const WSRect& rect, SizeChangeReason reason,
124         const SceneAnimationConfig& config = { nullptr, ROTATE_ANIMATION_DURATION }) override;
125     void UpdateDensity() override;
126     void SetUniqueVirtualPixelRatio(bool useUniqueDensity, float virtualPixelRatio) override;
127     WSError UpdateOrientation() override;
128     WSError UpdateDisplayId(uint64_t displayId) override;
129     WSError UpdateFocus(bool focus) override;
130     bool IsFocused() const override;
131     WMError RequestFocus() const override;
132     WMError RequestFocusByClient(bool isFocused) const override;
133     WSError UpdateWindowMode(WindowMode mode) override;
134     WSError HandleBackEvent() override;
135     WMError SetWindowGravity(WindowGravity gravity, uint32_t percent) override;
136     WMError SetSystemBarProperty(WindowType type, const SystemBarProperty& property) override;
137     KeyboardAnimationConfig GetKeyboardAnimationConfig() override;
138 
139     void NotifyPointerEvent(const std::shared_ptr<MMI::PointerEvent>& pointerEvent) override;
140     void NotifyKeyEvent(const std::shared_ptr<MMI::KeyEvent>& keyEvent, bool& isConsumed,
141         bool notifyInputMethod = true) override;
142     void NotifyOccupiedAreaChangeInfoInner(sptr<OccupiedAreaChangeInfo> info);
143     void NotifyOccupiedAreaChangeInfo(sptr<OccupiedAreaChangeInfo> info,
144                                       const std::shared_ptr<RSTransaction>& rsTransaction = nullptr) override;
145     void NotifyForegroundInteractiveStatus(bool interactive) override;
146     void NotifyDisplayMove(DisplayId from, DisplayId to) override;
147 
148     WMError RegisterLifeCycleListener(const sptr<IWindowLifeCycle>& listener) override;
149     WMError UnregisterLifeCycleListener(const sptr<IWindowLifeCycle>& listener) override;
150     WMError RegisterDisplayMoveListener(sptr<IDisplayMoveListener>& listener) override;
151     WMError UnregisterDisplayMoveListener(sptr<IDisplayMoveListener>& listener) override;
152     WMError RegisterWindowChangeListener(const sptr<IWindowChangeListener>& listener) override;
153     WMError UnregisterWindowChangeListener(const sptr<IWindowChangeListener>& listener) override;
154     WMError RegisterAvoidAreaChangeListener(sptr<IAvoidAreaChangedListener>& listener) override;
155     WMError UnregisterAvoidAreaChangeListener(sptr<IAvoidAreaChangedListener>& listener) override;
156     void RegisterDialogDeathRecipientListener(const sptr<IDialogDeathRecipientListener>& listener) override;
157     void UnregisterDialogDeathRecipientListener(const sptr<IDialogDeathRecipientListener>& listener) override;
158     WMError RegisterDialogTargetTouchListener(const sptr<IDialogTargetTouchListener>& listener) override;
159     WMError UnregisterDialogTargetTouchListener(const sptr<IDialogTargetTouchListener>& listener) override;
160     WMError RegisterOccupiedAreaChangeListener(const sptr<IOccupiedAreaChangeListener>& listener) override;
161     WMError UnregisterOccupiedAreaChangeListener(const sptr<IOccupiedAreaChangeListener>& listener) override;
162     WMError RegisterTouchOutsideListener(const sptr<ITouchOutsideListener>& listener) override;
163     WMError UnregisterTouchOutsideListener(const sptr<ITouchOutsideListener>& listener) override;
164     WMError RegisterWindowVisibilityChangeListener(const IWindowVisibilityListenerSptr& listener) override;
165     WMError UnregisterWindowVisibilityChangeListener(const IWindowVisibilityListenerSptr& listener) override;
166     WMError RegisterWindowNoInteractionListener(const IWindowNoInteractionListenerSptr& listener) override;
167     WMError UnregisterWindowNoInteractionListener(const IWindowNoInteractionListenerSptr& listener) override;
168     void RegisterWindowDestroyedListener(const NotifyNativeWinDestroyFunc& func) override;
UnregisterWindowDestroyedListener()169     void UnregisterWindowDestroyedListener() override { notifyNativeFunc_ = nullptr; }
170     WMError RegisterScreenshotListener(const sptr<IScreenshotListener>& listener) override;
171     WMError UnregisterScreenshotListener(const sptr<IScreenshotListener>& listener) override;
172     void SetAceAbilityHandler(const sptr<IAceAbilityHandler>& handler) override;
173     void SetInputEventConsumer(const std::shared_ptr<IInputEventConsumer>& inputEventConsumer) override;
174     WMError SetTitleButtonVisible(bool isMaximizeVisible, bool isMinimizeVisible, bool isSplitVisible) override;
175 
176     WMError SetBackgroundColor(const std::string& color) override;
177     virtual Orientation GetRequestedOrientation() override;
178 
179     int32_t GetParentId() const;
180     int32_t GetPersistentId() const override;
181     sptr<WindowSessionProperty> GetProperty() const;
182     SystemSessionConfig GetSystemSessionConfig() const;
183     sptr<ISession> GetHostSession() const;
184     int32_t GetFloatingWindowParentId();
185     void NotifyAfterForeground(bool needNotifyListeners = true, bool needNotifyUiContent = true);
186     void NotifyAfterBackground(bool needNotifyListeners = true, bool needNotifyUiContent = true);
187     void NotifyForegroundFailed(WMError ret);
188     void NotifyBackgroundFailed(WMError ret);
189     WSError MarkProcessed(int32_t eventId) override;
190     void UpdateTitleButtonVisibility();
191     WSError NotifyDestroy() override;
192     WSError NotifyTransferComponentData(const AAFwk::WantParams& wantParams) override;
193     WSErrorCode NotifyTransferComponentDataSync(const AAFwk::WantParams& wantParams,
194         AAFwk::WantParams& reWantParams) override;
195     void NotifyAvoidAreaChange(const sptr<AvoidArea>& avoidArea, AvoidAreaType type);
196     WSError UpdateAvoidArea(const sptr<AvoidArea>& avoidArea, AvoidAreaType type) override;
197     void NotifyTouchDialogTarget(int32_t posX = 0, int32_t posY = 0) override;
198     void NotifyScreenshot() override;
199     void DumpSessionElementInfo(const std::vector<std::string>& params) override;
200     // colorspace, gamut
201     virtual bool IsSupportWideGamut() override;
202     virtual void SetColorSpace(ColorSpace colorSpace) override;
203     virtual ColorSpace GetColorSpace() override;
204     WSError NotifyTouchOutside() override;
205     WMError SetLandscapeMultiWindow(bool isLandscapeMultiWindow) override;
206     WSError NotifyWindowVisibility(bool isVisible) override;
207     WSError NotifyNoInteractionTimeout(const IWindowNoInteractionListenerSptr& listener);
208     WMError TransferAccessibilityEvent(const Accessibility::AccessibilityEventInfo& info,
209         int64_t uiExtensionIdLevel) override;
210     WindowState state_ { WindowState::STATE_INITIAL };
211     WindowState requestState_ { WindowState::STATE_INITIAL };
212     WSError UpdateMaximizeMode(MaximizeMode mode) override;
213     void NotifySessionForeground(uint32_t reason, bool withAnimation) override;
214     void NotifySessionBackground(uint32_t reason, bool withAnimation, bool isFromInnerkits) override;
215     WSError UpdateTitleInTargetPos(bool isShow, int32_t height) override;
216     WSError NotifyDialogStateChange(bool isForeground) override;
217     bool IsMainHandlerAvailable() const override;
218 
219     /*
220      * PiP Window
221      */
222     WSError NotifyCloseExistPipWindow() override;
223     WSError SetPipActionEvent(const std::string& action, int32_t status) override;
224     WSError SetPiPControlEvent(WsPiPControlType controlType, WsPiPControlStatus status) override;
225     void UpdatePiPRect(const Rect& rect, WindowSizeChangeReason reason) override;
226     void UpdatePiPControlStatus(PiPControlType controlType, PiPControlStatus status) override;
227     void SetAutoStartPiP(bool isAutoStart, uint32_t priority) override;
228 
229     void SetDrawingContentState(bool drawingContentState);
230     WMError RegisterWindowStatusChangeListener(const sptr<IWindowStatusChangeListener>& listener) override;
231     WMError UnregisterWindowStatusChangeListener(const sptr<IWindowStatusChangeListener>& listener) override;
232     WMError SetSpecificBarProperty(WindowType type, const SystemBarProperty& property) override;
233     virtual WMError SetSubWindowModal(bool isModal) override;
234     virtual WMError SetDecorVisible(bool isVisible) override;
235     virtual WMError SetDecorHeight(int32_t decorHeight) override;
236     virtual WMError GetDecorHeight(int32_t& height) override;
237     virtual WMError GetTitleButtonArea(TitleButtonRect& titleButtonRect) override;
238     WSError GetUIContentRemoteObj(sptr<IRemoteObject>& uiContentRemoteObj) override;
239     virtual WMError RegisterWindowTitleButtonRectChangeListener(
240         const sptr<IWindowTitleButtonRectChangedListener>& listener) override;
241     virtual WMError UnregisterWindowTitleButtonRectChangeListener(
242         const sptr<IWindowTitleButtonRectChangedListener>& listener) override;
243     void NotifyWindowTitleButtonRectChange(TitleButtonRect titleButtonRect);
244     void RecoverSessionListener();
245     void SetDefaultDisplayIdIfNeed();
246     WMError RegisterWindowRectChangeListener(const sptr<IWindowRectChangeListener>& listener) override;
247     WMError UnregisterWindowRectChangeListener(const sptr<IWindowRectChangeListener>& listener) override;
248     WMError RegisterSubWindowCloseListeners(const sptr<ISubWindowCloseListener>& listener) override;
249     WMError UnregisterSubWindowCloseListeners(const sptr<ISubWindowCloseListener>& listener) override;
250     WMError RegisterSwitchFreeMultiWindowListener(const sptr<ISwitchFreeMultiWindowListener>& listener) override;
251     WMError UnregisterSwitchFreeMultiWindowListener(const sptr<ISwitchFreeMultiWindowListener>& listener) override;
252     virtual WMError GetCallingWindowWindowStatus(WindowStatus& windowStatus) const override;
253     virtual WMError GetCallingWindowRect(Rect& rect) const override;
254     virtual void SetUiDvsyncSwitch(bool dvsyncSwitch) override;
255     WMError SetContinueState(int32_t continueState) override;
256 
257     /*
258      * Window Layout
259      */
260     WSError SetEnableDragBySystem(bool enableDrag) override;
261 
262 protected:
263     WMError Connect();
264     bool IsWindowSessionInvalid() const;
265     void NotifyWindowAfterUnfocused();
266     void NotifyWindowAfterFocused();
267     void NotifyAfterActive();
268     void NotifyAfterInactive();
269     void NotifyBeforeDestroy(std::string windowName);
270     void NotifyAfterDestroy();
271     void ClearListenersById(int32_t persistentId);
272     void ClearSwitchFreeMultiWindowListenersById(int32_t persistentId);
273     void ClearVsyncStation();
274     WMError WindowSessionCreateCheck();
275     void UpdateDecorEnableToAce(bool isDecorEnable);
276     void UpdateDecorEnable(bool needNotify = false, WindowMode mode = WindowMode::WINDOW_MODE_UNDEFINED);
277     void NotifyModeChange(WindowMode mode, bool hasDeco = true);
278     WMError UpdateProperty(WSPropertyChangeAction action);
279     WMError SetBackgroundColor(uint32_t color);
280     uint32_t GetBackgroundColor() const;
281     virtual WMError SetLayoutFullScreenByApiVersion(bool status);
282     float GetVirtualPixelRatio() override;
283     virtual float GetVirtualPixelRatio(sptr<DisplayInfo> displayInfo);
284     void UpdateViewportConfig(const Rect& rect, WindowSizeChangeReason reason,
285         const std::shared_ptr<RSTransaction>& rsTransaction = nullptr,
286         const sptr<DisplayInfo>& info = nullptr,
287         const std::map<AvoidAreaType, AvoidArea>& avoidAreas = {});
288     void NotifySizeChange(Rect rect, WindowSizeChangeReason reason);
289     void NotifySubWindowClose(bool& terminateCloseProcess);
290     void NotifySwitchFreeMultiWindow(bool enable);
291     static sptr<Window> FindWindowById(uint32_t winId);
292     void NotifyWindowStatusChange(WindowMode mode);
293     void NotifyTransformChange(const Transform& transForm) override;
294     bool IsKeyboardEvent(const std::shared_ptr<MMI::KeyEvent>& keyEvent) const;
295     void DispatchKeyEventCallback(const std::shared_ptr<MMI::KeyEvent>& keyEvent, bool& isConsumed);
296     bool FilterKeyEvent(const std::shared_ptr<MMI::KeyEvent>& keyEvent);
297     void RegisterFrameLayoutCallback();
298     void CopyUniqueDensityParameter(sptr<WindowSessionImpl> parentWindow);
299     sptr<WindowSessionImpl> FindMainWindowWithContext();
300     sptr<WindowSessionImpl> FindExtensionWindowWithContext();
301 
302     WMError RegisterExtensionAvoidAreaChangeListener(sptr<IAvoidAreaChangedListener>& listener);
303     WMError UnregisterExtensionAvoidAreaChangeListener(sptr<IAvoidAreaChangedListener>& listener);
304 
305     void RefreshNoInteractionTimeoutMonitor();
306     WindowStatus GetWindowStatusInner(WindowMode mode);
307 
308     /**
309      * Sub Window
310      */
311     void UpdateSubWindowStateAndNotify(int32_t parentPersistentId, const WindowState newState);
312     void DestroySubWindow();
313 
314     sptr<ISession> hostSession_;
315     mutable std::mutex hostSessionMutex_;
316     std::shared_ptr<Ace::UIContent> uiContent_;
317     mutable std::shared_mutex uiContentMutex_;
318     std::shared_ptr<AbilityRuntime::Context> context_;
319     std::shared_ptr<RSSurfaceNode> surfaceNode_;
320 
321     sptr<WindowSessionProperty> property_;
322     SystemSessionConfig windowSystemConfig_;
323     NotifyNativeWinDestroyFunc notifyNativeFunc_;
324 
325     std::recursive_mutex mutex_;
326     static std::map<std::string, std::pair<int32_t, sptr<WindowSessionImpl>>> windowSessionMap_;
327     // protect windowSessionMap_
328     static std::shared_mutex windowSessionMutex_;
329     static std::set<sptr<WindowSessionImpl>> windowExtensionSessionSet_;
330     // protect windowExtensionSessionSet_
331     static std::shared_mutex windowExtensionSessionMutex_;
332     static std::map<int32_t, std::vector<sptr<WindowSessionImpl>>> subWindowSessionMap_;
333     bool isSystembarPropertiesSet_ = false;
334     bool isIgnoreSafeAreaNeedNotify_ = false;
335     bool isIgnoreSafeArea_ = false;
336     std::atomic_bool isFocused_ = false;
337     std::shared_ptr<AppExecFwk::EventHandler> handler_ = nullptr;
338     bool shouldReNotifyFocus_ = false;
339     std::shared_ptr<VsyncStation> vsyncStation_ = nullptr;
340     std::shared_ptr<IInputEventConsumer> inputEventConsumer_;
341     bool useUniqueDensity_ { false };
342     float virtualPixelRatio_ { 1.0f };
343     bool escKeyEventTriggered_ = false;
344     // Check whether the UIExtensionAbility process is started
345     static bool isUIExtensionAbilityProcess_;
346     virtual WMError SetKeyEventFilter(KeyEventFilterFunc filter) override;
347     virtual WMError ClearKeyEventFilter() override;
348     WSError SwitchFreeMultiWindow(bool enable) override;
349     std::string identityToken_ = { "" };
350     void MakeSubOrDialogWindowDragableAndMoveble();
IsFreeMultiWindowMode()351     bool IsFreeMultiWindowMode() const
352     {
353         return windowSystemConfig_.IsFreeMultiWindowMode();
354     }
355 
356     /*
357      * DFX
358      */
359     void SetUIContentComplete();
360     void AddSetUIContentTimeoutCheck();
361     void NotifySetUIContentComplete();
NotifyExtensionTimeout(int32_t errorCode)362     virtual void NotifyExtensionTimeout(int32_t errorCode) {}
363     std::atomic_bool setUIContentCompleted_ { false };
364     enum TimeoutErrorCode : int32_t {
365         SET_UICONTENT_TIMEOUT = 1000
366     };
367 
368     /*
369      * Window Lifecycle
370      */
371     bool hasFirstNotifyInteractive_ = false;
372     bool interactive_ = true;
373 
374     /*
375      * Window Layout
376      */
377     sptr<FutureCallback> layoutCallback_ = nullptr;
378     void UpdateVirtualPixelRatio(const sptr<Display>& display);
379 
380 private:
381     //Trans between colorGamut and colorSpace
382     static ColorSpace GetColorSpaceFromSurfaceGamut(GraphicColorGamut colorGamut);
383     static GraphicColorGamut GetSurfaceGamutFromColorSpace(ColorSpace colorSpace);
384 
385     template<typename T> WMError RegisterListener(std::vector<sptr<T>>& holder, const sptr<T>& listener);
386     template<typename T> WMError UnregisterListener(std::vector<sptr<T>>& holder, const sptr<T>& listener);
387     template<typename T> EnableIfSame<T, IWindowLifeCycle, std::vector<sptr<IWindowLifeCycle>>> GetListeners();
388     template<typename T> EnableIfSame<T, IDisplayMoveListener, std::vector<sptr<IDisplayMoveListener>>> GetListeners();
389     template<typename T>
390     EnableIfSame<T, IWindowChangeListener, std::vector<sptr<IWindowChangeListener>>> GetListeners();
391     template<typename T>
392     EnableIfSame<T, IAvoidAreaChangedListener, std::vector<sptr<IAvoidAreaChangedListener>>> GetListeners();
393     template<typename T>
394     EnableIfSame<T, IDialogDeathRecipientListener, std::vector<sptr<IDialogDeathRecipientListener>>> GetListeners();
395     template<typename T>
396     EnableIfSame<T, IDialogTargetTouchListener, std::vector<sptr<IDialogTargetTouchListener>>> GetListeners();
397     template<typename T>
398     EnableIfSame<T, IOccupiedAreaChangeListener, std::vector<sptr<IOccupiedAreaChangeListener>>> GetListeners();
399     template<typename T>
400     EnableIfSame<T, IScreenshotListener, std::vector<sptr<IScreenshotListener>>> GetListeners();
401     template<typename T>
402     EnableIfSame<T, ITouchOutsideListener, std::vector<sptr<ITouchOutsideListener>>> GetListeners();
403     template<typename T>
404     EnableIfSame<T, IWindowVisibilityChangedListener, std::vector<IWindowVisibilityListenerSptr>> GetListeners();
405     template<typename T>
406     EnableIfSame<T, IWindowNoInteractionListener, std::vector<IWindowNoInteractionListenerSptr>> GetListeners();
407     template<typename T>
408     EnableIfSame<T, IWindowTitleButtonRectChangedListener,
409         std::vector<sptr<IWindowTitleButtonRectChangedListener>>> GetListeners();
410     template<typename T> void ClearUselessListeners(std::map<int32_t, T>& listeners, int32_t persistentId);
411     RSSurfaceNode::SharedPtr CreateSurfaceNode(std::string name, WindowType type);
412     template<typename T>
413     EnableIfSame<T, IWindowStatusChangeListener, std::vector<sptr<IWindowStatusChangeListener>>> GetListeners();
414     template<typename T>
415     EnableIfSame<T, IWindowRectChangeListener, std::vector<sptr<IWindowRectChangeListener>>> GetListeners();
416     template<typename T>
417     EnableIfSame<T, ISubWindowCloseListener, sptr<ISubWindowCloseListener>> GetListeners();
418     template<typename T>
419     EnableIfSame<T, ISwitchFreeMultiWindowListener, std::vector<sptr<ISwitchFreeMultiWindowListener>>> GetListeners();
420     void NotifyAfterFocused();
421     void NotifyUIContentFocusStatus();
422     void NotifyAfterUnfocused(bool needNotifyUiContent = true);
423     void NotifyAfterResumed();
424     void NotifyAfterPaused();
425 
426     WMError InitUIContent(const std::string& contentInfo, napi_env env, napi_value storage,
427         WindowSetUIContentType type, AppExecFwk::Ability* ability, OHOS::Ace::UIContentErrorCode& aceRet);
428     WMError SetUIContentInner(const std::string& contentInfo, napi_env env, napi_value storage,
429         WindowSetUIContentType type, AppExecFwk::Ability* ability);
430     std::shared_ptr<std::vector<uint8_t>> GetAbcContent(const std::string& abcPath);
431 
432     void UpdateRectForRotation(const Rect& wmRect, const Rect& preRect, WindowSizeChangeReason wmReason,
433         const SceneAnimationConfig& config);
434     void UpdateRectForOtherReason(const Rect& wmRect, const Rect& preRect, WindowSizeChangeReason wmReason,
435         const std::shared_ptr<RSTransaction>& rsTransaction = nullptr);
436     void UpdateRectForOtherReasonTask(const Rect& wmRect, const Rect& preRect, WindowSizeChangeReason wmReason,
437         const std::shared_ptr<RSTransaction>& rsTransaction);
438     void NotifyRotationAnimationEnd();
439     void SubmitNoInteractionMonitorTask(int32_t eventId, const IWindowNoInteractionListenerSptr& listener);
440     bool IsUserOrientation(Orientation orientation) const;
441     void GetTitleButtonVisible(bool isPC, bool& hideMaximizeButton, bool& hideMinimizeButton, bool& hideSplitButton);
442     WMError GetAppForceLandscapeConfig(AppForceLandscapeConfig& config);
443     void SetForceSplitEnable(bool isForceSplit, const std::string& homePage = "");
444     void SetFrameLayoutCallbackEnable(bool enable);
445     void UpdateFrameLayoutCallbackIfNeeded(WindowSizeChangeReason wmReason);
446     void SetUniqueVirtualPixelRatioForSub(bool useUniqueDensity, float virtualPixelRatio);
447     bool IsNotifyInteractiveDuplicative(bool interactive);
448 
449     static std::recursive_mutex lifeCycleListenerMutex_;
450     static std::recursive_mutex windowChangeListenerMutex_;
451     static std::recursive_mutex avoidAreaChangeListenerMutex_;
452     static std::recursive_mutex dialogDeathRecipientListenerMutex_;
453     static std::recursive_mutex dialogTargetTouchListenerMutex_;
454     static std::recursive_mutex occupiedAreaChangeListenerMutex_;
455     static std::recursive_mutex screenshotListenerMutex_;
456     static std::recursive_mutex touchOutsideListenerMutex_;
457     static std::recursive_mutex windowVisibilityChangeListenerMutex_;
458     static std::recursive_mutex windowNoInteractionListenerMutex_;
459     static std::recursive_mutex windowStatusChangeListenerMutex_;
460     static std::recursive_mutex windowTitleButtonRectChangeListenerMutex_;
461     static std::mutex displayMoveListenerMutex_;
462     static std::mutex windowRectChangeListenerMutex_;
463     static std::mutex subWindowCloseListenersMutex_;
464     static std::mutex switchFreeMultiWindowListenerMutex_;
465     static std::map<int32_t, std::vector<sptr<IWindowLifeCycle>>> lifecycleListeners_;
466     static std::map<int32_t, std::vector<sptr<IDisplayMoveListener>>> displayMoveListeners_;
467     static std::map<int32_t, std::vector<sptr<IWindowChangeListener>>> windowChangeListeners_;
468     static std::map<int32_t, std::vector<sptr<IAvoidAreaChangedListener>>> avoidAreaChangeListeners_;
469     static std::map<int32_t, std::vector<sptr<IDialogDeathRecipientListener>>> dialogDeathRecipientListeners_;
470     static std::map<int32_t, std::vector<sptr<IDialogTargetTouchListener>>> dialogTargetTouchListener_;
471     static std::map<int32_t, std::vector<sptr<IOccupiedAreaChangeListener>>> occupiedAreaChangeListeners_;
472     static std::map<int32_t, std::vector<sptr<IScreenshotListener>>> screenshotListeners_;
473     static std::map<int32_t, std::vector<sptr<ITouchOutsideListener>>> touchOutsideListeners_;
474     static std::map<int32_t, std::vector<IWindowVisibilityListenerSptr>> windowVisibilityChangeListeners_;
475     static std::map<int32_t, std::vector<IWindowNoInteractionListenerSptr>> windowNoInteractionListeners_;
476     static std::map<int32_t, std::vector<sptr<IWindowStatusChangeListener>>> windowStatusChangeListeners_;
477     static std::map<int32_t, std::vector<sptr<IWindowTitleButtonRectChangedListener>>>
478         windowTitleButtonRectChangeListeners_;
479     static std::map<int32_t, std::vector<sptr<IWindowRectChangeListener>>> windowRectChangeListeners_;
480     static std::map<int32_t, sptr<ISubWindowCloseListener>> subWindowCloseListeners_;
481     static std::map<int32_t, std::vector<sptr<ISwitchFreeMultiWindowListener>>> switchFreeMultiWindowListeners_;
482 
483     // FA only
484     sptr<IAceAbilityHandler> aceAbilityHandler_;
485 
486     std::atomic<int32_t> lastInteractionEventId_ { 0 };
487 
488     bool isMainHandlerAvailable_ = true;
489 
490     std::string subWindowTitle_ = { "" };
491     std::string dialogTitle_ = { "" };
492     std::shared_mutex keyEventFilterMutex_;
493     KeyEventFilterFunc keyEventFilter_;
494     WindowTitleVisibleFlags windowTitleVisibleFlags_;
495     sptr<WindowOption> windowOption_;
496 
497     /*
498      * Window Layout
499      */
500     std::atomic_bool windowSizeChanged_ = true;
501     std::atomic_bool enableFrameLayoutFinishCb_ = false;
502     WindowSizeChangeReason lastSizeChangeReason_ = WindowSizeChangeReason::END;
503     bool postTaskDone_ = false;
504     int16_t rotationAnimationCount_ { 0 };
505 };
506 } // namespace Rosen
507 } // namespace OHOS
508 
509 #endif // OHOS_ROSEN_WINDOW_SESSION_IMPL_H
510