The Screen API – screen geometry functions
The Screen API has been lately added in order to better handle window sizing and positioning on single or multiple screens. Run the following code:
var gui = require('nw.gui'); gui.Screen.Init(); // Screen API is a Singleton var screens = gui.Screen.screens;
You'll get an array of screen
objects. Each screen
object has the following structure:
screen { // unique id for a screen id : 69673536, // physical screen resolution bounds : { x : 0, y : 0, width : 1280, height : 800 }, // useable area within the screen bound work_area : { x : 0, y : 23, width : 1280, height : 773 }, scaleFactor : 1, isBuiltIn : false }
You can easily access any of these properties in order to improve the user experience. Let's say, for example, that you want to position your window in the top-right corner of the screen. On Microsoft Windows, you would probably proceed as follows:
var gui = require...