Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Tom Tromey <tom@tromey.com>
To: gdb-patches@sourceware.org
Cc: Tom Tromey <tom@tromey.com>
Subject: [PATCH 15/24] Remove tui_delete_invisible_windows and tui_make_all_invisible
Date: Sat, 04 Jan 2020 18:34:00 -0000	[thread overview]
Message-ID: <20200104183410.17114-16-tom@tromey.com> (raw)
In-Reply-To: <20200104183410.17114-1-tom@tromey.com>

tui_delete_invisible_windows is only needed after applying a layout,
and tui_make_all_invisible is only needed before applying a layout.

This patch removes these functions, in favor of doing this management
directly in tui_apply_current_layout.  This is needed so that the
lifetimes of non-built-in windows will be properly managed.

2020-01-04  Tom Tromey  <tom@tromey.com>

	* tui/tui-wingeneral.h (tui_make_all_invisible): Don't declare.
	* tui/tui-wingeneral.c (tui_make_all_invisible): Remove.
	* tui/tui-win.c (tui_resize_all): Don't call
	tui_delete_invisible_windows.
	* tui/tui-layout.c (tui_apply_current_layout): Delete windows when
	done.
	(tui_set_layout): Update.
	(tui_add_win_to_layout): Don't call tui_delete_invisible_windows.
	* tui/tui-data.h (tui_delete_invisible_windows): Don't declare.
	* tui/tui-data.c (tui_delete_invisible_windows): Remove.

Change-Id: Ia3603b021dcb7ec31700a4a32640cd09b00b8f3b
---
 gdb/ChangeLog            | 13 ++++++++++++
 gdb/tui/tui-data.c       | 23 --------------------
 gdb/tui/tui-data.h       |  5 -----
 gdb/tui/tui-layout.c     | 46 ++++++++++++++++++++++++++++++----------
 gdb/tui/tui-win.c        |  1 -
 gdb/tui/tui-wingeneral.c |  9 --------
 gdb/tui/tui-wingeneral.h |  3 ---
 7 files changed, 48 insertions(+), 52 deletions(-)

diff --git a/gdb/tui/tui-data.c b/gdb/tui/tui-data.c
index 5d42fafccca..ead8b1043ca 100644
--- a/gdb/tui/tui-data.c
+++ b/gdb/tui/tui-data.c
@@ -129,29 +129,6 @@ tui_prev_win (struct tui_win_info *cur_win)
 }
 
 
-/* See tui-data.h.  */
-
-void
-tui_delete_invisible_windows ()
-{
-  for (int win_type = SRC_WIN; (win_type < MAX_MAJOR_WINDOWS); win_type++)
-    {
-      if (tui_win_list[win_type] != NULL
-	  && !tui_win_list[win_type]->is_visible ())
-	{
-	  /* This should always be made visible before a call to this
-	     function.  */
-	  gdb_assert (win_type != CMD_WIN);
-
-	  if (win_with_focus == tui_win_list[win_type])
-	    win_with_focus = nullptr;
-
-	  delete tui_win_list[win_type];
-	  tui_win_list[win_type] = NULL;
-	}
-    }
-}
-
 tui_win_info::tui_win_info (enum tui_win_type type)
   : tui_gen_win_info (type)
 {
diff --git a/gdb/tui/tui-data.h b/gdb/tui/tui-data.h
index a5e4940666c..96265bb4215 100644
--- a/gdb/tui/tui-data.h
+++ b/gdb/tui/tui-data.h
@@ -256,11 +256,6 @@ extern void tui_set_win_resized_to (bool);
 extern struct tui_win_info *tui_next_win (struct tui_win_info *);
 extern struct tui_win_info *tui_prev_win (struct tui_win_info *);
 
-/* Delete all the invisible windows.  Note that it is an error to call
-   this when the command window is invisible -- we don't allow the
-   command window to be removed from the layout.  */
-extern void tui_delete_invisible_windows ();
-
 extern unsigned int tui_tab_width;
 
 #endif /* TUI_TUI_DATA_H */
diff --git a/gdb/tui/tui-layout.c b/gdb/tui/tui-layout.c
index 9ad91ce713b..898d2f0b8d2 100644
--- a/gdb/tui/tui-layout.c
+++ b/gdb/tui/tui-layout.c
@@ -69,8 +69,43 @@ std::vector<tui_win_info *> tui_windows;
 void
 tui_apply_current_layout ()
 {
+  struct gdbarch *gdbarch;
+  CORE_ADDR addr;
+
+  extract_display_start_addr (&gdbarch, &addr);
+
+  std::vector<tui_win_info *> saved_windows = std::move (tui_windows);
   tui_windows.clear ();
+
+  for (tui_win_info *win_info : saved_windows)
+    win_info->make_visible (false);
+
   applied_layout->apply (0, 0, tui_term_width (), tui_term_height ());
+
+  /* Keep the list of internal windows up-to-date.  */
+  for (int win_type = SRC_WIN; (win_type < MAX_MAJOR_WINDOWS); win_type++)
+    if (tui_win_list[win_type] != nullptr
+	&& !tui_win_list[win_type]->is_visible ())
+      tui_win_list[win_type] = nullptr;
+
+  /* This should always be made visible by a layout.  */
+  gdb_assert (TUI_CMD_WIN->is_visible ());
+
+  /* Now delete any window that was not re-applied.  */
+  tui_win_info *focus = tui_win_with_focus ();
+  for (tui_win_info *win_info : saved_windows)
+    {
+      if (!win_info->is_visible ())
+	{
+	  if (focus == win_info)
+	    tui_set_win_focus_to (tui_windows[0]);
+	  delete win_info;
+	}
+    }
+
+  if (gdbarch == nullptr && TUI_DISASM_WIN != nullptr)
+    tui_get_begin_asm_address (&gdbarch, &addr);
+  tui_update_source_windows_with_addr (gdbarch, addr);
 }
 
 /* See tui-layout.  */
@@ -86,19 +121,9 @@ tui_adjust_window_height (struct tui_win_info *win, int new_height)
 static void
 tui_set_layout (tui_layout_split *layout)
 {
-  struct gdbarch *gdbarch;
-  CORE_ADDR addr;
-
-  extract_display_start_addr (&gdbarch, &addr);
-  tui_make_all_invisible ();
   applied_skeleton = layout;
   applied_layout = layout->clone ();
   tui_apply_current_layout ();
-  tui_delete_invisible_windows ();
-
-  if (gdbarch == nullptr && TUI_DISASM_WIN != nullptr)
-    tui_get_begin_asm_address (&gdbarch, &addr);
-  tui_update_source_windows_with_addr (gdbarch, addr);
 }
 
 /* See tui-layout.h.  */
@@ -121,7 +146,6 @@ tui_add_win_to_layout (enum tui_win_type type)
   const char *name = type == SRC_WIN ? SRC_NAME : DISASSEM_NAME;
   applied_layout->replace_window (tui_win_list[other]->name (), name);
   tui_apply_current_layout ();
-  tui_delete_invisible_windows ();
 }
 
 /* Find LAYOUT in the "layouts" global and return its index.  */
diff --git a/gdb/tui/tui-win.c b/gdb/tui/tui-win.c
index 6eab125d731..f8a57732cca 100644
--- a/gdb/tui/tui-win.c
+++ b/gdb/tui/tui-win.c
@@ -550,7 +550,6 @@ tui_resize_all (void)
       erase ();
       clearok (curscr, TRUE);
       tui_apply_current_layout ();
-      tui_delete_invisible_windows ();
       /* Turn keypad back on, unless focus is in the command
 	 window.  */
       if (win_with_focus != TUI_CMD_WIN)
diff --git a/gdb/tui/tui-wingeneral.c b/gdb/tui/tui-wingeneral.c
index dae4255ada2..9c571204e2a 100644
--- a/gdb/tui/tui-wingeneral.c
+++ b/gdb/tui/tui-wingeneral.c
@@ -159,15 +159,6 @@ tui_gen_win_info::make_visible (bool visible)
     handle.reset (nullptr);
 }
 
-/* See tui-wingeneral.h.  */
-
-void
-tui_make_all_invisible (void)
-{
-  for (tui_win_info *win_info : all_tui_windows ())
-    win_info->make_visible (false);
-}
-
 /* Function to refresh all the windows currently displayed.  */
 
 void
diff --git a/gdb/tui/tui-wingeneral.h b/gdb/tui/tui-wingeneral.h
index e32dbed2995..797a8a927e8 100644
--- a/gdb/tui/tui-wingeneral.h
+++ b/gdb/tui/tui-wingeneral.h
@@ -26,9 +26,6 @@
 
 struct tui_win_info;
 
-/* Makes all windows invisible.  */
-extern void tui_make_all_invisible (void);
-
 extern void tui_unhighlight_win (struct tui_win_info *);
 extern void tui_highlight_win (struct tui_win_info *);
 extern void tui_refresh_all ();
-- 
2.17.2


  parent reply	other threads:[~2020-01-04 18:34 UTC|newest]

Thread overview: 36+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-01-04 18:34 [PATCH 00/24] Horizontal TUI layout + windows in Python Tom Tromey
2020-01-04 18:34 ` [PATCH 23/24] Add "usage" text to all TUI command help Tom Tromey
2020-01-04 18:34 ` [PATCH 14/24] Handle ambiguity in tui_partial_win_by_name Tom Tromey
2020-01-04 18:34 ` [PATCH 08/24] Add the "tui new-layout" command Tom Tromey
2020-01-04 18:44   ` Eli Zaretskii
2020-01-04 18:34 ` [PATCH 22/24] Use error_no_arg in TUI Tom Tromey
2020-01-04 18:34 ` [PATCH 24/24] Fix cast in TUI_DISASM_WIN Tom Tromey
2020-01-04 18:34 ` [PATCH 18/24] Remove tui_set_win_focus_to Tom Tromey
2020-01-04 18:34 ` [PATCH 05/24] Reimplement TUI "C-x 1" binding Tom Tromey
2020-01-04 18:34 ` [PATCH 13/24] Reimplement tui_next_win and tui_prev_win Tom Tromey
2020-01-04 18:34 ` [PATCH 16/24] TUI windows do not need to store their type Tom Tromey
2020-01-04 18:34 ` [PATCH 03/24] Fix latent display bug in tui_data_window Tom Tromey
2020-01-04 18:34 ` [PATCH 20/24] Allow TUI windows in Python Tom Tromey
2020-01-04 18:57   ` Eli Zaretskii
2020-02-22 19:57     ` Tom Tromey
2020-02-22 20:18       ` Eli Zaretskii
2020-03-10 22:23   ` Simon Marchi
2020-03-11  0:23     ` Tom Tromey
2020-03-11  4:47       ` Simon Marchi
2020-03-11  5:07         ` Simon Marchi
2020-03-11 18:05         ` Tom Tromey
2020-01-04 18:34 ` [PATCH 04/24] Simplify TUI C-x 2 binding Tom Tromey
2020-01-04 18:34 ` [PATCH 10/24] Change return type of tui_layout_base::adjust_size Tom Tromey
2020-01-04 18:34 ` [PATCH 06/24] Reimplement "tui reg" command Tom Tromey
2020-01-04 18:34 ` [PATCH 11/24] Add horizontal splitting to TUI layout Tom Tromey
2020-01-04 18:47   ` Eli Zaretskii
2020-01-04 18:34 ` [PATCH 12/24] Change TUI window iteration Tom Tromey
2020-01-04 18:34 ` Tom Tromey [this message]
2020-01-04 18:34 ` [PATCH 19/24] Remove the TUI annotation hack Tom Tromey
2020-01-04 18:34 ` [PATCH 02/24] Simplify tui_add_win_to_layout Tom Tromey
2020-01-04 18:34 ` [PATCH 09/24] Allow TUI sub-layouts in "new-layout" command Tom Tromey
2020-01-04 18:34 ` [PATCH 07/24] Remove hard-coded TUI layouts Tom Tromey
2020-01-04 18:34 ` [PATCH 01/24] Use TUI_DISASM_WIN instead of tui_win_list array Tom Tromey
2020-01-04 18:34 ` [PATCH 21/24] Make some tui_source_window_base members "protected" Tom Tromey
2020-01-04 18:54 ` [PATCH 17/24] Change how TUI windows are instantiated Tom Tromey
2020-02-22 20:22 ` [PATCH 00/24] Horizontal TUI layout + windows in Python Tom Tromey

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200104183410.17114-16-tom@tromey.com \
    --to=tom@tromey.com \
    --cc=gdb-patches@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox