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_PROPERTY_H 17 #define OHOS_ROSEN_WINDOW_SESSION_PROPERTY_H 18 19 #include <refbase.h> 20 #include <string> 21 #include <unordered_map> 22 #include <parcel.h> 23 #include "interfaces/include/ws_common.h" 24 #include "interfaces/include/ws_common_inner.h" 25 #include "wm_common.h" 26 #include "dm_common.h" 27 #include <cfloat> 28 #include "pixel_map.h" 29 #include "floating_ball_template_info.h" 30 31 namespace OHOS { 32 namespace Rosen { 33 class WindowSessionProperty; 34 class CompatibleModeProperty; 35 using HandlWritePropertyFunc = bool (WindowSessionProperty::*)(Parcel& parcel); 36 using HandlReadPropertyFunc = void (WindowSessionProperty::*)(Parcel& parcel); 37 using TransitionAnimationMapType = std::unordered_map<WindowTransitionType, std::shared_ptr<TransitionAnimation>>; 38 constexpr float WINDOW_CORNER_RADIUS_INVALID = -1.0f; 39 40 class WindowSessionProperty : public Parcelable { 41 public: 42 friend class HidumpController; 43 WindowSessionProperty() = default; 44 ~WindowSessionProperty() = default; 45 explicit WindowSessionProperty(const sptr<WindowSessionProperty>& property); 46 void CopyFrom(const sptr<WindowSessionProperty>& property); 47 void SetWindowName(const std::string& name); 48 void SetSessionInfo(const SessionInfo& info); 49 void SetTransitionAnimationConfig(WindowTransitionType transitionType, const TransitionAnimation& animation); 50 void SetRequestRect(const struct Rect& rect); 51 void SetRectAnimationConfig(const RectAnimationConfig& rectAnimationConfig); 52 void SetWindowRect(const struct Rect& rect); 53 void SetFocusable(bool isFocusable); 54 void SetFocusableOnShow(bool isFocusableOnShow); 55 void SetTouchable(bool isTouchable); 56 void SetDragEnabled(bool dragEnabled); 57 void SetHideNonSystemFloatingWindows(bool hide); 58 void SetSkipSelfWhenShowOnVirtualScreen(bool isSkip); 59 void SetSkipEventOnCastPlus(bool isSkip); 60 void SetForceHide(bool hide); 61 void SetRaiseEnabled(bool raiseEnabled); 62 void SetSystemCalling(bool isSystemCalling); 63 void SetTurnScreenOn(bool turnScreenOn); 64 void SetKeepScreenOn(bool keepScreenOn); 65 void SetViewKeepScreenOn(bool keepScreenOn); 66 void SetWindowShadowEnabled(bool isEnabled); 67 void SetRequestedOrientation(Orientation orientation, bool needAnimation = true); 68 void SetDefaultRequestedOrientation(Orientation orientation); 69 void SetUserRequestedOrientation(Orientation orientation); 70 void SetPrivacyMode(bool isPrivate); 71 void SetSystemPrivacyMode(bool isSystemPrivate); 72 void SetSnapshotSkip(bool isSkip); 73 void SetBrightness(float brightness); 74 void SetDisplayId(uint64_t displayId); 75 void SetIsFollowParentWindowDisplayId(bool enabled); 76 void SetWindowType(WindowType type); 77 void SetParentId(int32_t parentId); 78 void SetPersistentId(int32_t persistentId); 79 void SetParentPersistentId(int32_t persistentId); 80 void SetAccessTokenId(uint32_t accessTokenId); 81 void SetTokenState(bool hasToken); 82 void SetMaximizeMode(MaximizeMode mode); 83 void SetWindowMode(WindowMode mode); 84 void SetWindowLimits(const WindowLimits& windowLimits); 85 void SetUserWindowLimits(const WindowLimits& windowLimits); 86 void SetConfigWindowLimitsVP(const WindowLimits& windowLimitsVP); 87 void SetLastLimitsVpr(float vpr); 88 void SetSystemBarProperty(WindowType type, const SystemBarProperty& property); 89 void SetKeyboardLayoutParams(const KeyboardLayoutParams& params); 90 void SetDecorEnable(bool isDecorEnable); 91 void SetAnimationFlag(uint32_t animationFlag); 92 void SetTransform(const Transform& trans); 93 void SetWindowFlags(uint32_t flags); 94 void SetTopmost(bool topmost); 95 bool IsTopmost() const; 96 void SetMainWindowTopmost(bool isTopmost); 97 bool IsMainWindowTopmost() const; 98 void AddWindowFlag(WindowFlag flag); 99 void SetWindowModeSupportType(uint32_t windowModeSupportType); 100 void SetFloatingWindowAppType(bool isAppType); 101 void SetTouchHotAreas(const std::vector<Rect>& rects); 102 void SetKeyboardTouchHotAreas(const KeyboardTouchHotAreas& keyboardTouchHotAreas); 103 void KeepKeyboardOnFocus(bool keepKeyboardFlag); 104 void SetIsNeedUpdateWindowMode(bool isNeedUpdateWindowMode); 105 void SetCallingSessionId(uint32_t sessionId); 106 void SetPiPTemplateInfo(const PiPTemplateInfo& pipTemplateInfo); 107 void SetFbTemplateInfo(const FloatingBallTemplateInfo& fbTemplateInfo); 108 void SetWindowMask(const std::shared_ptr<Media::PixelMap>& windowMask); 109 void SetIsShaped(bool isShaped); 110 void SetIsAppSupportPhoneInPc(bool isSupportPhone); 111 void SetIsPcAppInPad(bool isPcAppInLargeScreenDevice); 112 void SetIsAtomicService(bool isAtomicService); 113 114 /* 115 * Window Immersive 116 */ 117 void SetAvoidAreaOption(uint32_t avoidAreaOption); 118 uint32_t GetAvoidAreaOption() const; 119 120 bool GetIsNeedUpdateWindowMode() const; 121 const std::string& GetWindowName() const; 122 const SessionInfo& GetSessionInfo() const; 123 TransitionAnimationMapType GetTransitionAnimationConfig() const; 124 SessionInfo& EditSessionInfo(); 125 Rect GetWindowRect() const; 126 Rect GetRequestRect() const; 127 RectAnimationConfig GetRectAnimationConfig() const; 128 WindowType GetWindowType() const; 129 bool GetDragEnabled() const; 130 bool GetTouchable() const; 131 bool GetHideNonSystemFloatingWindows() const; 132 bool GetSkipSelfWhenShowOnVirtualScreen() const; 133 bool GetSkipEventOnCastPlus() const; 134 bool GetForceHide() const; 135 bool GetRaiseEnabled() const; 136 bool GetSystemCalling() const; 137 bool IsTurnScreenOn() const; 138 bool IsKeepScreenOn() const; 139 bool GetWindowShadowEnabled() const; 140 bool IsViewKeepScreenOn() const; 141 Orientation GetRequestedOrientation() const; 142 bool GetRequestedAnimation() const; 143 Orientation GetDefaultRequestedOrientation() const; 144 Orientation GetUserRequestedOrientation() const; 145 bool GetPrivacyMode() const; 146 bool GetSystemPrivacyMode() const; 147 bool GetSnapshotSkip() const; 148 float GetBrightness() const; 149 int32_t GetParentId() const; 150 uint32_t GetWindowFlags() const; 151 uint64_t GetDisplayId() const; 152 bool IsFollowParentWindowDisplayId() const; 153 int32_t GetPersistentId() const; 154 int32_t GetParentPersistentId() const; 155 uint32_t GetAccessTokenId() const; 156 bool GetTokenState() const; 157 MaximizeMode GetMaximizeMode() const; 158 WindowMode GetWindowMode() const; 159 WindowLimits GetWindowLimits() const; 160 WindowLimits GetUserWindowLimits() const; 161 WindowLimits GetConfigWindowLimitsVP() const; 162 float GetLastLimitsVpr() const; 163 uint32_t GetWindowModeSupportType() const; 164 std::unordered_map<WindowType, SystemBarProperty> GetSystemBarProperty() const; 165 bool IsDecorEnable(); 166 uint32_t GetAnimationFlag() const; 167 const Transform& GetTransform() const; 168 bool IsFloatingWindowAppType() const; 169 void GetTouchHotAreas(std::vector<Rect>& rects) const; 170 KeyboardTouchHotAreas GetKeyboardTouchHotAreas() const; 171 bool GetKeepKeyboardFlag() const; 172 uint32_t GetCallingSessionId() const; 173 PiPTemplateInfo GetPiPTemplateInfo() const; 174 FloatingBallTemplateInfo GetFbTemplateInfo() const; 175 std::shared_ptr<Media::PixelMap> GetWindowMask() const; 176 bool GetIsShaped() const; 177 KeyboardLayoutParams GetKeyboardLayoutParams() const; 178 bool GetIsAppSupportPhoneInPc() const; 179 bool GetIsPcAppInPad() const; 180 bool GetIsAtomicService() const; 181 182 bool MarshallingWindowLimits(Parcel& parcel) const; 183 static void UnmarshallingWindowLimits(Parcel& parcel, WindowSessionProperty* property); 184 bool MarshallingSystemBarMap(Parcel& parcel) const; 185 static void UnMarshallingSystemBarMap(Parcel& parcel, WindowSessionProperty* property); 186 bool MarshallingPiPTemplateInfo(Parcel& parcel) const; 187 static void UnmarshallingPiPTemplateInfo(Parcel& parcel, WindowSessionProperty* property); 188 bool MarshallingFbTemplateInfo(Parcel& parcel) const; 189 static void UnmarshallingFbTemplateInfo(Parcel& parcel, WindowSessionProperty* property); 190 bool Marshalling(Parcel& parcel) const override; 191 static WindowSessionProperty* Unmarshalling(Parcel& parcel); 192 bool MarshallingWindowMask(Parcel& parcel) const; 193 static void UnmarshallingWindowMask(Parcel& parcel, WindowSessionProperty* property); 194 bool MarshallingMainWindowTopmost(Parcel& parcel) const; 195 static void UnmarshallingMainWindowTopmost(Parcel& parcel, WindowSessionProperty* property); 196 bool MarshallingSessionInfo(Parcel& parcel) const; 197 static bool UnmarshallingSessionInfo(Parcel& parcel, WindowSessionProperty* property); 198 bool MarshallingTransitionAnimationMap(Parcel& parcel) const; 199 static bool UnmarshallingTransitionAnimationMap(Parcel& parcel, WindowSessionProperty* property); 200 bool MarshallingShadowsInfo(Parcel& parcel) const; 201 static void UnmarshallingShadowsInfo(Parcel& parcel, WindowSessionProperty* property); 202 bool MarshallingWindowAnchorInfo(Parcel& parcel) const; 203 static void UnmarshallingWindowAnchorInfo(Parcel& parcel, WindowSessionProperty* property); 204 205 void SetTextFieldPositionY(double textFieldPositionY); 206 void SetTextFieldHeight(double textFieldHeight); 207 208 WindowState GetWindowState() const; 209 void SetWindowState(WindowState state); 210 211 uint8_t GetBackgroundAlpha() const; 212 void SetBackgroundAlpha(uint8_t alpha); 213 214 double GetTextFieldPositionY() const; 215 double GetTextFieldHeight() const; 216 217 void SetSessionPropertyChangeCallback(std::function<void()>&& callback); 218 bool IsLayoutFullScreen() const; 219 void SetIsLayoutFullScreen(bool isLayoutFullScreen); 220 int32_t GetCollaboratorType() const; 221 void SetCollaboratorType(int32_t collaboratorType); 222 bool Write(Parcel& parcel, WSPropertyChangeAction action); 223 void Read(Parcel& parcel, WSPropertyChangeAction action); 224 void SetFullScreenStart(bool fullScreenStart); 225 bool GetFullScreenStart() const; 226 void SetApiVersion(uint32_t version); 227 uint32_t GetApiVersion() const; 228 void SetIsAbilityHookOff(bool isAbilityHookOff); 229 bool GetIsAbilityHookOff() const; 230 void SetIsAbilityHook(bool isAbilityHook); 231 bool GetIsAbilityHook() const; 232 void SetFollowScreenChange(bool isFollowScreenChange); 233 bool GetFollowScreenChange() const; 234 235 /* 236 * Sub Window 237 */ 238 void SetSubWindowLevel(uint32_t subWindowLevel); 239 uint32_t GetSubWindowLevel() const; 240 void SetSubWindowOutlineEnabled(bool subWindowOutlineEnabled); 241 bool IsSubWindowOutlineEnabled() const; 242 void SetWindowAnchorInfo(const WindowAnchorInfo& windowAnchorInfo); 243 WindowAnchorInfo GetWindowAnchorInfo() const; 244 245 /* 246 * Window Hierarchy 247 */ 248 void SetSubWindowZLevel(int32_t zLevel); 249 int32_t GetSubWindowZLevel() const; 250 void SetZIndex(int32_t zIndex); 251 int32_t GetZIndex() const; 252 253 /* 254 * Window Property 255 */ 256 void SetWindowCornerRadius(float cornerRadius); 257 float GetWindowCornerRadius() const; 258 void SetWindowShadows(const ShadowsInfo& shadowsInfo); 259 ShadowsInfo GetWindowShadows() const; 260 Rect GetGlobalDisplayRect() const; 261 void SetGlobalDisplayRect(const Rect& globalDisplayRect); 262 void SetPcAppInpadCompatibleMode(bool enabled); 263 bool GetPcAppInpadCompatibleMode() const; 264 void SetPcAppInpadSpecificSystemBarInvisible(bool isPcAppInpadSpecificSystemBarInvisible); 265 bool GetPcAppInpadSpecificSystemBarInvisible() const; 266 void SetPcAppInpadOrientationLandscape(bool isPcAppInpadOrientationLandscape); 267 bool GetPcAppInpadOrientationLandscape() const; 268 269 /* 270 * Window Lifecycle 271 */ 272 void SetUseControlState(bool isUseControlState); 273 bool GetUseControlState() const; 274 void SetAncoRealBundleName(const std::string& ancoRealBundleName); 275 std::string GetAncoRealBundleName() const; 276 277 /* 278 * UIExtension 279 */ 280 void SetRealParentId(int32_t realParentId); 281 int32_t GetRealParentId() const; 282 void SetUIExtensionUsage(UIExtensionUsage uiExtensionUsage); 283 UIExtensionUsage GetUIExtensionUsage() const; 284 void SetIsUIExtFirstSubWindow(bool isUIExtFirstSubWindow); 285 bool GetIsUIExtFirstSubWindow() const; 286 void SetIsUIExtensionAbilityProcess(bool isUIExtensionAbilityProcess); 287 bool GetIsUIExtensionAbilityProcess() const; 288 void SetParentWindowType(WindowType parentWindowType); 289 WindowType GetParentWindowType() const; 290 void SetIsUIExtAnySubWindow(bool isUIExtAnySubWindow); 291 bool GetIsUIExtAnySubWindow() const; 292 void SetConstrainedModal(bool isConstrainedModal); 293 bool IsConstrainedModal() const; 294 295 /* 296 * Multi Instance 297 */ 298 void SetAppInstanceKey(const std::string& appInstanceKey); 299 std::string GetAppInstanceKey() const; 300 301 /* 302 * PC Window 303 */ 304 void SetSupportedWindowModes(const std::vector<AppExecFwk::SupportWindowMode>& supportedWindowModes); 305 void GetSupportedWindowModes(std::vector<AppExecFwk::SupportWindowMode>& supportedWindowModes) const; 306 void SetWindowDelayRaiseEnabled(bool isEnabled); 307 bool IsWindowDelayRaiseEnabled() const; 308 void SetWindowSizeLimits(const WindowSizeLimits& windowSizeLimits); 309 WindowSizeLimits GetWindowSizeLimits() const; 310 void SetIsFullScreenWaterfallMode(bool isFullScreenWaterfallMode); 311 bool GetIsFullScreenWaterfallMode() const; 312 313 /* 314 * Compatible mode 315 */ 316 sptr<CompatibleModeProperty> GetCompatibleModeProperty() const; 317 void SetCompatibleModeProperty(const sptr<CompatibleModeProperty> property); 318 bool IsAdaptToImmersive() const; 319 bool IsAdaptToEventMapping() const; 320 bool IsAdaptToProportionalScale() const; 321 bool IsAdaptToBackButton() const; 322 bool IsAdaptToDragScale() const; 323 bool IsDragResizeDisabled() const; 324 bool IsResizeWithDpiDisabled() const; 325 bool IsFullScreenDisabled() const; 326 bool IsSplitDisabled() const; 327 bool IsWindowLimitDisabled() const; 328 bool IsDecorFullscreenDisabled() const; 329 bool IsSupportRotateFullScreen() const; 330 bool IsAdaptToSubWindow() const; 331 bool IsAdaptToSimulationScale() const; 332 333 /* 334 * Keyboard 335 */ 336 void SetIsSystemKeyboard(bool isSystemKeyboard); 337 bool IsSystemKeyboard() const; 338 void SetKeyboardEffectOption(const KeyboardEffectOption& effectOption); 339 KeyboardEffectOption GetKeyboardEffectOption() const; 340 mutable std::mutex keyboardMutex_; 341 342 /* 343 * Window focus 344 */ 345 bool GetFocusable() const; 346 bool GetFocusableOnShow() const; 347 bool GetExclusivelyHighlighted() const; 348 void SetExclusivelyHighlighted(bool isExclusivelyHighlighted); 349 mutable std::mutex windowMaskMutex_; 350 351 private: 352 void setTouchHotAreasInner(const std::vector<Rect>& rects, std::vector<Rect>& touchHotAreas); 353 bool MarshallingTouchHotAreasInner(const std::vector<Rect>& touchHotAreas, Parcel& parcel) const; 354 bool MarshallingTouchHotAreas(Parcel& parcel) const; 355 bool MarshallingKeyboardTouchHotAreas(Parcel& parcel) const; 356 static void UnmarshallingTouchHotAreasInner(Parcel& parcel, std::vector<Rect>& touchHotAreas); 357 static void UnmarshallingTouchHotAreas(Parcel& parcel, WindowSessionProperty* property); 358 static void UnmarshallingKeyboardTouchHotAreas(Parcel& parcel, WindowSessionProperty* property); 359 bool WriteActionUpdateTurnScreenOn(Parcel& parcel); 360 bool WriteActionUpdateKeepScreenOn(Parcel& parcel); 361 bool WriteActionUpdateViewKeepScreenOn(Parcel& parcel); 362 bool WriteActionUpdateWindowShadowEnabled(Parcel& parcel); 363 bool WriteActionUpdateFocusable(Parcel& parcel); 364 bool WriteActionUpdateTouchable(Parcel& parcel); 365 bool WriteActionUpdateSetBrightness(Parcel& parcel); 366 bool WriteActionUpdateOrientation(Parcel& parcel); 367 bool WriteActionUpdatePrivacyMode(Parcel& parcel); 368 bool WriteActionUpdateSnapshotSkip(Parcel& parcel); 369 bool WriteActionUpdateMaximizeState(Parcel& parcel); 370 bool WriteActionUpdateSystemBar(Parcel& parcel); 371 bool WriteActionUpdateFlags(Parcel& parcel); 372 bool WriteActionUpdateMode(Parcel& parcel); 373 bool WriteActionUpdateAnimationFlag(Parcel& parcel); 374 bool WriteActionUpdateTouchHotArea(Parcel& parcel); 375 bool WriteActionUpdateKeyboardTouchHotArea(Parcel& parcel); 376 bool WriteActionUpdateDecorEnable(Parcel& parcel); 377 bool WriteActionUpdateWindowLimits(Parcel& parcel); 378 bool WriteActionUpdateDragenabled(Parcel& parcel); 379 bool WriteActionUpdateRaiseenabled(Parcel& parcel); 380 bool WriteActionUpdateHideNonSystemFloatingWindows(Parcel& parcel); 381 bool WriteActionUpdateTextfieldAvoidInfo(Parcel& parcel); 382 bool WriteActionUpdateWindowMask(Parcel& parcel); 383 bool WriteActionUpdateTopmost(Parcel& parcel); 384 bool WriteActionUpdateMainWindowTopmost(Parcel& parcel); 385 bool WriteActionUpdateSubWindowZLevel(Parcel& parcel); 386 bool WriteActionUpdateWindowModeSupportType(Parcel& parcel); 387 bool WriteActionUpdateAvoidAreaOption(Parcel& parcel); 388 bool WriteActionUpdateBackgroundAlpha(Parcel& parcel); 389 bool WriteActionUpdateExclusivelyHighlighted(Parcel& parcel); 390 bool WriteActionUpdateFollowScreenChange(Parcel& parcel); 391 void ReadActionUpdateTurnScreenOn(Parcel& parcel); 392 void ReadActionUpdateKeepScreenOn(Parcel& parcel); 393 void ReadActionUpdateViewKeepScreenOn(Parcel& parcel); 394 void ReadActionUpdateWindowShadowEnabled(Parcel& parcel); 395 void ReadActionUpdateFocusable(Parcel& parcel); 396 void ReadActionUpdateTouchable(Parcel& parcel); 397 void ReadActionUpdateSetBrightness(Parcel& parcel); 398 void ReadActionUpdateOrientation(Parcel& parcel); 399 void ReadActionUpdatePrivacyMode(Parcel& parcel); 400 void ReadActionUpdateSnapshotSkip(Parcel& parcel); 401 void ReadActionUpdateMaximizeState(Parcel& parcel); 402 void ReadActionUpdateSystemBar(Parcel& parcel); 403 void ReadActionUpdateFlags(Parcel& parcel); 404 void ReadActionUpdateMode(Parcel& parcel); 405 void ReadActionUpdateAnimationFlag(Parcel& parcel); 406 void ReadActionUpdateTouchHotArea(Parcel& parcel); 407 void ReadActionUpdateKeyboardTouchHotArea(Parcel& parcel); 408 void ReadActionUpdateDecorEnable(Parcel& parcel); 409 void ReadActionUpdateWindowLimits(Parcel& parcel); 410 void ReadActionUpdateDragenabled(Parcel& parcel); 411 void ReadActionUpdateRaiseenabled(Parcel& parcel); 412 void ReadActionUpdateHideNonSystemFloatingWindows(Parcel& parcel); 413 void ReadActionUpdateTextfieldAvoidInfo(Parcel& parcel); 414 void ReadActionUpdateWindowMask(Parcel& parcel); 415 void ReadActionUpdateTopmost(Parcel& parcel); 416 void ReadActionUpdateMainWindowTopmost(Parcel& parcel); 417 void ReadActionUpdateSubWindowZLevel(Parcel& parcel); 418 void ReadActionUpdateWindowModeSupportType(Parcel& parcel); 419 void ReadActionUpdateAvoidAreaOption(Parcel& parcel); 420 void ReadActionUpdateBackgroundAlpha(Parcel& parcel); 421 void ReadActionUpdateExclusivelyHighlighted(Parcel& parcel); 422 void ReadActionUpdateFollowScreenChange(Parcel& parcel); 423 std::string windowName_; 424 SessionInfo sessionInfo_; 425 mutable std::mutex windowRectMutex_; 426 Rect windowRect_ { 0, 0, 0, 0 }; // actual window rect 427 mutable std::mutex requestRectMutex_; 428 Rect requestRect_ { 0, 0, 0, 0 }; // window rect requested by the client (without decoration size) 429 mutable std::mutex rectAnimationConfigMutex_; 430 RectAnimationConfig rectAnimationConfig_ { 0, 0.0f, 0.0f, 0.0f, 0.0f }; 431 WindowType type_ { WindowType::WINDOW_TYPE_APP_MAIN_WINDOW }; // type main window 432 bool touchable_ { true }; 433 bool dragEnabled_ = { true }; 434 bool raiseEnabled_ = { true }; 435 bool isSystemCalling_ = { false }; 436 bool tokenState_ { false }; 437 bool turnScreenOn_ = false; 438 bool keepScreenOn_ = false; 439 bool viewKeepScreenOn_ = false; 440 bool windowShadowEnabled_ { true }; 441 bool topmost_ = false; 442 bool mainWindowTopmost_ = false; 443 Orientation requestedOrientation_ = Orientation::UNSPECIFIED; 444 bool needRotateAnimation_ = true; 445 Orientation defaultRequestedOrientation_ = Orientation::UNSPECIFIED; // only accessed on SSM thread 446 Orientation userRequestedOrientation_ = Orientation::UNSPECIFIED; 447 bool isPrivacyMode_ { false }; 448 bool isSystemPrivacyMode_ { false }; 449 bool isSnapshotSkip_ { false }; 450 bool isFollowScreenChange_ { false }; 451 float brightness_ = UNDEFINED_BRIGHTNESS; 452 uint64_t displayId_ = 0; 453 bool isFollowParentWindowDisplayId_ = false; 454 int32_t parentId_ = INVALID_SESSION_ID; // parentId of sceneSession, which is low 32 bite of parentPersistentId_ 455 uint32_t flags_ = 0; 456 int32_t persistentId_ = INVALID_SESSION_ID; 457 int32_t parentPersistentId_ = INVALID_SESSION_ID; 458 uint32_t accessTokenId_ = INVALID_SESSION_ID; 459 MaximizeMode maximizeMode_ = MaximizeMode::MODE_RECOVER; 460 WindowMode windowMode_ = WindowMode::WINDOW_MODE_FULLSCREEN; 461 WindowState windowState_ = WindowState::STATE_INITIAL; 462 WindowLimits limits_; 463 WindowLimits userLimits_; 464 WindowLimits configLimitsVP_; 465 float lastVpr_ = 0.0f; 466 PiPTemplateInfo pipTemplateInfo_ = {}; 467 FloatingBallTemplateInfo fbTemplateInfo_ = {}; 468 KeyboardLayoutParams keyboardLayoutParams_; 469 uint32_t windowModeSupportType_ {WindowModeSupport::WINDOW_MODE_SUPPORT_ALL}; 470 std::unordered_map<WindowType, SystemBarProperty> sysBarPropMap_ { 471 { WindowType::WINDOW_TYPE_STATUS_BAR, SystemBarProperty(true, 0x00FFFFFF, 0xFF000000) }, 472 { WindowType::WINDOW_TYPE_NAVIGATION_BAR, SystemBarProperty(true, 0x00FFFFFF, 0xFF000000) }, 473 { WindowType::WINDOW_TYPE_NAVIGATION_INDICATOR, SystemBarProperty(true, 0x00FFFFFF, 0xFF000000) }, 474 }; 475 bool isDecorEnable_ = false; 476 uint32_t animationFlag_ { static_cast<uint32_t>(WindowAnimation::DEFAULT) }; 477 // Transform info 478 Transform trans_; 479 bool isFloatingWindowAppType_ = false; 480 mutable std::mutex touchHotAreasMutex_; 481 std::vector<Rect> touchHotAreas_; // coordinates relative to window. 482 KeyboardTouchHotAreas keyboardTouchHotAreas_; // coordinates relative to window. 483 bool hideNonSystemFloatingWindows_ = false; 484 bool isSkipSelfWhenShowOnVirtualScreen_ = false; 485 bool isSkipEventOnCastPlus_ = false; 486 bool forceHide_ = false; 487 bool keepKeyboardFlag_ = false; 488 uint32_t callingSessionId_ = INVALID_SESSION_ID; 489 490 double textFieldPositionY_ = 0.0; 491 double textFieldHeight_ = 0.0; 492 bool isNeedUpdateWindowMode_ = false; 493 std::function<void()> touchHotAreasChangeCallback_; 494 bool isLayoutFullScreen_ = false; 495 496 bool isShaped_ = false; 497 bool fullScreenStart_ = false; 498 std::shared_ptr<Media::PixelMap> windowMask_ = nullptr; 499 int32_t collaboratorType_ = CollaboratorType::DEFAULT_TYPE; 500 static const std::map<uint64_t, HandlWritePropertyFunc> writeFuncMap_; 501 static const std::map<uint64_t, HandlReadPropertyFunc> readFuncMap_; 502 bool isAppSupportPhoneInPc_ = false; 503 bool isPcAppInLargeScreenDevice_ = false; 504 mutable std::mutex compatibleModeMutex_; 505 uint8_t backgroundAlpha_ = 0xff; // default alpha is opaque. 506 mutable std::mutex atomicServiceMutex_; 507 bool isAtomicService_ = false; 508 uint32_t apiVersion_ = 0; 509 bool isAbilityHookOff_ = false; 510 bool isAbilityHook_ = false; 511 512 /* 513 * Sub Window 514 */ 515 uint32_t subWindowLevel_ = 0; 516 bool subWindowOutlineEnabled_ = false; 517 WindowAnchorInfo windowAnchorInfo_; 518 519 /* 520 * Window Hierarchy 521 */ 522 int32_t zLevel_ = 0; 523 int32_t zIndex_ = SPECIFIC_ZINDEX_INVALID; 524 525 /* 526 * UIExtension 527 */ 528 int32_t realParentId_ = INVALID_SESSION_ID; 529 UIExtensionUsage uiExtensionUsage_ { UIExtensionUsage::EMBEDDED }; 530 bool isUIExtFirstSubWindow_ = false; 531 bool isUIExtensionAbilityProcess_ = false; 532 bool isUIExtAnySubWindow_ = false; 533 WindowType parentWindowType_ = WindowType::WINDOW_TYPE_APP_MAIN_WINDOW; 534 bool isConstrainedModal_ = false; 535 536 /* 537 * Multi Instance 538 */ 539 std::string appInstanceKey_; 540 541 /* 542 * PC Window 543 */ 544 mutable std::mutex supportWindowModesMutex_; 545 std::vector<AppExecFwk::SupportWindowMode> supportedWindowModes_; 546 bool isWindowDelayRaiseEnabled_ = false; 547 WindowSizeLimits windowSizeLimits_; 548 bool isFullScreenWaterfallMode_ = false; 549 550 /* 551 * Keyboard 552 */ 553 bool isSystemKeyboard_ = false; 554 KeyboardEffectOption keyboardEffectOption_; 555 556 /* 557 * Window Immersive 558 */ 559 uint32_t avoidAreaOption_ = 0; 560 561 /* 562 * Window Focus 563 */ 564 bool focusable_ { true }; 565 bool focusableOnShow_ { true }; 566 bool isExclusivelyHighlighted_ { true }; 567 568 /* 569 * Window Lifecycle 570 */ 571 mutable std::mutex lifecycleUseControlMutex_; 572 bool isUseControlState_ = false; 573 std::string ancoRealBundleName_ = ""; 574 575 /* 576 * Window Property 577 */ 578 float cornerRadius_ = WINDOW_CORNER_RADIUS_INVALID; // corner radius of window set by application 579 mutable std::mutex cornerRadiusMutex_; 580 ShadowsInfo shadowsInfo_; 581 mutable std::mutex shadowsInfoMutex_; 582 mutable std::mutex globalDisplayRectMutex_; 583 Rect globalDisplayRect_ { 0, 0, 0, 0 }; 584 bool isPcAppInpadCompatibleMode_ = false; 585 bool isPcAppInpadSpecificSystemBarInvisible_ = false; 586 bool isPcAppInpadOrientationLandscape_ = false; 587 588 sptr<CompatibleModeProperty> compatibleModeProperty_ = nullptr; 589 590 /** 591 * Window Transition Animation For PC 592 */ 593 std::unordered_map<WindowTransitionType, std::shared_ptr<TransitionAnimation>> transitionAnimationConfig_; 594 }; 595 596 class CompatibleModeProperty : public Parcelable { 597 public: 598 void SetIsAdaptToImmersive(bool isAdaptToImmersive); 599 bool IsAdaptToImmersive() const; 600 601 void SetIsAdaptToEventMapping(bool isAdaptToEventMapping); 602 bool IsAdaptToEventMapping() const; 603 604 void SetIsAdaptToProportionalScale(bool isAdaptToProportionalScale); 605 bool IsAdaptToProportionalScale() const; 606 607 void SetIsAdaptToBackButton(bool isAdaptToBackButton); 608 bool IsAdaptToBackButton() const; 609 610 void SetIsAdaptToDragScale(bool isAdaptToDragScale); 611 bool IsAdaptToDragScale() const; 612 613 void SetDisableDragResize(bool disableDragResize); 614 bool IsDragResizeDisabled() const; 615 616 void SetDisableResizeWithDpi(bool disableResizeWithDpi); 617 bool IsResizeWithDpiDisabled() const; 618 619 void SetDisableFullScreen(bool setDisableFullScreen); 620 bool IsFullScreenDisabled() const; 621 622 void SetDisableSplit(bool disableSplit); 623 bool IsSplitDisabled() const; 624 625 void SetDisableWindowLimit(bool disableWindowLimit); 626 bool IsWindowLimitDisabled() const; 627 628 void SetDisableDecorFullscreen(bool disableDecorFullscreen); 629 bool IsDecorFullscreenDisabled() const; 630 631 void SetIsSupportRotateFullScreen(bool isSupportRotateFullScreen); 632 bool IsSupportRotateFullScreen() const; 633 634 void SetIsAdaptToSubWindow(bool isAdaptToSubWindow); 635 bool IsAdaptToSubWindow() const; 636 637 void SetIsAdaptToSimulationScale(bool isAdaptToSimulationScale); 638 bool IsAdaptToSimulationScale() const; 639 640 bool Marshalling(Parcel& parcel) const override; 641 static CompatibleModeProperty* Unmarshalling(Parcel& parcel); 642 643 void CopyFrom(const sptr<CompatibleModeProperty>& property); 644 ToString()645 std::string ToString() const 646 { 647 std::stringstream ss; 648 ss << "isAdaptToImmersive_:" << isAdaptToImmersive_ << " "; 649 ss << "isAdaptToEventMapping_:" << isAdaptToEventMapping_ << " "; 650 ss << "isAdaptToProportionalScale_:" << isAdaptToProportionalScale_ << " "; 651 ss << "isAdaptToBackButton_:" << isAdaptToBackButton_<< " "; 652 ss << "isAdaptToDragScale_:" << isAdaptToDragScale_<< " "; 653 ss << "disableDragResize_:" << disableDragResize_<< " "; 654 ss << "disableResizeWithDpi_:" << disableResizeWithDpi_<< " "; 655 ss << "disableFullScreen_:" << disableFullScreen_<< " "; 656 ss << "disableWindowLimit_:" << disableWindowLimit_<< " "; 657 ss << "disableDecorFullscreen_:" << disableDecorFullscreen_<< " "; 658 ss << "isSupportRotateFullScreen_:" << isSupportRotateFullScreen_ << " "; 659 ss << "isAdaptToSubWindow_:" << isAdaptToSubWindow_ << " "; 660 ss << "isAdaptToSimulationScale_:" << isAdaptToSimulationScale_ << " "; 661 return ss.str(); 662 } 663 664 private: 665 bool isAdaptToImmersive_ { false }; 666 bool isAdaptToEventMapping_ { false }; 667 bool isAdaptToProportionalScale_ { false }; 668 bool isAdaptToBackButton_ { false }; 669 bool isAdaptToDragScale_ { false }; 670 bool disableDragResize_ { false }; 671 bool disableResizeWithDpi_ { false }; 672 bool disableFullScreen_ { false }; 673 bool disableSplit_ { false }; 674 bool disableWindowLimit_ { false }; 675 bool disableDecorFullscreen_ { false }; 676 bool isSupportRotateFullScreen_ { false }; 677 bool isAdaptToSubWindow_ { false }; 678 bool isAdaptToSimulationScale_ { false }; 679 }; 680 681 struct FreeMultiWindowConfig : public Parcelable { 682 bool isSystemDecorEnable_ = true; 683 uint32_t decorWindowModeSupportType_ = WindowModeSupport::WINDOW_MODE_SUPPORT_ALL; 684 WindowMode defaultWindowMode_ = WindowMode::WINDOW_MODE_FULLSCREEN; 685 uint32_t maxMainFloatingWindowNumber_ = 0; 686 DragResizeType defaultDragResizeType_ = DragResizeType::RESIZE_TYPE_UNDEFINED; 687 MarshallingFreeMultiWindowConfig688 virtual bool Marshalling(Parcel& parcel) const override 689 { 690 if (!parcel.WriteBool(isSystemDecorEnable_) || 691 !parcel.WriteUint32(decorWindowModeSupportType_)) { 692 return false; 693 } 694 695 if (!parcel.WriteUint32(static_cast<uint32_t>(defaultWindowMode_)) || 696 !parcel.WriteUint32(maxMainFloatingWindowNumber_) || 697 !parcel.WriteUint32(static_cast<uint32_t>(defaultDragResizeType_))) { 698 return false; 699 } 700 return true; 701 } 702 UnmarshallingFreeMultiWindowConfig703 static FreeMultiWindowConfig* Unmarshalling(Parcel& parcel) 704 { 705 FreeMultiWindowConfig* config = new (std::nothrow) FreeMultiWindowConfig(); 706 if (config == nullptr) { 707 return nullptr; 708 } 709 config->isSystemDecorEnable_ = parcel.ReadBool(); 710 config->decorWindowModeSupportType_ = parcel.ReadUint32(); 711 config->defaultWindowMode_ = static_cast<WindowMode>(parcel.ReadUint32()); 712 config->maxMainFloatingWindowNumber_ = parcel.ReadUint32(); 713 uint32_t dragResizeType = parcel.ReadUint32(); 714 if (dragResizeType >= static_cast<uint32_t>(DragResizeType::RESIZE_MAX_VALUE)) { 715 delete config; 716 return nullptr; 717 } 718 config->defaultDragResizeType_ = static_cast<DragResizeType>(dragResizeType); 719 return config; 720 } 721 }; 722 723 struct AppForceLandscapeConfig : public Parcelable { 724 int32_t mode_ = 0; 725 std::string homePage_ = ""; 726 int32_t supportSplit_ = -1; 727 std::string arkUIOptions_ = ""; 728 AppForceLandscapeConfigAppForceLandscapeConfig729 AppForceLandscapeConfig() {} AppForceLandscapeConfigAppForceLandscapeConfig730 AppForceLandscapeConfig(int32_t mode, const std::string& homePage, int32_t supportSplit, 731 const std::string& arkUIOptions) : mode_(mode), homePage_(homePage), supportSplit_(supportSplit), 732 arkUIOptions_(arkUIOptions) {} 733 MarshallingAppForceLandscapeConfig734 virtual bool Marshalling(Parcel& parcel) const override 735 { 736 if (!parcel.WriteInt32(mode_) || 737 !parcel.WriteString(homePage_) || 738 !parcel.WriteInt32(supportSplit_) || 739 !parcel.WriteString(arkUIOptions_)) { 740 return false; 741 } 742 return true; 743 } 744 UnmarshallingAppForceLandscapeConfig745 static AppForceLandscapeConfig* Unmarshalling(Parcel& parcel) 746 { 747 std::unique_ptr<AppForceLandscapeConfig> config = std::make_unique<AppForceLandscapeConfig>(); 748 if (config == nullptr) { 749 return nullptr; 750 } 751 if (!parcel.ReadInt32(config->mode_) || 752 !parcel.ReadString(config->homePage_) || 753 !parcel.ReadInt32(config->supportSplit_) || 754 !parcel.ReadString(config->arkUIOptions_)) { 755 return nullptr; 756 } 757 return config.release(); 758 } 759 }; 760 761 struct SystemSessionConfig : public Parcelable { 762 bool isSystemDecorEnable_ = true; 763 uint32_t decorWindowModeSupportType_ = WindowModeSupport::WINDOW_MODE_SUPPORT_ALL; 764 bool isStretchable_ = false; 765 WindowMode defaultWindowMode_ = WindowMode::WINDOW_MODE_FULLSCREEN; 766 KeyboardAnimationCurve animationIn_; 767 KeyboardAnimationCurve animationOut_; 768 // 1920: default max window size 769 uint32_t maxFloatingWindowSize_ = 1920; 770 // 320: default minWidth main window size 771 uint32_t miniWidthOfMainWindow_ = 320; 772 // 240: default minHeight main window size 773 uint32_t miniHeightOfMainWindow_ = 240; 774 // 320: default minWidth sub window size 775 uint32_t miniWidthOfSubWindow_ = 320; 776 // 240: default minHeight sub window size 777 uint32_t miniHeightOfSubWindow_ = 240; 778 // 320: default minWidth dialog window size 779 uint32_t miniWidthOfDialogWindow_ = 320; 780 // 240: default minHeight dialog window size 781 uint32_t miniHeightOfDialogWindow_ = 240; 782 bool backgroundswitch = false; 783 bool freeMultiWindowEnable_ = false; 784 bool freeMultiWindowSupport_ = false; 785 FreeMultiWindowConfig freeMultiWindowConfig_; 786 WindowUIType windowUIType_ = WindowUIType::INVALID_WINDOW; 787 bool supportTypeFloatWindow_ = false; 788 // 4: default max mid scene num 789 uint32_t maxMidSceneNum_ = 4; 790 // Product configuration 791 bool supportFollowParentWindowLayout_ = false; 792 bool supportFollowRelativePositionToParent_ = false; 793 bool supportZLevel_ = false; 794 bool skipRedundantWindowStatusNotifications_ = false; 795 uint32_t supportFunctionType_ = 0; 796 bool supportSnapshotAllSessionStatus_ = false; 797 bool supportCreateFloatWindow_ = false; 798 float defaultCornerRadius_ = 0.0f; // default corner radius of window set by system config 799 MarshallingSystemSessionConfig800 virtual bool Marshalling(Parcel& parcel) const override 801 { 802 if (!parcel.WriteBool(isSystemDecorEnable_) || !parcel.WriteBool(isStretchable_) || 803 !parcel.WriteUint32(decorWindowModeSupportType_)) { 804 return false; 805 } 806 807 if (!parcel.WriteUint32(static_cast<uint32_t>(defaultWindowMode_)) || 808 !parcel.WriteParcelable(&animationIn_) || !parcel.WriteParcelable(&animationOut_) || 809 !parcel.WriteUint32(maxFloatingWindowSize_)) { 810 return false; 811 } 812 813 if (!parcel.WriteUint32(miniWidthOfMainWindow_) || !parcel.WriteUint32(miniHeightOfMainWindow_) || 814 !parcel.WriteUint32(miniWidthOfSubWindow_) || !parcel.WriteUint32(miniHeightOfSubWindow_) || 815 !parcel.WriteUint32(miniWidthOfDialogWindow_) || !parcel.WriteUint32(miniHeightOfDialogWindow_)) { 816 return false; 817 } 818 819 if (!parcel.WriteBool(backgroundswitch)) { 820 return false; 821 } 822 823 if (!parcel.WriteBool(freeMultiWindowEnable_)) { 824 return false; 825 } 826 827 if (!parcel.WriteBool(freeMultiWindowSupport_)) { 828 return false; 829 } 830 if (!parcel.WriteParcelable(&freeMultiWindowConfig_)) { 831 return false; 832 } 833 if (!parcel.WriteUint8(static_cast<uint8_t>(windowUIType_))) { 834 return false; 835 } 836 if (!parcel.WriteBool(supportTypeFloatWindow_)) { 837 return false; 838 } 839 if (!parcel.WriteBool(maxMidSceneNum_)) { 840 return false; 841 } 842 if (!parcel.WriteBool(supportFollowParentWindowLayout_)) { 843 return false; 844 } 845 if (!parcel.WriteBool(supportFollowRelativePositionToParent_)) { 846 return false; 847 } 848 if (!parcel.WriteBool(supportZLevel_) || 849 !parcel.WriteBool(skipRedundantWindowStatusNotifications_) || !parcel.WriteUint32(supportFunctionType_)) { 850 return false; 851 } 852 if (!parcel.WriteBool(supportSnapshotAllSessionStatus_)) { 853 return false; 854 } 855 if (!parcel.WriteFloat(defaultCornerRadius_)) { 856 return false; 857 } 858 return true; 859 } 860 UnmarshallingSystemSessionConfig861 static SystemSessionConfig* Unmarshalling(Parcel& parcel) 862 { 863 SystemSessionConfig* config = new (std::nothrow) SystemSessionConfig(); 864 if (config == nullptr) { 865 return nullptr; 866 } 867 config->isSystemDecorEnable_ = parcel.ReadBool(); 868 config->isStretchable_ = parcel.ReadBool(); 869 config->decorWindowModeSupportType_ = parcel.ReadUint32(); 870 config->defaultWindowMode_ = static_cast<WindowMode>(parcel.ReadUint32()); 871 sptr<KeyboardAnimationCurve> animationIn = parcel.ReadParcelable<KeyboardAnimationCurve>(); 872 if (animationIn == nullptr) { 873 delete config; 874 return nullptr; 875 } 876 config->animationIn_ = *animationIn; 877 sptr<KeyboardAnimationCurve> animationOut = parcel.ReadParcelable<KeyboardAnimationCurve>(); 878 if (animationOut == nullptr) { 879 delete config; 880 return nullptr; 881 } 882 config->animationOut_ = *animationOut; 883 config->maxFloatingWindowSize_ = parcel.ReadUint32(); 884 config->miniWidthOfMainWindow_ = parcel.ReadUint32(); 885 config->miniHeightOfMainWindow_ = parcel.ReadUint32(); 886 config->miniWidthOfSubWindow_ = parcel.ReadUint32(); 887 config->miniHeightOfSubWindow_ = parcel.ReadUint32(); 888 config->miniWidthOfDialogWindow_ = parcel.ReadUint32(); 889 config->miniHeightOfDialogWindow_ = parcel.ReadUint32(); 890 config->backgroundswitch = parcel.ReadBool(); 891 config->freeMultiWindowEnable_ = parcel.ReadBool(); 892 config->freeMultiWindowSupport_ = parcel.ReadBool(); 893 sptr<FreeMultiWindowConfig> freeMultiWindowConfig = parcel.ReadParcelable<FreeMultiWindowConfig>(); 894 if (freeMultiWindowConfig == nullptr) { 895 delete config; 896 return nullptr; 897 } 898 config->freeMultiWindowConfig_ = *freeMultiWindowConfig; 899 config->windowUIType_ = static_cast<WindowUIType>(parcel.ReadUint8()); 900 config->supportTypeFloatWindow_ = parcel.ReadBool(); 901 config->maxMidSceneNum_ = parcel.ReadUint32(); 902 config->supportFollowParentWindowLayout_ = parcel.ReadBool(); 903 config->supportFollowRelativePositionToParent_ = parcel.ReadBool(); 904 config->supportZLevel_ = parcel.ReadBool(); 905 config->skipRedundantWindowStatusNotifications_ = parcel.ReadBool(); 906 config->supportFunctionType_ = parcel.ReadUint32(); 907 config->supportSnapshotAllSessionStatus_ = parcel.ReadBool(); 908 if (!parcel.ReadFloat(config->defaultCornerRadius_)) { 909 delete config; 910 return nullptr; 911 } 912 return config; 913 } 914 IsFreeMultiWindowModeSystemSessionConfig915 bool IsFreeMultiWindowMode() const 916 { 917 return freeMultiWindowEnable_ && freeMultiWindowSupport_; 918 } 919 IsPhoneWindowSystemSessionConfig920 bool IsPhoneWindow() const 921 { 922 return windowUIType_ == WindowUIType::PHONE_WINDOW; 923 } 924 IsPcWindowSystemSessionConfig925 bool IsPcWindow() const 926 { 927 return windowUIType_ == WindowUIType::PC_WINDOW; 928 } 929 IsPadWindowSystemSessionConfig930 bool IsPadWindow() const 931 { 932 return windowUIType_ == WindowUIType::PAD_WINDOW; 933 } 934 IsPcOrPcModeSystemSessionConfig935 bool IsPcOrPcMode() const 936 { 937 return IsPcWindow() || (IsPadWindow() && IsFreeMultiWindowMode()); 938 } 939 }; 940 } // namespace Rosen 941 } // namespace OHOS 942 #endif // OHOS_ROSEN_WINDOW_PROPERTY_H 943