Streamlined window controls code.
Fixed LP bug 1102076.