Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mismatch in window size and image size #60

Open
bobbobbio opened this issue Apr 28, 2022 · 5 comments
Open

Mismatch in window size and image size #60

bobbobbio opened this issue Apr 28, 2022 · 5 comments

Comments

@bobbobbio
Copy link

bobbobbio commented Apr 28, 2022

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.

@QuantumBadger
Copy link
Owner

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.

@QuantumBadger
Copy link
Owner

I can reproduce this in Weston with --scale=2.

@QuantumBadger
Copy link
Owner

I've created a ticket for the upstream library "winit" here: rust-windowing/winit#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.

@bobbobbio
Copy link
Author

@QuantumBadger Thanks so much for looking into this. I'll give what you suggest a try.

@bobbobbio
Copy link
Author

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

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

No branches or pull requests

2 participants