Skip to content

Commit

Permalink
Fix #2831: Popup/Tooltip scaling on multi-monitor multi-DPI setups.
Browse files Browse the repository at this point in the history
  • Loading branch information
siegfriedpammer committed Nov 18, 2022
1 parent 4b14fbb commit bfe3914
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions ILSpy/TextView/DecompilerTextView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,8 @@ void TextViewMouseHover(object sender, MouseEventArgs e)
{
var popupPosition = GetPopupPosition(e);
popupToolTip.Closed += ToolTipClosed;
popupToolTip.Placement = PlacementMode.Relative;
popupToolTip.PlacementTarget = this;
popupToolTip.HorizontalOffset = popupPosition.X;
popupToolTip.VerticalOffset = popupPosition.Y;
popupToolTip.StaysOpen = true; // We will close it ourselves
Expand Down Expand Up @@ -282,23 +284,19 @@ bool TryCloseExistingPopup(bool mouseClick)
Point GetPopupPosition(MouseEventArgs mouseArgs)
{
Point mousePos = mouseArgs.GetPosition(this);
Point positionInPixels;
// align Popup with line bottom
TextViewPosition? logicalPos = textEditor.GetPositionFromPoint(mousePos);
if (logicalPos.HasValue)
{
var textView = textEditor.TextArea.TextView;
positionInPixels =
textView.PointToScreen(
textView.GetVisualPosition(logicalPos.Value, VisualYPosition.LineBottom) - textView.ScrollOffset);
positionInPixels.X -= 4;
return textView.GetVisualPosition(logicalPos.Value, VisualYPosition.LineBottom)
- textView.ScrollOffset
+ new Vector(-4, 0);
}
else
{
positionInPixels = PointToScreen(mousePos + new Vector(-4, 6));
return mousePos + new Vector(-4, 6);
}
// use device independent units, because Popup Left/Top are in independent units
return positionInPixels.TransformFromDevice(this);
}

void TextViewMouseHoverStopped(object sender, MouseEventArgs e)
Expand Down

0 comments on commit bfe3914

Please sign in to comment.