From 0d001a88b704aaf784eeb4172c915e22bd76bea0 Mon Sep 17 00:00:00 2001 From: Miciah Dashiel Butler Masters Date: Thu, 3 Jan 2008 06:38:27 +0000 Subject: [PATCH] redraw_leds: Redraw the LED panel for each terminal, not each session Since there is only one LED panel per terminal, redrawing for each session is wasteful. Furthermore, since one terminal can have many sessions (i.e. tabs), and since the last session in the list might not be the current session, the wrong LEDs might be drawn. An easy way to demonstrate the bug is to enable ui.clock.enable, so that the panel is redrawn every 100ms, and then to select a text field and enter insert mode. Unless the current tab is the last tab, the insert-mode LED will only briefly show that insert mode is enabled. --- src/bfu/leds.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/bfu/leds.c b/src/bfu/leds.c index 91bcdf9df..17a72ca3b 100644 --- a/src/bfu/leds.c +++ b/src/bfu/leds.c @@ -23,6 +23,7 @@ #include "main/timer.h" #include "session/session.h" #include "terminal/draw.h" +#include "terminal/tab.h" #include "terminal/terminal.h" #include "terminal/window.h" #include "util/color.h" @@ -300,7 +301,7 @@ update_download_led(struct session *ses) static void redraw_leds(void *xxx) { - struct session *ses; + struct terminal *term; if (!get_leds_panel_enable() && get_opt_int("ui.timer.enable", NULL) != 2) { @@ -314,11 +315,20 @@ redraw_leds(void *xxx) if (drawing) return; drawing = 1; - foreach (ses, sessions) { + foreach (term, terminals) { + struct session *ses; + struct window *win; + + if (list_empty(term->windows)) continue; + + win = get_current_tab(term); + assert(win); + ses = win->data; + update_download_led(ses); if (!sync_leds(ses)) continue; - redraw_terminal(ses->tab->term); + redraw_terminal(term); draw_leds(ses); } drawing = 0;