!574 修复5.0分屏失败2

Merge pull request !574 from zhengyongjie/OpenHarmony-5.0-Release
This commit is contained in:
openharmony_ci 2024-09-23 08:19:27 +00:00 committed by Gitee
commit a362c6e34c
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
2 changed files with 25 additions and 0 deletions

View File

@ -312,6 +312,7 @@ class WindowManager {
createRecentWindow(mode?: number) {
Log.showDebug(TAG, 'createRecentWindow Begin, mode=' + mode);
globalThis.recentMode = mode;
let setWinMode = (mode && this.isSplitWindowMode(mode)) ? (win) => {
windowManager.recentMode = mode;
win.setWindowMode(mode).then();
@ -321,6 +322,28 @@ class WindowManager {
Log.showDebug(TAG, `${this.RECENT_WINDOW_NAME} setFullScreen`);
});
};
let registerWinEvent = (win: window.Window) => {
Log.showDebug(TAG, 'registerWinEvent Begin');
win.on('windowEvent', (stageEventType) => {
Log.showError(TAG,`Recent lifeCycleEvent callback stageEventType=${stageEventType}`);
if (!globalThis.recentDisplay) {
return;
}
if (stageEventType === window.WindowEventType.WINDOW_INACTIVE && globalThis.recentDisplay === globalThis.recentMode) {
Log.showDebug(TAG,'Recent MainAbility onWindowStageInactive');
try {
let wins: window.Window = window.findWindow(windowManager.RECENT_WINDOW_NAME);
Log.showError(TAG,'Hide recent on inactive');
wins.hide().then(() => {
globalThis.recentDisplay = null;
})
} catch (err) {
let _err = err as BusinessError;
Log.showError(TAG, `Recent lifeCycleEvent findWindow errCode: ${_err.code}, errMsg: ${_err.message}`);
}
}
})
};
try {
let win: window.Window = window.findWindow(windowManager.RECENT_WINDOW_NAME);
setWinMode(win);
@ -332,6 +355,7 @@ class WindowManager {
Log.showDebug(TAG, `recent window is not created, because ${JSON.stringify(err)}`);
let callback = (win) => {
Log.showDebug(TAG, 'Post recent window created');
registerWinEvent(win);
setWinMode(win);
}
this.createWindow(globalThis.desktopContext, windowManager.RECENT_WINDOW_NAME, windowManager.RECENT_RANK,

View File

@ -171,6 +171,7 @@ export class RecentMissionsViewModel {
*/
async moveMissionToFront(missionId: number): Promise<void> {
if (globalThis.recentMode && windowManager.isSplitWindowMode(globalThis.recentMode)) {
globalThis.recentDisplay = globalThis.recentMode;
await amsMissionManager.moveMissionToFront(missionId, globalThis.recentMode);
} else {
await amsMissionManager.moveMissionToFront(missionId);