/* * Copyright (c) 2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef OHOS_ROSEN_WINDOW_SESSION_IMPL_H #define OHOS_ROSEN_WINDOW_SESSION_IMPL_H #include #include #include #include #include #include #include #include "display_manager.h" #include "singleton_container.h" #include "common/include/window_session_property.h" #include "display_info.h" #include "future_callback.h" #include "interfaces/include/ws_common.h" #include "interfaces/include/ws_common_inner.h" #include "session/container/include/zidl/session_stage_stub.h" #include "session/host/include/zidl/session_interface.h" #include "vsync_station.h" #include "window.h" #include "window_helper.h" #include "window_option.h" #include "wm_common.h" #include "wm_common_inner.h" namespace OHOS { namespace Rosen { namespace { template using EnableIfSame = typename std::enable_if, Ret>::type; /* * DFX */ const std::string SET_UICONTENT_TIMEOUT_LISTENER_TASK_NAME = "SetUIContentTimeoutListener"; constexpr int64_t SET_UICONTENT_TIMEOUT_TIME_MS = 4000; constexpr int64_t SET_UICONTENT_TIMEOUT_TIME_AFTER_FREEZE_MS = 5000; } struct WindowTitleVisibleFlags { bool isMaximizeVisible = true; bool isMinimizeVisible = true; bool isSplitVisible = true; bool isCloseVisible = true; }; class WindowSessionImpl : public Window, public virtual SessionStageStub { public: explicit WindowSessionImpl(const sptr& option); ~WindowSessionImpl(); static sptr Find(const std::string& name); static std::vector> GetSubWindow(int parentId); virtual WMError Create(const std::shared_ptr& context, const sptr& iSession, const std::string& identityToken = "") { return WMError::WM_OK; } /* * inherits from window */ WMError Show(uint32_t reason = 0, bool withAnimation = false, bool withFocus = true) override; WMError Hide(uint32_t reason = 0, bool withAnimation = false, bool isFromInnerkits = true) override; WMError Destroy() override; virtual WMError Destroy(bool needNotifyServer, bool needClearListener = true); WMError NapiSetUIContent(const std::string& contentInfo, napi_env env, napi_value storage, BackupAndRestoreType type, sptr token, AppExecFwk::Ability* ability) override; WMError SetUIContentByName(const std::string& contentInfo, napi_env env, napi_value storage, AppExecFwk::Ability* ability) override; WMError SetUIContentByAbc(const std::string& abcPath, napi_env env, napi_value storage, AppExecFwk::Ability* ability) override; std::shared_ptr GetSurfaceNode() const override; const std::shared_ptr GetContext() const override; Rect GetRequestRect() const override; WindowType GetType() const override; const std::string& GetWindowName() const override; WindowState GetWindowState() const override; WindowState GetRequestWindowState() const; WMError SetFocusable(bool isFocusable) override; WMError SetTouchable(bool isTouchable) override; /* * Window Hierarchy */ WMError SetTopmost(bool topmost) override; bool IsTopmost() const override; WMError SetMainWindowTopmost(bool isTopmost) override; bool IsMainWindowTopmost() const override; void SetSubWindowZLevelToProperty(); int32_t GetSubWindowZLevelByFlags(WindowType type, uint32_t windowFlags, bool isTopmost); WMError SetResizeByDragEnabled(bool dragEnabled) override; WMError SetRaiseByClickEnabled(bool raiseEnabled) override; WMError HideNonSystemFloatingWindows(bool shouldHide) override; WMError SetSingleFrameComposerEnabled(bool enable) override; bool IsFloatingWindowAppType() const override; /* * PC Window */ bool IsPcWindow() const override; bool IsPcOrPadCapabilityEnabled() const override; bool IsPcOrPadFreeMultiWindowMode() const override; bool IsSceneBoardEnabled() const override; bool GetCompatibleModeInPc() const override; WMError SetWindowDelayRaiseEnabled(bool isEnabled) override; bool IsWindowDelayRaiseEnabled() const override; WMError SetTitleButtonVisible(bool isMaximizeVisible, bool isMinimizeVisible, bool isSplitVisible, bool isCloseVisible) override; WMError SetSubWindowModal(bool isModal, ModalityType modalityType = ModalityType::WINDOW_MODALITY) override; WMError SetWindowModal(bool isModal) override; void SetTargetAPIVersion(uint32_t targetAPIVersion); uint32_t GetTargetAPIVersion() const; WMError SetWindowType(WindowType type) override; WMError SetBrightness(float brightness) override; virtual float GetBrightness() const override; void SetRequestedOrientation(Orientation orientation, bool needAnimation = true) override; bool GetTouchable() const override; uint32_t GetWindowId() const override; uint64_t GetDisplayId() const override; Rect GetRect() const override; bool GetFocusable() const override; std::string GetContentInfo(BackupAndRestoreType type = BackupAndRestoreType::CONTINUATION) override; WMError SetRestoredRouterStack(const std::string& routerStack) override; Ace::UIContent* GetUIContent() const override; std::shared_ptr GetUIContentSharedPtr() const; Ace::UIContent* GetUIContentWithId(uint32_t winId) const override; void OnNewWant(const AAFwk::Want& want) override; void RequestVsync(const std::shared_ptr& vsyncCallback) override; int64_t GetVSyncPeriod() override; void FlushFrameRate(uint32_t rate, int32_t animatorExpectedFrameRate, uint32_t rateType = 0) override; void ConsumePointerEvent(const std::shared_ptr& pointerEvent) override; void ConsumeKeyEvent(std::shared_ptr& inputEvent) override; bool PreNotifyKeyEvent(const std::shared_ptr& keyEvent) override; /* * inherits from session stage */ WSError SetActive(bool active) override; WSError UpdateRect(const WSRect& rect, SizeChangeReason reason, const SceneAnimationConfig& config = { nullptr, ROTATE_ANIMATION_DURATION }, const std::map& avoidAreas = {}) override; void UpdateDensity() override; void SetUniqueVirtualPixelRatio(bool useUniqueDensity, float virtualPixelRatio) override; WSError UpdateOrientation() override; WSError UpdateDisplayId(uint64_t displayId) override; WSError UpdateFocus(bool focus) override; bool IsFocused() const override; WMError RequestFocus() const override; WMError RequestFocusByClient(bool isFocused) const override; WSError UpdateWindowMode(WindowMode mode) override; WSError HandleBackEvent() override; KeyboardAnimationConfig GetKeyboardAnimationConfig() override; bool NotifyOnKeyPreImeEvent(const std::shared_ptr& keyEvent) override; void NotifyPointerEvent(const std::shared_ptr& pointerEvent) override; void NotifyKeyEvent(const std::shared_ptr& keyEvent, bool& isConsumed, bool notifyInputMethod = true) override; void NotifyOccupiedAreaChangeInfoInner(sptr info); void NotifyOccupiedAreaChangeInfo(sptr info, const std::shared_ptr& rsTransaction = nullptr) override; void NotifyKeyboardDidShow(const KeyboardPanelInfo& keyboardPanelInfo); void NotifyKeyboardDidHide(const KeyboardPanelInfo& keyboardPanelInfo); void NotifyKeyboardAnimationCompleted(const KeyboardPanelInfo& keyboardPanelInfo) override; void NotifyForegroundInteractiveStatus(bool interactive) override; void NotifyDisplayMove(DisplayId from, DisplayId to) override; void NotifyWindowCrossAxisChange(CrossAxisState state) override; WMError RegisterLifeCycleListener(const sptr& listener) override; WMError UnregisterLifeCycleListener(const sptr& listener) override; WMError RegisterDisplayMoveListener(sptr& listener) override; WMError UnregisterDisplayMoveListener(sptr& listener) override; WMError RegisterWindowChangeListener(const sptr& listener) override; WMError UnregisterWindowChangeListener(const sptr& listener) override; WMError RegisterWindowCrossAxisListener(const sptr& listener) override; WMError UnregisterWindowCrossAxisListener(const sptr& listener) override; void RegisterDialogDeathRecipientListener(const sptr& listener) override; void UnregisterDialogDeathRecipientListener(const sptr& listener) override; WMError RegisterDialogTargetTouchListener(const sptr& listener) override; WMError UnregisterDialogTargetTouchListener(const sptr& listener) override; WMError RegisterOccupiedAreaChangeListener(const sptr& listener) override; WMError UnregisterOccupiedAreaChangeListener(const sptr& listener) override; WMError RegisterKeyboardDidShowListener(const sptr& listener) override; WMError UnregisterKeyboardDidShowListener(const sptr& listener) override; WMError RegisterKeyboardDidHideListener(const sptr& listener) override; WMError UnregisterKeyboardDidHideListener(const sptr& listener) override; WMError RegisterTouchOutsideListener(const sptr& listener) override; WMError UnregisterTouchOutsideListener(const sptr& listener) override; WMError RegisterWindowVisibilityChangeListener(const IWindowVisibilityListenerSptr& listener) override; WMError UnregisterWindowVisibilityChangeListener(const IWindowVisibilityListenerSptr& listener) override; WMError RegisterDisplayIdChangeListener(const IDisplayIdChangeListenerSptr& listener) override; WMError UnregisterDisplayIdChangeListener(const IDisplayIdChangeListenerSptr& listener) override; WMError RegisterSystemDensityChangeListener(const ISystemDensityChangeListenerSptr& listener) override; WMError UnregisterSystemDensityChangeListener(const ISystemDensityChangeListenerSptr& listener) override; WMError RegisterWindowNoInteractionListener(const IWindowNoInteractionListenerSptr& listener) override; WMError UnregisterWindowNoInteractionListener(const IWindowNoInteractionListenerSptr& listener) override; void RegisterWindowDestroyedListener(const NotifyNativeWinDestroyFunc& func) override; void UnregisterWindowDestroyedListener() override { notifyNativeFunc_ = nullptr; } WMError RegisterScreenshotListener(const sptr& listener) override; WMError UnregisterScreenshotListener(const sptr& listener) override; void SetAceAbilityHandler(const sptr& handler) override; void SetInputEventConsumer(const std::shared_ptr& inputEventConsumer) override; void GetExtensionConfig(AAFwk::WantParams& want) const override; void UpdateExtensionConfig(const std::shared_ptr& want) override; WMError SetBackgroundColor(const std::string& color) override; virtual Orientation GetRequestedOrientation() override; int32_t GetParentId() const; int32_t GetPersistentId() const override; sptr GetProperty() const; SystemSessionConfig GetSystemSessionConfig() const; sptr GetHostSession() const; int32_t GetFloatingWindowParentId(); void NotifyAfterForeground(bool needNotifyListeners = true, bool needNotifyUiContent = true); void NotifyAfterBackground(bool needNotifyListeners = true, bool needNotifyUiContent = true); void NotifyAfterDidForeground(uint32_t reason = static_cast(WindowStateChangeReason::NORMAL)); void NotifyAfterDidBackground(uint32_t reason = static_cast(WindowStateChangeReason::NORMAL)); void NotifyForegroundFailed(WMError ret); void NotifyBackgroundFailed(WMError ret); WSError MarkProcessed(int32_t eventId) override; void UpdateTitleButtonVisibility(); WSError NotifyDestroy() override; WSError NotifyTransferComponentData(const AAFwk::WantParams& wantParams) override; WSErrorCode NotifyTransferComponentDataSync(const AAFwk::WantParams& wantParams, AAFwk::WantParams& reWantParams) override; void NotifyTouchDialogTarget(int32_t posX = 0, int32_t posY = 0) override; void NotifyScreenshot() override; void DumpSessionElementInfo(const std::vector& params) override; // colorspace, gamut virtual bool IsSupportWideGamut() override; virtual void SetColorSpace(ColorSpace colorSpace) override; virtual ColorSpace GetColorSpace() override; WSError NotifyTouchOutside() override; WMError SetLandscapeMultiWindow(bool isLandscapeMultiWindow) override; WSError NotifyWindowVisibility(bool isVisible) override; WSError NotifyNoInteractionTimeout(const IWindowNoInteractionListenerSptr& listener); WMError TransferAccessibilityEvent(const Accessibility::AccessibilityEventInfo& info, int64_t uiExtensionIdLevel) override; WindowState state_ { WindowState::STATE_INITIAL }; WindowState requestState_ { WindowState::STATE_INITIAL }; WSError UpdateMaximizeMode(MaximizeMode mode) override; void NotifySessionForeground(uint32_t reason, bool withAnimation) override; void NotifySessionBackground(uint32_t reason, bool withAnimation, bool isFromInnerkits) override; WSError UpdateTitleInTargetPos(bool isShow, int32_t height) override; WSError NotifyDialogStateChange(bool isForeground) override; bool IsMainHandlerAvailable() const override; /* * PiP Window */ WSError NotifyCloseExistPipWindow() override; WSError SetPipActionEvent(const std::string& action, int32_t status) override; WSError SetPiPControlEvent(WsPiPControlType controlType, WsPiPControlStatus status) override; WSError NotifyPipWindowSizeChange(double width, double height, double scale) override; void UpdatePiPRect(const Rect& rect, WindowSizeChangeReason reason) override; void UpdatePiPControlStatus(PiPControlType controlType, PiPControlStatus status) override; void SetAutoStartPiP(bool isAutoStart, uint32_t priority, uint32_t width, uint32_t height) override; void SetDrawingContentState(bool drawingContentState); WMError RegisterWindowStatusChangeListener(const sptr& listener) override; WMError UnregisterWindowStatusChangeListener(const sptr& listener) override; WMError SetSpecificBarProperty(WindowType type, const SystemBarProperty& property) override; void SetLayoutTransform(const Transform& trans); Transform GetLayoutTransform() const override; /* * Window Decor */ WMError SetDecorVisible(bool isVisible) override; WMError GetDecorVisible(bool& isVisible) override; WMError SetWindowTitleMoveEnabled(bool enable) override; WMError SetDecorHeight(int32_t decorHeight) override; WMError GetDecorHeight(int32_t& height) override; WMError SetDecorButtonStyle(const DecorButtonStyle& decorButtonStyle) override; WMError GetDecorButtonStyle(DecorButtonStyle& decorButtonStyle) override; WMError GetTitleButtonArea(TitleButtonRect& titleButtonRect) override; WMError SetAPPWindowLabel(const std::string& label) override; WMError SetAPPWindowIcon(const std::shared_ptr& icon) override; WMError SetWindowContainerColor(const std::string& activeColor, const std::string& inactiveColor) override; /* * Window Decor listener */ WMError RegisterWindowTitleButtonRectChangeListener( const sptr& listener) override; WMError UnregisterWindowTitleButtonRectChangeListener( const sptr& listener) override; void NotifyWindowTitleButtonRectChange(TitleButtonRect titleButtonRect); WMError RegisterSubWindowCloseListeners(const sptr& listener) override; WMError UnregisterSubWindowCloseListeners(const sptr& listener) override; void NotifySubWindowClose(bool& terminateCloseProcess); WMError RegisterMainWindowCloseListeners(const sptr& listener) override; WMError UnregisterMainWindowCloseListeners(const sptr& listener) override; WMError NotifyMainWindowClose(bool& terminateCloseProcess); WMError RegisterWindowWillCloseListeners(const sptr& listener) override; WMError UnRegisterWindowWillCloseListeners(const sptr& listener) override; WMError NotifyWindowWillClose(sptr window); WSError GetUIContentRemoteObj(sptr& uiContentRemoteObj) override; void RecoverSessionListener(); void SetDefaultDisplayIdIfNeed(); WMError RegisterWindowRectChangeListener(const sptr& listener) override; WMError UnregisterWindowRectChangeListener(const sptr& listener) override; virtual WMError GetCallingWindowWindowStatus(WindowStatus& windowStatus) const override; virtual WMError GetCallingWindowRect(Rect& rect) const override; virtual void SetUiDvsyncSwitch(bool dvsyncSwitch) override; WMError SetContinueState(int32_t continueState) override; /* * Multi Window */ WSError SetSplitButtonVisible(bool isVisible) override; WMError GetIsMidScene(bool& isMidScene) override; WSError SendContainerModalEvent(const std::string& eventName, const std::string& eventValue) override; /* * Window Layout */ WMError EnableDrag(bool enableDrag) override; WSError SetDragActivated(bool dragActivated) override; WSError SetEnableDragBySystem(bool enableDrag) override; bool IsWindowDraggable(); float GetVirtualPixelRatio() override; CrossAxisState GetCrossAxisState() override; /* * Free Multi Window */ WMError RegisterSwitchFreeMultiWindowListener(const sptr& listener) override; WMError UnregisterSwitchFreeMultiWindowListener(const sptr& listener) override; void SetFreeMultiWindowMode(bool enable) { windowSystemConfig_.freeMultiWindowEnable_ = enable; } /* * Window Immersive */ WMError RegisterAvoidAreaChangeListener(const sptr& listener) override; WMError UnregisterAvoidAreaChangeListener(const sptr& listener) override; WMError SetAvoidAreaOption(uint32_t avoidAreaOption) override; WMError GetAvoidAreaOption(uint32_t& avoidAreaOption) override; void NotifyAvoidAreaChange(const sptr& avoidArea, AvoidAreaType type); WSError UpdateAvoidArea(const sptr& avoidArea, AvoidAreaType type) override; bool IsSystemWindow() const override { return WindowHelper::IsSystemWindow(GetType()); } bool IsAppWindow() const override { return WindowHelper::IsAppWindow(GetType()); } WindowType GetRootHostWindowType() const override { return rootHostWindowType_; } void SetRootHostWindowType(WindowType& rootHostWindowType) override { rootHostWindowType_ = rootHostWindowType; } WMError UpdateSystemBarProperties(const std::unordered_map& systemBarProperties, const std::unordered_map& systemBarPropertyFlags) override; void UpdateSpecificSystemBarEnabled(bool systemBarEnable, bool systemBarEnableAnimation, SystemBarProperty& property) override; WMError SetSystemBarProperty(WindowType type, const SystemBarProperty& property) override; /* * Window Property */ WSError NotifyDisplayIdChange(DisplayId displayId); /* * Window Input Event */ WMError NotifyWatchGestureConsumeResult(int32_t keyCode, bool isConsumed); WMError NotifyWatchFocusActiveChange(bool isActive); void RegisterWatchFocusActiveChangeCallback(); void NotifyConsumeResultToFloatWindow(const std::shared_ptr& keyEvent, bool isConsumed); /* * HightLight Window */ bool GetExclusivelyHighlighted() const; WMError IsWindowHighlighted(bool& highlighted) const override; WMError SetExclusivelyHighlighted(bool isExclusivelyHighlighted) override; WMError RegisterWindowHighlightChangeListeners(const sptr& listener) override; WMError UnregisterWindowHighlightChangeListeners(const sptr& listener) override; WSError NotifyHighlightChange(bool isHighlight) override; protected: WMError Connect(); bool IsWindowSessionInvalid() const; void NotifyWindowAfterUnfocused(); void NotifyWindowAfterFocused(); void NotifyAfterActive(); void NotifyAfterInactive(); void NotifyBeforeDestroy(std::string windowName); void NotifyAfterDestroy(); void ClearListenersById(int32_t persistentId); /* * Free Multi Window */ void ClearSwitchFreeMultiWindowListenersById(int32_t persistentId); void NotifySwitchFreeMultiWindow(bool enable); void ClearVsyncStation(); WMError WindowSessionCreateCheck(); void UpdateDecorEnableToAce(bool isDecorEnable); void UpdateDecorEnable(bool needNotify = false, WindowMode mode = WindowMode::WINDOW_MODE_UNDEFINED); void NotifyModeChange(WindowMode mode, bool hasDeco = true); WMError UpdateProperty(WSPropertyChangeAction action); WMError SetBackgroundColor(uint32_t color); uint32_t GetBackgroundColor() const; virtual WMError SetLayoutFullScreenByApiVersion(bool status); virtual float GetVirtualPixelRatio(const sptr& displayInfo); void UpdateViewportConfig(const Rect& rect, WindowSizeChangeReason reason, const std::shared_ptr& rsTransaction = nullptr, const sptr& info = nullptr, const std::map& avoidAreas = {}); void NotifySizeChange(Rect rect, WindowSizeChangeReason reason); static sptr FindWindowById(uint32_t winId); void NotifyWindowStatusChange(WindowMode mode); void NotifyTransformChange(const Transform& transForm) override; void NotifySingleHandTransformChange(const SingleHandTransform& singleHandTransform) override; bool IsKeyboardEvent(const std::shared_ptr& keyEvent) const; void DispatchKeyEventCallback(const std::shared_ptr& keyEvent, bool& isConsumed); bool IsVerticalOrientation(Orientation orientation) const; void CopyUniqueDensityParameter(sptr parentWindow); sptr FindMainWindowWithContext(); sptr FindExtensionWindowWithContext(); WMError RegisterExtensionAvoidAreaChangeListener(const sptr& listener); WMError UnregisterExtensionAvoidAreaChangeListener(const sptr& listener); void RefreshNoInteractionTimeoutMonitor(); WindowStatus GetWindowStatusInner(WindowMode mode); /* * PC Event Filter */ bool FilterKeyEvent(const std::shared_ptr& keyEvent); bool FilterPointerEvent(const std::shared_ptr& pointerEvent); WMError SetKeyEventFilter(KeyEventFilterFunc filter) override; WMError ClearKeyEventFilter() override; WMError SetMouseEventFilter(MouseEventFilterFunc filter) override; WMError ClearMouseEventFilter() override; WMError SetTouchEventFilter(TouchEventFilterFunc filter) override; WMError ClearTouchEventFilter() override; /* * Sub Window */ void UpdateSubWindowStateAndNotify(int32_t parentPersistentId, const WindowState newState); void DestroySubWindow(); bool IsSubWindowMaximizeSupported() const override; void UpdateSubWindowLevel(uint32_t subWindowLevel); void GetSubWidnows(int32_t parentPersistentId, std::vector>& subWindows); void RemoveSubWindow(int32_t parentPersistentId); sptr windowOption_; sptr hostSession_; mutable std::mutex hostSessionMutex_; std::shared_ptr uiContent_; mutable std::shared_mutex uiContentMutex_; std::shared_ptr context_; std::shared_ptr surfaceNode_; sptr property_; SystemSessionConfig windowSystemConfig_; NotifyNativeWinDestroyFunc notifyNativeFunc_; std::recursive_mutex mutex_; static std::map>> windowSessionMap_; // protect windowSessionMap_ static std::shared_mutex windowSessionMutex_; static std::set> windowExtensionSessionSet_; // protect windowExtensionSessionSet_ static std::shared_mutex windowExtensionSessionMutex_; bool isSystembarPropertiesSet_ = false; bool isIgnoreSafeAreaNeedNotify_ = false; bool isIgnoreSafeArea_ = false; std::atomic_bool isFocused_ = false; std::atomic_bool isHighlighted_ = false; std::atomic_bool shouldReNotifyHighlight_ = false; std::shared_ptr handler_ = nullptr; bool shouldReNotifyFocus_ = false; std::shared_ptr vsyncStation_ = nullptr; std::shared_ptr inputEventConsumer_; bool useUniqueDensity_ { false }; float virtualPixelRatio_ { 1.0f }; bool escKeyEventTriggered_ = false; // Check whether the UIExtensionAbility process is started static bool isUIExtensionAbilityProcess_; WSError SwitchFreeMultiWindow(bool enable) override; std::string identityToken_ = { "" }; void MakeSubOrDialogWindowDragableAndMoveble(); bool IsFreeMultiWindowMode() const { return windowSystemConfig_.IsFreeMultiWindowMode(); } /* * Sub Window */ static std::recursive_mutex subWindowSessionMutex_; static std::map>> subWindowSessionMap_; /* * DFX */ void SetUIContentComplete(); void AddSetUIContentTimeoutCheck(); void NotifySetUIContentComplete(); std::atomic_bool setUIContentCompleted_ { false }; void SetUIExtensionDestroyComplete(); void SetUIExtensionDestroyCompleteInSubWindow(); void AddSetUIExtensionDestroyTimeoutCheck(); std::atomic_bool setUIExtensionDestroyCompleted_ { false }; std::atomic_bool startUIExtensionDestroyTimer_ { false }; enum TimeoutErrorCode : int32_t { SET_UICONTENT_TIMEOUT = 1000, SET_UIEXTENSION_DESTROY_TIMEOUT }; /* * Window Lifecycle */ bool hasFirstNotifyInteractive_ = false; bool interactive_ = true; bool isDidForeground_ = false; /* * Window Layout */ std::atomic_bool isDragTaskPostDone_ = true; void FlushLayoutSize(int32_t width, int32_t height) override; sptr layoutCallback_ = nullptr; void UpdateVirtualPixelRatio(const sptr& display); WMError GetVirtualPixelRatio(float& vpr); void SetCurrentTransform(const Transform& transform); Transform GetCurrentTransform() const; void NotifyAfterUIContentReady(); void SetNeedRenotifyTransform(bool isNeedRenotify) { needRenotifyTransform_.store(isNeedRenotify); } bool IsNeedRenotifyTransform() const { return needRenotifyTransform_.load(); } mutable std::recursive_mutex transformMutex_; std::atomic crossAxisState_ = CrossAxisState::STATE_INVALID; bool IsValidCrossState(int32_t state) const; /* * Window Immersive */ std::map lastAvoidAreaMap_; uint32_t GetStatusBarHeight() override; WindowType rootHostWindowType_ = WindowType::APP_MAIN_WINDOW_BASE; /* * PC Fold Screen */ bool supportEnterWaterfallMode_ { false }; /* * Window Property */ float lastSystemDensity_ = UNDEFINED_DENSITY; WSError NotifySystemDensityChange(float density); void RegisterWindowInspectorCallback(); uint32_t GetTargetAPIVersionByApplicationInfo() const; /* * Window Input Event */ bool GetWatchGestureConsumed() const; void SetWatchGestureConsumed(bool isWatchGestureConsumed); private: //Trans between colorGamut and colorSpace static ColorSpace GetColorSpaceFromSurfaceGamut(GraphicColorGamut colorGamut); static GraphicColorGamut GetSurfaceGamutFromColorSpace(ColorSpace colorSpace); template WMError RegisterListener(std::vector>& holder, const sptr& listener); template WMError UnregisterListener(std::vector>& holder, const sptr& listener); template EnableIfSame>> GetListeners(); template EnableIfSame>> GetListeners(); template EnableIfSame>> GetListeners(); template EnableIfSame>> GetListeners(); template EnableIfSame>> GetListeners(); template EnableIfSame>> GetListeners(); template EnableIfSame>> GetListeners(); template EnableIfSame>> GetListeners(); template EnableIfSame>> GetListeners(); template EnableIfSame>> GetListeners(); template EnableIfSame>> GetListeners(); template EnableIfSame>> GetListeners(); template EnableIfSame> GetListeners(); template EnableIfSame> GetListeners(); template EnableIfSame> GetListeners(); template EnableIfSame> GetListeners(); template void ClearUselessListeners(std::map& listeners, int32_t persistentId); template void ClearUselessListeners(std::unordered_map& listeners, int32_t persistentId); RSSurfaceNode::SharedPtr CreateSurfaceNode(const std::string& name, WindowType type); template EnableIfSame>> GetListeners(); template EnableIfSame>> GetListeners(); template EnableIfSame>> GetListeners(); template EnableIfSame>> GetListeners(); void NotifyAfterFocused(); void NotifyUIContentFocusStatus(); void NotifyAfterUnfocused(bool needNotifyUiContent = true); void NotifyAfterResumed(); void NotifyAfterPaused(); void NotifyUIContentHighlightStatus(bool isHighlighted); /* * Window Decor listener */ template EnableIfSame>> GetListeners(); template EnableIfSame> GetListeners(); template EnableIfSame> GetListeners(); template EnableIfSame>> GetListeners(); WMError InitUIContent(const std::string& contentInfo, napi_env env, napi_value storage, WindowSetUIContentType setUIContentType, BackupAndRestoreType restoreType, AppExecFwk::Ability* ability, OHOS::Ace::UIContentErrorCode& aceRet); WMError SetUIContentInner(const std::string& contentInfo, napi_env env, napi_value storage, WindowSetUIContentType setUIContentType, BackupAndRestoreType restoreType, AppExecFwk::Ability* ability); std::shared_ptr> GetAbcContent(const std::string& abcPath); inline void DestroyExistUIContent(); std::string GetRestoredRouterStack(); bool CheckIfNeedCommitRsTransaction(WindowSizeChangeReason wmReason); void UpdateRectForRotation(const Rect& wmRect, const Rect& preRect, WindowSizeChangeReason wmReason, const SceneAnimationConfig& config, const std::map& avoidAreas = {}); void UpdateRectForOtherReason(const Rect& wmRect, const Rect& preRect, WindowSizeChangeReason wmReason, const std::shared_ptr& rsTransaction = nullptr, const std::map& avoidAreas = {}); void UpdateRectForOtherReasonTask(const Rect& wmRect, const Rect& preRect, WindowSizeChangeReason wmReason, const std::shared_ptr& rsTransaction, const std::map& avoidAreas = {}); void UpdateRectForResizeWithAnimation(const Rect& wmRect, const Rect& preRect, WindowSizeChangeReason wmReason, const RectAnimationConfig& rectAnimationConfig, const std::shared_ptr& rsTransaction = nullptr, const std::map& avoidAreas = {}); void NotifyRotationAnimationEnd(); void SubmitNoInteractionMonitorTask(int32_t eventId, const IWindowNoInteractionListenerSptr& listener); bool IsUserOrientation(Orientation orientation) const; WMError GetAppForceLandscapeConfig(AppForceLandscapeConfig& config); void SetForceSplitEnable(bool isForceSplit, const std::string& homePage = ""); void SetFrameLayoutCallbackEnable(bool enable); void UpdateFrameLayoutCallbackIfNeeded(WindowSizeChangeReason wmReason); bool IsNotifyInteractiveDuplicative(bool interactive); void SetUniqueVirtualPixelRatioForSub(bool useUniqueDensity, float virtualPixelRatio); /* * PC Window */ void GetTitleButtonVisible(bool& hideMaximizeButton, bool& hideMinimizeButton, bool& hideSplitButton, bool& hideCloseButton); static std::recursive_mutex lifeCycleListenerMutex_; static std::recursive_mutex windowChangeListenerMutex_; static std::recursive_mutex windowCrossAxisListenerMutex_; static std::recursive_mutex avoidAreaChangeListenerMutex_; static std::recursive_mutex dialogDeathRecipientListenerMutex_; static std::recursive_mutex dialogTargetTouchListenerMutex_; static std::recursive_mutex occupiedAreaChangeListenerMutex_; static std::recursive_mutex keyboardDidShowListenerMutex_; static std::recursive_mutex keyboardDidHideListenerMutex_; static std::recursive_mutex screenshotListenerMutex_; static std::recursive_mutex touchOutsideListenerMutex_; static std::recursive_mutex windowVisibilityChangeListenerMutex_; static std::recursive_mutex windowNoInteractionListenerMutex_; static std::recursive_mutex windowStatusChangeListenerMutex_; static std::mutex displayMoveListenerMutex_; static std::mutex windowRectChangeListenerMutex_; static std::mutex switchFreeMultiWindowListenerMutex_; static std::mutex highlightChangeListenerMutex_; static std::map>> lifecycleListeners_; static std::map>> displayMoveListeners_; static std::map>> windowChangeListeners_; static std::map>> windowCrossAxisListeners_; static std::map>> avoidAreaChangeListeners_; static std::map>> dialogDeathRecipientListeners_; static std::map>> dialogTargetTouchListener_; static std::map>> occupiedAreaChangeListeners_; static std::map>> keyboardDidShowListeners_; static std::map>> keyboardDidHideListeners_; static std::map>> screenshotListeners_; static std::map>> touchOutsideListeners_; static std::map> windowVisibilityChangeListeners_; static std::mutex displayIdChangeListenerMutex_; static std::map> displayIdChangeListeners_; static std::mutex systemDensityChangeListenerMutex_; static std::unordered_map> systemDensityChangeListeners_; static std::map> windowNoInteractionListeners_; static std::map>> windowStatusChangeListeners_; static std::map>> windowRectChangeListeners_; static std::map>> switchFreeMultiWindowListeners_; static std::map>> highlightChangeListeners_; // FA only sptr aceAbilityHandler_; std::atomic lastInteractionEventId_ { 0 }; bool isMainHandlerAvailable_ = true; std::string subWindowTitle_ = { "" }; std::string dialogTitle_ = { "" }; WindowTitleVisibleFlags windowTitleVisibleFlags_; std::string restoredRouterStack_; // It was set and get in same thread, which is js thread. /* * Window Layout */ WSRect layoutRect_; std::atomic_bool windowSizeChanged_ = false; std::atomic_bool enableFrameLayoutFinishCb_ = false; std::atomic_bool dragActivated_ = true; WindowSizeChangeReason lastSizeChangeReason_ = WindowSizeChangeReason::END; bool postTaskDone_ = false; int16_t rotationAnimationCount_ { 0 }; Transform layoutTransform_; SingleHandTransform singleHandTransform_; mutable std::mutex currentTransformMutex_; Transform currentTransform_; std::atomic_bool needRenotifyTransform_ = false; /* * Window Decor */ DecorButtonStyle decorButtonStyle_; int32_t decorHeight_ = 0; /* * Window Decor listener */ static std::recursive_mutex windowTitleButtonRectChangeListenerMutex_; static std::map>> windowTitleButtonRectChangeListeners_; static std::mutex subWindowCloseListenersMutex_; static std::map> subWindowCloseListeners_; static std::mutex mainWindowCloseListenersMutex_; static std::map> mainWindowCloseListeners_; static std::mutex windowWillCloseListenersMutex_; static std::unordered_map>> windowWillCloseListeners_; /* * Multi Window */ bool isSplitButtonVisible_ = true; /* * PC Window */ uint32_t targetAPIVersion_ = 0; /* * Window Input Event */ bool isWatchGestureConsumed_ = false; /* * PC Event Filter */ std::mutex keyEventFilterMutex_; KeyEventFilterFunc keyEventFilter_; std::mutex mouseEventFilterMutex_; MouseEventFilterFunc mouseEventFilter_; std::mutex touchEventFilterMutex_; TouchEventFilterFunc touchEventFilter_; /* * Window Scene */ WSError NotifyWindowAttachStateChange(bool isAttach) override { return WSError::WS_OK; } /* * keyboard */ bool isKeyboardDidShowRegistered_ = false; bool isKeyboardDidHideRegistered_ = false; }; } // namespace Rosen } // namespace OHOS #endif // OHOS_ROSEN_WINDOW_SESSION_IMPL_H