Dynamical resize of the window