Bug 233488

Summary: attempt to use mouse with ncurses inside screen causes erratic behavior
Product: [Fedora] Fedora Reporter: Gabriel Somlo <somlo>
Component: gpmAssignee: Tomas Janousek <tjanouse>
Status: CLOSED ERRATA QA Contact: David Lawrence <dkl>
Severity: medium Docs Contact:
Priority: medium    
Version: 6CC: mlichvar, mmaslano
Target Milestone: ---   
Target Release: ---   
Hardware: i386   
OS: Linux   
Whiteboard:
Fixed In Version: gpm-1.20.1-81.fc6 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2007-03-23 16:36:30 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Gabriel Somlo 2007-03-22 18:46:14 UTC
Description of problem:

programs using the mouse click feature of ncurses act crazy when run from
within /usr/bin/screen. When mousemask() is used after initscr() in a
ncurses-based program, getch() will go crazy. See example code below.

Version-Release number of selected component (if applicable):

ncurses-5.5-24.20060715
ncurses-devel-5.5-24.20060715
screen-4.0.3-2.fc6

How reproducible:

by compiling and executing the following example code (cursebug.c):

#include <stdio.h>
#include <ncurses.h>

int main(int argc, char **argv) {

    initscr();

    mousemask(BUTTON1_PRESSED | BUTTON1_CLICKED, NULL);

    halfdelay(10);

    for (;;) {
        int key = getch();
        switch (key) {
            case 'q':
            case 'Q':
                return 0;
            case KEY_MOUSE:
                fprintf(stderr, "Mouse Click.\n");
                break;
            default:
                fprintf(stderr, "default: key = %d\n", key);
                break;
        }
    }

    endwin();

    return 0;
}

Steps to Reproduce:
1. compile code: gcc -o cursebug cursebug.c -Wall -lncurses
2. in a window, start screen: /usr/bin/screen
3. then, start example from within screen: ./cursebug 2>cursebug.log
3. in a separate window, view log: tail -f cursebug.log
  
Actual results:

getch() returns -1 in a very tight loop

Expected results:

getch() should return -1 once every second (as per halfdelay(10)), and
actual key presses and mouse clicks when entered. This works fine when
example is run directly from console or an xterm, but not from within
screen.

Additional info:

Comment 1 Miroslav Lichvar 2007-03-23 15:17:24 UTC
Thanks for the report, looks like a gpm problem.

Comment 2 Tomas Janousek 2007-03-23 16:36:30 UTC
A gpm prob indeed. I broke it with the deadsocket patch. There was a better way
to do it and I hope I took the One this time. Should be fixed in the upcoming
update. You can try out the rawhide srpm in the meantime, it's equivalent.

Comment 3 Fedora Update System 2007-03-23 22:16:41 UTC
gpm-1.20.1-81.fc6 has been pushed for fc6, which should resolve this issue.  If these problems are still present in this version, then please make note of it in this bug report.

Comment 4 Fedora Update System 2007-03-23 22:17:38 UTC
gpm-1.20.1-81.fc5 has been pushed for fc5, which should resolve this issue.  If these problems are still present in this version, then please make note of it in this bug report.

Comment 5 Gabriel Somlo 2007-03-27 18:01:24 UTC
sorry for taking this long to respond -- just for the record, gpm-1.20.1-81.fc6
does indeed fix the problem. Thanks !