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

Resize fails on Windows if done during minimization #3291

Closed
NicolasDorier opened this issue Nov 26, 2019 · 9 comments · Fixed by #6254
Closed

Resize fails on Windows if done during minimization #3291

NicolasDorier opened this issue Nov 26, 2019 · 9 comments · Fixed by #6254
Labels

Comments

@NicolasDorier
Copy link

NicolasDorier commented Nov 26, 2019

  1. Get a windows say 800x600
  2. Minimize the window
  3. Resize the window (either manually via ClientSize OR by triggering a stackpanel to become visible which should change the size of the window if SizeToContent is set to Width/Height)
  4. Restore the window

0.9.0-preview7

@NicolasDorier NicolasDorier changed the title Auto resize fail on windows after minimization Auto resize fail on Windows after minimization Nov 26, 2019
@NicolasDorier
Copy link
Author

NicolasDorier commented Nov 26, 2019

it seems it happen if an element is expanded while the windows is minimized. It seems the auto resize is broken then. (or in general, any resize that happen during minimized state)

@NicolasDorier
Copy link
Author

The problem happens even if SizeToContent="Manual".

The root of the problem is that when the window is restored, Avalonia seems to set the ClientSize back to what it was before it has been minimized, regardless of whether SizeToContent and even if this ClientSize changed while the windows was minimized.

@jmacato jmacato added the bug label Nov 26, 2019
@grokys
Copy link
Member

grokys commented Nov 26, 2019

I think the problem here is that there's no way of telling whether a resize was caused by an auto-resize, a user resize or a minimize/restore.

A user resize always results in auto-resizing being turned off, but we need a way to tell where the resize event came from. I'm not sure there is any of way of knowing that?

@jmacato jmacato added this to To do in 0.9 Release via automation Nov 26, 2019
@jmacato jmacato added this to the 0.9 milestone Nov 26, 2019
@grokys
Copy link
Member

grokys commented Nov 26, 2019

I tried to solve this here #2383 but gave up... The description only mentions X11, but this was also an attempt to fix auto-resizing on other platforms too. Unfortunately I think my solution was flawed. Probably need to revisit this soon.

@jmacato I don't think this can be fixed for 0.9, it's not a simple problem.

@jmacato
Copy link
Member

jmacato commented Nov 26, 2019

@grokys got it, i included it to 0.9 for posterity; removing milestones now

@jmacato jmacato removed this from To do in 0.9 Release Nov 26, 2019
@jmacato jmacato removed this from the 0.9 milestone Nov 26, 2019
@grokys
Copy link
Member

grokys commented Nov 26, 2019

@NicolasDorier when you say that "it happens even if SizeToContent="Manual"" - what happens? The problem is "Not sizing to content anymore", right? If SizeToContent="Manual" then it shouldn't be sizing to content.

Sorry, I'm probably thick here ;)

@NicolasDorier
Copy link
Author

NicolasDorier commented Nov 26, 2019

@grokys so here it what happen precisely, whichever the value of SizeToContent.

  1. Get a windows say 800x600
  2. Minimize the window
  3. Resize the window (either manually via ClientSize OR by triggering a stackpanel to become visible which should change the size of the window if SizeToContent is set to Width/Height)
  4. Restore the window

What I noticed was that after step 3. the windows ClientSize and DesiredSize is what is expected.
But as soon as 4. happen, the size go back to 800x600.

My workaround is to have a DispatcherTimer which look my viewmodel every second and resize to a fixed hardcoded size. Not pretty... but good enough for me. :p

@Gillibald
Copy link
Contributor

What is the content of your StackPanel? Does it have a fixed size? SizeToContent only works if your content has a fixed size (DesiredSize != infinity)

@NicolasDorier
Copy link
Author

NicolasDorier commented Nov 27, 2019

@Gillibald here is my windows:

https://github.com/btcpayserver/BTCPayServer.Vault/blob/master/BTCPayServer.Vault/MainWindow.xaml

The problematic stackpanel is <StackPanel IsVisible="{Binding IsVisible}" Margin="0,15,0,0">

SizeToContent is actually unrelated to this issue. The same problem happen if it is in Manual.
I am sorry, just updated the description. I noticed it was unrelated to SizeToContent only later after posting.

@NicolasDorier NicolasDorier changed the title Auto resize fail on Windows after minimization Resize fails on Windows if done during minimization Nov 27, 2019
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.

4 participants