예제 #1
0
파일: control.c 프로젝트: bholt/tmux
static void
control_write_layout_change_cb(struct client *c, unused void *user_data)
{
	struct format_tree	*ft;
	struct winlink		*wl;

	if (!(c->flags & CLIENT_CONTROL_READY)) {
		/* Don't issue spontaneous commands until the remote client has
		 * finished its initalization. It's ok because the remote
		 * client should fetch all window and layout info at the same
		 * time as it's marked ready. */
		return;
	}

	for (int i = 0; i < num_layouts_changed; i++) {
		struct window	*w = layouts_changed[i];
		if (w &&
		    winlink_find_by_window_id(&c->session->windows, w->id)) {
			/* When the last pane in a window is closed it won't
			 * have a layout root and we don't need to inform the
			 * client about its layout change because the whole
			 * window will go away soon. */
			if (w && w->layout_root) {
				const char *template =
				    "%layout-change #{window_id} "
				    "#{window_layout}\n";
				ft = format_create();
				wl = winlink_find_by_window(
				    &c->session->windows, w);
				if (wl) {
					format_winlink(ft, c->session, wl);
					control_write_str(
					    c, format_expand(ft, template));
				}
예제 #2
0
void
control_notify_window_layout_changed(struct window *w)
{
	struct client		*c;
	struct session		*s;
	struct format_tree	*ft;
	struct winlink		*wl;
	u_int			 i;
	const char		*template;

	for (i = 0; i < ARRAY_LENGTH(&clients); i++) {
		c = ARRAY_ITEM(&clients, i);
		if (!CONTROL_SHOULD_NOTIFY_CLIENT(c) || c->session == NULL)
			continue;
		s = c->session;

		if (winlink_find_by_window_id(&s->windows, w->id) == NULL)
			continue;

		/*
		 * When the last pane in a window is closed it won't have a
		 * layout root and we don't need to inform the client about the
		 * layout change because the whole window will go away soon.
		 */
		if (w->layout_root == NULL)
			continue;