id	summary	reporter	owner	description	type	status	priority	milestone	component	version	resolution	keywords	cc	blockedby	blocking	branch_state	votes
3614	MC is unresponsive when running under tmux in Linux virtual terminal	devzero		"MC randomly stucks reading input when the following coditions met:
* MC is running under tmux or another terminal multiplexer.
* tmux itself is running in Linux virtual terminal.
* GPM is running.

MC tries to connect to GPM and then stucks reading GPM events. Under these conditions, MC is actually running in a pseudo terminal created by tmux, not in a virtual terminal, so we should not try connecting to GPM. The possible solution is to check ttyname in init_mouse(). If ttyname is /dev/tty*, it is a virtual terminal.

{{{
diff --git a/lib/tty/mouse.c b/lib/tty/mouse.c
index e9542e2..6546802 100644
--- a/lib/tty/mouse.c
+++ b/lib/tty/mouse.c
@@ -84,7 +84,15 @@ init_mouse (void)
     {
 #ifdef HAVE_LIBGPM
     case MOUSE_NONE:
-        use_mouse_p = MOUSE_GPM;
+        {
+            /* check if stdin is a linux virtual terminal */
+            char tname[64];
+            if (ttyname_r(0, tname, sizeof(tname)/sizeof(tname[0])) == 0 &&
+                strncmp(tname, ""/dev/tty"", sizeof(""/dev/tty"") - 1) == 0)
+            {
+                use_mouse_p = MOUSE_GPM;
+            }
+        }
         break;
 #endif /* HAVE_LIBGPM */
 
}}}
"	defect	closed	major	4.8.23	mc-tty	master	fixed	gpm		3208		no branch	
