PistonDevelopers / glutin_window

A Piston window back-end using the Glutin library
MIT License
25 stars 40 forks source link

`scale_factor` is not considered in mouse event arguments #196

Closed shinmili closed 3 years ago

shinmili commented 3 years ago

piston crate doc mentions mouse events as:

Since some computer screens have higher resolution than others, it is convenient to use two kinds of coordinate systems:

  • A pixel is a single square on the screen
  • A point is a unit used by window events and 2D graphics

For example, the mouse cursor position events are measured in points.

But current glutin_window doesn't follow this statement; MouseCursorEvent::mouse_cursor passes a position in pixels to a handler.

One would be able to confirm this with paint example in piston-examples. If you let the scale factor be another value than 1.0 according to this, run the paint example and click on the canvas, you would see a dot plotted at a point not under the mouse cursor. (I confirmed on Gentoo Linux X11 Desktop and display that lets scale_factor return 1.8333333333333333.)