Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Initial Draw Sequence #41

Closed
Guillaume227 opened this issue Feb 6, 2023 · 8 comments
Closed

Initial Draw Sequence #41

Guillaume227 opened this issue Feb 6, 2023 · 8 comments

Comments

@Guillaume227
Copy link
Contributor

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).

@Guillaume227 Guillaume227 changed the title Init sequence Initial Draw Sequence Feb 6, 2023
@pthom
Copy link
Owner

pthom commented Feb 7, 2023

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

What you are seeing is:

Docking layout:

  • docking layout is applied on the second frame: if I remember well, ImGui requires that all windows must have been displayed once in order to be able to assign them to splits.

Window sizing:

  • On windows, windows sizing on multiple screen with different dpis is also cumbersome. If you do not specify the screen there is no easy way to know what is the scaling of the screen on which the window will appear before opening it.
    Are you using multiple displays with different scalings?

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
Copy link
Contributor Author

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
Copy link
Owner

pthom commented Feb 9, 2023

Hi,

This should be solved with d6af807

@Guillaume227
Copy link
Contributor Author

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
Copy link
Owner

pthom commented Feb 10, 2023

I’m on the slopes right now .

@Guillaume227 Guillaume227 reopened this Feb 15, 2023
@Guillaume227
Copy link
Contributor Author

Guillaume227 commented Feb 15, 2023

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
Copy link
Owner

pthom commented Feb 15, 2023 via email

@Guillaume227
Copy link
Contributor Author

Ok - I sent my simple change as a PR if that makes it easier for you: #47

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants