SDA-4207 Snipping tool being closed in case it was existing before persisting existing windows and capturing the screen

This commit is contained in:
sbenmoussati 2023-06-09 11:30:39 +02:00 committed by Salah Benmoussati
parent b63b44bd0e
commit b7190024e0
6 changed files with 59 additions and 55 deletions

View File

@ -95,7 +95,7 @@ class ScreenSnippet {
const currentWindowName = (currentWindowObj as ICustomBrowserWindow)
?.winName;
const mainWindow = windowHandler.getMainWindow();
windowHandler.closeSnippingToolWindow();
if (hideOnCapture) {
this.storeWindowsState(mainWindow, currentWindowObj);
winStore.hideWindowsOnCapturing(hideOnCapture);
@ -465,7 +465,9 @@ class ScreenSnippet {
const windowObj = winStore.getWindowStore();
const currentWindowName = (currentWindowObj as ICustomBrowserWindow)
?.winName;
if (windowObj.windows.length < 1) {
if (windowObj.windows.length > 0) {
winStore.destroyWindowStore();
}
const allWindows = BrowserWindow.getAllWindows();
let windowsArr: IWindowState[] = [];
const mainArr: IWindowState[] = [
@ -475,12 +477,12 @@ class ScreenSnippet {
minimized: mainWindow?.isMinimized(),
isFullScreen: mainWindow?.isFullScreen(),
isVisible: mainWindow?.isVisible(),
isAlwaysOnTop: mainWindow?.isAlwaysOnTop(),
},
];
allWindows.forEach((window) => {
if (
(window as ICustomBrowserWindow).winName &&
(window as ICustomBrowserWindow).winName !== currentWindowName &&
(window as ICustomBrowserWindow).winName !== 'main' &&
(window as ICustomBrowserWindow).winName !==
@ -492,7 +494,6 @@ class ScreenSnippet {
minimized: window?.isMinimized(),
isFullScreen: window?.isFullScreen(),
isVisible: window?.isVisible(),
isAlwaysOnTop: window?.isAlwaysOnTop(),
});
}
});
@ -504,7 +505,6 @@ class ScreenSnippet {
minimized: currentWindowObj?.isMinimized(),
isFullScreen: currentWindowObj?.isFullScreen(),
isVisible: currentWindowObj?.isVisible(),
isAlwaysOnTop: currentWindowObj?.isAlwaysOnTop(),
});
windowsArr = mainArr.concat(windowsArr);
} else {
@ -513,7 +513,6 @@ class ScreenSnippet {
winStore.setWindowStore({
windows: windowsArr,
});
}
};
/**

View File

@ -17,7 +17,6 @@ export interface IWindowState {
focused?: boolean;
isFullScreen?: boolean;
isVisible?: boolean;
isAlwaysOnTop?: boolean;
}
export class WindowStore {
@ -104,9 +103,6 @@ export class WindowStore {
focusedWindowToRestore = window;
}
}
if (currentWindow && currentWindow.isAlwaysOnTop) {
window.setAlwaysOnTop(true);
}
}
});

View File

@ -229,6 +229,7 @@ export const updateAlwaysOnTop = async (
}
if (browserWins.length > 0) {
browserWins
.filter((browser) => browser && windowExists(browser))
.filter((browser) => typeof browser.notificationData !== 'object')
.forEach((browser) => browser.setAlwaysOnTop(shouldSetAlwaysOnTop));

View File

@ -170,7 +170,7 @@ export class WindowHandler {
private screenSharingFrameWindow: Electron.BrowserWindow | null = null;
private basicAuthWindow: Electron.BrowserWindow | null = null;
private notificationSettingsWindow: Electron.BrowserWindow | null = null;
private snippingToolWindow: Electron.BrowserWindow | null = null;
private snippingToolWindow: ICustomBrowserWindow | null = null;
private finishedLoading: boolean = false;
private readonly opts: Electron.BrowserViewConstructorOptions | undefined;
private hideOnCapture: boolean = false;
@ -1364,7 +1364,11 @@ export class WindowHandler {
opts.modal = true;
}
this.snippingToolWindow = createComponentWindow('snipping-tool', opts);
this.snippingToolWindow = createComponentWindow(
'snipping-tool',
opts,
) as ICustomBrowserWindow;
this.snippingToolWindow.winName = apiName.snippingToolWindowName;
this.moveWindow(this.snippingToolWindow, undefined, parentWindow);
this.snippingToolWindow.setVisibleOnAllWorkspaces(true);

View File

@ -1007,6 +1007,9 @@ export const didVerifyAndRestoreWindow = (
if (browserWindow.isMinimized()) {
browserWindow.restore();
}
if (!browserWindow.isVisible()) {
browserWindow.show();
}
browserWindow.focus();
return true;
};

View File

@ -83,6 +83,7 @@ export enum apiName {
mainWindowName = 'main',
notificationWindowName = 'notification-window',
welcomeScreenName = 'welcome-screen',
snippingToolWindowName = 'snipping-tool-window',
}
export const NOTIFICATION_WINDOW_TITLE = 'Notification - Symphony';