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

[release/3.1] Context Menus are sometimes not shown in High-DPI applications #2098

Merged
2 commits merged into from Oct 29, 2019
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -1510,7 +1510,7 @@ private void CreateWindow(bool asyncCall)
// cascading failure.
if (PopupInitialPlacementHelper.IsPerMonitorDpiScalingActive)
{
DestroyWindow();
DestroyWindowImpl();
_positionInfo = null;
makeNewWindow = true;
}
Expand Down Expand Up @@ -1601,18 +1601,40 @@ private void BuildWindow(Visual targetVisual)
_secHelper.BuildWindow(origin.x, origin.y, targetVisual, IsTransparent, PopupFilterMessage, OnWindowResize, OnDpiChanged);
}

private void DestroyWindow()
/// <summary>
/// Destroys the underlying window (HWND) if it is alive
/// </summary>
/// <returns>true if the window was destroyed, otherwise false</returns>
private bool DestroyWindowImpl()
{
if (_secHelper.IsWindowAlive())
{
_secHelper.DestroyWindow(PopupFilterMessage, OnWindowResize, OnDpiChanged);
ReleasePopupCapture();
return true;
}

// Raise closed event after popup has actually closed
OnClosed(EventArgs.Empty);
return false;
}

// When closing, clear the placement target registration
UpdatePlacementTargetRegistration(PlacementTarget, null);
/// <summary>
/// Destroys the window, and does additional book-keeping
/// like releasing the capture, raising Closed event, and
/// clearing placement-target registration
/// </summary>
private void DestroyWindow()
{
if (_secHelper.IsWindowAlive())
{
if (DestroyWindowImpl())
{
ReleasePopupCapture();

// Raise closed event after popup has actually closed
OnClosed(EventArgs.Empty);

// When closing, clear the placement target registration
UpdatePlacementTargetRegistration(PlacementTarget, null);
}
}
}

Expand Down