save and restore window state by takashiro