mirror of
https://github.com/finos/SymphonyElectron.git
synced 2025-02-25 18:55:29 -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": {
|
"optionalDependencies": {
|
||||||
"auto-update": "file:auto_update",
|
"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",
|
"screen-share-indicator-frame": "git+https://github.com/symphonyoss/ScreenShareIndicatorFrame.git#v1.4.10",
|
||||||
"swift-search": "2.0.3"
|
"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 fs from 'fs';
|
||||||
import * as os from 'os';
|
import * as os from 'os';
|
||||||
import * as path from 'path';
|
import * as path from 'path';
|
||||||
@ -28,7 +28,6 @@ const readFile = util.promisify(fs.readFile);
|
|||||||
|
|
||||||
class ScreenSnippet {
|
class ScreenSnippet {
|
||||||
private readonly tempDir: string;
|
private readonly tempDir: string;
|
||||||
private readonly isOldWindows: boolean;
|
|
||||||
private outputFilePath: string | undefined;
|
private outputFilePath: string | undefined;
|
||||||
private captureUtil: string;
|
private captureUtil: string;
|
||||||
private captureUtilArgs: ReadonlyArray<string>;
|
private captureUtilArgs: ReadonlyArray<string>;
|
||||||
@ -45,16 +44,6 @@ class ScreenSnippet {
|
|||||||
fs.mkdirSync(this.tempDir);
|
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.captureUtil = '';
|
||||||
this.captureUtilArgs = [];
|
this.captureUtilArgs = [];
|
||||||
@ -96,29 +85,25 @@ class ScreenSnippet {
|
|||||||
'symphonyImage-' + Date.now() + '.png',
|
'symphonyImage-' + Date.now() + '.png',
|
||||||
);
|
);
|
||||||
|
|
||||||
let usingClipboard = false;
|
|
||||||
if (isMac) {
|
if (isMac) {
|
||||||
|
logger.info('screen-snippet-handler: Mac');
|
||||||
this.captureUtil = '/usr/sbin/screencapture';
|
this.captureUtil = '/usr/sbin/screencapture';
|
||||||
this.captureUtilArgs = ['-i', '-s', '-t', 'png', this.outputFilePath];
|
this.captureUtilArgs = ['-i', '-s', '-t', 'png', this.outputFilePath];
|
||||||
} else if (isWindowsOS) {
|
} else if (isWindowsOS) {
|
||||||
|
logger.info('screen-snippet-handler: Windows');
|
||||||
if (windowHandler.isMana) {
|
if (windowHandler.isMana) {
|
||||||
if (this.isOldWindows) {
|
logger.info('screen-snippet-handler: Mana, no native annotate');
|
||||||
this.captureUtil = isDevEnv
|
this.captureUtil = isDevEnv
|
||||||
? path.join(
|
? path.join(
|
||||||
__dirname,
|
__dirname,
|
||||||
'../../../node_modules/screen-snippet/ScreenSnippet.exe',
|
'../../../node_modules/screen-snippet/ScreenSnippet.exe',
|
||||||
)
|
)
|
||||||
: path.join(path.dirname(app.getPath('exe')), 'ScreenSnippet.exe');
|
: path.join(path.dirname(app.getPath('exe')), 'ScreenSnippet.exe');
|
||||||
this.captureUtilArgs = [
|
this.captureUtilArgs = [
|
||||||
'--no-annotate',
|
'--no-annotate',
|
||||||
this.outputFilePath,
|
this.outputFilePath,
|
||||||
i18n.getLocale(),
|
i18n.getLocale(),
|
||||||
];
|
];
|
||||||
} else {
|
|
||||||
this.captureUtil = 'SnippingTool';
|
|
||||||
this.captureUtilArgs = ['/clip'];
|
|
||||||
usingClipboard = true;
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
this.captureUtil = isDevEnv
|
this.captureUtil = isDevEnv
|
||||||
? path.join(
|
? path.join(
|
||||||
@ -147,17 +132,8 @@ class ScreenSnippet {
|
|||||||
this.killChildProcess();
|
this.killChildProcess();
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
if (usingClipboard) {
|
await this.execCmd(this.captureUtil, this.captureUtilArgs);
|
||||||
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);
|
|
||||||
}
|
|
||||||
if (windowHandler.isMana) {
|
if (windowHandler.isMana) {
|
||||||
logger.info(
|
logger.info(
|
||||||
'screen-snippet-handler: Attempting to extract image dimensions from: ' +
|
'screen-snippet-handler: Attempting to extract image dimensions from: ' +
|
||||||
|
Loading…
Reference in New Issue
Block a user