目录

Window Mode Overview

When to Use

Window mode refers to the display state of a window on the device screen, including full-screen, maximized, minimized, floating window, and split-screen modes. It is an attribute of a single window.

By properly configuring and using window modes, apps can better adapt to different device forms and user interaction scenarios, delivering a superior multi-window experience.

Multi-window is a practical example of combining multiple window modes. It allows users to run multiple app windows simultaneously on the same screen at the same time in floating window, split-screen, or panoramic multi-window mode, thereby enabling multitasking.

The window mode capability allows users to use multiple app windows simultaneously. This capability differs between the freeform window state and the non-freeform window state:

Refer to the following sections for details on basic window mode capabilities, freeform window adaptation, and more.

Window Mode WindowStatusType

Window modes are described by the WindowStatusType enum, which defines the display states of an app window in different scenarios. You can select an appropriate window mode based on app requirements, or dynamically listen for window mode changes to perform corresponding adaptation. The following sections detail the characteristics of each window mode, how to detect window mode changes, and how to configure window mode policies.

Except that the FULL_SCREEN mode is always supported for the main window in non-freeform window states, all other window modes must have their corresponding support policies configured in advance before they can be triggered.

[h2]FULL_SCREEN

This mode is a display state in which the app window fills the entire screen.

Features:

Applicable scenarios:

Trigger methods:

[h2]MAXIMIZE

This mode means that the app window is maximized to fill the entire screen in the freeform window state, while the dock bar, status bar, and title bar remain visible.

Features:

Applicable scenarios:

When the app needs full-screen display in freeform window mode while keeping the dock bar, status bar, and title bar visible.

Trigger methods:

  • App subwindows support the FULL_SCREEN and MAXIMIZE modes only in the freeform window state, and the maximizeSupported parameter must be set to true when creating the subwindow. Alternatively, you can configure support through setSupportedWindowModes().

  • Key differences between FULL_SCREEN and MAXIMIZE:

    • FULL_SCREEN: The window is maximized to fill the entire screen. In the freeform window state, no dock bar, status bar, or title bar is displayed. In the non-freeform window state, no dock bar or title bar is displayed.

    • MAXIMIZE: The window is maximized to fill the entire screen, and the dock bar, status bar, and title bar are displayed.

    • The MAXIMIZE mode takes effect only in the freeform window state.

[h2]MINIMIZE

This mode refers to the state where the app window shrinks to the taskbar or dock and no longer displays content on the screen.

Features:

Applicable scenarios:

Trigger methods:

[h2]FLOATING

This mode allows an app window to be displayed as a floating window, with freely adjustable size and position.

In the freeform window state and the non-freeform window state, the floating window mode has different characteristics and applicable scenarios.

[h2]SPLIT_SCREEN

This mode is a state in which an app window occupies a portion of the screen and is displayed simultaneously with another window. Both in-app split-screen and cross-app split-screen are supported.

Features:

Applicable scenarios:

Scenarios where multiple apps are used in parallel for an extended period, such as viewing a document while composing an email, or comparing product prices across multiple apps.

Trigger methods:

Obtaining and Listening for Window Mode

An app can detect changes in the current window state by querying the window mode and listening for window mode change events, and then perform corresponding service adaptations accordingly.

The system provides the following related query and listening APIs.

API Description Trigger Timing Applicable Scenario
getWindowStatus() Obtains the current app window mode. When the app actively calls it. Scenarios where the current window mode needs to be obtained immediately for judgment, such as checking the current window mode before performing certain window operations to avoid calling related APIs in an unsupported window mode.
on('windowStatusChange') Enables listening for window mode changes. Triggered immediately when the window mode changes (window properties may not have been updated yet). Scenarios that require quick response to window mode changes without depending on window properties.
on('windowStatusDidChange') Enables listening for window mode changes. Triggered after the window mode changes and the Rect attribute update is complete. Scenarios where the exact window size and position need to be obtained immediately after a window mode change.

Customizing Window Mode Support Policies

An app can configure supported window modes in multiple ways to meet the requirements of different devices and scenarios. For main window and subwindow modes, four configuration methods are provided, listed below in descending order of priority:

Priority Configuration Method Supported Window Types Effective Scope
1 Configuring via setSupportedWindowModes() Main window, subwindow Takes effect only in freeform window state
2 Configuring via the startAbility() API Main window Takes effect only in freeform window state
3 Configuring via the metadata tag under the abilities tag in the module.json5 configuration file Main window Takes effect only in freeform window state
4 Configuring the supportWindowMode property under the abilities tag in the module.json5 Configuration File Main window Takes effect in all states
  • In non-freeform window states, window mode support can only be configured via the supportWindowMode attribute under the abilities tag in the module.json5 configuration file. Other configuration methods do not take effect.

  • In non-freeform window states, even if FULL_SCREEN is not included in the supportWindowMode attribute configured under the abilities tag, the app still supports full-screen mode display by default.

  • In the freeform window state, the FULL_SCREEN mode configured in supportWindowMode indicates that the window supports both windowStatusType.FULL_SCREEN and windowStatusType.MAXIMIZE display modes.

  • For development and implementation of different window modes in multi-device scenarios, refer to Best Practices for Window Mode.

[h2]Configuring via setSupportedWindowModes()

The supported window modes are as follows:

Configuration Value Mode Description
SupportWindowMode.FULL_SCREEN Full-screen mode The window supports full-screen display.
SupportWindowMode.SPLIT Split-screen mode The main window does not support configuring SPLIT alone; it must be used together with FULL_SCREEN and FLOATING. The subwindow does not support configuring SPLIT.
SupportWindowMode.FLOATING Floating mode The window supports floating display.

[h2]Configuring via the startAbility() API

When an app calls startAbility(), it can specify the window modes supported at startup through the supportWindowMode parameter in StartOptions.

Supported mode values (For details, see bundleManager.SupportWindowMode):

Name Mode Description
bundleManager.SupportWindowMode.FULL_SCREEN Full-screen mode The window supports full-screen display.
bundleManager.SupportWindowMode.SPLIT Split-screen mode The window supports split-screen display.
bundleManager.SupportWindowMode.FLOATING Floating window mode The window supports floating display.

[h2]Configuring via the metadata Tag Under the abilities Tag in the module.json5 Configuration File

Through the metadata tag under the abilities in the module.json5 configuration file, you can set window-related metadata attributes, including supported window modes in freeform multi-window.

Configuration Item Description:

Configuration Item Description Value
name Metadata name "ohos.ability.window.supportWindowModeInFreeMultiWindow"
value Supported window modes

String. Multiple modes can be configured, separated by commas without regard to order and without spaces. The supported modes are:

- "fullscreen": Full-screen mode, where the app window is maximized to cover the entire screen.

- "split": Split-screen mode, where the app window occupies a portion of the screen and is displayed simultaneously with another window.

- "floating": Floating window mode, where the app window is displayed as a floating window.

[h2]Configuring the supportWindowMode Attribute Under the abilities Tag in the module.json5 Configuration File

The supportWindowMode attribute under the abilities tag tag in the module.json5 configuration file specifies the window modes supported by the app.

Supported mode values:

Configuration Value Mode Description
"fullscreen" Full-screen mode The app window is maximized to cover the entire screen.
"split" Split-screen mode The app window occupies a portion of the screen and is displayed alongside another window.
"floating" Floating window mode The app window is displayed as a floating window.