From 3468c75a30f25d394fe4cc8bc5f75e9ae5e15d73 Mon Sep 17 00:00:00 2001 From: xuhangqi Date: Thu, 24 Jul 2025 10:27:29 +0800 Subject: [PATCH] Refactor overload ohos.window1 Issue: https://gitee.com/openharmony/interface_sdk-js/issues/ICOFWM Signed-off-by: xuhangqi Change-Id: I0a522efcb65ac0831fbc24a610d46ea5d2724893 --- api/@ohos.window.d.ts | 90 +++++++++++++++++++++++++++++++++++++++---- 1 file changed, 82 insertions(+), 8 deletions(-) diff --git a/api/@ohos.window.d.ts b/api/@ohos.window.d.ts index d3fffd2bfd..7046b75f8f 100644 --- a/api/@ohos.window.d.ts +++ b/api/@ohos.window.d.ts @@ -3341,11 +3341,27 @@ declare namespace window { * @syscap SystemCapability.WindowManager.WindowManager.Core * @crossplatform * @atomicservice - * @since arkts {'1.1':'12', '1.2':'20'} - * @arkts 1.1&1.2 + * @since 12 + * */ export function getLastWindow(ctx: BaseContext, callback: AsyncCallback): void; + /** + * Obtains the top window of the current application. This API uses an asynchronous callback to return the result. + * If no child window is available, the main window of the application is returned. + * + * @param { BaseContext } ctx - Current application context. + * @param { AsyncCallback } callback - Callback used to return the top window obtained. + * @throws { BusinessError } 401 - Parameter error. Possible cause: 1. Mandatory parameters are left unspecified; + * 2. Incorrect parameter types. + * @throws { BusinessError } 1300002 - This window state is abnormal. Top window or main window is null or destroyed. + * @throws { BusinessError } 1300006 - This window context is abnormal. + * @syscap SystemCapability.WindowManager.WindowManager.Core + * @since 20 + * @arkts 1.2 + */ + export function getLastWindowWithCallback(ctx: BaseContext, callback: AsyncCallback): void; + /** * Get the final show window. * @@ -3384,11 +3400,33 @@ declare namespace window { * @syscap SystemCapability.WindowManager.WindowManager.Core * @crossplatform * @atomicservice - * @since arkts {'1.1':'12', '1.2':'20'} - * @arkts 1.1&1.2 + * @since 12 + * */ export function getLastWindow(ctx: BaseContext): Promise; + /** + * Obtains the top window of the current application. This API uses a promise to return the result. + * If no child window is available, the main window of the application is returned. + * + * @param { BaseContext } ctx - Current application context. + * @returns { Promise } Promise used to return the top window obtained. + * @throws { BusinessError } 401 - Parameter error. Possible cause: 1. Mandatory parameters are left unspecified; + * 2. Incorrect parameter types. + * @throws { BusinessError } 1300002 - This window state is abnormal. Top window or main window is null or destroyed. + * @throws { BusinessError } 1300006 - This window context is abnormal. + * @syscap SystemCapability.WindowManager.WindowManager.Core + * @since 20 + * @arkts 1.2 + */ + export function getLastWindowReturnPromise(ctx: BaseContext): Promise; + + /** + * @since 20 + * @arkts 1.2 + */ + export overload getLastWindow { getLastWindowWithCallback, getLastWindowReturnPromise }; + /** * Minimize all app windows. * @@ -8348,11 +8386,26 @@ declare namespace window { * @throws { BusinessError } 1300003 - This window manager service works abnormally. * @syscap SystemCapability.WindowManager.WindowManager.Core * @atomicservice - * @since arkts {'1.1':'12', '1.2':'20'} - * @arkts 1.1&1.2 + * @since 12 + * */ setWindowFocusable(isFocusable: boolean): Promise; + /** + * Sets whether focusable or not. + * + * @param { boolean } isFocusable can be focus if true, or can not be focus if false. + * @returns { Promise } Promise that returns no value. + * @throws { BusinessError } 401 - Parameter error. Possible cause: 1. Mandatory parameters are left unspecified; + * 2. Incorrect parameter types. + * @throws { BusinessError } 1300002 - This window state is abnormal. + * @throws { BusinessError } 1300003 - This window manager service works abnormally. + * @syscap SystemCapability.WindowManager.WindowManager.Core + * @since 20 + * @arkts 1.2 + */ + setWindowFocusableReturnPromise(isFocusable: boolean): Promise; + /** * Sets whether focusable or not. * @@ -8376,11 +8429,32 @@ declare namespace window { * @throws { BusinessError } 1300003 - This window manager service works abnormally. * @syscap SystemCapability.WindowManager.WindowManager.Core * @atomicservice - * @since arkts {'1.1':'12', '1.2':'20'} - * @arkts 1.1&1.2 + * @since 12 + * */ setWindowFocusable(isFocusable: boolean, callback: AsyncCallback): void; + /** + * Sets whether focusable or not. + * + * @param { boolean } isFocusable can be focus if true, or can not be focus if false. + * @param { AsyncCallback } callback Callback used to return the result. + * @throws { BusinessError } 401 - Parameter error. Possible cause: 1. Mandatory parameters are left unspecified; + * 2. Incorrect parameter types. + * @throws { BusinessError } 1300002 - This window state is abnormal. + * @throws { BusinessError } 1300003 - This window manager service works abnormally. + * @syscap SystemCapability.WindowManager.WindowManager.Core + * @since 20 + * @arkts 1.2 + */ + setWindowFocusableWithCallback(isFocusable: boolean, callback: AsyncCallback): void; + + /** + * @since 20 + * @arkts 1.2 + */ + overload setWindowFocusable { setWindowFocusableWithCallback, setWindowFocusableReturnPromise }; + /** * Window requests to get focus or lose focus. * -- Gitee