patch 8.1.1450: popup window positioning wrong when using padding or borders

Problem:    Popup window positioning wrong when using padding or borders.
Solution:   Fix computing the position.
diff --git a/src/testdir/dumps/Test_popupwin_corners.dump b/src/testdir/dumps/Test_popupwin_corners.dump
new file mode 100644
index 0000000..eee6601
--- /dev/null
+++ b/src/testdir/dumps/Test_popupwin_corners.dump
@@ -0,0 +1,12 @@
+|-+0&#ffffff0@59| @14
+|-@1|#|-@20|@|-@34| @14
+|-@1|╔+0#0000001#ffd7ff255|═@7|╗|-+0#0000000#ffffff0@2|╔+0#0000001#ffd7ff255|═@7|╗|-+0#0000000#ffffff0@2|╔+0#0000001#ffd7ff255|═@7|╗|-+0#0000000#ffffff0@2|╔+0#0000001#ffd7ff255|═@7|╗|-+0#0000000#ffffff0@8| @14
+|-@1|║+0#0000001#ffd7ff255| @7|║|-+0#0000000#ffffff0@2|║+0#0000001#ffd7ff255| @7|║|-+0#0000000#ffffff0@2|║+0#0000001#ffd7ff255| @7|║|-+0#0000000#ffffff0@2|║+0#0000001#ffd7ff255| @7|║|-+0#0000000#ffffff0@8| @14
+|-@1|║+0#0000001#ffd7ff255| |f|i|r|s|t| @1|║|-+0#0000000#ffffff0@2|║+0#0000001#ffd7ff255| |F|i|r|s|t| @1|║|-+0#0000000#ffffff0@2|║+0#0000001#ffd7ff255| |f|i|R|S|t| @1|║|-+0#0000000#ffffff0@2|║+0#0000001#ffd7ff255| |F|I|r|s|T| @1|║|-+0#0000000#ffffff0@8| @14
+|-@1|║+0#0000001#ffd7ff255| |s|e|c|o|n|d| |║|-+0#0000000#ffffff0@2|║+0#0000001#ffd7ff255| |S|e|c|o|n|D| |║|-+0#0000000#ffffff0@2|║+0#0000001#ffd7ff255| |s|e|C|O|n|d| |║|-+0#0000000#ffffff0@2|║+0#0000001#ffd7ff255| |S|E|c|o|N|D| |║|-+0#0000000#ffffff0@8| @14
+|-@1|║+0#0000001#ffd7ff255| @7|║|-+0#0000000#ffffff0@2|║+0#0000001#ffd7ff255| @7|║|-+0#0000000#ffffff0@2|║+0#0000001#ffd7ff255| @7|║|-+0#0000000#ffffff0@2|║+0#0000001#ffd7ff255| @7|║|-+0#0000000#ffffff0@8| @14
+|-@1|╚+0#0000001#ffd7ff255|═@7|╝|-+0#0000000#ffffff0@2|╚+0#0000001#ffd7ff255|═@7|╝|-+0#0000000#ffffff0@2|╚+0#0000001#ffd7ff255|═@7|╝|-+0#0000000#ffffff0@2|╚+0#0000001#ffd7ff255|═@7|╝|-+0#0000000#ffffff0@8| @14
+|-@27|%|-@20>&|-@8| @14
+|-@59| @14
+|-@59| @14
+@57|9|,|5|1| @9|T|o|p| 
diff --git a/src/testdir/test_popupwin.vim b/src/testdir/test_popupwin.vim
index e4f7cd2..73f53a2 100644
--- a/src/testdir/test_popupwin.vim
+++ b/src/testdir/test_popupwin.vim
@@ -175,6 +175,55 @@
   call delete('XtestPopup')
 endfunc
 
+func Test_popup_all_corners()
+  if !CanRunVimInTerminal()
+    return
+  endif
+  let lines =<< trim END
+	call setline(1, repeat([repeat('-', 60)], 15))
+	set so=0
+	normal 2G3|r#
+	let winid1 = popup_create(['first', 'second'], {
+	      \ 'line': 'cursor+1',
+	      \ 'col': 'cursor',
+	      \ 'pos': 'topleft',
+	      \ 'border': [],
+	      \ 'padding': [],
+	      \ })
+	normal 25|r@
+	let winid1 = popup_create(['First', 'SeconD'], {
+	      \ 'line': 'cursor+1',
+	      \ 'col': 'cursor',
+	      \ 'pos': 'topright',
+	      \ 'border': [],
+	      \ 'padding': [],
+	      \ })
+	normal 9G29|r%
+	let winid1 = popup_create(['fiRSt', 'seCOnd'], {
+	      \ 'line': 'cursor-1',
+	      \ 'col': 'cursor',
+	      \ 'pos': 'botleft',
+	      \ 'border': [],
+	      \ 'padding': [],
+	      \ })
+	normal 51|r&
+	let winid1 = popup_create(['FIrsT', 'SEcoND'], {
+	      \ 'line': 'cursor-1',
+	      \ 'col': 'cursor',
+	      \ 'pos': 'botright',
+	      \ 'border': [],
+	      \ 'padding': [],
+	      \ })
+  END
+  call writefile(lines, 'XtestPopupCorners')
+  let buf = RunVimInTerminal('-S XtestPopupCorners', {'rows': 12})
+  call VerifyScreenDump(buf, 'Test_popupwin_corners', {})
+
+  " clean up
+  call StopVimInTerminal(buf)
+  call delete('XtestPopupCorners')
+endfunc
+
 func Test_win_execute_closing_curwin()
   split
   let winid = popup_create('some text', {})