pthom / hello_imgui

Hello, Dear ImGui: unleash your creativity in app development and prototyping
https://pthom.github.io/hello_imgui
MIT License
606 stars 91 forks source link

Initial Draw Sequence #41

Closed Guillaume227 closed 1 year ago

Guillaume227 commented 1 year ago

Upon launching my the hello_imgui powered version of my app I am seeing the main window appear in two steps, which does not look great. I am trying to understand where that's coming from. I am still on Windows.

For a split second I first see this: image

That's after the first call to ShowGui() callback.

And then it becomes: image

Interestingly both the position of the window on the screen and the window size change (and that can't be told from the images above). It seems that there is a first rendering pass of just the empty main window and then it picks up the dock spaces contents and somehow relocates the window (my code is not attempting any resize/change of position).

pthom commented 1 year ago

Hum, the initial sequence on Windows is a bit hard.

What you are seeing is:

Docking layout:

Window sizing:

Anyhow; I know it would be interesting to study this. Perhaps by hiding the window on the first frames.

I'll study that a bit later.

Guillaume227 commented 1 year ago

I am on high DPI monitor (dell XPS 15 laptop). I just unplugged the extra display I was using (which is not high DPI) and I can confirm the behavior I described also happens when I use a single (laptop) screen. I am more than happy to help/test/validate any changes you have in mind.

pthom commented 1 year ago

Hi,

This should be solved with https://github.com/pthom/hello_imgui/commit/d6af807aebc3cf9d87b2a3547402647f475b1054

Guillaume227 commented 1 year ago

The glitch is gone, that looks much nicer now. Thanks Thom for the quick turnaround (and I hope you get to do other fun stuff besides coding during your week of vacation)!

pthom commented 1 year ago

I’m on the slopes right now .

Guillaume227 commented 1 year ago

I was doing some more testing of that change and noticed an undesirable side effect : the hello_imgui app window now forces its way to the forefront all the time (e.g. I alt-tab to some other app and the hello_imgui app jumps back again to the front).

I think it's down to calling showWindow() for every frame index >= 3. I tried this locally: if (mIdxFrame >= 3) if (mIdxFrame == 3) in src/hello_imgui/internal/backend_impls/abstract_runner.cpp, around line 484

and that fixes that behavior. Any reason not to use an equality there?

pthom commented 1 year ago

Oops you are right. This needs a quick fix. Thanks ! Le 15 févr. 2023 à 14:36, Guillaume Giraud @.***> a écrit : I was doing some more testing of that change and noticed an undesirable side effect : the hello_imgui app window now forces its way to the forefront all the time (e.g. I alt-tab to some other app and the hello_imgui app jumps back again to the front). I think it's down to calling showWindow() for every frame index >= 3. Any reason not to use an equality ? if (mIdxFrame >= 3) if (mIdxFrame == 3)

—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you commented.Message ID: @.***>

Guillaume227 commented 1 year ago

Ok - I sent my simple change as a PR if that makes it easier for you: https://github.com/pthom/hello_imgui/pull/47