You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

73 lines
2.7 KiB

  1. From b92c7f86b4be3b200e0f2de713a4c40b28599e61 Mon Sep 17 00:00:00 2001
  2. From: Egmont Koblinger <egmont@gmail.com>
  3. Date: Fri, 14 Feb 2020 22:14:19 +0100
  4. Subject: [PATCH] Ticket #3954: fix mouse handling with newer terminfo entries.
  5. Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
  6. ---
  7. lib/tty/key.c | 11 +++++++++--
  8. lib/tty/mouse.c | 6 ++++--
  9. lib/tty/tty.c | 9 ++++++++-
  10. 3 files changed, 21 insertions(+), 5 deletions(-)
  11. diff --git a/lib/tty/key.c b/lib/tty/key.c
  12. index 1aa5110af0..4abfc71d73 100644
  13. --- a/lib/tty/key.c
  14. +++ b/lib/tty/key.c
  15. @@ -2120,8 +2120,15 @@ tty_get_event (struct Gpm_Event *event, gboolean redo_event, gboolean block)
  16. #endif /* KEY_MOUSE */
  17. || c == MCKEY_EXTENDED_MOUSE))
  18. {
  19. - /* Mouse event */
  20. - xmouse_get_event (event, c == MCKEY_EXTENDED_MOUSE);
  21. + /* Mouse event. See tickets 2956 and 3954 for extended mode detection. */
  22. + gboolean extended = c == MCKEY_EXTENDED_MOUSE;
  23. +
  24. +#ifdef KEY_MOUSE
  25. + extended = extended || (c == KEY_MOUSE && xmouse_seq == NULL
  26. + && xmouse_extended_seq != NULL);
  27. +#endif /* KEY_MOUSE */
  28. +
  29. + xmouse_get_event (event, extended);
  30. c = (event->type != 0) ? EV_MOUSE : EV_NONE;
  31. }
  32. else if (c == MCKEY_BRACKETED_PASTING_START)
  33. diff --git a/lib/tty/mouse.c b/lib/tty/mouse.c
  34. index 0f830ce08a..1bba0cc587 100644
  35. --- a/lib/tty/mouse.c
  36. +++ b/lib/tty/mouse.c
  37. @@ -90,8 +90,10 @@ init_mouse (void)
  38. case MOUSE_XTERM_NORMAL_TRACKING:
  39. case MOUSE_XTERM_BUTTON_EVENT_TRACKING:
  40. - define_sequence (MCKEY_MOUSE, xmouse_seq, MCKEY_NOACTION);
  41. - define_sequence (MCKEY_EXTENDED_MOUSE, xmouse_extended_seq, MCKEY_NOACTION);
  42. + if (xmouse_seq != NULL)
  43. + define_sequence (MCKEY_MOUSE, xmouse_seq, MCKEY_NOACTION);
  44. + if (xmouse_extended_seq != NULL)
  45. + define_sequence (MCKEY_EXTENDED_MOUSE, xmouse_extended_seq, MCKEY_NOACTION);
  46. break;
  47. default:
  48. diff --git a/lib/tty/tty.c b/lib/tty/tty.c
  49. index 1bca37c476..a232cd96e8 100644
  50. --- a/lib/tty/tty.c
  51. +++ b/lib/tty/tty.c
  52. @@ -361,9 +361,16 @@ tty_init_xterm_support (gboolean is_xterm)
  53. }
  54. }
  55. - /* No termcap for SGR extended mouse (yet), hardcode it for now */
  56. + /* There's only one termcap entry "kmous", typically containing "\E[M" or "\E[<".
  57. + * We need the former in xmouse_seq, the latter in xmouse_extended_seq.
  58. + * See tickets 2956 and 3954 for details. */
  59. if (xmouse_seq != NULL)
  60. + {
  61. + if (strcmp (xmouse_seq, ESC_STR "[<") == 0)
  62. + xmouse_seq = NULL;
  63. +
  64. xmouse_extended_seq = ESC_STR "[<";
  65. + }
  66. }
  67. /* --------------------------------------------------------------------------------------------- */