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) |
1698 | 1698 | gboolean |
1699 | 1699 | is_idle (void) |
1700 | 1700 | { |
1701 | | int nfd; |
| 1701 | int maxfdp; |
1702 | 1702 | fd_set select_set; |
1703 | | struct timeval time_out; |
| 1703 | struct timeval time_out = { 0, 0 }; |
1704 | 1704 | |
1705 | 1705 | FD_ZERO (&select_set); |
1706 | 1706 | 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 | |
1710 | 1709 | #ifdef HAVE_LIBGPM |
1711 | 1710 | if (mouse_enabled && use_mouse_p == MOUSE_GPM) |
1712 | 1711 | { |
1713 | 1712 | if (gpm_fd >= 0) |
1714 | 1713 | { |
1715 | 1714 | FD_SET (gpm_fd, &select_set); |
1716 | | nfd = max (nfd, gpm_fd + 1); |
| 1715 | maxfdp = max (maxfdp, gpm_fd); |
1717 | 1716 | } |
1718 | 1717 | else |
1719 | 1718 | { |
… |
… |
is_idle (void) |
1732 | 1731 | } |
1733 | 1732 | } |
1734 | 1733 | #endif |
1735 | | return (select (nfd, &select_set, 0, 0, &time_out) <= 0); |
| 1734 | return (select (maxfdp + 1, &select_set, 0, 0, &time_out) <= 0); |
1736 | 1735 | } |
1737 | 1736 | |
1738 | 1737 | /* --------------------------------------------------------------------------------------------- */ |
… |
… |
tty_get_event (struct Gpm_Event *event, gboolean redo_event, gboolean block) |
1977 | 1976 | /* Repeat if using mouse */ |
1978 | 1977 | while (pending_keys == NULL) |
1979 | 1978 | { |
1980 | | int nfd; |
| 1979 | int maxfdp; |
1981 | 1980 | fd_set select_set; |
1982 | 1981 | |
1983 | 1982 | FD_ZERO (&select_set); |
1984 | 1983 | 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)); |
1986 | 1986 | |
1987 | 1987 | #ifdef HAVE_LIBGPM |
1988 | 1988 | if (mouse_enabled && (use_mouse_p == MOUSE_GPM)) |
… |
… |
tty_get_event (struct Gpm_Event *event, gboolean redo_event, gboolean block) |
1990 | 1990 | if (gpm_fd >= 0) |
1991 | 1991 | { |
1992 | 1992 | FD_SET (gpm_fd, &select_set); |
1993 | | nfd = max (nfd, gpm_fd + 1); |
| 1993 | maxfdp = max (maxfdp, gpm_fd); |
1994 | 1994 | } |
1995 | 1995 | else |
1996 | 1996 | { |
… |
… |
tty_get_event (struct Gpm_Event *event, gboolean redo_event, gboolean block) |
2046 | 2046 | } |
2047 | 2047 | |
2048 | 2048 | 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); |
2050 | 2050 | tty_disable_interrupt_key (); |
2051 | 2051 | |
2052 | 2052 | /* select timed out: it could be for any of the following reasons: |