How to make a hidden Window visible?

I would like to set my OpenFL application’s initial window size dynamically, for example by reading the size at startup from a user defined configuration file. In the OpenFL project XML file one can set the initial window size, but this is of course a compile time constant.

I tried calling Lib.application.window.resize(width, height) at the beginning of my main method, but this gets called only after the window is already on screen, resulting in an ugly “jump” from the original size to the resized one.

I then tried setting the window hidden=“true” attribute in the project XML, and this seems to work. The window is not visible when the main method is called, but it still exists in Lib.application.window and I was able to call its resize-method.

The problem is, I can’t get the initially hidden window to show up. I’ve tried setting its minimized property as false and I’ve called its focus-method. I even tried to reset the displayMode-property, although this required bypassing the private DisplayMode constructor. Nothing helps, the window is there, but won’t show up. I’ve read https://api.lime.software/lime/ui/Window.html and can’t figure out what other method or property I could use to make the window visible.

I’m testing this on Linux with Neko, using OpenFL 9.1.0 with Lime 7.9.0 and Haxe 4.2.2.

Let the main window be hidden and create a new one with the desired size and position. Don’t forget to close the main window or terminate the app when that other window is closed.

Thank you for the advice! I earlier tried that too, but surely that can’t be the right way to do it? It does cause OpenFL to put its stage in the new window, but for example the Lib.application.current.window remains pointing to the original window, and I’m not sure if that might cause some issues later?

On a more general note, I would like to be able to show and hide any given Window, so I’m wondering if there is a mechanism to do so?

This is the only way I know of aside from modifying Lime source code. Lime uses SDL2 and I don’t see SDL_HideWindow or SDL_ShowWindow anywhere in it’s source so I don’t think it’s possible to toggle a window visibility after creating it. I just keep scene graph for every window and close/create them to emulate toggling visibility.

I guess Lime doesn’t provide access to that SDL functionality then. I tried a few more experiments and I think I found a way to dynamically set the initial window size.

If you add a Preloader to the program and call Lib.application.window.resize in the Preloader’s constructor, at least to my eye the main window seems to show up initially in the correct size. I think the Preloader constructor is the earliest place where you can run your own code in an OpenFL program, so perhaps that’s also intended as the place where you can modify the main window before it is shown.

For additional windows, closing and re-creating the window as you said should be good enough. Thank you again for the quick help, and even if the Lime windows cannot be shown or hidden directly, I think these workarounds can effectively achieve the same end result.