title: Qt: "normal" window size lost when switching to maximized state and then to fullscreen
body: <p>I have an Qt application that can be displayed either "normal" (a normal window that's neither maximized nor minimized), maximized or fullscreen. I achieve that by calling the functions <code>QWidget::showNormal()</code>, <code>QWidget::showMaximized()</code> and <code>QWidget::showFullscreen()</code>.</p>
  
  <p>Let me first of all explain what does work:</p>
  
  <ol>
  <li>Going from normal to maximized and back works. Qt remembers the window size and position of the normal window and then restores that when exiting the maximized state.</li>
  <li>Going from normal to fullscreen and back works. Also here the size and position of the normal window is maintained.</li>
  </ol>
  
  <p>What doesn't work?</p>
  
  <p>When going from normal to maximized, then to fullscreen, back to maximized and then back to normal that does not work as expected. The window will not be resized to the size that it had originally, before maximizing. Instead the window will be as large as the screen (basically as large as the OS allows the window to be). </p>
  
  <p>If I now go to fullscreen again then in the right upper corner and on the bottom edge there are weird artifacts that seem to look like parts of an old Vista window frame with visual effects disabled.</p>
  
  <p>Here is an image that should illustrate the process I just explained:</p>
  
  <p><a href="https://i.stack.imgur.com/q3gaF.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/q3gaF.jpg" alt="enter image description here"></a></p>
  
  <p>I tried to save the last size of the window using <code>QWidget::saveGeometry()</code> or just saving the size obtained by <code>QWidget::size()</code> when a window state change event occured, but there were always cases when it behaved strangely. Apart from that, that last step when going full screen again looks like a bug to me.</p>
  
  <p>What do you think?</p>
  
  <p>UPDATE:</p>
  
  <p>If I resize the window manually (to an arbitrary size) before the last step (which is going to fullscreen again), the fullscreen works without problems.</p>