patch 8.1.1399: popup windows not adjusted when switching tabs

Problem:    Popup windows not adjusted when switching tabs.
Solution:   Save and restore first_tab_popupwin. Fix closing a tabpage.
diff --git a/src/testdir/test_popupwin.vim b/src/testdir/test_popupwin.vim
index 7bae0b5..e79c03d 100644
--- a/src/testdir/test_popupwin.vim
+++ b/src/testdir/test_popupwin.vim
@@ -20,6 +20,19 @@
   let buf = RunVimInTerminal('-S XtestPopup', {'rows': 10})
   call VerifyScreenDump(buf, 'Test_popupwin_01', {})
 
+  " Add a tabpage
+  call term_sendkeys(buf, ":tabnew\<CR>")
+  call term_sendkeys(buf, ":call popup_create('other tab', {'line': 4, 'col': 9})\<CR>")
+  call VerifyScreenDump(buf, 'Test_popupwin_02', {})
+
+  " switch back to first tabpage
+  call term_sendkeys(buf, "gt")
+  call VerifyScreenDump(buf, 'Test_popupwin_03', {})
+
+  " close that tabpage
+  call term_sendkeys(buf, ":quit!\<CR>")
+  call VerifyScreenDump(buf, 'Test_popupwin_04', {})
+
   " clean up
   call StopVimInTerminal(buf)
   call delete('XtestPopup')