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

Reported coordinates on high/variable dpr displays? #13

Open
patrickhlauke opened this issue Oct 2, 2018 · 1 comment
Open

Reported coordinates on high/variable dpr displays? #13

patrickhlauke opened this issue Oct 2, 2018 · 1 comment

Comments

@patrickhlauke
Copy link

We've been having to compensate for situations where a screen isn't set to 100% scaling by dividing the x and y by window.devicePixelRatio (see ThePacielloGroup/CCAe@739de8f). Wondering if there's a cleaner way that this package could do this out of the box?

@poiru
Copy link

poiru commented Feb 6, 2019

@patrickhlauke On Electron 3 and later, you should be able to use screen.screenToDipPoint like so:

const screen = require('electron').screen;
mouse.on('move', (x, y) => {
 console.log('move pixels:', {x, y}, 'dip:', screen.screenToDipPoint({x, y}));
});

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