Ticket #3208: 0001-Ticket-3208-fix-usage-of-GPM-under-screen-tmux.patch

File 0001-Ticket-3208-fix-usage-of-GPM-under-screen-tmux.patch, 2.7 KB (added by andrew_b, 10 years ago)
  • lib/tty/key.c

    From 118c05cc72cc538f5f54be0391ed6b15ce2e73cd Mon Sep 17 00:00:00 2001
    From: Andrew Borodin <aborodin@vmail.ru>
    Date: Thu, 11 Sep 2014 13:48:12 +0400
    Subject: [PATCH] Ticket #3208: fix usage of GPM under screen/tmux.
    
    Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
    ---
     lib/tty/key.c | 22 +++++++++++-----------
     1 file changed, 11 insertions(+), 11 deletions(-)
    
    diff --git a/lib/tty/key.c b/lib/tty/key.c
    index bdb4e1e..fc93b4e 100644
    a b define_sequence (int code, const char *seq, int action) 
    16981698gboolean 
    16991699is_idle (void) 
    17001700{ 
    1701     int nfd; 
     1701    int maxfdp; 
    17021702    fd_set select_set; 
    1703     struct timeval time_out; 
     1703    struct timeval time_out = { 0, 0 }; 
    17041704 
    17051705    FD_ZERO (&select_set); 
    17061706    FD_SET (input_fd, &select_set); 
    1707     nfd = max (0, input_fd) + 1; 
    1708     time_out.tv_sec = 0; 
    1709     time_out.tv_usec = 0; 
     1707    maxfdp = max (0, input_fd); 
     1708 
    17101709#ifdef HAVE_LIBGPM 
    17111710    if (mouse_enabled && use_mouse_p == MOUSE_GPM) 
    17121711    { 
    17131712        if (gpm_fd >= 0) 
    17141713        { 
    17151714            FD_SET (gpm_fd, &select_set); 
    1716             nfd = max (nfd, gpm_fd + 1); 
     1715            maxfdp = max (maxfdp, gpm_fd); 
    17171716        } 
    17181717        else 
    17191718        { 
    is_idle (void) 
    17321731        } 
    17331732    } 
    17341733#endif 
    1735     return (select (nfd, &select_set, 0, 0, &time_out) <= 0); 
     1734    return (select (maxfdp + 1, &select_set, 0, 0, &time_out) <= 0); 
    17361735} 
    17371736 
    17381737/* --------------------------------------------------------------------------------------------- */ 
    tty_get_event (struct Gpm_Event *event, gboolean redo_event, gboolean block) 
    19771976    /* Repeat if using mouse */ 
    19781977    while (pending_keys == NULL) 
    19791978    { 
    1980         int nfd; 
     1979        int maxfdp; 
    19811980        fd_set select_set; 
    19821981 
    19831982        FD_ZERO (&select_set); 
    19841983        FD_SET (input_fd, &select_set); 
    1985         nfd = max (add_selects (&select_set), max (0, input_fd)) + 1; 
     1984        maxfdp = add_selects (&select_set); 
     1985        maxfdp = max (maxfdp, max (0, input_fd)); 
    19861986 
    19871987#ifdef HAVE_LIBGPM 
    19881988        if (mouse_enabled && (use_mouse_p == MOUSE_GPM)) 
    tty_get_event (struct Gpm_Event *event, gboolean redo_event, gboolean block) 
    19901990            if (gpm_fd >= 0) 
    19911991            { 
    19921992                FD_SET (gpm_fd, &select_set); 
    1993                 nfd = max (nfd, gpm_fd + 1); 
     1993                maxfdp = max (maxfdp, gpm_fd); 
    19941994            } 
    19951995            else 
    19961996            { 
    tty_get_event (struct Gpm_Event *event, gboolean redo_event, gboolean block) 
    20462046        } 
    20472047 
    20482048        tty_enable_interrupt_key (); 
    2049         flag = select (nfd, &select_set, NULL, NULL, time_addr); 
     2049        flag = select (maxfdp + 1, &select_set, NULL, NULL, time_addr); 
    20502050        tty_disable_interrupt_key (); 
    20512051 
    20522052        /* select timed out: it could be for any of the following reasons: