Improved screen boundary check - prevent positions to become negative.