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) const currentWindowName = (currentWindowObj as ICustomBrowserWindow)
?.winName; ?.winName;
const mainWindow = windowHandler.getMainWindow(); const mainWindow = windowHandler.getMainWindow();
windowHandler.closeSnippingToolWindow();
if (hideOnCapture) { if (hideOnCapture) {
this.storeWindowsState(mainWindow, currentWindowObj); this.storeWindowsState(mainWindow, currentWindowObj);
winStore.hideWindowsOnCapturing(hideOnCapture); winStore.hideWindowsOnCapturing(hideOnCapture);
@ -465,55 +465,54 @@ class ScreenSnippet {
const windowObj = winStore.getWindowStore(); const windowObj = winStore.getWindowStore();
const currentWindowName = (currentWindowObj as ICustomBrowserWindow) const currentWindowName = (currentWindowObj as ICustomBrowserWindow)
?.winName; ?.winName;
if (windowObj.windows.length < 1) { if (windowObj.windows.length > 0) {
const allWindows = BrowserWindow.getAllWindows(); winStore.destroyWindowStore();
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,
});
} }
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; focused?: boolean;
isFullScreen?: boolean; isFullScreen?: boolean;
isVisible?: boolean; isVisible?: boolean;
isAlwaysOnTop?: boolean;
} }
export class WindowStore { export class WindowStore {
@ -104,9 +103,6 @@ export class WindowStore {
focusedWindowToRestore = window; focusedWindowToRestore = window;
} }
} }
if (currentWindow && currentWindow.isAlwaysOnTop) {
window.setAlwaysOnTop(true);
}
} }
}); });

View File

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

View File

@ -170,7 +170,7 @@ export class WindowHandler {
private screenSharingFrameWindow: Electron.BrowserWindow | null = null; private screenSharingFrameWindow: Electron.BrowserWindow | null = null;
private basicAuthWindow: Electron.BrowserWindow | null = null; private basicAuthWindow: Electron.BrowserWindow | null = null;
private notificationSettingsWindow: 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 finishedLoading: boolean = false;
private readonly opts: Electron.BrowserViewConstructorOptions | undefined; private readonly opts: Electron.BrowserViewConstructorOptions | undefined;
private hideOnCapture: boolean = false; private hideOnCapture: boolean = false;
@ -1364,7 +1364,11 @@ export class WindowHandler {
opts.modal = true; 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.moveWindow(this.snippingToolWindow, undefined, parentWindow);
this.snippingToolWindow.setVisibleOnAllWorkspaces(true); this.snippingToolWindow.setVisibleOnAllWorkspaces(true);

View File

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

View File

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