core
core copied to clipboard
better strategy for dealing with screen changes
- detect when screen is not avail and just go into some kind of hibernation mode
- when screen becomes avail again, do full reset, including geom files which seem like they are not updating properly
- also icons per prior issue.
there were various issues in screen detection. but also some bugs / limitations in glfw (on mac at least). In particular, if you open on a plugged-in monitor that is primary (starts as screen 0), then unplug that monitor (it now does this properly), then plug back in that monitor, it does not return that monitor to position 0, and it incorrectly thinks your window is on the wrong monitor.
because there is no good way to figure out what monitor your window is actually on: https://github.com/glfw/glfw/issues/1699 this is hard to recover from..
I'm going to try the workaround in that issue..
There are some major bugs in the glfw GetMonitors code: https://github.com/glfw/glfw/issues/2160 -- implemented workarounds to restore mostly sensible behavior: don't set builtin as primary if it wasn't originally such.
Also rewrote WinGeomMgr as a struct, don't try to convert geom across monitors: just use default sizing (which is now quite good) instead.
Looks like the window gets some spurious window resize and move events right before the disconnect of the screen -- during this time the window has actually changed screens and is reporting values for that screen, but our list of screens is not yet updated because the glfw monitor events have not been updated yet.
There are two strategies: always get new screens when we get a resize / move, which is not actually that expensive -- monitor info is cached on the glfw side (which is what is causing the bugs!) or cache the last move / resize events and only save prefs if we don't get a disconnect or another such event within some time frame. This latter approach is good in any case to prevent so much redundant saving of prefs. Probably doing both is not a bad idea.
calling GetScreens() during one of those disconnect-driven resize etc events can crash.. gotta do the caching strategy.
ok, hopefully finally all working with latest push. much cleaner overall -- moved zoom stuff into oswin so LogicalDPI is always correct..
yep all good