I would like to prevent moving child window to another screen.
Reason: Because there is a bug on macOS. When I drag child window to a different screen than parent window is, the child window disappears.
So I would like to prevent this, but I am not able to achieve it in some nice way. moved event is alis for move event on mac, so it is triggered quite often and window is jumping when it is dragged to another screen.
I have tried will-move, but it is triggered just once in the beginning.
My code:
childWindow.on('moved', () => { // Same as `move` on mac
const bounds = childWindow.getBounds();
const currentDisplay = screen.getDisplayNearestPoint({
x: bounds.x,
y: bounds.y,
});
const parentBounds = childWindow.getParent().getBounds();
const parentDisplay = screen.getDisplayNearestPoint({
x: parentBounds!.x,
y: parentBounds!.y,
});
if (currentDisplay.id !== parentDisplay.id) {
childWindow.setBounds({ x: 0, y: 0 }); // Here I can center the window or set proper x, y. This is just for testing purposes.
}
});