Fixing window size problem when detaching a window