Fixed pixel calculations for narrow screens

These were causing a _java.lang.ArrayIndexOutOfBoundsException: Coordinate out of bounds!_ message, especially when changing resolution or your system waking up from sleep.

Fixes #387