Speedy2D
Speedy2D copied to clipboard
Mismatch in window size and image size
I've been using speedy2d for my emulator. It's been working great up until recently
I recently updated my development machine to Ubuntu 22.04. After that speedy2d started giving a PrimaryMonitorNotFound
error.
I tried updating my version of speedy2d to the latest (1.7.0) and now it is working again, but now a different problem is happening. I've attached a picture showing the problem https://imgur.com/a/dvl80nD
The image I'm drawing to the window is smaller than the window size even though they should be the same size. The amount that it is different I think is the same amount of the UI scaling I have set for my window manager. This use to work fine before I upgraded.
Here is the code where I am making the window https://github.com/bobbobbio/come_boy/blob/master/library/src/rendering/speedy.rs
In the example image I was running it with a scale of 1 to make it even more clear. I also confirmed that if I adjust my UI scaling to 100% the problem goes away
Thanks for reading. Sorry if there is something I am missing.
Thanks for the report! This is probably due to Wayland vs X -- I suspect we're being given the "scaled pixels" size of the window rather than the "physical pixels" size. I'll investigate some more.
I can reproduce this in Weston with --scale=2
.
I've created a ticket for the upstream library "winit" here: https://github.com/rust-windowing/winit/issues/2275
@bobbobbio As a workaround in the meantime, it should be possible to set the window size (using WindowHelper::set_size_pixels()
) whenever you get an on_scale_factor_changed()
callback. The window will still be created with the wrong size initially, but after a moment will resize to be correct.
@QuantumBadger Thanks so much for looking into this. I'll give what you suggest a try.
@QuantumBadger your suggestion for a workaround almost works. If the launch size of the window exceeds the current resolution the resizing doesn't seem to take effect.