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

Use ShowWindowCommand.Hide when positioning an unshown win32 window #15035

Merged
merged 1 commit into from
Mar 20, 2024

Conversation

TomEdwardsEnscape
Copy link
Contributor

@TomEdwardsEnscape TomEdwardsEnscape commented Mar 19, 2024

There is a race condition when these conditions are met:

  1. WindowStartupLocation="CenterScreen"
  2. Width and/or Height are defined
  3. The window takes a long time to construct its visual tree

(Thread.Sleep can be called in OnApplyTemplate to artificially fulfil the third requirement.)

In this situation, the window can be seen opening in one location then later moving to another location. This seems to be happening because it isn't centred on the screen until measured? In any case, the PR fixes the issue by keeping the window hidden until it is shown.

Breaking changes

None

Obsoletions / Deprecations

None

Fixed issues

Fixes #15003

@avaloniaui-bot
Copy link

You can test this PR using the following package version. 11.2.999-cibuild0046358-alpha. (feed url: https://nuget-feed-all.avaloniaui.net/v3/index.json) [PRBUILDID]

@TomEdwardsEnscape TomEdwardsEnscape force-pushed the fixes/unshown-window-resize branch from 88d21db to 6c6d1b2 Compare March 19, 2024 21:24
@avaloniaui-bot
Copy link

You can test this PR using the following package version. 11.2.999-cibuild0046391-alpha. (feed url: https://nuget-feed-all.avaloniaui.net/v3/index.json) [PRBUILDID]

@maxkatz6 maxkatz6 added this pull request to the merge queue Mar 20, 2024
@maxkatz6 maxkatz6 added backport-candidate-11.1.x Consider this PR for backporting to 11.1 branch bug os-windows labels Mar 20, 2024
Merged via the queue into AvaloniaUI:master with commit 8cf28fa Mar 20, 2024
6 checks passed
@TomEdwardsEnscape TomEdwardsEnscape deleted the fixes/unshown-window-resize branch March 20, 2024 21:34
maxkatz6 pushed a commit that referenced this pull request Apr 6, 2024
@maxkatz6 maxkatz6 added backported-11.1.x and removed backport-candidate-11.1.x Consider this PR for backporting to 11.1 branch labels Apr 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Main Window flickers in incorrect location prior to rendering in v11.1.0-beta1
3 participants