Fix an issue that window cannot resize correctly