Open Ragnar-H opened 3 years ago
@bryphe I suspect the solution is to expose the SDL_WINDOWFLAGS to the Sdl2.Window.create call in Window.re
I'm happy to take this on, although I expect I'll need some help since there's some C plumbing I'm not immediately familiar with :)
Hi @Ragnar-H ,
Thanks for logging the issue and all the details! This would certainly be a nice improvement - it can help reduce flicker when starting up apps to start them hidden, and then show them once everything has been loaded / setup.
The simplest fix would probably be to add a flag here: https://github.com/revery-ui/revery/blob/9ec44ff79a3e4ca75508bf53cd385d1db8b231b4/packages/reason-sdl2/src/sdl2_wrapper.cpp#L1574
These places would also need to be updated:
(and then, validating that the window can be shown after being hidden is important - I think the current SDL_ShowWindow
is the right thing for that, though).
A larger, but more flexible, fix would be as you suggested - expose the SDL_WINDOWFLAGS as something we can build and pass from Reason to the C stubs. We have the flags hard-coded here: https://github.com/revery-ui/revery/blob/9ec44ff79a3e4ca75508bf53cd385d1db8b231b4/packages/reason-sdl2/src/sdl2_wrapper.cpp#L1641
One idea would be to pass a uint
to our CreateWindow
API, and have a module like WindowFlags
that can be used with that API, like:
module WindowFlags: {
// Internally, this would be a uint
type t;
type flags =
| Hidden
| OpenGL
| Fullscreen
| ...;
// The default set of flags we use currently - OpenGL, HighDPI, Resizable
let default: t;
let make: list(flags) => t;
}
...
module Window: {
let create: (~flags=WindowFlags.default, ...);
}
Hope that helps give some ideas!
Thanks @bryphe!
My time contributing to OSS is very sporadic but let's see if I can get to this :) I'll drop a comment if I start digging into this.
If anyone else is reading this and is missing the functionality feel free to jump on this 🤝
I'm happy to create a dedicated repo for this if that's needed. This can be reproduced in the Examples in this repo which seemed easiest :)
visible=false
into the Examples in this repo - see git diff in above sectionesy @examples run
App window is shown and focused
App window is hidden
In
Window.create
we've got a guard for calling .show() on Sdl2 window however we probably want to pass inSDL_WINDOW_HIDDEN
to theSdl2.Window.create
. I suspect Sdl2 has the sane default of windows being visible.visible, createWindow