So I'm imagining that when my second monitor is gone, the stage bounds shrink to the size of the first screen.
That doesn't happen.
Look at my tracings. By the way my second monitor is smaller than the main monitor.
App starts on the first Monitor:
screens.length : 1
window is on FIRST monitor
screen.bounds (x=0, y=0, w=1280, h=1024)
event.afterBounds (x=293, y=192, w=719, h=619)
stage.nativeWindow.bounds (x=293, y=192, w=719, h=619)
I move the window, so it intersects the second monitor:
screens.length : 2
window is on both monitors ( do nothing )
screen.bounds (x=1280, y=0, w=1024, h=768)
event.afterBounds (x=904, y=125, w=719, h=619)
stage.nativeWindow.bounds (x=293, y=192, w=719, h=619)
Now the window is on the second monitor:
screens.length : 1
window is on SECOND monitor
screen.bounds (x=1280, y=0, w=1024, h=768)
event.afterBounds (x=1465, y=57, w=719, h=619)
stage.nativeWindow.bounds (x=904, y=125, w=719, h=619)
Here the window is minimized:
screens.length : 0
window is minimized
When you just move the App, the stage.nativeWindow.bounds change their x and y values, not the size. Only the screen.bounds reflect the monitor's size.
And only the event.afterBounds rectangle shows the real position of the Application on the screen.
So even if you unplug your 2nd monitor, the above tracings will be the same.
If the App was on the second monitor last time you opened it, it will still be there when you start your App again, even if your second monitor is gone. If you then activate your second monitor, the App is still there (2nd Monitor), waiting for you
I don't know what would happen, if the MS Windows settings for the Dual Display changed, meaning that you'd have only one monitor defined in the settings and you tried the above. I don't want to try this on my computer, but I think it would be the same:
you would know that your App is NOT on the main monitor - eventually as in my code that it is on the second monitor, but you wouldn't know if other monitors are there or not.
So until you'll find an “edgy”
solution, I will just notify the user about the Application being on other monitors through the App Title and add an item to the SystemTrayIcon, that will let them take the App back on the main monitor.