Fix window size calculation

Hi Jordan,

We were talking about this yesterday, this is my fix.  No point in you having to redo.  Are you going to put the C code back in master?