version 1.121, 2015/04/22 15:05:03 |
version 1.122, 2015/04/22 15:30:11 |
|
|
|
|
struct window_pane *window_pane_choose_best(struct window_pane_list *); |
struct window_pane *window_pane_choose_best(struct window_pane_list *); |
|
|
|
RB_GENERATE(windows, window, entry, window_cmp); |
|
|
|
int |
|
window_cmp(struct window *w1, struct window *w2) |
|
{ |
|
return (w1->id - w2->id); |
|
} |
|
|
RB_GENERATE(winlinks, winlink, entry, winlink_cmp); |
RB_GENERATE(winlinks, winlink, entry, winlink_cmp); |
|
|
int |
int |
|
|
struct window * |
struct window * |
window_find_by_id(u_int id) |
window_find_by_id(u_int id) |
{ |
{ |
struct window *w; |
struct window w; |
u_int i; |
|
|
|
for (i = 0; i < ARRAY_LENGTH(&windows); i++) { |
w.id = id; |
w = ARRAY_ITEM(&windows, i); |
return (RB_FIND(windows, &windows, &w)); |
if (w != NULL && w->id == id) |
|
return (w); |
|
} |
|
return (NULL); |
|
} |
} |
|
|
struct window * |
struct window * |
window_create1(u_int sx, u_int sy) |
window_create1(u_int sx, u_int sy) |
{ |
{ |
struct window *w; |
struct window *w; |
u_int i; |
|
|
|
w = xcalloc(1, sizeof *w); |
w = xcalloc(1, sizeof *w); |
w->id = next_window_id++; |
|
w->name = NULL; |
w->name = NULL; |
w->flags = 0; |
w->flags = 0; |
|
|
|
|
if (options_get_number(&w->options, "automatic-rename")) |
if (options_get_number(&w->options, "automatic-rename")) |
queue_window_name(w); |
queue_window_name(w); |
|
|
for (i = 0; i < ARRAY_LENGTH(&windows); i++) { |
|
if (ARRAY_ITEM(&windows, i) == NULL) { |
|
ARRAY_SET(&windows, i, w); |
|
break; |
|
} |
|
} |
|
if (i == ARRAY_LENGTH(&windows)) |
|
ARRAY_ADD(&windows, w); |
|
w->references = 0; |
w->references = 0; |
|
|
|
w->id = next_window_id++; |
|
RB_INSERT (windows, &windows, w); |
|
|
return (w); |
return (w); |
} |
} |
|
|
|
|
void |
void |
window_destroy(struct window *w) |
window_destroy(struct window *w) |
{ |
{ |
u_int i; |
|
|
|
window_unzoom(w); |
window_unzoom(w); |
|
|
for (i = 0; i < ARRAY_LENGTH(&windows); i++) { |
RB_REMOVE(windows, &windows, w); |
if (w == ARRAY_ITEM(&windows, i)) |
|
break; |
|
} |
|
if (i == ARRAY_LENGTH(&windows)) |
|
fatalx("index not found"); |
|
ARRAY_SET(&windows, i, NULL); |
|
while (!ARRAY_EMPTY(&windows) && ARRAY_LAST(&windows) == NULL) |
|
ARRAY_TRUNC(&windows, 1); |
|
|
|
if (w->layout_root != NULL) |
if (w->layout_root != NULL) |
layout_free(w); |
layout_free(w); |
|
|
void |
void |
winlink_clear_flags(struct winlink *wl) |
winlink_clear_flags(struct winlink *wl) |
{ |
{ |
struct winlink *wm; |
|
struct session *s; |
struct session *s; |
struct window *w; |
struct winlink *wl_loop; |
u_int i; |
|
|
|
for (i = 0; i < ARRAY_LENGTH(&windows); i++) { |
RB_FOREACH(s, sessions, &sessions) { |
if ((w = ARRAY_ITEM(&windows, i)) == NULL) |
RB_FOREACH(wl_loop, winlinks, &s->windows) { |
continue; |
if (wl_loop->window != wl->window) |
|
|
RB_FOREACH(s, sessions, &sessions) { |
|
if ((wm = session_has(s, w)) == NULL) |
|
continue; |
continue; |
|
if ((wl_loop->flags & WINLINK_ALERTFLAGS) == 0) |
if (wm->window != wl->window) |
|
continue; |
continue; |
if ((wm->flags & WINLINK_ALERTFLAGS) == 0) |
|
continue; |
|
|
|
wm->flags &= ~WINLINK_ALERTFLAGS; |
wl_loop->flags &= ~WINLINK_ALERTFLAGS; |
wm->window->flags &= ~WINDOW_ALERTFLAGS; |
wl_loop->window->flags &= ~WINDOW_ALERTFLAGS; |
server_status_session(s); |
server_status_session(s); |
} |
} |
} |
} |