public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH 1/3] Refactor keypad calls to tui_set_win_focus_to
       [not found] <20210607163003.621-1-ssbssa.ref@yahoo.de>
@ 2021-06-07 16:30 ` Hannes Domani
  2021-06-07 16:30   ` [PATCH 2/3] Disable mouse events if the command window has focos Hannes Domani
                     ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Hannes Domani @ 2021-06-07 16:30 UTC (permalink / raw)
  To: gdb-patches

Previously it always was called after tui_set_win_focus_to, except it was
missing in tui_apply_current_layout.

gdb/ChangeLog:

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

	* tui/tui-data.c (tui_set_win_focus_to): Add keypad call.
	* tui/tui-win.c (tui_set_focus_command): Remove keypad call.
	* tui/tui.c (tui_rl_other_window): Likewise.
	(tui_enable): Likewise.
---
 gdb/tui/tui-data.c | 5 +++++
 gdb/tui/tui-win.c  | 1 -
 gdb/tui/tui.c      | 2 --
 3 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/gdb/tui/tui-data.c b/gdb/tui/tui-data.c
index 691459abe2a..89afdb429ba 100644
--- a/gdb/tui/tui-data.c
+++ b/gdb/tui/tui-data.c
@@ -22,6 +22,7 @@
 #include "defs.h"
 #include "symtab.h"
 #include "tui/tui.h"
+#include "tui/tui-command.h"
 #include "tui/tui-data.h"
 #include "tui/tui-win.h"
 #include "tui/tui-wingeneral.h"
@@ -69,6 +70,10 @@ tui_set_win_focus_to (struct tui_win_info *win_info)
       tui_unhighlight_win (win_with_focus);
       win_with_focus = win_info;
       tui_highlight_win (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);
     }
 }
 
diff --git a/gdb/tui/tui-win.c b/gdb/tui/tui-win.c
index 4e75a66a00e..094b503eae8 100644
--- a/gdb/tui/tui-win.c
+++ b/gdb/tui/tui-win.c
@@ -703,7 +703,6 @@ tui_set_focus_command (const char *arg, int from_tty)
     error (_("Window \"%s\" is not visible"), arg);
 
   tui_set_win_focus_to (win_info);
-  keypad (TUI_CMD_WIN->handle.get (), win_info != TUI_CMD_WIN);
   printf_filtered (_("Focus set to %s window.\n"),
 		   tui_win_with_focus ()->name ());
 }
diff --git a/gdb/tui/tui.c b/gdb/tui/tui.c
index 529fc62c9ac..394c357cebb 100644
--- a/gdb/tui/tui.c
+++ b/gdb/tui/tui.c
@@ -181,7 +181,6 @@ tui_rl_other_window (int count, int key)
   if (win_info)
     {
       tui_set_win_focus_to (win_info);
-      keypad (TUI_CMD_WIN->handle.get (), win_info != TUI_CMD_WIN);
     }
   return 0;
 }
@@ -439,7 +438,6 @@ tui_enable (void)
       tui_show_frame_info (0);
       tui_set_initial_layout ();
       tui_set_win_focus_to (TUI_SRC_WIN);
-      keypad (TUI_CMD_WIN->handle.get (), TRUE);
       wrefresh (TUI_CMD_WIN->handle.get ());
       tui_finish_init = false;
     }
-- 
2.31.1


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH 2/3] Disable mouse events if the command window has focos
  2021-06-07 16:30 ` [PATCH 1/3] Refactor keypad calls to tui_set_win_focus_to Hannes Domani
@ 2021-06-07 16:30   ` Hannes Domani
  2021-06-07 16:30   ` [PATCH 3/3] Add setting to enable/disable TUI mouse handling Hannes Domani
  2021-06-17 14:54   ` [PATCH 1/3] Refactor keypad calls to tui_set_win_focus_to Hannes Domani
  2 siblings, 0 replies; 5+ messages in thread
From: Hannes Domani @ 2021-06-07 16:30 UTC (permalink / raw)
  To: gdb-patches

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(-)

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
 }
 
-- 
2.31.1


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH 3/3] Add setting to enable/disable TUI mouse handling
  2021-06-07 16:30 ` [PATCH 1/3] Refactor keypad calls to tui_set_win_focus_to Hannes Domani
  2021-06-07 16:30   ` [PATCH 2/3] Disable mouse events if the command window has focos Hannes Domani
@ 2021-06-07 16:30   ` Hannes Domani
  2021-06-07 16:49     ` Eli Zaretskii
  2021-06-17 14:54   ` [PATCH 1/3] Refactor keypad calls to tui_set_win_focus_to Hannes Domani
  2 siblings, 1 reply; 5+ messages in thread
From: Hannes Domani @ 2021-06-07 16:30 UTC (permalink / raw)
  To: gdb-patches

Useful if the mouse events don't work correctly on a system, or the user just
doesn't need them.

gdb/ChangeLog:

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

	* tui/tui-data.c (tui_set_win_focus_to): Handle mouse setting.
	* tui/tui-io.c (tui_prep_terminal): Likewise.
	* tui/tui-win.c (tui_mouse): New global.
	(tui_set_mouse, tui_show_mouse_function): New functions.
	(_initialize_tui_win): Add mouse setting.
	* tui/tui-win.h (tui_mouse): Declare.

gdb/doc/ChangeLog:

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

	* gdb.texinfo (TUI Configuration): Document mouse setting.
---
 gdb/doc/gdb.texinfo |  4 ++++
 gdb/tui/tui-data.c  |  3 ++-
 gdb/tui/tui-io.c    |  2 +-
 gdb/tui/tui-win.c   | 36 ++++++++++++++++++++++++++++++++++++
 gdb/tui/tui-win.h   |  3 +++
 5 files changed, 46 insertions(+), 2 deletions(-)

diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo
index 90d827a50e7..76d6bc8d321 100644
--- a/gdb/doc/gdb.texinfo
+++ b/gdb/doc/gdb.texinfo
@@ -28909,6 +28909,10 @@ The default display uses more space for line numbers and starts the
 source text at the next tab stop; the compact display uses only as
 much space as is needed for the line numbers in the current file, and
 only a single space to separate the line numbers from the source.
+
+@item set tui mouse @r{[}on@r{|}off@r{]}
+@kindex set tui mouse
+Set whether the TUI handles mouse events.
 @end table
 
 Note that the colors of the TUI borders can be controlled using the
diff --git a/gdb/tui/tui-data.c b/gdb/tui/tui-data.c
index e6452386628..43538766857 100644
--- a/gdb/tui/tui-data.c
+++ b/gdb/tui/tui-data.c
@@ -78,7 +78,8 @@ tui_set_win_focus_to (struct tui_win_info *win_info)
 #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);
+      mousemask ((tui_mouse && 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 4570e55231b..075b4fa58c8 100644
--- a/gdb/tui/tui-io.c
+++ b/gdb/tui/tui-io.c
@@ -640,7 +640,7 @@ static void
 tui_prep_terminal (int notused1)
 {
 #ifdef NCURSES_MOUSE_VERSION
-  if (tui_win_with_focus () != TUI_CMD_WIN)
+  if (tui_mouse && tui_win_with_focus () != TUI_CMD_WIN)
     mousemask (ALL_MOUSE_EVENTS, NULL);
 #endif
 }
diff --git a/gdb/tui/tui-win.c b/gdb/tui/tui-win.c
index 094b503eae8..2211f987fc4 100644
--- a/gdb/tui/tui-win.c
+++ b/gdb/tui/tui-win.c
@@ -822,6 +822,34 @@ tui_show_compact_source (struct ui_file *file, int from_tty,
   printf_filtered (_("TUI source window compactness is %s.\n"), value);
 }
 
+/* See tui-win.h.  */
+
+bool tui_mouse = false;
+
+/* Callback for "set tui mouse".  */
+
+static void
+tui_set_mouse (const char *ignore, int from_tty,
+	       struct cmd_list_element *c)
+{
+#ifndef NCURSES_MOUSE_VERSION
+  if (tui_mouse)
+    {
+      tui_mouse = false;
+      error (_("The curses library does not provide mouse events."));
+    }
+#endif
+}
+
+/* Callback for "show tui mouse".  */
+
+static void
+tui_show_mouse_function (struct ui_file *file, int from_tty,
+			 struct cmd_list_element *c, const char *value)
+{
+  printf_filtered (_("Handling of mouse events in TUI is %s.\n"), value);
+}
+
 /* Set the tab width of the specified window.  */
 static void
 tui_set_tab_width_command (const char *arg, int from_tty)
@@ -1119,6 +1147,14 @@ the line numbers and uses less horizontal space."),
 			   tui_set_compact_source, tui_show_compact_source,
 			   &tui_setlist, &tui_showlist);
 
+  add_setshow_boolean_cmd ("mouse", class_tui,
+			   &tui_mouse, _("\
+Set whether the TUI handles mouse events."), _("\
+Show whether the TUI handles mouse events."),
+			   nullptr,
+			   tui_set_mouse, tui_show_mouse_function,
+			   &tui_setlist, &tui_showlist);
+
   tui_border_style.changed.attach (tui_rehighlight_all, "tui-win");
   tui_active_border_style.changed.attach (tui_rehighlight_all, "tui-win");
 }
diff --git a/gdb/tui/tui-win.h b/gdb/tui/tui-win.h
index e9da9b98477..f771ec87400 100644
--- a/gdb/tui/tui-win.h
+++ b/gdb/tui/tui-win.h
@@ -51,4 +51,7 @@ struct cmd_list_element **tui_get_cmd_list (void);
 /* Whether compact source display should be used.  */
 extern bool compact_source;
 
+/* Whether the TUI handles mouse events.  */
+extern bool tui_mouse;
+
 #endif /* TUI_TUI_WIN_H */
-- 
2.31.1


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH 3/3] Add setting to enable/disable TUI mouse handling
  2021-06-07 16:30   ` [PATCH 3/3] Add setting to enable/disable TUI mouse handling Hannes Domani
@ 2021-06-07 16:49     ` Eli Zaretskii
  0 siblings, 0 replies; 5+ messages in thread
From: Eli Zaretskii @ 2021-06-07 16:49 UTC (permalink / raw)
  To: Hannes Domani; +Cc: gdb-patches

> Date: Mon,  7 Jun 2021 18:30:03 +0200
> From: Hannes Domani via Gdb-patches <gdb-patches@sourceware.org>
> 
> Useful if the mouse events don't work correctly on a system, or the user just
> doesn't need them.
> 
> gdb/ChangeLog:
> 
> 2021-06-07  Hannes Domani  <ssbssa@yahoo.de>
> 
> 	* tui/tui-data.c (tui_set_win_focus_to): Handle mouse setting.
> 	* tui/tui-io.c (tui_prep_terminal): Likewise.
> 	* tui/tui-win.c (tui_mouse): New global.
> 	(tui_set_mouse, tui_show_mouse_function): New functions.
> 	(_initialize_tui_win): Add mouse setting.
> 	* tui/tui-win.h (tui_mouse): Declare.
> 
> gdb/doc/ChangeLog:
> 
> 2021-06-07  Hannes Domani  <ssbssa@yahoo.de>
> 
> 	* gdb.texinfo (TUI Configuration): Document mouse setting.

OK for the documentation part.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH 1/3] Refactor keypad calls to tui_set_win_focus_to
  2021-06-07 16:30 ` [PATCH 1/3] Refactor keypad calls to tui_set_win_focus_to Hannes Domani
  2021-06-07 16:30   ` [PATCH 2/3] Disable mouse events if the command window has focos Hannes Domani
  2021-06-07 16:30   ` [PATCH 3/3] Add setting to enable/disable TUI mouse handling Hannes Domani
@ 2021-06-17 14:54   ` Hannes Domani
  2 siblings, 0 replies; 5+ messages in thread
From: Hannes Domani @ 2021-06-17 14:54 UTC (permalink / raw)
  To: gdb-patches

 This series is no longer useful, Pedro fixed the mouse problems in a much
better way.


Hannes


Am Montag, 7. Juni 2021, 18:30:55 MESZ hat Hannes Domani via Gdb-patches <gdb-patches@sourceware.org> Folgendes geschrieben:

> Previously it always was called after tui_set_win_focus_to, except it was
> missing in tui_apply_current_layout.
>
> gdb/ChangeLog:
>
> 2021-06-07  Hannes Domani  <ssbssa@yahoo.de>
>
>     * tui/tui-data.c (tui_set_win_focus_to): Add keypad call.
>     * tui/tui-win.c (tui_set_focus_command): Remove keypad call.
>     * tui/tui.c (tui_rl_other_window): Likewise.
>     (tui_enable): Likewise.
> ---
> gdb/tui/tui-data.c | 5 +++++
> gdb/tui/tui-win.c  | 1 -
> gdb/tui/tui.c      | 2 --
> 3 files changed, 5 insertions(+), 3 deletions(-)
>
> diff --git a/gdb/tui/tui-data.c b/gdb/tui/tui-data.c
> index 691459abe2a..89afdb429ba 100644
> --- a/gdb/tui/tui-data.c
> +++ b/gdb/tui/tui-data.c
> @@ -22,6 +22,7 @@
> #include "defs.h"
> #include "symtab.h"
> #include "tui/tui.h"
> +#include "tui/tui-command.h"
> #include "tui/tui-data.h"
> #include "tui/tui-win.h"
> #include "tui/tui-wingeneral.h"
> @@ -69,6 +70,10 @@ tui_set_win_focus_to (struct tui_win_info *win_info)
>       tui_unhighlight_win (win_with_focus);
>       win_with_focus = win_info;
>       tui_highlight_win (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);
>     }
> }
>
> diff --git a/gdb/tui/tui-win.c b/gdb/tui/tui-win.c
> index 4e75a66a00e..094b503eae8 100644
> --- a/gdb/tui/tui-win.c
> +++ b/gdb/tui/tui-win.c
> @@ -703,7 +703,6 @@ tui_set_focus_command (const char *arg, int from_tty)
>     error (_("Window \"%s\" is not visible"), arg);
>
>   tui_set_win_focus_to (win_info);
> -  keypad (TUI_CMD_WIN->handle.get (), win_info != TUI_CMD_WIN);
>   printf_filtered (_("Focus set to %s window.\n"),
>           tui_win_with_focus ()->name ());
> }
> diff --git a/gdb/tui/tui.c b/gdb/tui/tui.c
> index 529fc62c9ac..394c357cebb 100644
> --- a/gdb/tui/tui.c
> +++ b/gdb/tui/tui.c
> @@ -181,7 +181,6 @@ tui_rl_other_window (int count, int key)
>   if (win_info)
>     {
>       tui_set_win_focus_to (win_info);
> -      keypad (TUI_CMD_WIN->handle.get (), win_info != TUI_CMD_WIN);
>     }
>   return 0;
> }
> @@ -439,7 +438,6 @@ tui_enable (void)
>       tui_show_frame_info (0);
>       tui_set_initial_layout ();
>       tui_set_win_focus_to (TUI_SRC_WIN);
> -      keypad (TUI_CMD_WIN->handle.get (), TRUE);
>       wrefresh (TUI_CMD_WIN->handle.get ());
>       tui_finish_init = false;
>     }
> --
> 2.31.1

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2021-06-17 14:54 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <20210607163003.621-1-ssbssa.ref@yahoo.de>
2021-06-07 16:30 ` [PATCH 1/3] Refactor keypad calls to tui_set_win_focus_to Hannes Domani
2021-06-07 16:30   ` [PATCH 2/3] Disable mouse events if the command window has focos Hannes Domani
2021-06-07 16:30   ` [PATCH 3/3] Add setting to enable/disable TUI mouse handling Hannes Domani
2021-06-07 16:49     ` Eli Zaretskii
2021-06-17 14:54   ` [PATCH 1/3] Refactor keypad calls to tui_set_win_focus_to Hannes Domani

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).