From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 121537 invoked by alias); 27 Apr 2015 16:35:08 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 121440 invoked by uid 89); 27 Apr 2015 16:35:07 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=AWL,BAYES_00,SPF_HELO_PASS,SPF_PASS,T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Mon, 27 Apr 2015 16:35:06 +0000 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id t3RGZ29T028523 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Mon, 27 Apr 2015 12:35:02 -0400 Received: from [127.0.0.1] (ovpn01.gateway.prod.ext.ams2.redhat.com [10.39.146.11]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t3RGZ1pJ014752; Mon, 27 Apr 2015 12:35:01 -0400 Message-ID: <553E6535.2030306@redhat.com> Date: Mon, 27 Apr 2015 16:35:00 -0000 From: Pedro Alves User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.5.0 MIME-Version: 1.0 To: Patrick Palka , gdb-patches@sourceware.org Subject: Re: [PATCH 2/3] Update our idea of our terminal's dimensions even outside of TUI References: <1429836801-14218-1-git-send-email-patrick@parcs.ath.cx> <1429836801-14218-2-git-send-email-patrick@parcs.ath.cx> In-Reply-To: <1429836801-14218-2-git-send-email-patrick@parcs.ath.cx> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit X-SW-Source: 2015-04/txt/msg00999.txt.bz2 On 04/24/2015 01:53 AM, Patrick Palka wrote: > When in the CLI, GDB's "width" and "height" variables are not kept in sync > when the underlying terminal gets resized. > > This patch fixes this issue by making sure sure to update GDB's "width" > and "height" variables in the !tui_active case of our SIGWINCH handler. > > gdb/ChangeLog: > > * tui/tui-win.c (tui_sigwinch_handler): Remove now-stale comment. > (tui_sigwinch_handler): Still update our idea of > the terminal's width and height even when TUI is not active. (A next step for a rainy day would be to more the signal handler to core code, and make this work even when the TUI is not compiled in.) > @@ -850,15 +844,26 @@ tui_sigwinch_handler (int signal) > static void > tui_async_resize_screen (gdb_client_data arg) > { > - if (!tui_active) > - return; > - > rl_resize_terminal (); > - tui_resize_all (); > - tui_refresh_all_win (); > - tui_update_gdb_sizes (); > - tui_set_win_resized_to (FALSE); > - tui_redisplay_readline (); > + > + if (!tui_active) > + { > + int screen_height, screen_width; > + > + rl_get_screen_size (&screen_height, &screen_width); > + set_screen_width_and_height (screen_width, screen_height); > + > + /* win_resized will be untoggled and the windows resized in the next call > + to tui_enable(). */ Hmm, can we please avoid "untoggle"? I'm not a native speaker, but it game me pause, as assuming toggle is x^=1, then untoggle is x^=1 too, thus toggle==untoggle. :-) I'd rather use "unset". OK with that change. FWIW, the comment gives a bit of pause. I'd suggest something like this instead: /* win_resized is left set so that the next call to tui_enable resizes windows. */ > + } > + else > + { > + tui_resize_all (); > + tui_refresh_all_win (); > + tui_update_gdb_sizes (); > + tui_set_win_resized_to (FALSE); > + tui_redisplay_readline (); A preexisting problem (thus not be fixed by this patch), but I note that this seems racy. If another SIGWINCH comes in after between tui_resize_all and tui_set_win_resized_to, we'll clear tui_set_win_resized_to and lose the need to resize in tui_enable: /* Resize windows before anything might display/refresh a window. */ if (tui_win_resized ()) { tui_resize_all (); tui_set_win_resized_to (FALSE); } That's why the mainline code that handles a signal should always clear the signal handler's control variable before actually reacting to it, like: tui_set_win_resized_to (FALSE); tui_resize_all (); tui_refresh_all_win (); tui_update_gdb_sizes (); tui_redisplay_readline (); Thanks, Pedro Alves