client: fix the dynamic layout algorithm