Discussion:
[whatwg] window.innerScreenX and window.innerScreenY
Jan Norden
2016-12-13 13:30:12 UTC
Permalink
There is currently no good way of translation a position in a browser to a
position on the screen. Our particular need is translating a gaze-position
(which we have in screen coordinates from our eyetracking hardware).

It is possible in Firefox, using the proprietary
mozInnerScreenX/mozInnerScreenY, but not in general.

One of the comments in
https://bugs.chromium.org/p/chromium/issues/detail?id=151983 seems to
indicate that the correct course of action is to raise the issue here, so I
will just post this and see where it leads.
--
/Jan Norden
Jonathan Zuckerman
2016-12-13 13:46:40 UTC
Permalink
Jan, does window.screenX/screenY not meet your needs?
https://developer.mozilla.org/en-US/docs/Web/API/Window/screenX
https://developer.mozilla.org/en-US/docs/Web/API/Window/screenY
Post by Jan Norden
There is currently no good way of translation a position in a browser to a
position on the screen. Our particular need is translating a gaze-position
(which we have in screen coordinates from our eyetracking hardware).
It is possible in Firefox, using the proprietary
mozInnerScreenX/mozInnerScreenY, but not in general.
One of the comments in
https://bugs.chromium.org/p/chromium/issues/detail?id=151983 seems to
indicate that the correct course of action is to raise the issue here, so I
will just post this and see where it leads.
--
/Jan Norden
Boris Zbarsky
2016-12-13 14:03:44 UTC
Permalink
Post by Jonathan Zuckerman
Jan, does window.screenX/screenY not meet your needs?
https://developer.mozilla.org/en-US/docs/Web/API/Window/screenX
https://developer.mozilla.org/en-US/docs/Web/API/Window/screenY
That doesn't work because it gives the screen position of the top/left
edge of the browser window, not of the content are the web page is
rendered into. So if you have a screen coordinate and you want to
translate it into page-relative coordinates, this won't do what you
want: you'll be off by the size of the window decorations and the
browser chrome.

-Boris
Jonathan Zuckerman
2016-12-13 14:09:11 UTC
Permalink
Ah right.. would it be possible to compute the missing dimensions given a
mouse event with screenX/Y and clientX/Y properties?
Post by Boris Zbarsky
Post by Jonathan Zuckerman
Jan, does window.screenX/screenY not meet your needs?
https://developer.mozilla.org/en-US/docs/Web/API/Window/screenX
https://developer.mozilla.org/en-US/docs/Web/API/Window/screenY
That doesn't work because it gives the screen position of the top/left
edge of the browser window, not of the content are the web page is
rendered into. So if you have a screen coordinate and you want to
translate it into page-relative coordinates, this won't do what you
want: you'll be off by the size of the window decorations and the
browser chrome.
-Boris
Boris Zbarsky
2016-12-13 14:18:40 UTC
Permalink
Post by Jonathan Zuckerman
Ah right.. would it be possible to compute the missing dimensions given
a mouse event with screenX/Y and clientX/Y properties?
Yes, that should be possible.

-Boris

Loading...