mirror of
https://github.com/tmux/tmux.git
synced 2024-12-13 18:38:48 +00:00
Sync OpenBSD patchset 324:
Tidy some common code for destroying sessions into a new function.
This commit is contained in:
parent
61990deb36
commit
69e7f4af19
38
server-fn.c
38
server-fn.c
@ -1,4 +1,4 @@
|
|||||||
/* $Id: server-fn.c,v 1.86 2009-09-05 19:03:41 tcunha Exp $ */
|
/* $Id: server-fn.c,v 1.87 2009-09-13 20:37:37 tcunha Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||||
@ -278,10 +278,7 @@ server_kill_window(struct window *w)
|
|||||||
{
|
{
|
||||||
struct session *s;
|
struct session *s;
|
||||||
struct winlink *wl;
|
struct winlink *wl;
|
||||||
struct client *c;
|
u_int i;
|
||||||
u_int i, j;
|
|
||||||
int destroyed;
|
|
||||||
|
|
||||||
|
|
||||||
for (i = 0; i < ARRAY_LENGTH(&sessions); i++) {
|
for (i = 0; i < ARRAY_LENGTH(&sessions); i++) {
|
||||||
s = ARRAY_ITEM(&sessions, i);
|
s = ARRAY_ITEM(&sessions, i);
|
||||||
@ -290,22 +287,29 @@ server_kill_window(struct window *w)
|
|||||||
if ((wl = winlink_find_by_window(&s->windows, w)) == NULL)
|
if ((wl = winlink_find_by_window(&s->windows, w)) == NULL)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
destroyed = session_detach(s, wl);
|
if (session_detach(s, wl))
|
||||||
for (j = 0; j < ARRAY_LENGTH(&clients); j++) {
|
server_destroy_session(s);
|
||||||
c = ARRAY_ITEM(&clients, j);
|
else
|
||||||
if (c == NULL || c->session != s)
|
server_redraw_session(s);
|
||||||
continue;
|
|
||||||
|
|
||||||
if (destroyed) {
|
|
||||||
c->session = NULL;
|
|
||||||
server_write_client(c, MSG_EXIT, NULL, 0);
|
|
||||||
} else
|
|
||||||
server_redraw_client(c);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
recalculate_sizes();
|
recalculate_sizes();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
server_destroy_session(struct session *s)
|
||||||
|
{
|
||||||
|
struct client *c;
|
||||||
|
u_int i;
|
||||||
|
|
||||||
|
for (i = 0; i < ARRAY_LENGTH(&clients); i++) {
|
||||||
|
c = ARRAY_ITEM(&clients, i);
|
||||||
|
if (c == NULL || c->session != s)
|
||||||
|
continue;
|
||||||
|
c->session = NULL;
|
||||||
|
server_write_client(c, MSG_EXIT, NULL, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
server_set_identify(struct client *c)
|
server_set_identify(struct client *c)
|
||||||
{
|
{
|
||||||
|
20
server.c
20
server.c
@ -1,4 +1,4 @@
|
|||||||
/* $Id: server.c,v 1.184 2009-09-11 14:13:52 tcunha Exp $ */
|
/* $Id: server.c,v 1.185 2009-09-13 20:37:37 tcunha Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||||
@ -1214,21 +1214,11 @@ server_check_window(struct window *w)
|
|||||||
RB_FOREACH(wl, winlinks, &s->windows) {
|
RB_FOREACH(wl, winlinks, &s->windows) {
|
||||||
if (wl->window != w)
|
if (wl->window != w)
|
||||||
continue;
|
continue;
|
||||||
destroyed = session_detach(s, wl);
|
if (session_detach(s, wl)) {
|
||||||
for (j = 0; j < ARRAY_LENGTH(&clients); j++) {
|
server_destroy_session(s);
|
||||||
c = ARRAY_ITEM(&clients, j);
|
|
||||||
if (c == NULL || c->session != s)
|
|
||||||
continue;
|
|
||||||
if (!destroyed) {
|
|
||||||
server_redraw_client(c);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
c->session = NULL;
|
|
||||||
server_write_client(c, MSG_EXIT, NULL, 0);
|
|
||||||
}
|
|
||||||
/* If the session was destroyed, bail now. */
|
|
||||||
if (destroyed)
|
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
server_redraw_session(s);
|
||||||
goto restart;
|
goto restart;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
3
tmux.h
3
tmux.h
@ -1,4 +1,4 @@
|
|||||||
/* $Id: tmux.h,v 1.440 2009-09-11 14:13:52 tcunha Exp $ */
|
/* $Id: tmux.h,v 1.441 2009-09-13 20:37:37 tcunha Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||||
@ -1455,6 +1455,7 @@ void server_status_window(struct window *);
|
|||||||
void server_lock(void);
|
void server_lock(void);
|
||||||
int server_unlock(const char *);
|
int server_unlock(const char *);
|
||||||
void server_kill_window(struct window *);
|
void server_kill_window(struct window *);
|
||||||
|
void server_destroy_session(struct session *);
|
||||||
void server_set_identify(struct client *);
|
void server_set_identify(struct client *);
|
||||||
void server_clear_identify(struct client *);
|
void server_clear_identify(struct client *);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user