Fixes #819. Note that I have no idea whether the code works well on retina screens, might have to multiple the pixel count by the scale factor on those screens?