Skip to content

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

@eugenesvk

Description

@eugenesvk

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions