• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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): the current 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 '@ohos.window';
20```
21
22## WindowType<sup>7+</sup>
23
24
25Enumerates the window types.
26
27**System capability**: SystemCapability.WindowManager.WindowManager.Core
28
29| Name                                 | Value| Description                                                                                    |
30|-------------------------------------| ------ |----------------------------------------------------------------------------------------|
31| TYPE_INPUT_METHOD<sup>9+</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.                        |
32| 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.                        |
33| 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.                          |
34| 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.                           |
35| 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.                          |
36| 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.                        |
37| 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.                           |
38| 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.                           |
39| 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.                        |
40| 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.                      |
41| 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.                         |
42| 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.                           |
43| 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.                      |
44| 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.                         |
45| 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.                       |
46| 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.                |
47| 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.                       |
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| Readable| Writable| Description                                        |
132| ------ | -------- | ---- | ---- |--------------------------------------------|
133| x      | number   | No  | Yes  | Scale factor along the x-axis. The value is a floating point number, and the default value is **1.0**.                  |
134| y      | number   | No  | Yes  | Scale factor along the y-axis. The value is a floating point number, and the default value is **1.0**.                  |
135| pivotX | number   | No  | Yes  | 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  | Yes  | 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| Readable| Writable| Description                                         |
147| ------ | -------- | ---- | ---- |---------------------------------------------|
148| x      | number   | No  | Yes  | Rotation angle around the x-axis. The value is a floating point number, and the default value is **0.0**.                  |
149| y      | number   | No  | Yes  | Rotation angle around the y-axis. The value is a floating point number, and the default value is **0.0**.                  |
150| z      | number   | No  | Yes  | Rotation angle around the z-axis. The value is a floating point number, and the default value is **0.0**.                  |
151| pivotX | number   | No  | Yes  | 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  | Yes  | 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| Readable| Writable| Description                        |
163| ---- | -------- | ---- | ---- | ---------------------------- |
164| x    | number   | No  | Yes  | 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  | Yes  | 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  | Yes  | 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
169## window.minimizeAll<sup>9+</sup>
170minimizeAll(id: number, callback: AsyncCallback&lt;void&gt;): void
171
172Minimizes all windows on a display. This API uses an asynchronous callback to return the result.
173
174**System API**: This is a system API.
175
176**System capability**: SystemCapability.WindowManager.WindowManager.Core
177
178**Parameters**
179
180| Name  | Type                     | Mandatory| Description          |
181| -------- | ------------------------- | ---- | -------------- |
182| id       | number                    | Yes  | ID of the [display](js-apis-display.md#display). The value must be an integer.|
183| callback | AsyncCallback&lt;void&gt; | Yes  | Callback used to return the result.    |
184
185**Error codes**
186
187For details about the error codes, see [Window Error Codes](errorcode-window.md).
188
189| ID| Error Message|
190| ------- | -------------------------------------------- |
191| 1300003 | This window manager service works abnormally. |
192
193**Example**
194
195```ts
196import display from '@ohos.display'
197import { BusinessError } from '@ohos.base';
198
199let displayClass: display.Display | null = null;
200try {
201  displayClass = display.getDefaultDisplaySync();
202
203  try {
204    window.minimizeAll(displayClass.id, (err: BusinessError) => {
205      const errCode: number = err.code;
206      if (errCode) {
207        console.error('Failed to minimize all windows. Cause: ' + JSON.stringify(err));
208        return;
209      }
210      console.info('Succeeded in minimizing all windows.');
211    });
212  } catch (exception) {
213    console.error('Failed to minimize all windows. Cause: ' + JSON.stringify(exception));
214  }
215} catch (exception) {
216  console.error('Failed to obtain the default display object. Code: ' + JSON.stringify(exception));
217}
218```
219
220## window.minimizeAll<sup>9+</sup>
221minimizeAll(id: number): Promise&lt;void&gt;
222
223Minimizes all windows on a display. This API uses a promise to return the result.
224
225**System API**: This is a system API.
226
227**System capability**: SystemCapability.WindowManager.WindowManager.Core
228
229**Parameters**
230
231| Name  | Type                     | Mandatory| Description          |
232| -------- | ------------------------- | ---- | -------------- |
233| id       | number                    | Yes  | ID of the [display](js-apis-display.md#display). The value must be an integer.|
234
235**Return value**
236
237| Type               | Description                     |
238| ------------------- | ------------------------- |
239| Promise&lt;void&gt; | Promise that returns no value.|
240
241**Error codes**
242
243For details about the error codes, see [Window Error Codes](errorcode-window.md).
244
245| ID| Error Message|
246| ------- | -------------------------------------------- |
247| 1300003 | This window manager service works abnormally. |
248
249**Example**
250
251```ts
252import display from '@ohos.display'
253import { BusinessError } from '@ohos.base';
254
255let displayClass: display.Display | null = null;
256try {
257  displayClass = display.getDefaultDisplaySync();
258
259  try {
260    let promise = window.minimizeAll(displayClass.id);
261    promise.then(() => {
262      console.info('Succeeded in minimizing all windows.');
263    }).catch((err: BusinessError) => {
264      console.error('Failed to minimize all windows. Cause: ' + JSON.stringify(err));
265    });
266  } catch (exception) {
267    console.error('Failed to minimize all windows. Cause: ' + JSON.stringify(exception));
268  }
269} catch (exception) {
270  console.error('Failed to obtain the default display object. Code: ' + JSON.stringify(exception));
271}
272```
273
274## window.toggleShownStateForAllAppWindows<sup>9+</sup>
275toggleShownStateForAllAppWindows(callback: AsyncCallback&lt;void&gt;): void
276
277Hides or restores the application's windows during quick multi-window switching. This API uses an asynchronous callback to return the result.
278
279**System API**: This is a system API.
280
281**System capability**: SystemCapability.WindowManager.WindowManager.Core
282
283**Parameters**
284
285| Name  | Type                     | Mandatory| Description          |
286| -------- | ------------------------- | ---- | -------------- |
287| callback | AsyncCallback&lt;void&gt; | Yes  | Callback used to return the result.    |
288
289**Error codes**
290
291For details about the error codes, see [Window Error Codes](errorcode-window.md).
292
293| ID| Error Message|
294| ------- | -------------------------------------------- |
295| 1300003 | This window manager service works abnormally. |
296
297**Example**
298
299```ts
300import { BusinessError } from '@ohos.base';
301
302window.toggleShownStateForAllAppWindows((err: BusinessError) => {
303  const errCode: number = err.code;
304  if (errCode) {
305    console.error('Failed to toggle shown state for all app windows. Cause: ' + JSON.stringify(err));
306    return;
307  }
308  console.info('Succeeded in toggling shown state for all app windows.');
309});
310```
311
312## window.toggleShownStateForAllAppWindows<sup>9+</sup>
313toggleShownStateForAllAppWindows(): Promise&lt;void&gt;
314
315Hides or restores the application's windows during quick multi-window switching. This API uses a promise to return the result.
316
317**System API**: This is a system API.
318
319**System capability**: SystemCapability.WindowManager.WindowManager.Core
320
321**Return value**
322
323| Type               | Description                     |
324| ------------------- | ------------------------- |
325| Promise&lt;void&gt; | Promise that returns no value.|
326
327**Error codes**
328
329For details about the error codes, see [Window Error Codes](errorcode-window.md).
330
331| ID| Error Message|
332| ------- | -------------------------------------------- |
333| 1300003 | This window manager service works abnormally. |
334
335**Example**
336
337```ts
338import { BusinessError } from '@ohos.base';
339
340let promise = window.toggleShownStateForAllAppWindows();
341promise.then(() => {
342  console.info('Succeeded in toggling shown state for all app windows.');
343}).catch((err: BusinessError) => {
344  console.error('Failed to toggle shown state for all app windows. Cause: ' + JSON.stringify(err));
345});
346```
347
348## window.setWindowLayoutMode<sup>9+</sup>
349setWindowLayoutMode(mode: WindowLayoutMode, callback: AsyncCallback&lt;void&gt;): void
350
351Sets the window layout mode. This API uses an asynchronous callback to return the result.
352
353**System API**: This is a system API.
354
355**System capability**: SystemCapability.WindowManager.WindowManager.Core
356
357**Parameters**
358
359| Name  | Type                     | Mandatory| Description          |
360| -------- | ------------------------- | ---- | -------------- |
361| mode       | [WindowLayoutMode](#windowlayoutmode9)                  | Yes  | Window layout mode to set.|
362| callback | AsyncCallback&lt;void&gt; | Yes  | Callback used to return the result.    |
363
364**Error codes**
365
366For details about the error codes, see [Window Error Codes](errorcode-window.md).
367
368| ID| Error Message|
369| ------- | -------------------------------------------- |
370| 1300003 | This window manager service works abnormally. |
371
372**Example**
373
374```ts
375import { BusinessError } from '@ohos.base';
376
377try {
378  window.setWindowLayoutMode(window.WindowLayoutMode.WINDOW_LAYOUT_MODE_CASCADE, (err: BusinessError) => {
379    const errCode: number = err.code;
380    if (errCode) {
381      console.error('Failed to set window layout mode. Cause: ' + JSON.stringify(err));
382      return;
383    }
384    console.info('Succeeded in setting window layout mode.');
385  });
386} catch (exception) {
387  console.error('Failed to set window layout mode. Cause: ' + JSON.stringify(exception));
388}
389```
390
391## window.setWindowLayoutMode<sup>9+</sup>
392setWindowLayoutMode(mode: WindowLayoutMode): Promise&lt;void&gt;
393
394Sets the window layout mode. This API uses a promise to return the result.
395
396**System API**: This is a system API.
397
398**System capability**: SystemCapability.WindowManager.WindowManager.Core
399
400**Parameters**
401
402| Name  | Type                     | Mandatory| Description          |
403| -------- | ------------------------- | ---- | -------------- |
404| mode       | [WindowLayoutMode](#windowlayoutmode9)                    | Yes  | Window layout mode to set.|
405
406**Return value**
407
408| Type               | Description                     |
409| ------------------- | ------------------------- |
410| Promise&lt;void&gt; | Promise that returns no value.|
411
412**Error codes**
413
414For details about the error codes, see [Window Error Codes](errorcode-window.md).
415
416| ID| Error Message|
417| ------- | -------------------------------------------- |
418| 1300003 | This window manager service works abnormally. |
419
420**Example**
421
422```ts
423import { BusinessError } from '@ohos.base';
424
425try {
426  let promise = window.setWindowLayoutMode(window.WindowLayoutMode.WINDOW_LAYOUT_MODE_CASCADE);
427  promise.then(() => {
428    console.info('Succeeded in setting window layout mode.');
429  }).catch((err: BusinessError) => {
430    console.error('Failed to set window layout mode. Cause: ' + JSON.stringify(err));
431  });
432} catch (exception) {
433  console.error('Failed to set window layout mode. Cause: ' + JSON.stringify(exception));
434}
435```
436
437## window.on('systemBarTintChange')<sup>8+</sup>
438
439on(type: 'systemBarTintChange', callback: Callback&lt;SystemBarTintState&gt;): void
440
441Subscribes to the property change event of the status bar and navigation bar.
442
443**System API**: This is a system API.
444
445**System capability**: SystemCapability.WindowManager.WindowManager.Core
446
447**Parameters**
448
449| Name  | Type                                                      | Mandatory| Description                                                        |
450| -------- | ---------------------------------------------------------- | ---- | ------------------------------------------------------------ |
451| type     | string                                                     | Yes  | Event type. The value is fixed at **'systemBarTintChange'**, indicating the property change event of the status bar and navigation bar.|
452| callback | Callback&lt;[SystemBarTintState](#systembartintstate8)&gt; | Yes  | Callback used to return the properties of the status bar and navigation bar.                |
453
454**Example**
455
456```ts
457try {
458  window.on('systemBarTintChange', (data) => {
459    console.info('Succeeded in enabling the listener for systemBarTint changes. Data: ' + JSON.stringify(data));
460  });
461} catch (exception) {
462  console.error('Failed to enable the listener for systemBarTint changes. Cause: ' + JSON.stringify(exception));
463}
464```
465
466## window.off('systemBarTintChange')<sup>8+</sup>
467
468off(type: 'systemBarTintChange', callback?: Callback&lt;SystemBarTintState &gt;): void
469
470Unsubscribes from the property change event of the status bar and navigation bar.
471
472**System API**: This is a system API.
473
474**System capability**: SystemCapability.WindowManager.WindowManager.Core
475
476**Parameters**
477
478| Name  | Type                                                      | Mandatory| Description                                                        |
479| -------- | ---------------------------------------------------------- | ---- | ------------------------------------------------------------ |
480| type     | string                                                     | Yes  | Event type. The value is fixed at **'systemBarTintChange'**, indicating the property change event of the status bar and navigation bar.|
481| callback | Callback&lt;[SystemBarTintState](#systembartintstate8)&gt; | 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.               |
482
483**Example**
484
485```ts
486try {
487  window.off('systemBarTintChange');
488} catch (exception) {
489  console.error('Failed to disable the listener for systemBarTint changes. Cause: ' + JSON.stringify(exception));
490}
491```
492
493## window.on('gestureNavigationEnabledChange')<sup>10+</sup>
494
495on(type: 'gestureNavigationEnabledChange', callback: Callback&lt;boolean&gt;): void
496
497Subscribes to the gesture navigation status change event.
498
499**System API**: This is a system API.
500
501**System capability**: SystemCapability.WindowManager.WindowManager.Core
502
503**Parameters**
504
505| Name  | Type                    | Mandatory| Description                                                                         |
506| -------- | ----------------------- | ---- | ----------------------------------------------------------------------------- |
507| type     | string                  | Yes  | Event type. The value is fixed at **'gestureNavigationEnabledChange'**, indicating the gesture navigation status change event.   |
508| callback | Callback&lt;boolean&gt; | 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.|
509
510**Error codes**
511
512For details about the error codes, see [Window Error Codes](errorcode-window.md).
513
514| ID| Error Message|
515| ------- | -------------------------------------------- |
516| 1300002 | This window state is abnormal. |
517| 1300003 | This window manager service works abnormally. |
518
519**Example**
520
521```ts
522try {
523  window.on('gestureNavigationEnabledChange', (data) => {
524    console.info('Succeeded in enabling the listener for gesture navigation status changes. Data: ' + JSON.stringify(data));
525  });
526} catch (exception) {
527  console.error('Failed to enable the listener for gesture navigation status changes. Cause: ' + JSON.stringify(exception));
528}
529```
530
531## window.off('gestureNavigationEnabledChange')<sup>10+</sup>
532
533off(type: 'gestureNavigationEnabledChange', callback?: Callback&lt;boolean&gt;): void
534
535Unsubscribes from the gesture navigation status change event.
536
537**System API**: This is a system API.
538
539**System capability**: SystemCapability.WindowManager.WindowManager.Core
540
541**Parameters**
542
543| Name  | Type                    | Mandatory| Description                                                       |
544| -------- | ----------------------- | -- | ------------------------------------------------------------ |
545| type     | string                  | Yes| Event type. The value is fixed at **'gestureNavigationEnabledChange'**, indicating the gesture navigation status change event.|
546| callback | Callback&lt;boolean&gt; | 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.|
547
548**Error codes**
549
550For details about the error codes, see [Window Error Codes](errorcode-window.md).
551
552| ID| Error Message|
553| ------- | -------------------------------------------- |
554| 1300002 | This window state is abnormal. |
555| 1300003 | This window manager service works abnormally. |
556
557**Example**
558
559```ts
560try {
561  window.off('gestureNavigationEnabledChange');
562} catch (exception) {
563  console.error('Failed to disable the listener for gesture navigation status changes. Cause: ' + JSON.stringify(exception));
564}
565```
566
567## window.on('waterMarkFlagChange')<sup>10+</sup>
568
569on(type: 'waterMarkFlagChange', callback: Callback&lt;boolean&gt;): void
570
571Subscribes to the watermark status change event.
572
573**System API**: This is a system API.
574
575**System capability**: SystemCapability.WindowManager.WindowManager.Core
576
577**Parameters**
578
579| Name  | Type                    | Mandatory| Description                                                                         |
580| -------- | ----------------------- | ---- | ----------------------------------------------------------------------------- |
581| type     | string                  | Yes  | Event type. The value is fixed at **'waterMarkFlagChange'**, indicating the watermark status change event.   |
582| callback | Callback&lt;boolean&gt; | Yes  | Callback used to return the watermark status. The value **true** means that the watermark feature is enabled, and **false** means the opposite.|
583
584**Error codes**
585
586For details about the error codes, see [Window Error Codes](errorcode-window.md).
587
588| ID| Error Message|
589| ------- | -------------------------------------------- |
590| 1300003 | This window manager service works abnormally. |
591
592**Example**
593
594```ts
595try {
596  window.on('waterMarkFlagChange', (data) => {
597    console.info('Succeeded in enabling the listener for watermark flag changes. Data: ' + JSON.stringify(data));
598  });
599} catch (exception) {
600  console.error('Failed to enable the listener for watermark flag changes. Cause: ' + JSON.stringify(exception));
601}
602```
603
604## window.off('waterMarkFlagChange')<sup>10+</sup>
605
606off(type: 'waterMarkFlagChange', callback?: Callback&lt;boolean&gt;): void
607
608Unsubscribes from the watermark status change event.
609
610**System API**: This is a system API.
611
612**System capability**: SystemCapability.WindowManager.WindowManager.Core
613
614**Parameters**
615
616| Name  | Type                    | Mandatory| Description                                                       |
617| -------- | ----------------------- | -- | ------------------------------------------------------------ |
618| type     | string                  | Yes| Event type. The value is fixed at **'waterMarkFlagChange'**, indicating the watermark status change event.|
619| callback | Callback&lt;boolean&gt; | 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.|
620
621**Error codes**
622
623For details about the error codes, see [Window Error Codes](errorcode-window.md).
624
625| ID| Error Message|
626| ------- | -------------------------------------------- |
627| 1300003 | This window manager service works abnormally. |
628
629**Example**
630
631```ts
632try {
633  window.off('waterMarkFlagChange');
634} catch (exception) {
635  console.error('Failed to disable the listener for watermark flag changes. Cause: ' + JSON.stringify(exception));
636}
637```
638
639## window.setGestureNavigationEnabled<sup>10+</sup>
640setGestureNavigationEnabled(enable: boolean, callback: AsyncCallback&lt;void&gt;): void
641
642Enables or disables gesture navigation. This API uses an asynchronous callback to return the result.
643
644**System API**: This is a system API.
645
646**System capability**: SystemCapability.WindowManager.WindowManager.Core
647
648**Parameters**
649
650| Name  | Type                     | Mandatory| Description          |
651| -------- | ------------------------- | ---- | -------------- |
652| enable   | boolean                  | Yes  | Whether to enable gesture navigation. The value **true** means to enable gesture navigation, and **false** means the opposite.|
653| callback | AsyncCallback&lt;void&gt; | Yes  | Callback used to return the result.|
654
655**Error codes**
656
657For details about the error codes, see [Window Error Codes](errorcode-window.md).
658
659| ID| Error Message|
660| ------- | --------------------------------------------- |
661| 1300002 | This window state is abnormal.                |
662| 1300003 | This window manager service works abnormally. |
663
664**Example**
665
666```ts
667import { BusinessError } from '@ohos.base';
668
669try {
670  window.setGestureNavigationEnabled(true, (err: BusinessError) => {
671    const errCode: number = err.code;
672    if (errCode) {
673      console.error('Failed to set gesture navigation enabled. Cause: ' + JSON.stringify(err));
674      return;
675    }
676    console.info('Succeeded in setting gesture navigation enabled.');
677  });
678} catch (exception) {
679  console.error('Failed to set gesture navigation enabled. Cause: ' + JSON.stringify(exception));
680}
681```
682
683## window.setGestureNavigationEnabled<sup>10+</sup>
684setGestureNavigationEnabled(enable: boolean): Promise&lt;void&gt;
685
686Enables or disables gesture navigation. This API uses a promise to return the result.
687
688**System API**: This is a system API.
689
690**System capability**: SystemCapability.WindowManager.WindowManager.Core
691
692**Parameters**
693
694| Name| Type    | Mandatory | Description                |
695| ------ | ------- | ---- | -------------------- |
696| enable | boolean | Yes  | Whether to enable gesture navigation. The value **true** means to enable gesture navigation, and **false** means the opposite.|
697
698**Return value**
699
700| Type               | Description                     |
701| ------------------- | ------------------------- |
702| Promise&lt;void&gt; | Promise that returns no value.|
703
704**Error codes**
705
706For details about the error codes, see [Window Error Codes](errorcode-window.md).
707
708| ID| Error Message|
709| ------- | -------------------------------------------- |
710| 1300002 | This window state is abnormal.                |
711| 1300003 | This window manager service works abnormally. |
712
713**Example**
714
715```ts
716import { BusinessError } from '@ohos.base';
717
718try {
719  let promise = window.setGestureNavigationEnabled(true);
720  promise.then(() => {
721    console.info('Succeeded in setting gesture navigation enabled.');
722  }).catch((err: BusinessError) => {
723    console.error('Failed to set gesture navigation enabled. Cause: ' + JSON.stringify(err));
724  });
725} catch (exception) {
726  console.error('Failed to set gesture navigation enabled. Cause: ' + JSON.stringify(exception));
727}
728```
729
730## window.setWaterMarkImage<sup>10+</sup>
731setWaterMarkImage(pixelMap: image.PixelMap, enable: boolean, callback: AsyncCallback&lt;void&gt;): void
732
733Sets the watermark image display status. This API uses an asynchronous callback to return the result.
734
735**System API**: This is a system API.
736
737**System capability**: SystemCapability.WindowManager.WindowManager.Core
738
739**Parameters**
740
741| Name  | Type                     | Mandatory| Description          |
742| -------- | ------------------------- | ---- | -------------- |
743| pixelMap | [image.PixelMap](../apis-image-kit/js-apis-image.md#pixelmap7) | Yes| Watermark image.|
744| enable   | boolean                  | Yes  | Whether to display the watermark image. The value **true** means to display the watermark image, and **false** means the opposite.|
745| callback | AsyncCallback&lt;void&gt; | Yes  | Callback used to return the result.|
746
747**Error codes**
748
749For details about the error codes, see [Window Error Codes](errorcode-window.md).
750
751| ID| Error Message|
752| ------- | --------------------------------------------- |
753| 1300003 | This window manager service works abnormally. |
754
755**Example**
756
757```ts
758import image from '@ohos.multimedia.image';
759import { BusinessError } from '@ohos.base';
760
761let enable: boolean = true;
762let color: ArrayBuffer = new ArrayBuffer(0);
763let initializationOptions: image.InitializationOptions = {
764  size: {
765    height: 100,
766    width: 100
767  }
768};
769image.createPixelMap(color, initializationOptions).then((pixelMap: image.PixelMap) => {
770  console.info('Succeeded in creating pixelmap.');
771  try {
772    window.setWaterMarkImage(pixelMap, enable, (err: BusinessError) => {
773      const errCode: number = err.code;
774      if (errCode) {
775        console.error('Failed to show watermark image. Cause: ' + JSON.stringify(err));
776        return;
777      }
778      console.info('Succeeded in showing watermark image.');
779    });
780  } catch (exception) {
781    console.error('Failed to show watermark image. Cause: ' + JSON.stringify(exception));
782  }
783}).catch((err: BusinessError) => {
784  console.error('Failed to create PixelMap. Cause: ' + JSON.stringify(err));
785});
786```
787
788## window.setWaterMarkImage<sup>10+</sup>
789setWaterMarkImage(pixelMap: image.PixelMap, enable: boolean): Promise&lt;void&gt;
790
791Sets the watermark image display status. This API uses a promise to return the result.
792
793**System API**: This is a system API.
794
795**System capability**: SystemCapability.WindowManager.WindowManager.Core
796
797**Parameters**
798
799| Name| Type                       | Mandatory | Description                |
800| ------ | --------------------------- | ---- | -------------------- |
801| pixelMap | [image.PixelMap](../apis-image-kit/js-apis-image.md#pixelmap7) | Yes| Watermark image.|
802| enable   | boolean                  | Yes  | Whether to display the watermark image. The value **true** means to display the watermark image, and **false** means the opposite.|
803
804**Return value**
805
806| Type               | Description                     |
807| ------------------- | ------------------------- |
808| Promise&lt;void&gt; | Promise that returns no value.|
809
810**Error codes**
811
812For details about the error codes, see [Window Error Codes](errorcode-window.md).
813
814| ID| Error Message|
815| ------- | -------------------------------------------- |
816| 1300003 | This window manager service works abnormally. |
817
818**Example**
819
820```ts
821import image from '@ohos.multimedia.image';
822import { BusinessError } from '@ohos.base';
823
824let enable: boolean = true;
825let color: ArrayBuffer = new ArrayBuffer(0);
826let initializationOptions: image.InitializationOptions = {
827  size: {
828    height: 100,
829    width: 100
830  }
831};
832image.createPixelMap(color, initializationOptions).then((pixelMap: image.PixelMap) => {
833  console.info('Succeeded in creating pixelmap.');
834  try {
835    let promise = window.setWaterMarkImage(pixelMap, enable);
836    promise.then(() => {
837      console.info('Succeeded in showing watermark image.');
838    }).catch((err: BusinessError) => {
839      console.error('Failed to show watermark image. Cause: ' + JSON.stringify(err));
840    });
841  } catch (exception) {
842    console.error('Failed to show watermark image. Cause: ' + JSON.stringify(exception));
843  }
844}).catch((err: BusinessError) => {
845  console.error('Failed to create PixelMap. Cause: ' + JSON.stringify(err));
846});
847```
848
849## Window
850
851Represents the current window instance, which is the basic unit managed by the window manager.
852
853In 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.
854
855### hide<sup>7+</sup>
856
857hide (callback: AsyncCallback&lt;void&gt;): void
858
859Hides this window. This API uses an asynchronous callback to return the result.
860
861**System API**: This is a system API.
862
863**System capability**: SystemCapability.WindowManager.WindowManager.Core
864
865**Parameters**
866
867| Name  | Type                     | Mandatory| Description      |
868| -------- | ------------------------- | ---- | ---------- |
869| callback | AsyncCallback&lt;void&gt; | Yes  | Callback used to return the result.|
870
871**Error codes**
872
873For details about the error codes, see [Window Error Codes](errorcode-window.md).
874
875| ID| Error Message|
876| ------- | ------------------------------ |
877| 1300002 | This window state is abnormal. |
878
879**Example**
880
881```ts
882import { BusinessError } from '@ohos.base';
883
884windowClass.hide((err: BusinessError) => {
885  const errCode: number = err.code;
886  if (errCode) {
887    console.error('Failed to hide the window. Cause: ' + JSON.stringify(err));
888    return;
889  }
890  console.info('Succeeded in hiding the window.');
891});
892```
893
894### hide<sup>7+</sup>
895
896hide(): Promise&lt;void&gt;
897
898Hides this window. This API uses a promise to return the result.
899
900**System API**: This is a system API.
901
902**System capability**: SystemCapability.WindowManager.WindowManager.Core
903
904**Return value**
905
906| Type               | Description                     |
907| ------------------- | ------------------------- |
908| Promise&lt;void&gt; | Promise that returns no value.|
909
910**Error codes**
911
912For details about the error codes, see [Window Error Codes](errorcode-window.md).
913
914| ID| Error Message|
915| ------- | ------------------------------ |
916| 1300002 | This window state is abnormal. |
917
918**Example**
919
920```ts
921import { BusinessError } from '@ohos.base';
922
923let promise = windowClass.hide();
924promise.then(() => {
925  console.info('Succeeded in hiding the window.');
926}).catch((err: BusinessError) => {
927  console.error('Failed to hide the window. Cause: ' + JSON.stringify(err));
928});
929```
930
931### hideWithAnimation<sup>9+</sup>
932
933hideWithAnimation(callback: AsyncCallback&lt;void&gt;): void
934
935Hides this window and plays an animation during the process. This API uses an asynchronous callback to return the result.
936
937**System API**: This is a system API.
938
939**System capability**: SystemCapability.WindowManager.WindowManager.Core
940
941**Parameters**
942
943| Name  | Type                     | Mandatory| Description      |
944| -------- | ------------------------- | ---- | ---------- |
945| callback | AsyncCallback&lt;void&gt; | Yes  | Callback used to return the result.|
946
947**Error codes**
948
949For details about the error codes, see [Window Error Codes](errorcode-window.md).
950
951| ID| Error Message|
952| ------- | -------------------------------------------- |
953| 1300002 | This window state is abnormal.               |
954| 1300003 | This window manager service works abnormally. |
955| 1300004 | Unauthorized operation.                |
956
957**Example**
958
959```ts
960import { BusinessError } from '@ohos.base';
961
962windowClass.hideWithAnimation((err: BusinessError) => {
963  const errCode: number = err.code;
964  if (errCode) {
965    console.error('Failed to hide the window with animation. Cause: ' + JSON.stringify(err));
966    return;
967  }
968  console.info('Succeeded in hiding the window with animation.');
969});
970```
971
972### hideWithAnimation<sup>9+</sup>
973
974hideWithAnimation(): Promise&lt;void&gt;
975
976Hides this window and plays an animation during the process. This API uses a promise to return the result.
977
978**System API**: This is a system API.
979
980**System capability**: SystemCapability.WindowManager.WindowManager.Core
981
982**Return value**
983
984| Type               | Description                     |
985| ------------------- | ------------------------- |
986| Promise&lt;void&gt; | Promise that returns no value.|
987
988**Error codes**
989
990For details about the error codes, see [Window Error Codes](errorcode-window.md).
991
992| ID| Error Message|
993| ------- | -------------------------------------------- |
994| 1300002 | This window state is abnormal.               |
995| 1300003 | This window manager service works abnormally. |
996| 1300004 | Unauthorized operation.                |
997
998**Example**
999
1000```ts
1001import { BusinessError } from '@ohos.base';
1002
1003let promise = windowClass.hideWithAnimation();
1004promise.then(() => {
1005  console.info('Succeeded in hiding the window with animation.');
1006}).catch((err: BusinessError) => {
1007  console.error('Failed to hide the window with animation. Cause: ' + JSON.stringify(err));
1008});
1009```
1010
1011
1012### showWithAnimation<sup>9+</sup>
1013
1014showWithAnimation(callback: AsyncCallback&lt;void&gt;): void
1015
1016Shows this window and plays an animation during the process. This API uses an asynchronous callback to return the result.
1017
1018**System API**: This is a system API.
1019
1020**System capability**: SystemCapability.WindowManager.WindowManager.Core
1021
1022**Parameters**
1023
1024| Name  | Type                     | Mandatory| Description      |
1025| -------- | ------------------------- | ---- | ---------- |
1026| callback | AsyncCallback&lt;void&gt; | Yes  | Callback used to return the result.|
1027
1028**Error codes**
1029
1030For details about the error codes, see [Window Error Codes](errorcode-window.md).
1031
1032| ID| Error Message|
1033| ------- | -------------------------------------------- |
1034| 1300002 | This window state is abnormal.               |
1035| 1300003 | This window manager service works abnormally. |
1036| 1300004 | Unauthorized operation.                |
1037
1038**Example**
1039
1040```ts
1041import { BusinessError } from '@ohos.base';
1042
1043windowClass.showWithAnimation((err: BusinessError) => {
1044  const errCode: number = err.code;
1045  if (errCode) {
1046    console.error('Failed to show the window with animation. Cause: ' + JSON.stringify(err));
1047    return;
1048  }
1049  console.info('Succeeded in showing the window with animation.');
1050});
1051```
1052
1053### showWithAnimation<sup>9+</sup>
1054
1055showWithAnimation(): Promise&lt;void&gt;
1056
1057Shows this window and plays an animation during the process. This API uses a promise to return the result.
1058
1059**System API**: This is a system API.
1060
1061**System capability**: SystemCapability.WindowManager.WindowManager.Core
1062
1063**Return value**
1064
1065| Type               | Description                     |
1066| ------------------- | ------------------------- |
1067| Promise&lt;void&gt; | Promise that returns no value.|
1068
1069**Error codes**
1070
1071For details about the error codes, see [Window Error Codes](errorcode-window.md).
1072
1073| ID| Error Message|
1074| ------- | -------------------------------------------- |
1075| 1300002 | This window state is abnormal.               |
1076| 1300003 | This window manager service works abnormally. |
1077| 1300004 | Unauthorized operation.                |
1078
1079**Example**
1080
1081```ts
1082import { BusinessError } from '@ohos.base';
1083
1084let promise = windowClass.showWithAnimation();
1085promise.then(() => {
1086  console.info('Succeeded in showing the window with animation.');
1087}).catch((err: BusinessError) => {
1088  console.error('Failed to show the window with animation. Cause: ' + JSON.stringify(err));
1089});
1090```
1091
1092### setWindowMode<sup>9+</sup>
1093
1094setWindowMode(mode: WindowMode, callback: AsyncCallback&lt;void&gt;): void
1095
1096Sets the mode of this window. This API uses an asynchronous callback to return the result.
1097
1098**System API**: This is a system API.
1099
1100**System capability**: SystemCapability.WindowManager.WindowManager.Core
1101
1102**Parameters**
1103
1104| Name| Type| Mandatory| Description|
1105| -------- | -------------------------- | -- | --------- |
1106| mode     | [WindowMode](#windowmode7) | Yes| Window mode to set.|
1107| callback | AsyncCallback&lt;void&gt;  | Yes| Callback used to return the result.|
1108
1109**Error codes**
1110
1111For details about the error codes, see [Window Error Codes](errorcode-window.md).
1112
1113| ID| Error Message|
1114| ------- | -------------------------------------------- |
1115| 1300002 | This window state is abnormal.               |
1116| 1300003 | This window manager service works abnormally. |
1117
1118**Example**
1119
1120```ts
1121import { BusinessError } from '@ohos.base';
1122
1123let mode = window.WindowMode.FULLSCREEN;
1124try {
1125  windowClass.setWindowMode(mode, (err: BusinessError) => {
1126    const errCode: number = err.code;
1127    if (errCode) {
1128      console.error('Failed to set the window mode. Cause: ' + JSON.stringify(err));
1129      return;
1130    }
1131    console.info('Succeeded in setting the window mode.');
1132  });
1133} catch (exception) {
1134  console.error('Failed to set the window mode. Cause: ' + JSON.stringify(exception));
1135}
1136```
1137
1138### setWindowMode<sup>9+</sup>
1139
1140setWindowMode(mode: WindowMode): Promise&lt;void&gt;
1141
1142Sets the type of this window. This API uses a promise to return the result.
1143
1144**System API**: This is a system API.
1145
1146**System capability**: SystemCapability.WindowManager.WindowManager.Core
1147
1148**Parameters**
1149
1150| Name| Type| Mandatory| Description|
1151| -------- | -------------------------- | -- | --------- |
1152| mode     | [WindowMode](#windowmode7) | Yes| Window mode to set.|
1153
1154**Return value**
1155
1156| Type| Description|
1157| ------------------- | ----------------------- |
1158| Promise&lt;void&gt; | Promise that returns no value.|
1159
1160**Error codes**
1161
1162For details about the error codes, see [Window Error Codes](errorcode-window.md).
1163
1164| ID| Error Message|
1165| ------- | -------------------------------------------- |
1166| 1300002 | This window state is abnormal.               |
1167| 1300003 | This window manager service works abnormally. |
1168
1169**Example**
1170
1171```ts
1172import { BusinessError } from '@ohos.base';
1173
1174let mode = window.WindowMode.FULLSCREEN;
1175try {
1176  let promise = windowClass.setWindowMode(mode);
1177  promise.then(() => {
1178    console.info('Succeeded in setting the window mode.');
1179  }).catch((err: BusinessError) => {
1180    console.error('Failed to set the window mode. Cause: ' + JSON.stringify(err));
1181  });
1182} catch (exception) {
1183  console.error('Failed to set the window mode. Cause: ' + JSON.stringify(exception));
1184}
1185```
1186
1187### bindDialogTarget<sup>9+</sup>
1188
1189bindDialogTarget(token: rpc.RemoteObject, deathCallback: Callback&lt;void&gt;, callback: AsyncCallback&lt;void&gt;): void
1190
1191Binds 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.
1192
1193**System API**: This is a system API.
1194
1195**System capability**: SystemCapability.WindowManager.WindowManager.Core
1196
1197**Parameters**
1198
1199| Name      | Type                     | Mandatory| Description                 |
1200| ----------- | ------------------------- | ---- | -------------------- |
1201| token       | [rpc.RemoteObject](../apis-ipc-kit/js-apis-rpc.md#remoteobject) | Yes  | Token of the target window.|
1202| deathCallback | Callback&lt;void&gt;        | Yes  | Callback used to listen for modal window destruction events.|
1203| callback    | AsyncCallback&lt;void&gt; | Yes  | Callback used to return the result.|
1204
1205**Error codes**
1206
1207For details about the error codes, see [Window Error Codes](errorcode-window.md).
1208
1209| ID| Error Message|
1210| ------- | -------------------------------------------- |
1211| 1300002 | This window state is abnormal.               |
1212| 1300003 | This window manager service works abnormally. |
1213
1214**Example**
1215
1216```ts
1217import rpc from '@ohos.rpc';
1218import { BusinessError } from '@ohos.base';
1219
1220class MyDeathRecipient {
1221  onRemoteDied() {
1222    console.log('server died');
1223  }
1224}
1225
1226class TestRemoteObject extends rpc.RemoteObject {
1227  constructor(descriptor: string) {
1228    super(descriptor);
1229  }
1230
1231  addDeathRecipient(recipient: MyDeathRecipient, flags: number): boolean {
1232    return true;
1233  }
1234
1235  removeDeathRecipient(recipient: MyDeathRecipient, flags: number): boolean {
1236    return true;
1237  }
1238
1239  isObjectDead(): boolean {
1240    return false;
1241  }
1242}
1243
1244let token: TestRemoteObject = new TestRemoteObject('testObject');
1245let windowClass: window.Window | undefined = undefined;
1246let config: window.Configuration = { name: "test", windowType: window.WindowType.TYPE_DIALOG, ctx: this.context };
1247try {
1248  window.createWindow(config, (err: BusinessError, data) => {
1249    let errCode: number = err.code;
1250    if (errCode) {
1251      console.error('Failed to create the window. Cause: ' + JSON.stringify(err));
1252      return;
1253    }
1254    windowClass = data;
1255  });
1256  windowClass.bindDialogTarget(token, () => {
1257    console.info('Dialog Window Need Destroy.');
1258  }, (err: BusinessError) => {
1259    let errCode: number = err.code;
1260    if (errCode) {
1261      console.error('Failed to bind dialog target. Cause:' + JSON.stringify(err));
1262      return;
1263    }
1264    console.info('Succeeded in binding dialog target.');
1265  });
1266} catch (exception) {
1267  console.error('Failed to bind dialog target. Cause:' + JSON.stringify(exception));
1268}
1269```
1270
1271### bindDialogTarget<sup>9+</sup>
1272
1273bindDialogTarget(token: rpc.RemoteObject, deathCallback: Callback&lt;void&gt;): Promise&lt;void&gt;
1274
1275Binds 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.
1276
1277**System API**: This is a system API.
1278
1279**System capability**: SystemCapability.WindowManager.WindowManager.Core
1280
1281**Parameters**
1282
1283| Name      | Type                     | Mandatory| Description                 |
1284| ----------- | ------------------------- | ---- | -------------------- |
1285| token       | [rpc.RemoteObject](../apis-ipc-kit/js-apis-rpc.md#remoteobject) | Yes  | Token of the target window.|
1286| deathCallback | Callback&lt;void&gt;        | Yes  | Callback used to listen for modal window destruction events.|
1287
1288**Return value**
1289
1290| Type               | Description                     |
1291| ------------------- | ------------------------- |
1292| Promise&lt;void&gt; | Promise that returns no value.|
1293
1294**Error codes**
1295
1296For details about the error codes, see [Window Error Codes](errorcode-window.md).
1297
1298| ID| Error Message|
1299| ------- | -------------------------------------------- |
1300| 1300002 | This window state is abnormal.               |
1301| 1300003 | This window manager service works abnormally. |
1302
1303**Example**
1304
1305```ts
1306import rpc from '@ohos.rpc';
1307import { BusinessError } from '@ohos.base';
1308
1309class MyDeathRecipient {
1310  onRemoteDied() {
1311    console.log('server died');
1312  }
1313}
1314
1315class TestRemoteObject extends rpc.RemoteObject {
1316  constructor(descriptor: string) {
1317    super(descriptor);
1318  }
1319
1320  addDeathRecipient(recipient: MyDeathRecipient, flags: number): boolean {
1321    return true;
1322  }
1323
1324  removeDeathRecipient(recipient: MyDeathRecipient, flags: number): boolean {
1325    return true;
1326  }
1327
1328  isObjectDead(): boolean {
1329    return false;
1330  }
1331}
1332
1333let token: TestRemoteObject = new TestRemoteObject('testObject');
1334let windowClass: window.Window | undefined = undefined;
1335let config: window.Configuration = {
1336  name: "test",
1337  windowType: window.WindowType.TYPE_DIALOG,
1338  ctx: this.context
1339};
1340try {
1341  window.createWindow(config, (err: BusinessError, data) => {
1342    const errCode: number = err.code;
1343    if (errCode) {
1344      console.error('Failed to create the window. Cause: ' + JSON.stringify(err));
1345      return;
1346    }
1347    windowClass = data;
1348  });
1349  let promise = windowClass.bindDialogTarget(token, () => {
1350    console.info('Dialog Window Need Destroy.');
1351  });
1352  promise.then(() => {
1353    console.info('Succeeded in binding dialog target.');
1354  }).catch((err: BusinessError) => {
1355    console.error('Failed to bind dialog target. Cause:' + JSON.stringify(err));
1356  });
1357} catch (exception) {
1358  console.error('Failed to bind dialog target. Cause:' + JSON.stringify(exception));
1359}
1360```
1361
1362### bindDialogTarget<sup>9+</sup>
1363
1364bindDialogTarget(requestInfo: dialogRequest.RequestInfo, deathCallback: Callback&lt;void&gt;, callback: AsyncCallback&lt;void&gt;): void
1365
1366Binds 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.
1367
1368**System API**: This is a system API.
1369
1370**System capability**: SystemCapability.WindowManager.WindowManager.Core
1371
1372**Parameters**
1373
1374| Name      | Type                     | Mandatory| Description                 |
1375| ----------- | ------------------------- | ---- | -------------------- |
1376| requestInfo | [dialogRequest.RequestInfo](../apis-ability-kit/js-apis-app-ability-dialogRequest.md#requestinfo) | Yes  | **RequestInfo** of the target window.|
1377| deathCallback | Callback&lt;void&gt;    | Yes  | Callback used to listen for modal window destruction events.|
1378| callback    | AsyncCallback&lt;void&gt; | Yes  | Callback used to return the result.|
1379
1380**Error codes**
1381
1382For details about the error codes, see [Window Error Codes](errorcode-window.md).
1383
1384| ID| Error Message|
1385| ------- | -------------------------------------------- |
1386| 1300002 | This window state is abnormal.               |
1387| 1300003 | This window manager service works abnormally. |
1388
1389**Example**
1390
1391```ts
1392import ServiceExtensionAbility from '@ohos.app.ability.ServiceExtensionAbility';
1393import dialogRequest from '@ohos.app.ability.dialogRequest';
1394import Want from '@ohos.app.ability.Want';
1395import { BusinessError } from '@ohos.base';
1396
1397export default class ServiceExtAbility extends ServiceExtensionAbility {
1398  onRequest(want: Want, startId: number) {
1399    console.info('onRequest');
1400    let windowClass: window.Window | undefined = undefined;
1401    let config: window.Configuration = {
1402      name: "test", windowType: window.WindowType.TYPE_DIALOG, ctx: this.context
1403    };
1404    try {
1405      window.createWindow(config, (err: BusinessError, data) => {
1406        let errCode: number = err.code;
1407        if (errCode) {
1408          console.error('Failed to create the window. Cause: ' + JSON.stringify(err));
1409          return;
1410        }
1411        windowClass = data;
1412      });
1413      let requestInfo = dialogRequest.getRequestInfo(want)
1414      windowClass.bindDialogTarget(requestInfo, () => {
1415        console.info('Dialog Window Need Destroy.');
1416      }, (err: BusinessError) => {
1417        let errCode: number = err.code;
1418        if (errCode) {
1419          console.error('Failed to bind dialog target. Cause:' + JSON.stringify(err));
1420          return;
1421        }
1422        console.info('Succeeded in binding dialog target.');
1423      });
1424    } catch (err) {
1425      console.error('Failed to bind dialog target. Cause:' + JSON.stringify(err))
1426    }
1427  }
1428}
1429```
1430
1431### bindDialogTarget<sup>9+</sup>
1432
1433bindDialogTarget(requestInfo: dialogRequest.RequestInfo, deathCallback: Callback&lt;void&gt;): Promise&lt;void&gt;
1434
1435Binds 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.
1436
1437**System API**: This is a system API.
1438
1439**System capability**: SystemCapability.WindowManager.WindowManager.Core
1440
1441**Parameters**
1442
1443| Name      | Type                     | Mandatory| Description                 |
1444| ----------- | ------------------------- | ---- | -------------------- |
1445| requestInfo | [dialogRequest.RequestInfo](../apis-ability-kit/js-apis-app-ability-dialogRequest.md#requestinfo) | Yes  | **RequestInfo** of the target window.|
1446| deathCallback | Callback&lt;void&gt;    | Yes  | Callback used to listen for modal window destruction events.|
1447
1448**Return value**
1449
1450| Type               | Description                     |
1451| ------------------- | ------------------------- |
1452| Promise&lt;void&gt; | Promise that returns no value.|
1453
1454**Error codes**
1455
1456For details about the error codes, see [Window Error Codes](errorcode-window.md).
1457
1458| ID| Error Message|
1459| ------- | -------------------------------------------- |
1460| 1300002 | This window state is abnormal.               |
1461| 1300003 | This window manager service works abnormally. |
1462
1463**Example**
1464
1465```ts
1466import ServiceExtensionAbility from '@ohos.app.ability.ServiceExtensionAbility';
1467import dialogRequest from '@ohos.app.ability.dialogRequest';
1468import Want from '@ohos.app.ability.Want';
1469import { BusinessError } from '@ohos.base';
1470
1471export default class ServiceExtAbility extends ServiceExtensionAbility {
1472  onRequest(want: Want, startId: number) {
1473    console.info('onRequest');
1474    let windowClass: window.Window | undefined = undefined;
1475    let config: window.Configuration = {
1476      name: "test", windowType: window.WindowType.TYPE_DIALOG, ctx: this.context
1477    };
1478    try {
1479      window.createWindow(config, (err: BusinessError, data) => {
1480        const errCode: number = err.code;
1481        if (errCode) {
1482          console.error('Failed to create the window. Cause: ' + JSON.stringify(err));
1483          return;
1484        }
1485        windowClass = data;
1486      });
1487      let requestInfo = dialogRequest.getRequestInfo(want)
1488      let promise = windowClass.bindDialogTarget(requestInfo, () => {
1489        console.info('Dialog Window Need Destroy.');
1490      });
1491      promise.then(() => {
1492        console.info('Succeeded in binding dialog target.');
1493      }).catch((err: BusinessError) => {
1494        console.error('Failed to bind dialog target. Cause:' + JSON.stringify(err));
1495      });
1496    } catch (err) {
1497      console.error('Failed to bind dialog target. Cause:' + JSON.stringify(err))
1498    }
1499  }
1500}
1501```
1502
1503### setWakeUpScreen()<sup>9+</sup>
1504
1505setWakeUpScreen(wakeUp: boolean): void
1506
1507Wakes up the screen.
1508
1509**System API**: This is a system API.
1510
1511**System capability**: SystemCapability.WindowManager.WindowManager.Core
1512
1513**Parameters**
1514
1515| Name          | Type   | Mandatory| Description                        |
1516| ---------------- | ------- | ---- | ---------------------------- |
1517| wakeUp           | boolean | Yes  | Whether to wake up the screen. The value **true** means to wake up the screen, and **false** means the opposite. |
1518
1519**Error codes**
1520
1521For details about the error codes, see [Window Error Codes](errorcode-window.md).
1522
1523| ID| Error Message|
1524| ------- | -------------------------------------------- |
1525| 1300002 | This window state is abnormal.               |
1526| 1300003 | This window manager service works abnormally. |
1527
1528**Example**
1529
1530```ts
1531let wakeUp: boolean = true;
1532try {
1533  windowClass.setWakeUpScreen(wakeUp);
1534} catch (exception) {
1535  console.error('Failed to wake up the screen. Cause: ' + JSON.stringify(exception));
1536}
1537```
1538
1539### setSnapshotSkip<sup>9+</sup>
1540setSnapshotSkip(isSkip: boolean): void
1541
1542Sets whether to ignore this window during screen capturing or recording. This API is generally used in scenarios where screen capture or recording is disabled.
1543
1544**System API**: This is a system API.
1545
1546**System capability**: SystemCapability.WindowManager.WindowManager.Core
1547
1548**Parameters**
1549
1550| Name       | Type   | Mandatory| Description                |
1551| ------------- | ------- | ---- | -------------------- |
1552| 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>|
1553
1554**Error codes**
1555
1556For details about the error codes, see [Window Error Codes](errorcode-window.md).
1557
1558| ID| Error Message|
1559| ------- | ------------------------------ |
1560| 1300002 | This window state is abnormal. |
1561
1562```ts
1563let isSkip: boolean = true;
1564try {
1565  windowClass.setSnapshotSkip(isSkip);
1566} catch (exception) {
1567  console.error('Failed to Skip. Cause: ' + JSON.stringify(exception));
1568}
1569```
1570
1571### setForbidSplitMove<sup>9+</sup>
1572
1573setForbidSplitMove(isForbidSplitMove: boolean, callback: AsyncCallback&lt;void&gt;): void
1574
1575Sets whether this window is forbidden to move in split-screen mode. This API uses an asynchronous callback to return the result.
1576
1577**System API**: This is a system API.
1578
1579**System capability**: SystemCapability.WindowManager.WindowManager.Core
1580
1581**Parameters**
1582
1583| Name     | Type                     | Mandatory| Description                |
1584| ----------- | ------------------------- | ---- | -------------------- |
1585| 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.|
1586| callback    | AsyncCallback&lt;void&gt; | Yes  | Callback used to return the result.          |
1587
1588**Error codes**
1589
1590For details about the error codes, see [Window Error Codes](errorcode-window.md).
1591
1592| ID| Error Message|
1593| ------- | -------------------------------------------- |
1594| 1300002 | This window state is abnormal.               |
1595| 1300003 | This window manager service works abnormally. |
1596
1597**Example**
1598
1599```ts
1600import { BusinessError } from '@ohos.base';
1601
1602let isForbidSplitMove: boolean = true;
1603try {
1604  windowClass.setForbidSplitMove(isForbidSplitMove, (err: BusinessError) => {
1605    const errCode: number = err.code;
1606    if (errCode) {
1607      console.error('Failed to forbid window moving in split screen mode. Cause:' + JSON.stringify(err));
1608      return;
1609    }
1610    console.info('Succeeded in forbidding window moving in split screen mode.');
1611  });
1612} catch (exception) {
1613  console.error('Failed to forbid window moving in split screen mode. Cause:' + JSON.stringify(exception));
1614}
1615```
1616
1617### setForbidSplitMove<sup>9+</sup>
1618
1619setForbidSplitMove(isForbidSplitMove: boolean): Promise&lt;void&gt;
1620
1621Sets whether this window is forbidden to move in split-screen mode. This API uses a promise to return the result.
1622
1623**System API**: This is a system API.
1624
1625**System capability**: SystemCapability.WindowManager.WindowManager.Core
1626
1627**Parameters**
1628
1629| Name     | Type   | Mandatory| Description                |
1630| ----------- | ------- | ---- | -------------------- |
1631| 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.|
1632
1633**Return value**
1634
1635| Type               | Description                     |
1636| ------------------- | ------------------------- |
1637| Promise&lt;void&gt; | Promise that returns no value.|
1638
1639**Error codes**
1640
1641For details about the error codes, see [Window Error Codes](errorcode-window.md).
1642
1643| ID| Error Message|
1644| ------- | -------------------------------------------- |
1645| 1300002 | This window state is abnormal.               |
1646| 1300003 | This window manager service works abnormally. |
1647
1648**Example**
1649
1650```ts
1651import { BusinessError } from '@ohos.base';
1652
1653let isForbidSplitMove: boolean = true;
1654try {
1655  let promise = windowClass.setForbidSplitMove(isForbidSplitMove);
1656  promise.then(() => {
1657    console.info('Succeeded in forbidding window moving in split screen mode.');
1658  }).catch((err: BusinessError) => {
1659    console.error('Failed to forbid window moving in split screen mode. Cause: ' + JSON.stringify(err));
1660  });
1661} catch (exception) {
1662  console.error('Failed to forbid window moving in split screen mode. Cause:' + JSON.stringify(exception));
1663}
1664```
1665
1666### opacity<sup>9+</sup>
1667
1668opacity(opacity: number): void
1669
1670Sets 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).
1671
1672**System API**: This is a system API.
1673
1674**System capability**: SystemCapability.WindowManager.WindowManager.Core
1675
1676**Parameters**
1677
1678| Name | Type  | Mandatory| Description                                                |
1679| ------- | ------ | ---- |----------------------------------------------------|
1680| 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.|
1681
1682**Error codes**
1683
1684For details about the error codes, see [Window Error Codes](errorcode-window.md).
1685
1686| ID| Error Message|
1687| ------- | ------------------------------ |
1688| 1300002 | This window state is abnormal. |
1689| 1300004 | Unauthorized operation.  |
1690
1691**Example**
1692
1693```ts
1694try {
1695  windowClass.opacity(0.5);
1696} catch (exception) {
1697  console.error('Failed to opacity. Cause: ' + JSON.stringify(exception));
1698}
1699```
1700
1701### scale<sup>9+</sup>
1702
1703scale(scaleOptions: ScaleOptions): void
1704
1705Sets 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).
1706
1707**System API**: This is a system API.
1708
1709**System capability**: SystemCapability.WindowManager.WindowManager.Core
1710
1711**Parameters**
1712
1713| Name      | Type                          | Mandatory| Description      |
1714| ------------ | ------------------------------ | ---- | ---------- |
1715| scaleOptions | [ScaleOptions](#scaleoptions9) | Yes  | Scale parameters to set.|
1716
1717**Error codes**
1718
1719For details about the error codes, see [Window Error Codes](errorcode-window.md).
1720
1721| ID| Error Message|
1722| ------- | ------------------------------ |
1723| 1300002 | This window state is abnormal. |
1724| 1300004 | Unauthorized operation.  |
1725
1726**Example**
1727
1728```ts
1729let obj: window.ScaleOptions = {
1730  x: 2.0,
1731  y: 1.0,
1732  pivotX: 0.5,
1733  pivotY: 0.5
1734};
1735try {
1736  windowClass.scale(obj);
1737} catch (exception) {
1738  console.error('Failed to scale. Cause: ' + JSON.stringify(exception));
1739}
1740```
1741
1742### rotate<sup>9+</sup>
1743
1744rotate(rotateOptions: RotateOptions): void
1745
1746Sets 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).
1747
1748**System API**: This is a system API.
1749
1750**System capability**: SystemCapability.WindowManager.WindowManager.Core
1751
1752**Parameters**
1753
1754| Name       | Type                            | Mandatory| Description      |
1755| ------------- | -------------------------------- | ---- | ---------- |
1756| rotateOptions | [RotateOptions](#rotateoptions9) | Yes  | Rotation parameters to set.|
1757
1758**Error codes**
1759
1760For details about the error codes, see [Window Error Codes](errorcode-window.md).
1761
1762| ID| Error Message|
1763| ------- | ------------------------------ |
1764| 1300002 | This window state is abnormal. |
1765| 1300004 | Unauthorized operation.  |
1766
1767**Example**
1768
1769```ts
1770let obj: window.RotateOptions = {
1771  x: 1.0,
1772  y: 1.0,
1773  z: 45.0,
1774  pivotX: 0.5,
1775  pivotY: 0.5
1776};
1777try {
1778  windowClass.rotate(obj);
1779} catch (exception) {
1780  console.error('Failed to rotate. Cause: ' + JSON.stringify(exception));
1781}
1782```
1783
1784### translate<sup>9+</sup>
1785
1786translate(translateOptions: TranslateOptions): void
1787
1788Sets 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).
1789
1790**System API**: This is a system API.
1791
1792**System capability**: SystemCapability.WindowManager.WindowManager.Core
1793
1794**Parameters**
1795
1796| Name          | Type                                  | Mandatory| Description                |
1797| ---------------- | -------------------------------------- | ---- | -------------------- |
1798| translateOptions | [TranslateOptions](#translateoptions9) | Yes  | Translation parameters. The unit is px.|
1799
1800**Error codes**
1801
1802For details about the error codes, see [Window Error Codes](errorcode-window.md).
1803
1804| ID| Error Message|
1805| ------- | ------------------------------ |
1806| 1300002 | This window state is abnormal. |
1807| 1300004 | Unauthorized operation.  |
1808
1809**Example**
1810
1811```ts
1812let obj: window.TranslateOptions = {
1813  x: 100.0,
1814  y: 0.0,
1815  z: 0.0
1816};
1817try {
1818  windowClass.translate(obj);
1819} catch (exception) {
1820  console.error('Failed to translate. Cause: ' + JSON.stringify(exception));
1821}
1822```
1823
1824###  getTransitionController<sup>9+</sup>
1825
1826 getTransitionController(): TransitionController
1827
1828Obtains the transition animation controller.
1829
1830**System API**: This is a system API.
1831
1832**System capability**: SystemCapability.WindowManager.WindowManager.Core
1833
1834**Return value**
1835
1836| Type                                          | Description            |
1837| ---------------------------------------------- | ---------------- |
1838| [TransitionController](#transitioncontroller9) | Transition animation controller.|
1839
1840**Error codes**
1841
1842For details about the error codes, see [Window Error Codes](errorcode-window.md).
1843
1844| ID| Error Message|
1845| ------- | ------------------------------ |
1846| 1300002 | This window state is abnormal. |
1847| 1300004 | Unauthorized operation.  |
1848
1849**Example**
1850
1851```ts
1852let controller = windowClass.getTransitionController(); // Obtain the transition animation controller.
1853```
1854
1855### setBlur<sup>9+</sup>
1856
1857setBlur(radius: number): void
1858
1859Blurs this window.
1860
1861**System API**: This is a system API.
1862
1863**System capability**: SystemCapability.WindowManager.WindowManager.Core
1864
1865**Parameters**
1866
1867| Name| Type  | Mandatory| Description                                              |
1868| ------ | ------ | ---- |--------------------------------------------------|
1869| 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.|
1870
1871**Error codes**
1872
1873For details about the error codes, see [Window Error Codes](errorcode-window.md).
1874
1875| ID| Error Message|
1876| ------- | ------------------------------ |
1877| 1300002 | This window state is abnormal. |
1878| 1300004 | Unauthorized operation.  |
1879
1880**Example**
1881
1882```ts
1883try {
1884  windowClass.setBlur(4.0);
1885} catch (exception) {
1886  console.error('Failed to set blur. Cause: ' + JSON.stringify(exception));
1887}
1888```
1889
1890### setBackdropBlur<sup>9+</sup>
1891
1892setBackdropBlur(radius: number): void
1893
1894Blurs the background of this window.
1895
1896**System API**: This is a system API.
1897
1898**System capability**: SystemCapability.WindowManager.WindowManager.Core
1899
1900**Parameters**
1901
1902| Name| Type  | Mandatory| Description                                                   |
1903| ------ | ------ | ---- |-------------------------------------------------------|
1904| 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.|
1905
1906**Error codes**
1907
1908For details about the error codes, see [Window Error Codes](errorcode-window.md).
1909
1910| ID| Error Message|
1911| ------- | ------------------------------ |
1912| 1300002 | This window state is abnormal. |
1913| 1300004 | Unauthorized operation.  |
1914
1915**Example**
1916
1917```ts
1918try {
1919  windowClass.setBackdropBlur(4.0);
1920} catch (exception) {
1921  console.error('Failed to set backdrop blur. Cause: ' + JSON.stringify(exception));
1922}
1923```
1924
1925### setBackdropBlurStyle<sup>9+</sup>
1926
1927setBackdropBlurStyle(blurStyle: BlurStyle): void
1928
1929Sets the blur style for the background of this window.
1930
1931**System API**: This is a system API.
1932
1933**System capability**: SystemCapability.WindowManager.WindowManager.Core
1934
1935**Parameters**
1936
1937| Name   | Type     | Mandatory| Description                  |
1938| --------- | --------- | ---- | ---------------------- |
1939| blurStyle | [BlurStyle](#blurstyle9) | Yes  | Blur style to set for the background of the window.|
1940
1941**Error codes**
1942
1943For details about the error codes, see [Window Error Codes](errorcode-window.md).
1944
1945| ID| Error Message|
1946| ------- | ------------------------------ |
1947| 1300002 | This window state is abnormal. |
1948| 1300004 | Unauthorized operation.  |
1949
1950**Example**
1951
1952```ts
1953try {
1954  windowClass.setBackdropBlurStyle(window.BlurStyle.THIN);
1955} catch (exception) {
1956  console.error('Failed to set backdrop blur style. Cause: ' + JSON.stringify(exception));
1957}
1958```
1959
1960### setShadow<sup>9+</sup>
1961
1962setShadow(radius: number, color?: string, offsetX?: number, offsetY?: number): void
1963
1964Sets the shadow for the window borders.
1965
1966**System API**: This is a system API.
1967
1968**System capability**: SystemCapability.WindowManager.WindowManager.Core
1969
1970**Parameters**
1971
1972| Name | Type  | Mandatory| Description                                                         |
1973| ------- | ------ | ---- |-------------------------------------------------------------|
1974| 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.    |
1975| 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**.|
1976| offsetX | number | No  | Offset of the shadow along the x-axis, in px. The value is a floating point number.                             |
1977| offsetY | number | No  | Offset of the shadow along the y-axis, in px. The value is a floating point number.                             |
1978
1979**Error codes**
1980
1981For details about the error codes, see [Window Error Codes](errorcode-window.md).
1982
1983| ID| Error Message|
1984| ------- | ------------------------------ |
1985| 1300002 | This window state is abnormal. |
1986| 1300004 | Unauthorized operation.  |
1987
1988**Example**
1989
1990```ts
1991try {
1992  windowClass.setShadow(4.0, '#FF00FF00', 2, 3);
1993} catch (exception) {
1994  console.error('Failed to set shadow. Cause: ' + JSON.stringify(exception));
1995}
1996```
1997
1998### setCornerRadius<sup>9+</sup>
1999
2000setCornerRadius(cornerRadius: number): void
2001
2002Sets the radius of the rounded corners for this window.
2003
2004**System API**: This is a system API.
2005
2006**System capability**: SystemCapability.WindowManager.WindowManager.Core
2007
2008**Parameters**
2009
2010| Name     | Type   | Mandatory| Description                                                |
2011| ----------- | ------- | ---- |----------------------------------------------------|
2012| radius | 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.|
2013
2014**Error codes**
2015
2016For details about the error codes, see [Window Error Codes](errorcode-window.md).
2017
2018| ID| Error Message|
2019| ------- | ------------------------------ |
2020| 1300002 | This window state is abnormal. |
2021| 1300004 | Unauthorized operation.  |
2022
2023**Example**
2024
2025```ts
2026try {
2027  windowClass.setCornerRadius(4.0);
2028} catch (exception) {
2029  console.error('Failed to set corner radius. Cause: ' + JSON.stringify(exception));
2030}
2031```
2032
2033### raiseToAppTop<sup>10+</sup>
2034
2035raiseToAppTop(callback: AsyncCallback&lt;void&gt;): void
2036
2037Raises the application subwindow to the top layer of the application. This API uses an asynchronous callback to return the result.
2038
2039**System API**: This is a system API.
2040
2041**System capability**: SystemCapability.WindowManager.WindowManager.Core
2042
2043**Parameters**
2044
2045| Name  | Type                     | Mandatory| Description      |
2046| -------- | ------------------------- | ---- | ---------- |
2047| callback | AsyncCallback&lt;void&gt; | Yes  | Callback used to return the result.|
2048
2049**Error codes**
2050
2051For details about the error codes, see [Window Error Codes](errorcode-window.md).
2052
2053| ID| Error Message|
2054| ------- | ------------------------------ |
2055| 1300002 | This window state is abnormal. |
2056| 1300003 | This window manager service works abnormally. |
2057| 1300004 | Unauthorized operation. |
2058| 1300009 | The parent window is invalid. |
2059
2060**Example**
2061
2062```ts
2063import { BusinessError } from '@ohos.base';
2064
2065windowClass.raiseToAppTop((err: BusinessError) => {
2066  const errCode: number = err.code;
2067  if (errCode) {
2068    console.error('Failed to raise the window to app top. Cause: ' + JSON.stringify(err));
2069    return;
2070  }
2071  console.info('Succeeded in raising the window to app top.');
2072});
2073```
2074
2075### raiseToAppTop<sup>10+</sup>
2076
2077raiseToAppTop(): Promise&lt;void&gt;
2078
2079Raises the application subwindow to the top layer of the application. This API uses a promise to return the result.
2080
2081**System API**: This is a system API.
2082
2083**System capability**: SystemCapability.WindowManager.WindowManager.Core
2084
2085**Return value**
2086
2087| Type               | Description                     |
2088| ------------------- | ------------------------- |
2089| Promise&lt;void&gt; | Promise that returns no value.|
2090
2091**Error codes**
2092
2093For details about the error codes, see [Window Error Codes](errorcode-window.md).
2094
2095| ID| Error Message|
2096| ------- | ------------------------------ |
2097| 1300002 | This window state is abnormal. |
2098| 1300003 | This window manager service works abnormally. |
2099| 1300004 | Unauthorized operation. |
2100| 1300009 | The parent window is invalid. |
2101
2102**Example**
2103
2104```ts
2105import { BusinessError } from '@ohos.base';
2106
2107let promise = windowClass.raiseToAppTop();
2108promise.then(() => {
2109  console.info('Succeeded in raising the window to app top.');
2110}).catch((err: BusinessError) => {
2111  console.error('Failed to raise the window to app top. Cause: ' + JSON.stringify(err));
2112});
2113```
2114
2115### setWaterMarkFlag<sup>10+</sup>
2116
2117setWaterMarkFlag(enable: boolean): Promise&lt;void&gt;
2118
2119Adds or deletes the watermark flag for this window. This API uses a promise to return the result.
2120
2121**System API**: This is a system API.
2122
2123**System capability**: SystemCapability.WindowManager.WindowManager.Core
2124
2125**Parameters**
2126
2127| Name| Type    | Mandatory| Description                                           |
2128| ------ | ------- | --- | ------------------------------------------------ |
2129| enable | boolean | Yes  | Whether to add or delete the watermark flag to the window. The value **true** means to add the watermark flag and **false** means to delete the watermark flag.|
2130
2131**Return value**
2132
2133| Type               | Description                     |
2134| ------------------- | ------------------------- |
2135| Promise&lt;void&gt; | Promise that returns no value.|
2136
2137**Error codes**
2138
2139For details about the error codes, see [Window Error Codes](errorcode-window.md).
2140
2141| ID| Error Message|
2142| ------- | ---------------------------------------------- |
2143| 1300002 | This window state is abnormal.                 |
2144| 1300003 | This window manager service works abnormally.  |
2145| 1300008 | The operation is on invalid display.           |
2146
2147**Example**
2148
2149```ts
2150import { BusinessError } from '@ohos.base';
2151
2152try {
2153  let enable = true;
2154  let promise = windowClass.setWaterMarkFlag(enable);
2155  promise.then(() => {
2156    console.info('Succeeded in setting water mark flag of window.');
2157  }).catch((err: BusinessError) => {
2158    console.error('Failed to set water mark flag of window. Cause:' + JSON.stringify(err));
2159  });
2160} catch (exception) {
2161  console.error('Failed to set water mark flag of window. Cause: ' + JSON.stringify(exception));
2162}
2163```
2164
2165### setWaterMarkFlag<sup>10+</sup>
2166
2167setWaterMarkFlag(enable: boolean, callback: AsyncCallback&lt;void&gt;): void
2168
2169Adds or deletes the watermark flag for this window. This API uses an asynchronous callback to return the result.
2170
2171**System API**: This is a system API.
2172
2173**System capability**: SystemCapability.WindowManager.WindowManager.Core
2174
2175**Parameters**
2176
2177| Name  | Type                      | Mandatory| Description                                             |
2178| -------- | ------------------------- | ---  | ----------------------------------------------- |
2179| enable   | boolean                   | Yes  | Whether to add or delete the watermark flag to the window. The value **true** means to add the watermark flag and **false** means to delete the watermark flag.|
2180| callback | AsyncCallback&lt;void&gt; | Yes  | Callback used to return the result.          |
2181
2182**Error codes**
2183
2184For details about the error codes, see [Window Error Codes](errorcode-window.md).
2185
2186| ID| Error Message|
2187| ------- | ---------------------------------------------- |
2188| 1300002 | This window state is abnormal.                 |
2189| 1300003 | This window manager service works abnormally.  |
2190| 1300008 | The operation is on invalid display.           |
2191
2192**Example**
2193
2194```ts
2195import { BusinessError } from '@ohos.base';
2196
2197try {
2198  let enable: boolean = true;
2199  windowClass.setWaterMarkFlag(enable, (err: BusinessError) => {
2200    const errCode: number = err.code;
2201    if (errCode) {
2202      console.error('Failed to set water mark flag of window. Cause:' + JSON.stringify(err));
2203      return;
2204    }
2205    console.info('Succeeded in setting water mark flag of window.');
2206  });
2207} catch (exception) {
2208  console.error('Failed to set water mark flag of window. Cause: ' + JSON.stringify(exception));
2209}
2210```
2211### raiseAboveTarget<sup>10+</sup>
2212
2213raiseAboveTarget(windowId: number, callback: AsyncCallback&lt;void&gt;): void
2214
2215Raises a subwindow above a target subwindow. This API uses an asynchronous callback to return the result.
2216
2217**System API**: This is a system API.
2218
2219**System capability**: SystemCapability.Window.SessionManager
2220
2221**Parameters**
2222
2223| Name  | Type                     | Mandatory| Description      |
2224| -------- | ------------------------- | ---- | ---------- |
2225| 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).|
2226| callback | AsyncCallback&lt;void&gt; | Yes  | Callback used to return the result.|
2227
2228**Error codes**
2229
2230For details about the error codes, see [Window Error Codes](errorcode-window.md).
2231
2232| ID| Error Message|
2233| ------- | ---------------------------------------------- |
2234| 1300002 | This window state is abnormal. |
2235| 1300003 | This window manager service works abnormally. |
2236| 1300004 | Unauthorized operation. |
2237| 1300009 | The parent window is invalid. |
2238
2239**Example**
2240
2241```js
2242// The windowClass must be obtained above the targetWindow.
2243let targetWindow: window.Window = windowClass;
2244let properties = targetWindow.getWindowProperties();
2245let targetId = properties.id;
2246windowClass.raiseAboveTarget(targetId, (err) => {
2247    if (err.code) {
2248        console.error('Failed to raise the subWindow to target subWindow top. Cause: ' + JSON.stringify(err));
2249        return;
2250    }
2251    console.info('Succeeded in raising the subWindow to target subWindow top.');
2252});
2253```
2254
2255### raiseAboveTarget<sup>10+</sup>
2256
2257raiseAboveTarget(windowId: number): Promise&lt;void&gt;
2258
2259Raises a subwindow above a target subwindow. This API uses a promise to return the result.
2260
2261**System API**: This is a system API.
2262
2263**System capability**: SystemCapability.Window.SessionManager
2264
2265**Parameters**
2266
2267| Name  | Type                     | Mandatory| Description      |
2268| -------- | ------------------------- | ---- | ---------- |
2269| 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).|
2270
2271**Return value**
2272
2273| Type               | Description                     |
2274| ------------------- | ------------------------- |
2275| Promise&lt;void&gt; | Promise that returns no value.|
2276
2277**Error codes**
2278
2279For details about the error codes, see [Window Error Codes](errorcode-window.md).
2280
2281| ID| Error Message|
2282| ------- | ------------------------------ |
2283| 1300002 | This window state is abnormal. |
2284| 1300003 | This window manager service works abnormally. |
2285| 1300004 | Unauthorized operation. |
2286| 1300009 | The parent window is invalid. |
2287
2288**Example**
2289
2290```js
2291// The windowClass must be obtained above the targetWindow.
2292let targetWindow: window.Window = windowClass;
2293let properties = targetWindow.getWindowProperties();
2294let targetId = properties.id;
2295let promise = windowClass.raiseAboveTarget(targetId);
2296promise.then(()=> {
2297    console.info('Succeeded in raising the subWindow to target subWindow top.');
2298}).catch((err)=>{
2299    console.error('Failed to raise the subWindow to target subWindow top. Cause: ' + JSON.stringify(err));
2300});
2301```
2302### setRaiseByClickEnabled<sup>10+</sup>
2303
2304setRaiseByClickEnabled(enable: boolean, callback: AsyncCallback&lt;void&gt;): void
2305
2306Sets whether to enable a subwindow to raise itself by click. This API uses an asynchronous callback to return the result.
2307
2308Generally, 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.
2309
2310**System API**: This is a system API.
2311
2312**System capability**: SystemCapability.Window.SessionManager
2313
2314**Parameters**
2315
2316| Name  | Type                     | Mandatory| Description      |
2317| -------- | ------------------------- | ---- | ---------- |
2318| 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.|
2319| callback | AsyncCallback&lt;void&gt; | Yes  | Callback used to return the result.|
2320
2321**Error codes**
2322
2323For details about the error codes, see [Window Error Codes](errorcode-window.md).
2324
2325| ID| Error Message|
2326| ------- | ------------------------------ |
2327| 1300002 | This window state is abnormal. |
2328| 1300003 | This window manager service works abnormally. |
2329| 1300004 | Unauthorized operation. |
2330| 1300009 | The parent window is invalid. |
2331
2332**Example**
2333
2334```js
2335let enabled = false;
2336windowClass.setRaiseByClickEnabled(enabled, (err) => {
2337    if (err.code) {
2338        console.error('Failed to disable the raise-by-click function. Cause: ' + JSON.stringify(err));
2339        return;
2340    }
2341    console.info('Succeeded in disabling the raise-by-click function.');
2342});
2343```
2344
2345### setRaiseByClickEnabled<sup>10+</sup>
2346
2347setRaiseByClickEnabled(enable: boolean): Promise&lt;void&gt;
2348
2349Sets whether to enable a subwindow to raise itself by click. This API uses a promise to return the result.
2350
2351Generally, 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.
2352
2353**System API**: This is a system API.
2354
2355**System capability**: SystemCapability.Window.SessionManager
2356
2357**Parameters**
2358
2359| Name  | Type                     | Mandatory| Description      |
2360| -------- | ------------------------- | ---- | ---------- |
2361| 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.|
2362
2363**Return value**
2364
2365| Type               | Description                     |
2366| ------------------- | ------------------------- |
2367| Promise&lt;void&gt; | Promise that returns no value.|
2368
2369**Error codes**
2370
2371For details about the error codes, see [Window Error Codes](errorcode-window.md).
2372
2373| ID| Error Message|
2374| ------- | ------------------------------ |
2375| 1300002 | This window state is abnormal. |
2376| 1300003 | This window manager service works abnormally. |
2377| 1300004 | Unauthorized operation. |
2378| 1300009 | The parent window is invalid. |
2379
2380**Example**
2381
2382```js
2383let enabled = false;
2384let promise = windowClass.setRaiseByClickEnabled(enabled);
2385promise.then(()=> {
2386    console.info('Succeeded in disabling the raise-by-click function.');
2387}).catch((err)=>{
2388    console.error('Failed to disable the raise-by-click function. Cause: ' + JSON.stringify(err));
2389});
2390```
2391
2392### setResizeByDragEnabled<sup>10+</sup>
2393
2394setResizeByDragEnabled(enable: boolean, callback: AsyncCallback&lt;void&gt;): void
2395
2396Sets whether to enable the main window to resize itself by dragging. This API uses an asynchronous callback to return the result.
2397
2398**System API**: This is a system API.
2399
2400**System capability**: SystemCapability.Window.SessionManager
2401
2402**Parameters**
2403
2404| Name  | Type                     | Mandatory| Description      |
2405| -------- | ------------------------- | ---- | ---------- |
2406| enable   | boolean                   | Yes  | Whether to enable the main window to resize itself by dragging. The value **true** means to enable the main window to resize itself by dragging, and **false** means the opposite.|
2407| callback | AsyncCallback&lt;void&gt; | Yes  | Callback used to return the result.|
2408
2409**Error codes**
2410
2411For details about the error codes, see [Window Error Codes](errorcode-window.md).
2412
2413| ID| Error Message|
2414| ------- | ------------------------------ |
2415| 1300002 | This window state is abnormal. |
2416| 1300003 | This window manager service works abnormally. |
2417
2418**Example**
2419
2420```js
2421import UIAbility from '@ohos.app.ability.UIAbility';
2422
2423export default class EntryAbility extends UIAbility {
2424    onWindowStageCreate(windowStage) {
2425        // Load content for the main window.
2426        windowStage.loadContent("pages/page2", (err) => {
2427            if (err.code) {
2428                console.error('Failed to load the content. Cause:' + JSON.stringify(err));
2429                return;
2430            }
2431            console.info('Succeeded in loading the content.');
2432        });
2433        // Obtain the main window.
2434        let mainWindow = null;
2435
2436        windowStage.getMainWindow((err, data) => {
2437            if (err.code) {
2438                console.error('Failed to obtain the main window. Cause: ' + JSON.stringify(err));
2439                return;
2440            }
2441            mainWindow = data;
2442            console.info('Succeeded in obtaining the main window. Data: ' + JSON.stringify(data));
2443
2444            let enabled = false;
2445            // Call setResizeByDragEnabled.
2446            mainWindow.setResizeByDragEnabled(enabled, (err) => {
2447                if (err.code) {
2448                    console.error('Failed to set the function of disabling the resize by dragg window. Cause: ' + JSON.stringify(err));
2449                    return;
2450                }
2451                console.info('Succeeded in setting the function of disabling the resize by dragg window.');
2452            });
2453        })
2454    }
2455};
2456```
2457
2458### setResizeByDragEnabled<sup>10+</sup>
2459
2460setResizeByDragEnabled(enable: boolean): Promise&lt;void&gt;
2461
2462Sets whether to enable the main window to resize itself by dragging. This API uses a promise to return the result.
2463
2464**System API**: This is a system API.
2465
2466**System capability**: SystemCapability.Window.SessionManager
2467
2468**Parameters**
2469
2470| Name  | Type                     | Mandatory| Description      |
2471| -------- | ------------------------- | ---- | ---------- |
2472| enable   | boolean                   | Yes  | Whether to enable the main window to resize itself by dragging. The value **true** means to enable the main window to resize itself by dragging, and **false** means the opposite.|
2473
2474**Return value**
2475
2476| Type               | Description                     |
2477| ------------------- | ------------------------- |
2478| Promise&lt;void&gt; | Promise that returns no value.|
2479
2480**Error codes**
2481
2482For details about the error codes, see [Window Error Codes](errorcode-window.md).
2483
2484| ID| Error Message|
2485| ------- | ------------------------------ |
2486| 1300002 | This window state is abnormal. |
2487| 1300003 | This window manager service works abnormally. |
2488
2489**Example**
2490
2491```js
2492import UIAbility from '@ohos.app.ability.UIAbility';
2493
2494export default class EntryAbility extends UIAbility {
2495    onWindowStageCreate(windowStage) {
2496        // Load content for the main window.
2497        windowStage.loadContent("pages/page2", (err) => {
2498            if (err.code) {
2499                console.error('Failed to load the content. Cause:' + JSON.stringify(err));
2500                return;
2501            }
2502            console.info('Succeeded in loading the content.');
2503        });
2504        // Obtain the main window.
2505        let mainWindow = null;
2506
2507        windowStage.getMainWindow((err, data) => {
2508            if (err.code) {
2509                console.error('Failed to obtain the main window. Cause: ' + JSON.stringify(err));
2510                return;
2511            }
2512            mainWindow = data;
2513            console.info('Succeeded in obtaining the main window. Data: ' + JSON.stringify(data));
2514
2515            let enabled = false;
2516            // Promise object of the setResizeByDragEnabled API.
2517            let promise = mainWindow.setResizeByDragEnabled(enabled);
2518            promise.then(()=> {
2519                console.info('Succeeded in setting the function of disabling the resize by dragg window.');
2520            }).catch((err)=>{
2521                console.error('Failed to set the function of disabling the resize by dragg window. Cause: ' + JSON.stringify(err));
2522            });
2523        })
2524    }
2525};
2526```
2527
2528### hideNonSystemFloatingWindows<sup>11+</sup>
2529
2530hideNonSystemFloatingWindows(shouldHide: boolean, callback: AsyncCallback&lt;void&gt;): void
2531
2532Sets whether to hide non-system floating windows. This API uses an asynchronous callback to return the result.
2533
2534A 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.
2535
2536**System API**: This is a system API.
2537
2538**System capability**: SystemCapability.Window.SessionManager
2539
2540**Parameters**
2541
2542| Name     | Type                     | Mandatory| Description      |
2543| ----------- | ------------------------- | ---- | ---------- |
2544| shouldHide  | boolean                   | Yes  | Whether to hide non-system floating windows. The value **true** means to hide the floating windows, and **false** means the opposite.|
2545| callback    | AsyncCallback&lt;void&gt; | Yes  | Callback used to return the result.|
2546
2547**Error codes**
2548
2549For details about the error codes, see [Window Error Codes](errorcode-window.md).
2550
2551| ID| Error Message|
2552| ------- | ------------------------------ |
2553| 1300002 | This window state is abnormal. |
2554| 1300003 | This window manager service works abnormally. |
2555| 1300004 | Unauthorized operation. |
2556
2557**Example**
2558
2559```ts
2560import UIAbility from '@ohos.app.ability.UIAbility';
2561import window from '@ohos.window';
2562
2563export default class EntryAbility extends UIAbility {
2564  onWindowStageCreate(windowStage: window.WindowStage) {
2565    // Load the page corresponding to the main window.
2566    windowStage.loadContent('pages/Index', (err) => {
2567      if (err.code) {
2568        console.error('Failed to load the content. Cause:' + JSON.stringify(err));
2569        return;
2570      }
2571      console.info('Succeeded in loading the content.');
2572    });
2573
2574    // Obtain the main window.
2575    let mainWindow = null;
2576    windowStage.getMainWindow((err, data) => {
2577      if (err.code) {
2578        console.error('Failed to obtain the main window. Cause: ' + JSON.stringify(err));
2579        return;
2580      }
2581      mainWindow = data;
2582      console.info('Succeeded in obtaining the main window. Data: ' + JSON.stringify(data));
2583
2584      let shouldHide = true;
2585      // Call hideNonSystemFloatingWindows with the callback parameter.
2586      mainWindow.hideNonSystemFloatingWindows(shouldHide, (err) => {
2587        if (err.code) {
2588          console.error('Failed to hide the non-system floating windows. Cause: ' + JSON.stringify(err));
2589          return;
2590        }
2591        console.info('Succeeded in hiding the non-system floating windows.');
2592      });
2593    })
2594  }
2595}
2596```
2597
2598### hideNonSystemFloatingWindows<sup>11+</sup>
2599
2600hideNonSystemFloatingWindows(shouldHide: boolean): Promise&lt;void&gt;
2601
2602Sets whether to hide non-system floating windows. This API uses an asynchronous callback to return the result.
2603
2604A 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.
2605
2606**System API**: This is a system API.
2607
2608**System capability**: SystemCapability.Window.SessionManager
2609
2610**Parameters**
2611
2612| Name     | Type                     | Mandatory| Description      |
2613| ----------- | ------------------------- | ---- | ---------- |
2614| shouldHide  | boolean                   | Yes  | Whether to hide non-system floating windows. The value **true** means to hide the floating windows, and **false** means the opposite.|
2615
2616**Return value**
2617
2618| Type               | Description                     |
2619| ------------------- | ------------------------- |
2620| Promise&lt;void&gt; | Promise that returns no value.|
2621
2622**Error codes**
2623
2624For details about the error codes, see [Window Error Codes](errorcode-window.md).
2625
2626| ID| Error Message|
2627| ------- | ------------------------------ |
2628| 1300002 | This window state is abnormal. |
2629| 1300003 | This window manager service works abnormally. |
2630| 1300004 | Unauthorized operation. |
2631
2632**Example**
2633
2634```ts
2635import UIAbility from '@ohos.app.ability.UIAbility';
2636import window from '@ohos.window';
2637
2638export default class EntryAbility extends UIAbility {
2639  onWindowStageCreate(windowStage: window.WindowStage) {
2640    // Load the page corresponding to the main window.
2641    windowStage.loadContent('pages/Index', (err) => {
2642      if (err.code) {
2643        console.error('Failed to load the content. Cause:' + JSON.stringify(err));
2644        return;
2645      }
2646      console.info('Succeeded in loading the content.');
2647    });
2648
2649    // Obtain the main window.
2650    let mainWindow = null;
2651    windowStage.getMainWindow((err, data) => {
2652      if (err.code) {
2653        console.error('Failed to obtain the main window. Cause: ' + JSON.stringify(err));
2654        return;
2655      }
2656      mainWindow = data;
2657      console.info('Succeeded in obtaining the main window. Data: ' + JSON.stringify(data));
2658
2659      let shouldHide = true;
2660      // Call hideNonSystemFloatingWindows to obtain a promise object.
2661      let promise = mainWindow.hideNonSystemFloatingWindows(shouldHide);
2662      promise.then(()=> {
2663        console.info('Succeeded in hiding the non-system floating windows.');
2664      }).catch((err)=>{
2665        console.error('Failed to hide the non-system floating windows. Cause: ' + JSON.stringify(err));
2666      });
2667    })
2668  }
2669}
2670```
2671
2672### setSingleFrameComposerEnabled<sup>11+</sup>
2673
2674setSingleFrameComposerEnabled(enable: boolean): Promise&lt;void&gt;
2675
2676Enables or disables the single-frame composer. This API uses a promise to return the result.
2677
2678The single-frame composer is mainly used in scenarios that requires extremely low interaction latency. It reduces the screen display latency of the rendering node.
2679
2680**System API**: This is a system API.
2681
2682**System capability**: SystemCapability.Window.SessionManager
2683
2684**Parameters**
2685
2686| Name  | Type                     | Mandatory| Description      |
2687| -------- | ------------------------- | ---- | ---------- |
2688| 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.|
2689
2690**Return value**
2691
2692| Type               | Description                     |
2693| ------------------- | ------------------------- |
2694| Promise&lt;void&gt; | Promise that returns no value.|
2695
2696**Error codes**
2697
2698For details about the error codes, see [Window Error Codes](errorcode-window.md).
2699
2700| ID| Error Message|
2701| ------- | ------------------------------ |
2702| 1300002 | This window state is abnormal. |
2703
2704**Example**
2705
2706```ts
2707import { BusinessError } from '@ohos.base';
2708
2709let enable = true;
2710let promise = windowClass.setSingleFrameComposerEnabled(enable);
2711promise.then(()=> {
2712    console.info('Succeeded in enabling the single-frame-composer function.');
2713}).catch((err: BusinessError)=>{
2714    console.error('Failed to enable the single-frame-composer function. code:${err.code}, message:${err.message}.');
2715});
2716```
2717
2718### setWindowType<sup>(deprecated)</sup>
2719
2720setWindowType(type: WindowType, callback: AsyncCallback&lt;void&gt;): void
2721
2722Sets the type of this window. This API uses an asynchronous callback to return the result.
2723
2724**System API**: This is a system API.
2725
2726> **NOTE**
2727>
2728> This API is supported since API version 7 and deprecated since API version 9.
2729
2730**System capability**: SystemCapability.WindowManager.WindowManager.Core
2731
2732**Parameters**
2733
2734| Name  | Type                     | Mandatory| Description      |
2735| -------- | ------------------------- | ---- | ---------- |
2736| type     | [WindowType](#windowtype7) | Yes  | Window type.|
2737| callback | AsyncCallback&lt;void&gt; | Yes  | Callback used to return the result.|
2738
2739**Example**
2740
2741```ts
2742import { BusinessError } from '@ohos.base';
2743
2744let type = window.WindowType.TYPE_SYSTEM_ALERT;
2745windowClass.setWindowType(type, (err: BusinessError) => {
2746  const errCode: number = err.code;
2747  if (errCode) {
2748    console.error('Failed to set the window type. Cause: ' + JSON.stringify(err));
2749    return;
2750  }
2751  console.info('Succeeded in setting the window type.');
2752});
2753```
2754
2755### setWindowType<sup>(deprecated)</sup>
2756
2757setWindowType(type: WindowType): Promise&lt;void&gt;
2758
2759Sets the type of this window. This API uses a promise to return the result.
2760
2761**System API**: This is a system API.
2762
2763> **NOTE**
2764>
2765> This API is supported since API version 7 and deprecated since API version 9.
2766
2767**System capability**: SystemCapability.WindowManager.WindowManager.Core
2768
2769**Parameters**
2770
2771| Name| Type                     | Mandatory| Description      |
2772| ------ | ------------------------- | ---- | ---------- |
2773| type   | [WindowType](#windowtype7) | Yes  | Window type.|
2774
2775**Return value**
2776
2777| Type               | Description                     |
2778| ------------------- | ------------------------- |
2779| Promise&lt;void&gt; | Promise that returns no value.|
2780
2781**Example**
2782
2783```ts
2784import { BusinessError } from '@ohos.base';
2785
2786let type = window.WindowType.TYPE_SYSTEM_ALERT;
2787let promise = windowClass.setWindowType(type);
2788promise.then(() => {
2789  console.info('Succeeded in setting the window type.');
2790}).catch((err: BusinessError) => {
2791  console.error('Failed to set the window type. Cause: ' + JSON.stringify(err));
2792});
2793```
2794
2795## WindowStage<sup>9+</sup>
2796
2797Implements a window manager, which manages each basic window unit, that is, [Window](#window) instance.
2798
2799Before 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.
2800
2801### disableWindowDecor()<sup>9+</sup>
2802
2803disableWindowDecor(): void
2804
2805Disables window decorators.
2806
2807**Model restriction**: This API can be used only in the stage model.
2808
2809**System API**: This is a system API.
2810
2811**System capability**: SystemCapability.WindowManager.WindowManager.Core
2812
2813**Error codes**
2814
2815For details about the error codes, see [Window Error Codes](errorcode-window.md).
2816
2817| ID| Error Message|
2818| ------- | ------------------------------ |
2819| 1300002 | This window state is abnormal. |
2820| 1300005 | This window stage is abnormal. |
2821
2822**Example**
2823
2824```ts
2825import UIAbility from '@ohos.app.ability.UIAbility';
2826import window from '@ohos.window';
2827
2828export default class EntryAbility extends UIAbility {
2829  // ...
2830
2831  onWindowStageCreate(windowStage: window.WindowStage) {
2832    console.log('disableWindowDecor');
2833    windowStage.disableWindowDecor();
2834  }
2835};
2836```
2837
2838### setShowOnLockScreen()<sup>9+</sup>
2839
2840setShowOnLockScreen(showOnLockScreen: boolean): void
2841
2842Sets whether to display the window of the application on the lock screen.
2843
2844**System API**: This is a system API.
2845
2846**Model restriction**: This API can be used only in the stage model.
2847
2848**System capability**: SystemCapability.WindowManager.WindowManager.Core
2849
2850**Parameters**
2851
2852| Name          | Type   | Mandatory| Description                        |
2853| ---------------- | ------- | ---- | ---------------------------- |
2854| 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.|
2855
2856**Error codes**
2857
2858For details about the error codes, see [Window Error Codes](errorcode-window.md).
2859
2860| ID| Error Message|
2861| ------- | ------------------------------ |
2862| 1300002 | This window state is abnormal. |
2863| 1300005 | This window stage is abnormal. |
2864
2865**Example**
2866
2867```ts
2868import UIAbility from '@ohos.app.ability.UIAbility';
2869import window from '@ohos.window';
2870
2871export default class EntryAbility extends UIAbility {
2872  // ...
2873
2874  onWindowStageCreate(windowStage: window.WindowStage) {
2875    console.log('onWindowStageCreate');
2876    try {
2877      windowStage.setShowOnLockScreen(true);
2878    } catch (exception) {
2879      console.error('Failed to show on lockscreen. Cause:' + JSON.stringify(exception));
2880    }
2881  }
2882};
2883```
2884## TransitionContext<sup>9+</sup>
2885
2886Provides the context for the transition animation.
2887
2888**System API**: This is a system API.
2889
2890### Attributes
2891
2892**System API**: This is a system API.
2893
2894**System capability**: SystemCapability.WindowManager.WindowManager.Core
2895
2896| Name                 | Type         | Readable| Writable| Description            |
2897| --------------------- | ----------------- | ---- | ---- | ---------------- |
2898| toWindow<sup>9+</sup> | [Window](#window) | Yes  | Yes  | Target window to display the animation.|
2899
2900### completeTransition<sup>9+</sup>
2901
2902completeTransition(isCompleted: boolean): void
2903
2904Completes the transition. This API can be called only after [animateTo()](arkui-ts/ts-explicit-animation.md) is executed.
2905
2906**System API**: This is a system API.
2907
2908**System capability**: SystemCapability.WindowManager.WindowManager.Core
2909
2910**Parameters**
2911
2912| Name     | Type   | Mandatory| Description                                                        |
2913| ----------- | ------- | ---- | ------------------------------------------------------------ |
2914| isCompleted | boolean | Yes  | Whether the transition is complete. The value **true** means that the transition is complete, and **false** means the opposite.|
2915
2916**Example**
2917
2918```ts
2919(context: window.TransitionContext) => {
2920  let toWindow: window.Window = context.toWindow;
2921  animateTo({
2922    duration: 1000, // Animation duration.
2923    tempo: 0.5, // Playback speed.
2924    curve: Curve.EaseInOut, // Animation curve.
2925    delay: 0, // Animation delay.
2926    iterations: 1, // Number of playback times.
2927    playMode: PlayMode.Normal // Animation playback mode.
2928  }, () => {
2929    let obj: window.TranslateOptions = {
2930      x: 100.0,
2931      y: 0.0,
2932      z: 0.0
2933    };
2934    toWindow.translate(obj);
2935    console.info('toWindow translate end');
2936  }
2937  );
2938  try {
2939    context.completeTransition(true)
2940  } catch (exception) {
2941    console.info('toWindow translate fail. Cause: ' + JSON.stringify(exception));
2942  }
2943  console.info('complete transition end');
2944};
2945```
2946
2947## TransitionController<sup>9+</sup>
2948
2949Implements the transition animation controller.
2950
2951**System API**: This is a system API.
2952
2953### animationForShown<sup>9+</sup>
2954
2955animationForShown(context: TransitionContext): void
2956
2957Customizes the animation for the scenario when the window is shown.
2958
2959**System API**: This is a system API.
2960
2961**System capability**: SystemCapability.WindowManager.WindowManager.Core
2962
2963**Parameters**
2964
2965| Name | Type                                    | Mandatory| Description                |
2966| ------- | ---------------------------------------- | ---- | -------------------- |
2967| context | [TransitionContext](#transitioncontext9) | Yes  | Context of the transition animation.|
2968
2969**Example**
2970
2971```ts
2972// xxx.ts
2973export class AnimationConfig {
2974  private animationForShownCallFunc_: Function = undefined;
2975  ShowWindowWithCustomAnimation(windowClass: window.Window, callback) {
2976    if (!windowClass) {
2977      console.error('windowClass is undefined');
2978      return false;
2979    }
2980    this.animationForShownCallFunc_ = callback;
2981    let controller: window.TransitionController = windowClass.getTransitionController();
2982    controller.animationForShown = (context : window.TransitionContext)=> {
2983      this.animationForShownCallFunc_(context);
2984    };
2985    windowClass.showWithAnimation(()=>{
2986      console.info('Show with animation success');
2987    })
2988  }
2989}
2990```
2991
2992```ts
2993// xxx.ets
2994let animationConfig = new AnimationConfig();
2995let systemTypeWindow = window.findWindow("systemTypeWindow"); // Obtain a system window.
2996try {
2997  animationConfig?.ShowWindowWithCustomAnimation(systemTypeWindow, (context : window.TransitionContext)=>{
2998    console.info('complete transition end');
2999    let toWindow = context.toWindow;
3000    animateTo({
3001      duration: 1000, // Animation duration.
3002      tempo: 0.5, // Playback speed.
3003      curve: Curve.EaseInOut, // Animation curve.
3004      delay: 0, // Animation delay.
3005      iterations: 1, // Number of playback times.
3006      playMode: PlayMode.Normal // Animation playback mode.
3007      onFinish: () => {
3008        console.info('onFinish in animation');
3009        context.completeTransition(true)
3010      }
3011    }, () => {
3012      let obj : window.TranslateOptions = {
3013        x : 100.0,
3014        y : 0.0,
3015        z : 0.0
3016      };
3017      toWindow.translate(obj); // Set the transition animation.
3018      console.info('toWindow translate end in animation');
3019    });
3020    console.info('complete transition end');
3021  });
3022} catch (error) {
3023  console.error('ShowWindowWithCustomAnimation err : ' + JSON.stringify(error));
3024}
3025```
3026### animationForHidden<sup>9+</sup>
3027
3028animationForHidden(context: TransitionContext): void
3029
3030Customizes the animation for the scenario when the window is hidden.
3031
3032**System API**: This is a system API.
3033
3034**System capability**: SystemCapability.WindowManager.WindowManager.Core
3035
3036**Parameters**
3037
3038| Name | Type                                    | Mandatory| Description                |
3039| ------- | ---------------------------------------- | ---- | -------------------- |
3040| context | [TransitionContext](#transitioncontext9) | Yes  | Context of the transition animation.|
3041
3042**Example**
3043
3044```ts
3045// xxx.ts
3046export class AnimationConfig {
3047  private animationForHiddenCallFunc_: Function = undefined;
3048  HideWindowWithCustomAnimation(windowClass: window.Window, callback) {
3049    if (!windowClass) {
3050      console.error('windowClass is undefined');
3051      return false;
3052    }
3053    this.animationForHiddenCallFunc_ = callback;
3054    let controller: window.TransitionController = windowClass.getTransitionController();
3055    controller.animationForHidden = (context : window.TransitionContext)=> {
3056      this.animationForHiddenCallFunc_(context);
3057    };
3058    windowClass.hideWithAnimation(()=>{
3059      console.info('hide with animation success');
3060    })
3061  }
3062}
3063```
3064
3065```ts
3066// xxx.ets
3067let animationConfig = new AnimationConfig();
3068let systemTypeWindow = window.findWindow("systemTypeWindow"); // Obtain a system window.
3069try {
3070  animationConfig?.HideWindowWithCustomAnimation(systemTypeWindow, (context : window.TransitionContext)=>{
3071    console.info('complete transition end');
3072    let toWindow = context.toWindow;
3073    animateTo({
3074      duration: 1000, // Animation duration.
3075      tempo: 0.5, // Playback speed.
3076      curve: Curve.EaseInOut, // Animation curve.
3077      delay: 0, // Animation delay.
3078      iterations: 1, // Number of playback times.
3079      playMode: PlayMode.Normal // Animation playback mode.
3080      onFinish: () => {
3081        console.info('onFinish in animation');
3082        context.completeTransition(true)
3083      }
3084    }, () => {
3085      let obj : window.TranslateOptions = {
3086        x : 100.0,
3087        y : 0.0,
3088        z : 0.0
3089      };
3090      toWindow.translate(obj); // Set the transition animation.
3091      console.info('toWindow translate end in animation');
3092    });
3093    console.info('complete transition end');
3094  });
3095} catch (error) {
3096  console.error('HideWindowWithCustomAnimation err : ' + JSON.stringify(error));
3097}
3098```
3099
3100 <!--no_check-->