NWJS Version : latest (HEAD)
Operating System : Arch Linux / GNOME3
API Question / Unclear API
I figured out that after reading several issues (e.g. #2384 #2178 #2383), stackoverflow posts (e.g. https://stackoverflow.com/questions/22438235/node-webkit-nwjs-how-to-align-window-to-the-right) and the online API docs that there is a GUI API for Screen handling available. However, this API works fine and works as intended; but it is unclear how to actually use it in order to move windows to a different screen.
On my main system, I have 3 different screens:
const GUI = require('nw.gui');
let screens = GUI.Screen.screens;
screens.length; // 3, all working properly with x/y being different and correct width/height properties.
When I want to use the window’s moveTo(x,y)
API, the window will stay on the screen where it spawned (the primary screen of the OS, in my case the middle screen).
window.window.moveTo(1920, 0); // void API, window moved to the right corner of the middle screen
window.window.moveTo(1920*2, 0); // void API, window unchanged
window.window.moveBy(200, 0); // void API, window unchanged
I also searched the docs regarding combinations of window and screen, but I did not find any API that uses both in order to make a window appear on a different screen.
The window.window.screen
API is a read-API, and does not change the actual screen, so I cannot do something like this: window.window.screen = screens[2]
.
My questions are now the following:
- How do I change the screen on which the window is positioned?
- Is there an alternative manifest position – e.g. like “right” or “left”?
You just need to find the target screen’s offsets: