-
Notifications
You must be signed in to change notification settings - Fork 102
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Overlay issues with preview display and HTML CANVAS #1376
Comments
我有着同样的需求。 translation: I have the same requirement. My current solution is to create a separate B window to output the OBS screen, and set the background of the A window to be transparent where it needs to be displayed. |
@naive0817 然后强制B窗口固定显示在A窗口下方吗? |
是的, 我利用了子窗口一定会位于父窗口上方的特性. 以下是代码片段: const mainWindow = new BrowserWindow({
autoHideMenuBar: true,
titleBarOverlay: {
height: 30,
},
...
});
const childWindow = new BrowserWindow({
parent: mainWindow,
transparent: true,
frame: false,
...
});
combineMainAndChildWindow(mainWindow, childWindow)
app.obs.bind(mainWindow)
// 将主窗口和子窗口绑定在一起, 实现同步移动和缩放
function combineMainAndChildWindow(mainWindow: BrowserWindow, childWindow: BrowserWindow) {
function resize() {
const [width, height] = mainWindow.getContentSize();
childWindow.setContentSize(width, height);
}
function move() {
const yOffset = 30;
const [x, y] = mainWindow.getPosition();
childWindow.setPosition(x + 8, y + yOffset);
}
mainWindow.on('resize', () => {
if (mainWindow.isMinimized()) {
return;
}
resize();
// move();
});
// 监听主窗口的move事件
mainWindow.on('move', () => {
if (mainWindow.isMinimized()) {
return;
}
resize();
move();
});
mainWindow.on('moved', () => {
if (mainWindow.isMinimized()) {
return;
}
move();
});
mainWindow.on('maximize', () => {
resize();
move();
});
mainWindow.on('unmaximize', () => {
resize();
move();
});
mainWindow.on('minimize', () => {
childWindow.minimize();
});
mainWindow.on('restore', () => {
childWindow.restore();
resize();
move();
});
childWindow.on('restore', () => {
mainWindow.restore();
resize();
move();
});
// 失去焦点时重定位(解决多屏幕下, 点击B屏幕时, A屏幕的窗口消失问题)
childWindow.on('blur', () => {
if (!BrowserWindow.getFocusedWindow()) {
move();
resize();
}
});
return [resize, move];
} |
请问可以将display输出到指定的canvas元素吗?
感觉这个问题没有得到很好的回答。
#1229
The text was updated successfully, but these errors were encountered: