Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion src/DynamoCoreWpf/ViewModels/Core/PortViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -399,6 +399,9 @@ private CustomPopupPlacement[] PlacePortContextMenu(Size popupSize, Size targetS
// What matters is the zoom factor measured from the scaled : unscaled node size
var zoom = node.WorkspaceViewModel.Zoom;

var source = PresentationSource.FromVisual(Application.Current.MainWindow);
var dpiScale = source?.CompositionTarget?.TransformToDevice.M22 ?? 1.0;

double x;
var scaledWidth = autocompletePopupSpacing * targetSize.Width / node.ActualWidth;

Expand All @@ -421,7 +424,9 @@ private CustomPopupPlacement[] PlacePortContextMenu(Size popupSize, Size targetS
var rowOffset = PortModel.Index * PortModel.Height * zoom;
var customNodeOffset = NodeModel.CustomNodeTopBorderHeight * zoom;

var y = popupHeightOffset + headerHeightOffset + portHalfHeight + rowOffset + customNodeOffset;
// popupSize.Height is already DPI-scaled (in screen pixels), so we do NOT apply dpiScale to it
// All other layout values are in logical units and must be multiplied by dpiScale for correct placement
var y = popupHeightOffset + (headerHeightOffset + portHalfHeight + rowOffset + customNodeOffset) * dpiScale;

Copilot AI May 30, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider whether popupHeightOffset should also be scaled by dpiScale for consistency. If it's intentionally left unscaled, please add a comment to clarify the rationale.

Copilot uses AI. Check for mistakes.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same question as copilot :)

@ivaylo-matov ivaylo-matov May 30, 2025

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Applying dpi scaling to this value causes the popup to appear vertically misaligned. This is because popupSize.Height is already in dpi scaled screen pixels, while HeaderHeight and PortModel.Height are in device independent units and require manual adjustment.
I've added a comment to clarify this.


var placement = new CustomPopupPlacement(new Point(x, y), PopupPrimaryAxis.None);

Expand Down