From e2100c5f5f9c71185e2a3c410ebdd37f52d701a7 Mon Sep 17 00:00:00 2001 From: nicm Date: Fri, 28 Aug 2015 15:51:48 +0000 Subject: We now only checking for name changes when the active pane has changed, but that can only happen when we have already been woken up by a read event, so there is no need for a timer, we can just check the changed flag on the end of that read event (we already loop over the windows to check for bells etc anyway). --- window.c | 5 ----- 1 file changed, 5 deletions(-) (limited to 'window.c') diff --git a/window.c b/window.c index 77c7a633..bfd13b1c 100644 --- a/window.c +++ b/window.c @@ -299,8 +299,6 @@ window_create1(u_int sx, u_int sy) fatal("gettimeofday failed"); options_init(&w->options, &global_w_options); - if (options_get_number(&w->options, "automatic-rename")) - queue_window_name(w); w->references = 0; @@ -349,9 +347,6 @@ window_destroy(struct window *w) layout_free_cell(w->saved_layout_root); free(w->old_layout); - if (event_initialized(&w->name_timer)) - evtimer_del(&w->name_timer); - options_free(&w->options); window_destroy_panes(w); -- cgit From 55b8d7456155de4e5d44136a140a599e2a2a755b Mon Sep 17 00:00:00 2001 From: nicm Date: Fri, 28 Aug 2015 16:10:46 +0000 Subject: Revert previous; we do need a timer, until I have a better idea. We can't do the name check every loop, because that is too expensive, and we can't make sure it only happens infrequently because we have no idea when the next change will happen. --- window.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'window.c') diff --git a/window.c b/window.c index bfd13b1c..77c7a633 100644 --- a/window.c +++ b/window.c @@ -299,6 +299,8 @@ window_create1(u_int sx, u_int sy) fatal("gettimeofday failed"); options_init(&w->options, &global_w_options); + if (options_get_number(&w->options, "automatic-rename")) + queue_window_name(w); w->references = 0; @@ -347,6 +349,9 @@ window_destroy(struct window *w) layout_free_cell(w->saved_layout_root); free(w->old_layout); + if (event_initialized(&w->name_timer)) + evtimer_del(&w->name_timer); + options_free(&w->options); window_destroy_panes(w); -- cgit From d9b313332186b0c99ec6a9b7585db8188bb35cfc Mon Sep 17 00:00:00 2001 From: nicm Date: Fri, 28 Aug 2015 17:11:12 +0000 Subject: Only set default title to hostname on screens that are being used for a window pane, no point in calling gethostname() for temporary screens. --- window.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'window.c') diff --git a/window.c b/window.c index 77c7a633..ff3ccfb8 100644 --- a/window.c +++ b/window.c @@ -704,6 +704,7 @@ struct window_pane * window_pane_create(struct window *w, u_int sx, u_int sy, u_int hlimit) { struct window_pane *wp; + char host[HOST_NAME_MAX + 1]; wp = xcalloc(1, sizeof *wp); wp->window = w; @@ -740,6 +741,9 @@ window_pane_create(struct window *w, u_int sx, u_int sy, u_int hlimit) screen_init(&wp->base, sx, sy, hlimit); wp->screen = &wp->base; + if (gethostname(host, sizeof host) == 0) + screen_set_title(&wp->base, host); + input_init(wp); return (wp); -- cgit From b7861f34bae7a9e00446e0a8cf2f38e220c41c79 Mon Sep 17 00:00:00 2001 From: nicm Date: Sat, 29 Aug 2015 00:29:15 +0000 Subject: Better take on reducing the name timer. Again check for name changes in the main loop after events that may have changed the pane, but do so at most once every 500 millis. If the pane changed too soon, use a timer to ensure that a check happens later. --- window.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'window.c') diff --git a/window.c b/window.c index ff3ccfb8..f58d80ea 100644 --- a/window.c +++ b/window.c @@ -299,8 +299,6 @@ window_create1(u_int sx, u_int sy) fatal("gettimeofday failed"); options_init(&w->options, &global_w_options); - if (options_get_number(&w->options, "automatic-rename")) - queue_window_name(w); w->references = 0; @@ -349,8 +347,8 @@ window_destroy(struct window *w) layout_free_cell(w->saved_layout_root); free(w->old_layout); - if (event_initialized(&w->name_timer)) - evtimer_del(&w->name_timer); + if (event_initialized(&w->name_event)) + evtimer_del(&w->name_event); options_free(&w->options); -- cgit From 5267ce8ff41e8c5e69fa5d05da92b61e739c328a Mon Sep 17 00:00:00 2001 From: nicm Date: Sat, 29 Aug 2015 00:39:18 +0000 Subject: Treat entering or leaving a mode as pane changed. --- window.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'window.c') diff --git a/window.c b/window.c index f58d80ea..c172b68e 100644 --- a/window.c +++ b/window.c @@ -1066,7 +1066,7 @@ window_pane_set_mode(struct window_pane *wp, const struct window_mode *mode) if ((s = wp->mode->init(wp)) != NULL) wp->screen = s; - wp->flags |= PANE_REDRAW; + wp->flags |= (PANE_REDRAW|PANE_CHANGED); return (0); } @@ -1080,7 +1080,7 @@ window_pane_reset_mode(struct window_pane *wp) wp->mode = NULL; wp->screen = &wp->base; - wp->flags |= PANE_REDRAW; + wp->flags |= (PANE_REDRAW|PANE_CHANGED); } void -- cgit From b5aaefc727f303276a681d74f091f52a7e859d36 Mon Sep 17 00:00:00 2001 From: nicm Date: Sat, 29 Aug 2015 08:30:54 +0000 Subject: Move alerts onto events rather than checking every loop. --- window.c | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) (limited to 'window.c') diff --git a/window.c b/window.c index c172b68e..d8506774 100644 --- a/window.c +++ b/window.c @@ -277,6 +277,13 @@ window_find_by_id(u_int id) return (RB_FIND(windows, &windows, &w)); } +void +window_update_activity(struct window *w) +{ + gettimeofday(&w->activity_time, NULL); + alerts_queue(w, WINDOW_ACTIVITY); +} + struct window * window_create1(u_int sx, u_int sy) { @@ -295,9 +302,6 @@ window_create1(u_int sx, u_int sy) w->sx = sx; w->sy = sy; - if (gettimeofday(&w->activity_time, NULL) != 0) - fatal("gettimeofday failed"); - options_init(&w->options, &global_w_options); w->references = 0; @@ -305,6 +309,8 @@ window_create1(u_int sx, u_int sy) w->id = next_window_id++; RB_INSERT(windows, &windows, w); + window_update_activity(w); + return (w); } @@ -350,6 +356,9 @@ window_destroy(struct window *w) if (event_initialized(&w->name_event)) evtimer_del(&w->name_event); + if (event_initialized(&w->alerts_timer)) + evtimer_del(&w->alerts_timer); + options_free(&w->options); window_destroy_panes(w); @@ -929,14 +938,6 @@ window_pane_read_callback(unused struct bufferevent *bufev, void *data) input_parse(wp); wp->pipe_off = EVBUFFER_LENGTH(evb); - - /* - * If we get here, we're not outputting anymore, so set the silence - * flag on the window. - */ - wp->window->flags |= WINDOW_SILENCE; - if (gettimeofday(&wp->window->silence_timer, NULL) != 0) - fatal("gettimeofday failed"); return; start_timer: -- cgit From 5047670693e3bc861eb4ae95708c96041b12a759 Mon Sep 17 00:00:00 2001 From: nicm Date: Sat, 29 Aug 2015 23:55:55 +0000 Subject: Remove some old prototypes and unused functions. --- window.c | 10 ---------- 1 file changed, 10 deletions(-) (limited to 'window.c') diff --git a/window.c b/window.c index d8506774..e5decdc4 100644 --- a/window.c +++ b/window.c @@ -440,16 +440,6 @@ window_get_active_at(struct window *w, u_int x, u_int y) return (NULL); } -void -window_set_active_at(struct window *w, u_int x, u_int y) -{ - struct window_pane *wp; - - wp = window_get_active_at(w, x, y); - if (wp != NULL && wp != w->active) - window_set_active_pane(w, wp); -} - struct window_pane * window_find_string(struct window *w, const char *s) { -- cgit