mirror of
https://github.com/finos/SymphonyElectron.git
synced 2026-10-24 13:57:39 -05:00
SDA-3971 HWND retriever helper for Windows (#1695)
This commit is contained in:
1 parent
d58e8d41d6
commit
6d64182e4a
5 files changed
+108
-15
No files matched your search
@@ -66,6 +66,7 @@ class Script
|
|||||||
new File(@"..\..\..\dist\win-unpacked\vulkan-1.dll"),
|
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-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\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 Dir(@"config",
|
||||||
new Files(@"..\..\..\dist\win-unpacked\config\*.*")
|
new Files(@"..\..\..\dist\win-unpacked\config\*.*")
|
||||||
),
|
),
|
||||||
|
|||||||
Generated
+26
-9
@@ -26,6 +26,7 @@
|
|||||||
"rimraf": "^3.0.2",
|
"rimraf": "^3.0.2",
|
||||||
"save-svg-as-png": "^1.4.17",
|
"save-svg-as-png": "^1.4.17",
|
||||||
"shell-path": "^3.0.0",
|
"shell-path": "^3.0.0",
|
||||||
|
"symphony-native-window-handle-helper": "github:finos/SymphonyWindowsHwndHelper#1.0.1",
|
||||||
"win32-api": "^20.1.0"
|
"win32-api": "^20.1.0"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
@@ -41,7 +42,7 @@
|
|||||||
"builder-util-runtime": "^9.0.3",
|
"builder-util-runtime": "^9.0.3",
|
||||||
"cross-env": "5.2.1",
|
"cross-env": "5.2.1",
|
||||||
"del": "3.0.0",
|
"del": "3.0.0",
|
||||||
"electron": "^22.0.0",
|
"electron": "^22.0.3",
|
||||||
"electron-builder": "23.6.0",
|
"electron-builder": "23.6.0",
|
||||||
"electron-builder-squirrel-windows": "20.44.0",
|
"electron-builder-squirrel-windows": "20.44.0",
|
||||||
"electron-icon-maker": "0.0.5",
|
"electron-icon-maker": "0.0.5",
|
||||||
@@ -76,8 +77,9 @@
|
|||||||
},
|
},
|
||||||
"optionalDependencies": {
|
"optionalDependencies": {
|
||||||
"@symphony/symphony-c9-shell": "3.19.0-0.98.8.132",
|
"@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-share-indicator-frame": "git+https://github.com/finos/ScreenShareIndicatorFrame.git#v1.4.13",
|
||||||
"screen-snippet": "git+https://github.com/symphonyoss/ScreenSnippet2.git#9.2.2",
|
"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"
|
"winreg": "^1.2.4"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -7373,9 +7375,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/electron": {
|
"node_modules/electron": {
|
||||||
"version": "22.0.0",
|
"version": "22.0.3",
|
||||||
"resolved": "https://registry.npmjs.org/electron/-/electron-22.0.0.tgz",
|
"resolved": "https://repo.symphony.com/artifactory/api/npm/npm-virtual-dev/electron/-/electron-22.0.3.tgz",
|
||||||
"integrity": "sha512-cgRc4wjyM+81A0E8UGv1HNJjL1HBI5cWNh/DUIjzYvoUuiEM0SS0hAH/zaFQ18xOz2ced6Yih8SybpOiOYJhdg==",
|
"integrity": "sha1-RIBs0FPqLtNb/+/ZIUPT/GnXM30=",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"hasInstallScript": true,
|
"hasInstallScript": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
@@ -18953,6 +18955,16 @@
|
|||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "MIT"
|
"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": {
|
"node_modules/syntax-error": {
|
||||||
"version": "1.4.0",
|
"version": "1.4.0",
|
||||||
"resolved": "https://repo.symphony.com/artifactory/api/npm/npm-virtual-dev/syntax-error/-/syntax-error-1.4.0.tgz",
|
"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
|
"peer": true
|
||||||
},
|
},
|
||||||
"electron": {
|
"electron": {
|
||||||
"version": "22.0.0",
|
"version": "22.0.3",
|
||||||
"resolved": "https://registry.npmjs.org/electron/-/electron-22.0.0.tgz",
|
"resolved": "https://repo.symphony.com/artifactory/api/npm/npm-virtual-dev/electron/-/electron-22.0.3.tgz",
|
||||||
"integrity": "sha512-cgRc4wjyM+81A0E8UGv1HNJjL1HBI5cWNh/DUIjzYvoUuiEM0SS0hAH/zaFQ18xOz2ced6Yih8SybpOiOYJhdg==",
|
"integrity": "sha1-RIBs0FPqLtNb/+/ZIUPT/GnXM30=",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"requires": {
|
"requires": {
|
||||||
"@electron/get": "^2.0.0",
|
"@electron/get": "^2.0.0",
|
||||||
@@ -35150,6 +35162,11 @@
|
|||||||
"integrity": "sha1-QwY30ki6d+B4iDlR+5qg7tfGP6I=",
|
"integrity": "sha1-QwY30ki6d+B4iDlR+5qg7tfGP6I=",
|
||||||
"dev": true
|
"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": {
|
"syntax-error": {
|
||||||
"version": "1.4.0",
|
"version": "1.4.0",
|
||||||
"resolved": "https://repo.symphony.com/artifactory/api/npm/npm-virtual-dev/syntax-error/-/syntax-error-1.4.0.tgz",
|
"resolved": "https://repo.symphony.com/artifactory/api/npm/npm-virtual-dev/syntax-error/-/syntax-error-1.4.0.tgz",
|
||||||
|
|||||||
+8
-3
@@ -122,6 +122,10 @@
|
|||||||
"from": "node_modules/screen-snippet/ScreenSnippet.exe",
|
"from": "node_modules/screen-snippet/ScreenSnippet.exe",
|
||||||
"to": "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",
|
"from": "node_modules/@symphony/symphony-c9-shell/shell",
|
||||||
"to": "cloud9/shell",
|
"to": "cloud9/shell",
|
||||||
@@ -168,7 +172,7 @@
|
|||||||
"builder-util-runtime": "^9.0.3",
|
"builder-util-runtime": "^9.0.3",
|
||||||
"cross-env": "5.2.1",
|
"cross-env": "5.2.1",
|
||||||
"del": "3.0.0",
|
"del": "3.0.0",
|
||||||
"electron": "^22.0.0",
|
"electron": "^22.0.3",
|
||||||
"electron-builder": "23.6.0",
|
"electron-builder": "23.6.0",
|
||||||
"electron-builder-squirrel-windows": "20.44.0",
|
"electron-builder-squirrel-windows": "20.44.0",
|
||||||
"electron-icon-maker": "0.0.5",
|
"electron-icon-maker": "0.0.5",
|
||||||
@@ -221,8 +225,9 @@
|
|||||||
},
|
},
|
||||||
"optionalDependencies": {
|
"optionalDependencies": {
|
||||||
"@symphony/symphony-c9-shell": "3.19.0-0.98.8.132",
|
"@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-share-indicator-frame": "git+https://github.com/finos/ScreenShareIndicatorFrame.git#v1.4.13",
|
||||||
"screen-snippet": "git+https://github.com/symphonyoss/ScreenSnippet2.git#9.2.2",
|
"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"
|
"winreg": "^1.2.4"
|
||||||
},
|
},
|
||||||
"ava": {
|
"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\screen-share-indicator-frame\ScreenShareIndicatorFrame.exe
|
||||||
|
|
||||||
|
call %SIGNING_FILE_PATH% node_modules\symphony-native-window-handle-helper\SymphonyNativeWindowHandleHelper.exe
|
||||||
|
|
||||||
|
|
||||||
IF %errorlevel% neq 0 (
|
IF %errorlevel% neq 0 (
|
||||||
echo "Signing failed"
|
echo "Signing failed"
|
||||||
exit /b -1
|
exit /b -1
|
||||||
|
|||||||
+69
-3
@@ -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
|
* 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.
|
* that is positioned below the title bar.
|
||||||
* @returns translated window handle, or original handle if no applicable translation found
|
* @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) {
|
if (!isWindowsOS) {
|
||||||
return nativeWindowHandle;
|
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;
|
||||||
};
|
};
|
||||||
Reference in new issue
Block a user