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 704faa0f6af35ebe12bbc29b3ccd1b1421849051..9947915587d66b24db7fff4226e05872f3989e9f 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 @@ -717,6 +717,68 @@ export enum RectType { RELATIVE_TO_PARENT_WINDOW = 1 } +export interface SubWindowOptions { + title: string; + decorEnabled: boolean; + isModal?: boolean; + isTopmost?: boolean; + modalityType?: ModalityType; + windowRect?: Rect; + maximizeSupported?: boolean; + zLevel?: int; + outlineEnabled?: boolean; +} + +export class SubWindowOptionsInternal implements SubWindowOptions { + title: string; + decorEnabled: boolean; + isModal?: boolean; + isTopmost?: boolean; + modalityType?: ModalityType; + windowRect?: Rect; + maximizeSupported?: boolean; + zLevel?: int; + outlineEnabled?: boolean; +} + +export interface StatusBarProperty { + contentColor: string; +} + +export class StatusBarPropertyInternal implements StatusBarProperty { + contentColor: string; +} + +export interface WindowLayoutInfo { + windowRect: Rect; +} + +export class WindowLayoutInfoInternal implements WindowLayoutInfo { + windowRect: Rect; +} + +export interface WindowInfo { + rect: Rect; + globalDisplayRect?: Rect; + bundleName: string; + abilityName: string; + windowId: int; + windowStatusType: WindowStatusType; + isFocused?: boolean; +} + +export class WindowInfoInternal implements WindowInfo { + rect: Rect; + globalDisplayRect?: Rect; + bundleName: string; + abilityName: string; + windowId: int; + windowStatusType: WindowStatusType; + isFocused?: boolean; + windowStatusTypeInternal: int; + isFocusedInternal: boolean; +} + export enum BlurStyle { OFF = 0, THIN = 1, @@ -1310,6 +1372,12 @@ export interface WindowDensityInfo { customDensity: double; } +export class WindowDensityInfoInternal implements WindowDensityInfo { + systemDensity: double; + defaultDensity: double; + customDensity: double; +} + export interface SystemBarStyle { statusBarContentColor?: string; } @@ -1592,6 +1660,13 @@ export interface GetWindowsByCoordinateParam { y: number; } +export class GetWindowsByCoordinateParamInternal implements GetWindowsByCoordinateParam { + displayId: number; + windowNumber: number; + x: number; + y: number; +} + /** * The information of keyboard * @@ -1900,6 +1975,8 @@ export class WindowStageInternal implements WindowStage { public native setWindowModal(nativeObj: long, isModal: boolean): void; public native getMainWindowSync(nativeObj: long): Window; public native createSubWindowSync(nativeObj: long, name: String): Window; + public native setCustomDensitySync(nativeObj: long, density: double): void; + public native setDefaultDensityEnabledSync(nativeObj: long, enabled: boolean): void; native onSync(nativeObj: long, eventType: 'windowStageEvent', callback: Object): void; native offSync(nativeObj: long, eventType: 'windowStageEvent', callback?: Object): void; @@ -2008,7 +2085,23 @@ 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); + } + + public setDefaultDensityEnabled(enabled: boolean): void { + this.setDefaultDensityEnabledSync(this.nativeObj, enabled); } public getMainWindowSync(): Window { @@ -2087,6 +2180,8 @@ export interface WindowStage { disableWindowDecor(): void; setShowOnLockScreen(showOnLockScreen: boolean): void; setWindowModal(isModal: boolean): Promise; + setCustomDensity(density: double): void; + setDefaultDensityEnabled(enabled: boolean): void; on(eventType: 'windowStageEvent', callback: Callback): void; off(eventType: 'windowStageEvent', callback?: Callback): void; } @@ -2192,6 +2287,23 @@ export class WindowInternal implements Window { private native setSubWindowModalType(nativeObj: long, isModal: boolean, modalityType: int): void; private native isFocusedSync(nativeObj: long): boolean; private native setSubWindowZLevelSync(nativeObj: long, zLevel: int): void; + private native setWindowBrightness(nativeObj: long, brightness: double): void; + private native getWindowColorSpace(nativeObj: long): int; + private native setWakeUpScreen(nativeObj: long, wakeUp: boolean): void; + private native setSnapshotSkip(nativeObj: long, isSkip: boolean): void; + private native snapshotIgnorePrivacy(nativeObj: long): image.PixelMap; + private native setWindowContainerColor(nativeObj: long, activeColor: string, inactiveColor: string): void; + private native getStatusBarProperty(nativeObj: long): StatusBarProperty; + private native setStatusBarColor(nativeObj: long, color: long): void; + private native isSystemAvoidAreaEnabled(nativeObj: long): boolean; + private native setSystemAvoidAreaEnabled(nativeObj: long, enabled: boolean): void; + private native getWindowDensityInfo(nativeObj: long): WindowDensityInfo; + private native getImmersiveModeEnabledState(nativeObj: long): boolean; + private native setWindowGrayScale(nativeObj: long, grayScale: double): void; + private native getWindowSystemBarProperties(nativeObj: long): SystemBarProperties; + private native isGestureBackEnabled(nativeObj: long): boolean; + private native setGestureBackEnabled(nativeObj: long, enabled: boolean): void; + private native setSingleFrameComposerEnabled(nativeObj: long, enabled: boolean): void; private native setWindowTouchableSync(nativeObj: long, isTouchable: boolean): void; private native setDialogBackGestureEnabledSync(nativeObj: long, enabled: boolean): void; private native setWindowMaskSync(nativeObj: long, windowMask: Array>): void; @@ -2211,7 +2323,7 @@ export class WindowInternal implements Window { } public setFollowParentWindowLayoutEnabled(enabled: 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.setFollowParentWindowLayoutEnabled(this.nativeObj, enabled); }).then((ret: NullishType): void => { @@ -2235,7 +2347,7 @@ export class WindowInternal implements Window { } public stopMoving(): 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.stopMoving(this.nativeObj); }).then((ret: NullishType): void => { @@ -2247,7 +2359,7 @@ export class WindowInternal implements Window { } public setParentWindow(windowId: number): 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.setParentWindow(this.nativeObj, windowId); }).then((ret: NullishType): void => { @@ -2259,7 +2371,7 @@ export class WindowInternal implements Window { } public setWindowTitle(titleName: 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.setWindowTitle(this.nativeObj, titleName); }).then((ret: NullishType): void => { @@ -2306,7 +2418,7 @@ export class WindowInternal implements Window { } public setTitleAndDockHoverShown(isTitleHoverShown?: boolean, isDockHoverShown?: 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 => { let titleShow: boolean = true; if (isTitleHoverShown != undefined) { @@ -2326,7 +2438,7 @@ export class WindowInternal implements Window { } public restore(): 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.restore(this.nativeObj); }).then((ret: NullishType): void => { @@ -2338,24 +2450,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); }); }); @@ -2383,12 +2495,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); }); }); @@ -2405,7 +2517,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); @@ -2413,33 +2525,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); }); }); @@ -2471,12 +2583,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); }); }); @@ -2494,12 +2606,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); }); }); @@ -2588,12 +2700,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); }); }); @@ -2644,12 +2756,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); }); }); @@ -2666,16 +2778,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); }); }); @@ -2868,7 +2980,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 => { @@ -2890,7 +3002,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) => { @@ -3293,6 +3405,142 @@ export class WindowInternal implements Window { }); }); } + + public setWindowBrightness(brightness: double): Promise { + return new Promise((resolve: (value: undefined) => void, reject: (error: BusinessError) => void): void => { + taskpool.execute((): void => { + this.setWindowBrightness(this.nativeObj, brightness); + }).then((ret: NullishType) => { + resolve(undefined); + }).catch((err: NullishType) => { + reject(err as BusinessError); + }); + }); + } + + public setWindowBrightness(brightness: double, callback: AsyncCallback): void { + taskpool.execute((): void => { + this.setWindowBrightness(this.nativeObj, brightness); + }).then((ret: NullishType) => { + callback(new BusinessError(), undefined); + }).catch((err: NullishType) => { + callback(err as BusinessError, undefined); + }); + } + + public getWindowColorSpace(): ColorSpace { + return this.getWindowColorSpace(this.nativeObj) as ColorSpace; + } + + public setWakeUpScreen(wakeUp: boolean): void { + return this.setWakeUpScreen(this.nativeObj, wakeUp); + } + + public setSnapshotSkip(isSkip: boolean): void { + return this.setSnapshotSkip(this.nativeObj, isSkip); + } + + public snapshotIgnorePrivacy(): Promise { + return new Promise((resolve: (value: image.PixelMap) => void, + reject: (error: BusinessError) => void): void => { + taskpool.execute(() => { + return this.snapshotIgnorePrivacy(this.nativeObj); + }).then((ret: NullishType) => { + resolve(ret as image.PixelMap); + }).catch((err: NullishType) => { + reject(err as BusinessError); + }); + }); + } + + public setWindowContainerColor(activeColor: string, inactiveColor: string): void { + return this.setWindowContainerColor(this.nativeObj, activeColor, inactiveColor); + } + + public getStatusBarProperty(): StatusBarProperty { + return this.getStatusBarProperty(this.nativeObj); + } + + public setStatusBarColor(color: ColorMetrics): Promise { + return new Promise((resolve: (value: undefined) => void, reject: (error: BusinessError) => void): void => { + taskpool.execute((): void => { + this.setStatusBarColor( + this.nativeObj, (color.alpha << 24) | (color.red << 16) | (color.green << 8) | color.blue); + }).then((ret: NullishType) => { + resolve(undefined); + }).catch((err: NullishType) => { + reject(err as BusinessError); + }); + }); + } + + public isSystemAvoidAreaEnabled(): boolean { + return this.isSystemAvoidAreaEnabled(this.nativeObj); + } + + public setSystemAvoidAreaEnabled(enabled: boolean): Promise { + return new Promise((resolve: (value: undefined) => void, reject: (error: BusinessError) => void): void => { + taskpool.execute((): void => { + this.setSystemAvoidAreaEnabled(this.nativeObj, enabled); + }).then((ret: NullishType) => { + resolve(undefined); + }).catch((err: NullishType) => { + reject(err as BusinessError); + }); + }); + } + + public getWindowDensityInfo(): WindowDensityInfo { + return this.getWindowDensityInfo(this.nativeObj) as WindowDensityInfoInternal; + } + + public getImmersiveModeEnabledState(): boolean { + return this.getImmersiveModeEnabledState(this.nativeObj); + } + + public setWindowGrayScale(grayScale: double): Promise { + return new Promise((resolve: (value: undefined) => void, reject: (error: BusinessError) => void): void => { + taskpool.execute((): void => { + this.setWindowGrayScale(this.nativeObj, grayScale); + }).then((ret: NullishType) => { + resolve(undefined); + }).catch((err: NullishType) => { + reject(err as BusinessError); + }); + }); + } + + public getWindowSystemBarProperties(): SystemBarProperties { + return this.getWindowSystemBarProperties(this.nativeObj); + } + + public isGestureBackEnabled(): boolean { + return this.isGestureBackEnabled(this.nativeObj); + } + + public setGestureBackEnabled(enabled: boolean): Promise { + return new Promise((resolve: (value: undefined) => void, reject: (error: BusinessError) => void): void => { + taskpool.execute((): void => { + this.setGestureBackEnabled(this.nativeObj, enabled); + }).then((ret: NullishType) => { + resolve(undefined); + }).catch((err: NullishType) => { + reject(err as BusinessError); + }); + }); + } + + public setSingleFrameComposerEnabled(enabled: boolean): Promise { + return new Promise((resolve: (value: undefined) => void, reject: (error: BusinessError) => void): void => { + taskpool.execute((): void => { + this.setSingleFrameComposerEnabled(this.nativeObj, enabled); + }).then((ret: NullishType) => { + resolve(undefined); + }).catch((err: NullishType) => { + reject(err as BusinessError); + }); + }); + } } export interface Window { @@ -3413,6 +3661,24 @@ export interface Window { getWindowCornerRadius(): double; setWindowCornerRadius(cornerRadius: double): Promise; setWindowShadowRadius(radius: double): void; + setWindowBrightness(brightness: double): Promise; + setWindowBrightness(brightness: double, callback: AsyncCallback): void; + getWindowColorSpace(): ColorSpace; + setWakeUpScreen(wakeUp: boolean): void; + setSnapshotSkip(isSkip: boolean): void; + snapshotIgnorePrivacy(): Promise; + setWindowContainerColor(activeColor: string, inactiveColor: string): void; + getStatusBarProperty(): StatusBarProperty; + setStatusBarColor(color: ColorMetrics): Promise; + isSystemAvoidAreaEnabled(): boolean; + setSystemAvoidAreaEnabled(enabled: boolean): Promise; + getWindowDensityInfo(): WindowDensityInfo; + getImmersiveModeEnabledState(): boolean; + setWindowGrayScale(grayScale: double): Promise; + getWindowSystemBarProperties(): SystemBarProperties; + isGestureBackEnabled(): boolean; + setGestureBackEnabled(enabled: boolean): Promise; + setSingleFrameComposerEnabled(enabled: boolean): Promise; on(type: string, callback: Callback): void; on(type: 'noInteractionDetected', timeout: long, callback: Callback): void; off(type: string, callback?: Callback): void; @@ -3437,6 +3703,11 @@ native function offSync(nativeObj: long, type: string, callback?: object): void; native function shiftAppWindowFocusSync(nativeObj: long, sourceWindowId: int, targetWindowId: int): void; native function shiftAppWindowPointerEventSync(nativeObj: long, sourceWindowId: int, targetWindowId: int): void; native function createWindowSync(nativeObj: long, config: Configuration): Window; +native function getAllWindowLayoutInfo(nativeObj: long, displayId: long): Array; +native function getSnapshot(nativeObj: long, windowId: number): image.PixelMap; +native function getVisibleWindowInfo(nativeObj: long): Array; +native function setGestureNavigationEnabled(nativeObj: long, enabled: boolean): void; +native function setWaterMarkImage(nativeObj: long, pixelMap: image.PixelMap, enabled: boolean): void; export function getLastWindow(ctx: BaseContext): Promise { return new Promise((resolve: (value: Window) => void, reject: (error: BusinessError) => void) => { @@ -3463,7 +3734,7 @@ export function getLastWindow(ctx: BaseContext, callback: AsyncCallback) } export function createWindow(config: Configuration): Promise { - return new Promise((resolve: (value: Window) => void, reject: (error: BusinessError) => void ) => { + return new Promise((resolve: (value: Window) => void, reject: (error: BusinessError) => void) => { taskpool.execute((): Window => { return createWindowSync(nativeObj, config); }).then((ret: NullishType) => { @@ -3516,7 +3787,7 @@ export function getWindowsByCoordinate(displayId: number, windowNumber?: number, windowNumber: 0, x: -1, y: -1 - }; + } as GetWindowsByCoordinateParamInternal; if (windowNumber != undefined) { param.windowNumber = windowNumber; } @@ -3535,6 +3806,97 @@ export function getWindowsByCoordinate(displayId: number, windowNumber?: number, }); } +export function getAllWindowLayoutInfo(displayId: long): Promise> { + return new Promise>(( + resolve: (value: Array) => void, reject: (error: BusinessError) => void): void => { + taskpool.execute(() => { + return getAllWindowLayoutInfo(nativeObj, displayId); + }).then((ret: NullishType) => { + resolve(ret as Array); + }).catch((err: NullishType) => { + reject(err as BusinessError); + }); + }); +} + +export function getSnapshot(windowId: number): Promise { + return new Promise(( + resolve: (value: image.PixelMap) => void, reject: (error: BusinessError) => void): void => { + taskpool.execute(() => { + return getSnapshot(nativeObj, windowId); + }).then((ret: NullishType) => { + resolve(ret as image.PixelMap); + }).catch((err: NullishType) => { + reject(err as BusinessError); + }); + }); +} + +export function getVisibleWindowInfo(): Promise> { + return new Promise>(( + resolve: (value: Array) => void, reject: (error: BusinessError) => void): void => { + taskpool.execute(() => { + let visibleWindowInfos = getVisibleWindowInfo(nativeObj); + for (let i = 0; i < visibleWindowInfos.length; i++) { + visibleWindowInfos[i].windowStatusType = + visibleWindowInfos[i].windowStatusTypeInternal as WindowStatusType; + visibleWindowInfos[i].isFocused = visibleWindowInfos[i].isFocusedInternal; + } + return visibleWindowInfos; + }).then((ret: NullishType) => { + resolve(ret as Array); + }).catch((err: NullishType) => { + reject(err as BusinessError); + }); + }); +} + +export function setGestureNavigationEnabled(enabled: boolean): Promise { + return new Promise(( + resolve: (value: undefined) => void, reject: (error: BusinessError) => void): void => { + taskpool.execute((): void => { + return setGestureNavigationEnabled(nativeObj, enabled); + }).then((ret: NullishType) => { + resolve(undefined); + }).catch((err: NullishType) => { + reject(err as BusinessError); + }); + }); +} + +export function setGestureNavigationEnabled(enabled: boolean, callback: AsyncCallback): void { + taskpool.execute((): void => { + setGestureNavigationEnabled(nativeObj, enabled); + }).then((ret: NullishType) => { + callback(new BusinessError(), undefined); + }).catch((err: NullishType) => { + callback(err as BusinessError, undefined); + }); +} + +export function setWaterMarkImage(pixelMap: image.PixelMap, enabled: boolean): Promise { + return new Promise(( + resolve: (value: undefined) => void, reject: (error: BusinessError) => void): void => { + taskpool.execute((): void => { + return setWaterMarkImage(nativeObj, pixelMap, enabled); + }).then((ret: NullishType) => { + resolve(undefined); + }).catch((err: NullishType) => { + reject(err as BusinessError); + }); + }); +} + +export function setWaterMarkImage(pixelMap: image.PixelMap, enabled: boolean, callback: AsyncCallback): void { + taskpool.execute((): void => { + setWaterMarkImage(nativeObj, pixelMap, enabled); + }).then((ret: NullishType) => { + callback(new BusinessError(), undefined); + }).catch((err: NullishType) => { + callback(err as BusinessError, undefined); + }); +} + export function findWindow(name: string): Window { return findWindowSync(nativeObj, name); } 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 6db039f2d4a4092f92e467e90079074b997a5035..aacd320c4d2ba70573324a380d27b6b777d5caae 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 @@ -1099,8 +1099,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); @@ -1128,7 +1128,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; } @@ -3182,8 +3182,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); @@ -3457,8 +3457,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); @@ -3472,8 +3472,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); @@ -3503,7 +3503,7 @@ static ani_int WindowSetSpecificSystemBarEnabled(ani_env* env, ani_object obj, a TLOGI(WmsLogTag::WMS_IMMS, "[ANI]"); AniWindow* aniWindow = reinterpret_cast(nativeObj); if (aniWindow == nullptr) { - TLOGE(WmsLogTag::WMS_IMMS, "[ANI] windowToken_ is nullptr"); + TLOGE(WmsLogTag::WMS_IMMS, "[ANI] aniWindow is nullptr"); AniWindowUtils::AniThrowError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY); return ANI_ERROR; }