Prevent erroneous movement of the window (fixes #85, fixes #167)