improved fullscreen handling code