Speedy2D
Speedy2D copied to clipboard
Flapping windows on start
Hello! I'm trying to use Speedy2D in my new UI project, and stumbled upon windows flap. You can see it in this short video: https://up.agrd.eu/2NbRso.mp4
It seems that the window is shown before it is resized and moved to needed position. Very annoying :)
Thanks for the report!
It looks like the ability to set the window position during creation has just been added to the winit library:
https://github.com/rust-windowing/winit/pull/1866
I'm happy to make use of this in Speedy2D, however we need to wait for that commit to be integrated in a winit release (0.25.0?), which will then need to be integrated into glutin :)
One concern is that we won't have access to the size of the window borders at that time, and so can't take that into account for the centering, and the window would be slightly offset.
Thanks! I'll bear with it for now. There is so much work for me ahead for time being :)
I think we're ready to set position during creation ;)
Thanks, looks like you're right. I might wait for the WebGL work to be finished before doing this -- it's in the Glutin-specific code, and so it'll create a merge conflict due to splitting window.rs into multiple files. If WebGL still isn't ready a few weeks from now, I'll just add it anyway and manually deal with the conflict :)
Looking at this again, I think they're only exposing the ability to set the outer position of the window. There's a distinction between:
- Inner size: The size of your framebuffer/content area
- Outer size: The inner size, plus the title bar and window borders
- Inner position: The position of the top left corner of the inner area (framebuffer) on the screen
- Outer position: The position of the top left corner of the title bar on the screen
Currently we:
- Create the window at an arbitrary position
- Get the outer size of the window
- Use the outer size to find the central outer position
- Set the outer position on the window
The above process causes the flapping, but it also means we're able to correctly center the window on the screen. If we did this before the window first appears, I don't think there's a way to get the outer size (only the inner size), so we wouldn't actually know where to put the window. If we used the inner size, the window wouldn't be centered, it would be offset by the title bar/left window border.
So I'm not sure if there's a way to do this even after that API has been added. I'm open to suggestions though :)
Winit ticket for centering window: https://github.com/rust-windowing/winit/issues/38
@Revertron Could you confirm that #57 fixes the issue for you please?
@QuantumBadger, yes, it works perfectly!