When starting without windowed -w argument, fullscreen mode is briefly set and then unset when the cvar value is eventually loaded after the application is actually created. Using -w argument skips this behavior by overriding the client.windowed cvar (-w indicates that windowed mode is forced and client.windowed is ignored). The expected behavior should be:
-w is set: start in windowed mode and force windowed mode at all times
client.windowed 0: start in fullscreen mode
client.windowed 1: start in windowed mode
The issue lies with when the StateListener is added and when Client.Windowed is loaded. The check of to && Gdx.graphics.isFullscreen() within the Client.WindowedStateListener within DesktopLauncher#main doesn't work correctly in the initial state and sets to fullscreen mode (after this initial set, this appears to work as expected though).
I experimented with adding Cvar#addStateListener(boolean, StateListener) to Cvar which uses the boolean argument to tell whether or not the passed StateListener should have onLoaded called to set the initial value. This circumvents the behavior by delaying onLoaded until the program has started and client.windowed loaded. This fixed the bug where the program has fullscreen set erroneously, however it doesn't fix the problem of having the value we want set late. The state listener is added without this parameter until this issue can be looked into properly and we can evaluate if Cvar#addStateListener(boolean, StateListener) should be kept or deprecated/removed.
Something I didn't try which might give the results I'm after are to use some external serialization of client.windowed to apply a default value (changing client.windowed would reserialize it). So when the application starts, we can read this without having to init Riiablo.cvars and apply the correct value.
When starting without windowed
-w
argument, fullscreen mode is briefly set and then unset when the cvar value is eventually loaded after the application is actually created. Using-w
argument skips this behavior by overriding theclient.windowed
cvar (-w
indicates that windowed mode is forced andclient.windowed
is ignored). The expected behavior should be:-w
is set: start in windowed mode and force windowed mode at all timesclient.windowed 0
: start in fullscreen modeclient.windowed 1
: start in windowed modeThe issue lies with when the
StateListener
is added and whenClient.Windowed
is loaded. The check ofto && Gdx.graphics.isFullscreen()
within theClient.Windowed
StateListener
withinDesktopLauncher#main
doesn't work correctly in the initial state and sets to fullscreen mode (after this initial set, this appears to work as expected though).I experimented with adding
Cvar#addStateListener(boolean, StateListener)
toCvar
which uses the boolean argument to tell whether or not the passedStateListener
should haveonLoaded
called to set the initial value. This circumvents the behavior by delayingonLoaded
until the program has started andclient.windowed
loaded. This fixed the bug where the program has fullscreen set erroneously, however it doesn't fix the problem of having the value we want set late. The state listener is added without this parameter until this issue can be looked into properly and we can evaluate ifCvar#addStateListener(boolean, StateListener)
should be kept or deprecated/removed.Something I didn't try which might give the results I'm after are to use some external serialization of
client.windowed
to apply a default value (changingclient.windowed
would reserialize it). So when the application starts, we can read this without having to initRiiablo.cvars
and apply the correct value.