mirror of
https://github.com/finos/SymphonyElectron.git
synced 2024-11-21 16:38:41 -06:00
SDA-3971 HWND retriever helper for Windows (#1695)
This commit is contained in:
parent
d58e8d41d6
commit
6d64182e4a
@ -66,6 +66,7 @@ class Script
|
||||
new File(@"..\..\..\dist\win-unpacked\vulkan-1.dll"),
|
||||
new File(@"..\..\..\dist\win-unpacked\resources\app.asar.unpacked\node_modules\screen-share-indicator-frame\ScreenShareIndicatorFrame.exe"),
|
||||
new File(@"..\..\..\dist\win-unpacked\resources\app.asar.unpacked\node_modules\screen-snippet\ScreenSnippet.exe"),
|
||||
new File(@"..\..\..\dist\win-unpacked\resources\app.asar.unpacked\node_modules\symphony-native-window-handle-helper\SymphonyNativeWindowHandleHelper.exe"),
|
||||
new Dir(@"config",
|
||||
new Files(@"..\..\..\dist\win-unpacked\config\*.*")
|
||||
),
|
||||
|
35
package-lock.json
generated
35
package-lock.json
generated
@ -26,6 +26,7 @@
|
||||
"rimraf": "^3.0.2",
|
||||
"save-svg-as-png": "^1.4.17",
|
||||
"shell-path": "^3.0.0",
|
||||
"symphony-native-window-handle-helper": "github:finos/SymphonyWindowsHwndHelper#1.0.1",
|
||||
"win32-api": "^20.1.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
@ -41,7 +42,7 @@
|
||||
"builder-util-runtime": "^9.0.3",
|
||||
"cross-env": "5.2.1",
|
||||
"del": "3.0.0",
|
||||
"electron": "^22.0.0",
|
||||
"electron": "^22.0.3",
|
||||
"electron-builder": "23.6.0",
|
||||
"electron-builder-squirrel-windows": "20.44.0",
|
||||
"electron-icon-maker": "0.0.5",
|
||||
@ -76,8 +77,9 @@
|
||||
},
|
||||
"optionalDependencies": {
|
||||
"@symphony/symphony-c9-shell": "3.19.0-0.98.8.132",
|
||||
"screen-share-indicator-frame": "git+https://github.com/symphonyoss/ScreenShareIndicatorFrame.git#v1.4.13",
|
||||
"screen-snippet": "git+https://github.com/symphonyoss/ScreenSnippet2.git#9.2.2",
|
||||
"screen-share-indicator-frame": "git+https://github.com/finos/ScreenShareIndicatorFrame.git#v1.4.13",
|
||||
"screen-snippet": "git+https://github.com/finos/ScreenSnippet2.git#9.2.2",
|
||||
"symphony-native-window-handle-helper": "github:finos/SymphonyWindowsHwndHelper#1.0.1",
|
||||
"winreg": "^1.2.4"
|
||||
}
|
||||
},
|
||||
@ -7373,9 +7375,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/electron": {
|
||||
"version": "22.0.0",
|
||||
"resolved": "https://registry.npmjs.org/electron/-/electron-22.0.0.tgz",
|
||||
"integrity": "sha512-cgRc4wjyM+81A0E8UGv1HNJjL1HBI5cWNh/DUIjzYvoUuiEM0SS0hAH/zaFQ18xOz2ced6Yih8SybpOiOYJhdg==",
|
||||
"version": "22.0.3",
|
||||
"resolved": "https://repo.symphony.com/artifactory/api/npm/npm-virtual-dev/electron/-/electron-22.0.3.tgz",
|
||||
"integrity": "sha1-RIBs0FPqLtNb/+/ZIUPT/GnXM30=",
|
||||
"dev": true,
|
||||
"hasInstallScript": true,
|
||||
"dependencies": {
|
||||
@ -18953,6 +18955,16 @@
|
||||
"dev": true,
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/symphony-native-window-handle-helper": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "git+ssh://git@github.com/finos/SymphonyWindowsHwndHelper.git#5b173043da34a04acf57efd4c1a4317d0a7d1fe4",
|
||||
"hasInstallScript": true,
|
||||
"license": "ISC",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"win32"
|
||||
]
|
||||
},
|
||||
"node_modules/syntax-error": {
|
||||
"version": "1.4.0",
|
||||
"resolved": "https://repo.symphony.com/artifactory/api/npm/npm-virtual-dev/syntax-error/-/syntax-error-1.4.0.tgz",
|
||||
@ -26402,9 +26414,9 @@
|
||||
"peer": true
|
||||
},
|
||||
"electron": {
|
||||
"version": "22.0.0",
|
||||
"resolved": "https://registry.npmjs.org/electron/-/electron-22.0.0.tgz",
|
||||
"integrity": "sha512-cgRc4wjyM+81A0E8UGv1HNJjL1HBI5cWNh/DUIjzYvoUuiEM0SS0hAH/zaFQ18xOz2ced6Yih8SybpOiOYJhdg==",
|
||||
"version": "22.0.3",
|
||||
"resolved": "https://repo.symphony.com/artifactory/api/npm/npm-virtual-dev/electron/-/electron-22.0.3.tgz",
|
||||
"integrity": "sha1-RIBs0FPqLtNb/+/ZIUPT/GnXM30=",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"@electron/get": "^2.0.0",
|
||||
@ -35150,6 +35162,11 @@
|
||||
"integrity": "sha1-QwY30ki6d+B4iDlR+5qg7tfGP6I=",
|
||||
"dev": true
|
||||
},
|
||||
"symphony-native-window-handle-helper": {
|
||||
"version": "git+ssh://git@github.com/finos/SymphonyWindowsHwndHelper.git#5b173043da34a04acf57efd4c1a4317d0a7d1fe4",
|
||||
"from": "symphony-native-window-handle-helper@github:finos/SymphonyWindowsHwndHelper#1.0.1",
|
||||
"optional": true
|
||||
},
|
||||
"syntax-error": {
|
||||
"version": "1.4.0",
|
||||
"resolved": "https://repo.symphony.com/artifactory/api/npm/npm-virtual-dev/syntax-error/-/syntax-error-1.4.0.tgz",
|
||||
|
11
package.json
11
package.json
@ -122,6 +122,10 @@
|
||||
"from": "node_modules/screen-snippet/ScreenSnippet.exe",
|
||||
"to": "ScreenSnippet.exe"
|
||||
},
|
||||
{
|
||||
"from": "node_modules/symphony-native-window-handle-helper/SymphonyNativeWindowHandleHelper.exe",
|
||||
"to": "SymphonyNativeWindowHandleHelper.exe"
|
||||
},
|
||||
{
|
||||
"from": "node_modules/@symphony/symphony-c9-shell/shell",
|
||||
"to": "cloud9/shell",
|
||||
@ -168,7 +172,7 @@
|
||||
"builder-util-runtime": "^9.0.3",
|
||||
"cross-env": "5.2.1",
|
||||
"del": "3.0.0",
|
||||
"electron": "^22.0.0",
|
||||
"electron": "^22.0.3",
|
||||
"electron-builder": "23.6.0",
|
||||
"electron-builder-squirrel-windows": "20.44.0",
|
||||
"electron-icon-maker": "0.0.5",
|
||||
@ -221,8 +225,9 @@
|
||||
},
|
||||
"optionalDependencies": {
|
||||
"@symphony/symphony-c9-shell": "3.19.0-0.98.8.132",
|
||||
"screen-share-indicator-frame": "git+https://github.com/symphonyoss/ScreenShareIndicatorFrame.git#v1.4.13",
|
||||
"screen-snippet": "git+https://github.com/symphonyoss/ScreenSnippet2.git#9.2.2",
|
||||
"screen-share-indicator-frame": "git+https://github.com/finos/ScreenShareIndicatorFrame.git#v1.4.13",
|
||||
"screen-snippet": "git+https://github.com/finos/ScreenSnippet2.git#9.2.2",
|
||||
"symphony-native-window-handle-helper": "github:finos/SymphonyWindowsHwndHelper#1.0.1",
|
||||
"winreg": "^1.2.4"
|
||||
},
|
||||
"ava": {
|
||||
|
@ -55,6 +55,10 @@ if NOT EXIST %SIGNING_FILE_PATH% (
|
||||
)
|
||||
|
||||
call %SIGNING_FILE_PATH% node_modules\screen-share-indicator-frame\ScreenShareIndicatorFrame.exe
|
||||
|
||||
call %SIGNING_FILE_PATH% node_modules\symphony-native-window-handle-helper\SymphonyNativeWindowHandleHelper.exe
|
||||
|
||||
|
||||
IF %errorlevel% neq 0 (
|
||||
echo "Signing failed"
|
||||
exit /b -1
|
||||
|
@ -1,4 +1,8 @@
|
||||
import { isWindowsOS } from '../common/env';
|
||||
import { ExecException, execFile } from 'child_process';
|
||||
import { app } from 'electron';
|
||||
import * as path from 'path';
|
||||
import { isDevEnv, isWindowsOS } from '../common/env';
|
||||
import { logger } from '../common/logger';
|
||||
|
||||
/**
|
||||
* Translate the nativeWindowHandle of an Electron BrowserWindow to the handle
|
||||
@ -7,9 +11,71 @@ import { isWindowsOS } from '../common/env';
|
||||
* that is positioned below the title bar.
|
||||
* @returns translated window handle, or original handle if no applicable translation found
|
||||
*/
|
||||
export const getContentWindowHandle = (nativeWindowHandle: Buffer): Buffer => {
|
||||
export const getContentWindowHandle = async (
|
||||
nativeWindowHandle: Buffer,
|
||||
): Promise<any> => {
|
||||
const execCmd = (
|
||||
captureUtil: string,
|
||||
captureUtilArgs: ReadonlyArray<string>,
|
||||
): Promise<any> => {
|
||||
logger.info(
|
||||
`screen-snippet-handlers: execCmd ${captureUtil} ${captureUtilArgs}`,
|
||||
);
|
||||
return new Promise<string>((resolve, reject) => {
|
||||
return execFile(
|
||||
captureUtil,
|
||||
captureUtilArgs,
|
||||
(error: ExecException | null, stdout: any) => {
|
||||
if (error && error.killed) {
|
||||
return reject(error);
|
||||
}
|
||||
resolve(stdout);
|
||||
},
|
||||
);
|
||||
});
|
||||
};
|
||||
|
||||
const convertBuffer = (uint8Arr: Uint8Array) => {
|
||||
let result = 0;
|
||||
for (let i = uint8Arr.length - 1; i >= 0; i--) {
|
||||
result = result * 256 + uint8Arr[i];
|
||||
}
|
||||
return result;
|
||||
};
|
||||
|
||||
const convertToUint8Array = (num: number) => {
|
||||
const arr = new Uint8Array(8);
|
||||
for (let i = 0; i < 8; i++) {
|
||||
arr[i] = num % 256;
|
||||
num = Math.floor(num / 256);
|
||||
}
|
||||
return arr;
|
||||
};
|
||||
|
||||
if (!isWindowsOS) {
|
||||
return nativeWindowHandle;
|
||||
}
|
||||
return nativeWindowHandle;
|
||||
const dec = convertBuffer(nativeWindowHandle);
|
||||
logger.info(`hwnd-handler: getting content hwnd for ${dec}`, dec);
|
||||
const hwndExecPath = isDevEnv
|
||||
? path.join(
|
||||
__dirname,
|
||||
'../../../node_modules/symphony-native-window-handle-helper/SymphonyNativeWindowHandleHelper.exe',
|
||||
)
|
||||
: path.join(
|
||||
path.dirname(app.getPath('exe')),
|
||||
'SymphonyNativeWindowHandleHelper.exe',
|
||||
);
|
||||
const hwndExecArgs = [dec.toString()];
|
||||
const output = await execCmd(hwndExecPath, hwndExecArgs);
|
||||
if (!output.length) {
|
||||
logger.error(
|
||||
'hwnd-handler: cannot retrieve the right window handle. Returning default one',
|
||||
);
|
||||
return nativeWindowHandle;
|
||||
}
|
||||
const intValue = parseInt(output, 10);
|
||||
logger.info(`hwnd-handler: returning content hwnd for ${dec}: ${intValue}`);
|
||||
const res = convertToUint8Array(intValue);
|
||||
return res;
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user