diff --git a/interfaces/kits/ani/window_runtime/window_stage_ani/ets/@ohos.window.ets b/interfaces/kits/ani/window_runtime/window_stage_ani/ets/@ohos.window.ets index 9db93913dd84d56a5a726571d9f6045603d53350..34d33b9c7ab8173a0bca3ddac5b7fd26b0fb1a15 100644 --- a/interfaces/kits/ani/window_runtime/window_stage_ani/ets/@ohos.window.ets +++ b/interfaces/kits/ani/window_runtime/window_stage_ani/ets/@ohos.window.ets @@ -1960,7 +1960,7 @@ export class WindowStageInternal implements WindowStage { static { loadLibrary('windowstageani_module.z') } private nativeObj: long = 0; - setNativeObj(nativeObj: long):void { + setNativeObj(nativeObj: long): void { this.nativeObj = nativeObj; } @@ -2085,9 +2085,16 @@ export class WindowStageInternal implements WindowStage { } public setWindowModal(isModal: boolean): Promise { - this.setWindowModal(this.nativeObj, isModal); + return new Promise((resolve: (value: undefined) => void, reject: (error: BusinessError) => void): void => { + taskpool.execute((): void => { + this.setWindowModal(this.nativeObj, isModal); + }).then((ret: NullishType): void => { + resolve(undefined); + }).catch((err: NullishType): void => { + reject(err as BusinessError); + }); + }); } - public setCustomDensity(density: double): void { this.setCustomDensitySync(this.nativeObj, density); } @@ -2442,24 +2449,24 @@ export class WindowInternal implements Window { } public startMoving(): Promise { - return new Promise((resolve: (value: undefined) => void, reject: (error: BusinessError) => void ) :void => { + return new Promise((resolve: (value: undefined) => void, reject: (error: BusinessError) => void ): void => { taskpool.execute((): void => { this.startMoving(this.nativeObj); - }).then((ret: NullishType) :void => { + }).then((ret: NullishType): void => { resolve(undefined); - }).catch((err: NullishType) :void => { + }).catch((err: NullishType): void => { reject(err as BusinessError); }); }); } public startMoving(offsetX: int, offsetY: int): Promise { - return new Promise((resolve: (value: undefined) => void, reject: (error: BusinessError) => void ) :void => { + return new Promise((resolve: (value: undefined) => void, reject: (error: BusinessError) => void ): void => { taskpool.execute((): void => { this.startMoveWindowWithCoordinate(this.nativeObj, offsetX, offsetY); - }).then((ret: NullishType) :void => { + }).then((ret: NullishType): void => { resolve(undefined); - }).catch((err: NullishType) :void => { + }).catch((err: NullishType): void => { reject(err as BusinessError); }); }); @@ -2487,12 +2494,12 @@ export class WindowInternal implements Window { } public minimize(): Promise { - return new Promise((resolve: (value: undefined) => void, reject: (error: BusinessError) => void ) :void => { + return new Promise((resolve: (value: undefined) => void, reject: (error: BusinessError) => void ): void => { taskpool.execute((): void => { this.minimize(this.nativeObj); - }).then((ret: NullishType) :void => { + }).then((ret: NullishType): void => { resolve(undefined); - }).catch((err: NullishType) :void => { + }).catch((err: NullishType): void => { reject(err as BusinessError); }); }); @@ -2509,7 +2516,7 @@ export class WindowInternal implements Window { } public maximize(presentation?: MaximizePresentation): Promise { - return new Promise((resolve: (value: undefined) => void, reject: (error: BusinessError) => void ) :void => { + return new Promise((resolve: (value: undefined) => void, reject: (error: BusinessError) => void ): void => { taskpool.execute((): void => { if (presentation == undefined) { this.maximize(this.nativeObj, MaximizePresentation.ENTER_IMMERSIVE as int); @@ -2517,33 +2524,33 @@ export class WindowInternal implements Window { else { this.maximize(this.nativeObj, presentation as int); } - }).then((ret: NullishType) :void => { + }).then((ret: NullishType): void => { resolve(undefined); - }).catch((err: NullishType) :void => { + }).catch((err: NullishType): void => { reject(err as BusinessError); }); }); } public resize(width: int, height: int): Promise { - return new Promise((resolve: (value: undefined) => void, reject: (error: BusinessError) => void) :void => { + return new Promise((resolve: (value: undefined) => void, reject: (error: BusinessError) => void): void => { taskpool.execute((): void => { this.resize(this.nativeObj, width, height); - }).then((ret: NullishType) :void => { + }).then((ret: NullishType): void => { resolve(undefined); - }).catch((err: NullishType) :void => { + }).catch((err: NullishType): void => { reject(err as BusinessError); }); }); } public moveWindowTo(x: int, y: int): Promise { - return new Promise((resolve: (value: undefined) => void, reject: (error: BusinessError) => void) :void => { + return new Promise((resolve: (value: undefined) => void, reject: (error: BusinessError) => void): void => { taskpool.execute((): void => { this.moveWindowTo(this.nativeObj, x, y); - }).then((ret: NullishType) :void => { + }).then((ret: NullishType): void => { resolve(undefined); - }).catch((err: NullishType) :void => { + }).catch((err: NullishType): void => { reject(err as BusinessError); }); }); @@ -2575,12 +2582,12 @@ export class WindowInternal implements Window { } public setHandwritingFlag(enable: boolean): Promise { - return new Promise((resolve: (value: undefined) => void, reject: (error: BusinessError) => void) :void => { + return new Promise((resolve: (value: undefined) => void, reject: (error: BusinessError) => void): void => { taskpool.execute((): void => { this.setHandwritingFlag(this.nativeObj, enable); - }).then((ret: NullishType) :void => { + }).then((ret: NullishType): void => { resolve(undefined); - }).catch((err: NullishType) :void => { + }).catch((err: NullishType): void => { reject(err as BusinessError); }); }); @@ -2598,12 +2605,12 @@ export class WindowInternal implements Window { } public setBackgroundColor(color: string): Promise { - return new Promise((resolve: (value: undefined) => void, reject: (error: BusinessError) => void) :void => { + return new Promise((resolve: (value: undefined) => void, reject: (error: BusinessError) => void): void => { taskpool.execute((): void => { this.setWindowBackgroundColor(this.nativeObj, color); - }).then((ret: NullishType) :void => { + }).then((ret: NullishType): void => { resolve(undefined); - }).catch((err: NullishType) :void => { + }).catch((err: NullishType): void => { reject(err as BusinessError); }); }); @@ -2692,12 +2699,12 @@ export class WindowInternal implements Window { } public setWindowLayoutFullScreen(isLayoutFullScreen: boolean): Promise { - return new Promise((resolve: (value: undefined) => void, reject: (error: BusinessError) => void) :void => { + return new Promise((resolve: (value: undefined) => void, reject: (error: BusinessError) => void): void => { taskpool.execute((): void => { this.setWindowLayoutFullScreen(this.nativeObj, isLayoutFullScreen); - }).then((ret: NullishType) :void => { + }).then((ret: NullishType): void => { resolve(undefined); - }).catch((err: NullishType) :void => { + }).catch((err: NullishType): void => { reject(err as BusinessError); }); }); @@ -2748,12 +2755,12 @@ export class WindowInternal implements Window { } public setWindowSystemBarProperties(systemBarProperties: SystemBarProperties): Promise { - return new Promise((resolve: (value: undefined) => void, reject: (error: BusinessError) => void) :void => { + return new Promise((resolve: (value: undefined) => void, reject: (error: BusinessError) => void): void => { taskpool.execute((): void => { this.setWindowSystemBarProperties(this.nativeObj, systemBarProperties); - }).then((ret: NullishType) :void => { + }).then((ret: NullishType): void => { resolve(undefined); - }).catch((err: NullishType) :void => { + }).catch((err: NullishType): void => { reject(err as BusinessError); }); }); @@ -2770,16 +2777,16 @@ export class WindowInternal implements Window { } public setSpecificSystemBarEnabled(name: String, enable: boolean, enableAnimation?: boolean): Promise { - return new Promise((resolve: (value: undefined) => void, reject: (error: BusinessError) => void) :void => { + return new Promise((resolve: (value: undefined) => void, reject: (error: BusinessError) => void): void => { taskpool.execute((): void => { if (enableAnimation == undefined) { this.setSpecificSystemBarEnabled(this.nativeObj, name, enable, false); } else { this.setSpecificSystemBarEnabled(this.nativeObj, name, enable, enableAnimation); } - }).then((ret: NullishType) :void => { + }).then((ret: NullishType): void => { resolve(undefined); - }).catch((err: NullishType) :void => { + }).catch((err: NullishType): void => { reject(err as BusinessError); }); }); @@ -2972,7 +2979,7 @@ export class WindowInternal implements Window { } public setWindowKeepScreenOn(isKeepScreenOn: boolean): Promise { - return new Promise((resolve: (value: undefined) => void, reject: (error: BusinessError) => void) :void => { + return new Promise((resolve: (value: undefined) => void, reject: (error: BusinessError) => void): void => { taskpool.execute((): void => { this.setWindowKeepScreenOnSync(this.nativeObj, isKeepScreenOn); }).then((ret: NullishType): void => { @@ -2994,7 +3001,7 @@ export class WindowInternal implements Window { } public setWindowSystemBarEnable(names: Array<'status' | 'navigation'>): Promise { - return new Promise((resolve: (value: undefined) => void, reject: (error: BusinessError) => void) :void => { + return new Promise((resolve: (value: undefined) => void, reject: (error: BusinessError) => void): void => { taskpool.execute((): void => { this.setWindowSystemBarEnableSync(this.nativeObj, names); }).then((ret: NullishType) => { @@ -3681,7 +3688,7 @@ export function CreateWindowStageApi(scene: long): WindowStage { return CreateWi export native function CreateWindow(window: long): WindowInternal; let nativeObj: long; -export function setNativeObj(nativeObject: long):void { +export function setNativeObj(nativeObject: long): void { hilog.info(DOMAIN, TAG, 'setNativeObj, nativeObject:' + nativeObject); nativeObj = nativeObject; } diff --git a/interfaces/kits/ani/window_runtime/window_stage_ani/src/ani_window.cpp b/interfaces/kits/ani/window_runtime/window_stage_ani/src/ani_window.cpp index 077b48e9de39f16d95614dee5dd1dc481a6df624..a55618cb2e7db463bed2ce3b0292e22d4499120e 100644 --- a/interfaces/kits/ani/window_runtime/window_stage_ani/src/ani_window.cpp +++ b/interfaces/kits/ani/window_runtime/window_stage_ani/src/ani_window.cpp @@ -1101,8 +1101,8 @@ ani_int AniWindow::GetSubWindowZLevel(ani_env* env, ani_object obj, ani_long nat using namespace OHOS::Rosen; TLOGI(WmsLogTag::WMS_HIERARCHY, "[ANI]"); AniWindow* aniWindow = reinterpret_cast(nativeObj); - if (aniWindow == nullptr || aniWindow->GetWindow() == nullptr) { - TLOGE(WmsLogTag::WMS_HIERARCHY, "[ANI] windowToken_ is nullptr"); + if (aniWindow == nullptr) { + TLOGE(WmsLogTag::WMS_HIERARCHY, "[ANI] aniWindow is nullptr"); return ANI_ERROR; } return aniWindow->OnGetSubWindowZLevel(env); @@ -1130,7 +1130,7 @@ ani_boolean AniWindow::IsFocused(ani_env* env, ani_object obj, ani_long nativeOb using namespace OHOS::Rosen; TLOGI(WmsLogTag::WMS_FOCUS, "[ANI]"); AniWindow* aniWindow = reinterpret_cast(nativeObj); - if (aniWindow == nullptr || aniWindow->GetWindow() == nullptr) { + if (aniWindow == nullptr) { TLOGE(WmsLogTag::WMS_FOCUS, "[ANI] aniWindow is nullptr"); return ANI_ERROR; } @@ -3551,8 +3551,8 @@ static void SetWindowTopmost(ani_env* env, ani_object obj, ani_long nativeObj, a using namespace OHOS::Rosen; TLOGI(WmsLogTag::WMS_HIERARCHY, "[ANI] start"); AniWindow* aniWindow = reinterpret_cast(nativeObj); - if (aniWindow == nullptr || aniWindow->GetWindow() == nullptr) { - TLOGE(WmsLogTag::WMS_HIERARCHY, "[ANI] windowToken is null"); + if (aniWindow == nullptr) { + TLOGE(WmsLogTag::WMS_HIERARCHY, "[ANI] aniWindow is null"); return; } aniWindow->SetWindowTopmost(env, isWindowTopmost); @@ -3826,8 +3826,8 @@ static ani_int WindowSetRaiseByClickEnabled(ani_env* env, ani_object obj, using namespace OHOS::Rosen; TLOGI(WmsLogTag::WMS_FOCUS, "[ANI]"); AniWindow* aniWindow = reinterpret_cast(nativeObj); - if (aniWindow == nullptr || aniWindow->GetWindow() == nullptr) { - TLOGE(WmsLogTag::WMS_FOCUS, "[ANI] windowToken_ is nullptr"); + if (aniWindow == nullptr) { + TLOGE(WmsLogTag::WMS_FOCUS, "[ANI] aniWindow is nullptr"); return ANI_ERROR; } aniWindow->SetRaiseByClickEnabled(env, enable); @@ -3841,8 +3841,8 @@ static ani_int WindowSetExclusivelyHighlighted(ani_env* env, ani_object obj, using namespace OHOS::Rosen; TLOGI(WmsLogTag::WMS_FOCUS, "[ANI]"); AniWindow* aniWindow = reinterpret_cast(nativeObj); - if (aniWindow == nullptr || aniWindow->GetWindow() == nullptr) { - TLOGE(WmsLogTag::WMS_FOCUS, "[ANI] windowToken_ is nullptr"); + if (aniWindow == nullptr) { + TLOGE(WmsLogTag::WMS_FOCUS, "[ANI] aniWindow is nullptr"); return ANI_ERROR; } aniWindow->SetExclusivelyHighlighted(env, exclusivelyHighlighted);