mirror of
https://github.com/MidnightCommander/mc
synced 2025-01-03 10:04:32 +03:00
Merge branch '3011_mc_gpm_and_xterm'
* 3011_mc_gpm_and_xterm: Ticket #3011: mc under x11 problems with mouse or hang due gpm
This commit is contained in:
commit
fef50bf629
108
lib/tty/key.c
108
lib/tty/key.c
@ -1326,7 +1326,7 @@ init_key (void)
|
||||
|| (term != NULL
|
||||
&& (strncmp (term, "iris-ansi", 9) == 0
|
||||
|| strncmp (term, "xterm", 5) == 0
|
||||
|| strncmp (term, "rxvt", 4) == 0 || strcmp (term, "screen") == 0)))
|
||||
|| strncmp (term, "rxvt", 4) == 0 || strncmp (term, "screen", 6) == 0)))
|
||||
define_sequences (xterm_key_defines);
|
||||
|
||||
/* load some additional keys (e.g. direct Alt-? support) */
|
||||
@ -1708,23 +1708,41 @@ define_sequence (int code, const char *seq, int action)
|
||||
gboolean
|
||||
is_idle (void)
|
||||
{
|
||||
int maxfdp;
|
||||
int nfd;
|
||||
fd_set select_set;
|
||||
struct timeval time_out;
|
||||
|
||||
FD_ZERO (&select_set);
|
||||
FD_SET (input_fd, &select_set);
|
||||
maxfdp = input_fd;
|
||||
#ifdef HAVE_LIBGPM
|
||||
if (mouse_enabled && (use_mouse_p == MOUSE_GPM) && (gpm_fd > 0))
|
||||
{
|
||||
FD_SET (gpm_fd, &select_set);
|
||||
maxfdp = max (maxfdp, gpm_fd);
|
||||
}
|
||||
#endif
|
||||
nfd = max (0, input_fd) + 1;
|
||||
time_out.tv_sec = 0;
|
||||
time_out.tv_usec = 0;
|
||||
return (select (maxfdp + 1, &select_set, 0, 0, &time_out) <= 0);
|
||||
#ifdef HAVE_LIBGPM
|
||||
if (mouse_enabled && use_mouse_p == MOUSE_GPM)
|
||||
{
|
||||
if (gpm_fd >= 0)
|
||||
{
|
||||
FD_SET (gpm_fd, &select_set);
|
||||
nfd = max (nfd, gpm_fd + 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (mouse_fd >= 0) /* error indicative */
|
||||
{
|
||||
if (FD_ISSET (mouse_fd, &select_set))
|
||||
FD_CLR (mouse_fd, &select_set);
|
||||
mouse_fd = gpm_fd;
|
||||
}
|
||||
/* gpm_fd == -2 means under some X terminal */
|
||||
if (gpm_fd == -1)
|
||||
{
|
||||
mouse_enabled = FALSE;
|
||||
use_mouse_p = MOUSE_NONE;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
return (select (nfd, &select_set, 0, 0, &time_out) <= 0);
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
@ -1969,26 +1987,37 @@ tty_get_event (struct Gpm_Event *event, gboolean redo_event, gboolean block)
|
||||
/* Repeat if using mouse */
|
||||
while (pending_keys == NULL)
|
||||
{
|
||||
int maxfdp;
|
||||
int nfd;
|
||||
fd_set select_set;
|
||||
|
||||
FD_ZERO (&select_set);
|
||||
FD_SET (input_fd, &select_set);
|
||||
maxfdp = max (add_selects (&select_set), input_fd);
|
||||
nfd = max (add_selects (&select_set), max (0, input_fd)) + 1;
|
||||
|
||||
#ifdef HAVE_LIBGPM
|
||||
if (mouse_enabled && (use_mouse_p == MOUSE_GPM))
|
||||
{
|
||||
if (gpm_fd < 0)
|
||||
if (gpm_fd >= 0)
|
||||
{
|
||||
FD_SET (gpm_fd, &select_set);
|
||||
nfd = max (nfd, gpm_fd + 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (mouse_fd >= 0) /* error indicative */
|
||||
{
|
||||
if (FD_ISSET (mouse_fd, &select_set))
|
||||
FD_CLR (mouse_fd, &select_set);
|
||||
mouse_fd = gpm_fd;
|
||||
}
|
||||
/* gpm_fd == -2 means under some X terminal */
|
||||
if (gpm_fd == -1)
|
||||
{
|
||||
/* Connection to gpm broken, possibly gpm has died */
|
||||
mouse_enabled = FALSE;
|
||||
use_mouse_p = MOUSE_NONE;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
FD_SET (gpm_fd, &select_set);
|
||||
maxfdp = max (maxfdp, gpm_fd);
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -2027,7 +2056,7 @@ tty_get_event (struct Gpm_Event *event, gboolean redo_event, gboolean block)
|
||||
}
|
||||
|
||||
tty_enable_interrupt_key ();
|
||||
flag = select (maxfdp + 1, &select_set, NULL, NULL, time_addr);
|
||||
flag = select (nfd, &select_set, NULL, NULL, time_addr);
|
||||
tty_disable_interrupt_key ();
|
||||
|
||||
/* select timed out: it could be for any of the following reasons:
|
||||
@ -2051,14 +2080,49 @@ tty_get_event (struct Gpm_Event *event, gboolean redo_event, gboolean block)
|
||||
if (FD_ISSET (input_fd, &select_set))
|
||||
break;
|
||||
#ifdef HAVE_LIBGPM
|
||||
if (mouse_enabled && use_mouse_p == MOUSE_GPM
|
||||
&& gpm_fd > 0 && FD_ISSET (gpm_fd, &select_set))
|
||||
if (mouse_enabled && use_mouse_p == MOUSE_GPM)
|
||||
{
|
||||
if (gpm_fd >= 0)
|
||||
{
|
||||
if (FD_ISSET (gpm_fd, &select_set))
|
||||
{
|
||||
int status;
|
||||
|
||||
status = Gpm_GetEvent (&ev);
|
||||
if (status == 1) /* success */
|
||||
{
|
||||
Gpm_GetEvent (&ev);
|
||||
Gpm_FitEvent (&ev);
|
||||
*event = ev;
|
||||
return EV_MOUSE;
|
||||
}
|
||||
else if (status == 0) /* connection closed; -1 == error */
|
||||
{
|
||||
if (mouse_fd >= 0 && FD_ISSET (mouse_fd, &select_set))
|
||||
FD_CLR (mouse_fd, &select_set);
|
||||
|
||||
/* Try to reopen gpm_mouse connection */
|
||||
disable_mouse ();
|
||||
enable_mouse ();
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (mouse_fd >= 0) /* error indicative */
|
||||
{
|
||||
if (FD_ISSET (mouse_fd, &select_set))
|
||||
FD_CLR (mouse_fd, &select_set);
|
||||
mouse_fd = gpm_fd;
|
||||
}
|
||||
/* gpm_fd == -2 means under some X terminal */
|
||||
if (gpm_fd == -1)
|
||||
{
|
||||
mouse_enabled = FALSE;
|
||||
use_mouse_p = MOUSE_NONE;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
#endif /* !HAVE_LIBGPM */
|
||||
}
|
||||
|
||||
|
@ -47,6 +47,7 @@
|
||||
|
||||
Mouse_Type use_mouse_p = MOUSE_NONE;
|
||||
gboolean mouse_enabled = FALSE;
|
||||
int mouse_fd = -1; /* for when gpm_fd changes to < 0 and the old one must be cleared from select_set */
|
||||
const char *xmouse_seq;
|
||||
const char *xmouse_extended_seq;
|
||||
|
||||
@ -114,7 +115,6 @@ enable_mouse (void)
|
||||
#ifdef HAVE_LIBGPM
|
||||
case MOUSE_GPM:
|
||||
{
|
||||
int mouse_d;
|
||||
Gpm_Connect conn;
|
||||
|
||||
conn.eventMask = ~GPM_MOVE;
|
||||
@ -122,8 +122,8 @@ enable_mouse (void)
|
||||
conn.minMod = 0;
|
||||
conn.maxMod = 0;
|
||||
|
||||
mouse_d = Gpm_Open (&conn, 0);
|
||||
if (mouse_d == -1)
|
||||
mouse_fd = Gpm_Open (&conn, 0);
|
||||
if (mouse_fd == -1)
|
||||
{
|
||||
use_mouse_p = MOUSE_NONE;
|
||||
return;
|
||||
|
@ -97,6 +97,9 @@ typedef int (*mouse_h) (Gpm_Event *, void *);
|
||||
/* Type of the currently used mouse */
|
||||
extern Mouse_Type use_mouse_p;
|
||||
|
||||
/* To be used when gpm_fd were initially >= 0 */
|
||||
extern int mouse_fd;
|
||||
|
||||
/* String indicating that a mouse event has occurred, usually "\E[M" */
|
||||
extern const char *xmouse_seq;
|
||||
|
||||
|
@ -90,6 +90,7 @@ gboolean
|
||||
tty_check_term (gboolean force_xterm)
|
||||
{
|
||||
const char *termvalue;
|
||||
const char *xdisplay;
|
||||
|
||||
termvalue = getenv ("TERM");
|
||||
if (termvalue == NULL || *termvalue == '\0')
|
||||
@ -98,10 +99,16 @@ tty_check_term (gboolean force_xterm)
|
||||
exit (EXIT_FAILURE);
|
||||
}
|
||||
|
||||
xdisplay = getenv ("DISPLAY");
|
||||
if (xdisplay != NULL && *xdisplay == '\0')
|
||||
xdisplay = NULL;
|
||||
|
||||
return force_xterm || strncmp (termvalue, "xterm", 5) == 0
|
||||
|| strncmp (termvalue, "konsole", 7) == 0
|
||||
|| strncmp (termvalue, "rxvt", 4) == 0
|
||||
|| strcmp (termvalue, "Eterm") == 0 || strcmp (termvalue, "dtterm") == 0;
|
||||
|| strcmp (termvalue, "Eterm") == 0
|
||||
|| strcmp (termvalue, "dtterm") == 0
|
||||
|| (strncmp (termvalue, "screen", 6) == 0 && xdisplay != NULL);
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
Loading…
Reference in New Issue
Block a user