summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNicolas Viennot <nicolas@viennot.biz>2015-12-31 11:35:36 -0500
committerNicolas Viennot <nicolas@viennot.biz>2015-12-31 11:35:36 -0500
commit66e4f554c323e549f39ea49b5e0394933d134141 (patch)
treec8a098cc1f5d828e9e87190ba7c1b7598d14ec7b
parenta104b160b290e7b0f79efee7f6f57a37b3a3cdcc (diff)
Layout fixes
-rw-r--r--server-client.c2
-rw-r--r--tmate-decoder.c9
-rw-r--r--tmate-encoder.c17
-rw-r--r--tmux.h3
-rw-r--r--window.c4
5 files changed, 30 insertions, 5 deletions
diff --git a/server-client.c b/server-client.c
index 5565e1ab..28c2a348 100644
--- a/server-client.c
+++ b/server-client.c
@@ -722,6 +722,8 @@ server_client_loop(void)
#ifdef TMATE
if (w->flags & WINDOW_REDRAW)
tmate_should_sync_layout = 1;
+ if (w->tmate_last_sync_active_pane != w->active)
+ tmate_should_sync_layout = 1;
#endif
w->flags &= ~WINDOW_REDRAW;
diff --git a/tmate-decoder.c b/tmate-decoder.c
index 79925566..7020e64d 100644
--- a/tmate-decoder.c
+++ b/tmate-decoder.c
@@ -105,7 +105,7 @@ static void tmate_client_pane_key(struct tmate_unpacker *uk)
window_pane_key(wp, NULL, s, key, NULL);
}
-static struct window_pane *find_window_pane(struct session *s, unsigned int pane_id)
+static struct window_pane *find_window_pane(struct session *s, int pane_id)
{
struct window *w;
struct window_pane *wp;
@@ -118,13 +118,16 @@ static struct window_pane *find_window_pane(struct session *s, unsigned int pane
wp = w->active;
if (!wp)
goto slow_path;
- if (wp->id == pane_id)
+ if (pane_id == -1 || (int)wp->id == pane_id)
return wp;
slow_path:
+ if (pane_id == -1)
+ return NULL;
+
RB_FOREACH(wl, winlinks, &s->windows) {
TAILQ_FOREACH(wp, &wl->window->panes, entry) {
- if (wp->id == pane_id)
+ if ((int)wp->id == pane_id)
return wp;
}
}
diff --git a/tmate-encoder.c b/tmate-encoder.c
index 6f9bc0e4..da460515 100644
--- a/tmate-encoder.c
+++ b/tmate-encoder.c
@@ -48,10 +48,17 @@ void tmate_sync_layout(void)
struct window_pane *wp;
int num_panes = 0;
int num_windows = 0;
- int active_pane_id = -1;
+ int active_pane_id;
int active_window_idx = -1;
/*
+ * TODO this can get a little heavy.
+ * We are shipping the full layout whenever a window name changes,
+ * that is, at every shell command.
+ * Might be better to do something incremental.
+ */
+
+ /*
* We only allow one session, it makes our lives easier.
* Especially when the HTML5 client will come along.
* We make no distinction between a winlink and its window except
@@ -83,6 +90,9 @@ void tmate_sync_layout(void)
if (!w)
continue;
+ w->tmate_last_sync_active_pane = NULL;
+ active_pane_id = -1;
+
if (active_window_idx == -1)
active_window_idx = wl->idx;
@@ -103,8 +113,11 @@ void tmate_sync_layout(void)
pack(int, wp->xoff);
pack(int, wp->yoff);
- if (wp == w->active)
+ if (wp == w->active) {
+ w->tmate_last_sync_active_pane = wp;
active_pane_id = wp->id;
+ }
+
}
pack(int, active_pane_id);
}
diff --git a/tmux.h b/tmux.h
index 24a7db59..f2a02368 100644
--- a/tmux.h
+++ b/tmux.h
@@ -915,6 +915,9 @@ struct window {
struct timeval activity_time;
+#ifdef TMATE
+ struct window_pane *tmate_last_sync_active_pane;
+#endif
struct window_pane *active;
struct window_pane *last;
struct window_panes panes;
diff --git a/window.c b/window.c
index 6de39d8a..f0e7b53e 100644
--- a/window.c
+++ b/window.c
@@ -296,6 +296,10 @@ window_create1(u_int sx, u_int sy)
TAILQ_INIT(&w->panes);
w->active = NULL;
+#ifdef TMATE
+ w->tmate_last_sync_active_pane = NULL;
+#endif
+
w->lastlayout = -1;
w->layout_root = NULL;