• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# @ohos.window (窗口)(系统接口)
2
3窗口提供管理窗口的一些基础能力,包括对当前窗口的创建、销毁、各属性设置,以及对各窗口间的管理调度。
4
5该模块提供以下窗口相关的常用功能:
6
7- [Window](#window):当前窗口实例,窗口管理器管理的基本单元。
8- [WindowStage](#windowstage9):窗口管理器。管理各个基本窗口单元。
9
10> **说明:**
11>
12> - 本模块首批接口从API version 6开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
13>
14> - 当前页面仅包含本模块的系统接口,其他公开接口参见[@ohos.window (窗口)](js-apis-window.md)。
15
16## 导入模块
17
18```ts
19import window from '@ohos.window';
20```
21
22## WindowType<sup>7+</sup>
23
24
25窗口类型枚举。
26
27**系统能力:** SystemCapability.WindowManager.WindowManager.Core
28
29| 名称                                  | 值 | 说明                                                                                     |
30|-------------------------------------| ------ |----------------------------------------------------------------------------------------|
31| TYPE_INPUT_METHOD<sup>9+</sup>      | 2      | 表示输入法窗口。<br>**模型约束:** 此接口仅可在Stage模型下使用。<br>**系统接口:** 此接口为系统接口。                         |
32| TYPE_STATUS_BAR<sup>9+</sup>        | 3      | 表示状态栏窗口。<br>**模型约束:** 此接口仅可在Stage模型下使用。<br>**系统接口:** 此接口为系统接口。                         |
33| TYPE_PANEL<sup>9+</sup>             | 4      | 表示通知栏。<br>**模型约束:** 此接口仅可在Stage模型下使用。<br>**系统接口:** 此接口为系统接口。                           |
34| TYPE_KEYGUARD<sup>9+</sup>          | 5      | 表示锁屏。<br>**模型约束:** 此接口仅可在Stage模型下使用。<br>**系统接口:** 此接口为系统接口。                            |
35| TYPE_VOLUME_OVERLAY<sup>9+</sup>    | 6      | 表示音量条。<br>**模型约束:** 此接口仅可在Stage模型下使用。<br>**系统接口:** 此接口为系统接口。                           |
36| TYPE_NAVIGATION_BAR<sup>9+</sup>    | 7      | 表示导航栏窗口。<br>**模型约束:** 此接口仅可在Stage模型下使用。<br>**系统接口:** 此接口为系统接口。                         |
37| TYPE_WALLPAPER<sup>9+</sup>         | 9      | 表示壁纸。<br>**模型约束:** 此接口仅可在Stage模型下使用。<br>**系统接口:** 此接口为系统接口。                            |
38| TYPE_DESKTOP<sup>9+</sup>           | 10      | 表示桌面。<br>**模型约束:** 此接口仅可在Stage模型下使用。<br>**系统接口:** 此接口为系统接口。                            |
39| TYPE_LAUNCHER_RECENT<sup>9+</sup>   | 11      | 表示多任务中心。<br>**模型约束:** 此接口仅可在Stage模型下使用。<br>**系统接口:** 此接口为系统接口。                         |
40| TYPE_LAUNCHER_DOCK<sup>9+</sup>     | 12      | 表示桌面Dock栏。<br>**模型约束:** 此接口仅可在Stage模型下使用。<br>**系统接口:** 此接口为系统接口。                       |
41| TYPE_VOICE_INTERACTION<sup>9+</sup> | 13      | 表示智慧语音。<br>**模型约束:** 此接口仅可在Stage模型下使用。<br>**系统接口:** 此接口为系统接口。                          |
42| TYPE_POINTER<sup>9+</sup>           | 14      | 表示鼠标。<br>**模型约束:** 此接口仅可在Stage模型下使用。<br>**系统接口:** 此接口为系统接口。                            |
43| TYPE_FLOAT_CAMERA<sup>9+</sup>      | 15      | 表示相机类型悬浮窗。<br>**模型约束:** 此接口仅可在Stage模型下使用。<br>**系统接口:** 此接口为系统接口。                       |
44| TYPE_SCREENSHOT<sup>9+</sup>        | 17      | 表示截屏窗口。<br>**模型约束:** 此接口仅可在Stage模型下使用。<br>**系统接口:** 此接口为系统接口。                          |
45| TYPE_SYSTEM_TOAST<sup>11+</sup>     | 18      | 表示顶层提示窗口。<br>**模型约束:** 此接口仅可在Stage模型下使用。<br>**系统接口:** 此接口为系统接口。                        |
46| TYPE_DIVIDER<sup>11+</sup>          | 19      | 表示分屏条。<br>**模型约束:** 此接口仅可在Stage模型下使用。<br>**系统接口:** 此接口为系统接口。                 |
47| TYPE_GLOBAL_SEARCH<sup>11+</sup>    | 20      | 表示全局搜索窗口。<br>**模型约束:** 此接口仅可在Stage模型下使用。<br>**系统接口:** 此接口为系统接口。                        |
48
49## WindowMode<sup>7+</sup>
50
51窗口模式枚举。
52
53**系统接口:** 此接口为系统接口。
54
55**系统能力:** SystemCapability.WindowManager.WindowManager.Core
56
57| 名称       | 值   | 说明                          |
58| ---------- | ---- | ----------------------------- |
59| UNDEFINED  | 1    | 表示APP未定义窗口模式。       |
60| FULLSCREEN | 2    | 表示APP全屏模式。             |
61| PRIMARY    | 3    | 表示APP分屏多窗口主要模式。   |
62| SECONDARY  | 4    | 表示APP分屏多窗口次要模式。   |
63| FLOATING   | 5    | 表示APP自由悬浮形式窗口模式。 |
64
65## WindowLayoutMode<sup>9+</sup>
66
67窗口布局模式枚举。
68
69**系统接口:** 此接口为系统接口。
70
71**系统能力:** SystemCapability.WindowManager.WindowManager.Core
72
73| 名称       | 值   | 说明                          |
74| ---------- | ---- | ----------------------------- |
75| WINDOW_LAYOUT_MODE_CASCADE  | 0    | 表示使用层叠布局模式。       |
76| WINDOW_LAYOUT_MODE_TILE | 1    | 表示使用平铺布局模式。             |
77
78
79## BlurStyle<sup>9+</sup>
80
81窗口模糊类型枚举。
82
83**系统接口:** 此接口为系统接口。
84
85**系统能力:** SystemCapability.WindowManager.WindowManager.Core
86
87| 名称    | 值   | 说明                 |
88| ------- | ---- | -------------------- |
89| OFF     | 0    | 表示关闭模糊。       |
90| THIN    | 1    | 表示较薄的模糊类型。 |
91| REGULAR | 2    | 表示适中的模糊类型。 |
92| THICK   | 3    | 表示较厚的模糊类型。 |
93
94## SystemBarRegionTint<sup>8+</sup>
95
96单个导航栏或状态栏回调信息。
97
98**系统接口:** 此接口为系统接口。
99
100**系统能力:** SystemCapability.WindowManager.WindowManager.Core
101
102| 名称            | 类型                  | 可读 | 可写 | 说明                                                         |
103| --------------- | ------------------------- | ---- | ---- | ------------------------------------------------------------ |
104| type            | [WindowType](#windowtype7) | 是   | 否   | 当前属性改变的系统栏类型,仅支持类型为导航栏、状态栏的系统栏。 |
105| isEnable        | boolean                   | 是   | 否   | 当前系统栏是否显示。true表示显示;false表示不显示。 |
106| region          | [Rect](js-apis-window.md#rect7)             | 是   | 否   | 当前系统栏的位置及大小。                                     |
107| backgroundColor | string                    | 是   | 否   | 系统栏背景颜色,为十六进制RGB或ARGB颜色,不区分大小写,例如`#00FF00`或`#FF00FF00`。 |
108| contentColor    | string                    | 是   | 否   | 系统栏文字颜色。                                             |
109
110## SystemBarTintState<sup>8+</sup>
111
112当前系统栏回调信息集合。
113
114**系统接口:** 此接口为系统接口。
115
116**系统能力:** SystemCapability.WindowManager.WindowManager.Core
117
118| 名称       | 类型                                            | 可读 | 可写 | 说明                         |
119| ---------- | --------------------------------------------------- | ---- | ---- | ---------------------------- |
120| displayId  | number                                              | 是   | 否   | 当前物理屏幕id,该参数应为整数。             |
121| regionTint | Array<[SystemBarRegionTint](#systembarregiontint8)> | 是   | 否   | 当前已改变的所有系统栏信息。 |
122
123## ScaleOptions<sup>9+</sup>
124
125缩放参数。
126
127**系统接口:** 此接口为系统接口。
128
129**系统能力**:SystemCapability.WindowManager.WindowManager.Core
130
131| 名称   | 类型 | 可读 | 可写 | 说明                                         |
132| ------ | -------- | ---- | ---- |--------------------------------------------|
133| x      | number   | 否   | 是   | X轴的缩放参数。该参数为浮点数,默认值为1.0。                   |
134| y      | number   | 否   | 是   | Y轴的缩放参数。该参数为浮点数,默认值为1.0。                   |
135| pivotX | number   | 否   | 是   | 缩放中心点X轴坐标。该参数为浮点数,默认值为0.5, 取值范围[0.0, 1.0]。 |
136| pivotY | number   | 否   | 是   | 缩放中心点Y轴坐标。该参数为浮点数,默认值为0.5, 取值范围[0.0, 1.0]。 |
137
138## RotateOptions<sup>9+</sup>
139
140旋转参数。
141
142**系统接口:** 此接口为系统接口。
143
144**系统能力**:SystemCapability.WindowManager.WindowManager.Core
145
146| 名称   | 类型 | 可读 | 可写 | 说明                                          |
147| ------ | -------- | ---- | ---- |---------------------------------------------|
148| x      | number   | 否   | 是   | 绕X轴的旋转角度。该参数为浮点数,默认值为0.0。                   |
149| y      | number   | 否   | 是   | 绕Y轴的旋转角度。该参数为浮点数,默认值为0.0。                   |
150| z      | number   | 否   | 是   | 绕Z轴的旋转角度。该参数为浮点数,默认值为0.0。                   |
151| pivotX | number   | 否   | 是   | 旋转中心点X轴坐标。该参数为浮点数,默认值为0.5, 取值范围为[0.0, 1.0]。 |
152| pivotY | number   | 否   | 是   | 旋转中心点Y轴坐标。该参数为浮点数,默认值为0.5, 取值范围为[0.0, 1.0]。  |
153
154## TranslateOptions<sup>9+</sup>
155
156平移参数。
157
158**系统接口:** 此接口为系统接口。
159
160**系统能力**:SystemCapability.WindowManager.WindowManager.Core
161
162| 名称 | 类型 | 可读 | 可写 | 说明                         |
163| ---- | -------- | ---- | ---- | ---------------------------- |
164| x    | number   | 否   | 是   | X轴的平移参数。该参数为浮点数,默认值为0.0,单位为px。 |
165| y    | number   | 否   | 是   | Y轴的平移参数。该参数为浮点数,默认值为0.0,单位为px。 |
166| z    | number   | 否   | 是   | Z轴的平移参数。该参数为浮点数,默认值为0.0,单位为px。 |
167
168
169## window.minimizeAll<sup>9+</sup>
170minimizeAll(id: number, callback: AsyncCallback&lt;void&gt;): void
171
172最小化某显示设备下的所有窗口。
173
174**系统接口:** 此接口为系统接口。
175
176**系统能力:** SystemCapability.WindowManager.WindowManager.Core
177
178**参数:**
179
180| 参数名   | 类型                      | 必填 | 说明           |
181| -------- | ------------------------- | ---- | -------------- |
182| id       | number                    | 是   | 显示设备[Display](js-apis-display.md#display)的ID号,该参数仅支持整数输入。 |
183| callback | AsyncCallback&lt;void&gt; | 是   | 回调信息。     |
184
185**错误码:**
186
187以下错误码的详细介绍请参见[窗口错误码](errorcode-window.md)。
188
189| 错误码ID | 错误信息 |
190| ------- | -------------------------------------------- |
191| 1300003 | This window manager service works abnormally. |
192
193**示例:**
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
223最小化某显示设备下的所有窗口。
224
225**系统接口:** 此接口为系统接口。
226
227**系统能力:** SystemCapability.WindowManager.WindowManager.Core
228
229**参数:**
230
231| 参数名   | 类型                      | 必填 | 说明           |
232| -------- | ------------------------- | ---- | -------------- |
233| id       | number                    | 是   | 显示设备[Display](js-apis-display.md#display)的ID号,该参数仅支持整数输入。 |
234
235**返回值:**
236
237| 类型                | 说明                      |
238| ------------------- | ------------------------- |
239| Promise&lt;void&gt; | 无返回结果的Promise对象。 |
240
241**错误码:**
242
243以下错误码的详细介绍请参见[窗口错误码](errorcode-window.md)。
244
245| 错误码ID | 错误信息 |
246| ------- | -------------------------------------------- |
247| 1300003 | This window manager service works abnormally. |
248
249**示例:**
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
277多窗口快速切换时隐藏或者恢复应用窗口。
278
279**系统接口:** 此接口为系统接口。
280
281**系统能力:** SystemCapability.WindowManager.WindowManager.Core
282
283**参数:**
284
285| 参数名   | 类型                      | 必填 | 说明           |
286| -------- | ------------------------- | ---- | -------------- |
287| callback | AsyncCallback&lt;void&gt; | 是   | 回调信息。     |
288
289**错误码:**
290
291以下错误码的详细介绍请参见[窗口错误码](errorcode-window.md)。
292
293| 错误码ID | 错误信息 |
294| ------- | -------------------------------------------- |
295| 1300003 | This window manager service works abnormally. |
296
297**示例:**
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
315多窗口快速切换时隐藏或者恢复应用窗口。
316
317**系统接口:** 此接口为系统接口。
318
319**系统能力:** SystemCapability.WindowManager.WindowManager.Core
320
321**返回值:**
322
323| 类型                | 说明                      |
324| ------------------- | ------------------------- |
325| Promise&lt;void&gt; | 无返回结果的Promise对象。 |
326
327**错误码:**
328
329以下错误码的详细介绍请参见[窗口错误码](errorcode-window.md)。
330
331| 错误码ID | 错误信息 |
332| ------- | -------------------------------------------- |
333| 1300003 | This window manager service works abnormally. |
334
335**示例:**
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
351设置窗口布局模式。
352
353**系统接口:** 此接口为系统接口。
354
355**系统能力:** SystemCapability.WindowManager.WindowManager.Core
356
357**参数:**
358
359| 参数名   | 类型                      | 必填 | 说明           |
360| -------- | ------------------------- | ---- | -------------- |
361| mode       | [WindowLayoutMode](#windowlayoutmode9)                  | 是   | 设置的窗口布局模式。 |
362| callback | AsyncCallback&lt;void&gt; | 是   | 回调信息。     |
363
364**错误码:**
365
366以下错误码的详细介绍请参见[窗口错误码](errorcode-window.md)。
367
368| 错误码ID | 错误信息 |
369| ------- | -------------------------------------------- |
370| 1300003 | This window manager service works abnormally. |
371
372**示例:**
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
394设置窗口布局模式。
395
396**系统接口:** 此接口为系统接口。
397
398**系统能力:** SystemCapability.WindowManager.WindowManager.Core
399
400**参数:**
401
402| 参数名   | 类型                      | 必填 | 说明           |
403| -------- | ------------------------- | ---- | -------------- |
404| mode       | [WindowLayoutMode](#windowlayoutmode9)                    | 是   | 设置的窗口布局模式。 |
405
406**返回值:**
407
408| 类型                | 说明                      |
409| ------------------- | ------------------------- |
410| Promise&lt;void&gt; | 无返回结果的Promise对象。 |
411
412**错误码:**
413
414以下错误码的详细介绍请参见[窗口错误码](errorcode-window.md)。
415
416| 错误码ID | 错误信息 |
417| ------- | -------------------------------------------- |
418| 1300003 | This window manager service works abnormally. |
419
420**示例:**
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
441开启状态栏、导航栏属性变化的监听。
442
443**系统接口:** 此接口为系统接口。
444
445**系统能力:** SystemCapability.WindowManager.WindowManager.Core
446
447**参数:**
448
449| 参数名   | 类型                                                       | 必填 | 说明                                                         |
450| -------- | ---------------------------------------------------------- | ---- | ------------------------------------------------------------ |
451| type     | string                                                     | 是   | 监听事件,固定为'systemBarTintChange',即导航栏、状态栏属性变化事件。 |
452| callback | Callback&lt;[SystemBarTintState](#systembartintstate8)&gt; | 是   | 回调函数。返回当前的状态栏、导航栏信息集合。                 |
453
454**示例:**
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
470关闭状态栏、导航栏属性变化的监听。
471
472**系统接口:** 此接口为系统接口。
473
474**系统能力:** SystemCapability.WindowManager.WindowManager.Core
475
476**参数:**
477
478| 参数名   | 类型                                                       | 必填 | 说明                                                         |
479| -------- | ---------------------------------------------------------- | ---- | ------------------------------------------------------------ |
480| type     | string                                                     | 是   | 监听事件,固定为'systemBarTintChange',即导航栏、状态栏属性变化事件。 |
481| callback | Callback&lt;[SystemBarTintState](#systembartintstate8)&gt; | 否   | 回调函数。返回当前的状态栏、导航栏信息集合。如果传入参数,则关闭该监听。如果未传入参数,则关闭所有状态栏、导航栏属性变化的监听。                |
482
483**示例:**
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
497添加手势导航启用状态变化的监听。
498
499**系统接口:** 此接口为系统接口。
500
501**系统能力:** SystemCapability.WindowManager.WindowManager.Core
502
503**参数:**
504
505| 参数名   | 类型                     | 必填 | 说明                                                                          |
506| -------- | ----------------------- | ---- | ----------------------------------------------------------------------------- |
507| type     | string                  | 是   | 监听事件,固定为'gestureNavigationEnabledChange',即手势导航启用状态变化事件。    |
508| callback | Callback&lt;boolean&gt; | 是   | 回调函数。返回当前手势导航的启用状态。true表示手势导航状态变化为启用;false表示手势导航状态变化为禁用。 |
509
510**错误码:**
511
512以下错误码的详细介绍请参见[窗口错误码](errorcode-window.md)。
513
514| 错误码ID | 错误信息 |
515| ------- | -------------------------------------------- |
516| 1300002 | This window state is abnormal. |
517| 1300003 | This window manager service works abnormally. |
518
519**示例:**
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
535移除手势导航启用状态变化的监听。
536
537**系统接口:** 此接口为系统接口。
538
539**系统能力:** SystemCapability.WindowManager.WindowManager.Core
540
541**参数:**
542
543| 参数名   | 类型                     | 必填 | 说明                                                        |
544| -------- | ----------------------- | -- | ------------------------------------------------------------ |
545| type     | string                  | 是 | 监听事件,固定为'gestureNavigationEnabledChange',即手势导航启用状态变化事件。 |
546| callback | Callback&lt;boolean&gt; | 否 | 已注册的回调函数。如果传入参数,则关闭该监听。如果未传入参数,则关闭所有手势导航启用状态变化的监听。 |
547
548**错误码:**
549
550以下错误码的详细介绍请参见[窗口错误码](errorcode-window.md)。
551
552| 错误码ID | 错误信息 |
553| ------- | -------------------------------------------- |
554| 1300002 | This window state is abnormal. |
555| 1300003 | This window manager service works abnormally. |
556
557**示例:**
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
571添加水印启用状态变化的监听。
572
573**系统接口:** 此接口为系统接口。
574
575**系统能力:** SystemCapability.WindowManager.WindowManager.Core
576
577**参数:**
578
579| 参数名   | 类型                     | 必填 | 说明                                                                          |
580| -------- | ----------------------- | ---- | ----------------------------------------------------------------------------- |
581| type     | string                  | 是   | 监听事件,固定为'waterMarkFlagChange',即水印启用状态变化事件。    |
582| callback | Callback&lt;boolean&gt; | 是   | 回调函数。返回当前水印的启用状态。true表示当前已启用水印;false表示当前未启用水印。 |
583
584**错误码:**
585
586以下错误码的详细介绍请参见[窗口错误码](errorcode-window.md)。
587
588| 错误码ID | 错误信息 |
589| ------- | -------------------------------------------- |
590| 1300003 | This window manager service works abnormally. |
591
592**示例:**
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
608移除水印启用状态变化的监听。
609
610**系统接口:** 此接口为系统接口。
611
612**系统能力:** SystemCapability.WindowManager.WindowManager.Core
613
614**参数:**
615
616| 参数名   | 类型                     | 必填 | 说明                                                        |
617| -------- | ----------------------- | -- | ------------------------------------------------------------ |
618| type     | string                  | 是 | 监听事件,固定为'waterMarkFlagChange',即水印启用状态变化事件。 |
619| callback | Callback&lt;boolean&gt; | 否 | 已注册的回调函数。如果传入参数,则关闭该监听。如果未传入参数,则关闭所有水印启用状态变化的监听。 |
620
621**错误码:**
622
623以下错误码的详细介绍请参见[窗口错误码](errorcode-window.md)。
624
625| 错误码ID | 错误信息 |
626| ------- | -------------------------------------------- |
627| 1300003 | This window manager service works abnormally. |
628
629**示例:**
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
642设置手势导航启用状态。使用callback异步回调。
643
644**系统接口:** 此接口为系统接口。
645
646**系统能力:** SystemCapability.WindowManager.WindowManager.Core
647
648**参数:**
649
650| 参数名   | 类型                      | 必填 | 说明           |
651| -------- | ------------------------- | ---- | -------------- |
652| enable   | boolean                  | 是   | 设置手势导航启用状态。true表示启用手势导航;false表示禁用手势导航。 |
653| callback | AsyncCallback&lt;void&gt; | 是   | 回调信息。 |
654
655**错误码:**
656
657以下错误码的详细介绍请参见[窗口错误码](errorcode-window.md)。
658
659| 错误码ID | 错误信息 |
660| ------- | --------------------------------------------- |
661| 1300002 | This window state is abnormal.                |
662| 1300003 | This window manager service works abnormally. |
663
664**示例:**
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
686设置手势导航启用状态。使用Promise异步回调。
687
688**系统接口:** 此接口为系统接口。
689
690**系统能力:** SystemCapability.WindowManager.WindowManager.Core
691
692**参数:**
693
694| 参数名 | 类型     | 必填  | 说明                 |
695| ------ | ------- | ---- | -------------------- |
696| enable | boolean | 是   | 设置手势导航启用状态。true表示启用手势导航;false表示禁用手势导航。 |
697
698**返回值:**
699
700| 类型                | 说明                      |
701| ------------------- | ------------------------- |
702| Promise&lt;void&gt; | 无返回结果的Promise对象。 |
703
704**错误码:**
705
706以下错误码的详细介绍请参见[窗口错误码](errorcode-window.md)。
707
708| 错误码ID | 错误信息 |
709| ------- | -------------------------------------------- |
710| 1300002 | This window state is abnormal.                |
711| 1300003 | This window manager service works abnormally. |
712
713**示例:**
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
733设置水印图片显示状态。使用callback异步回调。
734
735**系统接口:** 此接口为系统接口。
736
737**系统能力:** SystemCapability.WindowManager.WindowManager.Core
738
739**参数:**
740
741| 参数名   | 类型                      | 必填 | 说明           |
742| -------- | ------------------------- | ---- | -------------- |
743| pixelMap | [image.PixelMap](../apis-image-kit/js-apis-image.md#pixelmap7) | 是 | 水印图片。 |
744| enable   | boolean                  | 是   | 设置是否显示水印图片。true显示水印图片;false表示不显示水印图片。 |
745| callback | AsyncCallback&lt;void&gt; | 是   | 回调信息。 |
746
747**错误码:**
748
749以下错误码的详细介绍请参见[窗口错误码](errorcode-window.md)。
750
751| 错误码ID | 错误信息 |
752| ------- | --------------------------------------------- |
753| 1300003 | This window manager service works abnormally. |
754
755**示例:**
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
791设置水印图片显示状态。使用Promise异步回调。
792
793**系统接口:** 此接口为系统接口。
794
795**系统能力:** SystemCapability.WindowManager.WindowManager.Core
796
797**参数:**
798
799| 参数名 | 类型                        | 必填  | 说明                 |
800| ------ | --------------------------- | ---- | -------------------- |
801| pixelMap | [image.PixelMap](../apis-image-kit/js-apis-image.md#pixelmap7) | 是 | 水印图片。 |
802| enable   | boolean                  | 是   | 设置是否显示水印图片。true显示水印图片;false表示不显示水印图片。 |
803
804**返回值:**
805
806| 类型                | 说明                      |
807| ------------------- | ------------------------- |
808| Promise&lt;void&gt; | 无返回结果的Promise对象。 |
809
810**错误码:**
811
812以下错误码的详细介绍请参见[窗口错误码](errorcode-window.md)。
813
814| 错误码ID | 错误信息 |
815| ------- | -------------------------------------------- |
816| 1300003 | This window manager service works abnormally. |
817
818**示例:**
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
851当前窗口实例,窗口管理器管理的基本单元。
852
853下列API示例中都需先使用[getLastWindow()](js-apis-window.md#windowgetlastwindow9)、[createWindow()](js-apis-window.md#windowcreatewindow9)、[findWindow()](js-apis-window.md#windowfindwindow9)中的任一方法获取到Window实例(windowClass),再通过此实例调用对应方法。
854
855### hide<sup>7+</sup>
856
857hide (callback: AsyncCallback&lt;void&gt;): void
858
859隐藏当前窗口,使用callback异步回调。
860
861**系统接口:** 此接口为系统接口。
862
863**系统能力:** SystemCapability.WindowManager.WindowManager.Core
864
865**参数:**
866
867| 参数名   | 类型                      | 必填 | 说明       |
868| -------- | ------------------------- | ---- | ---------- |
869| callback | AsyncCallback&lt;void&gt; | 是   | 回调函数。 |
870
871**错误码:**
872
873以下错误码的详细介绍请参见[窗口错误码](errorcode-window.md)。
874
875| 错误码ID | 错误信息 |
876| ------- | ------------------------------ |
877| 1300002 | This window state is abnormal. |
878
879**示例:**
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
898隐藏当前窗口,使用Promise异步回调。
899
900**系统接口:** 此接口为系统接口。
901
902**系统能力:** SystemCapability.WindowManager.WindowManager.Core
903
904**返回值:**
905
906| 类型                | 说明                      |
907| ------------------- | ------------------------- |
908| Promise&lt;void&gt; | 无返回结果的Promise对象。 |
909
910**错误码:**
911
912以下错误码的详细介绍请参见[窗口错误码](errorcode-window.md)。
913
914| 错误码ID | 错误信息 |
915| ------- | ------------------------------ |
916| 1300002 | This window state is abnormal. |
917
918**示例:**
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
935隐藏当前窗口,过程中播放动画,使用callback异步回调。
936
937**系统接口:** 此接口为系统接口。
938
939**系统能力:** SystemCapability.WindowManager.WindowManager.Core
940
941**参数:**
942
943| 参数名   | 类型                      | 必填 | 说明       |
944| -------- | ------------------------- | ---- | ---------- |
945| callback | AsyncCallback&lt;void&gt; | 是   | 回调函数。 |
946
947**错误码:**
948
949以下错误码的详细介绍请参见[窗口错误码](errorcode-window.md)。
950
951| 错误码ID | 错误信息 |
952| ------- | -------------------------------------------- |
953| 1300002 | This window state is abnormal.               |
954| 1300003 | This window manager service works abnormally. |
955| 1300004 | Unauthorized operation.                |
956
957**示例:**
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
976隐藏当前窗口,过程中播放动画,使用Promise异步回调。
977
978**系统接口:** 此接口为系统接口。
979
980**系统能力:** SystemCapability.WindowManager.WindowManager.Core
981
982**返回值:**
983
984| 类型                | 说明                      |
985| ------------------- | ------------------------- |
986| Promise&lt;void&gt; | 无返回结果的Promise对象。 |
987
988**错误码:**
989
990以下错误码的详细介绍请参见[窗口错误码](errorcode-window.md)。
991
992| 错误码ID | 错误信息 |
993| ------- | -------------------------------------------- |
994| 1300002 | This window state is abnormal.               |
995| 1300003 | This window manager service works abnormally. |
996| 1300004 | Unauthorized operation.                |
997
998**示例:**
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
1016显示当前窗口,过程中播放动画,使用callback异步回调。
1017
1018**系统接口:** 此接口为系统接口。
1019
1020**系统能力:** SystemCapability.WindowManager.WindowManager.Core
1021
1022**参数:**
1023
1024| 参数名   | 类型                      | 必填 | 说明       |
1025| -------- | ------------------------- | ---- | ---------- |
1026| callback | AsyncCallback&lt;void&gt; | 是   | 回调函数。 |
1027
1028**错误码:**
1029
1030以下错误码的详细介绍请参见[窗口错误码](errorcode-window.md)。
1031
1032| 错误码ID | 错误信息 |
1033| ------- | -------------------------------------------- |
1034| 1300002 | This window state is abnormal.               |
1035| 1300003 | This window manager service works abnormally. |
1036| 1300004 | Unauthorized operation.                |
1037
1038**示例:**
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
1057显示当前窗口,过程中播放动画,使用Promise异步回调。
1058
1059**系统接口:** 此接口为系统接口。
1060
1061**系统能力:** SystemCapability.WindowManager.WindowManager.Core
1062
1063**返回值:**
1064
1065| 类型                | 说明                      |
1066| ------------------- | ------------------------- |
1067| Promise&lt;void&gt; | 无返回结果的Promise对象。 |
1068
1069**错误码:**
1070
1071以下错误码的详细介绍请参见[窗口错误码](errorcode-window.md)。
1072
1073| 错误码ID | 错误信息 |
1074| ------- | -------------------------------------------- |
1075| 1300002 | This window state is abnormal.               |
1076| 1300003 | This window manager service works abnormally. |
1077| 1300004 | Unauthorized operation.                |
1078
1079**示例:**
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
1096设置窗口模式,使用callback异步回调。
1097
1098**系统接口:** 此接口为系统接口。
1099
1100**系统能力:** SystemCapability.WindowManager.WindowManager.Core
1101
1102**参数:**
1103
1104| 参数名 | 类型 | 必填 | 说明 |
1105| -------- | -------------------------- | -- | --------- |
1106| mode     | [WindowMode](#windowmode7) | 是 | 窗口模式。 |
1107| callback | AsyncCallback&lt;void&gt;  | 是 | 回调函数。 |
1108
1109**错误码:**
1110
1111以下错误码的详细介绍请参见[窗口错误码](errorcode-window.md)。
1112
1113| 错误码ID | 错误信息 |
1114| ------- | -------------------------------------------- |
1115| 1300002 | This window state is abnormal.               |
1116| 1300003 | This window manager service works abnormally. |
1117
1118**示例:**
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
1142设置窗口类型,使用Promise异步回调。
1143
1144**系统接口:** 此接口为系统接口。
1145
1146**系统能力:** SystemCapability.WindowManager.WindowManager.Core
1147
1148**参数:**
1149
1150| 参数名 | 类型 | 必填 | 说明 |
1151| -------- | -------------------------- | -- | --------- |
1152| mode     | [WindowMode](#windowmode7) | 是 | 窗口模式。 |
1153
1154**返回值:**
1155
1156| 类型 | 说明 |
1157| ------------------- | ----------------------- |
1158| Promise&lt;void&gt; | 无返回结果的Promise对象。 |
1159
1160**错误码:**
1161
1162以下错误码的详细介绍请参见[窗口错误码](errorcode-window.md)。
1163
1164| 错误码ID | 错误信息 |
1165| ------- | -------------------------------------------- |
1166| 1300002 | This window state is abnormal.               |
1167| 1300003 | This window manager service works abnormally. |
1168
1169**示例:**
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
1191绑定模态窗口与目标窗口并添加模态窗口销毁监听,使用callback异步回调。
1192
1193**系统接口:** 此接口为系统接口。
1194
1195**系统能力:** SystemCapability.WindowManager.WindowManager.Core
1196
1197**参数:**
1198
1199| 参数名       | 类型                      | 必填 | 说明                  |
1200| ----------- | ------------------------- | ---- | -------------------- |
1201| token       | [rpc.RemoteObject](../apis-ipc-kit/js-apis-rpc.md#remoteobject) | 是   | 目标窗口token值。 |
1202| deathCallback | Callback&lt;void&gt;        | 是   | 模态窗口销毁监听。 |
1203| callback    | AsyncCallback&lt;void&gt; | 是   | 回调函数。 |
1204
1205**错误码:**
1206
1207以下错误码的详细介绍请参见[窗口错误码](errorcode-window.md)。
1208
1209| 错误码ID | 错误信息 |
1210| ------- | -------------------------------------------- |
1211| 1300002 | This window state is abnormal.               |
1212| 1300003 | This window manager service works abnormally. |
1213
1214**示例:**
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
1275绑定模态窗口与目标窗口并添加模态窗口销毁监听,使用Promise异步回调。
1276
1277**系统接口:** 此接口为系统接口。
1278
1279**系统能力:** SystemCapability.WindowManager.WindowManager.Core
1280
1281**参数:**
1282
1283| 参数名       | 类型                      | 必填 | 说明                  |
1284| ----------- | ------------------------- | ---- | -------------------- |
1285| token       | [rpc.RemoteObject](../apis-ipc-kit/js-apis-rpc.md#remoteobject) | 是   | 目标窗口token值。 |
1286| deathCallback | Callback&lt;void&gt;        | 是   | 模态窗口销毁监听。 |
1287
1288**返回值:**
1289
1290| 类型                | 说明                      |
1291| ------------------- | ------------------------- |
1292| Promise&lt;void&gt; | 无返回结果的Promise对象。 |
1293
1294**错误码:**
1295
1296以下错误码的详细介绍请参见[窗口错误码](errorcode-window.md)。
1297
1298| 错误码ID | 错误信息 |
1299| ------- | -------------------------------------------- |
1300| 1300002 | This window state is abnormal.               |
1301| 1300003 | This window manager service works abnormally. |
1302
1303**示例:**
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
1366绑定模态窗口与目标窗口并添加模态窗口销毁监听,使用callback异步回调。
1367
1368**系统接口:** 此接口为系统接口。
1369
1370**系统能力:** SystemCapability.WindowManager.WindowManager.Core
1371
1372**参数:**
1373
1374| 参数名       | 类型                      | 必填 | 说明                  |
1375| ----------- | ------------------------- | ---- | -------------------- |
1376| requestInfo | [dialogRequest.RequestInfo](../apis-ability-kit/js-apis-app-ability-dialogRequest.md#requestinfo) | 是   | 目标窗口RequestInfo值。 |
1377| deathCallback | Callback&lt;void&gt;    | 是   | 模态窗口销毁监听。 |
1378| callback    | AsyncCallback&lt;void&gt; | 是   | 回调函数。 |
1379
1380**错误码:**
1381
1382以下错误码的详细介绍请参见[窗口错误码](errorcode-window.md)。
1383
1384| 错误码ID | 错误信息 |
1385| ------- | -------------------------------------------- |
1386| 1300002 | This window state is abnormal.               |
1387| 1300003 | This window manager service works abnormally. |
1388
1389**示例:**
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
1435绑定模态窗口与目标窗口并添加模态窗口销毁监听,使用Promise异步回调。
1436
1437**系统接口:** 此接口为系统接口。
1438
1439**系统能力:** SystemCapability.WindowManager.WindowManager.Core
1440
1441**参数:**
1442
1443| 参数名       | 类型                      | 必填 | 说明                  |
1444| ----------- | ------------------------- | ---- | -------------------- |
1445| requestInfo | [dialogRequest.RequestInfo](../apis-ability-kit/js-apis-app-ability-dialogRequest.md#requestinfo) | 是   | 目标窗口RequestInfo值。 |
1446| deathCallback | Callback&lt;void&gt;    | 是   | 模态窗口销毁监听。 |
1447
1448**返回值:**
1449
1450| 类型                | 说明                      |
1451| ------------------- | ------------------------- |
1452| Promise&lt;void&gt; | 无返回结果的Promise对象。 |
1453
1454**错误码:**
1455
1456以下错误码的详细介绍请参见[窗口错误码](errorcode-window.md)。
1457
1458| 错误码ID | 错误信息 |
1459| ------- | -------------------------------------------- |
1460| 1300002 | This window state is abnormal.               |
1461| 1300003 | This window manager service works abnormally. |
1462
1463**示例:**
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
1507窗口唤醒屏幕。
1508
1509**系统接口:** 此接口为系统接口。
1510
1511**系统能力:** SystemCapability.WindowManager.WindowManager.Core
1512
1513**参数:**
1514
1515| 参数名           | 类型    | 必填 | 说明                         |
1516| ---------------- | ------- | ---- | ---------------------------- |
1517| wakeUp           | boolean | 是   | 是否设置唤醒屏幕。true表示唤醒;false表示不唤醒。  |
1518
1519**错误码:**
1520
1521以下错误码的详细介绍请参见[窗口错误码](errorcode-window.md)。
1522
1523| 错误码ID | 错误信息 |
1524| ------- | -------------------------------------------- |
1525| 1300002 | This window state is abnormal.               |
1526| 1300003 | This window manager service works abnormally. |
1527
1528**示例:**
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
1542截屏录屏是否忽略当前窗口。此接口一般用于禁止截屏/录屏的场景。
1543
1544**系统接口:** 此接口为系统接口。
1545
1546**系统能力:** SystemCapability.WindowManager.WindowManager.Core
1547
1548**参数:**
1549
1550| 参数名        | 类型    | 必填 | 说明                 |
1551| ------------- | ------- | ---- | -------------------- |
1552| isSkip | boolean | 是   | 截屏录屏是否忽略当前窗口,默认为false。<br>true表示忽略当前窗口,false表示不忽略当前窗口。</br> |
1553
1554**错误码:**
1555
1556以下错误码的详细介绍请参见[窗口错误码](errorcode-window.md)。
1557
1558| 错误码ID | 错误信息 |
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
1575设置窗口在分屏模式下是否被禁止移动,使用callback异步回调。
1576
1577**系统接口:** 此接口为系统接口。
1578
1579**系统能力:** SystemCapability.WindowManager.WindowManager.Core
1580
1581**参数:**
1582
1583| 参数名      | 类型                      | 必填 | 说明                 |
1584| ----------- | ------------------------- | ---- | -------------------- |
1585| isForbidSplitMove | boolean                   | 是   | 窗口在分屏模式下是否被禁止移动。true表示禁止;false表示不禁止。 |
1586| callback    | AsyncCallback&lt;void&gt; | 是   | 回调函数。           |
1587
1588**错误码:**
1589
1590以下错误码的详细介绍请参见[窗口错误码](errorcode-window.md)。
1591
1592| 错误码ID | 错误信息 |
1593| ------- | -------------------------------------------- |
1594| 1300002 | This window state is abnormal.               |
1595| 1300003 | This window manager service works abnormally. |
1596
1597**示例:**
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
1621设置窗口在分屏模式下是否被禁止移动,使用Promise异步回调。
1622
1623**系统接口:** 此接口为系统接口。
1624
1625**系统能力:** SystemCapability.WindowManager.WindowManager.Core
1626
1627**参数:**
1628
1629| 参数名      | 类型    | 必填 | 说明                 |
1630| ----------- | ------- | ---- | -------------------- |
1631| isForbidSplitMove | boolean | 是   | 窗口在分屏模式下是否被禁止移动。true表示禁止;false表示不禁止。 |
1632
1633**返回值:**
1634
1635| 类型                | 说明                      |
1636| ------------------- | ------------------------- |
1637| Promise&lt;void&gt; | 无返回结果的Promise对象。 |
1638
1639**错误码:**
1640
1641以下错误码的详细介绍请参见[窗口错误码](errorcode-window.md)。
1642
1643| 错误码ID | 错误信息 |
1644| ------- | -------------------------------------------- |
1645| 1300002 | This window state is abnormal.               |
1646| 1300003 | This window manager service works abnormally. |
1647
1648**示例:**
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
1670设置窗口不透明度。仅支持在[自定义系统窗口的显示与隐藏动画](../../windowmanager/system-window-stage.md#自定义系统窗口的显示与隐藏动画)中使用。
1671
1672**系统接口:** 此接口为系统接口。
1673
1674**系统能力:** SystemCapability.WindowManager.WindowManager.Core
1675
1676**参数:**
1677
1678| 参数名  | 类型   | 必填 | 说明                                                 |
1679| ------- | ------ | ---- |----------------------------------------------------|
1680| opacity | number | 是   | 不透明度。该参数为浮点数,取值范围为[0.0, 1.0]。0.0表示完全透明,1.0表示完全不透明。 |
1681
1682**错误码:**
1683
1684以下错误码的详细介绍请参见[窗口错误码](errorcode-window.md)。
1685
1686| 错误码ID | 错误信息 |
1687| ------- | ------------------------------ |
1688| 1300002 | This window state is abnormal. |
1689| 1300004 | Unauthorized operation.  |
1690
1691**示例:**
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
1705设置窗口缩放参数。仅支持在[自定义系统窗口的显示与隐藏动画](../../windowmanager/system-window-stage.md#自定义系统窗口的显示与隐藏动画)中使用。
1706
1707**系统接口:** 此接口为系统接口。
1708
1709**系统能力:** SystemCapability.WindowManager.WindowManager.Core
1710
1711**参数:**
1712
1713| 参数名       | 类型                           | 必填 | 说明       |
1714| ------------ | ------------------------------ | ---- | ---------- |
1715| scaleOptions | [ScaleOptions](#scaleoptions9) | 是   | 缩放参数。 |
1716
1717**错误码:**
1718
1719以下错误码的详细介绍请参见[窗口错误码](errorcode-window.md)。
1720
1721| 错误码ID | 错误信息 |
1722| ------- | ------------------------------ |
1723| 1300002 | This window state is abnormal. |
1724| 1300004 | Unauthorized operation.  |
1725
1726**示例:**
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
1746设置窗口旋转参数。仅支持在[自定义系统窗口的显示与隐藏动画](../../windowmanager/system-window-stage.md#自定义系统窗口的显示与隐藏动画)中使用。
1747
1748**系统接口:** 此接口为系统接口。
1749
1750**系统能力:** SystemCapability.WindowManager.WindowManager.Core
1751
1752**参数:**
1753
1754| 参数名        | 类型                             | 必填 | 说明       |
1755| ------------- | -------------------------------- | ---- | ---------- |
1756| rotateOptions | [RotateOptions](#rotateoptions9) | 是   | 旋转参数。 |
1757
1758**错误码:**
1759
1760以下错误码的详细介绍请参见[窗口错误码](errorcode-window.md)。
1761
1762| 错误码ID | 错误信息 |
1763| ------- | ------------------------------ |
1764| 1300002 | This window state is abnormal. |
1765| 1300004 | Unauthorized operation.  |
1766
1767**示例:**
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
1788设置窗口平移参数。仅支持在[自定义系统窗口的显示与隐藏动画](../../windowmanager/system-window-stage.md#自定义系统窗口的显示与隐藏动画)中使用。
1789
1790**系统接口:** 此接口为系统接口。
1791
1792**系统能力:** SystemCapability.WindowManager.WindowManager.Core
1793
1794**参数:**
1795
1796| 参数名           | 类型                                   | 必填 | 说明                 |
1797| ---------------- | -------------------------------------- | ---- | -------------------- |
1798| translateOptions | [TranslateOptions](#translateoptions9) | 是   | 平移参数,单位为px。 |
1799
1800**错误码:**
1801
1802以下错误码的详细介绍请参见[窗口错误码](errorcode-window.md)。
1803
1804| 错误码ID | 错误信息 |
1805| ------- | ------------------------------ |
1806| 1300002 | This window state is abnormal. |
1807| 1300004 | Unauthorized operation.  |
1808
1809**示例:**
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
1828获取窗口属性转换控制器。
1829
1830**系统接口:** 此接口为系统接口。
1831
1832**系统能力:** SystemCapability.WindowManager.WindowManager.Core
1833
1834**返回值:**
1835
1836| 类型                                           | 说明             |
1837| ---------------------------------------------- | ---------------- |
1838| [TransitionController](#transitioncontroller9) | 属性转换控制器。 |
1839
1840**错误码:**
1841
1842以下错误码的详细介绍请参见[窗口错误码](errorcode-window.md)。
1843
1844| 错误码ID | 错误信息 |
1845| ------- | ------------------------------ |
1846| 1300002 | This window state is abnormal. |
1847| 1300004 | Unauthorized operation.  |
1848
1849**示例:**
1850
1851```ts
1852let controller = windowClass.getTransitionController(); // 获取属性转换控制器
1853```
1854
1855### setBlur<sup>9+</sup>
1856
1857setBlur(radius: number): void
1858
1859设置窗口模糊。
1860
1861**系统接口:** 此接口为系统接口。
1862
1863**系统能力:** SystemCapability.WindowManager.WindowManager.Core
1864
1865**参数:**
1866
1867| 参数名 | 类型   | 必填 | 说明                                               |
1868| ------ | ------ | ---- |--------------------------------------------------|
1869| radius | number | 是   | 表示窗口模糊的半径值。该参数为浮点数,单位为px,取值范围为[0, +∞),取值为0.0时表示关闭窗口模糊。 |
1870
1871**错误码:**
1872
1873以下错误码的详细介绍请参见[窗口错误码](errorcode-window.md)。
1874
1875| 错误码ID | 错误信息 |
1876| ------- | ------------------------------ |
1877| 1300002 | This window state is abnormal. |
1878| 1300004 | Unauthorized operation.  |
1879
1880**示例:**
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
1894设置窗口背景模糊。
1895
1896**系统接口:** 此接口为系统接口。
1897
1898**系统能力:** SystemCapability.WindowManager.WindowManager.Core
1899
1900**参数:**
1901
1902| 参数名 | 类型   | 必填 | 说明                                                    |
1903| ------ | ------ | ---- |-------------------------------------------------------|
1904| radius | number | 是   | 表示窗口背景模糊的半径值。该参数为浮点数,单位为px,取值范围为[0.0, +∞),取值为0.0表示关闭窗口背景模糊。 |
1905
1906**错误码:**
1907
1908以下错误码的详细介绍请参见[窗口错误码](errorcode-window.md)。
1909
1910| 错误码ID | 错误信息 |
1911| ------- | ------------------------------ |
1912| 1300002 | This window state is abnormal. |
1913| 1300004 | Unauthorized operation.  |
1914
1915**示例:**
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
1929设置窗口背景模糊类型。
1930
1931**系统接口:** 此接口为系统接口。
1932
1933**系统能力:** SystemCapability.WindowManager.WindowManager.Core
1934
1935**参数:**
1936
1937| 参数名    | 类型      | 必填 | 说明                   |
1938| --------- | --------- | ---- | ---------------------- |
1939| blurStyle | [BlurStyle](#blurstyle9) | 是   | 表示窗口背景模糊类型。 |
1940
1941**错误码:**
1942
1943以下错误码的详细介绍请参见[窗口错误码](errorcode-window.md)。
1944
1945| 错误码ID | 错误信息 |
1946| ------- | ------------------------------ |
1947| 1300002 | This window state is abnormal. |
1948| 1300004 | Unauthorized operation.  |
1949
1950**示例:**
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
1964设置窗口边缘阴影。
1965
1966**系统接口:** 此接口为系统接口。
1967
1968**系统能力:** SystemCapability.WindowManager.WindowManager.Core
1969
1970**参数:**
1971
1972| 参数名  | 类型   | 必填 | 说明                                                          |
1973| ------- | ------ | ---- |-------------------------------------------------------------|
1974| radius  | number | 是   | 表示窗口边缘阴影的模糊半径。该参数为浮点数,单位为px,取值范围为[0.0, +∞),取值为0.0时表示关闭窗口边缘阴影。     |
1975| color   | string | 否   | 表示窗口边缘阴影的颜色,为十六进制RGB或ARGB颜色,不区分大小写,例如`#00FF00`或`#FF00FF00`。 |
1976| offsetX | number | 否   | 表示窗口边缘阴影的X轴的偏移量。该参数为浮点数,单位为px。                              |
1977| offsetY | number | 否   | 表示窗口边缘阴影的Y轴的偏移量。该参数为浮点数,单位为px。                              |
1978
1979**错误码:**
1980
1981以下错误码的详细介绍请参见[窗口错误码](errorcode-window.md)。
1982
1983| 错误码ID | 错误信息 |
1984| ------- | ------------------------------ |
1985| 1300002 | This window state is abnormal. |
1986| 1300004 | Unauthorized operation.  |
1987
1988**示例:**
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
2002设置窗口圆角半径。
2003
2004**系统接口:** 此接口为系统接口。
2005
2006**系统能力:** SystemCapability.WindowManager.WindowManager.Core
2007
2008**参数:**
2009
2010| 参数名      | 类型    | 必填 | 说明                                                 |
2011| ----------- | ------- | ---- |----------------------------------------------------|
2012| radius | number | 是   | 表示窗口圆角的半径值。该参数为浮点数,单位为px,取值范围为[0.0, +∞),取值为0.0时表示没有窗口圆角。 |
2013
2014**错误码:**
2015
2016以下错误码的详细介绍请参见[窗口错误码](errorcode-window.md)。
2017
2018| 错误码ID | 错误信息 |
2019| ------- | ------------------------------ |
2020| 1300002 | This window state is abnormal. |
2021| 1300004 | Unauthorized operation.  |
2022
2023**示例:**
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
2037提升应用子窗口到应用顶层。使用callback异步回调。
2038
2039**系统接口:** 此接口为系统接口。
2040
2041**系统能力:** SystemCapability.WindowManager.WindowManager.Core
2042
2043**参数:**
2044
2045| 参数名   | 类型                      | 必填 | 说明       |
2046| -------- | ------------------------- | ---- | ---------- |
2047| callback | AsyncCallback&lt;void&gt; | 是   | 回调函数。 |
2048
2049**错误码:**
2050
2051以下错误码的详细介绍请参见[窗口错误码](errorcode-window.md)。
2052
2053| 错误码ID | 错误信息 |
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**示例:**
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
2079提升应用子窗口到应用顶层。使用Promise异步回调。
2080
2081**系统接口:** 此接口为系统接口。
2082
2083**系统能力:** SystemCapability.WindowManager.WindowManager.Core
2084
2085**返回值:**
2086
2087| 类型                | 说明                      |
2088| ------------------- | ------------------------- |
2089| Promise&lt;void&gt; | 无返回结果的Promise对象。 |
2090
2091**错误码:**
2092
2093以下错误码的详细介绍请参见[窗口错误码](errorcode-window.md)。
2094
2095| 错误码ID | 错误信息 |
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**示例:**
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
2119为当前窗口添加或删除安全水印标志,使用Promise异步回调。
2120
2121**系统接口:** 此接口为系统接口。
2122
2123**系统能力:** SystemCapability.WindowManager.WindowManager.Core
2124
2125**参数:**
2126
2127| 参数名 | 类型     | 必填 | 说明                                            |
2128| ------ | ------- | --- | ------------------------------------------------ |
2129| enable | boolean | 是   | 是否对窗口添加标志位。true表示添加,false表示删除。 |
2130
2131**返回值:**
2132
2133| 类型                | 说明                      |
2134| ------------------- | ------------------------- |
2135| Promise&lt;void&gt; | 无返回结果的Promise对象。 |
2136
2137**错误码:**
2138
2139以下错误码的详细介绍请参见[窗口错误码](errorcode-window.md)。
2140
2141| 错误码ID | 错误信息 |
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**示例:**
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
2169为当前窗口添加或删除安全水印标志,使用callback异步回调。
2170
2171**系统接口:** 此接口为系统接口。
2172
2173**系统能力:** SystemCapability.WindowManager.WindowManager.Core
2174
2175**参数:**
2176
2177| 参数名   | 类型                       | 必填 | 说明                                              |
2178| -------- | ------------------------- | ---  | ----------------------------------------------- |
2179| enable   | boolean                   | 是   | 是否对窗口添加标志位。true表示添加,false表示删除。 |
2180| callback | AsyncCallback&lt;void&gt; | 是   | 回调函数。           |
2181
2182**错误码:**
2183
2184以下错误码的详细介绍请参见[窗口错误码](errorcode-window.md)。
2185
2186| 错误码ID | 错误信息 |
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**示例:**
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
2215将同一个主窗口下的子窗口提升到目标子窗口之上。使用callback异步回调。
2216
2217**系统接口:** 此接口为系统接口。
2218
2219**系统能力:** SystemCapability.Window.SessionManager
2220
2221**参数:**
2222
2223| 参数名   | 类型                      | 必填 | 说明       |
2224| -------- | ------------------------- | ---- | ---------- |
2225| windowId | number                    | 是   | 目标子窗口的id,通过[getWindowProperties](js-apis-window.md#getwindowproperties9)接口获取到[properties](js-apis-window.md#windowproperties)后,再通过properties.id获取 |
2226| callback | AsyncCallback&lt;void&gt; | 是   | 回调函数。 |
2227
2228**错误码:**
2229
2230以下错误码的详细介绍请参见[窗口错误码](errorcode-window.md)。
2231
2232| 错误码ID | 错误信息 |
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**示例:**
2240
2241```js
2242// windowClass的获取需放在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
2259将同一个主窗下的子窗口提升到目标子窗口之上。使用Promise异步回调。
2260
2261**系统接口:** 此接口为系统接口。
2262
2263**系统能力:** SystemCapability.Window.SessionManager
2264
2265**参数:**
2266
2267| 参数名   | 类型                      | 必填 | 说明       |
2268| -------- | ------------------------- | ---- | ---------- |
2269| windowId | number                    | 是   | 目标子窗口的id,通过[getWindowProperties](js-apis-window.md#getwindowproperties9)接口获取到[properties](js-apis-window.md#windowproperties)后,再通过properties.id获取 |
2270
2271**返回值:**
2272
2273| 类型                | 说明                      |
2274| ------------------- | ------------------------- |
2275| Promise&lt;void&gt; | 无返回结果的Promise对象。 |
2276
2277**错误码:**
2278
2279以下错误码的详细介绍请参见[窗口错误码](errorcode-window.md)。
2280
2281| 错误码ID | 错误信息 |
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**示例:**
2289
2290```js
2291// windowClass的获取需放在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
2306禁止/使能子窗口点击抬升功能。使用callback异步回调。
2307
2308通常来说,点击一个子窗口,会将该子窗口显示到最上方,如果设置为false,那么点击子窗口的时候,不会将该子窗口显示到最上方,而是保持不变。
2309
2310**系统接口:** 此接口为系统接口。
2311
2312**系统能力:** SystemCapability.Window.SessionManager
2313
2314**参数:**
2315
2316| 参数名   | 类型                      | 必填 | 说明       |
2317| -------- | ------------------------- | ---- | ---------- |
2318| enable   | boolean                   | 是   | 设置子窗口点击抬升功能是否使能,true表示使能,false表示禁止。 |
2319| callback | AsyncCallback&lt;void&gt; | 是   | 回调函数。 |
2320
2321**错误码:**
2322
2323以下错误码的详细介绍请参见[窗口错误码](errorcode-window.md)。
2324
2325| 错误码ID | 错误信息 |
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**示例:**
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
2349禁止/使能子窗点击抬升功能。使用Promise异步回调。
2350
2351通常来说,点击一个子窗口,会将该子窗口显示到最上方,如果设置为false,那么点击子窗口的时候,不会将该子窗口显示到最上方,而是保持不变。
2352
2353**系统接口:** 此接口为系统接口。
2354
2355**系统能力:** SystemCapability.Window.SessionManager
2356
2357**参数:**
2358
2359| 参数名   | 类型                      | 必填 | 说明       |
2360| -------- | ------------------------- | ---- | ---------- |
2361| enable   | boolean                   | 是   | 设置子窗口点击抬升功能是否使能,true表示使能,false表示禁止。 |
2362
2363**返回值:**
2364
2365| 类型                | 说明                      |
2366| ------------------- | ------------------------- |
2367| Promise&lt;void&gt; | 无返回结果的Promise对象。 |
2368
2369**错误码:**
2370
2371以下错误码的详细介绍请参见[窗口错误码](errorcode-window.md)。
2372
2373| 错误码ID | 错误信息 |
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**示例:**
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
2396禁止/使能通过拖拽方式缩放主窗口的功能。使用callback异步回调。
2397
2398**系统接口:** 此接口为系统接口。
2399
2400**系统能力:** SystemCapability.Window.SessionManager
2401
2402**参数:**
2403
2404| 参数名   | 类型                      | 必填 | 说明       |
2405| -------- | ------------------------- | ---- | ---------- |
2406| enable   | boolean                   | 是   | 设置窗口是否使能通过拖拽进行缩放,true表示使能,false表示禁止。 |
2407| callback | AsyncCallback&lt;void&gt; | 是   | 回调函数。 |
2408
2409**错误码:**
2410
2411以下错误码的详细介绍请参见[窗口错误码](errorcode-window.md)。
2412
2413| 错误码ID | 错误信息 |
2414| ------- | ------------------------------ |
2415| 1300002 | This window state is abnormal. |
2416| 1300003 | This window manager service works abnormally. |
2417
2418**示例:**
2419
2420```js
2421import UIAbility from '@ohos.app.ability.UIAbility';
2422
2423export default class EntryAbility extends UIAbility {
2424    onWindowStageCreate(windowStage) {
2425        // 为主窗口加载对应的目标页面。
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        // 获取应用主窗口。
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            // 调用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
2462禁止/使能通过拖拽方式缩放主窗口的功能。使用Promise异步回调。
2463
2464**系统接口:** 此接口为系统接口。
2465
2466**系统能力:** SystemCapability.Window.SessionManager
2467
2468**参数:**
2469
2470| 参数名   | 类型                      | 必填 | 说明       |
2471| -------- | ------------------------- | ---- | ---------- |
2472| enable   | boolean                   | 是   | 设置窗口是否使能通过拖拽进行缩放,true表示使能,false表示禁止。 |
2473
2474**返回值:**
2475
2476| 类型                | 说明                      |
2477| ------------------- | ------------------------- |
2478| Promise&lt;void&gt; | 无返回结果的Promise对象。 |
2479
2480**错误码:**
2481
2482以下错误码的详细介绍请参见[窗口错误码](errorcode-window.md)。
2483
2484| 错误码ID | 错误信息 |
2485| ------- | ------------------------------ |
2486| 1300002 | This window state is abnormal. |
2487| 1300003 | This window manager service works abnormally. |
2488
2489**示例:**
2490
2491```js
2492import UIAbility from '@ohos.app.ability.UIAbility';
2493
2494export default class EntryAbility extends UIAbility {
2495    onWindowStageCreate(windowStage) {
2496        // 为主窗口加载对应的目标页面。
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        // 获取应用主窗口。
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            // 获取setResizeByDragEnabled接口的promise对象
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
2532设置是否隐藏非系统级悬浮窗口。使用callback异步回调。
2533
2534非系统级悬浮窗口是指非系统应用创建的悬浮窗口。默认情况下,一个系统应用主窗口可以与非系统级悬浮窗口共同显示,即该主窗口可以被上层的非系统级悬浮窗口遮挡,如果设置为true,则所有的非系统级悬浮窗口会被隐藏,此时该主窗口就不会被上层的非系统级悬浮窗口遮挡了。
2535
2536**系统接口:** 此接口为系统接口。
2537
2538**系统能力:** SystemCapability.Window.SessionManager
2539
2540**参数:**
2541
2542| 参数名      | 类型                      | 必填 | 说明       |
2543| ----------- | ------------------------- | ---- | ---------- |
2544| shouldHide  | boolean                   | 是   | 指示是否隐藏非系统级的悬浮窗口,true表示隐藏,false表示不隐藏。 |
2545| callback    | AsyncCallback&lt;void&gt; | 是   | 回调函数。 |
2546
2547**错误码:**
2548
2549以下错误码的详细介绍请参见[窗口错误码](errorcode-window.md)。
2550
2551| 错误码ID | 错误信息 |
2552| ------- | ------------------------------ |
2553| 1300002 | This window state is abnormal. |
2554| 1300003 | This window manager service works abnormally. |
2555| 1300004 | Unauthorized operation. |
2556
2557**示例:**
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    // 加载主窗口对应的页面
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    // 获取应用主窗口。
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      // 调用带callback参数的hideNonSystemFloatingWindows接口
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
2602设置是否隐藏非系统级悬浮窗口。使用callback异步回调。
2603
2604非系统级悬浮窗口是指非系统应用创建的悬浮窗口。默认情况下,一个系统应用主窗口可以与非系统级悬浮窗口共同显示,即该主窗口可以被上层的非系统级悬浮窗口遮挡,如果设置为true,则所有的非系统级悬浮窗口会被隐藏,此时该主窗口就不会被上层的非系统级悬浮窗口遮挡了。
2605
2606**系统接口:** 此接口为系统接口。
2607
2608**系统能力:** SystemCapability.Window.SessionManager
2609
2610**参数:**
2611
2612| 参数名      | 类型                      | 必填 | 说明       |
2613| ----------- | ------------------------- | ---- | ---------- |
2614| shouldHide  | boolean                   | 是   | 指示是否隐藏非系统级的悬浮窗口,true表示隐藏,false表示不隐藏。 |
2615
2616**返回值:**
2617
2618| 类型                | 说明                      |
2619| ------------------- | ------------------------- |
2620| Promise&lt;void&gt; | 无返回结果的Promise对象。 |
2621
2622**错误码:**
2623
2624以下错误码的详细介绍请参见[窗口错误码](errorcode-window.md)。
2625
2626| 错误码ID | 错误信息 |
2627| ------- | ------------------------------ |
2628| 1300002 | This window state is abnormal. |
2629| 1300003 | This window manager service works abnormally. |
2630| 1300004 | Unauthorized operation. |
2631
2632**示例:**
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    // 加载主窗口对应的页面
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    // 获取应用主窗口。
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      // 调用hideNonSystemFloatingWindows接口,获取promise对象
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
2676禁止/使能单帧合成渲染节点的功能。使用Promise异步回调。
2677
2678单帧合成渲染节点的功能主要用于跟手性要求较高的场景,使能该功能之后可以降低渲染节点的上屏延时。通过setSingleFrameComposerEnabled接口,如果enable设置为true,则使能单帧合成渲染节点的功能,否则禁止单帧合成渲染节点的功能。
2679
2680**系统接口:** 此接口为系统接口。
2681
2682**系统能力:** SystemCapability.Window.SessionManager
2683
2684**参数:**
2685
2686| 参数名   | 类型                      | 必填 | 说明       |
2687| -------- | ------------------------- | ---- | ---------- |
2688| enable   | boolean                   | 是   | 设置单帧合成渲染节点的功能是否使能,true表示使能,false表示禁止。 |
2689
2690**返回值:**
2691
2692| 类型                | 说明                      |
2693| ------------------- | ------------------------- |
2694| Promise&lt;void&gt; | 无返回结果的Promise对象。 |
2695
2696**错误码:**
2697
2698以下错误码的详细介绍请参见[窗口错误码](errorcode-window.md)。
2699
2700| 错误码ID | 错误信息 |
2701| ------- | ------------------------------ |
2702| 1300002 | This window state is abnormal. |
2703
2704**示例:**
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
2722设置窗口类型,使用callback异步回调。
2723
2724**系统接口:** 此接口为系统接口。
2725
2726> **说明:**
2727>
2728> 从 API version 7开始支持,从API version 9开始废弃。
2729
2730**系统能力:** SystemCapability.WindowManager.WindowManager.Core
2731
2732**参数:**
2733
2734| 参数名   | 类型                      | 必填 | 说明       |
2735| -------- | ------------------------- | ---- | ---------- |
2736| type     | [WindowType](#windowtype7) | 是   | 窗口类型。 |
2737| callback | AsyncCallback&lt;void&gt; | 是   | 回调函数。 |
2738
2739**示例:**
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
2759设置窗口类型,使用Promise异步回调。
2760
2761**系统接口:** 此接口为系统接口。
2762
2763> **说明:**
2764>
2765> 从 API version 7开始支持,从API version 9开始废弃。
2766
2767**系统能力:** SystemCapability.WindowManager.WindowManager.Core
2768
2769**参数:**
2770
2771| 参数名 | 类型                      | 必填 | 说明       |
2772| ------ | ------------------------- | ---- | ---------- |
2773| type   | [WindowType](#windowtype7) | 是   | 窗口类型。 |
2774
2775**返回值:**
2776
2777| 类型                | 说明                      |
2778| ------------------- | ------------------------- |
2779| Promise&lt;void&gt; | 无返回结果的Promise对象。 |
2780
2781**示例:**
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
2797窗口管理器。管理各个基本窗口单元,即[Window](#window)实例。
2798
2799下列API示例中都需在[onWindowStageCreate()](../apis-ability-kit/js-apis-app-ability-uiAbility.md#uiabilityonwindowstagecreate)函数中使用WindowStage的实例调用对应方法。
2800
2801### disableWindowDecor()<sup>9+</sup>
2802
2803disableWindowDecor(): void
2804
2805禁止窗口装饰。
2806
2807**模型约束:** 此接口仅可在Stage模型下使用。
2808
2809**系统接口:** 此接口为系统接口。
2810
2811**系统能力:** SystemCapability.WindowManager.WindowManager.Core
2812
2813**错误码:**
2814
2815以下错误码的详细介绍请参见[窗口错误码](errorcode-window.md)。
2816
2817| 错误码ID | 错误信息 |
2818| ------- | ------------------------------ |
2819| 1300002 | This window state is abnormal. |
2820| 1300005 | This window stage is abnormal. |
2821
2822**示例:**
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
2842设置应用显示在锁屏之上。
2843
2844**系统接口:** 此接口为系统接口。
2845
2846**模型约束:** 此接口仅可在Stage模型下使用。
2847
2848**系统能力:** SystemCapability.WindowManager.WindowManager.Core
2849
2850**参数:**
2851
2852| 参数名           | 类型    | 必填 | 说明                         |
2853| ---------------- | ------- | ---- | ---------------------------- |
2854| showOnLockScreen | boolean | 是   | 是否设置应用显示在锁屏之上。true表示显示在锁屏之上;false表示不显示在锁屏之上。 |
2855
2856**错误码:**
2857
2858以下错误码的详细介绍请参见[窗口错误码](errorcode-window.md)。
2859
2860| 错误码ID | 错误信息 |
2861| ------- | ------------------------------ |
2862| 1300002 | This window state is abnormal. |
2863| 1300005 | This window stage is abnormal. |
2864
2865**示例:**
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
2886属性转换的上下文信息。
2887
2888**系统接口:** 此接口为系统接口。
2889
2890### 属性
2891
2892**系统接口:** 此接口为系统接口。
2893
2894**系统能力**:SystemCapability.WindowManager.WindowManager.Core
2895
2896| 名称                  | 类型          | 可读 | 可写 | 说明             |
2897| --------------------- | ----------------- | ---- | ---- | ---------------- |
2898| toWindow<sup>9+</sup> | [Window](#window) | 是   | 是   | 动画的目标窗口。 |
2899
2900### completeTransition<sup>9+</sup>
2901
2902completeTransition(isCompleted: boolean): void
2903
2904设置属性转换的最终完成状态。该函数需要在动画函数[animateTo()](arkui-ts/ts-explicit-animation.md)执行后设置。
2905
2906**系统接口:** 此接口为系统接口。
2907
2908**系统能力**:SystemCapability.WindowManager.WindowManager.Core
2909
2910**参数:**
2911
2912| 参数名      | 类型    | 必填 | 说明                                                         |
2913| ----------- | ------- | ---- | ------------------------------------------------------------ |
2914| isCompleted | boolean | 是   | 窗口属性转换是否完成。true表示完成本次转换;false表示撤销本次转换。 |
2915
2916**示例:**
2917
2918```ts
2919(context: window.TransitionContext) => {
2920  let toWindow: window.Window = context.toWindow;
2921  animateTo({
2922    duration: 1000, // 动画时长
2923    tempo: 0.5, // 播放速率
2924    curve: Curve.EaseInOut, // 动画曲线
2925    delay: 0, // 动画延迟
2926    iterations: 1, // 播放次数
2927    playMode: PlayMode.Normal, // 动画模式
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
2949属性转换控制器。使用其子接口之前得先创建系统窗口,参照示例代码。
2950
2951**系统接口:** 此接口为系统接口。
2952
2953**示例:**
2954
2955```ts
2956import { BusinessError } from '@ohos.base';
2957
2958let windowClass: window.Window | undefined = undefined;
2959let config: window.Configuration = {
2960  name: "systemTypeWindow",
2961  windowType: window.WindowType.TYPE_PANEL, //根据需要自选系统窗口类型
2962  ctx: this.context
2963};
2964try {
2965  let promise = window.createWindow(config);
2966  promise.then((data) => {
2967    windowClass = data;
2968    console.info('Succeeded in creating the window. Data:' + JSON.stringify(data));
2969  }).catch((err: BusinessError) => {
2970    console.error('Failed to create the Window. Cause:' + JSON.stringify(err));
2971  });
2972} catch (exception) {
2973  console.error('Failed to create the window. Cause: ' + JSON.stringify(exception));
2974}
2975```
2976
2977### animationForShown<sup>9+</sup>
2978
2979animationForShown(context: TransitionContext): void
2980
2981窗口显示时的自定义动画配置。
2982
2983**系统接口:** 此接口为系统接口。
2984
2985**系统能力:** SystemCapability.WindowManager.WindowManager.Core
2986
2987**参数:**
2988
2989| 参数名  | 类型                                     | 必填 | 说明                 |
2990| ------- | ---------------------------------------- | ---- | -------------------- |
2991| context | [TransitionContext](#transitioncontext9) | 是   | 属性转换时的上下文。 |
2992
2993**示例:**
2994
2995```ts
2996// xxx.ts
2997export class AnimationConfig {
2998  private animationForShownCallFunc_: Function = undefined;
2999  ShowWindowWithCustomAnimation(windowClass: window.Window, callback) {
3000    if (!windowClass) {
3001      console.error('windowClass is undefined');
3002      return false;
3003    }
3004    this.animationForShownCallFunc_ = callback;
3005    let controller: window.TransitionController = windowClass.getTransitionController();
3006    controller.animationForShown = (context : window.TransitionContext)=> {
3007      this.animationForShownCallFunc_(context);
3008    };
3009    windowClass.showWithAnimation(()=>{
3010      console.info('Show with animation success');
3011    })
3012  }
3013}
3014```
3015
3016```ts
3017// xxx.ets
3018let animationConfig = new AnimationConfig();
3019let systemTypeWindow = window.findWindow("systemTypeWindow"); // 此处需要获取一个系统类型窗口。
3020try {
3021  animationConfig?.ShowWindowWithCustomAnimation(systemTypeWindow, (context : window.TransitionContext)=>{
3022    console.info('complete transition end');
3023    let toWindow = context.toWindow;
3024    animateTo({
3025      duration: 1000, // 动画时长
3026      tempo: 0.5, // 播放速率
3027      curve: Curve.EaseInOut, // 动画曲线
3028      delay: 0, // 动画延迟
3029      iterations: 1, // 播放次数
3030      playMode: PlayMode.Normal, // 动画模式
3031      onFinish: () => {
3032        console.info('onFinish in animation');
3033        context.completeTransition(true)
3034      }
3035    }, () => {
3036      let obj : window.TranslateOptions = {
3037        x : 100.0,
3038        y : 0.0,
3039        z : 0.0
3040      };
3041      toWindow.translate(obj); // 设置动画过程中的属性转换
3042      console.info('toWindow translate end in animation');
3043    });
3044    console.info('complete transition end');
3045  });
3046} catch (error) {
3047  console.error('ShowWindowWithCustomAnimation err : ' + JSON.stringify(error));
3048}
3049```
3050### animationForHidden<sup>9+</sup>
3051
3052animationForHidden(context: TransitionContext): void
3053
3054窗口隐藏时的自定义动画配置。
3055
3056**系统接口:** 此接口为系统接口。
3057
3058**系统能力:** SystemCapability.WindowManager.WindowManager.Core
3059
3060**参数:**
3061
3062| 参数名  | 类型                                     | 必填 | 说明                 |
3063| ------- | ---------------------------------------- | ---- | -------------------- |
3064| context | [TransitionContext](#transitioncontext9) | 是   | 属性转换时的上下文。 |
3065
3066**示例:**
3067
3068```ts
3069// xxx.ts
3070export class AnimationConfig {
3071  private animationForHiddenCallFunc_: Function = undefined;
3072  HideWindowWithCustomAnimation(windowClass: window.Window, callback) {
3073    if (!windowClass) {
3074      console.error('windowClass is undefined');
3075      return false;
3076    }
3077    this.animationForHiddenCallFunc_ = callback;
3078    let controller: window.TransitionController = windowClass.getTransitionController();
3079    controller.animationForHidden = (context : window.TransitionContext)=> {
3080      this.animationForHiddenCallFunc_(context);
3081    };
3082    windowClass.hideWithAnimation(()=>{
3083      console.info('hide with animation success');
3084    })
3085  }
3086}
3087```
3088
3089```ts
3090// xxx.ets
3091let animationConfig = new AnimationConfig();
3092let systemTypeWindow = window.findWindow("systemTypeWindow"); // 此处需要获取一个系统类型窗口。
3093try {
3094  animationConfig?.HideWindowWithCustomAnimation(systemTypeWindow, (context : window.TransitionContext)=>{
3095    console.info('complete transition end');
3096    let toWindow = context.toWindow;
3097    animateTo({
3098      duration: 1000, // 动画时长
3099      tempo: 0.5, // 播放速率
3100      curve: Curve.EaseInOut, // 动画曲线
3101      delay: 0, // 动画延迟
3102      iterations: 1, // 播放次数
3103      playMode: PlayMode.Normal, // 动画模式
3104      onFinish: () => {
3105        console.info('onFinish in animation');
3106        context.completeTransition(true)
3107      }
3108    }, () => {
3109      let obj : window.TranslateOptions = {
3110        x : 100.0,
3111        y : 0.0,
3112        z : 0.0
3113      };
3114      toWindow.translate(obj); // 设置动画过程中的属性转换
3115      console.info('toWindow translate end in animation');
3116    });
3117    console.info('complete transition end');
3118  });
3119} catch (error) {
3120  console.error('HideWindowWithCustomAnimation err : ' + JSON.stringify(error));
3121}
3122```