Skip to content

Improve ImGui fractional scaling support - #2614

Draft
jaredh wants to merge 2 commits into
dotnet:mainfrom
jaredh:main
Draft

Improve ImGui fractional scaling support#2614
jaredh wants to merge 2 commits into
dotnet:mainfrom
jaredh:main

Conversation

@jaredh

@jaredh jaredh commented Sep 4, 2026

Copy link
Copy Markdown

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

jaredh commented Sep 4, 2026

Copy link
Copy Markdown
Author

@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
Author

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.

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

Labels

None yet

Projects

Status: Todo

Development

Successfully merging this pull request may close these issues.

1 participant