1# RemoteWindow (System API)
2
3**RemoteWindow** is a component used to control the application window, providing the component animator and application window animation linkage during application startup and exit.
4
5>  **NOTE**
6>
7>  This component is supported since API version 9. Updates will be marked with a superscript to indicate their earliest API version.
8>
9>  The APIs provided by this module are system APIs.
10
11## Child Components
12
13Not supported
14
15## APIs
16
17RemoteWindow(target: WindowAnimationTarget)
18
19Creates a **RemoteWindow** through a window animation object.
20
21**Parameters**
22
23| Name| Type| Mandatory | Description|
24| -------- | -------- | --------------- | -------- |
25| target | [WindowAnimationTarget](#windowanimationtarget) | Yes  | Description of the animation window to control.|
26
27## WindowAnimationTarget
28
29Implements a target window, which is used to remotely control the animation.
30
31| Name     | Type    | Description|
32| ------- | ------ | ----------------------- |
33| bundleName  | string | Process corresponding to the animation window.|
34| abilityName | string | Ability corresponding to the animation window.|
35| windowBounds | [RRect](#rrect) | Actual size of the animation window.|
36| missionId  | number | Mission ID.|
37
38## RRect
39
40Implements a rounded rectangle.
41
42| Name     | Type    | Description|
43| ------- | ------ | ----------------------- |
44| left  | number | Horizontal coordinate of the upper left corner of the animation window relative to the screen.|
45| top | number | Vertical coordinate of the upper left corner of the animation window relative to the screen.|
46| width | number | Width of the animation window.|
47| height | number | Height of the animation window.|
48| radius | number | Radius of the rounded corner of the animation window.|
49
50## Attributes
51
52The [universal attributes](ts-universal-attributes-size.md) are supported.
53
54## Events
55
56The [universal events](ts-universal-events-click.md) are supported.
57
58## Example
59The **RemoteWindow** component needs to receive the **WindowAnimationTarget** object from the **WindowAnimationController** object set by [windowAnimationManager](../js-apis-windowAnimationManager-sys.md). You can create a **RemoteWindowExample.ets** file as an example to encapsulate the **RemoteWindow** component and the passed **WindowAnimationTarget** object.
60The **RemoteWindow** component can be used only in the system home screen application. Therefore, you can place the **RemoteWindowExample** component in the **build** function of the **EntryView.ets** page of the home screen application, compile the application, and push the application installation package to the device.
61
62```ts
63// WindowAnimationControllerImpl.ets file
64import { windowAnimationManager } from '@kit.ArkUI';
65
66export default class WindowAnimationControllerImpl implements windowAnimationManager.WindowAnimationController {
67  onStartAppFromLauncher(startingWindowTarget: windowAnimationManager.WindowAnimationTarget,
68                         finishedCallback: windowAnimationManager.WindowAnimationFinishedCallback): void
69  {
70    console.log(`remote window animation onStartAppFromLauncher`);
71    finishedCallback.onAnimationFinish();
72  }
73
74  onStartAppFromRecent(startingWindowTarget: windowAnimationManager.WindowAnimationTarget,
75                       finishedCallback: windowAnimationManager.WindowAnimationFinishedCallback): void {
76    console.log(`remote window animation onStartAppFromRecent`);
77    finishedCallback.onAnimationFinish();
78  }
79
80  onStartAppFromOther(startingWindowTarget: windowAnimationManager.WindowAnimationTarget,
81                      finishedCallback: windowAnimationManager.WindowAnimationFinishedCallback): void {
82    console.log(`remote window animation onStartAppFromOther`);
83    finishedCallback.onAnimationFinish();
84  }
85
86  onAppTransition(fromWindowTarget: windowAnimationManager.WindowAnimationTarget,
87                  toWindowTarget: windowAnimationManager.WindowAnimationTarget,
88                  finishedCallback: windowAnimationManager.WindowAnimationFinishedCallback): void{
89    console.log(`remote window animation onAppTransition`);
90    finishedCallback.onAnimationFinish();
91  }
92
93  onMinimizeWindow(minimizingWindowTarget: windowAnimationManager.WindowAnimationTarget,
94                   finishedCallback: windowAnimationManager.WindowAnimationFinishedCallback): void {
95    console.log(`remote window animation onMinimizeWindow`);
96    finishedCallback.onAnimationFinish();
97  }
98
99  onCloseWindow(closingWindowTarget: windowAnimationManager.WindowAnimationTarget,
100                finishedCallback: windowAnimationManager.WindowAnimationFinishedCallback): void {
101    console.log(`remote window animation onCloseWindow`);
102    finishedCallback.onAnimationFinish();
103  }
104
105  onScreenUnlock(finishedCallback: windowAnimationManager.WindowAnimationFinishedCallback): void {
106    console.log(`remote window animation onScreenUnlock`);
107    finishedCallback.onAnimationFinish();
108  }
109
110  onWindowAnimationTargetsUpdate(fullScreenWindowTarget: windowAnimationManager.WindowAnimationTarget,
111                              floatingWindowTargets: Array<windowAnimationManager.WindowAnimationTarget>): void {
112    console.log('onWindowAnimationTargetsUpdate, the fullScreenWindowTarget is: ' + fullScreenWindowTarget);
113    console.log('onWindowAnimationTargetsUpdate, the floatingWindowTargets are: ' + floatingWindowTargets);
114  }
115}
116```
117
118```ts
119// RemoteWindowExample.ets file
120import { windowAnimationManager } from '@kit.ArkUI';
121import WindowAnimationControllerImpl from './WindowAnimationControllerImpl';
122
123@Entry
124@Component
125export default struct RemoteWindowExample {
126  @State target:WindowAnimationTarget | undefined = undefined // Obtained through windowAnimationManager.
127
128  aboutToAppear(): void {
129    let controller: WindowAnimationControllerImpl = new WindowAnimationControllerImpl();
130    windowAnimationManager.setController(controller);
131
132    controller.onStartAppFromLauncher = (startingWindowTarget: WindowAnimationTarget,
133                                         finishedCallback: windowAnimationManager.WindowAnimationFinishedCallback) => {
134      console.log(`RemoteWindowExample: remote window animation onStartAppFromLauncher`);
135      this.target = startingWindowTarget;
136      finishedCallback.onAnimationFinish();
137    }
138
139    controller.onStartAppFromRecent = (startingWindowTarget: WindowAnimationTarget,
140                                       finishedCallback: windowAnimationManager.WindowAnimationFinishedCallback) => {
141      console.log(`RemoteWindowExample: remote window animation onStartAppFromRecent`);
142      this.target = startingWindowTarget;
143      finishedCallback.onAnimationFinish();
144    }
145
146    controller.onStartAppFromOther = (startingWindowTarget: WindowAnimationTarget,
147                                      finishedCallback: windowAnimationManager.WindowAnimationFinishedCallback) => {
148      console.log(`RemoteWindowExample: remote window animation onStartAppFromOther`);
149      this.target = startingWindowTarget;
150      finishedCallback.onAnimationFinish();
151    }
152
153    controller.onAppTransition = (fromWindowTarget: WindowAnimationTarget, toWindowTarget: WindowAnimationTarget,
154                                  finishedCallback: windowAnimationManager.WindowAnimationFinishedCallback) => {
155      console.log(`RemoteWindowExample: remote window animation onAppTransition`);
156      this.target = toWindowTarget;
157      finishedCallback.onAnimationFinish();
158    }
159
160    controller.onMinimizeWindow = (minimizingWindowTarget: WindowAnimationTarget,
161                                   finishedCallback: windowAnimationManager.WindowAnimationFinishedCallback) => {
162      console.log(`RemoteWindowExample: remote window animation onMinimizeWindow`);
163      this.target = minimizingWindowTarget;
164      finishedCallback.onAnimationFinish();
165    }
166
167    controller.onCloseWindow = (closingWindowTarget: WindowAnimationTarget,
168                                finishedCallback: windowAnimationManager.WindowAnimationFinishedCallback) => {
169      console.log(`RemoteWindowExample: remote window animation onCloseWindow`);
170      this.target = closingWindowTarget;
171      finishedCallback.onAnimationFinish();
172    }
173  }
174
175  build() {
176    Column() {
177      if(this.target){
178        RemoteWindow(this.target)
179          .scale({ x: 0.5, y: 0.5}) // Used for demonstration purposes only. .In general cases, scale({ x: 1, y: 1 }) is required.
180          .position({ x: px2vp(this.target?.windowBounds.left), y: px2vp(this.target?.windowBounds.top) })
181          .width(px2vp(this.target?.windowBounds.width))
182          .height(px2vp(this.target?.windowBounds.height))
183      }
184     }
185  }
186}
187```
188