DefOS fullscreen toggle on Windows 10

Hi again,

I’ve got a slight problem with my Windows projects. The project settings reflect the resolution of my monitor, 1920x1080.

Whenever I start a project in Windows 10, it does not start in a maximized window, but a “maximizable” one. And this window is larger than a maximized one and parts of the content are hidden behind the taskbar. So, using defos.toggle_fullscreen() right after start-up toggles between fullscreen and this too-large window.
Ok, let’s maximize the window then. Nope, defos.toggle_fullscreen() ignores the maximized window and chooses the too-large window.
Only when I resize the window to a smaller size does toggling work as expected.
Right, what happens if the user maximizes this smaller window? defos.toggle_fullscreen() again ignores the maximized window and chooses the smaller window.

In Manjaro Linux, my apps start in a maximized window and toggling works well. Only when this maximized window has not been resized yet and “restore down” is clicked the problem with the too-large window occurs.

I have searched the forum for answers and found this thread.
So, I used defos.set_window_size() to set the start-up window to a size slightly smaller than the project settings. The toggling now works quite nicely, but still ignores a maximized window. Also, I would like the app to start in fullscreen mode.

I tried to fix the problem via code. So far, I was able to write some lines to force toggling between fullscreen and maximized but not between fullscreen and a smaller window.
I have also tried some convoluted code involving a window listener but so far without success.
My cunning plan to bundle a window.exe in Manjaro Linux did not work either, same behaviour as on Windows.

In short: when a maximized window has not been resized yet, the window produced when “restore down” is pressed is too large. Is there a way to fix this? Also, is there a way to make defos.toggle_fullscreen() stop ignoring maximized windows on Windows?

Sorry for the long post!

Something must be breaking in that your initial window size is supposed to be the size of your monitor but the view size can’t actually get that big since you have the window decoration as well? The situation is confusing a little.

There is a waiting pull request for DefOS which will allow you to set an alternate starting window view size rather than the one for your project size. And this won’t have a negative impact on GUI positions and so on.

One trick you can do is halve the size of the project in Defold’s game.project, and then have the assets be 2x scale of that size (so same size they are now) but halve their scale in engine to 0.5. Easy to do if you do that based on a parent node/object. Then you would need to setup your shaders to not have mipmaps enabled too.

1 Like

Hello @Pkeod,

thank you very much for your answer. It is confusing, isn’t it?
Sorry, I have made a mistake in my first post and just edited it: my start-up window is of course not a “restoredown-able” one, but one that can be maximized.

Here are screenshots from a mockup to show you what happens:

project settings:
Capture1

project in the engine:

startup window, too large and slightly offset:

maximized window, all good:

I have a non-maximized window on start-up in any project on Windows 10, DefOS or not.
What on earth am I doing wrong now? I am sure I haven’t tampered with anything in the engine apart from setting the resolution.

This is a super idea, will try at once- thank you!

Cheers

Brigitte

@Pkeod, I wanted to find out if something is indeed wrong on my side of things. Could well be and also, I just cannot give up easily. So I conducted a lengthy experiment.
I took 3 different machines: desktop (dual booting Win10/Manjaro), laptop (same resolution, dual booting Win10/Manjaro), small laptop (smaller resolution, dual booting Win 10/Linux Mint).

On each I did the following: I downloaded the engine again and prepared 2 identical new projects, one using DefOS, one without. They contain just a gui box as a root node and some children. All the nodes are set to fit. I changed nothing in the project settings apart from setting the resolution.
I built the projects on each of the machines, in each OS. In each OS, I produced an executable for Win and for Lin to see if it makes a difference on which OS they are made.

The behaviour is the same in all cases, so I attached only the screenshots from my desktop:

initial window after start:

if this initial window has not been resized yet to a smaller one:

So it is still true after my experiment:
when the project’s display settings are set to the monitor’s resolution, the initial window in Win 10 is offset and content is hidden behind the taskbar, while on Linux the initial window is fine. Which is how it should be on Windows as well (with extensions or without), am I right to assume this?
Both in Win and Linux toggling works just fine once the window has been resized to a smaller one. Except when the window is maximized again in Win, defos.toggle_fullscreen() does not want to know and toggles between full screen and the previous, smaller window.
Hm, there is definitely something going on and I don’t think I caused it.

Cool, I think I am going to wait before I finish my app’s Windows version.

Thought you might be interested in my findings and maybe they are useful to you or someone else. I can post the other screenshots as well if you would like to see them.

Cheers

Brigitte

1 Like