patch 8.1.1131: getwinpos() does not work in the MS-Windows console

Problem:    getwinpos() does not work in the MS-Windows console.
Solution:   Implement getwinpos().
diff --git a/src/evalfunc.c b/src/evalfunc.c
index 968bc00..b79284c 100644
--- a/src/evalfunc.c
+++ b/src/evalfunc.c
@@ -5985,7 +5985,9 @@
 
     if (rettv_list_alloc(rettv) == FAIL)
 	return;
-#if defined(FEAT_GUI) || (defined(HAVE_TGETENT) && defined(FEAT_TERMRESPONSE))
+#if defined(FEAT_GUI) \
+	|| (defined(HAVE_TGETENT) && defined(FEAT_TERMRESPONSE)) \
+	|| defined(MSWIN)
     {
 	varnumber_T timeout = 100;
 
@@ -6007,7 +6009,10 @@
 f_getwinposx(typval_T *argvars UNUSED, typval_T *rettv)
 {
     rettv->vval.v_number = -1;
-#if defined(FEAT_GUI) || (defined(HAVE_TGETENT) && defined(FEAT_TERMRESPONSE))
+#if defined(FEAT_GUI) \
+	|| (defined(HAVE_TGETENT) && defined(FEAT_TERMRESPONSE)) \
+	|| defined(MSWIN)
+
     {
 	int	    x, y;
 
@@ -6024,7 +6029,9 @@
 f_getwinposy(typval_T *argvars UNUSED, typval_T *rettv)
 {
     rettv->vval.v_number = -1;
-#if defined(FEAT_GUI) || (defined(HAVE_TGETENT) && defined(FEAT_TERMRESPONSE))
+#if defined(FEAT_GUI) \
+	|| (defined(HAVE_TGETENT) && defined(FEAT_TERMRESPONSE)) \
+	|| defined(MSWIN)
     {
 	int	    x, y;
 
diff --git a/src/terminal.c b/src/terminal.c
index 4ff28b8..01cabf0 100644
--- a/src/terminal.c
+++ b/src/terminal.c
@@ -3868,7 +3868,9 @@
 
     // When getting the window position is not possible or it fails it results
     // in zero/zero.
-#if defined(FEAT_GUI) || (defined(HAVE_TGETENT) && defined(FEAT_TERMRESPONSE))
+#if defined(FEAT_GUI) \
+	|| (defined(HAVE_TGETENT) && defined(FEAT_TERMRESPONSE)) \
+	|| defined(MSWIN)
     (void)ui_get_winpos(&x, &y, (varnumber_T)100);
 #endif
 
diff --git a/src/testdir/test_terminal.vim b/src/testdir/test_terminal.vim
index 56b36d0..cbde579 100644
--- a/src/testdir/test_terminal.vim
+++ b/src/testdir/test_terminal.vim
@@ -1889,12 +1889,6 @@
 endfunc
 
 func Test_terminal_getwinpos()
-  " getwinpos() does not work in the MS-Windows console, and the GUI runs the
-  " console version in the terminal window.
-  if has('win32')
-    return
-  endif
-
   " split, go to the bottom-right window
   split
   wincmd j
@@ -1913,10 +1907,17 @@
   let xpos = str2nr(substitute(line, '\[\(\d\+\), \d\+\]', '\1', ''))
   let ypos = str2nr(substitute(line, '\[\d\+, \(\d\+\)\]', '\1', ''))
 
-  " Position must be bigger than the getwinpos() result of Vim itself.
-  let [xroot, yroot] = getwinpos()
-  call assert_inrange(xroot + 2, xroot + 1000, xpos)
-  call assert_inrange(yroot + 2, yroot + 1000, ypos)
+  " getwinpos() in the MS-Windows console returns the screen position of the
+  " emulated console.
+  if has('win32')
+    call assert_inrange(0, 4000, xpos)
+    call assert_inrange(0, 2000, ypos)
+  else
+    " Position must be bigger than the getwinpos() result of Vim itself.
+    let [xroot, yroot] = getwinpos()
+    call assert_inrange(xroot + 2, xroot + 1000, xpos)
+    call assert_inrange(yroot + 2, yroot + 1000, ypos)
+  endif
 
   call term_wait(buf)
   call term_sendkeys(buf, ":q\<CR>")
diff --git a/src/ui.c b/src/ui.c
index 7214876..3f41010 100644
--- a/src/ui.c
+++ b/src/ui.c
@@ -629,6 +629,7 @@
 
 #if ((defined(FEAT_EVAL) || defined(FEAT_TERMINAL)) \
 	    && (defined(FEAT_GUI) \
+		|| defined(MSWIN) \
 		|| (defined(HAVE_TGETENT) && defined(FEAT_TERMRESPONSE)))) \
 	|| defined(PROTO)
 /*
@@ -642,10 +643,14 @@
     if (gui.in_use)
 	return gui_mch_get_winpos(x, y);
 # endif
-# if defined(HAVE_TGETENT) && defined(FEAT_TERMRESPONSE)
-    return term_get_winpos(x, y, timeout);
+# if defined(MSWIN) && !defined(FEAT_GUI)
+    return mch_get_winpos(x, y);
 # else
+#  if defined(HAVE_TGETENT) && defined(FEAT_TERMRESPONSE)
+    return term_get_winpos(x, y, timeout);
+#  else
     return FAIL;
+#  endif
 # endif
 }
 #endif
diff --git a/src/version.c b/src/version.c
index 0052232..1fa1e8e 100644
--- a/src/version.c
+++ b/src/version.c
@@ -772,6 +772,8 @@
 static int included_patches[] =
 {   /* Add new patch number below this line */
 /**/
+    1131,
+/**/
     1130,
 /**/
     1129,