bug-ncurses
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: getch() in nodelay mode returns KEY_RESIZE too late


From: Clemens Ladisch
Subject: Re: getch() in nodelay mode returns KEY_RESIZE too late
Date: Tue, 11 Aug 2009 12:47:58 +0200
User-agent: Thunderbird 2.0.0.22 (Windows/20090605)

Clemens Ladisch wrote:
> Thomas Dickey wrote:
> > On Mon, Jun 08, 2009 at 02:39:00PM +0200, Clemens Ladisch wrote:
> > > When the following program is run and its console window is resized, the
> > > first following getch() call returns ERR instead of KEY_RESIZE.  That
> > > KEY_RESIZE is returned only after the refresh() call, i.e., when a key
> > > is pressed or when the window is resized a second time.
> > 
> > I don't see that error (looking at a debug-trace, attached).
> 
> Sorry, it turns out my description was misleading.  The error does not
> show in the very first call of getch().  To reproduce, press some key
> before resizing, or resize more than once.

This is fixed by the patch below.

For a window in non-blocking input mode, _nc_wgetch() did not check for
SIGWINCH.  (In most cases, this bug was hidden by the fact that
_nc_wgetch() calls wrefresh() if the window was touched and that the
resulting doupdate() executes its own copy of the SIGWINCH handling
code.)

This can be fixed by executing the WIGWINCH handling code for both
blocking and non-blocking modes.  (I've used a goto to avoid making
more extensive changes to the control flow.)

--- ncurses-5.7-20090808/ncurses/base/lib_getch.c
+++ ncurses-5.7-20090808/ncurses/base/lib_getch.c
@@ -467,7 +467,7 @@ _nc_wgetch(WINDOW *win,
            }
 #endif
            if (!rc) {
-               returnCode(ERR);
+               goto check_sigwinch;
            }
        }
        /* else go on to read data available */
@@ -529,6 +529,7 @@ _nc_wgetch(WINDOW *win,
     }
 
     if (ch == ERR) {
+      check_sigwinch:
 #if USE_SIZECHANGE
        if (_nc_handle_sigwinch(sp)) {
            _nc_update_screensize(sp);




reply via email to

[Prev in Thread] Current Thread [Next in Thread]