diff options
Diffstat (limited to 'window.c')
-rw-r--r-- | window.c | 28 |
1 files changed, 28 insertions, 0 deletions
@@ -294,6 +294,9 @@ 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); if (options_get_number(&w->options, "automatic-rename")) queue_window_name(w); @@ -1389,3 +1392,28 @@ winlink_clear_flags(struct winlink *wl) } } } + +int +winlink_shuffle_up(struct session *s, struct winlink *wl) +{ + int idx, last; + + idx = wl->idx + 1; + + /* Find the next free index. */ + for (last = idx; last < INT_MAX; last++) { + if (winlink_find_by_index(&s->windows, last) == NULL) + break; + } + if (last == INT_MAX) + return (-1); + + /* Move everything from last - 1 to idx up a bit. */ + for (; last > idx; last--) { + wl = winlink_find_by_index(&s->windows, last - 1); + server_link_window(s, wl, s, last, 0, 0, NULL); + server_unlink_window(s, wl); + } + + return (idx); +} |