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,55 +465,54 @@ class ScreenSnippet {
const windowObj = winStore.getWindowStore();
const currentWindowName = (currentWindowObj as ICustomBrowserWindow)
?.winName;
if (windowObj.windows.length < 1) {
const allWindows = BrowserWindow.getAllWindows();
let windowsArr: IWindowState[] = [];
const mainArr: IWindowState[] = [
{
id: 'main',
focused: mainWindow?.isFocused(),
minimized: mainWindow?.isMinimized(),
isFullScreen: mainWindow?.isFullScreen(),
isVisible: mainWindow?.isVisible(),
isAlwaysOnTop: mainWindow?.isAlwaysOnTop(),
},
];
allWindows.forEach((window) => {
if (
(window as ICustomBrowserWindow).winName !== currentWindowName &&
(window as ICustomBrowserWindow).winName !== 'main' &&
(window as ICustomBrowserWindow).winName !==
apiName.notificationWindowName
) {
windowsArr.push({
id: (window as ICustomBrowserWindow).winName,
focused: window.isFocused(),
minimized: window?.isMinimized(),
isFullScreen: window?.isFullScreen(),
isVisible: window?.isVisible(),
isAlwaysOnTop: window?.isAlwaysOnTop(),
});
}
});
if (currentWindowName !== 'main') {
windowsArr.push({
id: currentWindowName,
focused: currentWindowObj?.isFocused(),
minimized: currentWindowObj?.isMinimized(),
isFullScreen: currentWindowObj?.isFullScreen(),
isVisible: currentWindowObj?.isVisible(),
isAlwaysOnTop: currentWindowObj?.isAlwaysOnTop(),
});
windowsArr = mainArr.concat(windowsArr);
} else {
windowsArr = windowsArr.concat(mainArr);
}
winStore.setWindowStore({
windows: windowsArr,
});
if (windowObj.windows.length > 0) {
winStore.destroyWindowStore();
}
const allWindows = BrowserWindow.getAllWindows();
let windowsArr: IWindowState[] = [];
const mainArr: IWindowState[] = [
{
id: 'main',
focused: mainWindow?.isFocused(),
minimized: mainWindow?.isMinimized(),
isFullScreen: mainWindow?.isFullScreen(),
isVisible: mainWindow?.isVisible(),
},
];
allWindows.forEach((window) => {
if (
(window as ICustomBrowserWindow).winName &&
(window as ICustomBrowserWindow).winName !== currentWindowName &&
(window as ICustomBrowserWindow).winName !== 'main' &&
(window as ICustomBrowserWindow).winName !==
apiName.notificationWindowName
) {
windowsArr.push({
id: (window as ICustomBrowserWindow).winName,
focused: window.isFocused(),
minimized: window?.isMinimized(),
isFullScreen: window?.isFullScreen(),
isVisible: window?.isVisible(),
});
}
});
if (currentWindowName !== 'main') {
windowsArr.push({
id: currentWindowName,
focused: currentWindowObj?.isFocused(),
minimized: currentWindowObj?.isMinimized(),
isFullScreen: currentWindowObj?.isFullScreen(),
isVisible: currentWindowObj?.isVisible(),
});
windowsArr = mainArr.concat(windowsArr);
} else {
windowsArr = windowsArr.concat(mainArr);
}
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';