Skip to content

Commit

Permalink
Fix issue that ChromeWindow is misplaced when returning from minimize.
Browse files Browse the repository at this point in the history
  • Loading branch information
mntone committed Aug 25, 2020
1 parent 14c2282 commit 6bebfdf
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions source/MetroRadiance.Chrome/Chrome/Primitives/ChromeWindow..cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ static ChromeWindow()
private IntPtr _handle;
private bool _sourceInitialized;
private bool _closed;
private bool _firstActivated;
private WindowState _ownerPreviewState;

protected Dpi SystemDpi { get; private set; }
Expand Down Expand Up @@ -165,6 +166,8 @@ public void Detach()
owner.ContentRendered -= this.OwnerContentRenderedCallback;
}
this.Visibility = Visibility.Collapsed;
this._firstActivated = false;
this._closed = false;
}

private bool GetIsUpdateAvailable()
Expand All @@ -191,6 +194,7 @@ private void UpdateState(bool forceImmediate = false)
if (t.IsCompleted)
{
this.Visibility = Visibility.Visible;
this.UpdateLocationAndSizeCore();
}
else if (t.IsFaulted)
{
Expand All @@ -207,6 +211,7 @@ private void UpdateState(bool forceImmediate = false)
else
{
this.Visibility = Visibility.Visible;
this.UpdateLocationAndSizeCore();
}
}
else
Expand All @@ -217,7 +222,7 @@ private void UpdateState(bool forceImmediate = false)

private void UpdateLocation()
{
if (!this.GetIsUpdateAvailable()) return;
if (!this.GetIsUpdateAvailable() || this._ownerPreviewState != WindowState.Normal) return;

this.CheckDpiChange();

Expand All @@ -231,7 +236,7 @@ private void UpdateLocation()

protected void UpdateSize()
{
if (!this.GetIsUpdateAvailable()) return;
if (!this.GetIsUpdateAvailable() || this._ownerPreviewState != WindowState.Normal) return;

if (this.CheckDpiChange())
{
Expand All @@ -249,7 +254,7 @@ protected void UpdateSize()

private void UpdateLocationAndSize()
{
if (!this.GetIsUpdateAvailable()) return;
if (!this.GetIsUpdateAvailable() || this._ownerPreviewState != WindowState.Normal) return;

this.CheckDpiChange();
this.UpdateLocationAndSizeCore();
Expand Down Expand Up @@ -385,7 +390,6 @@ private void OwnerStateChangedCallback(object sender, EventArgs eventArgs)
{
if (this._closed) return;
this.UpdateState();
this.UpdateLocation();
this._ownerPreviewState = this.Owner.WindowState;
}

Expand All @@ -401,12 +405,13 @@ protected virtual void OwnerSizeChangedCallback(object sender, EventArgs eventAr

private void OwnerActivatedCallback(object sender, EventArgs eventArgs)
{
if (!this._firstActivated) return;
this._firstActivated = true;
this.UpdateState();
}

private void OwnerDeactivatedCallback(object sender, EventArgs eventArgs)
{
this.UpdateState();
}

private void OwnerClosedCallback(object sender, EventArgs eventArgs)
Expand Down

0 comments on commit 6bebfdf

Please sign in to comment.