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

Window not rendered after Hide() #2994

Closed
MonkAlex opened this issue Sep 14, 2019 · 6 comments · Fixed by #3876
Closed

Window not rendered after Hide() #2994

MonkAlex opened this issue Sep 14, 2019 · 6 comments · Fixed by #3876
Labels

Comments

@MonkAlex
Copy link
Contributor

MonkAlex commented Sep 14, 2019

Use windows7

Create new project from Avalonia Application template
For MainWindow add:

        protected override void HandleWindowStateChanged(WindowState state)
        {
            if (state == WindowState.Minimized)
            {
                this.Hide();
                Task.Run(async () =>
                {
                    await Task.Delay(1000);
                    Dispatcher.UIThread.Post(() =>
                    {
                        var window = this;
                        window.Show();
                        window.Activate();
                        if (window.WindowState == WindowState.Minimized)
                            window.WindowState = WindowState.Normal;
                    });
                });
            }

            base.HandleWindowStateChanged(state);
        }

Run (netcore 2.1), minimize, wait
On minimize-show render broken and show black screen:
image

If i manual resize window after that - all rendered and work fine.
Keyboard events to change VM run render too.
Mouse events dont work.

UPD: also reproduce on second hide-show when run on windows10
not reproduced on macos

UPD2: linux mint 18 (in virtual box) showed bad, resize help too:
linux

@MonkAlex
Copy link
Contributor Author

MonkAlex commented Sep 30, 2019

On Windows7 help this simple code:

                        window.Show();
                        window.Width += 0.1;

Mint not tested.
Ugly, but work 😣

UPD: Width change raise InvalidateMeasure(); and its also help. Its correct solution for this problem?

@jmacato
Copy link
Member

jmacato commented Oct 1, 2019

Confirmed bug on Cinnamon+Ubuntu 18.04.

@josegomez
Copy link

Can confirm this is still an issue on 0.9.9
Render

Workarounds such as changing screen size, InvalidateMeasure() and InvalidateVisual() don't always work consistently.

@kekekeks
Copy link
Member

Please, record the events sent to the window via xev -id <window id>. Window id can be obtained via xwininfo utility.

@alexhauser
Copy link

alexhauser commented May 2, 2020

@kekekeks, here is a link to the recorded window events that you've requested:
https://pastebin.com/y4reQ70T

This is from the same app that @josegomez has posted screencasts of in the post above.
The last "minimize to tray" and then "restore" triggered the garbled display.

@kekekeks
Copy link
Member

kekekeks commented May 2, 2020

I don't see any Expose events being sent to the window (we are treating them in the same way as WM_PAINT). I guess we should handle VisibilityNotify in the same way and trigger an immediate repaint.

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

Successfully merging a pull request may close this issue.

6 participants