Skip to content

Improve ImGui fractional scaling support - #2614

Merged
Perksey merged 2 commits into
dotnet:mainfrom
jaredh:main
Sep 6, 2026
Merged

Improve ImGui fractional scaling support#2614
Perksey merged 2 commits into
dotnet:mainfrom
jaredh:main

Conversation

@jaredh

Copy link
Copy Markdown
Contributor

Summary of the PR

Looking at improving support for Wayland fractional scaling in BlackLabelHQ/RecompOne (issue[1]) has led me to a couple fixes here. Looks like a lot of this is improving in 3.0 with windowing API improvements, but not sure when to expect that to hit GA.

These fixes are reproducible in the ImGui sample app, and seem to stem from deviation from the original C++ port[2][3][4]. The tl;dr is integer division was being performed, truncating fractional values, and never updating the viewport with the framebuffer size. This was resulting in the UI rendering seemingly correct, but mouse input not lining up. Note the cursor position and the selected Configuration row in this screenshot 👇

Screenshot From 2026-09-04 17-22-42

I've also exposed GetWindowContentScale, which GLFW added at the same time as the monitor scale API; this is required downstream so we can access the fractional scale value from Wayland/mutter.

A platform guard has been added to Silk.NET.Input so I can build this on Linux without the iOS target.

Related issues

[1] BlackLabelHQ/SymphonyRecomp#46
[2] https://github.com/ocornut/imgui/blob/v1.82/backends/imgui_impl_glfw.cpp#L360-L362
[3] https://github.com/ocornut/imgui/blob/v1.82/backends/imgui_impl_opengl3.cpp#L272-L274
[4] https://github.com/ocornut/imgui/blob/v1.82/backends/imgui_impl_opengl3.cpp#L449-L450

Further Comments

I've fixed and tested this against the OpenGL implementation only. I'm not familiar with the status of Vulkan or if it's required there.

@jaredh

Copy link
Copy Markdown
ContributorAuthor

@dotnet-policy-service agree

@jaredh
jaredh marked this pull request as draft September 4, 2026 23:06
Comment on lines +242 to +244
// Update here since Resize isn't raised on all platforms
_windowWidth = size.X;
_windowHeight = size.Y;

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

When going fullscreen Resize is fired and the updated window size is correctly reflected, but when returning to windowed mode on Wayland, GLFX does not end up invoking the resize callback so we never end up receiving the updated window dimensions.

@PerkseyPerksey left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks!

@github-project-automationgithub-project-automationBot moved this from Todo to In Progress in Silk.NET Development TrackerSep 6, 2026
@Perksey
Perksey enabled auto-merge (squash) September 6, 2026 18:01
@Perksey
Perksey merged commit 2e8eaf6 into dotnet:mainSep 6, 2026
3 checks passed
@github-project-automationgithub-project-automationBot moved this from In Progress to Done in Silk.NET Development TrackerSep 6, 2026
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants

@jaredh@Perksey