egui icon indicating copy to clipboard operation
egui copied to clipboard

Fix incorrect window sizes for non-resizable windows on Wayland

Open GoldsteinE opened this issue 6 months ago • 3 comments

Using physical window sizes leads to all kinds of fun stuff: winit always uses scale factor 1.0 on start to convert it back to logical pixels and uses these logical pixels to set min/max size for non-resizeable windows. You're supposed to adjust size after getting a scale change event if you're using physical sizes, but adjusting min/max sizes doesn't seem to work on sway, so the window is stuck with an incorrect size.

The scale factor we guessed might also be wrong even if there's only a single display since it doesn't take fractional scale into account.

TL;DR: winit actually wants logical sizes in these methods (since Wayland in general operates mostly on logical sizes) and converting them back and forth is lossy.

  • Closes https://github.com/emilk/egui/issues/7095
  • [x] I have followed the instructions in the PR template

GoldsteinE avatar May 30 '25 08:05 GoldsteinE

Okay, I think this is ready. I wasn’t able to run all the tests locally (because some tests failed even on main branch for some reason), but it shouldn’t break anything.

GoldsteinE avatar May 30 '25 09:05 GoldsteinE

Currently checking on my device....

bircni avatar May 30 '25 17:05 bircni

all good here just some pixels in some images - i dont think thats because of you

bircni avatar May 30 '25 22:05 bircni

@bircni Hi! Could you please direct me to my next steps here? This is my first time contributing to egui and I’m a bit confused.

I’m happy to add lint reasons and do a direct import if you prefer it, but I’m not sure if this PR is waiting on me doing that or on emilk making a decision about this lint in general.

Thanks for review either way

GoldsteinE avatar Jun 12 '25 21:06 GoldsteinE

@GoldsteinE we are still waiting on comments from @emilk - but adding a reason would always be great!

If emilk decides to reallow the types we can do that afterwards :-)

bircni avatar Jun 12 '25 21:06 bircni

Sure, I’ve done that.

GoldsteinE avatar Jun 12 '25 21:06 GoldsteinE

This works beautifully on my mac ❤️

emilk avatar Jun 24 '25 11:06 emilk

Preview available at https://egui-pr-preview.github.io/pr/7103-window-logical-size Note that it might take a couple seconds for the update to show up after the preview_build workflow has completed.

github-actions[bot] avatar Jun 24 '25 11:06 github-actions[bot]

Thanks for fixing this!

emilk avatar Jun 24 '25 11:06 emilk

Thanks for reviewing!

GoldsteinE avatar Jun 24 '25 11:06 GoldsteinE