• 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_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 
30 namespace OHOS {
31 namespace Rosen {
32 class WindowSessionProperty;
33 using HandlWritePropertyFunc = bool (WindowSessionProperty::*)(Parcel& parcel);
34 using HandlReadPropertyFunc = void (WindowSessionProperty::*)(Parcel& parcel);
35 
36 class WindowSessionProperty : public Parcelable {
37 public:
38     friend class HidumpController;
39     WindowSessionProperty() = default;
40     ~WindowSessionProperty() = default;
41     explicit WindowSessionProperty(const sptr<WindowSessionProperty>& property);
42     void CopyFrom(const sptr<WindowSessionProperty>& property);
43     void SetWindowName(const std::string& name);
44     void SetSessionInfo(const SessionInfo& info);
45     void SetRequestRect(const struct Rect& rect);
46     void SetRectAnimationConfig(const RectAnimationConfig& rectAnimationConfig);
47     void SetWindowRect(const struct Rect& rect);
48     void SetFocusable(bool isFocusable);
49     void SetFocusableOnShow(bool isFocusableOnShow);
50     void SetTouchable(bool isTouchable);
51     void SetDragEnabled(bool dragEnabled);
52     void SetHideNonSystemFloatingWindows(bool hide);
53     void SetForceHide(bool hide);
54     void SetRaiseEnabled(bool raiseEnabled);
55     void SetSystemCalling(bool isSystemCalling);
56     void SetTurnScreenOn(bool turnScreenOn);
57     void SetKeepScreenOn(bool keepScreenOn);
58     void SetViewKeepScreenOn(bool keepScreenOn);
59     void SetRequestedOrientation(Orientation orientation);
60     void SetDefaultRequestedOrientation(Orientation orientation);
61     void SetPrivacyMode(bool isPrivate);
62     void SetSystemPrivacyMode(bool isSystemPrivate);
63     void SetSnapshotSkip(bool isSkip);
64     void SetBrightness(float brightness);
65     void SetDisplayId(uint64_t displayId);
66     void SetWindowType(WindowType type);
67     void SetParentId(int32_t parentId);
68     void SetPersistentId(int32_t persistentId);
69     void SetParentPersistentId(int32_t persistentId);
70     void SetAccessTokenId(uint32_t accessTokenId);
71     void SetTokenState(bool hasToken);
72     void SetMaximizeMode(MaximizeMode mode);
73     void SetWindowMode(WindowMode mode);
74     void SetWindowLimits(const WindowLimits& windowLimits);
75     void SetUserWindowLimits(const WindowLimits& windowLimits);
76     void SetConfigWindowLimitsVP(const WindowLimits& windowLimitsVP);
77     void SetLastLimitsVpr(float vpr);
78     void SetSystemBarProperty(WindowType type, const SystemBarProperty& property);
79     void SetKeyboardLayoutParams(const KeyboardLayoutParams& params);
80     void SetDecorEnable(bool isDecorEnable);
81     void SetAnimationFlag(uint32_t animationFlag);
82     void SetTransform(const Transform& trans);
83     void SetWindowFlags(uint32_t flags);
84     void SetTopmost(bool topmost);
85     bool IsTopmost() const;
86     void SetMainWindowTopmost(bool isTopmost);
87     bool IsMainWindowTopmost() const;
88     void AddWindowFlag(WindowFlag flag);
89     void SetWindowModeSupportType(uint32_t windowModeSupportType);
90     void SetFloatingWindowAppType(bool isAppType);
91     void SetTouchHotAreas(const std::vector<Rect>& rects);
92     void SetKeyboardTouchHotAreas(const KeyboardTouchHotAreas& keyboardTouchHotAreas);
93     void KeepKeyboardOnFocus(bool keepKeyboardFlag);
94     void SetIsNeedUpdateWindowMode(bool isNeedUpdateWindowMode);
95     void SetCallingSessionId(uint32_t sessionId);
96     void SetPiPTemplateInfo(const PiPTemplateInfo& pipTemplateInfo);
97     void SetWindowMask(const std::shared_ptr<Media::PixelMap>& windowMask);
98     void SetIsShaped(bool isShaped);
99     void SetCompatibleModeInPc(bool compatibleModeInPc);
100     void SetCompatibleWindowSizeInPc(int32_t portraitWidth, int32_t portraitHeight,
101         int32_t landscapeWidth, int32_t landscapeHeight);
102     void SetIsAppSupportPhoneInPc(bool isSupportPhone);
103     void SetIsSupportDragInPcCompatibleMode(bool isSupportDragInPcCompatibleMode);
104     void SetIsPcAppInPad(bool isPcAppInPad);
105     void SetCompatibleModeEnableInPad(bool enable);
106     void SetIsAtomicService(bool isAtomicService);
107 
108     /*
109      * Window Immersive
110      */
111     void SetAvoidAreaOption(uint32_t avoidAreaOption);
112     uint32_t GetAvoidAreaOption() const;
113 
114     bool GetIsNeedUpdateWindowMode() const;
115     const std::string& GetWindowName() const;
116     const SessionInfo& GetSessionInfo() const;
117     SessionInfo& EditSessionInfo();
118     Rect GetWindowRect() const;
119     Rect GetRequestRect() const;
120     RectAnimationConfig GetRectAnimationConfig() const;
121     WindowType GetWindowType() const;
122     bool GetDragEnabled() const;
123     bool GetTouchable() const;
124     bool GetHideNonSystemFloatingWindows() const;
125     bool GetForceHide() const;
126     bool GetRaiseEnabled() const;
127     bool GetSystemCalling() const;
128     bool IsTurnScreenOn() const;
129     bool IsKeepScreenOn() const;
130     bool IsViewKeepScreenOn() const;
131     Orientation GetRequestedOrientation() const;
132     Orientation GetDefaultRequestedOrientation() const;
133     bool GetPrivacyMode() const;
134     bool GetSystemPrivacyMode() const;
135     bool GetSnapshotSkip() const;
136     float GetBrightness() const;
137     int32_t GetParentId() const;
138     uint32_t GetWindowFlags() const;
139     uint64_t GetDisplayId() const;
140     int32_t GetPersistentId() const;
141     int32_t GetParentPersistentId() const;
142     uint32_t GetAccessTokenId() const;
143     bool GetTokenState() const;
144     MaximizeMode GetMaximizeMode() const;
145     WindowMode GetWindowMode() const;
146     WindowLimits GetWindowLimits() const;
147     WindowLimits GetUserWindowLimits() const;
148     WindowLimits GetConfigWindowLimitsVP() const;
149     float GetLastLimitsVpr() const;
150     uint32_t GetWindowModeSupportType() const;
151     std::unordered_map<WindowType, SystemBarProperty> GetSystemBarProperty() const;
152     bool IsDecorEnable();
153     uint32_t GetAnimationFlag() const;
154     const Transform& GetTransform() const;
155     bool IsFloatingWindowAppType() const;
156     void GetTouchHotAreas(std::vector<Rect>& rects) const;
157     KeyboardTouchHotAreas GetKeyboardTouchHotAreas() const;
158     bool GetKeepKeyboardFlag() const;
159     uint32_t GetCallingSessionId() const;
160     PiPTemplateInfo GetPiPTemplateInfo() const;
161     std::shared_ptr<Media::PixelMap> GetWindowMask() const;
162     bool GetIsShaped() const;
163     KeyboardLayoutParams GetKeyboardLayoutParams() const;
164     bool GetCompatibleModeInPc() const;
165     int32_t GetCompatibleInPcPortraitWidth() const;
166     int32_t GetCompatibleInPcPortraitHeight() const;
167     int32_t GetCompatibleInPcLandscapeWidth() const;
168     int32_t GetCompatibleInPcLandscapeHeight() const;
169     bool GetIsAppSupportPhoneInPc() const;
170     bool GetIsPcAppInPad() const;
171     bool GetIsSupportDragInPcCompatibleMode() const;
172     bool GetCompatibleModeEnableInPad() const;
173     bool GetIsAtomicService() const;
174 
175     bool MarshallingWindowLimits(Parcel& parcel) const;
176     static void UnmarshallingWindowLimits(Parcel& parcel, WindowSessionProperty* property);
177     bool MarshallingSystemBarMap(Parcel& parcel) const;
178     static void UnMarshallingSystemBarMap(Parcel& parcel, WindowSessionProperty* property);
179     bool MarshallingPiPTemplateInfo(Parcel& parcel) const;
180     static void UnmarshallingPiPTemplateInfo(Parcel& parcel, WindowSessionProperty* property);
181     bool Marshalling(Parcel& parcel) const override;
182     static WindowSessionProperty* Unmarshalling(Parcel& parcel);
183     bool MarshallingWindowMask(Parcel& parcel) const;
184     static void UnmarshallingWindowMask(Parcel& parcel, WindowSessionProperty* property);
185     bool MarshallingMainWindowTopmost(Parcel& parcel) const;
186     static void UnmarshallingMainWindowTopmost(Parcel& parcel, WindowSessionProperty* property);
187     bool MarshallingSessionInfo(Parcel& parcel) const;
188     static bool UnmarshallingSessionInfo(Parcel& parcel, WindowSessionProperty* property);
189 
190     void SetTextFieldPositionY(double textFieldPositionY);
191     void SetTextFieldHeight(double textFieldHeight);
192 
193     WindowState GetWindowState() const;
194     void SetWindowState(WindowState state);
195 
196     uint8_t GetBackgroundAlpha() const;
197     void SetBackgroundAlpha(uint8_t alpha);
198 
199     double GetTextFieldPositionY() const;
200     double GetTextFieldHeight() const;
201 
202     void SetSessionPropertyChangeCallback(std::function<void()>&& callback);
203     bool IsLayoutFullScreen() const;
204     void SetIsLayoutFullScreen(bool isLayoutFullScreen);
205     int32_t GetCollaboratorType() const;
206     void SetCollaboratorType(int32_t collaboratorType);
207     bool Write(Parcel& parcel, WSPropertyChangeAction action);
208     void Read(Parcel& parcel, WSPropertyChangeAction action);
209     void SetFullScreenStart(bool fullScreenStart);
210     bool GetFullScreenStart() const;
211     void SetApiVersion(uint32_t version);
212     uint32_t GetApiVersion() const;
213 
214     /*
215      * Sub Window
216      */
217     void SetSubWindowLevel(uint32_t subWindowLevel);
218     uint32_t GetSubWindowLevel() const;
219 
220     /*
221      * Window Hierarchy
222      */
223     void SetSubWindowZLevel(int32_t zLevel);
224     int32_t GetSubWindowZLevel() const;
225 
226     /*
227      * Window Property
228      */
229     void SetWindowCornerRadius(float cornerRadius);
230     float GetWindowCornerRadius() const;
231 
232     /*
233      * UIExtension
234      */
235     void SetRealParentId(int32_t realParentId);
236     int32_t GetRealParentId() const;
237     void SetUIExtensionUsage(UIExtensionUsage uiExtensionUsage);
238     UIExtensionUsage GetUIExtensionUsage() const;
239     void SetIsUIExtFirstSubWindow(bool isUIExtFirstSubWindow);
240     bool GetIsUIExtFirstSubWindow() const;
241     void SetIsUIExtensionAbilityProcess(bool isUIExtensionAbilityProcess);
242     bool GetIsUIExtensionAbilityProcess() const;
243     void SetParentWindowType(WindowType parentWindowType);
244     WindowType GetParentWindowType() const;
245     void SetIsUIExtAnySubWindow(bool isUIExtAnySubWindow);
246     bool GetIsUIExtAnySubWindow() const;
247     void SetConstrainedModal(bool isConstrainedModal);
248     bool IsConstrainedModal() const;
249 
250     /*
251      * Multi Instance
252      */
253     void SetAppInstanceKey(const std::string& appInstanceKey);
254     std::string GetAppInstanceKey() const;
255 
256     /*
257      * PC Window
258      */
259     void SetSupportedWindowModes(const std::vector<AppExecFwk::SupportWindowMode>& supportedWindowModes);
260     void GetSupportedWindowModes(std::vector<AppExecFwk::SupportWindowMode>& supportedWindowModes) const;
261     void SetWindowDelayRaiseEnabled(bool isEnabled);
262     bool IsWindowDelayRaiseEnabled() const;
263     void SetWindowSizeLimits(const WindowSizeLimits& windowSizeLimits);
264     WindowSizeLimits GetWindowSizeLimits() const;
265     void SetIsFullScreenWaterfallMode(bool isFullScreenWaterfallMode);
266     bool GetIsFullScreenWaterfallMode() const;
267     void SetIsSaveBySpecifiedFlag(bool isSaveBySpecifiedFlag);
268     bool GetIsSaveBySpecifiedFlag() const;
269 
270     /*
271      * Keyboard
272      */
273     void SetIsSystemKeyboard(bool isSystemKeyboard);
274     bool IsSystemKeyboard() const;
275     void SetKeyboardViewMode(KeyboardViewMode mode);
276     KeyboardViewMode GetKeyboardViewMode() const;
277 
278     /*
279      * Window focus
280      */
281     bool GetFocusable() const;
282     bool GetFocusableOnShow() const;
283     bool GetExclusivelyHighlighted() const;
284     void SetExclusivelyHighlighted(bool isExclusivelyHighlighted);
285 
286 private:
287     void setTouchHotAreasInner(const std::vector<Rect>& rects, std::vector<Rect>& touchHotAreas);
288     bool MarshallingTouchHotAreasInner(const std::vector<Rect>& touchHotAreas, Parcel& parcel) const;
289     bool MarshallingTouchHotAreas(Parcel& parcel) const;
290     bool MarshallingKeyboardTouchHotAreas(Parcel& parcel) const;
291     static void UnmarshallingTouchHotAreasInner(Parcel& parcel, std::vector<Rect>& touchHotAreas);
292     static void UnmarshallingTouchHotAreas(Parcel& parcel, WindowSessionProperty* property);
293     static void UnmarshallingKeyboardTouchHotAreas(Parcel& parcel, WindowSessionProperty* property);
294     bool WriteActionUpdateTurnScreenOn(Parcel& parcel);
295     bool WriteActionUpdateKeepScreenOn(Parcel& parcel);
296     bool WriteActionUpdateViewKeepScreenOn(Parcel& parcel);
297     bool WriteActionUpdateFocusable(Parcel& parcel);
298     bool WriteActionUpdateTouchable(Parcel& parcel);
299     bool WriteActionUpdateSetBrightness(Parcel& parcel);
300     bool WriteActionUpdateOrientation(Parcel& parcel);
301     bool WriteActionUpdatePrivacyMode(Parcel& parcel);
302     bool WriteActionUpdateSnapshotSkip(Parcel& parcel);
303     bool WriteActionUpdateMaximizeState(Parcel& parcel);
304     bool WriteActionUpdateSystemBar(Parcel& parcel);
305     bool WriteActionUpdateFlags(Parcel& parcel);
306     bool WriteActionUpdateMode(Parcel& parcel);
307     bool WriteActionUpdateAnimationFlag(Parcel& parcel);
308     bool WriteActionUpdateTouchHotArea(Parcel& parcel);
309     bool WriteActionUpdateKeyboardTouchHotArea(Parcel& parcel);
310     bool WriteActionUpdateDecorEnable(Parcel& parcel);
311     bool WriteActionUpdateWindowLimits(Parcel& parcel);
312     bool WriteActionUpdateDragenabled(Parcel& parcel);
313     bool WriteActionUpdateRaiseenabled(Parcel& parcel);
314     bool WriteActionUpdateHideNonSystemFloatingWindows(Parcel& parcel);
315     bool WriteActionUpdateTextfieldAvoidInfo(Parcel& parcel);
316     bool WriteActionUpdateWindowMask(Parcel& parcel);
317     bool WriteActionUpdateTopmost(Parcel& parcel);
318     bool WriteActionUpdateMainWindowTopmost(Parcel& parcel);
319     bool WriteActionUpdateSubWindowZLevel(Parcel& parcel);
320     bool WriteActionUpdateWindowModeSupportType(Parcel& parcel);
321     bool WriteActionUpdateAvoidAreaOption(Parcel& parcel);
322     bool WriteActionUpdateBackgroundAlpha(Parcel& parcel);
323     bool WriteActionUpdateExclusivelyHighlighted(Parcel& parcel);
324     void ReadActionUpdateTurnScreenOn(Parcel& parcel);
325     void ReadActionUpdateKeepScreenOn(Parcel& parcel);
326     void ReadActionUpdateViewKeepScreenOn(Parcel& parcel);
327     void ReadActionUpdateFocusable(Parcel& parcel);
328     void ReadActionUpdateTouchable(Parcel& parcel);
329     void ReadActionUpdateSetBrightness(Parcel& parcel);
330     void ReadActionUpdateOrientation(Parcel& parcel);
331     void ReadActionUpdatePrivacyMode(Parcel& parcel);
332     void ReadActionUpdateSnapshotSkip(Parcel& parcel);
333     void ReadActionUpdateMaximizeState(Parcel& parcel);
334     void ReadActionUpdateSystemBar(Parcel& parcel);
335     void ReadActionUpdateFlags(Parcel& parcel);
336     void ReadActionUpdateMode(Parcel& parcel);
337     void ReadActionUpdateAnimationFlag(Parcel& parcel);
338     void ReadActionUpdateTouchHotArea(Parcel& parcel);
339     void ReadActionUpdateKeyboardTouchHotArea(Parcel& parcel);
340     void ReadActionUpdateDecorEnable(Parcel& parcel);
341     void ReadActionUpdateWindowLimits(Parcel& parcel);
342     void ReadActionUpdateDragenabled(Parcel& parcel);
343     void ReadActionUpdateRaiseenabled(Parcel& parcel);
344     void ReadActionUpdateHideNonSystemFloatingWindows(Parcel& parcel);
345     void ReadActionUpdateTextfieldAvoidInfo(Parcel& parcel);
346     void ReadActionUpdateWindowMask(Parcel& parcel);
347     void ReadActionUpdateTopmost(Parcel& parcel);
348     void ReadActionUpdateMainWindowTopmost(Parcel& parcel);
349     void ReadActionUpdateSubWindowZLevel(Parcel& parcel);
350     void ReadActionUpdateWindowModeSupportType(Parcel& parcel);
351     void ReadActionUpdateAvoidAreaOption(Parcel& parcel);
352     void ReadActionUpdateBackgroundAlpha(Parcel& parcel);
353     void ReadActionUpdateExclusivelyHighlighted(Parcel& parcel);
354     std::string windowName_;
355     SessionInfo sessionInfo_;
356     mutable std::mutex windowRectMutex_;
357     Rect windowRect_ { 0, 0, 0, 0 }; // actual window rect
358     mutable std::mutex requestRectMutex_;
359     Rect requestRect_ { 0, 0, 0, 0 }; // window rect requested by the client (without decoration size)
360     mutable std::mutex rectAnimationConfigMutex_;
361     RectAnimationConfig rectAnimationConfig_ { 0, 0.0f, 0.0f, 0.0f, 0.0f };
362     WindowType type_ { WindowType::WINDOW_TYPE_APP_MAIN_WINDOW }; // type main window
363     bool touchable_ { true };
364     bool dragEnabled_ = { true };
365     bool raiseEnabled_ = { true };
366     bool isSystemCalling_ = { false };
367     bool tokenState_ { false };
368     bool turnScreenOn_ = false;
369     bool keepScreenOn_ = false;
370     bool viewKeepScreenOn_ = false;
371     bool topmost_ = false;
372     bool mainWindowTopmost_ = false;
373     Orientation requestedOrientation_ = Orientation::UNSPECIFIED;
374     Orientation defaultRequestedOrientation_ = Orientation::UNSPECIFIED; // only accessed on SSM thread
375     bool isPrivacyMode_ { false };
376     bool isSystemPrivacyMode_ { false };
377     bool isSnapshotSkip_ { false };
378     float brightness_ = UNDEFINED_BRIGHTNESS;
379     uint64_t displayId_ = 0;
380     int32_t parentId_ = INVALID_SESSION_ID; // parentId of sceneSession, which is low 32 bite of parentPersistentId_
381     uint32_t flags_ = 0;
382     int32_t persistentId_ = INVALID_SESSION_ID;
383     int32_t parentPersistentId_ = INVALID_SESSION_ID;
384     uint32_t accessTokenId_ = INVALID_SESSION_ID;
385     MaximizeMode maximizeMode_ = MaximizeMode::MODE_RECOVER;
386     WindowMode windowMode_ = WindowMode::WINDOW_MODE_FULLSCREEN;
387     WindowState windowState_ = WindowState::STATE_INITIAL;
388     WindowLimits limits_;
389     WindowLimits userLimits_;
390     WindowLimits configLimitsVP_;
391     float lastVpr_ = 0.0f;
392     PiPTemplateInfo pipTemplateInfo_ = {0, 0, {}};
393     KeyboardLayoutParams keyboardLayoutParams_;
394     uint32_t windowModeSupportType_ {WindowModeSupport::WINDOW_MODE_SUPPORT_ALL};
395     std::unordered_map<WindowType, SystemBarProperty> sysBarPropMap_ {
396         { WindowType::WINDOW_TYPE_STATUS_BAR,           SystemBarProperty(true, 0x00FFFFFF, 0xFF000000) },
397         { WindowType::WINDOW_TYPE_NAVIGATION_BAR,       SystemBarProperty(true, 0x00FFFFFF, 0xFF000000) },
398         { WindowType::WINDOW_TYPE_NAVIGATION_INDICATOR, SystemBarProperty(true, 0x00FFFFFF, 0xFF000000) },
399     };
400     bool isDecorEnable_ = false;
401     uint32_t animationFlag_ { static_cast<uint32_t>(WindowAnimation::DEFAULT) };
402     // Transform info
403     Transform trans_;
404     bool isFloatingWindowAppType_ = false;
405     mutable std::mutex touchHotAreasMutex_;
406     std::vector<Rect> touchHotAreas_;  // coordinates relative to window.
407     KeyboardTouchHotAreas keyboardTouchHotAreas_;  // coordinates relative to window.
408     bool hideNonSystemFloatingWindows_ = false;
409     bool forceHide_ = false;
410     bool keepKeyboardFlag_ = false;
411     uint32_t callingSessionId_ = INVALID_SESSION_ID;
412 
413     double textFieldPositionY_ = 0.0;
414     double textFieldHeight_ = 0.0;
415     bool isNeedUpdateWindowMode_ = false;
416     std::function<void()> touchHotAreasChangeCallback_;
417     bool isLayoutFullScreen_ = false;
418 
419     bool isShaped_ = false;
420     bool fullScreenStart_ = false;
421     std::shared_ptr<Media::PixelMap> windowMask_ = nullptr;
422     int32_t collaboratorType_ = CollaboratorType::DEFAULT_TYPE;
423     static const std::map<uint64_t, HandlWritePropertyFunc> writeFuncMap_;
424     static const std::map<uint64_t, HandlReadPropertyFunc> readFuncMap_;
425     bool compatibleModeInPc_ = false;
426     int32_t compatibleInPcPortraitWidth_ = 0;
427     int32_t compatibleInPcPortraitHeight_ = 0;
428     int32_t compatibleInPcLandscapeWidth_ = 0;
429     int32_t compatibleInPcLandscapeHeight_ = 0;
430     bool isAppSupportPhoneInPc_ = false;
431     bool isSupportDragInPcCompatibleMode_ = false;
432     bool isPcAppInPad_ = false;
433     mutable std::mutex compatibleModeMutex_;
434     bool compatibleModeEnableInPad_ = false;
435     uint8_t backgroundAlpha_ = 0xff; // default alpha is opaque.
436     mutable std::mutex atomicServiceMutex_;
437     bool isAtomicService_ = false;
438     uint32_t apiVersion_ = 0;
439 
440     /*
441      * Sub Window
442      */
443     uint32_t subWindowLevel_ = 0;
444 
445     /*
446      * Window Hierarchy
447      */
448     int32_t zLevel_ = 0;
449 
450     /*
451      * UIExtension
452      */
453     int32_t realParentId_ = INVALID_SESSION_ID;
454     UIExtensionUsage uiExtensionUsage_ { UIExtensionUsage::EMBEDDED };
455     bool isUIExtFirstSubWindow_ = false;
456     bool isUIExtensionAbilityProcess_ = false;
457     bool isUIExtAnySubWindow_ = false;
458     WindowType parentWindowType_ = WindowType::WINDOW_TYPE_APP_MAIN_WINDOW;
459     bool isConstrainedModal_ = false;
460 
461     /*
462      * Multi Instance
463      */
464     std::string appInstanceKey_;
465 
466     /*
467      * PC Window
468      */
469     mutable std::mutex supportWindowModesMutex_;
470     std::vector<AppExecFwk::SupportWindowMode> supportedWindowModes_;
471     bool isWindowDelayRaiseEnabled_ = false;
472     WindowSizeLimits windowSizeLimits_;
473     bool isFullScreenWaterfallMode_ = false;
474     bool isSaveBySpecifiedFlag_ = false;
475 
476     /*
477      * Keyboard
478      */
479     bool isSystemKeyboard_ = false;
480     KeyboardViewMode keyboardViewMode_ = KeyboardViewMode::NON_IMMERSIVE_MODE;
481 
482     /*
483      * Window Immersive
484      */
485     uint32_t avoidAreaOption_ = 0;
486 
487     /*
488      * Window Focus
489      */
490     bool focusable_ { true };
491     bool focusableOnShow_ { true };
492     bool isExclusivelyHighlighted_ { true };
493 
494     /*
495      * Window Property
496      */
497     float cornerRadius_ = 0.0f;
498     mutable std::mutex cornerRadiusMutex_;
499 };
500 
501 struct FreeMultiWindowConfig : public Parcelable {
502     bool isSystemDecorEnable_ = true;
503     uint32_t decorWindowModeSupportType_ = WindowModeSupport::WINDOW_MODE_SUPPORT_ALL;
504     WindowMode defaultWindowMode_ = WindowMode::WINDOW_MODE_FULLSCREEN;
505     uint32_t maxMainFloatingWindowNumber_ = 0;
506 
MarshallingFreeMultiWindowConfig507     virtual bool Marshalling(Parcel& parcel) const override
508     {
509         if (!parcel.WriteBool(isSystemDecorEnable_) ||
510             !parcel.WriteUint32(decorWindowModeSupportType_)) {
511             return false;
512         }
513 
514         if (!parcel.WriteUint32(static_cast<uint32_t>(defaultWindowMode_)) ||
515             !parcel.WriteUint32(maxMainFloatingWindowNumber_)) {
516             return false;
517         }
518         return true;
519     }
520 
UnmarshallingFreeMultiWindowConfig521     static FreeMultiWindowConfig* Unmarshalling(Parcel& parcel)
522     {
523         FreeMultiWindowConfig* config = new (std::nothrow) FreeMultiWindowConfig();
524         if (config == nullptr) {
525             return nullptr;
526         }
527         config->isSystemDecorEnable_ = parcel.ReadBool();
528         config->decorWindowModeSupportType_ = parcel.ReadUint32();
529         config->defaultWindowMode_ = static_cast<WindowMode>(parcel.ReadUint32());
530         config->maxMainFloatingWindowNumber_ = parcel.ReadUint32();
531         return config;
532     }
533 };
534 
535 struct AppForceLandscapeConfig : public Parcelable {
536     int32_t mode_ = 0;
537     std::string homePage_;
538 
AppForceLandscapeConfigAppForceLandscapeConfig539     AppForceLandscapeConfig() {}
AppForceLandscapeConfigAppForceLandscapeConfig540     AppForceLandscapeConfig(int32_t mode, const std::string& homePage) : mode_(mode), homePage_(homePage) {}
541 
MarshallingAppForceLandscapeConfig542     virtual bool Marshalling(Parcel& parcel) const override
543     {
544         if (!parcel.WriteInt32(mode_) ||
545             !parcel.WriteString(homePage_)) {
546             return false;
547         }
548         return true;
549     }
550 
UnmarshallingAppForceLandscapeConfig551     static AppForceLandscapeConfig* Unmarshalling(Parcel& parcel)
552     {
553         AppForceLandscapeConfig* config = new (std::nothrow) AppForceLandscapeConfig();
554         if (config == nullptr) {
555             return nullptr;
556         }
557         config->mode_ = parcel.ReadInt32();
558         config->homePage_ = parcel.ReadString();
559         return config;
560     }
561 };
562 
563 struct SystemSessionConfig : public Parcelable {
564     bool isSystemDecorEnable_ = true;
565     uint32_t decorWindowModeSupportType_ = WindowModeSupport::WINDOW_MODE_SUPPORT_ALL;
566     bool isStretchable_ = false;
567     WindowMode defaultWindowMode_ = WindowMode::WINDOW_MODE_FULLSCREEN;
568     KeyboardAnimationCurve animationIn_;
569     KeyboardAnimationCurve animationOut_;
570     // 1920: default max window size
571     uint32_t maxFloatingWindowSize_ = 1920;
572     // 320: default minWidth main window size
573     uint32_t miniWidthOfMainWindow_ = 320;
574     // 240: default minHeight main window size
575     uint32_t miniHeightOfMainWindow_ = 240;
576     // 320: default minWidth sub window size
577     uint32_t miniWidthOfSubWindow_ = 320;
578     // 240: default minHeight sub window size
579     uint32_t miniHeightOfSubWindow_ = 240;
580     // 320: default minWidth dialog window size
581     uint32_t miniWidthOfDialogWindow_ = 320;
582     // 240: default minHeight dialog window size
583     uint32_t miniHeightOfDialogWindow_ = 240;
584     bool backgroundswitch = false;
585     bool freeMultiWindowEnable_ = false;
586     bool freeMultiWindowSupport_ = false;
587     FreeMultiWindowConfig freeMultiWindowConfig_;
588     WindowUIType windowUIType_ = WindowUIType::INVALID_WINDOW;
589     bool supportTypeFloatWindow_ = false;
590     // Product configuration
591     bool supportFollowParentWindowLayout_ = false;
592 
MarshallingSystemSessionConfig593     virtual bool Marshalling(Parcel& parcel) const override
594     {
595         if (!parcel.WriteBool(isSystemDecorEnable_) || !parcel.WriteBool(isStretchable_) ||
596             !parcel.WriteUint32(decorWindowModeSupportType_)) {
597             return false;
598         }
599 
600         if (!parcel.WriteUint32(static_cast<uint32_t>(defaultWindowMode_)) ||
601             !parcel.WriteParcelable(&animationIn_) || !parcel.WriteParcelable(&animationOut_) ||
602             !parcel.WriteUint32(maxFloatingWindowSize_)) {
603             return false;
604         }
605 
606         bool parcelWriteFail = !parcel.WriteUint32(miniWidthOfMainWindow_) ||
607             !parcel.WriteUint32(miniHeightOfMainWindow_) || !parcel.WriteUint32(miniWidthOfSubWindow_) ||
608             !parcel.WriteUint32(miniHeightOfSubWindow_) || !parcel.WriteUint32(miniWidthOfDialogWindow_) ||
609             !parcel.WriteUint32(miniHeightOfDialogWindow_);
610         if (parcelWriteFail) {
611             return false;
612         }
613 
614         if (!parcel.WriteBool(backgroundswitch)) {
615             return false;
616         }
617 
618         if (!parcel.WriteBool(freeMultiWindowEnable_)) {
619             return false;
620         }
621 
622         if (!parcel.WriteBool(freeMultiWindowSupport_)) {
623             return false;
624         }
625         if (!parcel.WriteParcelable(&freeMultiWindowConfig_)) {
626             return false;
627         }
628         if (!parcel.WriteUint8(static_cast<uint8_t>(windowUIType_))) {
629             return false;
630         }
631         if (!parcel.WriteBool(supportTypeFloatWindow_)) {
632             return false;
633         }
634         if (!parcel.WriteBool(supportFollowParentWindowLayout_)) {
635             return false;
636         }
637         return true;
638     }
639 
UnmarshallingSystemSessionConfig640     static SystemSessionConfig* Unmarshalling(Parcel& parcel)
641     {
642         SystemSessionConfig* config = new (std::nothrow) SystemSessionConfig();
643         if (config == nullptr) {
644             return nullptr;
645         }
646         config->isSystemDecorEnable_ = parcel.ReadBool();
647         config->isStretchable_ = parcel.ReadBool();
648         config->decorWindowModeSupportType_ = parcel.ReadUint32();
649         config->defaultWindowMode_ = static_cast<WindowMode>(parcel.ReadUint32());
650         sptr<KeyboardAnimationCurve> animationIn = parcel.ReadParcelable<KeyboardAnimationCurve>();
651         if (animationIn == nullptr) {
652             delete config;
653             return nullptr;
654         }
655         config->animationIn_ = *animationIn;
656         sptr<KeyboardAnimationCurve> animationOut = parcel.ReadParcelable<KeyboardAnimationCurve>();
657         if (animationOut == nullptr) {
658             delete config;
659             return nullptr;
660         }
661         config->animationOut_ = *animationOut;
662         config->maxFloatingWindowSize_ = parcel.ReadUint32();
663         config->miniWidthOfMainWindow_ = parcel.ReadUint32();
664         config->miniHeightOfMainWindow_ = parcel.ReadUint32();
665         config->miniWidthOfSubWindow_ = parcel.ReadUint32();
666         config->miniHeightOfSubWindow_ = parcel.ReadUint32();
667         config->miniWidthOfDialogWindow_ = parcel.ReadUint32();
668         config->miniHeightOfDialogWindow_ = parcel.ReadUint32();
669         config->backgroundswitch = parcel.ReadBool();
670         config->freeMultiWindowEnable_ = parcel.ReadBool();
671         config->freeMultiWindowSupport_ = parcel.ReadBool();
672         sptr<FreeMultiWindowConfig> freeMultiWindowConfig = parcel.ReadParcelable<FreeMultiWindowConfig>();
673         if (freeMultiWindowConfig == nullptr) {
674             delete config;
675             return nullptr;
676         }
677         config->freeMultiWindowConfig_ = *freeMultiWindowConfig;
678         config->windowUIType_ = static_cast<WindowUIType>(parcel.ReadUint8());
679         config->supportTypeFloatWindow_ = parcel.ReadBool();
680         config->supportFollowParentWindowLayout_ = parcel.ReadBool();
681         return config;
682     }
683 
IsFreeMultiWindowModeSystemSessionConfig684     bool IsFreeMultiWindowMode() const
685     {
686         return freeMultiWindowEnable_ && freeMultiWindowSupport_;
687     }
688 
IsPhoneWindowSystemSessionConfig689     bool IsPhoneWindow() const
690     {
691         return windowUIType_ == WindowUIType::PHONE_WINDOW;
692     }
693 
IsPcWindowSystemSessionConfig694     bool IsPcWindow() const
695     {
696         return windowUIType_ == WindowUIType::PC_WINDOW;
697     }
698 
IsPadWindowSystemSessionConfig699     bool IsPadWindow() const
700     {
701         return windowUIType_ == WindowUIType::PAD_WINDOW;
702     }
703 };
704 } // namespace Rosen
705 } // namespace OHOS
706 #endif // OHOS_ROSEN_WINDOW_PROPERTY_H
707