[2/3] Disable mouse events if the command window has focos

Message ID 20210607163003.621-2-ssbssa@yahoo.de
State New
Headers show
Series
  • [1/3] Refactor keypad calls to tui_set_win_focus_to
Related show

Commit Message

Mike Frysinger via Gdb-patches June 7, 2021, 4:30 p.m.
This is necessary because if the command window has focus, the keypad is
disabled, and without the keypad the mouse escape sequences are not handled
by curses, and instead seen by gdb as console input.

gdb/ChangeLog:

2021-06-07  Hannes Domani  <ssbssa@yahoo.de>

	* tui/tui-data.c (tui_set_win_focus_to): Add mousemask call.
	* tui/tui-io.c (tui_prep_terminal): Only call mousemask if
	command window doesn't have focus.
---
 gdb/tui/tui-data.c | 6 ++++++
 gdb/tui/tui-io.c   | 3 ++-
 2 files changed, 8 insertions(+), 1 deletion(-)

-- 
2.31.1

Patch

diff --git a/gdb/tui/tui-data.c b/gdb/tui/tui-data.c
index 89afdb429ba..e6452386628 100644
--- a/gdb/tui/tui-data.c
+++ b/gdb/tui/tui-data.c
@@ -74,6 +74,12 @@  tui_set_win_focus_to (struct tui_win_info *win_info)
       /* Enable the keypad if any window except the command window has
 	 the focus.  */
       keypad (TUI_CMD_WIN->handle.get (), win_info != TUI_CMD_WIN);
+
+#ifdef NCURSES_MOUSE_VERSION
+      /* The mouse events only work with enabled keypad, so enable them
+	 accordingly.  */
+      mousemask (win_info != TUI_CMD_WIN ? ALL_MOUSE_EVENTS : 0, NULL);
+#endif
     }
 }
 
diff --git a/gdb/tui/tui-io.c b/gdb/tui/tui-io.c
index 7df0e2f1bd3..4570e55231b 100644
--- a/gdb/tui/tui-io.c
+++ b/gdb/tui/tui-io.c
@@ -640,7 +640,8 @@  static void
 tui_prep_terminal (int notused1)
 {
 #ifdef NCURSES_MOUSE_VERSION
-  mousemask (ALL_MOUSE_EVENTS, NULL);
+  if (tui_win_with_focus () != TUI_CMD_WIN)
+    mousemask (ALL_MOUSE_EVENTS, NULL);
 #endif
 }