ncurses 5.7 - patch 20090117
[ncurses.git] / ncurses / base / lib_getch.c
index 56e2a3a874d1de3d1f3efc021493b19f7527c3f0..a3812bee76e8003cdf946bcb9aa8503fc9099e38 100644 (file)
@@ -41,7 +41,7 @@
 
 #include <curses.priv.h>
 
-MODULE_ID("$Id: lib_getch.c,v 1.96 2008/06/28 23:29:20 tom Exp $")
+MODULE_ID("$Id: lib_getch.c,v 1.99 2008/09/20 19:46:13 tom Exp $")
 
 #include <fifo_defs.h>
 
@@ -260,7 +260,7 @@ recur_wrefresh(WINDOW *win)
 {
 #ifdef USE_PTHREADS
     SCREEN *sp = _nc_screen_of(win);
-    if (sp != SP) {
+    if (_nc_use_pthreads && sp != SP) {
        SCREEN *save_SP;
 
        /* temporarily switch to the window's screen to check/refresh */
@@ -284,23 +284,27 @@ recur_wgetnstr(WINDOW *win, char *buf)
     SCREEN *sp = _nc_screen_of(win);
     int rc;
 
+    if (sp != 0) {
 #ifdef USE_PTHREADS
-    if (sp != SP) {
-       SCREEN *save_SP;
-
-       /* temporarily switch to the window's screen to get cooked input */
-       _nc_lock_global(curses);
-       save_SP = SP;
-       _nc_set_screen(sp);
-       rc = recur_wgetnstr(win, buf);
-       _nc_set_screen(save_SP);
-       _nc_unlock_global(curses);
-    } else
+       if (_nc_use_pthreads && sp != SP) {
+           SCREEN *save_SP;
+
+           /* temporarily switch to the window's screen to get cooked input */
+           _nc_lock_global(curses);
+           save_SP = SP;
+           _nc_set_screen(sp);
+           rc = recur_wgetnstr(win, buf);
+           _nc_set_screen(save_SP);
+           _nc_unlock_global(curses);
+       } else
 #endif
-    {
-       sp->_called_wgetch = TRUE;
-       rc = wgetnstr(win, buf, MAXCOLUMNS);
-       sp->_called_wgetch = FALSE;
+       {
+           sp->_called_wgetch = TRUE;
+           rc = wgetnstr(win, buf, MAXCOLUMNS);
+           sp->_called_wgetch = FALSE;
+       }
+    } else {
+       rc = ERR;
     }
     return rc;
 }
@@ -377,7 +381,7 @@ _nc_wgetch(WINDOW *win,
 
     recur_wrefresh(win);
 
-    if (!win->_notimeout && (win->_delay >= 0 || sp->_cbreak > 1)) {
+    if (win->_notimeout || (win->_delay >= 0) || (sp->_cbreak > 1)) {
        if (head == -1) {       /* fifo is empty */
            int delay;
            int rc;