diff --git a/api/@ohos.window.d.ts b/api/@ohos.window.d.ts index 6edafec4b3a8af00eeeb5948a5e1feed7fc12b58..b3ba4fc62c4d0f05ebb26c4a044e337afaa5d179 100644 --- a/api/@ohos.window.d.ts +++ b/api/@ohos.window.d.ts @@ -1169,6 +1169,34 @@ declare namespace window { height: number; } + /** + * Position + * + * @interface Position + * @syscap SystemCapability.Window.SessionManager + * @since 20 + */ + export interface Position { + + /** + * The X-coordinate + * + * @type { number } + * @syscap SystemCapability.Window.SessionManager + * @since 20 + */ + x: number; + + /** + * The Y-coordinate + * + * @type { number } + * @syscap SystemCapability.Window.SessionManager + * @since 20 + */ + y: number; + } + /** * Enum for window anchor * @@ -4945,6 +4973,22 @@ declare namespace window { */ moveWindowToGlobal(x: number, y: number, moveConfiguration?: MoveConfiguration): Promise; + /** + * Move window to the position relative to the main screen. + * + * @param { number } x - Indicate the X-coordinate of the window relative to the main screen. + * @param { number } y - Indicate the Y-coordinate of the window relative to the main screen. + * @returns { Promise } Promise that returns no value. + * @throws { BusinessError } 801 - Capability not supported. Failed to call the API due to limited device capabilities. + * @throws { BusinessError } 1300002 - This window state is abnormal. + * @throws { BusinessError } 1300003 - This window manager service works abnormally. + * @throws { BusinessError } 1300010 - The operation in the current window status is invalid. + * @throws { BusinessError } 1300016 - Parameter error. Possible cause: 1.Invalid parameter range. + * @syscap SystemCapability.Window.SessionManager + * @since 20 + */ + moveWindowToGlobalDisplay(x: number, y: number): Promise; + /** * Set the size of a window . * @@ -9837,6 +9881,64 @@ declare namespace window { */ off(type: 'windowRectChange', callback?: Callback): void; + /** + * Register the callback of rectChangeInGlobalDisplay + * + * @param { 'rectChangeInGlobalDisplay' } type - The value is fixed at 'rectChangeInGlobalDisplay', indicating the window gloabl rect change event. + * @param { Callback } callback - Callback used to return the RectChangeOptions. + * @throws { BusinessError } 801 - Capability not supported. Failed to call the API due to limited device capabilities. + * @throws { BusinessError } 1300002 - This window state is abnormal. + * @throws { BusinessError } 1300003 - This window manager service works abnormally. + * @syscap SystemCapability.Window.SessionManager + * @since 20 + */ + on(type: 'rectChangeInGlobalDisplay', callback: Callback): void; + + /** + * Unregister the callback of rectChangeInGlobalDisplay + * + * @param { 'rectChangeInGlobalDisplay' } type - The value is fixed at 'rectChangeInGlobalDisplay', indicating the window global rect change event. + * @param { Callback } [callback] - Callback used to return the RectChangeOptions. + * @throws { BusinessError } 801 - Capability not supported. Failed to call the API due to limited device capabilities. + * @throws { BusinessError } 1300002 - This window state is abnormal. + * @throws { BusinessError } 1300003 - This window manager service works abnormally. + * @syscap SystemCapability.Window.SessionManager + * @since 20 + */ + off(type: 'rectChangeInGlobalDisplay', callback?: Callback): void; + + /** + * Convert the window coordinates to the global coordinates. + * + * @param { number } winX - Indicate the X-coordinate of the component relative to the current window. + * @param { number } winY - Indicate the Y-coordinate of the component relative to the current window. + * @returns { Promise } Promise used to return the Position. The pair {x, y} represents respectively the X-coordinate + * and Y-coordinate of the window relative to the main screen. + * @throws { BusinessError } 801 - Capability not supported. Failed to call the API due to limited device capabilities. + * @throws { BusinessError } 1300002 - This window state is abnormal. + * @throws { BusinessError } 1300003 - This window manager service works abnormally. + * @throws { BusinessError } 1300016 - Parameter error. Possible cause: 1.Invalid parameter range. + * @syscap SystemCapability.Window.SessionManager + * @since 20 + */ + clientToGlobalDisplay(winX: number, winY: number): Promise; + + /** + * Convert the global coordinates to the window coordinates. + * + * @param { number } globalDisplayX - Indicate the X-coordinate of the component relative to the main screen. + * @param { number } globalDisplayY - Indicate the Y-coordinate of the component relative to the main screen. + * @returns { Promise } Promise used to return the Position. The pair {x, y} represents respectively the X-coordinate + * and Y-coordinate of the window relative to the current screen. + * @throws { BusinessError } 801 - Capability not supported. Failed to call the API due to limited device capabilities. + * @throws { BusinessError } 1300002 - This window state is abnormal. + * @throws { BusinessError } 1300003 - This window manager service works abnormally. + * @throws { BusinessError } 1300016 - Parameter error. Possible cause: 1.Invalid parameter range. + * @syscap SystemCapability.Window.SessionManager + * @since 20 + */ + globalDisplayToClient(globalDisplayX: number, globalDisplayY: number): Promise; + /** * Register the callback of rotation change *