win-mouse icon indicating copy to clipboard operation
win-mouse copied to clipboard

Reported coordinates on high/variable dpr displays?

Open patrickhlauke opened this issue 7 years ago • 1 comments

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 https://github.com/ThePacielloGroup/CCAe/commit/739de8f284a37cf858e533706b443cbb2f74b892). Wondering if there's a cleaner way that this package could do this out of the box?

patrickhlauke avatar Oct 02 '18 21:10 patrickhlauke

@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}));
});

poiru avatar Feb 06 '19 11:02 poiru