Ok, I've commited a further refined and cleaned-up version of this
patch, this one without the confusion between the window frame size
and the content size.
It still has the problem of losing keyboard input after the window is
resized until the window is clicked. I must be doing something wrong,
but I can't find out what.