mirror of
https://github.com/finos/SymphonyElectron.git
synced 2024-12-28 09:51:06 -06:00
Merge pull request #1275 from johankwarnmarksymphony/sda-3418
Only use our native screen-snippet tool on Windows
This commit is contained in:
commit
c509db990a
@ -177,7 +177,7 @@
|
||||
},
|
||||
"optionalDependencies": {
|
||||
"auto-update": "file:auto_update",
|
||||
"screen-snippet": "git+https://github.com/symphonyoss/ScreenSnippet2.git#v2.4.0",
|
||||
"screen-snippet": "git+https://github.com/symphonyoss/ScreenSnippet2.git#9.2.2",
|
||||
"screen-share-indicator-frame": "git+https://github.com/symphonyoss/ScreenShareIndicatorFrame.git#v1.4.10",
|
||||
"swift-search": "2.0.3"
|
||||
},
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { app, BrowserWindow, clipboard, ipcMain, nativeImage } from 'electron';
|
||||
import { app, BrowserWindow, ipcMain, nativeImage } from 'electron';
|
||||
import * as fs from 'fs';
|
||||
import * as os from 'os';
|
||||
import * as path from 'path';
|
||||
@ -28,7 +28,6 @@ const readFile = util.promisify(fs.readFile);
|
||||
|
||||
class ScreenSnippet {
|
||||
private readonly tempDir: string;
|
||||
private readonly isOldWindows: boolean;
|
||||
private outputFilePath: string | undefined;
|
||||
private captureUtil: string;
|
||||
private captureUtilArgs: ReadonlyArray<string>;
|
||||
@ -45,16 +44,6 @@ class ScreenSnippet {
|
||||
fs.mkdirSync(this.tempDir);
|
||||
}
|
||||
}
|
||||
this.isOldWindows =
|
||||
isWindowsOS &&
|
||||
(parseInt(os.release().split('.')[0], 10) < 10 ||
|
||||
parseInt(os.release().split('.')[2], 10) < 15002);
|
||||
|
||||
logger.info(
|
||||
`screen-snippet-handler: isOldWindows ${
|
||||
this.isOldWindows
|
||||
} os.release: ${os.release()}`,
|
||||
);
|
||||
|
||||
this.captureUtil = '';
|
||||
this.captureUtilArgs = [];
|
||||
@ -96,29 +85,25 @@ class ScreenSnippet {
|
||||
'symphonyImage-' + Date.now() + '.png',
|
||||
);
|
||||
|
||||
let usingClipboard = false;
|
||||
if (isMac) {
|
||||
logger.info('screen-snippet-handler: Mac');
|
||||
this.captureUtil = '/usr/sbin/screencapture';
|
||||
this.captureUtilArgs = ['-i', '-s', '-t', 'png', this.outputFilePath];
|
||||
} else if (isWindowsOS) {
|
||||
logger.info('screen-snippet-handler: Windows');
|
||||
if (windowHandler.isMana) {
|
||||
if (this.isOldWindows) {
|
||||
this.captureUtil = isDevEnv
|
||||
? path.join(
|
||||
__dirname,
|
||||
'../../../node_modules/screen-snippet/ScreenSnippet.exe',
|
||||
)
|
||||
: path.join(path.dirname(app.getPath('exe')), 'ScreenSnippet.exe');
|
||||
this.captureUtilArgs = [
|
||||
'--no-annotate',
|
||||
this.outputFilePath,
|
||||
i18n.getLocale(),
|
||||
];
|
||||
} else {
|
||||
this.captureUtil = 'SnippingTool';
|
||||
this.captureUtilArgs = ['/clip'];
|
||||
usingClipboard = true;
|
||||
}
|
||||
logger.info('screen-snippet-handler: Mana, no native annotate');
|
||||
this.captureUtil = isDevEnv
|
||||
? path.join(
|
||||
__dirname,
|
||||
'../../../node_modules/screen-snippet/ScreenSnippet.exe',
|
||||
)
|
||||
: path.join(path.dirname(app.getPath('exe')), 'ScreenSnippet.exe');
|
||||
this.captureUtilArgs = [
|
||||
'--no-annotate',
|
||||
this.outputFilePath,
|
||||
i18n.getLocale(),
|
||||
];
|
||||
} else {
|
||||
this.captureUtil = isDevEnv
|
||||
? path.join(
|
||||
@ -147,17 +132,8 @@ class ScreenSnippet {
|
||||
this.killChildProcess();
|
||||
}
|
||||
try {
|
||||
if (usingClipboard) {
|
||||
logger.info(
|
||||
`screen-snippet-handler: Using clipboard when capturing screen snippet`,
|
||||
);
|
||||
clipboard.clear();
|
||||
await this.execCmd(this.captureUtil, this.captureUtilArgs);
|
||||
fs.writeFileSync(this.outputFilePath, clipboard.readImage().toPNG());
|
||||
clipboard.clear();
|
||||
} else {
|
||||
await this.execCmd(this.captureUtil, this.captureUtilArgs);
|
||||
}
|
||||
await this.execCmd(this.captureUtil, this.captureUtilArgs);
|
||||
|
||||
if (windowHandler.isMana) {
|
||||
logger.info(
|
||||
'screen-snippet-handler: Attempting to extract image dimensions from: ' +
|
||||
|
Loading…
Reference in New Issue
Block a user