From dc50393a8f26813337189e910988b62f285435ef Mon Sep 17 00:00:00 2001 From: Pavel Tsekov Date: Mon, 6 Mar 2006 09:28:14 +0000 Subject: [PATCH] * src/mouse.h (Mouse_Type): Add new enumerated values to describe the xterm mouse reporting modes offered by various xterm-like terminals. * src/mouse.c: Adjust the code to reflect the changes above. Send the proper terminal control codes when xterm normal mouse tracking is requested. * src/main.c (init_xterm_support): Try to fine-tune the mouse tracking mode based on the terminal type. --- src/ChangeLog | 11 +++++++++++ src/main.c | 9 ++++++++- src/mouse.c | 26 +++++++++++++++++++++++--- src/mouse.h | 4 +++- 4 files changed, 45 insertions(+), 5 deletions(-) diff --git a/src/ChangeLog b/src/ChangeLog index 64f50954e..5d4fff813 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,14 @@ +2006-03-06 Pavel Tsekov + + * mouse.h (Mouse_Type): Add new enumerated values to describe + the xterm mouse reporting modes offered by various xterm-like + terminals. + * mouse.c: Adjust the code to reflect the changes above. + Send the proper terminal control codes when xterm normal mouse + tracking is requested. + * main.c (init_xterm_support): Try to fine-tune the mouse tracking + mode based on the terminal type. + 2006-02-28 Pavel Tsekov * widget.h (struct WRadio): Remove unused field diff --git a/src/main.c b/src/main.c index 8133af170..3e25287a1 100644 --- a/src/main.c +++ b/src/main.c @@ -1385,7 +1385,14 @@ init_xterm_support (void) /* Enable mouse unless explicitly disabled by --nomouse */ if (use_mouse_p != MOUSE_DISABLED) { - use_mouse_p = MOUSE_XTERM; + const char *color_term = getenv ("COLORTERM"); + if (strncmp (termvalue, "rxvt", 4) == 0 || + (color_term != NULL && strncmp (color_term, "rxvt", 4) == 0) || + strcmp (termvalue, "Eterm") == 0) { + use_mouse_p = MOUSE_XTERM_NORMAL_TRACKING; + } else { + use_mouse_p = MOUSE_XTERM_BUTTON_EVENT_TRACKING; + } } } } diff --git a/src/mouse.c b/src/mouse.c index c7a233b90..e8e016151 100644 --- a/src/mouse.c +++ b/src/mouse.c @@ -50,7 +50,8 @@ void init_mouse (void) use_mouse_p = MOUSE_GPM; break; #endif /* HAVE_LIBGPM */ - case MOUSE_XTERM: + case MOUSE_XTERM_NORMAL_TRACKING: + case MOUSE_XTERM_BUTTON_EVENT_TRACKING: define_sequence (MCKEY_MOUSE, xmouse_seq, MCKEY_NOACTION); break; default: @@ -86,7 +87,17 @@ void enable_mouse (void) } break; #endif /* HAVE_LIBGPM */ - case MOUSE_XTERM: + case MOUSE_XTERM_NORMAL_TRACKING: + /* save old highlight mouse tracking */ + printf(ESC_STR "[?1001s"); + + /* enable mouse tracking */ + printf(ESC_STR "[?1000h"); + + fflush (stdout); + mouse_enabled = 1; + break; + case MOUSE_XTERM_BUTTON_EVENT_TRACKING: /* save old highlight mouse tracking */ printf(ESC_STR "[?1001s"); @@ -115,7 +126,16 @@ void disable_mouse (void) Gpm_Close (); break; #endif - case MOUSE_XTERM: + case MOUSE_XTERM_NORMAL_TRACKING: + /* disable mouse tracking */ + printf(ESC_STR "[?1000l"); + + /* restore old highlight mouse tracking */ + printf(ESC_STR "[?1001r"); + + fflush (stdout); + break; + case MOUSE_XTERM_BUTTON_EVENT_TRACKING: /* disable mouse tracking */ printf(ESC_STR "[?1002l"); diff --git a/src/mouse.h b/src/mouse.h index d994ee3b0..1ee85a17c 100644 --- a/src/mouse.h +++ b/src/mouse.h @@ -55,7 +55,9 @@ typedef enum { MOUSE_NONE, /* Not detected yet */ MOUSE_DISABLED, /* Explicitly disabled by -d */ MOUSE_GPM, /* Support using GPM on Linux */ - MOUSE_XTERM /* Support using xterm-style mouse reporting */ + MOUSE_XTERM, /* Support using xterm-style mouse reporting */ + MOUSE_XTERM_NORMAL_TRACKING = MOUSE_XTERM, + MOUSE_XTERM_BUTTON_EVENT_TRACKING } Mouse_Type; /* Type of the currently used mouse */