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

bug:float calculation cause deviation #422

Open
hcg2008 opened this issue Mar 22, 2024 · 0 comments
Open

bug:float calculation cause deviation #422

hcg2008 opened this issue Mar 22, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@hcg2008
Copy link

hcg2008 commented Mar 22, 2024

in src/native/windows.rc:

unsafe fn update_dimensions(&mut self, hwnd: HWND) -> bool {
....
        let window_width = ((rect.right - rect.left) as f32 / self.window_scale) as i32;
        let window_height = ((rect.bottom - rect.top) as f32 / self.window_scale) as i32;

        // prevent a framebuffer size of 0 when window is minimized
        let fb_width = ((window_width as f32 * self.content_scale) as i32).max(1);
        let fb_height = ((window_height as f32 * self.content_scale) as i32).max(1);
        if fb_width != d.screen_width || fb_height != d.screen_height {
            d.screen_width = fb_width;
            d.screen_height = fb_height;
            return true;
        }

example:
window height : 600, scale :1.75

let window_width = ((rect.right - rect.left) as f32 / self.window_scale) as i32; [<-- 342]
let fb_height = ((window_height as f32 * self.content_scale) as i32).max(1); [ <-- 598 ]

d.screen_height will been assigned 598

@not-fl3 not-fl3 added the bug Something isn't working label Mar 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants