The initial APIs of this module are supported since API version 6. Newly added APIs will be marked with a superscript to indicate their earliest API version.
For the system capability SystemCapability.Window.SessionManager, use canIUse() to check whether the device supports this system capability and the corresponding APIs.
Enumerates the window types.
System capability: SystemCapability.WindowManager.WindowManager.Core
| Name | Value | Description |
|---|---|---|
| TYPE_APP | 0 | Child window of an application. Model restriction: This API can be used only in the FA model. |
| TYPE_SYSTEM_ALERT(deprecated) | 1 | System alert window. Note: This API has been deprecated since API version 11, and was supported since API version 7. |
| TYPE_FLOAT9+ | 8 | Global floating window. Model restriction: This API can be used only in the stage model. Atomic service API: This API can be used in atomic services since API version 12. |
| TYPE_DIALOG10+ | 16 | Modal window. Model restriction: This API can be used only in the stage model. Atomic service API: This API can be used in atomic services since API version 12. |
| TYPE_MAIN18+ | 32 | Main window of an application. This window type cannot be used during window creation. |
Enumerates the window posture modes.
System capability: SystemCapability.Window.SessionManager
Since: 26.0.0
Model restriction: This API can be used only in the stage model.
| Name | Value | Description |
|---|---|---|
| DESKTOP_MODE | 0 | Desktop mode. The device is in desktop mode when all the following conditions are met: 1. The current device is in the half-folded state (FoldStatus.FOLD_STATUS_HALF_FOLDED). 2. The width of creaseRects obtained through getLiveCreaseRegion() on the screen where the window is located is greater than the height. 3. The window mode is full-screen mode (WindowStatusType.FULL_SCREEN) or maximized mode (WindowStatusType.MAXIMIZE). 4. The screen crease region is within the window display area. |
Enumerates the types of areas to avoid for window content.
When adapting window content for an immersive layout, you should adjust the content based on the corresponding AvoidArea specified by AvoidAreaType.
| Name | Value | Description |
|---|---|---|
| TYPE_SYSTEM | 0 | Default area of the system. It usually indicates the status bar area. In a floating window, it indicates the three-dot control bar area of the main window of the application. System capability: SystemCapability.WindowManager.WindowManager.Core Atomic service API: This API can be used in atomic services since API version 11. |
| TYPE_CUTOUT | 1 | Cutout area. System capability: SystemCapability.WindowManager.WindowManager.Core Atomic service API: This API can be used in atomic services since API version 11. |
| TYPE_SYSTEM_GESTURE9+ | 2 | Side return gesture area. Currently, no devices support this type of avoid area. System capability: SystemCapability.WindowManager.WindowManager.Core Atomic service API: This API can be used in atomic services since API version 11. |
| TYPE_KEYBOARD9+ | 3 | Fixed soft keyboard area. System capability: SystemCapability.WindowManager.WindowManager.Core Atomic service API: This API can be used in atomic services since API version 11. |
| TYPE_NAVIGATION_INDICATOR11+ | 4 | Bottom navigation bar. When a three-button navigation bar is displayed, the bottom navigation bar avoid area always exists. System capability: SystemCapability.WindowManager.WindowManager.Core Atomic service API: This API can be used in atomic services since API version 11. |
| TYPE_FLOAT_NAVIGATION | 5 | Three-button navigation bar. It may appear as a navigation bar or a three-button navigation bar depending on user settings. System capability: SystemCapability.Window.SessionManager Since: 26.0.0 Model restriction: This API can be used only in the stage model. Atomic service API: This API can be used in atomic services since API version 26.0.0. |
Enumerates the split ratio types of a window.
Since: 26.0.0
Model restriction: This API can be used only in the stage model.
System capability: SystemCapability.WindowManager.WindowManager.Core
| Name | Value | Description |
|---|---|---|
| EQUAL | 0 | The system allocates the same window ratio to the primary and secondary split-screen windows. This is the default value when no field value is specified. |
| PRIMARY_DOMINANT | 1 | The system allocates the larger available ratio allowed by the current device to the primary split-screen window. |
| SECONDARY_DOMINANT | 2 | The system allocates the larger available ratio allowed by the current device to the secondary split-screen window. |
Enumerates the window orientations.
| Name | Value | Description |
|---|---|---|
| UNSPECIFIED | 0 | Unspecified. The orientation is determined by the system. Atomic service API: This API can be used in atomic services since API version 12. System capability: SystemCapability.WindowManager.WindowManager.Core |
| PORTRAIT | 1 | Portrait. System capability: SystemCapability.WindowManager.WindowManager.Core Atomic service API: This API can be used in atomic services since API version 11. |
| LANDSCAPE | 2 | Landscape. Atomic service API: This API can be used in atomic services since API version 12. System capability: SystemCapability.WindowManager.WindowManager.Core |
| PORTRAIT_INVERTED | 3 | Reverse portrait. System capability: SystemCapability.WindowManager.WindowManager.Core Atomic service API: This API can be used in atomic services since API version 12. |
| LANDSCAPE_INVERTED | 4 | Reverse landscape. System capability: SystemCapability.WindowManager.WindowManager.Core Atomic service API: This API can be used in atomic services since API version 12. |
| AUTO_ROTATION | 5 | Automatically rotates with the sensor to four orientations: portrait, landscape, reverse portrait, and reverse landscape. This rotation is not controlled by the rotation switch in Control Panel. System capability: SystemCapability.WindowManager.WindowManager.Core Atomic service API: This API can be used in atomic services since API version 11. |
| AUTO_ROTATION_PORTRAIT | 6 | Automatically rotates with the sensor to two orientations: portrait and reverse portrait. This rotation is not controlled by the rotation switch in Control Panel. Atomic service API: This API can be used in atomic services since API version 12. System capability: SystemCapability.WindowManager.WindowManager.Core |
| AUTO_ROTATION_LANDSCAPE | 7 | Automatically rotates with the sensor to two orientations: landscape and reverse landscape. This rotation is not controlled by the rotation switch in Control Panel. System capability: SystemCapability.WindowManager.WindowManager.Core Atomic service API: This API can be used in atomic services since API version 12. |
| AUTO_ROTATION_RESTRICTED | 8 | Automatically rotates with the sensor to four orientations: portrait, landscape, reverse portrait, and reverse landscape. This rotation is controlled by the rotation switch in Control Panel. System capability: SystemCapability.WindowManager.WindowManager.Core Atomic service API: This API can be used in atomic services since API version 12. |
| AUTO_ROTATION_PORTRAIT_RESTRICTED | 9 | Automatically rotates with the sensor to two orientations: portrait and reverse portrait. This rotation is controlled by the rotation switch in Control Panel. Atomic service API: This API can be used in atomic services since API version 12. System capability: SystemCapability.WindowManager.WindowManager.Core |
| AUTO_ROTATION_LANDSCAPE_RESTRICTED | 10 | Automatically rotates with the sensor to two orientations: landscape and reverse landscape. This rotation is controlled by the rotation switch in Control Panel. Atomic service API: This API can be used in atomic services since API version 12. System capability: SystemCapability.WindowManager.WindowManager.Core |
| LOCKED | 11 | Locked mode, where the window orientation is consistent with the current screen orientation. Atomic service API: This API can be used in atomic services since API version 12. System capability: SystemCapability.WindowManager.WindowManager.Core |
| AUTO_ROTATION_UNSPECIFIED12+ | 12 | Automatically rotates with the sensor, under the restriction of the rotation switch in Control Panel. The orientation that can be rotated to is determined by the system. For example, the window can rotate to portrait, landscape, or reverse landscape, but not reverse portrait, on a bar-type phone. Atomic service API: This API can be used in atomic services since API version 12. System capability: SystemCapability.Window.SessionManager |
| USER_ROTATION_PORTRAIT12+ | 13 | Temporarily rotates to portrait mode, and then automatically rotates with the sensor, under the restriction of the rotation switch in Control Panel. The orientation that can be rotated to is determined by the system. For example, the window can rotate to portrait, landscape, or reverse landscape, but not reverse portrait, on a bar-type phone. Atomic service API: This API can be used in atomic services since API version 12. System capability: SystemCapability.Window.SessionManager |
| USER_ROTATION_LANDSCAPE12+ | 14 | Temporarily rotates to landscape mode, and then automatically rotates with the sensor, under the restriction of the rotation switch in Control Panel. The orientation that can be rotated to is determined by the system. For example, the window can rotate to portrait, landscape, or reverse landscape, but not reverse portrait, on a bar-type phone. Atomic service API: This API can be used in atomic services since API version 12. System capability: SystemCapability.Window.SessionManager |
| USER_ROTATION_PORTRAIT_INVERTED12+ | 15 | Temporarily rotates to reverse portrait mode, and then automatically rotates with the sensor, under the restriction of the rotation switch in Control Panel. The orientation that can be rotated to is determined by the system. For example, the window can rotate to portrait, landscape, or reverse landscape, but not reverse portrait, on a bar-type phone. Atomic service API: This API can be used in atomic services since API version 12. System capability: SystemCapability.Window.SessionManager |
| USER_ROTATION_LANDSCAPE_INVERTED12+ | 16 | Temporarily rotates to reverse landscape mode, and then automatically rotates with the sensor, under the restriction of the rotation switch in Control Panel. The orientation that can be rotated to is determined by the system. For example, the window can rotate to portrait, landscape, or reverse landscape, but not reverse portrait, on a bar-type phone. Atomic service API: This API can be used in atomic services since API version 12. System capability: SystemCapability.Window.SessionManager |
| FOLLOW_DESKTOP12+ | 17 | Follows the orientation of the home screen, where the window will rotate if the home screen rotates and will not rotate if the home screen does not. Atomic service API: This API can be used in atomic services since API version 12. System capability: SystemCapability.Window.SessionManager |
Enumerates the window levels (z-order) to which the main window can be adjusted.
Since: 26.0.1
Model restriction: This API can be used only in the stage model.
System capability: SystemCapability.Window.SessionManager
| Name | Value | Description |
|---|---|---|
| NOT_TOPMOST | -3 | Cancels topmost. After cancellation, the main window is no longer displayed above other application windows. If the main window is currently topmost, the ohos.permission.WINDOW_TOPMOST permission is required for cancellation. If a non-topmost window is set to cancel topmost, this permission is not required, and the setting takes no effect. |
| TOPMOST | -2 | Topmost. Places the main window above other application windows to ensure it is not obscured, and keeps it topmost until topmost is canceled. When multiple main windows are topmost at the same time, the window set to topmost later is displayed above other topmost windows. The ohos.permission.WINDOW_TOPMOST permission is required when setting this value. |
| BOTTOM | -1 | Places the main window at the bottom of all application main windows. |
| TOP | 0 | Places the main window at the top of all application main windows. This adjustment takes effect only once and does not keep the window topmost. A topmost (TOPMOST) window is always at the top layer, so if another main window is already topmost, the main window set with this value is placed below all topmost windows. |
Enumerates the reasons for window rectangle (position and size) changes.
System capability: SystemCapability.Window.SessionManager
Atomic service API: This API can be used in atomic services since API version 12.
| Name | Value | Description |
|---|---|---|
| UNDEFINED | 0 | Default value, indicating that the reason for the window rectangle change is undefined. |
| MAXIMIZE | 1 | The window enters maximization or full-screen mode. |
| RECOVER | 2 | The window restores from maximization mode, full-screen mode, or split-screen mode to the floating window mode. |
| MOVE | 3 | The window is moved. |
| DRAG | 4 | The window is zoomed in or out by dragging. |
| DRAG_START | 5 | The window starts zooming in or out. |
| DRAG_END | 6 | The window finishes zooming in or out. |
Enumerates the reasons for window focus state changes.
Since: 26.0.1
Model restriction: This API can be used only in the stage model.
System capability: SystemCapability.Window.SessionManager
| Name | Value | Description |
|---|---|---|
| DEFAULT | 0 | The focus state changes due to a default reason other than a user click. |
| CLICK | 1 | The focus state changes because the user clicks the window. |
Enumerates the color spaces.
Atomic service API: This API can be used in atomic services since API version 12.
System capability: SystemCapability.WindowManager.WindowManager.Core
| Name | Value | Description |
|---|---|---|
| DEFAULT | 0 | Default SRGB gamut. |
| WIDE_GAMUT | 1 | Wide-gamut. |
Enumerates the window lifecycle states.
Atomic service API: This API can be used in atomic services since API version 11.
| Name | Value | Description |
|---|---|---|
| WINDOW_SHOWN | 1 | The window is running in the foreground. System capability: SystemCapability.WindowManager.WindowManager.Core |
| WINDOW_ACTIVE | 2 | The window gains focus. System capability: SystemCapability.WindowManager.WindowManager.Core |
| WINDOW_INACTIVE | 3 | The window loses focus. System capability: SystemCapability.WindowManager.WindowManager.Core |
| WINDOW_HIDDEN | 4 | The window is running in the background. System capability: SystemCapability.WindowManager.WindowManager.Core |
| WINDOW_DESTROYED11+ | 7 | The window is destroyed. System capability: SystemCapability.Window.SessionManager |
Enumerates the window modes.
Atomic service API: This API can be used in atomic services since API version 12.
System capability: SystemCapability.Window.SessionManager
| Name | Value | Description |
|---|---|---|
| UNDEFINED | 0 | The window mode is not defined by the application. |
| FULL_SCREEN | 1 | The application is displayed in full screen. In freeform window state, the window occupies the entire screen with no dock, title bar, or status bar displayed by default. You can use maximize() and setTitleAndDockHoverShown() to configure whether to display the title bar and dock upon hovering over the hot zone. The last call takes precedence when both the maximize() and setTitleAndDockHoverShown() APIs are called. In non-freeform window state, the window occupies the entire screen with no title bar or dock displayed. You can use setSpecificSystemBarEnabled() to configure whether to display the status bar. |
| MAXIMIZE | 2 | The application window is maximized. In freeform window state, the window occupies the entire screen, and the dock, status bar, and title bar are displayed without requiring a hover. This state is unavailable in non-freeform window state. |
| MINIMIZE | 3 | The application window is minimized. |
| FLOATING | 4 | The application is displayed in a floating window. The window can be moved and resized freely, which is suitable for scenarios where multiple windows are used simultaneously. |
| SPLIT_SCREEN | 5 | The application is displayed in split-screen mode. The screen displays two application windows at the same time, each occupying half of the screen, which is suitable for scenarios where multiple tasks are processed in parallel. |
Enumerates the pixel units.
You can use px2vp and vp2px to convert between physical pixels and virtual pixels.
System capability: SystemCapability.Window.SessionManager
| Name | Value | Description |
|---|---|---|
| PX | 0 | Physical pixel unit (px). |
| VP | 1 | Virtual pixel unit (vp). |
Enumerates the layout when the window is maximized.
System capability: SystemCapability.Window.SessionManager
| Name | Value | Description |
|---|---|---|
| FOLLOW_APP_IMMERSIVE_SETTING | 0 | The window, when maximized, follows the application's full-screen mode. Atomic service API: This API can be used in atomic services since API version 12. |
| EXIT_IMMERSIVE | 1 | The window, when maximized, exits full-screen mode if it is set to full-screen. Atomic service API: This API can be used in atomic services since API version 12. |
| ENTER_IMMERSIVE | 2 | The window, when maximized, transitions into the full-screen mode, and the window title bar and dock bar are displayed when the cursor hovers over the hot zone. Atomic service API: This API can be used in atomic services since API version 12. |
| ENTER_IMMERSIVE_DISABLE_TITLE_AND_DOCK_HOVER14+ | 3 | The window, when maximized, transitions into the full-screen mode, and the window title bar and dock bar are not displayed when the cursor hovers over the hot zone. Atomic service API: This API can be used in atomic services since API version 14. |
Enumerates the cross-display presentation policies of a foldable device, used to control the waterfall-mode behavior when the main window is maximized in the hover state of a foldable 2-in-1 device.
Since: 26.0.0
Model restriction: This API can be used only in the stage model.
System capability: SystemCapability.Window.SessionManager
| Name | Value | Description |
|---|---|---|
| FOLLOW_ACROSS_DISPLAY_SETTING | 0 | Follows the current cross-display presentation policy setting. If no cross-display presentation policy has been set, the system default policy is used: in the hover state, the window enters single-screen maximization (that is, when maximized, the window is displayed only on the upper half or the lower half); in the unfolded state, the window is maximized and remains in waterfall mode when folded back to the hover state (that is, the window is displayed across the upper and lower halves). |
| ENTER_ACROSS_DISPLAY_MODE | 1 | In the hover state, the window directly enters waterfall mode; in the unfolded state, the window is maximized and remains in waterfall mode when folded back to the hover state. |
| EXIT_ACROSS_DISPLAY_MODE | 2 | In the hover state, the window exits waterfall mode and enters single-screen maximization; in the unfolded state, the window is maximized and exits waterfall mode when folded back to the hover state. |
Enumerates the types of window animation curves.
Atomic service API: This API can be used in atomic services since API version 20.
System capability: SystemCapability.Window.SessionManager
| Name | Value | Description |
|---|---|---|
| LINEAR | 0 | The animation speed is constant from start to finish. When this curve type is used, duration in WindowAnimationConfig is mandatory. When this curve type is used, param in WindowAnimationConfig is optional and does not take effect. |
| INTERPOLATION_SPRING | 1 | Interpolator spring curve, an animation curve from 0 to 1, where the actual animation values are interpolated based on the curve. The animation duration is subject to the curve parameters, rather than the duration parameter in WindowAnimationConfig. When this curve type is used, duration in WindowAnimationConfig is optional and does not take effect. When this curve type is used, param in WindowAnimationConfig is mandatory. |
| CUBIC_BEZIER | 2 | Cubic Bézier curve. When this curve type is used, param and duration in WindowAnimationConfig are mandatory. |
Enumerates the types of window transition animations.
Atomic service API: This API can be used in atomic services since API version 20.
System capability: SystemCapability.Window.SessionManager
| Name | Value | Description |
|---|---|---|
| DESTROY | 0 | Transition animation when the window is destroyed. |
Enumerates the types of window animations.
System capability: SystemCapability.Window.SessionManager
| Name | Value | Description |
|---|---|---|
| FADE_IN_OUT | 0 | Fade-in/fade-out animation. The fade-in animation takes effect during window display, and the fade-out animation takes effect during window hiding. |
Enumerates the window anchor points.
System capability: SystemCapability.Window.SessionManager
| Name | Value | Description |
|---|---|---|
| TOP_START | 0 | Top-left corner of the window. |
| TOP | 1 | Horizontal center point along the top edge of the window. |
| TOP_END | 2 | Top-right corner of the window. |
| START | 3 | Vertical center point along the left edge of the window. |
| CENTER | 4 | Center point of the window, both horizontally and vertically. |
| END | 5 | Vertical center point along the right edge of the window. |
| BOTTOM_START | 6 | Bottom-left corner of the window. |
| BOTTOM | 7 | Horizontal center point along the bottom edge of the window. |
| BOTTOM_END | 8 | Bottom-right corner of the window. |
Enumerates the types of window rotation events.
Atomic service API: This API can be used in atomic services since API version 19.
System capability: SystemCapability.Window.SessionManager
| Name | Value | Description |
|---|---|---|
| WINDOW_WILL_ROTATE | 0 | The window is about to rotate. |
| WINDOW_DID_ROTATE | 1 | The window has finished rotating. |
Enumerates the types of window rectangle coordinate systems.
Atomic service API: This API can be used in atomic services since API version 19.
System capability: SystemCapability.Window.SessionManager
| Name | Value | Description |
|---|---|---|
| RELATIVE_TO_SCREEN | 0 | The window rectangle is relative to the screen coordinate system. |
| RELATIVE_TO_PARENT_WINDOW | 1 | The window rectangle is relative to the parent window coordinate system. |
Enumerates the window modes.
Atomic service API: This API can be used in atomic services since API version 20.
System capability: SystemCapability.Window.SessionManager
| Name | Value | Description |
|---|---|---|
| FULLSCREEN | 1 | Full-screen window. The first binary bit from right to left is 1. |
| SPLIT | 1 << 1 | Split-screen window. The second binary bit from right to left is 1. |
| FLOAT | 1 << 2 | Floating window. The third binary bit from right to left is 1. |
| PIP | 1 << 3 | PiP window. The fourth binary bit from right to left is 1. |
Enumerates the window visibility states.
System capability: SystemCapability.Window.SessionManager
| Name | Value | Description |
|---|---|---|
| NO_OCCLUSION | 0 | The window is entirely visible, with no parts obscured by other non-transparent windows. |
| PARTIAL_OCCLUSION | 1 | The window is partially visible, with some parts obscured by other non-transparent windows. |
| FULL_OCCLUSION | 2 | The window is completely invisible, either fully obscured by other non-transparent windows, minimized, or hidden. |
Enumerates the lifecycle event types of a WindowStage.
Model restriction: This API can be used only in the stage model.
System capability: SystemCapability.WindowManager.WindowManager.Core
Atomic service API: This API can be used in atomic services since API version 11.
| Name | Value | Description |
|---|---|---|
| SHOWN | 1 | The WindowStage is shown in the foreground, for example, when launching from the application icon, triggered whether it is the first launch or resuming from the background. |
| ACTIVE | 2 | The WindowStage gains focus, for example, the state of the application window after handling a click event, or the state after the application is launched. |
| INACTIVE | 3 | The WindowStage loses focus, for example, the state of the window that was in focus when a new application is opened or another window is clicked. |
| HIDDEN | 4 | The WindowStage is running in the background, for example, when the application exists after swiping up or the application window is closed. |
| RESUMED11+ | 5 | The WindowStage is in the foreground and interactive, for example, when the application is open and can interact with the user. |
| PAUSED11+ | 6 | The WindowStage is in the foreground but not interactive, for example, when the application is in the foreground and is entering the multitasking screen. |
Enumerates the lifecycle state types of a WindowStage.
Model restriction: This API can be used only in the stage model.
System capability: SystemCapability.Window.SessionManager
| Name | Value | Description |
|---|---|---|
| SHOWN | 1 | The WindowStage is shown in the foreground, for example, when launching from the application icon, triggered whether it is the first launch or resuming from the background. |
| RESUMED | 2 | The WindowStage is in the foreground and interactive, for example, when the application is open and can interact with the user. |
| PAUSED | 3 | The WindowStage is in the foreground but not interactive, for example, when the application is in the foreground and is entering the multitasking screen. |
| HIDDEN | 4 | The WindowStage is running in the background, for example, when the application exists after swiping up or the application window is closed. |
Enumerates the modality types of the child window.
System capability: SystemCapability.Window.SessionManager
Atomic service API: This API can be used in atomic services since API version 14.
| Name | Value | Description |
|---|---|---|
| WINDOW_MODALITY | 0 | Select this value when only the parent window should not respond to user operations. |
| APPLICATION_MODALITY | 1 | Select this value when other instances of the application should also not respond to user operations. Device behavior differences: This enumeration can be called properly on a device that supports freeform windows and is in the freeform window state. On a device that supports freeform windows but is not in the freeform window state, or on a device that does not support freeform windows, this API returns error code 801. |
Enumerates the screenshot event types.
System capability: SystemCapability.WindowManager.WindowManager.Core
| Name | Value | Description |
|---|---|---|
| SYSTEM_SCREENSHOT | 0 | System screenshot succeeds. |
| SYSTEM_SCREENSHOT_ABORT | 1 | System screenshot aborted. |
| SCROLL_SHOT_START | 2 | Scroll screenshot starts. |
| SCROLL_SHOT_END | 3 | Scroll screenshot ends. |
| SCROLL_SHOT_ABORT | 4 | Scroll screenshot aborted. |
Enumerates the result of setting the window display orientation.
Since: 26.0.0
Model restriction: This API can be used only in the stage model.
Atomic service API: This API can be used in atomic services since API version 26.0.0.
System capability: SystemCapability.Window.SessionManager
| Name | Value | Description |
|---|---|---|
| ORIENTATION_APPLIED | 0 | The setting has taken effect. |
| ORIENTATION_IGNORED | 1 | The setting does not take effect. |
| ORIENTATION_PENDING | 2 | The setting will take effect after the system animation ends. |
Enumerates the types of rotation information.
System capability: SystemCapability.Window.SessionManager
| Name | Value | Description |
|---|---|---|
| WINDOW_ORIENTATION | 0 | Window's screen orientation, based on how the Window module defines landscape/portrait modes. Note that it maps to the orientation parameter in RotationChangeInfo. |
| DISPLAY_ORIENTATION | 1 | Physical screen orientation, based on how the Display module defines landscape/portrait modes. It maps to the orientation property of the display object. |
| DISPLAY_ROTATION | 2 | Physical rotation angle of the device's screen (in degrees, clockwise). It maps to the rotation property of the display object. |