SDA-4452 Focus on current window after taking a screenshot (#2077)

* SDA-4422 Bug - Workaroud for frameless transparent windows titlebar being displayed

* SDA-4452 Focus on current window after taking a screenshot

* SDA-4452 Focus on current window after cancelling screenshot
This commit is contained in:
Salah Benmoussati authored and GitHub committed 2024-01-16 10:10:54 +01:00
1 parent bafe62616d
commit 0bb3f1449e
1 file changed
+9 -6
+9 -6
View File
@@ -186,8 +186,8 @@ class ScreenSnippet {
currentWindowName,
hideOnCapture,
);
this.uploadSnippet(webContents, hideOnCapture);
this.closeSnippet(webContents);
this.uploadSnippet(currentWindowObj, webContents, hideOnCapture);
this.closeSnippet(currentWindowObj?.webContents);
this.copyToClipboard();
this.saveAs();
return;
@@ -335,7 +335,11 @@ class ScreenSnippet {
* Uploads a screen snippet
* @param webContents A browser window's web contents object
*/
private uploadSnippet(webContents: WebContents, hideOnCapture?: boolean) {
private uploadSnippet(
focusedWindow: BrowserWindow | null,
webContents: WebContents,
hideOnCapture?: boolean,
) {
ipcMain.once(
'upload-snippet',
async (
@@ -362,7 +366,7 @@ class ScreenSnippet {
`screen-snippet-handler: upload of screen capture failed with error: ${error}!`,
);
}
webContents.focus();
focusedWindow?.webContents.focus();
},
);
}
@@ -370,7 +374,7 @@ class ScreenSnippet {
/**
* Close the current snippet
*/
private closeSnippet(webContents: WebContents) {
private closeSnippet(webContents: WebContents | undefined) {
ipcMain.once(ScreenShotAnnotation.CLOSE, async (_event) => {
try {
windowHandler.closeSnippingToolWindow();
@@ -381,7 +385,6 @@ class ScreenSnippet {
`screen-snippet-handler: close window failed with error: ${error}!`,
);
}
webContents?.focus();
});
}