diff --git a/installer/win/Symphony-x64.aip b/installer/win/Symphony-x64.aip index 92e41dcb..bc559585 100644 --- a/installer/win/Symphony-x64.aip +++ b/installer/win/Symphony-x64.aip @@ -127,9 +127,6 @@ - - - @@ -166,7 +163,7 @@ - + @@ -175,12 +172,8 @@ + - - - - - @@ -269,7 +262,7 @@ - + @@ -277,7 +270,7 @@ - + diff --git a/installer/win/Symphony-x86.aip b/installer/win/Symphony-x86.aip index c51c1296..a02d457e 100644 --- a/installer/win/Symphony-x86.aip +++ b/installer/win/Symphony-x86.aip @@ -126,9 +126,6 @@ - - - @@ -165,7 +162,7 @@ - + @@ -174,12 +171,8 @@ + - - - - - @@ -276,7 +269,7 @@ - + diff --git a/package-lock.json b/package-lock.json index 7dfae368..42c6e816 100644 --- a/package-lock.json +++ b/package-lock.json @@ -13065,8 +13065,8 @@ "optional": true }, "screen-snippet": { - "version": "1.0.3", - "resolved": "git+https://github.com/symphonyoss/ScreenSnippet.git#84d3edb6656e2dbf5d8438336c51f80b0be1c8ad", + "version": "1.0.0", + "resolved": "git+https://github.com/symphonyoss/ScreenSnippet2.git#4bd0f9b76d3d99f341b344ef4d9264a0a6bc62a8", "optional": true }, "semver": { diff --git a/package.json b/package.json index 18e55e0e..7f67f5ca 100644 --- a/package.json +++ b/package.json @@ -132,8 +132,8 @@ "shell-path": "2.1.0" }, "optionalDependencies": { - "screen-snippet": "git+https://github.com/symphonyoss/ScreenSnippet.git#v1.0.8", - "screen-share-indicator-frame": "https://github.com/symphonyoss/ScreenShareIndicatorFrame.git#v1.0.0", + "screen-snippet": "git+https://github.com/symphonyoss/ScreenSnippet2.git#v1.0.0", + "screen-share-indicator-frame": "git+https://github.com/symphonyoss/ScreenShareIndicatorFrame.git#v1.0.0", "swift-search": "2.0.1" } } diff --git a/src/app/main-api-handler.ts b/src/app/main-api-handler.ts index 4d0d513f..ac96d0b0 100644 --- a/src/app/main-api-handler.ts +++ b/src/app/main-api-handler.ts @@ -124,6 +124,9 @@ ipcMain.on(apiName.symphonyApi, (event: Electron.IpcMainEvent, arg: IApiArgs) => case apiCmds.openScreenSnippet: screenSnippet.capture(event.sender); break; + case apiCmds.closeScreenSnippet: + screenSnippet.cancelCapture(); + break; case apiCmds.closeWindow: windowHandler.closeWindow(arg.windowType, arg.winKey); break; diff --git a/src/app/screen-snippet-handler.ts b/src/app/screen-snippet-handler.ts index f7df0dfd..bc6cae16 100644 --- a/src/app/screen-snippet-handler.ts +++ b/src/app/screen-snippet-handler.ts @@ -25,7 +25,7 @@ class ScreenSnippet { this.tempDir = os.tmpdir(); this.captureUtil = isMac ? '/usr/sbin/screencapture' : isDevEnv ? path.join(__dirname, - '../../node_modules/screen-snippet/bin/Release/ScreenSnippet.exe') + '../../../node_modules/screen-snippet/ScreenSnippet.exe') : path.join(path.dirname(app.getPath('exe')), 'ScreenSnippet.exe'); if (isLinux) { @@ -67,6 +67,22 @@ class ScreenSnippet { } } + /** + * Cancels a screen capture and closes the snippet window + * + * @param webContents {Electron.webContents} + */ + public async cancelCapture() { + logger.info(`screen-snippet-handler: Cancel screen capture!`); + this.focusedWindow = BrowserWindow.getFocusedWindow(); + + try { + await this.execCmd(this.captureUtil, []); + } catch (error) { + logger.error(`screen-snippet-handler: screen capture cancel failed with error: ${error}!`); + } + } + /** * Kills the child process when the application is reloaded */ @@ -88,6 +104,7 @@ class ScreenSnippet { * @example execCmd('-i -s', '/user/desktop/symphonyImage-1544025391698.png') */ private execCmd(captureUtil: string, captureUtilArgs: ReadonlyArray): Promise { + logger.info(`screen-snippet-handlers: execCmd ${captureUtil} ${captureUtilArgs}`); return new Promise((resolve, reject) => { return this.child = execFile(captureUtil, captureUtilArgs, (error: ExecException | null) => { if (error && error.killed) { diff --git a/src/common/api-interface.ts b/src/common/api-interface.ts index 140932a5..9c0fbb52 100644 --- a/src/common/api-interface.ts +++ b/src/common/api-interface.ts @@ -21,6 +21,7 @@ export enum apiCmds { setIsInMeeting = 'set-is-in-meeting', setLocale = 'set-locale', openScreenSnippet = 'open-screen-snippet', + closeScreenSnippet = 'close-screen-snippet', keyPress = 'key-press', closeWindow = 'close-window', openScreenSharingIndicator = 'open-screen-sharing-indicator', diff --git a/src/demo/index.html b/src/demo/index.html index 08bb79db..16b63a09 100644 --- a/src/demo/index.html +++ b/src/demo/index.html @@ -124,6 +124,7 @@

snippet output:

+

Logs:

@@ -199,6 +200,7 @@ setIsInMeeting: 'set-is-in-meeting', setLocale: 'set-locale', openScreenSnippet: 'open-screen-snippet', + closeScreenSnippet: 'close-screen-snippet', keyPress: 'key-press', closeWindow: 'close-window', openScreenSharingIndicator: 'open-screen-sharing-indicator', @@ -322,6 +324,16 @@ } }); + const cancelSnippetButton = document.getElementById('cancel-snippet'); + cancelSnippetButton.addEventListener('click', () => { + if (window.ssf) { + const screenSnippet = new window.ssf.ScreenSnippet(); + screenSnippet.cancelCapture(); + } else { + postMessage(apiCmds.closeScreenSnippet) + } + }); + let win; const openWinButton = document.getElementById('open-win'); diff --git a/src/renderer/app-bridge.ts b/src/renderer/app-bridge.ts index 7b24555f..5a06389a 100644 --- a/src/renderer/app-bridge.ts +++ b/src/renderer/app-bridge.ts @@ -115,6 +115,9 @@ export class AppBridge { case apiCmds.openScreenSnippet: ssf.openScreenSnippet(this.callbackHandlers.onScreenSnippetCallback); break; + case apiCmds.closeScreenSnippet: + ssf.closeScreenSnippet(); + break; case apiCmds.registerBoundsChange: ssf.registerBoundsChange(this.callbackHandlers.onRegisterBoundsChangeCallback); break; diff --git a/src/renderer/screen-snippet-bc-handler.ts b/src/renderer/screen-snippet-bc-handler.ts index cf2ee2a0..ace1dea8 100644 --- a/src/renderer/screen-snippet-bc-handler.ts +++ b/src/renderer/screen-snippet-bc-handler.ts @@ -24,4 +24,14 @@ export class ScreenSnippetBcHandler { }); }); } + /** + * cancel capture method to support backward compatibility + * + * @deprecated user closeScreenSnippet instead + */ + public cancel() { + ipcRenderer.send(apiName.symphonyApi, { + cmd: apiCmds.closeScreenSnippet, + }); + } } diff --git a/src/renderer/ssf-api.ts b/src/renderer/ssf-api.ts index 950e22fe..c5c833ea 100644 --- a/src/renderer/ssf-api.ts +++ b/src/renderer/ssf-api.ts @@ -332,6 +332,17 @@ export class SSFApi { } } + /** + * Cancel a screen capture in progress + * + * @param screenSnippetCallback {function} + */ + public closeScreenSnippet(): void { + local.ipcRenderer.send(apiName.symphonyApi, { + cmd: apiCmds.closeScreenSnippet, + }); + } + /** * Sets the count on the tray icon to the given number. *