Skip to content

bug:float calculation cause deviation #422

Description

@hcg2008

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions