patch 8.0.1563: timeout of getwinposx() can be too short

Problem:    Timeout of getwinposx() can be too short. (lilydjwg)
Solution:   Add getwinpos(). (closes #2689)
diff --git a/src/evalfunc.c b/src/evalfunc.c
index e866f4c..b02c956 100644
--- a/src/evalfunc.c
+++ b/src/evalfunc.c
@@ -197,6 +197,7 @@
 static void f_gettabvar(typval_T *argvars, typval_T *rettv);
 static void f_gettabwinvar(typval_T *argvars, typval_T *rettv);
 static void f_getwininfo(typval_T *argvars, typval_T *rettv);
+static void f_getwinpos(typval_T *argvars, typval_T *rettv);
 static void f_getwinposx(typval_T *argvars, typval_T *rettv);
 static void f_getwinposy(typval_T *argvars, typval_T *rettv);
 static void f_getwinvar(typval_T *argvars, typval_T *rettv);
@@ -641,6 +642,7 @@
     {"gettabvar",	2, 3, f_gettabvar},
     {"gettabwinvar",	3, 4, f_gettabwinvar},
     {"getwininfo",	0, 1, f_getwininfo},
+    {"getwinpos",	0, 1, f_getwinpos},
     {"getwinposx",	0, 0, f_getwinposx},
     {"getwinposy",	0, 0, f_getwinposy},
     {"getwinvar",	2, 3, f_getwinvar},
@@ -5527,6 +5529,38 @@
 }
 
 /*
+ * "getwinpos({timeout})" function
+ */
+    static void
+f_getwinpos(typval_T *argvars UNUSED, typval_T *rettv)
+{
+    int x = -1;
+    int y = -1;
+
+    if (rettv_list_alloc(rettv) == FAIL)
+	return;
+#ifdef FEAT_GUI
+    if (gui.in_use)
+	gui_mch_get_winpos(&x, &y);
+# if defined(HAVE_TGETENT) && defined(FEAT_TERMRESPONSE)
+    else
+# endif
+#endif
+#if defined(HAVE_TGETENT) && defined(FEAT_TERMRESPONSE)
+    {
+	varnumber_T timeout = 100;
+
+	if (argvars[0].v_type != VAR_UNKNOWN)
+	    timeout = get_tv_number(&argvars[0]);
+	term_get_winpos(&x, &y, timeout);
+    }
+#endif
+    list_append_number(rettv->vval.v_list, (varnumber_T)x);
+    list_append_number(rettv->vval.v_list, (varnumber_T)y);
+}
+
+
+/*
  * "getwinposx()" function
  */
     static void
@@ -5547,7 +5581,7 @@
     {
 	int	    x, y;
 
-	if (term_get_winpos(&x, &y) == OK)
+	if (term_get_winpos(&x, &y, (varnumber_T)100) == OK)
 	    rettv->vval.v_number = x;
     }
 #endif
@@ -5574,7 +5608,7 @@
     {
 	int	    x, y;
 
-	if (term_get_winpos(&x, &y) == OK)
+	if (term_get_winpos(&x, &y, (varnumber_T)100) == OK)
 	    rettv->vval.v_number = y;
     }
 #endif
diff --git a/src/proto/term.pro b/src/proto/term.pro
index 92cb26d..42405dd 100644
--- a/src/proto/term.pro
+++ b/src/proto/term.pro
@@ -24,7 +24,7 @@
 void term_append_lines(int line_count);
 void term_delete_lines(int line_count);
 void term_set_winpos(int x, int y);
-int term_get_winpos(int *x, int *y);
+int term_get_winpos(int *x, int *y, varnumber_T timeout);
 void term_set_winsize(int height, int width);
 void term_fg_color(int n);
 void term_bg_color(int n);
diff --git a/src/term.c b/src/term.c
index 12c4f2e..7dbbefa 100644
--- a/src/term.c
+++ b/src/term.c
@@ -2789,7 +2789,7 @@
  * Returns OK or FAIL.
  */
     int
-term_get_winpos(int *x, int *y)
+term_get_winpos(int *x, int *y, varnumber_T timeout)
 {
     int count = 0;
 
@@ -2801,8 +2801,8 @@
     OUT_STR(T_CGP);
     out_flush();
 
-    /* Try reading the result for 100 msec. */
-    while (count++ < 10)
+    /* Try reading the result for "timeout" msec. */
+    while (count++ < timeout / 10)
     {
 	(void)vpeekc_nomap();
 	if (winpos_x >= 0 && winpos_y >= 0)
diff --git a/src/version.c b/src/version.c
index 200ed6f..c780826 100644
--- a/src/version.c
+++ b/src/version.c
@@ -779,6 +779,8 @@
 static int included_patches[] =
 {   /* Add new patch number below this line */
 /**/
+    1563,
+/**/
     1562,
 /**/
     1561,