From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id MD+KKQTlbF8YBgAAWB0awg (envelope-from ) for ; Thu, 24 Sep 2020 14:27:16 -0400 Received: by simark.ca (Postfix, from userid 112) id A2C201EE05; Thu, 24 Sep 2020 14:27:16 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-1.0 required=5.0 tests=MAILING_LIST_MULTI, URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.2 Received: from sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id 2FB9A1E8D0 for ; Thu, 24 Sep 2020 14:27:16 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 79987386F47E; Thu, 24 Sep 2020 18:27:15 +0000 (GMT) Received: from rock.gnat.com (rock.gnat.com [205.232.38.15]) by sourceware.org (Postfix) with ESMTP id 45DD1386F47E for ; Thu, 24 Sep 2020 18:27:13 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 45DD1386F47E Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=adacore.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=tromey@adacore.com Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id 19E7111756F; Thu, 24 Sep 2020 14:27:13 -0400 (EDT) X-Virus-Scanned: Debian amavisd-new at gnat.com Received: from rock.gnat.com ([127.0.0.1]) by localhost (rock.gnat.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id julg1jwkscPO; Thu, 24 Sep 2020 14:27:13 -0400 (EDT) Received: from murgatroyd (75-166-120-119.hlrn.qwest.net [75.166.120.119]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by rock.gnat.com (Postfix) with ESMTPSA id B198011756E; Thu, 24 Sep 2020 14:27:12 -0400 (EDT) From: Tom Tromey To: Simon Marchi Subject: Re: [PATCH] Don't let TUI focus on locator References: <20200923185921.1006372-1-tromey@adacore.com> <1b3329ea-97c0-c379-d343-e891a337244b@simark.ca> <877dskp917.fsf@tromey.com> X-Attribution: Tom Date: Thu, 24 Sep 2020 12:27:12 -0600 In-Reply-To: (Simon Marchi's message of "Wed, 23 Sep 2020 15:57:18 -0400") Message-ID: <873637owsf.fsf@tromey.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: gdb-patches@sourceware.org, Tom Tromey Errors-To: gdb-patches-bounces@sourceware.org Sender: "Gdb-patches" >> Let me know what you think of this. Simon> That looks good to me, thanks! Simon> I've never looked at the TUI tests but... how hard would it be to write Simon> a test for this? I skipped it since I thought it would be hard, but I forgot that "focus" tells us what it is doing, and so it turned out to be super easy :} Tom commit b551a89f51504735e9979ac885a5784e21cfecef Author: Tom Tromey Date: Wed Sep 23 12:57:19 2020 -0600 Don't let TUI focus on locator PR tui/26638 notes that the C-x o binding can put the focus on the locator window. However, this is not useful and did not happen historically. This patch changes the TUI to skip this window when switching focus. gdb/ChangeLog 2020-09-24 Tom Tromey PR tui/26638: * tui/tui-stack.h (struct tui_locator_window) : New method. * tui/tui-data.h (struct tui_win_info) : New method. * tui/tui-data.c (tui_next_win): Exclude non-focusable windows. (tui_prev_win): Rewrite. gdb/testsuite/ChangeLog 2020-09-24 Tom Tromey PR tui/26638: * gdb.tui/list.exp: Check output of "focus next". diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 3b851dba41e..3872a8d9cbe 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,12 @@ +2020-09-24 Tom Tromey + + PR tui/26638: + * tui/tui-stack.h (struct tui_locator_window) : New + method. + * tui/tui-data.h (struct tui_win_info) : New method. + * tui/tui-data.c (tui_next_win): Exclude non-focusable windows. + (tui_prev_win): Rewrite. + 2020-09-23 Hannes Domani * nat/windows-nat.c (handle_exception): Handle 64bit breakpoints diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog index c85f3ed9427..41849756f97 100644 --- a/gdb/testsuite/ChangeLog +++ b/gdb/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2020-09-24 Tom Tromey + + PR tui/26638: + * gdb.tui/list.exp: Check output of "focus next". + 2020-09-23 Tom Tromey * gdb.dwarf2/intbits.exp: New file. diff --git a/gdb/testsuite/gdb.tui/list.exp b/gdb/testsuite/gdb.tui/list.exp index 77dbd69efd8..576b33fa869 100644 --- a/gdb/testsuite/gdb.tui/list.exp +++ b/gdb/testsuite/gdb.tui/list.exp @@ -39,3 +39,4 @@ Term::check_contents "list main" "21 *return 0" # The following 'focus next' must be immediately after 'list main' to # ensure that GDB has a valid idea of what is currently focused. Term::command "focus next" +Term::check_contents "focus next" "Focus set to cmd window" diff --git a/gdb/tui/tui-data.c b/gdb/tui/tui-data.c index 8f7d257e945..d475d031065 100644 --- a/gdb/tui/tui-data.c +++ b/gdb/tui/tui-data.c @@ -113,9 +113,18 @@ tui_next_win (struct tui_win_info *cur_win) auto iter = std::find (tui_windows.begin (), tui_windows.end (), cur_win); gdb_assert (iter != tui_windows.end ()); - ++iter; - if (iter == tui_windows.end ()) - return tui_windows[0]; + gdb_assert (cur_win->can_focus ()); + /* This won't loop forever since we can't have just an un-focusable + window. */ + while (true) + { + ++iter; + if (iter == tui_windows.end ()) + iter = tui_windows.begin (); + if ((*iter)->can_focus ()) + break; + } + return *iter; } @@ -125,12 +134,21 @@ tui_next_win (struct tui_win_info *cur_win) struct tui_win_info * tui_prev_win (struct tui_win_info *cur_win) { - auto iter = std::find (tui_windows.begin (), tui_windows.end (), cur_win); - gdb_assert (iter != tui_windows.end ()); + auto iter = std::find (tui_windows.rbegin (), tui_windows.rend (), cur_win); + gdb_assert (iter != tui_windows.rend ()); + + gdb_assert (cur_win->can_focus ()); + /* This won't loop forever since we can't have just an un-focusable + window. */ + while (true) + { + ++iter; + if (iter == tui_windows.rend ()) + iter = tui_windows.rbegin (); + if ((*iter)->can_focus ()) + break; + } - if (iter == tui_windows.begin ()) - return tui_windows.back (); - --iter; return *iter; } diff --git a/gdb/tui/tui-data.h b/gdb/tui/tui-data.h index 5e7a12293c9..d61bfc7dff8 100644 --- a/gdb/tui/tui-data.h +++ b/gdb/tui/tui-data.h @@ -99,6 +99,12 @@ struct tui_win_info return handle != nullptr; } + /* Return true if this window can accept the focus. */ + virtual bool can_focus () const + { + return true; + } + /* Disable output until the next call to doupdate. */ void no_refresh () { diff --git a/gdb/tui/tui-stack.h b/gdb/tui/tui-stack.h index 9ff57b1ba73..0e5916f0ce3 100644 --- a/gdb/tui/tui-stack.h +++ b/gdb/tui/tui-stack.h @@ -52,6 +52,11 @@ struct tui_locator_window : public tui_win_info return false; } + bool can_focus () const override + { + return false; + } + void rerender () override; /* Update the locator, with the provided arguments.