1# @ohos.window (Window) (System API) 2 3The Window module provides basic window management capabilities, such as creating and destroying the current window, setting properties for the current window, and managing and scheduling windows. 4 5This module provides the following common window-related functions: 6 7- [Window](#window): window instance, which is the basic unit managed by the window manager. 8- [WindowStage](#windowstage9): window manager that manages windows. 9 10> **NOTE** 11> 12> - 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. 13> 14> - This topic describes only system APIs provided by the module. For details about its public APIs, see [@ohos.window (Window)](js-apis-window.md). 15 16## Modules to Import 17 18```ts 19import { window } from '@kit.ArkUI'; 20``` 21 22## WindowType<sup>7+</sup> 23 24 25Enumerates the window types. 26 27 28| Name | Value| Description | 29|-------------------------------------| ------ |----------------------------------------------------------------------------------------| 30| TYPE_INPUT_METHOD<sup>(deprecated)</sup> | 2 | Input method window.<br>**Model restriction**: This API can be used only in the stage model.<br>**System API**: This is a system API.<br>**NOTE**: This API is supported since API version 9 and deprecated since API version 13. There is no alternative window type. To control the input method, call [Input method framework APIs](../../inputmethod/inputmethod-application-guide.md).<br>**System capability**: SystemCapability.WindowManager.WindowManager.Core| 31| TYPE_STATUS_BAR<sup>9+</sup> | 3 | Status bar.<br>**Model restriction**: This API can be used only in the stage model.<br>**System API**: This is a system API.<br>**System capability**: SystemCapability.WindowManager.WindowManager.Core| 32| TYPE_PANEL<sup>9+</sup> | 4 | Notification panel.<br>**Model restriction**: This API can be used only in the stage model.<br>**System API**: This is a system API.<br>**System capability**: SystemCapability.WindowManager.WindowManager.Core| 33| TYPE_KEYGUARD<sup>9+</sup> | 5 | Lock screen.<br>**Model restriction**: This API can be used only in the stage model.<br>**System API**: This is a system API.<br>**System capability**: SystemCapability.WindowManager.WindowManager.Core| 34| TYPE_VOLUME_OVERLAY<sup>9+</sup> | 6 | Volume bar.<br>**Model restriction**: This API can be used only in the stage model.<br>**System API**: This is a system API.<br>**System capability**: SystemCapability.WindowManager.WindowManager.Core| 35| TYPE_NAVIGATION_BAR<sup>9+</sup> | 7 | Navigation bar.<br>**Model restriction**: This API can be used only in the stage model.<br>**System API**: This is a system API.<br>**System capability**: SystemCapability.WindowManager.WindowManager.Core| 36| TYPE_WALLPAPER<sup>9+</sup> | 9 | Wallpaper.<br>**Model restriction**: This API can be used only in the stage model.<br>**System API**: This is a system API.<br>**System capability**: SystemCapability.WindowManager.WindowManager.Core| 37| TYPE_DESKTOP<sup>9+</sup> | 10 | Home screen.<br>**Model restriction**: This API can be used only in the stage model.<br>**System API**: This is a system API.<br>**System capability**: SystemCapability.WindowManager.WindowManager.Core| 38| TYPE_LAUNCHER_RECENT<sup>9+</sup> | 11 | Recent tasks screen.<br>**Model restriction**: This API can be used only in the stage model.<br>**System API**: This is a system API.<br>**System capability**: SystemCapability.WindowManager.WindowManager.Core| 39| TYPE_LAUNCHER_DOCK<sup>9+</sup> | 12 | Dock bar on the home screen.<br>**Model restriction**: This API can be used only in the stage model.<br>**System API**: This is a system API.<br>**System capability**: SystemCapability.WindowManager.WindowManager.Core| 40| TYPE_VOICE_INTERACTION<sup>9+</sup> | 13 | Voice assistant.<br>**Model restriction**: This API can be used only in the stage model.<br>**System API**: This is a system API.<br>**System capability**: SystemCapability.WindowManager.WindowManager.Core| 41| TYPE_POINTER<sup>9+</sup> | 14 | Mouse.<br>**Model restriction**: This API can be used only in the stage model.<br>**System API**: This is a system API.<br>**System capability**: SystemCapability.WindowManager.WindowManager.Core| 42| TYPE_FLOAT_CAMERA<sup>9+</sup> | 15 | Floating camera window.<br>**Model restriction**: This API can be used only in the stage model.<br>**System API**: This is a system API.<br>**System capability**: SystemCapability.WindowManager.WindowManager.Core| 43| TYPE_SCREENSHOT<sup>9+</sup> | 17 | Screenshot window.<br>**Model restriction**: This API can be used only in the stage model.<br>**System API**: This is a system API.<br>**System capability**: SystemCapability.WindowManager.WindowManager.Core| 44| TYPE_SYSTEM_TOAST<sup>11+</sup> | 18 | Toast displayed at the top.<br>**Model restriction**: This API can be used only in the stage model.<br>**System API**: This is a system API.<br>**System capability**: SystemCapability.WindowManager.WindowManager.Core| 45| TYPE_DIVIDER<sup>11+</sup> | 19 | Divider.<br>**Model restriction**: This API can be used only in the stage model.<br>**System API**: This is a system API.<br>**System capability**: SystemCapability.WindowManager.WindowManager.Core| 46| TYPE_GLOBAL_SEARCH<sup>11+</sup> | 20 | Window used for global search.<br>**Model restriction**: This API can be used only in the stage model.<br>**System API**: This is a system API.<br>**System capability**: SystemCapability.WindowManager.WindowManager.Core| 47| TYPE_HANDWRITE<sup>12+</sup> | 21 | Stylus window.<br>**Model restriction**: This API can be used only in the stage model.<br>**System API**: This is a system API.<br>**System capability**: SystemCapability.Window.SessionManager| 48 49## WindowMode<sup>7+</sup> 50 51Enumerates the window modes. 52 53**System API**: This is a system API. 54 55**System capability**: SystemCapability.WindowManager.WindowManager.Core 56 57| Name | Value | Description | 58| ---------- | ---- | ----------------------------- | 59| UNDEFINED | 1 | The window mode is not defined by the application. | 60| FULLSCREEN | 2 | The application is displayed in full screen. | 61| PRIMARY | 3 | The application is displayed in the primary window in split-screen mode. | 62| SECONDARY | 4 | The application is displayed in the secondary window in split-screen mode. | 63| FLOATING | 5 | The application is displayed in a floating window.| 64 65## WindowLayoutMode<sup>9+</sup> 66 67Enumerates the window layout modes. 68 69**System API**: This is a system API. 70 71**System capability**: SystemCapability.WindowManager.WindowManager.Core 72 73| Name | Value | Description | 74| ---------- | ---- | ----------------------------- | 75| WINDOW_LAYOUT_MODE_CASCADE | 0 | Cascade mode. | 76| WINDOW_LAYOUT_MODE_TILE | 1 | Tile mode. | 77 78 79## BlurStyle<sup>9+</sup> 80 81Enumerates the window blur styles. 82 83**System API**: This is a system API. 84 85**System capability**: SystemCapability.WindowManager.WindowManager.Core 86 87| Name | Value | Description | 88| ------- | ---- | -------------------- | 89| OFF | 0 | Blur disabled. | 90| THIN | 1 | Thin blur.| 91| REGULAR | 2 | Regular blur.| 92| THICK | 3 | Thick blur.| 93 94## SystemBarRegionTint<sup>8+</sup> 95 96Describes the callback for a single system bar. 97 98**System API**: This is a system API. 99 100**System capability**: SystemCapability.WindowManager.WindowManager.Core 101 102| Name | Type | Readable| Writable| Description | 103| --------------- | ------------------------- | ---- | ---- | ------------------------------------------------------------ | 104| type | [WindowType](#windowtype7) | Yes | No | Type of the system bar whose properties are changed. Only the status bar and navigation bar are supported.| 105| isEnable | boolean | Yes | No | Whether the system bar is displayed. The value **true** means that the system bar is displayed, and **false** means the opposite.| 106| region | [Rect](js-apis-window.md#rect7) | Yes | No | Current position and size of the system bar. | 107| backgroundColor | string | Yes | No | Background color of the system bar. The value is a hexadecimal RGB or ARGB color code and is case insensitive, for example, **#00FF00** or **#FF00FF00**.| 108| contentColor | string | Yes | No | Color of the text on the system bar. | 109 110## SystemBarTintState<sup>8+</sup> 111 112Describes the callback for the current system bar. 113 114**System API**: This is a system API. 115 116**System capability**: SystemCapability.WindowManager.WindowManager.Core 117 118| Name | Type | Readable| Writable| Description | 119| ---------- | --------------------------------------------------- | ---- | ---- | ---------------------------- | 120| displayId | number | Yes | No | ID of the current physical screen. The value must be an integer. | 121| regionTint | Array<[SystemBarRegionTint](#systembarregiontint8)> | Yes | No | All system bar information that has been changed.| 122 123## ScaleOptions<sup>9+</sup> 124 125Describes the scale parameters. 126 127**System API**: This is a system API. 128 129**System capability**: SystemCapability.WindowManager.WindowManager.Core 130 131| Name | Type| Read Only| Mandatory| Description | 132| ------ | -------- | ---- | ---- | --------------------------------------------| 133| x | number | No | No | Scale factor along the x-axis. The value is a floating point number, and the default value is **1.0**. | 134| y | number | No | No | Scale factor along the y-axis. The value is a floating point number, and the default value is **1.0**. | 135| pivotX | number | No | No | X coordinate of the scale center. The value is a floating point number in the range [0.0, 1.0], and the default value is **0.5**.| 136| pivotY | number | No | No | Y coordinate of the scale center. The value is a floating point number in the range [0.0, 1.0], and the default value is **0.5**.| 137 138## RotateOptions<sup>9+</sup> 139 140Describes the rotation parameters. 141 142**System API**: This is a system API. 143 144**System capability**: SystemCapability.WindowManager.WindowManager.Core 145 146| Name | Type| Read Only| Mandatory| Description | 147| ------ | -------- | ---- |---- |---------------------------------------------| 148| x | number | No | No | Rotation angle around the x-axis. The value is a floating point number, and the default value is **0.0**. | 149| y | number | No | No | Rotation angle around the y-axis. The value is a floating point number, and the default value is **0.0**. | 150| z | number | No | No | Rotation angle around the z-axis. The value is a floating point number, and the default value is **0.0**. | 151| pivotX | number | No | No | X coordinate of the rotation center. The value is a floating point number in the range [0.0, 1.0], and the default value is **0.5**.| 152| pivotY | number | No | No | Y coordinate of the rotation center. The value is a floating point number in the range [0.0, 1.0], and the default value is **0.5**. | 153 154## TranslateOptions<sup>9+</sup> 155 156Describes the translation parameters. 157 158**System API**: This is a system API. 159 160**System capability**: SystemCapability.WindowManager.WindowManager.Core 161 162| Name| Type| Read Only| Mandatory| Description | 163| ---- | -------- | ---- | ---- | ---------------------------- | 164| x | number | No | No | Distance to translate along the x-axis. The value is a floating point number, the default value is 0.0, and the unit is px.| 165| y | number | No | No | Distance to translate along the y-axis. The value is a floating point number, the default value is 0.0, and the unit is px.| 166| z | number | No | No | Distance to translate along the z-axis. The value is a floating point number, the default value is 0.0, and the unit is px.| 167 168## WindowInfo<sup>12+</sup> 169 170Describes the window information. 171 172**System API**: This is a system API. 173 174**System capability**: SystemCapability.Window.SessionManager 175 176| Name | Type | Read Only| Optional| Description | 177| ------ | ------ | ---- | ---- | ------------------------------------------ | 178| rect | [Rect](js-apis-window.md#rect7) | Yes | No | Size of the rectangle that can be drawn in the window. The upper boundary and left boundary are calculated relative to the window.| 179| bundleName | string | Yes | No | Bundle name. | 180| abilityName | string | Yes | No | Ability name. | 181| windowId | number | Yes | No | Window ID. | 182| windowStatusType | [WindowStatusType](js-apis-window.md#windowstatustype11) | Yes | No | Window mode. | 183| isFocused<sup>14+</sup> | boolean | Yes | Yes | Whether the window gains focus. The value **true** means that the window gains focus, and **false** means the opposite. | 184 185## window.minimizeAll<sup>9+</sup> 186minimizeAll(id: number, callback: AsyncCallback<void>): void 187 188Minimizes all windows on a display. This API uses an asynchronous callback to return the result. 189 190**System API**: This is a system API. 191 192**System capability**: SystemCapability.WindowManager.WindowManager.Core 193 194**Parameters** 195 196| Name | Type | Mandatory| Description | 197| -------- | ------------------------- | ---- | -------------- | 198| id | number | Yes | ID of the [display](js-apis-display.md#display). The value must be an integer.| 199| callback | AsyncCallback<void> | Yes | Callback used to return the result. | 200 201**Error codes** 202 203For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Window Error Codes](errorcode-window.md). 204 205| ID| Error Message| 206| ------- | -------------------------------------------- | 207| 202 | Permission verification failed. A non-system application calls a system API. | 208| 401 | Parameter error. Possible cause: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. | 209| 801 | Capability not supported. Failed to call the API due to limited device capabilities. | 210| 1300003 | This window manager service works abnormally. | 211 212**Example** 213 214```ts 215import { display } from '@kit.ArkUI'; 216import { BusinessError } from '@kit.BasicServicesKit'; 217 218let displayClass: display.Display | null = null; 219displayClass = display.getDefaultDisplaySync(); 220 221try { 222 window.minimizeAll(displayClass.id, (err: BusinessError) => { 223 const errCode: number = err.code; 224 if (errCode) { 225 console.error(`Failed to minimize all windows. Cause code: ${err.code}, message: ${err.message}`); 226 return; 227 } 228 console.info('Succeeded in minimizing all windows.'); 229 }); 230} catch (exception) { 231 console.error(`Failed to minimize all windows. Cause code: ${exception.code}, message: ${exception.message}`); 232} 233``` 234 235## window.minimizeAll<sup>9+</sup> 236minimizeAll(id: number): Promise<void> 237 238Minimizes all windows on a display. This API uses a promise to return the result. 239 240**System API**: This is a system API. 241 242**System capability**: SystemCapability.WindowManager.WindowManager.Core 243 244**Parameters** 245 246| Name | Type | Mandatory| Description | 247| -------- | ------------------------- | ---- | -------------- | 248| id | number | Yes | ID of the [display](js-apis-display.md#display). The value must be an integer.| 249 250**Return value** 251 252| Type | Description | 253| ------------------- | ------------------------- | 254| Promise<void> | Promise that returns no value.| 255 256**Error codes** 257 258For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Window Error Codes](errorcode-window.md). 259 260| ID| Error Message| 261| ------- | -------------------------------------------- | 262| 202 | Permission verification failed. A non-system application calls a system API. | 263| 401 | Parameter error. Possible cause: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. | 264| 801 | Capability not supported. Failed to call the API due to limited device capabilities. | 265| 1300003 | This window manager service works abnormally. | 266 267**Example** 268 269```ts 270import { display } from '@kit.ArkUI'; 271import { BusinessError } from '@kit.BasicServicesKit'; 272 273let displayClass: display.Display | null = null; 274displayClass = display.getDefaultDisplaySync(); 275 276try { 277 let promise = window.minimizeAll(displayClass.id); 278 promise.then(() => { 279 console.info('Succeeded in minimizing all windows.'); 280 }).catch((err: BusinessError) => { 281 console.error(`Failed to minimize all windows. Cause code: ${err.code}, message: ${err.message}`); 282 }); 283} catch (exception) { 284 console.error(`Failed to minimize all windows. Cause code: ${exception.code}, message: ${exception.message}`); 285} 286``` 287 288## window.toggleShownStateForAllAppWindows<sup>9+</sup> 289toggleShownStateForAllAppWindows(callback: AsyncCallback<void>): void 290 291Hides or restores the application's windows during quick multi-window switching. This API uses an asynchronous callback to return the result. 292 293**System API**: This is a system API. 294 295**System capability**: SystemCapability.WindowManager.WindowManager.Core 296 297**Parameters** 298 299| Name | Type | Mandatory| Description | 300| -------- | ------------------------- | ---- | -------------- | 301| callback | AsyncCallback<void> | Yes | Callback used to return the result. | 302 303**Error codes** 304 305For details about the error codes, see [Window Error Codes](errorcode-window.md). 306 307| ID| Error Message| 308| ------- | -------------------------------------------- | 309| 202 | Permission verification failed. A non-system application calls a system API. | 310| 801 | Capability not supported. Failed to call the API due to limited device capabilities. | 311| 1300003 | This window manager service works abnormally. | 312 313**Example** 314 315```ts 316import { BusinessError } from '@kit.BasicServicesKit'; 317 318window.toggleShownStateForAllAppWindows((err: BusinessError) => { 319 const errCode: number = err.code; 320 if (errCode) { 321 console.error(`Failed to toggle shown state for all app windows. Cause code: ${err.code}, message: ${err.message}`); 322 return; 323 } 324 console.info('Succeeded in toggling shown state for all app windows.'); 325}); 326``` 327 328## window.toggleShownStateForAllAppWindows<sup>9+</sup> 329toggleShownStateForAllAppWindows(): Promise<void> 330 331Hides or restores the application's windows during quick multi-window switching. This API uses a promise to return the result. 332 333**System API**: This is a system API. 334 335**System capability**: SystemCapability.WindowManager.WindowManager.Core 336 337**Return value** 338 339| Type | Description | 340| ------------------- | ------------------------- | 341| Promise<void> | Promise that returns no value.| 342 343**Error codes** 344 345For details about the error codes, see [Window Error Codes](errorcode-window.md). 346 347| ID| Error Message| 348| ------- | -------------------------------------------- | 349| 202 | Permission verification failed. A non-system application calls a system API. | 350| 801 | Capability not supported. Failed to call the API due to limited device capabilities. | 351| 1300003 | This window manager service works abnormally. | 352 353**Example** 354 355```ts 356import { BusinessError } from '@kit.BasicServicesKit'; 357 358let promise = window.toggleShownStateForAllAppWindows(); 359promise.then(() => { 360 console.info('Succeeded in toggling shown state for all app windows.'); 361}).catch((err: BusinessError) => { 362 console.error(`Failed to toggle shown state for all app windows. Cause code: ${err.code}, message: ${err.message}`); 363}); 364``` 365 366## window.setWindowLayoutMode<sup>9+</sup> 367setWindowLayoutMode(mode: WindowLayoutMode, callback: AsyncCallback<void>): void 368 369Sets the window layout mode. This API uses an asynchronous callback to return the result. 370 371**System API**: This is a system API. 372 373**System capability**: SystemCapability.WindowManager.WindowManager.Core 374 375**Parameters** 376 377| Name | Type | Mandatory| Description | 378| -------- | ------------------------- | ---- | -------------- | 379| mode | [WindowLayoutMode](#windowlayoutmode9) | Yes | Window layout mode to set.| 380| callback | AsyncCallback<void> | Yes | Callback used to return the result. | 381 382**Error codes** 383 384For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Window Error Codes](errorcode-window.md). 385 386| ID| Error Message| 387| ------- | -------------------------------------------- | 388| 202 | Permission verification failed. A non-system application calls a system API. | 389| 401 | Parameter error. Possible cause: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. | 390| 1300003 | This window manager service works abnormally. | 391 392**Example** 393 394```ts 395import { BusinessError } from '@kit.BasicServicesKit'; 396 397try { 398 window.setWindowLayoutMode(window.WindowLayoutMode.WINDOW_LAYOUT_MODE_CASCADE, (err: BusinessError) => { 399 const errCode: number = err.code; 400 if (errCode) { 401 console.error(`Failed to set window layout mode. Cause code: ${err.code}, message: ${err.message}`); 402 return; 403 } 404 console.info('Succeeded in setting window layout mode.'); 405 }); 406} catch (exception) { 407 console.error(`Failed to set window layout mode. Cause code: ${exception.code}, message: ${exception.message}`); 408} 409``` 410 411## window.setWindowLayoutMode<sup>9+</sup> 412setWindowLayoutMode(mode: WindowLayoutMode): Promise<void> 413 414Sets the window layout mode. This API uses a promise to return the result. 415 416**System API**: This is a system API. 417 418**System capability**: SystemCapability.WindowManager.WindowManager.Core 419 420**Parameters** 421 422| Name | Type | Mandatory| Description | 423| -------- | ------------------------- | ---- | -------------- | 424| mode | [WindowLayoutMode](#windowlayoutmode9) | Yes | Window layout mode to set.| 425 426**Return value** 427 428| Type | Description | 429| ------------------- | ------------------------- | 430| Promise<void> | Promise that returns no value.| 431 432**Error codes** 433 434For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Window Error Codes](errorcode-window.md). 435 436| ID| Error Message| 437| ------- | -------------------------------------------- | 438| 202 | Permission verification failed. A non-system application calls a system API. | 439| 401 | Parameter error. Possible cause: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. | 440| 1300003 | This window manager service works abnormally. | 441 442**Example** 443 444```ts 445import { BusinessError } from '@kit.BasicServicesKit'; 446 447try { 448 let promise = window.setWindowLayoutMode(window.WindowLayoutMode.WINDOW_LAYOUT_MODE_CASCADE); 449 promise.then(() => { 450 console.info('Succeeded in setting window layout mode.'); 451 }).catch((err: BusinessError) => { 452 console.error(`Failed to set window layout mode. Cause code: ${err.code}, message: ${err.message}`); 453 }); 454} catch (exception) { 455 console.error(`Failed to set window layout mode. Cause code: ${exception.code}, message: ${exception.message}`); 456} 457``` 458 459## window.on('systemBarTintChange')<sup>8+</sup> 460 461on(type: 'systemBarTintChange', callback: Callback<SystemBarTintState>): void 462 463Subscribes to the property change event of the status bar and navigation bar. 464 465**System API**: This is a system API. 466 467**System capability**: SystemCapability.WindowManager.WindowManager.Core 468 469**Parameters** 470 471| Name | Type | Mandatory| Description | 472| -------- | ---------------------------------------------------------- | ---- | ------------------------------------------------------------ | 473| type | string | Yes | Event type. The value is fixed at **'systemBarTintChange'**, indicating the property change event of the status bar and navigation bar.| 474| callback | Callback<[SystemBarTintState](#systembartintstate8)> | Yes | Callback used to return the properties of the status bar and navigation bar. | 475 476**Error codes** 477 478For details about the error codes, see [Universal Error Codes](../errorcode-universal.md). 479 480| ID| Error Message| 481| ------- | -------------------------------- | 482| 202 | Permission verification failed. A non-system application calls a system API. | 483| 401 | Parameter error. Possible cause: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. | 484 485**Example** 486 487```ts 488try { 489 window.on('systemBarTintChange', (data) => { 490 console.info('Succeeded in enabling the listener for systemBarTint changes. Data: ' + JSON.stringify(data)); 491 }); 492} catch (exception) { 493 console.error(`Failed to enable the listener for systemBarTint changes. Cause code: ${exception.code}, message: ${exception.message}`); 494} 495``` 496 497## window.off('systemBarTintChange')<sup>8+</sup> 498 499off(type: 'systemBarTintChange', callback?: Callback<SystemBarTintState >): void 500 501Unsubscribes from the property change event of the status bar and navigation bar. 502 503**System API**: This is a system API. 504 505**System capability**: SystemCapability.WindowManager.WindowManager.Core 506 507**Parameters** 508 509| Name | Type | Mandatory| Description | 510| -------- | ---------------------------------------------------------- | ---- | ------------------------------------------------------------ | 511| type | string | Yes | Event type. The value is fixed at **'systemBarTintChange'**, indicating the property change event of the status bar and navigation bar.| 512| callback | Callback<[SystemBarTintState](#systembartintstate8)> | No | Callback used to return the properties of the status bar and navigation bar. If a value is passed in, the corresponding subscription is canceled. If no value is passed in, all subscriptions to the specified event are canceled. | 513 514**Error codes** 515 516For details about the error codes, see [Universal Error Codes](../errorcode-universal.md). 517 518| ID| Error Message| 519| ------- | -------------------------------- | 520| 202 | Permission verification failed. A non-system application calls a system API. | 521| 401 | Parameter error. Possible cause: 1. Incorrect parameter types; 2. Parameter verification failed. | 522 523**Example** 524 525```ts 526const callback = (systemBarTintState: window.SystemBarTintState) => { 527 // ... 528} 529try { 530 window.on('systemBarTintChange', callback); 531 532 window.off('systemBarTintChange', callback); 533 // Unregister all the callbacks that have been registered through on(). 534 window.off('systemBarTintChange'); 535} catch (exception) { 536 console.error(`Failed to enable or disable the listener for systemBarTint changes. Cause code: ${exception.code}, message: ${exception.message}`); 537} 538``` 539 540## window.on('gestureNavigationEnabledChange')<sup>10+</sup> 541 542on(type: 'gestureNavigationEnabledChange', callback: Callback<boolean>): void 543 544Subscribes to the gesture navigation status change event. 545 546**System API**: This is a system API. 547 548**System capability**: SystemCapability.WindowManager.WindowManager.Core 549 550**Parameters** 551 552| Name | Type | Mandatory| Description | 553| -------- | ----------------------- | ---- | ----------------------------------------------------------------------------- | 554| type | string | Yes | Event type. The value is fixed at **'gestureNavigationEnabledChange'**, indicating the gesture navigation status change event. | 555| callback | Callback<boolean> | Yes | Callback used to return the gesture navigation status. The value **true** means that the gesture navigation status is changed to enabled, and **false** means that the gesture navigation status is changed to disabled.| 556 557**Error codes** 558 559For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Window Error Codes](errorcode-window.md). 560 561| ID| Error Message| 562| ------- | -------------------------------------------- | 563| 202 | Permission verification failed. A non-system application calls a system API. | 564| 401 | Parameter error. Possible cause: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. | 565| 1300002 | This window state is abnormal. | 566| 1300003 | This window manager service works abnormally. | 567 568**Example** 569 570```ts 571try { 572 window.on('gestureNavigationEnabledChange', (data) => { 573 console.info('Succeeded in enabling the listener for gesture navigation status changes. Data: ' + JSON.stringify(data)); 574 }); 575} catch (exception) { 576 console.error(`Failed to enable the listener for gesture navigation status changes. Cause code: ${exception.code}, message: ${exception.message}`); 577} 578``` 579 580## window.off('gestureNavigationEnabledChange')<sup>10+</sup> 581 582off(type: 'gestureNavigationEnabledChange', callback?: Callback<boolean>): void 583 584Unsubscribes from the gesture navigation status change event. 585 586**System API**: This is a system API. 587 588**System capability**: SystemCapability.WindowManager.WindowManager.Core 589 590**Parameters** 591 592| Name | Type | Mandatory| Description | 593| -------- | ----------------------- | -- | ------------------------------------------------------------ | 594| type | string | Yes| Event type. The value is fixed at **'gestureNavigationEnabledChange'**, indicating the gesture navigation status change event.| 595| callback | Callback<boolean> | No| Callback function that has been used for the subscription. If a value is passed in, the corresponding subscription is canceled. If no value is passed in, all subscriptions to the specified event are canceled.| 596 597**Error codes** 598 599For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Window Error Codes](errorcode-window.md). 600 601| ID| Error Message| 602| ------- | -------------------------------------------- | 603| 202 | Permission verification failed. A non-system application calls a system API. | 604| 401 | Parameter error. Possible cause: 1. Incorrect parameter types; 2. Parameter verification failed. | 605| 1300002 | This window state is abnormal. | 606| 1300003 | This window manager service works abnormally. | 607 608**Example** 609 610```ts 611const callback = (bool: boolean) => { 612 // ... 613} 614try { 615 window.on('gestureNavigationEnabledChange', callback); 616 window.off('gestureNavigationEnabledChange', callback); 617 // Unregister all the callbacks that have been registered through on(). 618 window.off('gestureNavigationEnabledChange'); 619} catch (exception) { 620 console.error(`Failed to enable or disable the listener for gesture navigation status changes. Cause code: ${exception.code}, message: ${exception.message}`); 621} 622``` 623 624## window.on('waterMarkFlagChange')<sup>10+</sup> 625 626on(type: 'waterMarkFlagChange', callback: Callback<boolean>): void 627 628Subscribes to the watermark status change event. 629 630**System API**: This is a system API. 631 632**System capability**: SystemCapability.WindowManager.WindowManager.Core 633 634**Parameters** 635 636| Name | Type | Mandatory| Description | 637| -------- | ----------------------- | ---- | ----------------------------------------------------------------------------- | 638| type | string | Yes | Event type. The value is fixed at **'waterMarkFlagChange'**, indicating the watermark status change event. | 639| callback | Callback<boolean> | Yes | Callback used to return the watermark status. The value **true** means that the watermark feature is enabled, and **false** means the opposite.| 640 641**Error codes** 642 643For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Window Error Codes](errorcode-window.md). 644 645| ID| Error Message| 646| ------- | -------------------------------------------- | 647| 202 | Permission verification failed. A non-system application calls a system API. | 648| 401 | Parameter error. Possible cause: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. | 649| 1300003 | This window manager service works abnormally. | 650 651**Example** 652 653```ts 654try { 655 window.on('waterMarkFlagChange', (data) => { 656 console.info('Succeeded in enabling the listener for watermark flag changes. Data: ' + JSON.stringify(data)); 657 }); 658} catch (exception) { 659 console.error(`Failed to enable the listener for watermark flag changes. Cause code: ${exception.code}, message: ${exception.message}`); 660} 661``` 662 663## window.off('waterMarkFlagChange')<sup>10+</sup> 664 665off(type: 'waterMarkFlagChange', callback?: Callback<boolean>): void 666 667Unsubscribes from the watermark status change event. 668 669**System API**: This is a system API. 670 671**System capability**: SystemCapability.WindowManager.WindowManager.Core 672 673**Parameters** 674 675| Name | Type | Mandatory| Description | 676| -------- | ----------------------- | -- | ------------------------------------------------------------ | 677| type | string | Yes| Event type. The value is fixed at **'waterMarkFlagChange'**, indicating the watermark status change event.| 678| callback | Callback<boolean> | No| Callback function that has been used for the subscription. If a value is passed in, the corresponding subscription is canceled. If no value is passed in, all subscriptions to the specified event are canceled.| 679 680**Error codes** 681 682For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Window Error Codes](errorcode-window.md). 683 684| ID| Error Message| 685| ------- | -------------------------------------------- | 686| 202 | Permission verification failed. A non-system application calls a system API. | 687| 401 | Parameter error. Possible cause: 1. Incorrect parameter types; 2. Parameter verification failed. | 688| 1300003 | This window manager service works abnormally. | 689 690**Example** 691 692```ts 693const callback = (bool: boolean) => { 694 // ... 695} 696try { 697 window.on('waterMarkFlagChange', callback); 698 window.off('waterMarkFlagChange', callback); 699 // Unregister all the callbacks that have been registered through on(). 700 window.off('waterMarkFlagChange'); 701} catch (exception) { 702 console.error(`Failed to enable or disable the listener for watermark flag changes. Cause code: ${exception.code}, message: ${exception.message}`); 703} 704``` 705 706## window.setGestureNavigationEnabled<sup>10+</sup> 707setGestureNavigationEnabled(enable: boolean, callback: AsyncCallback<void>): void 708 709Enables or disables gesture navigation. This API uses an asynchronous callback to return the result. 710 711For security purposes, the system does not interfere with the disabling and enabling of gesture navigation. If an application exits abnormally after it disables gesture navigation and wants to restore gesture navigation, it must implement automatic launch and call this API again to enable gesture navigation. 712 713**System API**: This is a system API. 714 715**System capability**: SystemCapability.WindowManager.WindowManager.Core 716 717**Parameters** 718 719| Name | Type | Mandatory| Description | 720| -------- | ------------------------- | ---- | -------------- | 721| enable | boolean | Yes | Whether to enable gesture navigation. The value **true** means to enable gesture navigation, and **false** means the opposite.| 722| callback | AsyncCallback<void> | Yes | Callback used to return the result.| 723 724**Error codes** 725 726For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Window Error Codes](errorcode-window.md). 727 728| ID| Error Message| 729| ------- | --------------------------------------------- | 730| 202 | Permission verification failed. A non-system application calls a system API. | 731| 401 | Parameter error. Possible cause: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. | 732| 1300002 | This window state is abnormal. | 733| 1300003 | This window manager service works abnormally. | 734 735**Example** 736 737```ts 738import { BusinessError } from '@kit.BasicServicesKit'; 739 740try { 741 window.setGestureNavigationEnabled(true, (err: BusinessError) => { 742 const errCode: number = err.code; 743 if (errCode) { 744 console.error(`Failed to set gesture navigation enabled. Cause code: ${err.code}, message: ${err.message}`); 745 return; 746 } 747 console.info('Succeeded in setting gesture navigation enabled.'); 748 }); 749} catch (exception) { 750 console.error(`Failed to set gesture navigation enabled. Cause code: ${exception.code}, message: ${exception.message}`); 751} 752``` 753 754## window.setGestureNavigationEnabled<sup>10+</sup> 755setGestureNavigationEnabled(enable: boolean): Promise<void> 756 757Enables or disables gesture navigation. This API uses a promise to return the result. 758 759For security purposes, the system does not interfere with the disabling and enabling of gesture navigation. If an application exits abnormally after it disables gesture navigation and wants to restore gesture navigation, it must implement automatic launch and call this API again to enable gesture navigation. 760 761**System API**: This is a system API. 762 763**System capability**: SystemCapability.WindowManager.WindowManager.Core 764 765**Parameters** 766 767| Name| Type | Mandatory | Description | 768| ------ | ------- | ---- | -------------------- | 769| enable | boolean | Yes | Whether to enable gesture navigation. The value **true** means to enable gesture navigation, and **false** means the opposite.| 770 771**Return value** 772 773| Type | Description | 774| ------------------- | ------------------------- | 775| Promise<void> | Promise that returns no value.| 776 777**Error codes** 778 779For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Window Error Codes](errorcode-window.md). 780 781| ID| Error Message| 782| ------- | -------------------------------------------- | 783| 202 | Permission verification failed. A non-system application calls a system API. | 784| 401 | Parameter error. Possible cause: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. | 785| 1300002 | This window state is abnormal. | 786| 1300003 | This window manager service works abnormally. | 787 788**Example** 789 790```ts 791import { BusinessError } from '@kit.BasicServicesKit'; 792 793try { 794 let promise = window.setGestureNavigationEnabled(true); 795 promise.then(() => { 796 console.info('Succeeded in setting gesture navigation enabled.'); 797 }).catch((err: BusinessError) => { 798 console.error(`Failed to set gesture navigation enabled. Cause code: ${err.code}, message: ${err.message}`); 799 }); 800} catch (exception) { 801 console.error(`Failed to set gesture navigation enabled. Cause code: ${exception.code}, message: ${exception.message}`); 802} 803``` 804 805## window.setWaterMarkImage<sup>10+</sup> 806setWaterMarkImage(pixelMap: image.PixelMap, enable: boolean, callback: AsyncCallback<void>): void 807 808Sets the watermark image display status. This API uses an asynchronous callback to return the result. 809 810**System API**: This is a system API. 811 812**System capability**: SystemCapability.WindowManager.WindowManager.Core 813 814**Parameters** 815 816| Name | Type | Mandatory| Description | 817| -------- | ------------------------- | ---- | -------------- | 818| pixelMap | [image.PixelMap](../apis-image-kit/js-apis-image.md#pixelmap7) | Yes| Watermark image.| 819| enable | boolean | Yes | Whether to display the watermark image. The value **true** means to display the watermark image, and **false** means the opposite.| 820| callback | AsyncCallback<void> | Yes | Callback used to return the result.| 821 822**Error codes** 823 824For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Window Error Codes](errorcode-window.md). 825 826| ID| Error Message| 827| ------- | --------------------------------------------- | 828| 202 | Permission verification failed. A non-system application calls a system API. | 829| 401 | Parameter error. Possible cause: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. | 830| 1300003 | This window manager service works abnormally. | 831 832**Example** 833 834```ts 835import { image } from '@kit.ImageKit'; 836import { BusinessError } from '@kit.BasicServicesKit'; 837 838let enable: boolean = true; 839let color: ArrayBuffer = new ArrayBuffer(0); 840let initializationOptions: image.InitializationOptions = { 841 size: { 842 height: 100, 843 width: 100 844 } 845}; 846image.createPixelMap(color, initializationOptions).then((pixelMap: image.PixelMap) => { 847 console.info('Succeeded in creating pixelmap.'); 848 try { 849 window.setWaterMarkImage(pixelMap, enable, (err: BusinessError) => { 850 const errCode: number = err.code; 851 if (errCode) { 852 console.error(`Failed to show watermark image. Cause code: ${err.code}, message: ${err.message}`); 853 return; 854 } 855 console.info('Succeeded in showing watermark image.'); 856 }); 857 } catch (exception) { 858 console.error(`Failed to show watermark image. Cause code: ${exception.code}, message: ${exception.message}`); 859 } 860}).catch((err: BusinessError) => { 861 console.error(`Failed to create PixelMap. Cause code: ${err.code}, message: ${err.message}`); 862}); 863``` 864 865## window.setWaterMarkImage<sup>10+</sup> 866setWaterMarkImage(pixelMap: image.PixelMap, enable: boolean): Promise<void> 867 868Sets the watermark image display status. This API uses a promise to return the result. 869 870**System API**: This is a system API. 871 872**System capability**: SystemCapability.WindowManager.WindowManager.Core 873 874**Parameters** 875 876| Name| Type | Mandatory | Description | 877| ------ | --------------------------- | ---- | -------------------- | 878| pixelMap | [image.PixelMap](../apis-image-kit/js-apis-image.md#pixelmap7) | Yes| Watermark image.| 879| enable | boolean | Yes | Whether to display the watermark image. The value **true** means to display the watermark image, and **false** means the opposite.| 880 881**Return value** 882 883| Type | Description | 884| ------------------- | ------------------------- | 885| Promise<void> | Promise that returns no value.| 886 887**Error codes** 888 889For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Window Error Codes](errorcode-window.md). 890 891| ID| Error Message| 892| ------- | -------------------------------------------- | 893| 202 | Permission verification failed. A non-system application calls a system API. | 894| 401 | Parameter error. Possible cause: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. | 895| 1300003 | This window manager service works abnormally. | 896 897**Example** 898 899```ts 900import { image } from '@kit.ImageKit'; 901import { BusinessError } from '@kit.BasicServicesKit'; 902 903let enable: boolean = true; 904let color: ArrayBuffer = new ArrayBuffer(0); 905let initializationOptions: image.InitializationOptions = { 906 size: { 907 height: 100, 908 width: 100 909 } 910}; 911image.createPixelMap(color, initializationOptions).then((pixelMap: image.PixelMap) => { 912 console.info('Succeeded in creating pixelmap.'); 913 try { 914 let promise = window.setWaterMarkImage(pixelMap, enable); 915 promise.then(() => { 916 console.info('Succeeded in showing watermark image.'); 917 }).catch((err: BusinessError) => { 918 console.error(`Failed to show watermark image. Cause code: ${err.code}, message: ${err.message}`); 919 }); 920 } catch (exception) { 921 console.error(`Failed to show watermark image. Cause code: ${exception.code}, message: ${exception.message}`); 922 } 923}).catch((err: BusinessError) => { 924 console.error(`Failed to create PixelMap. Cause code: ${err.code}, message: ${err.message}`); 925}); 926``` 927 928## window.getSnapshot<sup>12+</sup> 929 930getSnapshot(windowId: number): Promise<image.PixelMap> 931 932Obtains a snapshot of the same size as the specified window. This API uses a promise to return the result. 933 934**System API**: This is a system API. 935 936**System capability**: SystemCapability.WindowManager.WindowManager.Core 937 938**Parameters** 939| Name | Type | Mandatory | Description | 940| -------- | ------ | ----- | ------------ | 941| windowId | number | Yes | Window ID. You can call [getWindowProperties](js-apis-window.md#getwindowproperties9) to obtain the window properties, in which **id** is the window ID.| 942 943**Return value** 944| Type | Description | 945| ----------------------- | ------------------------------- | 946| Promise<[image.PixelMap](../apis-image-kit/js-apis-image.md#pixelmap7)> | Promise used to return the window screenshot.| 947 948**Error codes** 949For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Window Error Codes](errorcode-window.md). 950 951| ID| Error Message | 952| -------- | -------------------------------------------- | 953| 202 | Permission verification failed. A non-system application calls a system API. | 954| 401 | Parameter error. Possible cause: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. | 955| 1300002 | This window state is abnormal. | 956| 1300003 | This window manager service works abnormally. | 957| 1300004 | This operation is not accessible. | 958 959**Example** 960```ts 961import { BusinessError } from '@kit.BasicServicesKit'; 962import { image } from '@kit.ImageKit'; 963 964try { 965 // This is only an example. Use getWindowProperties to obtain the window ID. 966 let windowId: number = 40; 967 let promise = window.getSnapshot(windowId); 968 promise.then((pixelMap: image.PixelMap) => { 969 console.info('Succeeded in getting snapshot window. Pixel bytes number:' + pixelMap.getPixelBytesNumber()); 970 pixelMap.release(); 971 }).catch((err: BusinessError) =>{ 972 console.error(`Failed to get snapshot. Cause code: ${err.code}, message: ${err.message}`); 973 }); 974} catch (exception) { 975 console.error(`Failed to get snapshot. Cause code: ${exception.code}, message: ${exception.message}`); 976} 977``` 978 979## window.getVisibleWindowInfo<sup>12+</sup> 980 981getVisibleWindowInfo(): Promise<Array<WindowInfo>> 982 983Obtains information about visible windows on the current screen. Visible windows are windows that are not returned to the background. 984 985**System API**: This is a system API. 986 987**System capability**: SystemCapability.Window.SessionManager 988 989 990**Return value** 991 992| Type| Description| 993| ------------------- | ----------------------- | 994| Promise<[WindowInfo](#windowinfo12)> | Promise used to return the information about visible windows.| 995 996**Error codes** 997 998For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Window Error Codes](errorcode-window.md). 999 1000| ID| Error Message| 1001| ------- | ------------------------------ | 1002| 202 | Permission verification failed, non-system application uses system API. | 1003| 801 | Capability not supported. Failed to call the API due to limited device capabilities. | 1004| 1300003 | This window manager service works abnormally. | 1005 1006**Example** 1007 1008```ts 1009import { window } from '@kit.ArkUI'; 1010import { BusinessError } from '@kit.BasicServicesKit'; 1011 1012let promise = window.getVisibleWindowInfo(); 1013promise.then((data) => { 1014 data.forEach(windowInfo=>{ 1015 console.info(`left:${windowInfo.rect.left}`); 1016 console.info(`top:${windowInfo.rect.top}`); 1017 console.info(`width:${windowInfo.rect.width}`); 1018 console.info(`height:${windowInfo.rect.height}`); 1019 console.info(`windowId:${windowInfo.windowId}`); 1020 console.info(`windowStatusType:${windowInfo.windowStatusType}`); 1021 console.info(`abilityName:${windowInfo.abilityName}`); 1022 console.info(`bundleName:${windowInfo.bundleName}`); 1023 console.info(`isFocused:${windowInfo.isFocused}`); 1024 }) 1025}).catch((err: BusinessError) => { 1026 console.error('Failed to getWindowInfo. Cause: ' + JSON.stringify(err)); 1027}); 1028``` 1029 1030## Window 1031 1032Represents a window instance, which is the basic unit managed by the window manager. 1033 1034In the following API examples, you must use [getLastWindow()](js-apis-window.md#windowgetlastwindow9), [createWindow()](js-apis-window.md#windowcreatewindow9), or [findWindow()](js-apis-window.md#windowfindwindow9) to obtain a **Window** instance (named windowClass in this example) and then call a method in this instance. 1035 1036### hide<sup>7+</sup> 1037 1038hide (callback: AsyncCallback<void>): void 1039 1040Hides this window. This API uses an asynchronous callback to return the result. This API takes effect only for a system window or an application subwindow. 1041 1042**System API**: This is a system API. 1043 1044**System capability**: SystemCapability.WindowManager.WindowManager.Core 1045 1046**Parameters** 1047 1048| Name | Type | Mandatory| Description | 1049| -------- | ------------------------- | ---- | ---------- | 1050| callback | AsyncCallback<void> | Yes | Callback used to return the result.| 1051 1052**Error codes** 1053 1054For details about the error codes, see [Window Error Codes](errorcode-window.md). 1055 1056| ID| Error Message| 1057| ------- | ------------------------------ | 1058| 202 | Permission verification failed. A non-system application calls a system API. | 1059| 1300002 | This window state is abnormal. | 1060 1061**Example** 1062 1063```ts 1064import { BusinessError } from '@kit.BasicServicesKit'; 1065 1066windowClass.hide((err: BusinessError) => { 1067 const errCode: number = err.code; 1068 if (errCode) { 1069 console.error(`Failed to hide the window. Cause code: ${err.code}, message: ${err.message}`); 1070 return; 1071 } 1072 console.info('Succeeded in hiding the window.'); 1073}); 1074``` 1075 1076### hide<sup>7+</sup> 1077 1078hide(): Promise<void> 1079 1080Hides this window. This API uses a promise to return the result. This API takes effect only for a system window or an application subwindow. 1081 1082**System API**: This is a system API. 1083 1084**System capability**: SystemCapability.WindowManager.WindowManager.Core 1085 1086**Return value** 1087 1088| Type | Description | 1089| ------------------- | ------------------------- | 1090| Promise<void> | Promise that returns no value.| 1091 1092**Error codes** 1093 1094For details about the error codes, see [Window Error Codes](errorcode-window.md). 1095 1096| ID| Error Message| 1097| ------- | ------------------------------ | 1098| 202 | Permission verification failed. A non-system application calls a system API. | 1099| 1300002 | This window state is abnormal. | 1100 1101**Example** 1102 1103```ts 1104import { BusinessError } from '@kit.BasicServicesKit'; 1105 1106let promise = windowClass.hide(); 1107promise.then(() => { 1108 console.info('Succeeded in hiding the window.'); 1109}).catch((err: BusinessError) => { 1110 console.error(`Failed to hide the window. Cause code: ${err.code}, message: ${err.message}`); 1111}); 1112``` 1113 1114### hideWithAnimation<sup>9+</sup> 1115 1116hideWithAnimation(callback: AsyncCallback<void>): void 1117 1118Hides this window and plays an animation during the process. This API uses an asynchronous callback to return the result. This API takes effect only for a system window. 1119 1120**System API**: This is a system API. 1121 1122**System capability**: SystemCapability.WindowManager.WindowManager.Core 1123 1124**Parameters** 1125 1126| Name | Type | Mandatory| Description | 1127| -------- | ------------------------- | ---- | ---------- | 1128| callback | AsyncCallback<void> | Yes | Callback used to return the result.| 1129 1130**Error codes** 1131 1132For details about the error codes, see [Window Error Codes](errorcode-window.md). 1133 1134| ID| Error Message| 1135| ------- | -------------------------------------------- | 1136| 202 | Permission verification failed. A non-system application calls a system API. | 1137| 1300002 | This window state is abnormal. | 1138| 1300003 | This window manager service works abnormally. | 1139| 1300004 | Unauthorized operation. | 1140 1141**Example** 1142 1143```ts 1144import { BusinessError } from '@kit.BasicServicesKit'; 1145 1146windowClass.hideWithAnimation((err: BusinessError) => { 1147 const errCode: number = err.code; 1148 if (errCode) { 1149 console.error(`Failed to hide the window with animation. Cause code: ${err.code}, message: ${err.message}`); 1150 return; 1151 } 1152 console.info('Succeeded in hiding the window with animation.'); 1153}); 1154``` 1155 1156### hideWithAnimation<sup>9+</sup> 1157 1158hideWithAnimation(): Promise<void> 1159 1160Hides this window and plays an animation during the process. This API uses a promise to return the result. This API takes effect only for a system window. 1161 1162**System API**: This is a system API. 1163 1164**System capability**: SystemCapability.WindowManager.WindowManager.Core 1165 1166**Return value** 1167 1168| Type | Description | 1169| ------------------- | ------------------------- | 1170| Promise<void> | Promise that returns no value.| 1171 1172**Error codes** 1173 1174For details about the error codes, see [Window Error Codes](errorcode-window.md). 1175 1176| ID| Error Message| 1177| ------- | -------------------------------------------- | 1178| 202 | Permission verification failed. A non-system application calls a system API. | 1179| 1300002 | This window state is abnormal. | 1180| 1300003 | This window manager service works abnormally. | 1181| 1300004 | Unauthorized operation. | 1182 1183**Example** 1184 1185```ts 1186import { BusinessError } from '@kit.BasicServicesKit'; 1187 1188let promise = windowClass.hideWithAnimation(); 1189promise.then(() => { 1190 console.info('Succeeded in hiding the window with animation.'); 1191}).catch((err: BusinessError) => { 1192 console.error(`Failed to hide the window with animation. Cause code: ${err.code}, message: ${err.message}`); 1193}); 1194``` 1195 1196### showWithAnimation<sup>9+</sup> 1197 1198showWithAnimation(callback: AsyncCallback<void>): void 1199 1200Shows this window and plays an animation during the process. This API uses an asynchronous callback to return the result. This API takes effect only for a system window. 1201 1202**System API**: This is a system API. 1203 1204**System capability**: SystemCapability.WindowManager.WindowManager.Core 1205 1206**Parameters** 1207 1208| Name | Type | Mandatory| Description | 1209| -------- | ------------------------- | ---- | ---------- | 1210| callback | AsyncCallback<void> | Yes | Callback used to return the result.| 1211 1212**Error codes** 1213 1214For details about the error codes, see [Window Error Codes](errorcode-window.md). 1215 1216| ID| Error Message| 1217| ------- | -------------------------------------------- | 1218| 202 | Permission verification failed. A non-system application calls a system API. | 1219| 1300002 | This window state is abnormal. | 1220| 1300003 | This window manager service works abnormally. | 1221| 1300004 | Unauthorized operation. | 1222 1223**Example** 1224 1225```ts 1226import { BusinessError } from '@kit.BasicServicesKit'; 1227 1228windowClass.showWithAnimation((err: BusinessError) => { 1229 const errCode: number = err.code; 1230 if (errCode) { 1231 console.error(`Failed to show the window with animation. Cause code: ${err.code}, message: ${err.message}`); 1232 return; 1233 } 1234 console.info('Succeeded in showing the window with animation.'); 1235}); 1236``` 1237 1238### showWithAnimation<sup>9+</sup> 1239 1240showWithAnimation(): Promise<void> 1241 1242Shows this window and plays an animation during the process. This API uses a promise to return the result. This API takes effect only for a system window. 1243 1244**System API**: This is a system API. 1245 1246**System capability**: SystemCapability.WindowManager.WindowManager.Core 1247 1248**Return value** 1249 1250| Type | Description | 1251| ------------------- | ------------------------- | 1252| Promise<void> | Promise that returns no value.| 1253 1254**Error codes** 1255 1256For details about the error codes, see [Window Error Codes](errorcode-window.md). 1257 1258| ID| Error Message| 1259| ------- | -------------------------------------------- | 1260| 202 | Permission verification failed. A non-system application calls a system API. | 1261| 1300002 | This window state is abnormal. | 1262| 1300003 | This window manager service works abnormally. | 1263| 1300004 | Unauthorized operation. | 1264 1265**Example** 1266 1267```ts 1268import { BusinessError } from '@kit.BasicServicesKit'; 1269 1270let promise = windowClass.showWithAnimation(); 1271promise.then(() => { 1272 console.info('Succeeded in showing the window with animation.'); 1273}).catch((err: BusinessError) => { 1274 console.error(`Failed to show the window with animation. Cause code: ${err.code}, message: ${err.message}`); 1275}); 1276``` 1277 1278### setWindowMode<sup>9+</sup> 1279 1280setWindowMode(mode: WindowMode, callback: AsyncCallback<void>): void 1281 1282Sets the mode of the main window. This API uses an asynchronous callback to return the result. 1283 1284**System API**: This is a system API. 1285 1286**System capability**: SystemCapability.WindowManager.WindowManager.Core 1287 1288**Parameters** 1289 1290| Name| Type| Mandatory| Description| 1291| -------- | -------------------------- | -- | --------- | 1292| mode | [WindowMode](#windowmode7) | Yes| Window mode to set.| 1293| callback | AsyncCallback<void> | Yes| Callback used to return the result.| 1294 1295**Error codes** 1296 1297For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Window Error Codes](errorcode-window.md). 1298 1299| ID| Error Message| 1300| ------- | -------------------------------------------- | 1301| 202 | Permission verification failed. A non-system application calls a system API. | 1302| 401 | Parameter error. Possible cause: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. | 1303| 1300002 | This window state is abnormal. | 1304| 1300003 | This window manager service works abnormally. | 1305 1306**Example** 1307 1308```ts 1309// EntryAbility.ets 1310import { UIAbility } from '@kit.AbilityKit'; 1311import { BusinessError } from '@kit.BasicServicesKit'; 1312 1313export default class EntryAbility extends UIAbility { 1314 // ... 1315 onWindowStageCreate(windowStage: window.WindowStage): void { 1316 console.info('onWindowStageCreate'); 1317 let windowClass: window.Window | undefined = undefined; 1318 windowStage.getMainWindow((err: BusinessError, data) => { 1319 const errCode: number = err.code; 1320 if (errCode) { 1321 console.error(`Failed to obtain the main window. Cause code: ${err.code}, message: ${err.message}`); 1322 return; 1323 } 1324 windowClass = data; 1325 let mode = window.WindowMode.FULLSCREEN; 1326 try { 1327 windowClass.setWindowMode(mode, (err: BusinessError) => { 1328 const errCode: number = err.code; 1329 if (errCode) { 1330 console.error(`Failed to set the window mode. Cause code: ${err.code}, message: ${err.message}`); 1331 return; 1332 } 1333 console.info('Succeeded in setting the window mode.'); 1334 }); 1335 } catch (exception) { 1336 console.error(`Failed to set the window mode. Cause code: ${exception.code}, message: ${exception.message}`); 1337 } 1338 }); 1339 } 1340} 1341``` 1342 1343### setWindowMode<sup>9+</sup> 1344 1345setWindowMode(mode: WindowMode): Promise<void> 1346 1347Sets the mode of the main window. This API uses a promise to return the result. 1348 1349**System API**: This is a system API. 1350 1351**System capability**: SystemCapability.WindowManager.WindowManager.Core 1352 1353**Parameters** 1354 1355| Name| Type| Mandatory| Description| 1356| -------- | -------------------------- | -- | --------- | 1357| mode | [WindowMode](#windowmode7) | Yes| Window mode to set.| 1358 1359**Return value** 1360 1361| Type| Description| 1362| ------------------- | ----------------------- | 1363| Promise<void> | Promise that returns no value.| 1364 1365**Error codes** 1366 1367For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Window Error Codes](errorcode-window.md). 1368 1369| ID| Error Message| 1370| ------- | -------------------------------------------- | 1371| 202 | Permission verification failed. A non-system application calls a system API. | 1372| 401 | Parameter error. Possible cause: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. | 1373| 1300002 | This window state is abnormal. | 1374| 1300003 | This window manager service works abnormally. | 1375 1376**Example** 1377 1378```ts 1379// EntryAbility.ets 1380import { UIAbility } from '@kit.AbilityKit'; 1381import { BusinessError } from '@kit.BasicServicesKit'; 1382 1383export default class EntryAbility extends UIAbility { 1384 // ... 1385 onWindowStageCreate(windowStage: window.WindowStage): void { 1386 console.info('onWindowStageCreate'); 1387 let windowClass: window.Window | undefined = undefined; 1388 windowStage.getMainWindow((err: BusinessError, data) => { 1389 const errCode: number = err.code; 1390 if (errCode) { 1391 console.error(`Failed to obtain the main window. Cause code: ${err.code}, message: ${err.message}`); 1392 return; 1393 } 1394 windowClass = data; 1395 let mode = window.WindowMode.FULLSCREEN; 1396 try { 1397 let promise = windowClass.setWindowMode(mode); 1398 promise.then(() => { 1399 console.info('Succeeded in setting the window mode.'); 1400 }).catch((err: BusinessError) => { 1401 console.error(`Failed to set the window mode. Cause code: ${err.code}, message: ${err.message}`); 1402 }); 1403 } catch (exception) { 1404 console.error(`Failed to set the window mode. Cause code: ${exception.code}, message: ${exception.message}`); 1405 } 1406 }); 1407 } 1408} 1409``` 1410 1411### bindDialogTarget<sup>9+</sup> 1412 1413bindDialogTarget(token: rpc.RemoteObject, deathCallback: Callback<void>, callback: AsyncCallback<void>): void 1414 1415Binds the modal window to the target window, and adds a callback to listen for modal window destruction events. This API uses an asynchronous callback to return the result. 1416 1417**System API**: This is a system API. 1418 1419**System capability**: SystemCapability.WindowManager.WindowManager.Core 1420 1421**Parameters** 1422 1423| Name | Type | Mandatory| Description | 1424| ----------- | ------------------------- | ---- | -------------------- | 1425| token | [rpc.RemoteObject](../apis-ipc-kit/js-apis-rpc.md#remoteobject) | Yes | Token of the target window.| 1426| deathCallback | Callback<void> | Yes | Callback used to listen for modal window destruction events.| 1427| callback | AsyncCallback<void> | Yes | Callback used to return the result.| 1428 1429**Error codes** 1430 1431For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Window Error Codes](errorcode-window.md). 1432 1433| ID| Error Message| 1434| ------- | -------------------------------------------- | 1435| 202 | Permission verification failed. A non-system application calls a system API. | 1436| 401 | Parameter error. Possible cause: Incorrect parameter types. | 1437| 1300002 | This window state is abnormal. | 1438| 1300003 | This window manager service works abnormally. | 1439 1440**Example** 1441 1442```ts 1443import { rpc } from '@kit.IPCKit'; 1444import { BusinessError } from '@kit.BasicServicesKit'; 1445 1446class MyDeathRecipient { 1447 onRemoteDied() { 1448 console.log('server died'); 1449 } 1450} 1451 1452class TestRemoteObject extends rpc.RemoteObject { 1453 constructor(descriptor: string) { 1454 super(descriptor); 1455 } 1456 1457 addDeathRecipient(recipient: MyDeathRecipient, flags: number): boolean { 1458 return true; 1459 } 1460 1461 removeDeathRecipient(recipient: MyDeathRecipient, flags: number): boolean { 1462 return true; 1463 } 1464 1465 isObjectDead(): boolean { 1466 return false; 1467 } 1468} 1469 1470let token: TestRemoteObject = new TestRemoteObject('testObject'); 1471let windowClass: window.Window | undefined = undefined; 1472let config: window.Configuration = { name: "test", windowType: window.WindowType.TYPE_DIALOG, ctx: this.context }; 1473try { 1474 window.createWindow(config, (err: BusinessError, data) => { 1475 let errCode: number = err.code; 1476 if (errCode) { 1477 console.error(`Failed to create the window. Cause code: ${err.code}, message: ${err.message}`); 1478 return; 1479 } 1480 windowClass = data; 1481 }); 1482 windowClass.bindDialogTarget(token, () => { 1483 console.info('Dialog Window Need Destroy.'); 1484 }, (err: BusinessError) => { 1485 let errCode: number = err.code; 1486 if (errCode) { 1487 console.error(`Failed to bind dialog target. Cause code: ${err.code}, message: ${err.message}`); 1488 return; 1489 } 1490 console.info('Succeeded in binding dialog target.'); 1491 }); 1492} catch (exception) { 1493 console.error(`Failed to bind dialog target. Cause code: ${exception.code}, message: ${exception.message}`); 1494} 1495``` 1496 1497### bindDialogTarget<sup>9+</sup> 1498 1499bindDialogTarget(token: rpc.RemoteObject, deathCallback: Callback<void>): Promise<void> 1500 1501Binds the modal window to the target window, and adds a callback to listen for modal window destruction events. This API uses a promise to return the result. 1502 1503**System API**: This is a system API. 1504 1505**System capability**: SystemCapability.WindowManager.WindowManager.Core 1506 1507**Parameters** 1508 1509| Name | Type | Mandatory| Description | 1510| ----------- | ------------------------- | ---- | -------------------- | 1511| token | [rpc.RemoteObject](../apis-ipc-kit/js-apis-rpc.md#remoteobject) | Yes | Token of the target window.| 1512| deathCallback | Callback<void> | Yes | Callback used to listen for modal window destruction events.| 1513 1514**Return value** 1515 1516| Type | Description | 1517| ------------------- | ------------------------- | 1518| Promise<void> | Promise that returns no value.| 1519 1520**Error codes** 1521 1522For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Window Error Codes](errorcode-window.md). 1523 1524| ID| Error Message| 1525| ------- | -------------------------------------------- | 1526| 202 | Permission verification failed. A non-system application calls a system API. | 1527| 401 | Parameter error. Possible cause: Incorrect parameter types. | 1528| 1300002 | This window state is abnormal. | 1529| 1300003 | This window manager service works abnormally. | 1530 1531**Example** 1532 1533```ts 1534import { rpc } from '@kit.IPCKit'; 1535import { BusinessError } from '@kit.BasicServicesKit'; 1536 1537class MyDeathRecipient { 1538 onRemoteDied() { 1539 console.log('server died'); 1540 } 1541} 1542 1543class TestRemoteObject extends rpc.RemoteObject { 1544 constructor(descriptor: string) { 1545 super(descriptor); 1546 } 1547 1548 addDeathRecipient(recipient: MyDeathRecipient, flags: number): boolean { 1549 return true; 1550 } 1551 1552 removeDeathRecipient(recipient: MyDeathRecipient, flags: number): boolean { 1553 return true; 1554 } 1555 1556 isObjectDead(): boolean { 1557 return false; 1558 } 1559} 1560 1561let token: TestRemoteObject = new TestRemoteObject('testObject'); 1562let windowClass: window.Window | undefined = undefined; 1563let config: window.Configuration = { 1564 name: "test", 1565 windowType: window.WindowType.TYPE_DIALOG, 1566 ctx: this.context 1567}; 1568try { 1569 window.createWindow(config, (err: BusinessError, data) => { 1570 const errCode: number = err.code; 1571 if (errCode) { 1572 console.error(`Failed to create the window. Cause code: ${err.code}, message: ${err.message}`); 1573 return; 1574 } 1575 windowClass = data; 1576 }); 1577 let promise = windowClass.bindDialogTarget(token, () => { 1578 console.info('Dialog Window Need Destroy.'); 1579 }); 1580 promise.then(() => { 1581 console.info('Succeeded in binding dialog target.'); 1582 }).catch((err: BusinessError) => { 1583 console.error(`Failed to bind dialog target. Cause code: ${err.code}, message: ${err.message}`); 1584 }); 1585} catch (exception) { 1586 console.error(`Failed to bind dialog target. Cause code: ${exception.code}, message: ${exception.message}`); 1587} 1588``` 1589 1590### bindDialogTarget<sup>9+</sup> 1591 1592bindDialogTarget(requestInfo: dialogRequest.RequestInfo, deathCallback: Callback<void>, callback: AsyncCallback<void>): void 1593 1594Binds the modal window to the target window, and adds a callback to listen for modal window destruction events. This API uses an asynchronous callback to return the result. 1595 1596**System API**: This is a system API. 1597 1598**System capability**: SystemCapability.WindowManager.WindowManager.Core 1599 1600**Parameters** 1601 1602| Name | Type | Mandatory| Description | 1603| ----------- | ------------------------- | ---- | -------------------- | 1604| requestInfo | [dialogRequest.RequestInfo](../apis-ability-kit/js-apis-app-ability-dialogRequest.md#requestinfo) | Yes | **RequestInfo** of the target window.| 1605| deathCallback | Callback<void> | Yes | Callback used to listen for modal window destruction events.| 1606| callback | AsyncCallback<void> | Yes | Callback used to return the result.| 1607 1608**Error codes** 1609 1610For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Window Error Codes](errorcode-window.md). 1611 1612| ID| Error Message| 1613| ------- | -------------------------------------------- | 1614| 202 | Permission verification failed. A non-system application calls a system API. | 1615| 401 | Parameter error. Possible cause: Incorrect parameter types. | 1616| 1300002 | This window state is abnormal. | 1617| 1300003 | This window manager service works abnormally. | 1618 1619**Example** 1620 1621```ts 1622import { dialogRequest, Want, ServiceExtensionAbility } from '@kit.AbilityKit'; 1623import { BusinessError } from '@kit.BasicServicesKit'; 1624 1625export default class ServiceExtAbility extends ServiceExtensionAbility { 1626 onRequest(want: Want, startId: number) { 1627 console.info('onRequest'); 1628 let windowClass: window.Window | undefined = undefined; 1629 let config: window.Configuration = { 1630 name: "test", windowType: window.WindowType.TYPE_DIALOG, ctx: this.context 1631 }; 1632 try { 1633 window.createWindow(config, (err: BusinessError, data) => { 1634 let errCode: number = err.code; 1635 if (errCode) { 1636 console.error(`Failed to create the window. Cause code: ${err.code}, message: ${err.message}`); 1637 return; 1638 } 1639 windowClass = data; 1640 }); 1641 let requestInfo = dialogRequest.getRequestInfo(want) 1642 windowClass.bindDialogTarget(requestInfo, () => { 1643 console.info('Dialog Window Need Destroy.'); 1644 }, (err: BusinessError) => { 1645 let errCode: number = err.code; 1646 if (errCode) { 1647 console.error(`Failed to bind dialog target. Cause code: ${err.code}, message: ${err.message}`); 1648 return; 1649 } 1650 console.info('Succeeded in binding dialog target.'); 1651 }); 1652 } catch (err) { 1653 console.error(`Failed to bind dialog target. Cause code: ${err.code}, message: ${err.message}`) 1654 } 1655 } 1656} 1657``` 1658 1659### bindDialogTarget<sup>9+</sup> 1660 1661bindDialogTarget(requestInfo: dialogRequest.RequestInfo, deathCallback: Callback<void>): Promise<void> 1662 1663Binds the modal window to the target window, and adds a callback to listen for modal window destruction events. This API uses a promise to return the result. 1664 1665**System API**: This is a system API. 1666 1667**System capability**: SystemCapability.WindowManager.WindowManager.Core 1668 1669**Parameters** 1670 1671| Name | Type | Mandatory| Description | 1672| ----------- | ------------------------- | ---- | -------------------- | 1673| requestInfo | [dialogRequest.RequestInfo](../apis-ability-kit/js-apis-app-ability-dialogRequest.md#requestinfo) | Yes | **RequestInfo** of the target window.| 1674| deathCallback | Callback<void> | Yes | Callback used to listen for modal window destruction events.| 1675 1676**Return value** 1677 1678| Type | Description | 1679| ------------------- | ------------------------- | 1680| Promise<void> | Promise that returns no value.| 1681 1682**Error codes** 1683 1684For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Window Error Codes](errorcode-window.md). 1685 1686| ID| Error Message| 1687| ------- | -------------------------------------------- | 1688| 202 | Permission verification failed. A non-system application calls a system API. | 1689| 401 | Parameter error. Possible cause: Incorrect parameter types. | 1690| 1300002 | This window state is abnormal. | 1691| 1300003 | This window manager service works abnormally. | 1692 1693**Example** 1694 1695```ts 1696import { dialogRequest, Want, ServiceExtensionAbility } from '@kit.AbilityKit'; 1697import { BusinessError } from '@kit.BasicServicesKit'; 1698 1699export default class ServiceExtAbility extends ServiceExtensionAbility { 1700 onRequest(want: Want, startId: number) { 1701 console.info('onRequest'); 1702 let windowClass: window.Window | undefined = undefined; 1703 let config: window.Configuration = { 1704 name: "test", windowType: window.WindowType.TYPE_DIALOG, ctx: this.context 1705 }; 1706 try { 1707 window.createWindow(config, (err: BusinessError, data) => { 1708 const errCode: number = err.code; 1709 if (errCode) { 1710 console.error(`Failed to create the window. Cause code: ${err.code}, message: ${err.message}`); 1711 return; 1712 } 1713 windowClass = data; 1714 }); 1715 let requestInfo = dialogRequest.getRequestInfo(want) 1716 let promise = windowClass.bindDialogTarget(requestInfo, () => { 1717 console.info('Dialog Window Need Destroy.'); 1718 }); 1719 promise.then(() => { 1720 console.info('Succeeded in binding dialog target.'); 1721 }).catch((err: BusinessError) => { 1722 console.error(`Failed to bind dialog target. Cause code: ${err.code}, message: ${err.message}`); 1723 }); 1724 } catch (err) { 1725 console.error(`Failed to bind dialog target. Cause code: ${err.code}, message: ${err.message}`) 1726 } 1727 } 1728} 1729``` 1730 1731### setWakeUpScreen<sup>9+</sup> 1732 1733setWakeUpScreen(wakeUp: boolean): void 1734 1735Wakes up the screen. 1736 1737**System API**: This is a system API. 1738 1739**System capability**: SystemCapability.WindowManager.WindowManager.Core 1740 1741**Parameters** 1742 1743| Name | Type | Mandatory| Description | 1744| ---------------- | ------- | ---- | ---------------------------- | 1745| wakeUp | boolean | Yes | Whether to wake up the screen. The value **true** means to wake up the screen, and **false** means the opposite. | 1746 1747**Error codes** 1748 1749For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Window Error Codes](errorcode-window.md). 1750 1751| ID| Error Message| 1752| ------- | -------------------------------------------- | 1753| 202 | Permission verification failed. A non-system application calls a system API. | 1754| 401 | Parameter error. Possible cause: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. | 1755| 1300002 | This window state is abnormal. | 1756| 1300003 | This window manager service works abnormally. | 1757 1758**Example** 1759 1760```ts 1761let wakeUp: boolean = true; 1762try { 1763 windowClass.setWakeUpScreen(wakeUp); 1764} catch (exception) { 1765 console.error(`Failed to wake up the screen. Cause code: ${exception.code}, message: ${exception.message}`); 1766} 1767``` 1768 1769### setSnapshotSkip<sup>9+</sup> 1770setSnapshotSkip(isSkip: boolean): void 1771 1772Sets whether to ignore this window during screen capturing or recording. This API is generally used in scenarios where screen capture or recording is disabled. 1773 1774**System API**: This is a system API. 1775 1776**System capability**: SystemCapability.WindowManager.WindowManager.Core 1777 1778**Parameters** 1779 1780| Name | Type | Mandatory| Description | 1781| ------------- | ------- | ---- | -------------------- | 1782| isSkip | boolean | Yes | Whether to ignore the window. The default value is **false**.<br>The value **true** means that the window is ignored, and **false** means the opposite.<br>| 1783 1784**Error codes** 1785 1786For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Window Error Codes](errorcode-window.md). 1787 1788| ID| Error Message| 1789| ------- | ------------------------------ | 1790| 202 | Permission verification failed. A non-system application calls a system API. | 1791| 401 | Parameter error. Possible cause: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. | 1792| 1300002 | This window state is abnormal. | 1793 1794```ts 1795let isSkip: boolean = true; 1796try { 1797 windowClass.setSnapshotSkip(isSkip); 1798} catch (exception) { 1799 console.error(`Failed to Skip. Cause code: ${exception.code}, message: ${exception.message}`); 1800} 1801``` 1802 1803### setForbidSplitMove<sup>9+</sup> 1804 1805setForbidSplitMove(isForbidSplitMove: boolean, callback: AsyncCallback<void>): void 1806 1807Sets whether the main window is forbidden to move in split-screen mode. This API uses an asynchronous callback to return the result. 1808 1809**System API**: This is a system API. 1810 1811**System capability**: SystemCapability.WindowManager.WindowManager.Core 1812 1813**Parameters** 1814 1815| Name | Type | Mandatory| Description | 1816| ----------- | ------------------------- | ---- | -------------------- | 1817| isForbidSplitMove | boolean | Yes | Whether the window is forbidden to move in split-screen mode. The value **true** means the window is forbidden to move in split-screen mode, and **false** means the opposite.| 1818| callback | AsyncCallback<void> | Yes | Callback used to return the result. | 1819 1820**Error codes** 1821 1822For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Window Error Codes](errorcode-window.md). 1823 1824| ID| Error Message| 1825| ------- | -------------------------------------------- | 1826| 202 | Permission verification failed. A non-system application calls a system API. | 1827| 401 | Parameter error. Possible cause: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. | 1828| 1300002 | This window state is abnormal. | 1829| 1300003 | This window manager service works abnormally. | 1830 1831**Example** 1832 1833```ts 1834// EntryAbility.ets 1835import { UIAbility } from '@kit.AbilityKit'; 1836import { BusinessError } from '@kit.BasicServicesKit'; 1837 1838export default class EntryAbility extends UIAbility { 1839 // ... 1840 onWindowStageCreate(windowStage: window.WindowStage): void { 1841 console.info('onWindowStageCreate'); 1842 let windowClass: window.Window | undefined = undefined; 1843 windowStage.getMainWindow((err: BusinessError, data) => { 1844 const errCode: number = err.code; 1845 if (errCode) { 1846 console.error(`Failed to obtain the main window. Cause code: ${err.code}, message: ${err.message}`); 1847 return; 1848 } 1849 windowClass = data; 1850 let isForbidSplitMove: boolean = true; 1851 try { 1852 windowClass.setForbidSplitMove(isForbidSplitMove, (err: BusinessError) => { 1853 const errCode: number = err.code; 1854 if (errCode) { 1855 console.error(`Failed to forbid window moving in split screen mode. Cause code: ${err.code}, message: ${err.message}`); 1856 return; 1857 } 1858 console.info('Succeeded in forbidding window moving in split screen mode.'); 1859 }); 1860 } catch (exception) { 1861 console.error(`Failed to forbid window moving in split screen mode. Cause code: ${exception.code}, message: ${exception.message}`); 1862 } 1863 }); 1864 } 1865} 1866``` 1867 1868### setForbidSplitMove<sup>9+</sup> 1869 1870setForbidSplitMove(isForbidSplitMove: boolean): Promise<void> 1871 1872Sets whether the main window is forbidden to move in split-screen mode. This API uses a promise to return the result. 1873 1874**System API**: This is a system API. 1875 1876**System capability**: SystemCapability.WindowManager.WindowManager.Core 1877 1878**Parameters** 1879 1880| Name | Type | Mandatory| Description | 1881| ----------- | ------- | ---- | -------------------- | 1882| isForbidSplitMove | boolean | Yes | Whether the window is forbidden to move in split-screen mode. The value **true** means the window is forbidden to move in split-screen mode, and **false** means the opposite.| 1883 1884**Return value** 1885 1886| Type | Description | 1887| ------------------- | ------------------------- | 1888| Promise<void> | Promise that returns no value.| 1889 1890**Error codes** 1891 1892For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Window Error Codes](errorcode-window.md). 1893 1894| ID| Error Message| 1895| ------- | -------------------------------------------- | 1896| 202 | Permission verification failed. A non-system application calls a system API. | 1897| 401 | Parameter error. Possible cause: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. | 1898| 1300002 | This window state is abnormal. | 1899| 1300003 | This window manager service works abnormally. | 1900 1901**Example** 1902 1903```ts 1904// EntryAbility.ets 1905import { UIAbility } from '@kit.AbilityKit'; 1906import { BusinessError } from '@kit.BasicServicesKit'; 1907 1908export default class EntryAbility extends UIAbility { 1909 // ... 1910 onWindowStageCreate(windowStage: window.WindowStage): void { 1911 console.info('onWindowStageCreate'); 1912 let windowClass: window.Window | undefined = undefined; 1913 windowStage.getMainWindow((err: BusinessError, data) => { 1914 const errCode: number = err.code; 1915 if (errCode) { 1916 console.error(`Failed to obtain the main window. Cause code: ${err.code}, message: ${err.message}`); 1917 return; 1918 } 1919 windowClass = data; 1920 let isForbidSplitMove: boolean = true; 1921 try { 1922 let promise = windowClass.setForbidSplitMove(isForbidSplitMove); 1923 promise.then(() => { 1924 console.info('Succeeded in forbidding window moving in split screen mode.'); 1925 }).catch((err: BusinessError) => { 1926 console.error(`Failed to forbid window moving in split screen mode. Cause code: ${err.code}, message: ${err.message}`); 1927 }); 1928 } catch (exception) { 1929 console.error(`Failed to forbid window moving in split screen mode. Cause code: ${exception.code}, message: ${exception.message}`); 1930 } 1931 }); 1932 } 1933} 1934``` 1935 1936### opacity<sup>9+</sup> 1937 1938opacity(opacity: number): void 1939 1940Sets the opacity for this window. This API can be used only when you [customize an animation to be played during the display or hiding of a system window](../../windowmanager/system-window-stage.md#customizing-an-animation-to-be-played-during-the-display-or-hiding-of-a-system-window). 1941 1942**System API**: This is a system API. 1943 1944**System capability**: SystemCapability.WindowManager.WindowManager.Core 1945 1946**Parameters** 1947 1948| Name | Type | Mandatory| Description | 1949| ------- | ------ | ---- |----------------------------------------------------| 1950| opacity | number | Yes | Opacity. The value is a floating point number in the range [0.0, 1.0]. The value **0.0** means completely transparent, and **1.0** means completely opaque.| 1951 1952**Error codes** 1953 1954For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Window Error Codes](errorcode-window.md). 1955 1956| ID| Error Message| 1957| ------- | ------------------------------ | 1958| 202 | Permission verification failed. A non-system application calls a system API. | 1959| 401 | Parameter error. Possible cause: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. | 1960| 1300002 | This window state is abnormal. | 1961| 1300004 | Unauthorized operation. | 1962 1963**Example** 1964 1965```ts 1966try { 1967 windowClass.opacity(0.5); 1968} catch (exception) { 1969 console.error(`Failed to opacity. Cause code: ${exception.code}, message: ${exception.message}`); 1970} 1971``` 1972 1973### scale<sup>9+</sup> 1974 1975scale(scaleOptions: ScaleOptions): void 1976 1977Sets the scale parameters for this window. This API can be used only when you [customize an animation to be played during the display or hiding of a system window](../../windowmanager/system-window-stage.md#customizing-an-animation-to-be-played-during-the-display-or-hiding-of-a-system-window). 1978 1979**System API**: This is a system API. 1980 1981**System capability**: SystemCapability.WindowManager.WindowManager.Core 1982 1983**Parameters** 1984 1985| Name | Type | Mandatory| Description | 1986| ------------ | ------------------------------ | ---- | ---------- | 1987| scaleOptions | [ScaleOptions](#scaleoptions9) | Yes | Scale parameters to set.| 1988 1989**Error codes** 1990 1991For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Window Error Codes](errorcode-window.md). 1992 1993| ID| Error Message| 1994| ------- | ------------------------------ | 1995| 202 | Permission verification failed. A non-system application calls a system API. | 1996| 401 | Parameter error. Possible cause: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. | 1997| 1300002 | This window state is abnormal. | 1998| 1300004 | Unauthorized operation. | 1999 2000**Example** 2001 2002```ts 2003let obj: window.ScaleOptions = { 2004 x: 2.0, 2005 y: 1.0, 2006 pivotX: 0.5, 2007 pivotY: 0.5 2008}; 2009try { 2010 windowClass.scale(obj); 2011} catch (exception) { 2012 console.error(`Failed to scale. Cause code: ${exception.code}, message: ${exception.message}`); 2013} 2014``` 2015 2016### rotate<sup>9+</sup> 2017 2018rotate(rotateOptions: RotateOptions): void 2019 2020Sets the rotation parameters for this window. This API can be used only when you [customize an animation to be played during the display or hiding of a system window](../../windowmanager/system-window-stage.md#customizing-an-animation-to-be-played-during-the-display-or-hiding-of-a-system-window). 2021 2022**System API**: This is a system API. 2023 2024**System capability**: SystemCapability.WindowManager.WindowManager.Core 2025 2026**Parameters** 2027 2028| Name | Type | Mandatory| Description | 2029| ------------- | -------------------------------- | ---- | ---------- | 2030| rotateOptions | [RotateOptions](#rotateoptions9) | Yes | Rotation parameters to set.| 2031 2032**Error codes** 2033 2034For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Window Error Codes](errorcode-window.md). 2035 2036| ID| Error Message| 2037| ------- | ------------------------------ | 2038| 202 | Permission verification failed. A non-system application calls a system API. | 2039| 401 | Parameter error. Possible cause: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. | 2040| 1300002 | This window state is abnormal. | 2041| 1300004 | Unauthorized operation. | 2042 2043**Example** 2044 2045```ts 2046let obj: window.RotateOptions = { 2047 x: 1.0, 2048 y: 1.0, 2049 z: 45.0, 2050 pivotX: 0.5, 2051 pivotY: 0.5 2052}; 2053try { 2054 windowClass.rotate(obj); 2055} catch (exception) { 2056 console.error(`Failed to rotate. Cause code: ${exception.code}, message: ${exception.message}`); 2057} 2058``` 2059 2060### translate<sup>9+</sup> 2061 2062translate(translateOptions: TranslateOptions): void 2063 2064Sets the translation parameters for this window. This API can be used only when you [customize an animation to be played during the display or hiding of a system window](../../windowmanager/system-window-stage.md#customizing-an-animation-to-be-played-during-the-display-or-hiding-of-a-system-window). 2065 2066**System API**: This is a system API. 2067 2068**System capability**: SystemCapability.WindowManager.WindowManager.Core 2069 2070**Parameters** 2071 2072| Name | Type | Mandatory| Description | 2073| ---------------- | -------------------------------------- | ---- | -------------------- | 2074| translateOptions | [TranslateOptions](#translateoptions9) | Yes | Translation parameters. The unit is px.| 2075 2076**Error codes** 2077 2078For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Window Error Codes](errorcode-window.md). 2079 2080| ID| Error Message| 2081| ------- | ------------------------------ | 2082| 202 | Permission verification failed. A non-system application calls a system API. | 2083| 401 | Parameter error. Possible cause: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. | 2084| 1300002 | This window state is abnormal. | 2085| 1300004 | Unauthorized operation. | 2086 2087**Example** 2088 2089```ts 2090let obj: window.TranslateOptions = { 2091 x: 100.0, 2092 y: 0.0, 2093 z: 0.0 2094}; 2095try { 2096 windowClass.translate(obj); 2097} catch (exception) { 2098 console.error(`Failed to translate. Cause code: ${exception.code}, message: ${exception.message}`); 2099} 2100``` 2101 2102### getTransitionController<sup>9+</sup> 2103 2104 getTransitionController(): TransitionController 2105 2106Obtains the transition animation controller. 2107 2108**System API**: This is a system API. 2109 2110**System capability**: SystemCapability.WindowManager.WindowManager.Core 2111 2112**Return value** 2113 2114| Type | Description | 2115| ---------------------------------------------- | ---------------- | 2116| [TransitionController](#transitioncontroller9) | Transition animation controller.| 2117 2118**Error codes** 2119 2120For details about the error codes, see [Window Error Codes](errorcode-window.md). 2121 2122| ID| Error Message| 2123| ------- | ------------------------------ | 2124| 202 | Permission verification failed. A non-system application calls a system API. | 2125| 1300002 | This window state is abnormal. | 2126| 1300004 | Unauthorized operation. | 2127 2128**Example** 2129 2130```ts 2131let controller = windowClass.getTransitionController(); // Obtain the transition animation controller. 2132``` 2133 2134### setBlur<sup>9+</sup> 2135 2136setBlur(radius: number): void 2137 2138Blurs this window. 2139 2140**System API**: This is a system API. 2141 2142**System capability**: SystemCapability.WindowManager.WindowManager.Core 2143 2144**Parameters** 2145 2146| Name| Type | Mandatory| Description | 2147| ------ | ------ | ---- |--------------------------------------------------| 2148| radius | number | Yes | Radius of the blur. The value is a floating point number greater than or equal to 0.0, in px. The value **0.0** means that the blur is disabled for the window.| 2149 2150**Error codes** 2151 2152For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Window Error Codes](errorcode-window.md). 2153 2154| ID| Error Message| 2155| ------- | ------------------------------ | 2156| 202 | Permission verification failed. A non-system application calls a system API. | 2157| 401 | Parameter error. Possible cause: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. | 2158| 1300002 | This window state is abnormal. | 2159| 1300004 | Unauthorized operation. | 2160 2161**Example** 2162 2163```ts 2164try { 2165 windowClass.setBlur(4.0); 2166} catch (exception) { 2167 console.error(`Failed to set blur. Cause code: ${exception.code}, message: ${exception.message}`); 2168} 2169``` 2170 2171### setBackdropBlur<sup>9+</sup> 2172 2173setBackdropBlur(radius: number): void 2174 2175Blurs the background of this window. 2176 2177The window background refers to the lower-layer area covered by the window, which is the same as the window size. 2178 2179To make the blur effect visible, you must set the window background transparent by calling [setWindowBackgroundColor](js-apis-window.md#setwindowbackgroundcolor9). 2180 2181**System API**: This is a system API. 2182 2183**System capability**: SystemCapability.WindowManager.WindowManager.Core 2184 2185**Parameters** 2186 2187| Name| Type | Mandatory| Description | 2188| ------ | ------ | ---- |-------------------------------------------------------| 2189| radius | number | Yes | Radius of the blur. The value is a floating point number greater than or equal to 0.0, in px. The value **0.0** means that the blur is disabled for the background of the window.| 2190 2191**Error codes** 2192 2193For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Window Error Codes](errorcode-window.md). 2194 2195| ID| Error Message| 2196| ------- | ------------------------------ | 2197| 202 | Permission verification failed. A non-system application calls a system API. | 2198| 401 | Parameter error. Possible cause: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. | 2199| 1300002 | This window state is abnormal. | 2200| 1300004 | Unauthorized operation. | 2201 2202**Example** 2203 2204```ts 2205try { 2206 windowClass.setWindowBackgroundColor('#00FFFFFF'); 2207 windowClass.setBackdropBlur(4.0); 2208} catch (exception) { 2209 console.error(`Failed to set backdrop blur. Cause code: ${exception.code}, message: ${exception.message}`); 2210} 2211``` 2212 2213### setBackdropBlurStyle<sup>9+</sup> 2214 2215setBackdropBlurStyle(blurStyle: BlurStyle): void 2216 2217Sets the blur style for the background of this window. 2218 2219**System API**: This is a system API. 2220 2221**System capability**: SystemCapability.WindowManager.WindowManager.Core 2222 2223**Parameters** 2224 2225| Name | Type | Mandatory| Description | 2226| --------- | --------- | ---- | ---------------------- | 2227| blurStyle | [BlurStyle](#blurstyle9) | Yes | Blur style to set for the background of the window.| 2228 2229**Error codes** 2230 2231For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Window Error Codes](errorcode-window.md). 2232 2233| ID| Error Message| 2234| ------- | ------------------------------ | 2235| 202 | Permission verification failed. A non-system application calls a system API. | 2236| 401 | Parameter error. Possible cause: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. | 2237| 1300002 | This window state is abnormal. | 2238| 1300004 | Unauthorized operation. | 2239 2240**Example** 2241 2242```ts 2243try { 2244 windowClass.setBackdropBlurStyle(window.BlurStyle.THIN); 2245} catch (exception) { 2246 console.error(`Failed to set backdrop blur style. Cause code: ${exception.code}, message: ${exception.message}`); 2247} 2248``` 2249 2250### setShadow<sup>9+</sup> 2251 2252setShadow(radius: number, color?: string, offsetX?: number, offsetY?: number): void 2253 2254Sets the shadow for the window borders. 2255 2256**System API**: This is a system API. 2257 2258**System capability**: SystemCapability.WindowManager.WindowManager.Core 2259 2260**Parameters** 2261 2262| Name | Type | Mandatory| Description | 2263| ------- | ------ | ---- |-------------------------------------------------------------| 2264| radius | number | Yes | Radius of the shadow. The value is a floating point number greater than or equal to 0.0, in px. The value **0.0** means that the shadow is disabled for the window borders. | 2265| color | string | No | Color of the shadow. The value is a hexadecimal RGB or ARGB color code and is case insensitive, for example, **#00FF00** or **#FF00FF00**.| 2266| offsetX | number | No | Offset of the shadow along the x-axis, in px. The value is a floating point number. | 2267| offsetY | number | No | Offset of the shadow along the y-axis, in px. The value is a floating point number. | 2268 2269**Error codes** 2270 2271For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Window Error Codes](errorcode-window.md). 2272 2273| ID| Error Message| 2274| ------- | ------------------------------ | 2275| 202 | Permission verification failed. A non-system application calls a system API. | 2276| 401 | Parameter error. Possible cause: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. | 2277| 1300002 | This window state is abnormal. | 2278| 1300004 | Unauthorized operation. | 2279 2280**Example** 2281 2282```ts 2283try { 2284 windowClass.setShadow(4.0, '#FF00FF00', 2, 3); 2285} catch (exception) { 2286 console.error(`Failed to set shadow. Cause code: ${exception.code}, message: ${exception.message}`); 2287} 2288``` 2289 2290### setCornerRadius<sup>9+</sup> 2291 2292setCornerRadius(cornerRadius: number): void 2293 2294Sets the radius of the rounded corners for this window. 2295 2296**System API**: This is a system API. 2297 2298**System capability**: SystemCapability.WindowManager.WindowManager.Core 2299 2300**Parameters** 2301 2302| Name | Type | Mandatory| Description | 2303| ----------- | ------- | ---- |----------------------------------------------------| 2304| cornerRadius | number | Yes | Radius of the rounded corners. The value is a floating point number greater than or equal to 0.0, in px. The value **0.0** means that the window does not use rounded corners.| 2305 2306**Error codes** 2307 2308For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Window Error Codes](errorcode-window.md). 2309 2310| ID| Error Message| 2311| ------- | ------------------------------ | 2312| 202 | Permission verification failed. A non-system application calls a system API. | 2313| 401 | Parameter error. Possible cause: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. | 2314| 1300002 | This window state is abnormal. | 2315| 1300004 | Unauthorized operation. | 2316 2317**Example** 2318 2319```ts 2320try { 2321 windowClass.setCornerRadius(4.0); 2322} catch (exception) { 2323 console.error(`Failed to set corner radius. Cause code: ${exception.code}, message: ${exception.message}`); 2324} 2325``` 2326 2327### setTouchableAreas<sup>12+</sup> 2328 2329setTouchableAreas(rects: Array<Rect>): void 2330 2331Sets the touchable areas for this window. By default, the entire window is touchable. If a touchable area is set, touch events outside this area are transparently transmitted. The setting becomes invalid after the window rectangle changes. 2332 2333**System API**: This is a system API. 2334 2335**System capability**: SystemCapability.Window.SessionManager 2336 2337**Parameters** 2338 2339| Name | Type | Mandatory| Description | 2340| -------- | ------------------------- | ---- | ---------- | 2341| rects | Array<[Rect](js-apis-window.md#rect7)> | Yes | Touchable areas. The maximum number of touchable areas cannot exceed 10, and each touchable area cannot exceed the window area.| 2342 2343**Error codes** 2344 2345For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Window Error Codes](errorcode-window.md). 2346 2347| ID| Error Message| 2348| ------- | ------------------------------ | 2349| 202 | Permission verification failed. A non-system application calls a system API. | 2350| 401 | Parameter error. Possible cause: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. | 2351| 801 | Capability not supported. Failed to call the API due to limited device capabilities. | 2352| 1300002 | This window state is abnormal. | 2353| 1300003 | This window manager service works abnormally. | | 2354 2355**Example** 2356 2357```ts 2358try { 2359 windowClass.setTouchableAreas([{left: 100, top: 100, width: 200, height:200}, 2360 {left: 400, top: 100, width: 200, height:200}]); 2361} catch (exception) { 2362 console.error(`Failed to set touchable areas. Cause code: ${exception.code}, message: ${exception.message}`); 2363} 2364``` 2365 2366### raiseToAppTop<sup>10+</sup> 2367 2368raiseToAppTop(callback: AsyncCallback<void>): void 2369 2370Raises the application subwindow to the top layer of the application. This API uses an asynchronous callback to return the result. 2371 2372**System API**: This is a system API. 2373 2374**System capability**: SystemCapability.WindowManager.WindowManager.Core 2375 2376**Parameters** 2377 2378| Name | Type | Mandatory| Description | 2379| -------- | ------------------------- | ---- | ---------- | 2380| callback | AsyncCallback<void> | Yes | Callback used to return the result.| 2381 2382**Error codes** 2383 2384For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Window Error Codes](errorcode-window.md). 2385 2386| ID| Error Message| 2387| ------- | ------------------------------ | 2388| 202 | Permission verification failed. A non-system application calls a system API. | 2389| 1300002 | This window state is abnormal. | 2390| 1300003 | This window manager service works abnormally. | 2391| 1300004 | Unauthorized operation. | 2392| 1300009 | The parent window is invalid. | 2393 2394**Example** 2395 2396```ts 2397import { BusinessError } from '@kit.BasicServicesKit'; 2398 2399windowClass.raiseToAppTop((err: BusinessError) => { 2400 const errCode: number = err.code; 2401 if (errCode) { 2402 console.error(`Failed to raise the window to app top. Cause code: ${err.code}, message: ${err.message}`); 2403 return; 2404 } 2405 console.info('Succeeded in raising the window to app top.'); 2406}); 2407``` 2408 2409### setWaterMarkFlag<sup>10+</sup> 2410 2411setWaterMarkFlag(enable: boolean): Promise<void> 2412 2413Adds or deletes the watermark flag for this window. This API uses a promise to return the result. 2414 2415**System API**: This is a system API. 2416 2417**System capability**: SystemCapability.WindowManager.WindowManager.Core 2418 2419**Parameters** 2420 2421| Name| Type | Mandatory| Description | 2422| ------ | ------- | --- | ------------------------------------------------ | 2423| enable | boolean | Yes | Whether to add or delete the flag. The value **true** means to add the flag and **false** means to delete the flag.| 2424 2425**Return value** 2426 2427| Type | Description | 2428| ------------------- | ------------------------- | 2429| Promise<void> | Promise that returns no value.| 2430 2431**Error codes** 2432 2433For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Window Error Codes](errorcode-window.md). 2434 2435| ID| Error Message| 2436| ------- | ---------------------------------------------- | 2437| 202 | Permission verification failed. A non-system application calls a system API. | 2438| 401 | Parameter error. Possible cause: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. | 2439| 1300002 | This window state is abnormal. | 2440| 1300003 | This window manager service works abnormally. | 2441| 1300008 | The display device is abnormal. | 2442 2443**Example** 2444 2445```ts 2446import { BusinessError } from '@kit.BasicServicesKit'; 2447 2448try { 2449 let enable = true; 2450 let promise = windowClass.setWaterMarkFlag(enable); 2451 promise.then(() => { 2452 console.info('Succeeded in setting water mark flag of window.'); 2453 }).catch((err: BusinessError) => { 2454 console.error(`Failed to set water mark flag of window. Cause code: ${err.code}, message: ${err.message}`); 2455 }); 2456} catch (exception) { 2457 console.error(`Failed to set water mark flag of window. Cause code: ${exception.code}, message: ${exception.message}`); 2458} 2459``` 2460 2461### setWaterMarkFlag<sup>10+</sup> 2462 2463setWaterMarkFlag(enable: boolean, callback: AsyncCallback<void>): void 2464 2465Adds or deletes the watermark flag for this window. This API uses an asynchronous callback to return the result. 2466 2467**System API**: This is a system API. 2468 2469**System capability**: SystemCapability.WindowManager.WindowManager.Core 2470 2471**Parameters** 2472 2473| Name | Type | Mandatory| Description | 2474| -------- | ------------------------- | --- | ----------------------------------------------- | 2475| enable | boolean | Yes | Whether to add or delete the flag. The value **true** means to add the flag and **false** means to delete the flag.| 2476| callback | AsyncCallback<void> | Yes | Callback used to return the result. | 2477 2478**Error codes** 2479 2480For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Window Error Codes](errorcode-window.md). 2481 2482| ID| Error Message| 2483| ------- | ---------------------------------------------- | 2484| 202 | Permission verification failed. A non-system application calls a system API. | 2485| 401 | Parameter error. Possible cause: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. | 2486| 1300002 | This window state is abnormal. | 2487| 1300003 | This window manager service works abnormally. | 2488| 1300008 | The display device is abnormal. | 2489 2490**Example** 2491 2492```ts 2493import { BusinessError } from '@kit.BasicServicesKit'; 2494 2495try { 2496 let enable: boolean = true; 2497 windowClass.setWaterMarkFlag(enable, (err: BusinessError) => { 2498 const errCode: number = err.code; 2499 if (errCode) { 2500 console.error(`Failed to set water mark flag of window. Cause code: ${err.code}, message: ${err.message}`); 2501 return; 2502 } 2503 console.info('Succeeded in setting water mark flag of window.'); 2504 }); 2505} catch (exception) { 2506 console.error(`Failed to set water mark flag of window. Cause code: ${exception.code}, message: ${exception.message}`); 2507} 2508``` 2509 2510### setHandwritingFlag<sup>12+</sup> 2511 2512setHandwritingFlag(enable: boolean): Promise<void> 2513 2514Adds or deletes the handwriting flag for this window. After this flag is added, the window responds to stylus events but not touch events. This API uses a promise to return the result. 2515 2516**System API**: This is a system API. 2517 2518**System capability**: SystemCapability.Window.SessionManager 2519 2520**Parameters** 2521 2522| Name| Type | Mandatory| Description | 2523| ------ | ------- | --- | ------------------------------------------------ | 2524| enable | boolean | Yes | Whether to add or delete the flag. The value **true** means to add the flag and **false** means to delete the flag.| 2525 2526**Return value** 2527 2528| Type | Description | 2529| ------------------- | ------------------------- | 2530| Promise<void> | Promise that returns no value.| 2531 2532**Error codes** 2533 2534For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Window Error Codes](errorcode-window.md). 2535 2536| ID| Error Message| 2537| ------- | -------------------------------------------- | 2538| 202 | Permission verification failed. A non-system application calls a system API. | 2539| 401 | Parameter error. Possible cause: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. | 2540| 801 | Capability not supported. Failed to call the API due to limited device capabilities. | 2541| 1300002 | This window state is abnormal. | 2542| 1300003 | This window manager service works abnormally. | 2543 2544**Example** 2545 2546```ts 2547import { BusinessError } from '@kit.BasicServicesKit'; 2548 2549try { 2550 let enable = true; 2551 let promise = windowClass.setHandwritingFlag(enable); 2552 promise.then(() => { 2553 console.info('Succeeded in setting handwriting flag of window.'); 2554 }).catch((err: BusinessError) => { 2555 console.error(`Failed to set handwriting flag of window. Cause code: ${err.code}, message: ${err.message}`); 2556 }); 2557} catch (exception) { 2558 console.error(`Failed to set handwriting flag of window. Cause code: ${exception.code}, message: ${exception.message}`); 2559} 2560``` 2561 2562### raiseAboveTarget<sup>10+</sup> 2563 2564raiseAboveTarget(windowId: number, callback: AsyncCallback<void>): void 2565 2566Raises a subwindow above a target subwindow. This API uses an asynchronous callback to return the result. 2567 2568**System API**: This is a system API. 2569 2570**System capability**: SystemCapability.Window.SessionManager 2571 2572**Parameters** 2573 2574| Name | Type | Mandatory| Description | 2575| -------- | ------------------------- | ---- | ---------- | 2576| windowId | number | Yes | ID of the target subwindow, which is the value of **properties.id** in [properties](js-apis-window.md#windowproperties) obtained through [getWindowProperties](js-apis-window.md#getwindowproperties9).| 2577| callback | AsyncCallback<void> | Yes | Callback used to return the result.| 2578 2579**Error codes** 2580 2581For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Window Error Codes](errorcode-window.md). 2582 2583| ID| Error Message| 2584| ------- | ---------------------------------------------- | 2585| 202 | Permission verification failed. A non-system application calls a system API. | 2586| 401 | Parameter error. Possible cause: Mandatory parameters are left unspecified. | 2587| 801 | Capability not supported. Failed to call the API due to limited device capabilities. | 2588| 1300002 | This window state is abnormal. | 2589| 1300003 | This window manager service works abnormally. | 2590| 1300004 | Unauthorized operation. | 2591| 1300009 | The parent window is invalid. | 2592 2593**Example** 2594 2595```ts 2596// EntryAbility.ets 2597import { UIAbility } from '@kit.AbilityKit'; 2598import { BusinessError } from '@kit.BasicServicesKit'; 2599 2600export default class EntryAbility extends UIAbility { 2601 // ... 2602 onWindowStageCreate(windowStage: window.WindowStage): void { 2603 console.info('onWindowStageCreate'); 2604 let windowClass: window.Window | undefined = undefined; 2605 // Create a subwindow. 2606 try { 2607 let subWindow = windowStage.createSubWindow("testSubWindow"); 2608 subWindow.then((data) => { 2609 if (data == null) { 2610 console.error("Failed to create the subWindow. Cause: The data is empty"); 2611 return; 2612 } 2613 windowClass = data; 2614 // The windowClass must be obtained above the targetWindow. 2615 let targetWindow: window.Window = windowClass; 2616 let properties = targetWindow.getWindowProperties(); 2617 let targetId = properties.id; 2618 windowClass.raiseAboveTarget(targetId, (err) => { 2619 if (err.code) { 2620 console.error(`Failed to raise the subWindow to target subWindow top. Cause code: ${err.code}, message: ${err.message}`); 2621 return; 2622 } 2623 console.info('Succeeded in raising the subWindow to target subWindow top.'); 2624 }); 2625 }); 2626 } catch (exception) { 2627 console.error(`Failed to create the subWindow. Cause code: ${exception.code}, message: ${exception.message}`); 2628 } 2629 } 2630} 2631``` 2632 2633### raiseAboveTarget<sup>10+</sup> 2634 2635raiseAboveTarget(windowId: number): Promise<void> 2636 2637Raises a subwindow above a target subwindow. This API uses a promise to return the result. 2638 2639**System API**: This is a system API. 2640 2641**System capability**: SystemCapability.Window.SessionManager 2642 2643**Parameters** 2644 2645| Name | Type | Mandatory| Description | 2646| -------- | ------------------------- | ---- | ---------- | 2647| windowId | number | Yes | ID of the target subwindow, which is the value of **properties.id** in [properties](js-apis-window.md#windowproperties) obtained through [getWindowProperties](js-apis-window.md#getwindowproperties9).| 2648 2649**Return value** 2650 2651| Type | Description | 2652| ------------------- | ------------------------- | 2653| Promise<void> | Promise that returns no value.| 2654 2655**Error codes** 2656 2657For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Window Error Codes](errorcode-window.md). 2658 2659| ID| Error Message| 2660| ------- | ------------------------------ | 2661| 202 | Permission verification failed. A non-system application calls a system API. | 2662| 401 | Parameter error. Possible cause: Mandatory parameters are left unspecified. | 2663| 801 | Capability not supported. Failed to call the API due to limited device capabilities. | 2664| 1300002 | This window state is abnormal. | 2665| 1300003 | This window manager service works abnormally. | 2666| 1300004 | Unauthorized operation. | 2667| 1300009 | The parent window is invalid. | 2668 2669**Example** 2670 2671```ts 2672// EntryAbility.ets 2673import { UIAbility } from '@kit.AbilityKit'; 2674import { BusinessError } from '@kit.BasicServicesKit'; 2675 2676export default class EntryAbility extends UIAbility { 2677 // ... 2678 onWindowStageCreate(windowStage: window.WindowStage): void { 2679 console.info('onWindowStageCreate'); 2680 let windowClass: window.Window | undefined = undefined; 2681 // Create a subwindow. 2682 try { 2683 let subWindow = windowStage.createSubWindow("testSubWindow"); 2684 subWindow.then((data) => { 2685 if (data == null) { 2686 console.error("Failed to create the subWindow. Cause: The data is empty"); 2687 return; 2688 } 2689 windowClass = data; 2690 // The windowClass must be obtained above the targetWindow. 2691 let targetWindow: window.Window = windowClass; 2692 let properties = targetWindow.getWindowProperties(); 2693 let targetId = properties.id; 2694 let promise = windowClass.raiseAboveTarget(targetId); 2695 promise.then(()=> { 2696 console.info('Succeeded in raising the subWindow to target subWindow top.'); 2697 }).catch((err: BusinessError)=>{ 2698 console.error(`Failed to raise the subWindow to target subWindow top. Cause code: ${err.code}, message: ${err.message}`); 2699 }); 2700 }); 2701 } catch (exception) { 2702 console.error(`Failed to create the subWindow. Cause code: ${exception.code}, message: ${exception.message}`); 2703 } 2704 } 2705} 2706``` 2707 2708### setRaiseByClickEnabled<sup>10+</sup> 2709 2710setRaiseByClickEnabled(enable: boolean, callback: AsyncCallback<void>): void 2711 2712Sets whether to enable a subwindow to raise itself by click. This API uses an asynchronous callback to return the result. 2713 2714Generally, when a user clicks a subwindow, the subwindow is displayed on the top. If the **enable** parameter is set to **false**, the subwindow is not displayed on the top when being clicked. 2715 2716**System API**: This is a system API. 2717 2718**System capability**: SystemCapability.Window.SessionManager 2719 2720**Parameters** 2721 2722| Name | Type | Mandatory| Description | 2723| -------- | ------------------------- | ---- | ---------- | 2724| enable | boolean | Yes | Whether to enable a subwindow to raise itself by click. The value **true** means to enable the subwindow to raise itself by click, and **false** means the opposite.| 2725| callback | AsyncCallback<void> | Yes | Callback used to return the result.| 2726 2727**Error codes** 2728 2729For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Window Error Codes](errorcode-window.md). 2730 2731| ID| Error Message| 2732| ------- | ------------------------------ | 2733| 202 | Permission verification failed. A non-system application calls a system API. | 2734| 401 | Parameter error. Possible cause: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. | 2735| 801 | Capability not supported. Failed to call the API due to limited device capabilities. | 2736| 1300002 | This window state is abnormal. | 2737| 1300003 | This window manager service works abnormally. | 2738| 1300004 | Unauthorized operation. | 2739| 1300009 | The parent window is invalid. | 2740 2741**Example** 2742 2743```ts 2744// EntryAbility.ets 2745import { UIAbility } from '@kit.AbilityKit'; 2746import { BusinessError } from '@kit.BasicServicesKit'; 2747 2748export default class EntryAbility extends UIAbility { 2749 // ... 2750 onWindowStageCreate(windowStage: window.WindowStage): void { 2751 console.info('onWindowStageCreate'); 2752 let windowClass: window.Window | undefined = undefined; 2753 // Create a subwindow. 2754 try { 2755 let subWindow = windowStage.createSubWindow("testSubWindow"); 2756 subWindow.then((data) => { 2757 if (data == null) { 2758 console.error("Failed to create the subWindow. Cause: The data is empty"); 2759 return; 2760 } 2761 windowClass = data; 2762 let enabled = false; 2763 windowClass.setRaiseByClickEnabled(enabled, (err) => { 2764 if (err.code) { 2765 console.error(`Failed to disable the raise-by-click function. Cause code: ${err.code}, message: ${err.message}`); 2766 return; 2767 } 2768 console.info('Succeeded in disabling the raise-by-click function.'); 2769 }); 2770 }); 2771 } catch (exception) { 2772 console.error(`Failed to create the subWindow. Cause code: ${exception.code}, message: ${exception.message}`); 2773 } 2774 } 2775} 2776``` 2777 2778### enableDrag<sup>14+</sup> 2779 2780enableDrag(enable: boolean): Promise<void> 2781 2782Enables or disables window dragging. This API uses a promise to return the result. 2783 2784After window dragging is enabled, the window can be resized using the mouse. 2785 2786This API takes effect only for the system window on 2-in-1 devices. If this API is called for other device types, an error is reported. 2787 2788**System capability**: SystemCapability.Window.SessionManager 2789 2790**System API**: This is a system API. 2791 2792**Parameters** 2793 2794| Name| Type| Mandatory| Description| 2795| -------- | ---------------------------- | -- | --------- | 2796| enable| boolean | Yes| Whether to enable dragging.<br>The value **true** means to enable dragging, and **false** means the opposite.<br>| 2797 2798**Return value** 2799 2800| Type | Description | 2801| ------------------- | ------------------------- | 2802| Promise<void> | Promise that returns no value. | 2803 2804**Error codes** 2805 2806For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Window Error Codes](errorcode-window.md). 2807 2808| ID| Error Message| 2809| -------- | -------------------------------------------- | 2810| 202 | Permission verification failed. A non-system application calls a system API. | 2811| 401 | Parameter error. Possible cause: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. | 2812| 801 | Capability not supported. Failed to call the API due to limited device capabilities. | 2813| 1300002 | This window state is abnormal. | 2814| 1300003 | This window manager service works abnormally. | 2815| 1300004 | Unauthorized operation. | 2816 2817**Example** 2818 2819```ts 2820import { BusinessError } from '@kit.BasicServicesKit'; 2821 2822try { 2823 windowClass.enableDrag(true).then(() => { 2824 console.info('succeeded in setting window draggable'); 2825 }).catch((err: BusinessError) => { 2826 console.error(`Failed to set window draggable. Cause code: ${err.code}, message: ${err.message}`); 2827 }); 2828} catch (exception) { 2829 console.error(`Failed to set window draggable. Cause code: ${exception.code}, message: ${exception.message}`); 2830} 2831``` 2832 2833### hideNonSystemFloatingWindows<sup>11+</sup> 2834 2835hideNonSystemFloatingWindows(shouldHide: boolean, callback: AsyncCallback<void>): void 2836 2837Sets whether to hide non-system floating windows. This API uses an asynchronous callback to return the result. 2838 2839A non-system floating window is a floating window created by a non-system application. By default, the main window of a system application can be displayed together with a non-system floating window. This means that the main window may be blocked by an upper-layer non-system floating window. If the **shouldHide** parameter is set to **true**, all non-system floating windows are hidden, so that the main window will never be blocked by a non-system floating window. 2840 2841**System API**: This is a system API. 2842 2843**System capability**: SystemCapability.Window.SessionManager 2844 2845**Parameters** 2846 2847| Name | Type | Mandatory| Description | 2848| ----------- | ------------------------- | ---- | ---------- | 2849| shouldHide | boolean | Yes | Whether to hide non-system floating windows. The value **true** means to hide the floating windows, and **false** means the opposite.| 2850| callback | AsyncCallback<void> | Yes | Callback used to return the result.| 2851 2852**Error codes** 2853 2854For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Window Error Codes](errorcode-window.md). 2855 2856| ID| Error Message| 2857| ------- | ------------------------------ | 2858| 202 | Permission verification failed. A non-system application calls a system API. | 2859| 401 | Parameter error. Possible cause: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. | 2860| 801 | Capability not supported. Failed to call the API due to limited device capabilities. | 2861| 1300002 | This window state is abnormal. | 2862| 1300003 | This window manager service works abnormally. | 2863| 1300004 | Unauthorized operation. | 2864 2865**Example** 2866 2867```ts 2868// EntryAbility.ets 2869import { UIAbility, Want } from '@kit.AbilityKit'; 2870 2871export default class EntryAbility extends UIAbility { 2872 onWindowStageCreate(windowStage: window.WindowStage) { 2873 // Load the page corresponding to the main window. 2874 windowStage.loadContent('pages/Index', (err) => { 2875 if (err.code) { 2876 console.error(`Failed to load the content. Cause code: ${err.code}, message: ${err.message}`); 2877 return; 2878 } 2879 console.info('Succeeded in loading the content.'); 2880 }); 2881 2882 // Obtain the main window. 2883 let mainWindow: window.Window | undefined = undefined; 2884 windowStage.getMainWindow((err, data) => { 2885 if (err.code) { 2886 console.error(`Failed to obtain the main window. Cause code: ${err.code}, message: ${err.message}`); 2887 return; 2888 } 2889 mainWindow = data; 2890 console.info('Succeeded in obtaining the main window. Data: ' + JSON.stringify(data)); 2891 2892 let shouldHide = true; 2893 // Call hideNonSystemFloatingWindows with the callback parameter. 2894 mainWindow.hideNonSystemFloatingWindows(shouldHide, (err) => { 2895 if (err.code) { 2896 console.error(`Failed to hide the non-system floating windows. Cause code: ${err.code}, message: ${err.message}`); 2897 return; 2898 } 2899 console.info('Succeeded in hiding the non-system floating windows.'); 2900 }); 2901 }); 2902 } 2903} 2904``` 2905 2906### hideNonSystemFloatingWindows<sup>11+</sup> 2907 2908hideNonSystemFloatingWindows(shouldHide: boolean): Promise<void> 2909 2910Sets whether to hide non-system floating windows. This API uses a promise to return the result. 2911 2912A non-system floating window is a floating window created by a non-system application. By default, the main window of a system application can be displayed together with a non-system floating window. This means that the main window may be blocked by an upper-layer non-system floating window. If the **shouldHide** parameter is set to **true**, all non-system floating windows are hidden, so that the main window will never be blocked by a non-system floating window. 2913 2914**System API**: This is a system API. 2915 2916**System capability**: SystemCapability.Window.SessionManager 2917 2918**Parameters** 2919 2920| Name | Type | Mandatory| Description | 2921| ----------- | ------------------------- | ---- | ---------- | 2922| shouldHide | boolean | Yes | Whether to hide non-system floating windows. The value **true** means to hide the floating windows, and **false** means the opposite.| 2923 2924**Return value** 2925 2926| Type | Description | 2927| ------------------- | ------------------------- | 2928| Promise<void> | Promise that returns no value.| 2929 2930**Error codes** 2931 2932For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Window Error Codes](errorcode-window.md). 2933 2934| ID| Error Message| 2935| ------- | ------------------------------ | 2936| 202 | Permission verification failed. A non-system application calls a system API. | 2937| 401 | Parameter error. Possible cause: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. | 2938| 801 | Capability not supported. Failed to call the API due to limited device capabilities. | 2939| 1300002 | This window state is abnormal. | 2940| 1300003 | This window manager service works abnormally. | 2941| 1300004 | Unauthorized operation. | 2942 2943**Example** 2944 2945```ts 2946// EntryAbility.ets 2947import { UIAbility, Want } from '@kit.AbilityKit'; 2948import { BusinessError } from '@kit.BasicServicesKit'; 2949 2950export default class EntryAbility extends UIAbility { 2951 onWindowStageCreate(windowStage: window.WindowStage) { 2952 // Load the page corresponding to the main window. 2953 windowStage.loadContent('pages/Index', (err) => { 2954 if (err.code) { 2955 console.error(`Failed to load the content. Cause code: ${err.code}, message: ${err.message}`); 2956 return; 2957 } 2958 console.info('Succeeded in loading the content.'); 2959 }); 2960 2961 // Obtain the main window. 2962 let mainWindow: window.Window | undefined = undefined; 2963 windowStage.getMainWindow((err, data) => { 2964 if (err.code) { 2965 console.error(`Failed to obtain the main window. Cause code: ${err.code}, message: ${err.message}`); 2966 return; 2967 } 2968 mainWindow = data; 2969 console.info('Succeeded in obtaining the main window. Data: ' + JSON.stringify(data)); 2970 2971 let shouldHide = true; 2972 // Call hideNonSystemFloatingWindows to obtain a promise object. 2973 let promise = mainWindow.hideNonSystemFloatingWindows(shouldHide); 2974 promise.then(()=> { 2975 console.info('Succeeded in hiding the non-system floating windows.'); 2976 }).catch((err: BusinessError)=>{ 2977 console.error(`Failed to hide the non-system floating windows. Cause code: ${err.code}, message: ${err.message}`); 2978 }); 2979 }); 2980 } 2981} 2982``` 2983 2984### setTopmost<sup>12+</sup> 2985 2986setTopmost(isTopmost: boolean): Promise<void> 2987 2988Called by the main window to place the window above all the other windows. This API uses a promise to return the result. 2989 2990This parameter is valid only when the main window is a floating window in 2-in-1 devices. 2991 2992**System API**: This is a system API. 2993 2994**System capability**: SystemCapability.Window.SessionManager 2995 2996**Parameters** 2997 2998| Name | Type | Mandatory| Description | 2999| -------- | ------------------------- | ---- | ---------- | 3000| isTopmost | boolean | Yes | Whether to pin the main window on top. The value **true** means to pin the main window on top, and **false** means the opposite.| 3001 3002**Return value** 3003 3004| Type | Description | 3005| ------------------- | ------------------------- | 3006| Promise<void> | Promise that returns no value.| 3007 3008**Error codes** 3009 3010For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Window Error Codes](errorcode-window.md). 3011 3012| ID| Error Message| 3013| ------- | ------------------------------ | 3014| 202 | Permission verification failed. A non-system application calls a system API. | 3015| 401 | Parameter error. Possible cause: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. | 3016| 801 | Capability not supported. Failed to call the API due to limited device capabilities. | 3017| 1300002 | This window state is abnormal. | 3018| 1300003 | This window manager service works abnormally. | 3019| 1300004 | Unauthorized operation. | 3020 3021**Example** 3022 3023```ts 3024// EntryAbility.ets 3025import { UIAbility } from '@kit.AbilityKit'; 3026import { BusinessError } from '@kit.BasicServicesKit'; 3027 3028export default class EntryAbility extends UIAbility { 3029 // ... 3030 onWindowStageCreate(windowStage: window.WindowStage): void { 3031 // ... 3032 windowStage.getMainWindow().then((window) => { 3033 let isTopmost: boolean = true; 3034 let promise = window.setTopmost(isTopmost); 3035 promise.then(() => { 3036 console.info('Succeeded in setting the main window to be topmost.'); 3037 }).catch((err: BusinessError) => { 3038 console.error(`Failed to set the main window to be topmost. Cause code: ${err.code}, message: ${err.message}`); 3039 }); 3040 }); 3041 } 3042} 3043``` 3044 3045### setSingleFrameComposerEnabled<sup>11+</sup> 3046 3047setSingleFrameComposerEnabled(enable: boolean): Promise<void> 3048 3049Enables or disables the single-frame composer. This API uses a promise to return the result. 3050 3051The single-frame composer is mainly used in scenarios that requires extremely low interaction latency. It reduces the screen display latency of the rendering node. 3052 3053**System API**: This is a system API. 3054 3055**System capability**: SystemCapability.Window.SessionManager 3056 3057**Parameters** 3058 3059| Name | Type | Mandatory| Description | 3060| -------- | ------------------------- | ---- | ---------- | 3061| enable | boolean | Yes | Whether to enable the single-frame composer. The value **true** means to enable the single-frame composer, and false means to disable it.| 3062 3063**Return value** 3064 3065| Type | Description | 3066| ------------------- | ------------------------- | 3067| Promise<void> | Promise that returns no value.| 3068 3069**Error codes** 3070 3071For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Window Error Codes](errorcode-window.md). 3072 3073| ID| Error Message| 3074| ------- | ------------------------------ | 3075| 202 | Permission verification failed. A non-system application calls a system API. | 3076| 401 | Parameter error. Possible cause: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. | 3077| 801 | Capability not supported. Failed to call the API due to limited device capabilities. | 3078| 1300002 | This window state is abnormal. | 3079 3080**Example** 3081 3082```ts 3083import { BusinessError } from '@kit.BasicServicesKit'; 3084 3085let enable = true; 3086let promise = windowClass.setSingleFrameComposerEnabled(enable); 3087promise.then(()=> { 3088 console.info('Succeeded in enabling the single-frame-composer function.'); 3089}).catch((err: BusinessError)=>{ 3090 console.error(`Failed to enable the single-frame-composer function. code:${err.code}, message:${err.message}.`); 3091}); 3092``` 3093 3094### setTitleButtonVisible<sup>12+</sup> 3095 3096setTitleButtonVisible(isMaximizeVisible: boolean, isMinimizeVisible: boolean, isSplitVisible: boolean): void 3097 3098Shows or hides the maximize, minimize, and split-screen buttons on the title bar of the main window. 3099 3100This API is valid only for 2-in-1 devices and takes effect only for the title bar buttons (maximize, minimize, and split-screen) that are available in the current scenario. 3101 3102**System API**: This is a system API. 3103 3104**System capability**: SystemCapability.Window.SessionManager 3105 3106**Parameters** 3107 3108| Name | Type | Mandatory| Description | 3109| --------- | ------- | ---- | --------------------------------------------- | 3110| isMaximizeVisible | boolean | Yes | Whether to show the maximize button. The value **true** means to show the button, and **false** means to hide it.| 3111| isMinimizeVisible | boolean | Yes | Whether to show the minimize button. The value **true** means to show the button, and **false** means to hide it.| 3112| isSplitVisible | boolean | Yes | Whether to show the split-screen button. The value **true** means to show the button, and **false** means to hide it.| 3113 3114**Error codes** 3115 3116For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Window Error Codes](errorcode-window.md). 3117 3118| ID| Error Message | 3119| -------- | ------------------------------ | 3120| 202 | Permission verification failed. A non-system application calls a system API. | 3121| 401 | Parameter error. Possible cause: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. | 3122| 801 | Capability not supported. Failed to call the API due to limited device capabilities. | 3123| 1300002 | This window state is abnormal. | 3124| 1300004 | Unauthorized operation. | 3125 3126**Example** 3127 3128```ts 3129// EntryAbility.ets 3130import { UIAbility } from '@kit.AbilityKit'; 3131import { BusinessError } from '@kit.BasicServicesKit'; 3132 3133export default class EntryAbility extends UIAbility { 3134 onWindowStageCreate(windowStage: window.WindowStage): void { 3135 // Load the page corresponding to the main window. 3136 windowStage.loadContent('pages/Index', (err) => { 3137 let mainWindow: window.Window | undefined = undefined; 3138 // Obtain the main window. 3139 windowStage.getMainWindow().then( 3140 data => { 3141 mainWindow = data; 3142 console.info('Succeeded in obtaining the main window. Data: ' + JSON.stringify(data)); 3143 // Call setTitleButtonVisible to hide the maximize, minimize, and split-screen buttons on the title bar of the main window. 3144 mainWindow.setTitleButtonVisible(false, false, false); 3145 } 3146 ).catch((err: BusinessError) => { 3147 if(err.code){ 3148 console.error(`Failed to obtain the main window. Cause code: ${err.code}, message: ${err.message}`); 3149 } 3150 }); 3151 }); 3152 } 3153} 3154``` 3155 3156### setWindowType<sup>(deprecated)</sup> 3157 3158setWindowType(type: WindowType, callback: AsyncCallback<void>): void 3159 3160Sets the type of this window. This API uses an asynchronous callback to return the result. 3161 3162**System API**: This is a system API. 3163 3164> **NOTE** 3165> 3166> This API is supported since API version 7 and deprecated since API version 9. 3167 3168**System capability**: SystemCapability.WindowManager.WindowManager.Core 3169 3170**Parameters** 3171 3172| Name | Type | Mandatory| Description | 3173| -------- | ------------------------- | ---- | ---------- | 3174| type | [WindowType](#windowtype7) | Yes | Window type.| 3175| callback | AsyncCallback<void> | Yes | Callback used to return the result.| 3176 3177**Example** 3178 3179```ts 3180import { BusinessError } from '@kit.BasicServicesKit'; 3181 3182let type = window.WindowType.TYPE_SYSTEM_ALERT; 3183windowClass.setWindowType(type, (err: BusinessError) => { 3184 const errCode: number = err.code; 3185 if (errCode) { 3186 console.error(`Failed to set the window type. Cause code: ${err.code}, message: ${err.message}`); 3187 return; 3188 } 3189 console.info('Succeeded in setting the window type.'); 3190}); 3191``` 3192 3193### setWindowType<sup>(deprecated)</sup> 3194 3195setWindowType(type: WindowType): Promise<void> 3196 3197Sets the type of this window. This API uses a promise to return the result. 3198 3199**System API**: This is a system API. 3200 3201> **NOTE** 3202> 3203> This API is supported since API version 7 and deprecated since API version 9. 3204 3205**System capability**: SystemCapability.WindowManager.WindowManager.Core 3206 3207**Parameters** 3208 3209| Name| Type | Mandatory| Description | 3210| ------ | ------------------------- | ---- | ---------- | 3211| type | [WindowType](#windowtype7) | Yes | Window type.| 3212 3213**Return value** 3214 3215| Type | Description | 3216| ------------------- | ------------------------- | 3217| Promise<void> | Promise that returns no value.| 3218 3219**Example** 3220 3221```ts 3222import { BusinessError } from '@kit.BasicServicesKit'; 3223 3224let type = window.WindowType.TYPE_SYSTEM_ALERT; 3225let promise = windowClass.setWindowType(type); 3226promise.then(() => { 3227 console.info('Succeeded in setting the window type.'); 3228}).catch((err: BusinessError) => { 3229 console.error(`Failed to set the window type. Cause code: ${err.code}, message: ${err.message}`); 3230}); 3231``` 3232 3233### requestFocus<sup>13+</sup> 3234 3235requestFocus(isFocused: boolean): Promise<void> 3236 3237Allows this window to proactively request to gain or lose focus. This API uses a promise to return the result. A value is returned as long as the API is successfully called. The return value does not indicate that the window has gained or lost focus. You can use [on('windowEvent')](js-apis-window.md#onwindowevent10) to listen for the focus status of the window. 3238 3239When a focus request is sent, whether the window can successfully gain focus depends on its capability of being focused and its current visibility. To gain focus, the window must be capable of receiving focus and in a visible state (actively displayed and not hidden or destroyed). 3240 3241Conversely, once a blur request is sent, the window will lose focus without any conditions. 3242 3243**System API**: This is a system API. 3244 3245**System capability**: SystemCapability.Window.SessionManager 3246 3247**Parameters** 3248 3249| Name | Type | Mandatory| Description | 3250| -------- | ------------------------- | ---- | ---------- | 3251| isFocused | boolean | Yes | Whether to gain or lose focus. The value **true** means to gain focus, and **false** means to lose focus.| 3252 3253**Return value** 3254 3255| Type | Description | 3256| ------------------- | ------------------------- | 3257| Promise<void> | Promise that returns no value.| 3258 3259**Error codes** 3260 3261For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Window Error Codes](errorcode-window.md). 3262 3263| ID| Error Message| 3264| ------- | ------------------------------ | 3265| 202 | Permission verification failed. A non-system application calls a system API. | 3266| 401 | Parameter error. Possible cause: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. | 3267| 801 | Capability not supported. Failed to call the API due to limited device capabilities. | 3268| 1300002 | This window state is abnormal. | 3269| 1300003 | This window manager service works abnormally. | 3270 3271**Example** 3272 3273```ts 3274import { BusinessError } from '@kit.BasicServicesKit'; 3275 3276let isFocused: boolean = true; 3277let promise = windowClass.requestFocus(isFocused); 3278promise.then(() => { 3279 console.info('Succeeded in requesting focus.'); 3280}).catch((err: BusinessError) => { 3281 console.error(`Failed to request focus. Cause code: ${err.code}, message: ${err.message}`); 3282}); 3283``` 3284 3285## SubWindowOptions<sup>11+</sup> 3286 3287Describes the parameters used for creating a subwindow. 3288 3289**System capability**: SystemCapability.Window.SessionManager 3290 3291| Name | Type | Read Only| Optional| Description | 3292| ---------- | ---- | ---- | ---- | ----------- | 3293| isTopmost<sup>12+</sup> | boolean | No| Yes| Whether the subwindow is topmost. The value **true** means that the subwindow is topmost, and **false** means the opposite. The default value is **false**. | 3294 3295## WindowStage<sup>9+</sup> 3296 3297Implements a window manager, which manages each basic window unit, that is, [Window](#window) instance. 3298 3299Before calling any of the following APIs, you must use [onWindowStageCreate()](../apis-ability-kit/js-apis-app-ability-uiAbility.md#uiabilityonwindowstagecreate) to create a **WindowStage** instance. 3300 3301### disableWindowDecor<sup>9+</sup> 3302 3303disableWindowDecor(): void 3304 3305Disables window decorators. 3306 3307When window decorators are disabled and the main window transitions into full-screen mode, hovering the cursor over the hot zone of the top window's title bar will cause a floating title bar to appear. To prevent the floating title bar from appearing, call [setTitleAndDockHoverShown()](./js-apis-window.md#settitleanddockhovershown14). 3308 3309**Model restriction**: This API can be used only in the stage model. 3310 3311**System API**: This is a system API. 3312 3313**System capability**: SystemCapability.WindowManager.WindowManager.Core 3314 3315**Error codes** 3316 3317For details about the error codes, see [Window Error Codes](errorcode-window.md). 3318 3319| ID| Error Message| 3320| ------- | ------------------------------ | 3321| 202 | Permission verification failed. A non-system application calls a system API. | 3322| 1300002 | This window state is abnormal. | 3323| 1300005 | This window stage is abnormal. | 3324 3325**Example** 3326 3327```ts 3328// EntryAbility.ets 3329import { UIAbility, Want } from '@kit.AbilityKit'; 3330 3331export default class EntryAbility extends UIAbility { 3332 // ... 3333 3334 onWindowStageCreate(windowStage: window.WindowStage) { 3335 console.log('disableWindowDecor'); 3336 windowStage.disableWindowDecor(); 3337 } 3338}; 3339``` 3340 3341### setShowOnLockScreen<sup>9+</sup> 3342 3343setShowOnLockScreen(showOnLockScreen: boolean): void 3344 3345Sets whether to display the window of the application on the lock screen. 3346 3347**System API**: This is a system API. 3348 3349**Model restriction**: This API can be used only in the stage model. 3350 3351**System capability**: SystemCapability.WindowManager.WindowManager.Core 3352 3353**Parameters** 3354 3355| Name | Type | Mandatory| Description | 3356| ---------------- | ------- | ---- | ---------------------------- | 3357| showOnLockScreen | boolean | Yes | Whether to display the window on the lock screen. The value **true** means to display the window on the lock screen, and **false** means the opposite.| 3358 3359**Error codes** 3360 3361For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Window Error Codes](errorcode-window.md). 3362 3363| ID| Error Message| 3364| ------- | ------------------------------ | 3365| 202 | Permission verification failed. A non-system application calls a system API. | 3366| 401 | Parameter error. Possible cause: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. | 3367| 1300002 | This window state is abnormal. | 3368| 1300005 | This window stage is abnormal. | 3369 3370**Example** 3371 3372```ts 3373// EntryAbility.ets 3374import { UIAbility } from '@kit.AbilityKit'; 3375 3376export default class EntryAbility extends UIAbility { 3377 // ... 3378 3379 onWindowStageCreate(windowStage: window.WindowStage) { 3380 console.log('onWindowStageCreate'); 3381 try { 3382 windowStage.setShowOnLockScreen(true); 3383 } catch (exception) { 3384 console.error(`Failed to show on lockscreen. Cause code: ${exception.code}, message: ${exception.message}`); 3385 } 3386 } 3387}; 3388``` 3389 3390## TransitionContext<sup>9+</sup> 3391 3392Provides the context for the transition animation. 3393 3394**System API**: This is a system API. 3395 3396### Attributes 3397 3398**System API**: This is a system API. 3399 3400**System capability**: SystemCapability.WindowManager.WindowManager.Core 3401 3402| Name | Type | Readable| Writable| Description | 3403| --------------------- | ----------------- | ---- | ---- | ---------------- | 3404| toWindow<sup>9+</sup> | [Window](#window) | Yes | Yes | Target window to display the animation.| 3405 3406### completeTransition<sup>9+</sup> 3407 3408completeTransition(isCompleted: boolean): void 3409 3410Completes the transition. This API can be called only after [animateTo()](arkui-ts/ts-explicit-animation.md) is executed. 3411 3412**System API**: This is a system API. 3413 3414**System capability**: SystemCapability.WindowManager.WindowManager.Core 3415 3416**Parameters** 3417 3418| Name | Type | Mandatory| Description | 3419| ----------- | ------- | ---- | ------------------------------------------------------------ | 3420| isCompleted | boolean | Yes | Whether the transition is complete. The value **true** means that the transition is complete, and **false** means the opposite.| 3421 3422**Error codes** 3423 3424For details about the error codes, see [Universal Error Codes](../errorcode-universal.md). 3425 3426| ID| Error Message| 3427| ------- | -------------------------------- | 3428| 202 | Permission verification failed. A non-system application calls a system API. | 3429| 401 | Parameter error. Possible cause: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. | 3430 3431**Example** 3432 3433```ts 3434(context: window.TransitionContext) => { 3435 let toWindow: window.Window = context.toWindow; 3436 animateTo({ 3437 duration: 1000, // Animation duration. 3438 tempo: 0.5, // Playback speed. 3439 curve: Curve.EaseInOut, // Animation curve. 3440 delay: 0, // Animation delay. 3441 iterations: 1, // Number of playback times. 3442 playMode: PlayMode.Normal // Animation playback mode. 3443 }, () => { 3444 let obj: window.TranslateOptions = { 3445 x: 100.0, 3446 y: 0.0, 3447 z: 0.0 3448 }; 3449 toWindow.translate(obj); 3450 console.info('toWindow translate end'); 3451 } 3452 ); 3453 try { 3454 context.completeTransition(true) 3455 } catch (exception) { 3456 console.error(`toWindow translate fail. Cause code: ${exception.code}, message: ${exception.message}`); 3457 } 3458 console.info('complete transition end'); 3459}; 3460``` 3461 3462## TransitionController<sup>9+</sup> 3463 3464Implements the transition animation controller. Before calling any API, you must create a system window. For details, see the sample code. 3465 3466**System API**: This is a system API. 3467 3468**Example** 3469 3470```ts 3471import { BusinessError } from '@kit.BasicServicesKit'; 3472 3473let windowClass: window.Window | undefined = undefined; 3474let config: window.Configuration = { 3475 name: "systemTypeWindow", 3476 windowType: window.WindowType.TYPE_PANEL, // Select a system window type as required. 3477 ctx: this.context 3478}; 3479let promise = window.createWindow(config); 3480promise.then((data) => { 3481 windowClass = data; 3482 console.info('Succeeded in creating the window. Data:' + JSON.stringify(data)); 3483}).catch((err: BusinessError) => { 3484 console.error(`Failed to create the Window. Cause code: ${err.code}, message: ${err.message}`); 3485}); 3486``` 3487 3488### animationForShown<sup>9+</sup> 3489 3490animationForShown(context: TransitionContext): void 3491 3492Customizes the animation for the scenario when the window is shown. 3493 3494**System API**: This is a system API. 3495 3496**System capability**: SystemCapability.WindowManager.WindowManager.Core 3497 3498**Parameters** 3499 3500| Name | Type | Mandatory| Description | 3501| ------- | ---------------------------------------- | ---- | -------------------- | 3502| context | [TransitionContext](#transitioncontext9) | Yes | Context of the transition animation.| 3503 3504**Error codes** 3505 3506For details about the error codes, see [Universal Error Codes](../errorcode-universal.md). 3507 3508| ID| Error Message| 3509| ------- | -------------------------------- | 3510| 202 | Permission verification failed. A non-system application calls a system API. | 3511| 401 | Parameter error. Possible cause: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. | 3512 3513**Example** 3514 3515```ts 3516// xxx.ts 3517export class AnimationConfig { 3518 private animationForShownCallFunc_: Function = undefined; 3519 ShowWindowWithCustomAnimation(windowClass: window.Window, callback) { 3520 if (!windowClass) { 3521 console.error('windowClass is undefined'); 3522 return false; 3523 } 3524 this.animationForShownCallFunc_ = callback; 3525 let controller: window.TransitionController = windowClass.getTransitionController(); 3526 controller.animationForShown = (context : window.TransitionContext)=> { 3527 this.animationForShownCallFunc_(context); 3528 }; 3529 windowClass.showWithAnimation(()=>{ 3530 console.info('Show with animation success'); 3531 }); 3532 } 3533} 3534``` 3535 3536```ts 3537// xxx.ets 3538let animationConfig = new AnimationConfig(); 3539let systemTypeWindow = window.findWindow("systemTypeWindow"); // Obtain a system window. 3540try { 3541 animationConfig?.ShowWindowWithCustomAnimation(systemTypeWindow, (context : window.TransitionContext)=>{ 3542 console.info('complete transition end'); 3543 let toWindow = context.toWindow; 3544 animateTo({ 3545 duration: 1000, // Animation duration. 3546 tempo: 0.5, // Playback speed. 3547 curve: Curve.EaseInOut, // Animation curve. 3548 delay: 0, // Animation delay. 3549 iterations: 1, // Number of playback times. 3550 playMode: PlayMode.Normal // Animation playback mode. 3551 onFinish: () => { 3552 console.info('onFinish in animation'); 3553 context.completeTransition(true) 3554 } 3555 }, () => { 3556 let obj : window.TranslateOptions = { 3557 x : 100.0, 3558 y : 0.0, 3559 z : 0.0 3560 }; 3561 toWindow.translate(obj); // Set the transition animation. 3562 console.info('toWindow translate end in animation'); 3563 }); 3564 console.info('complete transition end'); 3565 }); 3566} catch (error) { 3567 console.error(`ShowWindowWithCustomAnimation error code: ${error.code}, message: ${error.message}`); 3568} 3569``` 3570 3571### animationForHidden<sup>9+</sup> 3572 3573animationForHidden(context: TransitionContext): void 3574 3575Customizes the animation for the scenario when the window is hidden. 3576 3577**System API**: This is a system API. 3578 3579**System capability**: SystemCapability.WindowManager.WindowManager.Core 3580 3581**Parameters** 3582 3583| Name | Type | Mandatory| Description | 3584| ------- | ---------------------------------------- | ---- | -------------------- | 3585| context | [TransitionContext](#transitioncontext9) | Yes | Context of the transition animation.| 3586 3587**Error codes** 3588 3589For details about the error codes, see [Universal Error Codes](../errorcode-universal.md). 3590 3591| ID| Error Message| 3592| ------- | -------------------------------- | 3593| 202 | Permission verification failed. A non-system application calls a system API. | 3594| 401 | Parameter error. Possible cause: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. | 3595 3596**Example** 3597 3598```ts 3599// xxx.ts 3600export class AnimationConfig { 3601 private animationForHiddenCallFunc_: Function = undefined; 3602 HideWindowWithCustomAnimation(windowClass: window.Window, callback) { 3603 if (!windowClass) { 3604 console.error('windowClass is undefined'); 3605 return false; 3606 } 3607 this.animationForHiddenCallFunc_ = callback; 3608 let controller: window.TransitionController = windowClass.getTransitionController(); 3609 controller.animationForHidden = (context : window.TransitionContext)=> { 3610 this.animationForHiddenCallFunc_(context); 3611 }; 3612 windowClass.hideWithAnimation(()=>{ 3613 console.info('hide with animation success'); 3614 }); 3615 } 3616} 3617``` 3618 3619```ts 3620// xxx.ets 3621let animationConfig = new AnimationConfig(); 3622let systemTypeWindow = window.findWindow("systemTypeWindow"); // Obtain a system window. 3623try { 3624 animationConfig?.HideWindowWithCustomAnimation(systemTypeWindow, (context : window.TransitionContext)=>{ 3625 console.info('complete transition end'); 3626 let toWindow = context.toWindow; 3627 animateTo({ 3628 duration: 1000, // Animation duration. 3629 tempo: 0.5, // Playback speed. 3630 curve: Curve.EaseInOut, // Animation curve. 3631 delay: 0, // Animation delay. 3632 iterations: 1, // Number of playback times. 3633 playMode: PlayMode.Normal // Animation playback mode. 3634 onFinish: () => { 3635 console.info('onFinish in animation'); 3636 context.completeTransition(true) 3637 } 3638 }, () => { 3639 let obj : window.TranslateOptions = { 3640 x : 100.0, 3641 y : 0.0, 3642 z : 0.0 3643 }; 3644 toWindow.translate(obj); // Set the transition animation. 3645 console.info('toWindow translate end in animation'); 3646 }); 3647 console.info('complete transition end'); 3648 }); 3649} catch (error) { 3650 console.error(`HideWindowWithCustomAnimation error code: ${error.code}, message: ${error.message}` ); 3651} 3652``` 3653 3654## ExtensionWindowAttribute<sup>14+</sup> 3655 3656Enumerates the attributes of a window for a UI ServiceExtensionAbility. 3657 3658**Model restriction**: This API can be used only in the stage model. 3659 3660**System API**: This is a system API. 3661 3662**System capability**: SystemCapability.Window.SessionManager 3663 3664| Name | Value| Description | 3665| ---------- | ----- | ----------- | 3666| SYSTEM_WINDOW | 0 | System window| 3667| SUB_WINDOW | 1 | Subwindow.| 3668 3669## SystemWindowOptions<sup>14+</sup> 3670 3671Describes the parameters for creating a system window. 3672 3673**Model restriction**: This API can be used only in the stage model. 3674 3675**System API**: This is a system API. 3676 3677**System capability**: SystemCapability.Window.SessionManager 3678 3679| Name| Type | Read Only |Optional| Description | 3680| ------ | ------------------------- | ---- | ---- |---------- | 3681| windowType | [WindowType](#windowtype7) | No | No | Window type. There is no default value. If null is passed in, the window fails to be created. **TYPE_DIALOG** is not supported.| 3682 3683## ExtensionWindowConfig<sup>14+</sup> 3684 3685Describes the parameters for creating a window for a UI ServiceExtensionAbility. 3686 3687**Model restriction**: This API can be used only in the stage model. 3688 3689**System API**: This is a system API. 3690 3691**System capability**: SystemCapability.Window.SessionManager 3692 3693| Name| Type | Read Only |Optional| Description | 3694| ------ | ------------------------- | ---- | ---- |---------- | 3695| windowName | string | No| No | Window name.| 3696| windowAttribute | [ExtensionWindowAttribute](#extensionwindowattribute14) | No| No | Window attribute. It specifies whether the created window is a subwindow or a system window. When **windowAttribute** is set to **SUB_WINDOW**, **subWindowOptions** is mandatory. When **windowAttribute** is set to **SYSTEM_WINDOW**, **systemWindowOptions** is mandatory. Otherwise, the window fails to be created.| 3697| windowRect | [Rect](js-apis-window.md#rect7) | No| No | Rectangular area of the window.| 3698| subWindowOptions | [SubWindowOptions](js-apis-window.md#subwindowoptions11) | No| Yes| Parameters used for creating a subwindow. There is no default value. This parameter is mandatory when **windowAttribute** is set to **SUB_WINDOW**. Otherwise, the window fails to be created.| 3699| systemWindowOptions | [SystemWindowOptions](#systemwindowoptions14) | No| Yes| Parameters for creating a system window. There is no default value. This parameter is mandatory when **windowAttribute** is set to **SYSTEM_WINDOW**. Otherwise, the window fails to be created.| 3700 3701 <!--no_check-->