+#if USE_REENTRANT
+#define GetEscdelay(sp) *_nc_ptr_Escdelay(sp)
+NCURSES_EXPORT(int)
+NCURSES_PUBLIC_VAR(ESCDELAY) (void)
+{
+ return *(_nc_ptr_Escdelay(CURRENT_SCREEN));
+}
+
+NCURSES_EXPORT(int *)
+_nc_ptr_Escdelay(SCREEN *sp)
+{
+ return ptrEscdelay(sp);
+}
+#else
+#define GetEscdelay(sp) ESCDELAY
+NCURSES_EXPORT_VAR(int) ESCDELAY = 1000;
+#endif
+
+#if NCURSES_EXT_FUNCS
+NCURSES_EXPORT(int)
+NCURSES_SP_NAME(set_escdelay) (NCURSES_SP_DCLx int value)
+{
+ int code = OK;
+#if USE_REENTRANT
+ if (SP_PARM) {
+ SET_ESCDELAY(value);
+ } else {
+ code = ERR;
+ }
+#else
+ (void) SP_PARM;
+ ESCDELAY = value;
+#endif
+ return code;
+}
+
+#if NCURSES_SP_FUNCS
+NCURSES_EXPORT(int)
+set_escdelay(int value)
+{
+ int code;
+#if USE_REENTRANT
+ code = NCURSES_SP_NAME(set_escdelay) (CURRENT_SCREEN, value);
+#else
+ ESCDELAY = value;
+ code = OK;
+#endif
+ return code;
+}
+#endif
+#endif /* NCURSES_EXT_FUNCS */
+
+#if NCURSES_EXT_FUNCS
+NCURSES_EXPORT(int)
+NCURSES_SP_NAME(get_escdelay) (NCURSES_SP_DCL0)
+{
+#if !USE_REENTRANT
+ (void) SP_PARM;
+#endif
+ return GetEscdelay(SP_PARM);
+}
+
+#if NCURSES_SP_FUNCS
+NCURSES_EXPORT(int)
+get_escdelay(void)
+{
+ return NCURSES_SP_NAME(get_escdelay) (CURRENT_SCREEN);
+}
+#endif
+#endif /* NCURSES_EXT_FUNCS */
+
+static int
+_nc_use_meta(WINDOW *win)
+{
+ SCREEN *sp = _nc_screen_of(win);
+ return (sp ? sp->_use_meta : 0);
+}
+
+/*
+ * Check for mouse activity, returning nonzero if we find any.
+ */
+static int
+check_mouse_activity(SCREEN *sp, int delay EVENTLIST_2nd(_nc_eventlist * evl))
+{
+ int rc;
+
+#ifdef USE_TERM_DRIVER
+ rc = TCBOf(sp)->drv->testmouse(TCBOf(sp), delay EVENTLIST_2nd(evl));
+#else
+#if USE_SYSMOUSE
+ if ((sp->_mouse_type == M_SYSMOUSE)
+ && (sp->_sysmouse_head < sp->_sysmouse_tail)) {
+ rc = TW_MOUSE;
+ } else
+#endif
+ {
+ rc = _nc_timed_wait(sp,
+ TWAIT_MASK,
+ delay,
+ (int *) 0
+ EVENTLIST_2nd(evl));
+#if USE_SYSMOUSE
+ if ((sp->_mouse_type == M_SYSMOUSE)
+ && (sp->_sysmouse_head < sp->_sysmouse_tail)
+ && (rc == 0)
+ && (errno == EINTR)) {
+ rc |= TW_MOUSE;
+ }
+#endif
+ }
+#endif
+ return rc;
+}