Community_Basic - difference between screen & change window?

Could someone please explain what is the difference between the screenWidth and screenHeight, and changeWindowWidthTo and changeWindowHeightTo parameters in this plugin (ships with MV)?

Only screenWidth and screenHeight have default values - the others are blank.

When would I want to use the others instead?
When would I want to use them all and set them to the same values?
What would happen if I used them but the values weren't consistent?

I've looked through the plugin and I don't really understand what it's doing with them or why two options are required.

Also, what's going on in the initNwjs function at the bottom?

Clearly I have a lot to learn about MV windows.
The screenX parameters set the initial dimensions of the canvas elements the game is drawn onto. The changeWindowXTo parameters set the initial dimensions of the window. The user can resize the window but the canvas elements will scale.

When would I want to use the others instead?

Set changeWindowXTo when initial dimensions other than the screenX values are desired. (I know, doesn't sound useful.)

When would I want to use them all and set them to the same values?

It looks nice when the game is running fully within the window borders. I don't know if it's a bug or a feature but I made a map 20 * 13 and set the screenWidth to 960 but the setting didn't take. The code expects both screenX parameters to be different from the default in order to resize the window. To fix the issue I had to set changeWindowHeight to the default 624.
Code:
var windowWidthTo = toNumber(parameters["changeWindowWidthTo"], 0);
var windowHeightTo = toNumber(parameters["changeWindowHeightTo"], 0);

var windowWidth;
var windowHeight;

if (windowWidthTo) {
    windowWidth = windowWidthTo;
} else if (screenWidth !== SceneManager._screenWidth) {
    windowWidth = screenWidth;
}

if (windowHeightTo) {
    windowHeight = windowHeightTo;
} else if (screenHeight !== SceneManager._screenHeight) {
    windowHeight = screenHeight;
}

The first part of the resizing problem was here. The windowHeightTo variable is either set by the parameter or 0. Since I only wanted to change the width I didn't set a height so windowHeightTo was assigned 0 by default. Then in the 2nd if statement it evaluates to false. The else if evaluates to false because screenHeight is equal to SceneManager._screenHeight.

The windowHeight variable is never assigned a value. Part 2 after the break.

What would happen if I used them but the values weren't consistent?

When the window is smaller or larger than the screenX values then the canvas scales. It's the same thing as the user resizing the window.

Part 2

The initNwjs function is where window size and position are computed.
Code:
if (Utils.isNwjs() && windowWidth && windowHeight) {
    var dw = windowWidth - window.innerWidth;
    var dh = windowHeight - window.innerHeight;
    window.moveBy(-dw / 2, -dh / 2);
    window.resizeBy(dw, dh);
}

Recall in part 1 that windowHeight was undefined therefore the if statement evaluates to false.

If everything went perfectly then the difference between the desired width and the current width is calculated and the same goes for the window height. The moveBy method is called to position the window at the center of the display and then resizeBy is called to resize the window.

Original thread: https://forums.rpgmakerweb.com/threads/community_basic-difference-between-screen-change-window.89816/