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_SCENE_WS_COMMON_H
17 #define OHOS_ROSEN_WINDOW_SCENE_WS_COMMON_H
18
19 #include <inttypes.h>
20 #include <iomanip>
21 #include <map>
22 #include <sstream>
23 #include <string>
24
25 #include <iremote_broker.h>
26 #include <want.h>
27
28 namespace OHOS::AAFwk {
29 class AbilityStartSetting;
30 class ProcessOptions;
31 class StartWindowOption;
32 }
33 namespace OHOS::AppExecFwk {
34 struct AbilityInfo;
35 enum class SupportWindowMode;
36 }
37
38 namespace OHOS::Rosen {
39 class RSTransaction;
40 constexpr int32_t ROTATE_ANIMATION_DURATION = 400;
41 constexpr int32_t INVALID_SESSION_ID = 0;
42 constexpr int32_t WINDOW_SUPPORT_MODE_MAX_SIZE = 4;
43 constexpr int32_t DEFAULT_SCALE_RATIO = 100;
44 const std::string WINDOW_SCREEN_LOCK_PREFIX = "windowLock_";
45 const std::string VIEW_SCREEN_LOCK_PREFIX = "viewLock_";
46
47 enum class WSError : int32_t {
48 WS_OK = 0,
49 WS_DO_NOTHING,
50 WS_ERROR_NO_MEM,
51 WS_ERROR_DESTROYED_OBJECT,
52 WS_ERROR_INVALID_WINDOW,
53 WS_ERROR_INVALID_WINDOW_MODE_OR_SIZE,
54 WS_ERROR_INVALID_OPERATION,
55 WS_ERROR_INVALID_PERMISSION,
56 WS_ERROR_NOT_SYSTEM_APP,
57 WS_ERROR_NO_REMOTE_ANIMATION,
58 WS_ERROR_INVALID_DISPLAY,
59 WS_ERROR_INVALID_PARENT,
60 WS_ERROR_OPER_FULLSCREEN_FAILED,
61 WS_ERROR_REPEAT_OPERATION,
62 WS_ERROR_INVALID_SESSION,
63 WS_ERROR_INVALID_CALLING,
64 WS_ERROR_UNCLEARABLE_SESSION,
65 WS_ERROR_FAIL_TO_GET_SNAPSHOT,
66 WS_ERROR_INTERNAL_ERROR,
67 WS_ERROR_NO_UI_CONTENT_ERROR,
68
69 WS_ERROR_DEVICE_NOT_SUPPORT = 801, // the value do not change.It is defined on all system
70
71 WS_ERROR_NEED_REPORT_BASE = 1000, // error code > 1000 means need report
72 WS_ERROR_NULLPTR,
73 WS_ERROR_INVALID_TYPE,
74 WS_ERROR_INVALID_PARAM,
75 WS_ERROR_SAMGR,
76 WS_ERROR_IPC_FAILED,
77 WS_ERROR_NEED_REPORT_END,
78 WS_ERROR_START_ABILITY_FAILED,
79 WS_ERROR_SET_SESSION_LABEL_FAILED,
80 WS_ERROR_SET_SESSION_ICON_FAILED,
81 WS_ERROR_INVALID_SESSION_LISTENER,
82 WS_ERROR_START_UI_EXTENSION_ABILITY_FAILED,
83 WS_ERROR_MIN_UI_EXTENSION_ABILITY_FAILED,
84 WS_ERROR_TERMINATE_UI_EXTENSION_ABILITY_FAILED,
85 WS_ERROR_PRE_HANDLE_COLLABORATOR_FAILED,
86 WS_ERROR_START_UI_ABILITY_TIMEOUT,
87
88 WS_ERROR_EDM_CONTROLLED = 2097215, // enterprise limit
89 };
90
91 enum class WSErrorCode : int32_t {
92 WS_OK = 0,
93 WS_ERROR_NO_PERMISSION = 201,
94 WS_ERROR_INVALID_PARAM = 401,
95 WS_ERROR_DEVICE_NOT_SUPPORT = 801,
96 WS_ERROR_TIMEOUT = 901,
97 WS_ERROR_NOT_REGISTER_SYNC_CALLBACK = 100011,
98 WS_ERROR_TRANSFER_DATA_FAILED = 100012,
99 WS_ERROR_REPEAT_OPERATION = 1300001,
100 WS_ERROR_STATE_ABNORMALLY = 1300002,
101 WS_ERROR_SYSTEM_ABNORMALLY = 1300003,
102 WS_ERROR_INVALID_CALLING = 1300004,
103 WS_ERROR_STAGE_ABNORMALLY = 1300005,
104 WS_ERROR_CONTEXT_ABNORMALLY = 1300006,
105
106 WS_ERROR_EDM_CONTROLLED = 16000013, // enterprise limit
107 };
108
109 const std::map<WSError, WSErrorCode> WS_JS_TO_ERROR_CODE_MAP {
110 { WSError::WS_OK, WSErrorCode::WS_OK },
111 { WSError::WS_DO_NOTHING, WSErrorCode::WS_ERROR_STATE_ABNORMALLY },
112 { WSError::WS_ERROR_INVALID_SESSION, WSErrorCode::WS_ERROR_STATE_ABNORMALLY },
113 { WSError::WS_ERROR_INVALID_PARAM, WSErrorCode::WS_ERROR_STATE_ABNORMALLY },
114 { WSError::WS_ERROR_IPC_FAILED, WSErrorCode::WS_ERROR_SYSTEM_ABNORMALLY },
115 { WSError::WS_ERROR_NULLPTR, WSErrorCode::WS_ERROR_STATE_ABNORMALLY },
116 { WSError::WS_ERROR_EDM_CONTROLLED, WSErrorCode::WS_ERROR_EDM_CONTROLLED },
117 { WSError::WS_ERROR_INVALID_WINDOW, WSErrorCode::WS_ERROR_STATE_ABNORMALLY },
118 };
119
120 enum class SessionState : uint32_t {
121 STATE_DISCONNECT = 0,
122 STATE_CONNECT,
123 STATE_FOREGROUND,
124 STATE_ACTIVE,
125 STATE_INACTIVE,
126 STATE_BACKGROUND,
127 STATE_END,
128 };
129
130 enum ContinueState {
131 CONTINUESTATE_UNKNOWN = -1,
132 CONTINUESTATE_ACTIVE = 0,
133 CONTINUESTATE_INACTIVE = 1,
134 CONTINUESTATE_MAX
135 };
136
137 enum class StartMethod : int32_t {
138 START_NORMAL,
139 START_CALL
140 };
141
142 enum class SingleHandMode : int32_t {
143 LEFT = 0,
144 RIGHT,
145 MIDDLE
146 };
147
148 /**
149 * @brief collaborator type.
150 */
151 enum CollaboratorType : int32_t {
152 DEFAULT_TYPE = 0,
153 RESERVE_TYPE,
154 OTHERS_TYPE,
155 };
156
157 enum AncoSceneState: int32_t {
158 DEFAULT_STATE = 0,
159 NOTIFY_START,
160 NOTIFY_CREATE,
161 NOTIFY_LOAD,
162 NOTIFY_UPDATE,
163 NOTIFY_FOREGROUND,
164 };
165
166 /**
167 * @brief collaborator type.
168 */
169 enum SessionOperationType : int32_t {
170 TYPE_DEFAULT = 0,
171 TYPE_CLEAR,
172 };
173
174 enum class ManagerState : uint32_t {
175 MANAGER_STATE_SCREEN_LOCKED = 0,
176 };
177
178 /**
179 * @brief Enumerates picture in picture control status.
180 */
181 enum class WsPiPControlStatus : int32_t {
182 PLAY = 1,
183 PAUSE = 0,
184 OPEN = 1,
185 CLOSE = 0,
186 ENABLED = -2,
187 DISABLED = -3,
188 };
189
190 /**
191 * @brief Enumerates picture in picture control type.
192 */
193 enum class WsPiPControlType : uint32_t {
194 VIDEO_PLAY_PAUSE = 0,
195 VIDEO_PREVIOUS = 1,
196 VIDEO_NEXT = 2,
197 FAST_FORWARD = 3,
198 FAST_BACKWARD = 4,
199 HANG_UP_BUTTON = 5,
200 MICROPHONE_SWITCH = 6,
201 CAMERA_SWITCH = 7,
202 MUTE_SWITCH = 8,
203 END,
204 };
205
206 enum class FocusChangeReason {
207 /**
208 * default focus change reason
209 */
210 DEFAULT = 0,
211
212 /**
213 * focus change for move up
214 */
215 MOVE_UP,
216
217 /**
218 * focus change for click
219 */
220 CLICK,
221
222 /**
223 * focus change for foreground
224 */
225 FOREGROUND,
226
227 /**
228 * focus change for background
229 */
230 BACKGROUND,
231
232 /**
233 * focus change for split screen.5
234 */
235 SPLIT_SCREEN,
236
237 /**
238 * focus change for full screen
239 */
240 FULL_SCREEN,
241
242 /**
243 * focus change for global search
244 */
245 SCB_SESSION_REQUEST,
246
247 /**
248 * focus change for floating scene
249 */
250 FLOATING_SCENE,
251
252 /**
253 * focus change for losing focus
254 */
255 SCB_SESSION_REQUEST_UNFOCUS,
256
257 /**
258 * focus change for client requerst.10
259 */
260 CLIENT_REQUEST,
261
262 /**
263 * focus change for wind
264 */
265 WIND,
266
267 /**
268 * focus change for app foreground
269 */
270 APP_FOREGROUND,
271
272 /**
273 * focus change for app background
274 */
275 APP_BACKGROUND,
276
277 /**
278 * focus change for recent,Multitasking
279 */
280 RECENT,
281
282 /**
283 * focus change for inner app.
284 */
285 SCB_START_APP,
286
287 /**
288 * focus for setting focuable.
289 */
290 FOCUSABLE,
291
292 /**
293 * select last focused app when requestSessionUnFocus.
294 */
295 LAST_FOCUSED_APP,
296
297 /**
298 * focus for zOrder pass through VOICE_INTERACTION.
299 */
300 VOICE_INTERACTION,
301
302 /**
303 * focus change for SA requerst.19
304 */
305 SA_REQUEST,
306
307 /**
308 * focus on previous window for system keyboard
309 */
310 SYSTEM_KEYBOARD,
311
312 /**
313 * focus change max.
314 */
315 MAX,
316 };
317
318 enum class SceneType : uint8_t {
319 DEFAULT = 0,
320 WINDOW_SCENE,
321 SYSTEM_WINDOW_SCENE,
322 TRANSFORM_SCENE,
323 PANEL_SCENE,
324 INPUT_SCENE,
325 };
326
327 struct SessionViewportConfig {
328 bool isDensityFollowHost_ = false;
329 float density_ = 1.0f; // Indicates the host's density, if following the host, use it, otherwise get it from DMS.
330 uint64_t displayId_ = 0;
331 int32_t orientation_ = 0;
332 uint32_t transform_ = 0;
333 };
334
335 struct WindowSizeLimits {
336 uint32_t maxWindowWidth = 0;
337 uint32_t minWindowWidth = 0;
338 uint32_t maxWindowHeight = 0;
339 uint32_t minWindowHeight = 0;
340
341 bool operator==(const WindowSizeLimits& sizeLimits) const
342 {
343 return (maxWindowWidth == sizeLimits.maxWindowWidth && minWindowWidth == sizeLimits.minWindowWidth &&
344 maxWindowHeight == sizeLimits.maxWindowHeight && minWindowHeight == sizeLimits.minWindowHeight);
345 }
346 };
347
348 struct SessionInfo {
349 std::string bundleName_ = "";
350 std::string moduleName_ = "";
351 std::string abilityName_ = "";
352 int32_t appIndex_ = 0;
353 bool isSystem_ = false;
354 SceneType sceneType_ = SceneType::WINDOW_SCENE;
355 uint32_t windowType_ = 1; // WINDOW_TYPE_APP_MAIN_WINDOW
356 sptr<IRemoteObject> callerToken_ = nullptr;
357 sptr<IRemoteObject> rootToken_ = nullptr;
358 uint64_t screenId_ = -1;
359 bool isPersistentRecover_ = false;
360 bool isFromIcon_ = false;
361
362 mutable std::shared_ptr<AAFwk::Want> want = nullptr; // want for ability start
363 std::shared_ptr<AAFwk::Want> closeAbilityWant = nullptr;
364 std::shared_ptr<AAFwk::AbilityStartSetting> startSetting = nullptr;
365 std::shared_ptr<AAFwk::ProcessOptions> processOptions = nullptr;
366 std::shared_ptr<AAFwk::StartWindowOption> startWindowOption = nullptr;
367 mutable std::shared_ptr<AppExecFwk::AbilityInfo> abilityInfo = nullptr;
368 int32_t resultCode = -1;
369 int32_t requestCode = -1;
370 int32_t errorCode = -1;
371 std::string errorReason = "";
372 int32_t persistentId_ = INVALID_SESSION_ID;
373 int32_t callerPersistentId_ = INVALID_SESSION_ID;
374 std::string callerBundleName_ = "";
375 std::string callerAbilityName_ = "";
376 uint32_t callState_ = 0;
377 uint32_t callingTokenId_ = 0;
378 bool reuse = false;
379 int32_t windowMode = 0;
380 StartMethod startMethod = StartMethod::START_NORMAL;
381 bool lockedState = false;
382 std::string time = "";
383 ContinueState continueState = ContinueState::CONTINUESTATE_ACTIVE;
384 int64_t uiAbilityId_ = 0;
385 int32_t ancoSceneState = 0;
386 bool isClearSession = false;
387 std::string sessionAffinity = "";
388 int32_t collaboratorType_ = CollaboratorType::DEFAULT_TYPE;
389 SessionState sessionState_ = SessionState::STATE_DISCONNECT;
390 uint32_t requestOrientation_ = 0;
391 bool isRotable_ = false;
392 bool isSetPointerAreas_ = false;
393 bool isCastSession_ = false;
394 uint32_t windowInputType_ = 0;
395 std::string continueSessionId_ = "";
396 bool isCalledRightlyByCallerId_ = false;
397 bool fullScreenStart_ = false;
398 bool isAtomicService_ = false;
399 bool isBackTransition_ = false;
400 bool needClearInNotShowRecent_ = false;
401 bool isPcOrPadEnableActivation_ = false;
402 bool canStartAbilityFromBackground_ = false;
403 bool isFoundationCall_ = false;
404 int32_t requestId = 0;
405 std::string specifiedFlag_ = "";
406
407 /*
408 * App Use Control
409 */
410 bool isUseControlSession = false; // Indicates whether the session is used for controlling a main session.
411
412 /*
413 * UIExtension
414 */
415 int32_t realParentId_ = INVALID_SESSION_ID;
416 uint32_t uiExtensionUsage_ = 0;
417 bool isAsyncModalBinding_ = false;
418 uint32_t parentWindowType_ = 1; // WINDOW_TYPE_APP_MAIN_WINDOW
419 SessionViewportConfig config_;
420
421 /*
422 * Multi Instance
423 */
424 bool isNewAppInstance_ = false;
425 std::string appInstanceKey_;
426
427 /*
428 * PC Window
429 */
430 std::vector<AppExecFwk::SupportWindowMode> supportedWindowModes;
431 WindowSizeLimits windowSizeLimits;
432 };
433
434 enum class SessionFlag : uint32_t {
435 SESSION_FLAG_NEED_AVOID = 1,
436 SESSION_FLAG_PARENT_LIMIT = 1 << 1,
437 SESSION_FLAG_SHOW_WHEN_LOCKED = 1 << 2,
438 SESSION_FLAG_FORBID_SPLIT_MOVE = 1 << 3,
439 SESSION_FLAG_WATER_MARK = 1 << 4,
440 SESSION_FLAG_END = 1 << 5,
441 };
442
443 enum class SizeChangeReason : uint32_t {
444 UNDEFINED = 0,
445 MAXIMIZE,
446 RECOVER,
447 ROTATION,
448 DRAG,
449 DRAG_START,
450 DRAG_END,
451 RESIZE,
452 RESIZE_WITH_ANIMATION,
453 MOVE,
454 MOVE_WITH_ANIMATION,
455 HIDE,
456 TRANSFORM,
457 CUSTOM_ANIMATION_SHOW,
458 FULL_TO_SPLIT,
459 SPLIT_TO_FULL,
460 FULL_TO_FLOATING,
461 FLOATING_TO_FULL,
462 PIP_START,
463 PIP_SHOW,
464 PIP_AUTO_START,
465 PIP_RATIO_CHANGE,
466 PIP_RESTORE,
467 UPDATE_DPI_SYNC,
468 DRAG_MOVE,
469 AVOID_AREA_CHANGE,
470 MAXIMIZE_TO_SPLIT,
471 SPLIT_TO_MAXIMIZE,
472 END,
473 };
474
IsMoveToOrDragMove(SizeChangeReason reason)475 inline bool IsMoveToOrDragMove(SizeChangeReason reason)
476 {
477 return reason == SizeChangeReason::MOVE || reason == SizeChangeReason::DRAG_MOVE ||
478 reason == SizeChangeReason::MOVE_WITH_ANIMATION;
479 }
480
481 enum class SessionEvent : uint32_t {
482 EVENT_MAXIMIZE = 100,
483 EVENT_RECOVER,
484 EVENT_MINIMIZE,
485 EVENT_CLOSE,
486 EVENT_START_MOVE,
487 EVENT_END_MOVE,
488 EVENT_MAXIMIZE_FLOATING,
489 EVENT_TERMINATE,
490 EVENT_EXCEPTION,
491 EVENT_SPLIT_PRIMARY,
492 EVENT_SPLIT_SECONDARY,
493 EVENT_DRAG_START,
494 EVENT_DRAG,
495 EVENT_MAXIMIZE_WITHOUT_ANIMATION,
496 EVENT_MAXIMIZE_WATERFALL,
497 EVENT_WATERFALL_TO_MAXIMIZE,
498 EVENT_END
499 };
500
501 enum class BrokerStates: uint32_t {
502 BROKER_UNKOWN = 1,
503 BROKER_STARTED = 0,
504 BROKER_NOT_START = -1,
505 };
506
GreatOrEqual(double left,double right)507 inline bool GreatOrEqual(double left, double right)
508 {
509 constexpr double epsilon = -0.00001f;
510 return (left - right) > epsilon;
511 }
512
LessOrEqual(double left,double right)513 inline bool LessOrEqual(double left, double right)
514 {
515 constexpr double epsilon = 0.00001f;
516 return (left - right) < epsilon;
517 }
518
NearEqual(const double left,const double right,const double epsilon)519 inline bool NearEqual(const double left, const double right, const double epsilon)
520 {
521 return (std::fabs(left - right) <= epsilon);
522 }
523
NearEqual(const float & left,const float & right)524 inline bool NearEqual(const float& left, const float& right)
525 {
526 constexpr double epsilon = 0.001f;
527 return NearEqual(left, right, epsilon);
528 }
529
NearEqual(const int32_t & left,const int32_t & right)530 inline bool NearEqual(const int32_t& left, const int32_t& right)
531 {
532 return left == right;
533 }
534
NearZero(const double left)535 inline bool NearZero(const double left)
536 {
537 constexpr double epsilon = 0.001f;
538 return NearEqual(left, 0.0, epsilon);
539 }
540
541 template<typename T>
542 struct WSRectT {
543 T posX_ = 0;
544 T posY_ = 0;
545 T width_ = 0;
546 T height_ = 0;
547
548 bool operator==(const WSRectT<T>& a) const
549 {
550 return (NearEqual(posX_, a.posX_) && NearEqual(posY_, a.posY_) &&
551 NearEqual(width_, a.width_) && NearEqual(height_, a.height_));
552 }
553
554 bool operator!=(const WSRectT<T>& a) const
555 {
556 return !this->operator==(a);
557 }
558
IsEmptyWSRectT559 bool IsEmpty() const
560 {
561 if (NearZero(posX_) && NearZero(posY_) && NearZero(width_) && NearZero(height_)) {
562 return true;
563 }
564 return false;
565 }
566
IsInRegionWSRectT567 inline bool IsInRegion(int32_t pointX, int32_t pointY) const
568 {
569 return GreatOrEqual(pointX, posX_) && LessOrEqual(pointX, posX_ + width_) &&
570 GreatOrEqual(pointY, posY_) && LessOrEqual(pointY, posY_ + height_);
571 }
572
IsOverlapWSRectT573 inline bool IsOverlap(const WSRectT<T>& rect) const
574 {
575 int32_t xStart = std::max(posX_, rect.posX_);
576 int32_t xEnd = std::min(posX_ + static_cast<int32_t>(width_),
577 rect.posX_ + static_cast<int32_t>(rect.width_));
578 int32_t yStart = std::max(posY_, rect.posY_);
579 int32_t yEnd = std::min(posY_ + static_cast<int32_t>(height_),
580 rect.posY_ + static_cast<int32_t>(rect.height_));
581 return (yStart < yEnd) && (xStart < xEnd);
582 }
583
IsInvalidWSRectT584 inline bool IsInvalid() const
585 {
586 return IsEmpty() || LessOrEqual(width_, 0) || LessOrEqual(height_, 0);
587 }
588
ToStringWSRectT589 inline std::string ToString() const
590 {
591 constexpr int precision = 2;
592 std::stringstream ss;
593 ss << "[" << std::fixed << std::setprecision(precision) << posX_ << " " << posY_ << " " <<
594 width_ << " " << height_ << "]";
595 return ss.str();
596 }
597 static const WSRectT<T> EMPTY_RECT;
598 };
599
600 template<typename T>
601 inline constexpr WSRectT<T> WSRectT<T>::EMPTY_RECT { 0, 0, 0, 0 };
602
603 using WSRect = WSRectT<int32_t>;
604 using WSRectF = WSRectT<float>;
605
606 struct WindowShadowConfig {
607 float offsetX_ = 0.0f;
608 float offsetY_ = 0.0f;
609 float alpha_ = 0.0f;
610 float radius_ = 0.0f;
611 std::string color_ = "#000000";
612 };
613
614 struct KeyboardSceneAnimationConfig {
615 std::string curveType_ = "default";
616 float ctrlX1_ = 0.2f;
617 float ctrlY1_ = 0.0f;
618 float ctrlX2_ = 0.2f;
619 float ctrlY2_ = 1.0f;
620 uint32_t duration_ = 150;
621 };
622
623 struct WindowAnimationConfig {
624 int32_t duration_ = 0;
625 std::string curveType_ = "easeOut";
626 float ctrlX1_ = 0.2f;
627 float ctrlY1_ = 0.0f;
628 float ctrlX2_ = 0.2f;
629 float ctrlY2_ = 1.0f;
630 float scaleX_ = 0.0f;
631 float scaleY_ = 0.0f;
632 float rotationX_ = 0.0f;
633 float rotationY_ = 0.0f;
634 float rotationZ_ = 0.0f;
635 int32_t angle_ = 0;
636 float translateX_ = 0.0f;
637 float translateY_ = 0.0f;
638 float opacity_ = 0;
639 };
640
641 struct StartingWindowInfo {
642 int32_t startingWindowBackgroundId_;
643 int32_t startingWindowIconId_;
644 uint32_t startingWindowBackgroundColor_;
645 std::string startingWindowIconPath_;
646 };
647
648 struct StartingWindowAnimationConfig {
649 bool enabled_ = true;
650 int duration_ = 200;
651 std::string curve_ = "linear";
652 float opacityStart_ = 1;
653 float opacityEnd_ = 0;
654 };
655
656 struct SystemUIStatusBarConfig {
657 bool showInLandscapeMode_ = false;
658 std::string immersiveStatusBarBgColor_ = "#4c000000";
659 std::string immersiveStatusBarContentColor_ = "#ffffff";
660 };
661
662 struct StatusBarConfig {
663 bool showHide_ = false;
664 std::string contentColor_;
665 std::string backgroundColor_;
666 };
667
668 struct WindowImmersive {
669 StatusBarConfig desktopStatusBarConfig_;
670 StatusBarConfig leftRightStatusBarConfig_;
671 StatusBarConfig upDownStatusBarConfig_;
672 };
673
674 struct AppWindowSceneConfig {
675 float floatCornerRadius_ = 0.0f;
676 std::string multiWindowUIType_ = "HandsetSmartWindow";
677 bool backgroundScreenLock_ = false;
678 std::string rotationMode_ = "windowRotation";
679 WindowShadowConfig focusedShadow_;
680 WindowShadowConfig unfocusedShadow_;
681 WindowShadowConfig focusedShadowDark_;
682 WindowShadowConfig unfocusedShadowDark_;
683 KeyboardSceneAnimationConfig keyboardAnimationIn_;
684 KeyboardSceneAnimationConfig keyboardAnimationOut_;
685 WindowAnimationConfig windowAnimation_;
686 StartingWindowAnimationConfig startingWindowAnimationConfig_;
687 SystemUIStatusBarConfig systemUIStatusBarConfig_;
688 WindowImmersive windowImmersive_;
689 };
690
691 struct SingleHandCompatibleModeConfig {
692 bool enabled = false;
693 float singleHandScale = 1.0f;
694 float heightChangeRatio = 1.0f;
695 float widthChangeRatio = 1.0f;
696 };
697
698 struct SingleHandScreenInfo {
699 int32_t scaleRatio = DEFAULT_SCALE_RATIO;
700 int32_t scalePivotX = 0;
701 int32_t scalePivotY = 0;
702 SingleHandMode mode = SingleHandMode::MIDDLE;
703 };
704
705 struct DeviceScreenConfig {
706 std::string rotationPolicy_ = "11"; // default use phone policy
707 std::string defaultRotationPolicy_ = "1"; // default unspecified policy
708 bool isRightPowerButton_ = true;
709 };
710
711 struct SceneAnimationConfig {
712 std::shared_ptr<RSTransaction> rsTransaction_ = nullptr;
713 int32_t animationDuration_ = ROTATE_ANIMATION_DURATION;
714 };
715
716 struct RotateAnimationConfig {
717 int32_t duration_ = ROTATE_ANIMATION_DURATION;
718 };
719
720 struct SessionEventParam {
721 int32_t pointerX_ = 0;
722 int32_t pointerY_ = 0;
723 int32_t sessionWidth_ = 0;
724 int32_t sessionHeight_ = 0;
725 uint32_t dragResizeType = 0;
726 };
727
728 /**
729 * @brief Enumerates session gravity.
730 */
731 enum class SessionGravity : uint32_t {
732 SESSION_GRAVITY_FLOAT = 0,
733 SESSION_GRAVITY_BOTTOM,
734 SESSION_GRAVITY_DEFAULT,
735 };
736
737 /**
738 * @brief TerminateType session terminate type.
739 */
740 enum class TerminateType : uint32_t {
741 CLOSE_AND_KEEP_MULTITASK = 0,
742 CLOSE_AND_CLEAR_MULTITASK,
743 CLOSE_AND_START_CALLER,
744 CLOSE_BY_EXCEPTION,
745 };
746
747 /**
748 * @brief System animaged scene type.
749 */
750 enum class SystemAnimatedSceneType : uint32_t {
751 SCENE_ENTER_MISSION_CENTER, // Enter the mission center
752 SCENE_EXIT_MISSION_CENTER, // Exit the mission center
753 SCENE_ENTER_TFS_WINDOW, // Three-finger sliding window recovery
754 SCENE_EXIT_TFU_WINDOW, // The three-finger up window disappears
755 SCENE_ENTER_WINDOW_FULL_SCREEN, // Enter the window full screen
756 SCENE_EXIT_WINDOW_FULL_SCREEN, // Exit the window full screen
757 SCENE_ENTER_MAX_WINDOW, // Enter the window maximization state
758 SCENE_EXIT_MAX_WINDOW, // Exit the window maximization state
759 SCENE_ENTER_SPLIT_SCREEN, // Enter the split screen
760 SCENE_EXIT_SPLIT_SCREEN, // Exit the split screen
761 SCENE_ENTER_APP_CENTER, // Enter the app center
762 SCENE_EXIT_APP_CENTER, // Exit the app center
763 SCENE_APPEAR_MISSION_CENTER, // A special case scenario that displays the mission center
764 SCENE_ENTER_WIND_CLEAR, // Enter win+D in clear screen mode
765 SCENE_ENTER_WIND_RECOVER, // Enter win+D in recover mode
766 SCENE_ENTER_RECENTS, // Enter recents
767 SCENE_EXIT_RECENTS, // Exit recent.
768 SCENE_LOCKSCREEN_TO_LAUNCHER, // Unlock screen.
769 SCENE_ENTER_MIN_WINDOW, // Enter the window minimization state
770 SCENE_RECOVER_MIN_WINDOW, // Recover minimized window
771 SCENE_OTHERS, // 1.Default state 2.The state in which the animation ends
772 };
773
774 /**
775 * @brief Session UI parameters
776 */
777 struct SessionUIParam {
778 bool interactive_ { true };
779 WSRect rect_;
780 float scaleX_ { 1.0f };
781 float scaleY_ { 1.0f };
782 float pivotX_ { 1.0f };
783 float pivotY_ { 1.0f };
784 float transX_ { 0.0f }; // global translateX
785 float transY_ { 0.0f }; // global translateY
786 uint32_t zOrder_ { 0 };
787 std::string sessionName_;
788 bool needSync_ { true };
789 };
790
791 enum class SessionUIDirtyFlag {
792 NONE = 0,
793 VISIBLE = 1,
794 INTERACTIVE = 1 << 1,
795 RECT = 1 << 2,
796 SCALE = 1 << 3,
797 TOUCH_HOT_AREA = 1 << 4,
798 Z_ORDER = 1 << 5,
799 AVOID_AREA = 1 << 6,
800 DRAG_RECT = 1 << 7,
801 GLOBAL_RECT = 1 << 8,
802 };
803
804 /**
805 * @brief State for post-process focus
806 */
807 struct PostProcessFocusState {
808 bool enabled_ { false };
809 bool isFocused_ { false };
810 bool byForeground_ { true };
811 FocusChangeReason reason_ { FocusChangeReason::DEFAULT };
812
ResetPostProcessFocusState813 void Reset()
814 {
815 enabled_ = false;
816 isFocused_ = false;
817 byForeground_ = true;
818 reason_ = FocusChangeReason::DEFAULT;
819 }
820 };
821 } // namespace OHOS::Rosen
822 #endif // OHOS_ROSEN_WINDOW_SCENE_WS_COMMON_H
823