gabdube / native-windows-gui

A light windows GUI toolkit for rust
https://gabdube.github.io/native-windows-gui/
MIT License
1.96k stars 127 forks source link

Window's set_position doesn't seem to take dpi scaling into account #299

Open eugenesvk opened 4 months ago

eugenesvk commented 4 months ago

I'd like to show a "tooltip" near mouse pointer position, so

    let (x,y) = nwg::GlobalCursor::position();
    self.win_tt.set_position(x,y);
    self.win_tt.set_visible(true);

where win_tt is a Window But this doesn't position the window correctly, but further to the rigght/bottom on a scaled monitor

However, if I manually adjust for dpi

    let (x,y) = nwg::GlobalCursor::position();
    let dpi:i32 = unsafe{nwg::dpi()};
    let xx = (x as f64 / (dpi as f64 / 96 as f64)).round() as i32;
    let yy = (y as f64 / (dpi as f64 / 96 as f64)).round() as i32;
    self.win_tt.set_position(xx,yy);
    self.win_tt.set_visible(true);

it works fine

I've added dpiAware in the manifest (without this the first example without dpi correction works) and the high-dpi feature enabled