Skip to content

Commit

Permalink
SDA-4452 Focus on current window after taking a screenshot (finos#2077)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
sbenmoussati authored Jan 16, 2024
1 parent bafe626 commit 0bb3f14
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions src/app/screen-snippet-handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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 (
Expand All @@ -362,15 +366,15 @@ class ScreenSnippet {
`screen-snippet-handler: upload of screen capture failed with error: ${error}!`,
);
}
webContents.focus();
focusedWindow?.webContents.focus();
},
);
}

/**
* Close the current snippet
*/
private closeSnippet(webContents: WebContents) {
private closeSnippet(webContents: WebContents | undefined) {
ipcMain.once(ScreenShotAnnotation.CLOSE, async (_event) => {
try {
windowHandler.closeSnippingToolWindow();
Expand All @@ -381,7 +385,6 @@ class ScreenSnippet {
`screen-snippet-handler: close window failed with error: ${error}!`,
);
}

webContents?.focus();
});
}
Expand Down

0 comments on commit 0bb3f14

Please sign in to comment.