From patchwork Sat Aug 3 13:29:15 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 33936 Received: (qmail 95410 invoked by alias); 3 Aug 2019 13:29:36 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 95148 invoked by uid 89); 3 Aug 2019 13:29:34 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-19.1 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_HELO_PASS autolearn=ham version=3.3.1 spammy= X-HELO: gateway34.websitewelcome.com Received: from gateway34.websitewelcome.com (HELO gateway34.websitewelcome.com) (192.185.148.231) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sat, 03 Aug 2019 13:29:32 +0000 Received: from cm10.websitewelcome.com (cm10.websitewelcome.com [100.42.49.4]) by gateway34.websitewelcome.com (Postfix) with ESMTP id 9ED8C16E01 for ; Sat, 3 Aug 2019 08:29:31 -0500 (CDT) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with SMTP id tu6Fh5rz32PzOtu6FhATht; Sat, 03 Aug 2019 08:29:31 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tromey.com; s=default; h=References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From: Sender:Reply-To:MIME-Version:Content-Type:Content-Transfer-Encoding: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=wQwh68rJbqixBtP5bLwjMbGkO/nR7R1ppzdLt41UZ8s=; b=oFt9IkkRF6YJTbvuDUYGDM+OWR yWnK7iV0k1wP51IFpEt4Brmin1Qz40x0NCQM+ApCwm0vSqKJcrYVz75kInQxsFjF4vvIJ/OyLGRVM yrO/Mb4H4d9O5JtnA0IFjClvA; Received: from 97-122-178-82.hlrn.qwest.net ([97.122.178.82]:36980 helo=bapiya.Home) by box5379.bluehost.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.92) (envelope-from ) id 1htu6F-003nqS-E1; Sat, 03 Aug 2019 08:29:31 -0500 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [PATCH 09/19] Delete invisible TUI windows Date: Sat, 3 Aug 2019 07:29:15 -0600 Message-Id: <20190803132925.25074-10-tom@tromey.com> In-Reply-To: <20190803132925.25074-1-tom@tromey.com> References: <20190803132925.25074-1-tom@tromey.com> This changes the TUI so that when the layout changes, any windows that are invisible are now deleted. This makes it simpler to understand window lifetimes. gdb/ChangeLog 2019-08-03 Tom Tromey * tui/tui-win.c (tui_resize_all): Call tui_delete_invisible_windows. * tui/tui-layout.c (show_layout): Call tui_delete_invisible_windows. * tui/tui-data.h (tui_delete_invisible_windows): Declare. * tui/tui-data.c (tui_delete_invisible_windows): New function. --- gdb/ChangeLog | 9 +++++++++ gdb/tui/tui-data.c | 22 ++++++++++++++++++++++ gdb/tui/tui-data.h | 5 +++++ gdb/tui/tui-layout.c | 3 +++ gdb/tui/tui-win.c | 15 ++------------- 5 files changed, 41 insertions(+), 13 deletions(-) diff --git a/gdb/tui/tui-data.c b/gdb/tui/tui-data.c index fd7649bdeab..bb725c199cc 100644 --- a/gdb/tui/tui-data.c +++ b/gdb/tui/tui-data.c @@ -269,6 +269,28 @@ tui_initialize_static_data () win->title = 0; } +/* 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 dbae2fb3b00..d3fa03657c5 100644 --- a/gdb/tui/tui-data.h +++ b/gdb/tui/tui-data.h @@ -399,6 +399,11 @@ extern void tui_set_win_resized_to (int); 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 f4f834dc83e..2715d322dc7 100644 --- a/gdb/tui/tui-layout.c +++ b/gdb/tui/tui-layout.c @@ -107,6 +107,8 @@ show_layout (enum tui_layout_type layout) default: break; } + + tui_delete_invisible_windows (); } } @@ -596,6 +598,7 @@ show_data (enum tui_layout_type new_layout) locator->make_visible (true); tui_show_locator_content (); tui_add_to_source_windows (base); + TUI_CMD_WIN->make_visible (true); current_layout = new_layout; } diff --git a/gdb/tui/tui-win.c b/gdb/tui/tui-win.c index 785c623b7e2..0e64db3e7a1 100644 --- a/gdb/tui/tui-win.c +++ b/gdb/tui/tui-win.c @@ -537,7 +537,6 @@ tui_resize_all (void) struct tui_win_info *second_win; tui_source_window_base *src_win; struct tui_locator_window *locator = tui_locator_win_info_ptr (); - int win_type; int new_height, split_diff, cmd_split_diff, num_wins_displayed = 2; #ifdef HAVE_RESIZE_TERM @@ -663,18 +662,8 @@ tui_resize_all (void) tui_erase_source_content (src_win); break; } - /* Now remove all invisible windows, and their content so that - they get created again when called for with the new size. */ - for (win_type = SRC_WIN; (win_type < MAX_MAJOR_WINDOWS); win_type++) - { - if (win_type != CMD_WIN - && (tui_win_list[win_type] != NULL) - && !tui_win_list[win_type]->is_visible) - { - delete tui_win_list[win_type]; - tui_win_list[win_type] = NULL; - } - } + + tui_delete_invisible_windows (); /* Turn keypad back on, unless focus is in the command window. */ if (win_with_focus != TUI_CMD_WIN)