Skip to content

Fix fractional DPI drawing issues with popup menus#104

Draft
Copilot wants to merge 2 commits intomainfrom
copilot/fix-popup-menu-drawing-issues
Draft

Fix fractional DPI drawing issues with popup menus#104
Copilot wants to merge 2 commits intomainfrom
copilot/fix-popup-menu-drawing-issues

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 28, 2026

At fractional DPI scales (e.g. 150%), popup menu borders have missing corners and selected item backgrounds show extra pixel gaps. Root cause: the device→logical→device pixel round-trip in MenuDropDown.Show() uses Math.Round, which can shrink the rendering buffer by 1px, clipping border lines and misaligning item fills.

  • Show(): Use Math.Ceiling instead of Math.Round when converting device pixel dimensions to logical pixels for the popup size, ensuring the buffer is never smaller than the calculated menu dimensions
// Before
popup.Size = ScaleSize(new Size(width, height), 1 / (float)Scaling, 1 / (float)Scaling);

// After
popup.Size = new Size(
    (int)Math.Ceiling(width / Scaling),
    (int)Math.Ceiling(height / Scaling));
  • LayoutItems(): Use Math.Max(calculated, ScaledSize) so items expand to fill any extra pixels introduced by ceiling rounding, preventing background-color gaps between items and borders

✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Use Math.Ceiling instead of Math.Round when converting device pixel
dimensions to logical pixels for the popup window size. This prevents
the rendering buffer from being smaller than the calculated menu
dimensions at fractional DPI scales (e.g. 150%).

Also use the actual control's scaled dimensions in LayoutItems() to
ensure menu items fill the available space, fixing extra pixel gaps.

Agent-Logs-Url: https://github.com/modern-forms/Modern.Forms/sessions/b107a3d9-1ec4-4d72-8040-a1c5814d3dee

Co-authored-by: jpobst <179295+jpobst@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix fractional resolution drawing issues with popup menus Fix fractional DPI drawing issues with popup menus Mar 28, 2026
Copilot AI requested a review from jpobst March 28, 2026 22:02
@jpobst
Copy link
Copy Markdown
Collaborator

jpobst commented Mar 28, 2026

@copilot This did not seem to fix any of the issues, updated screenshot attached.

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Fractional resolution drawing issues with popup menus

2 participants