Solution: make window non-resizable, or have a resize event handler preserve the dynamically set values.