summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNicolas Viennot <nicolas@viennot.biz>2013-06-12 17:58:31 -0400
committerNicolas Viennot <nicolas@viennot.biz>2013-06-12 17:58:31 -0400
commit2dca2c0fd5a592875260ef353f46cf81f9cb87f0 (patch)
treea10ef5755c5a68e631bc2e327bffe24636eec859
parente70a5f8b7febfa19a689d4978943602d625eaba3 (diff)
Synching winlinks idx instead of window ids
-rw-r--r--cmd-link-window.c5
-rw-r--r--cmd-move-window.c5
-rw-r--r--cmd-swap-pane.c7
-rw-r--r--cmd-swap-window.c5
-rw-r--r--cmd-unlink-window.c5
-rw-r--r--session.c13
-rw-r--r--tmate-encoder.c22
-rw-r--r--window.c10
8 files changed, 56 insertions, 16 deletions
diff --git a/cmd-link-window.c b/cmd-link-window.c
index 2be8ace0..761dad18 100644
--- a/cmd-link-window.c
+++ b/cmd-link-window.c
@@ -41,6 +41,10 @@ const struct cmd_entry cmd_link_window_entry = {
enum cmd_retval
cmd_link_window_exec(struct cmd *self, struct cmd_q *cmdq)
{
+#ifdef TMATE
+ cmdq_error(cmdq, "link window is not supported with tmate");
+ return (CMD_RETURN_ERROR);
+#else
struct args *args = self->args;
struct session *src, *dst;
struct winlink *wl;
@@ -62,4 +66,5 @@ cmd_link_window_exec(struct cmd *self, struct cmd_q *cmdq)
recalculate_sizes();
return (CMD_RETURN_NORMAL);
+#endif
}
diff --git a/cmd-move-window.c b/cmd-move-window.c
index 1a147c7e..3c675b03 100644
--- a/cmd-move-window.c
+++ b/cmd-move-window.c
@@ -41,6 +41,10 @@ const struct cmd_entry cmd_move_window_entry = {
enum cmd_retval
cmd_move_window_exec(struct cmd *self, struct cmd_q *cmdq)
{
+#ifdef TMATE
+ cmdq_error(cmdq, "move window is not supported with tmate");
+ return (CMD_RETURN_ERROR);
+#else
struct args *args = self->args;
struct session *src, *dst, *s;
struct winlink *wl;
@@ -73,4 +77,5 @@ cmd_move_window_exec(struct cmd *self, struct cmd_q *cmdq)
recalculate_sizes();
return (CMD_RETURN_NORMAL);
+#endif
}
diff --git a/cmd-swap-pane.c b/cmd-swap-pane.c
index d484f4e2..6990b5d4 100644
--- a/cmd-swap-pane.c
+++ b/cmd-swap-pane.c
@@ -85,6 +85,13 @@ cmd_swap_pane_exec(struct cmd *self, struct cmd_q *cmdq)
}
server_unzoom_window(src_w);
+#ifdef TMATE
+ if (src_w != dst_w) {
+ cmdq_error(cmdq, "swap pane on different window is not supported with tmate");
+ return (CMD_RETURN_ERROR);
+ }
+#endif
+
if (src_wp == dst_wp)
return (CMD_RETURN_NORMAL);
diff --git a/cmd-swap-window.c b/cmd-swap-window.c
index f9a2cb1b..a4eadfd9 100644
--- a/cmd-swap-window.c
+++ b/cmd-swap-window.c
@@ -41,6 +41,10 @@ const struct cmd_entry cmd_swap_window_entry = {
enum cmd_retval
cmd_swap_window_exec(struct cmd *self, struct cmd_q *cmdq)
{
+#ifdef TMATE
+ cmdq_error(cmdq, "swap window is not supported with tmate");
+ return (CMD_RETURN_ERROR);
+#else
struct args *args = self->args;
const char *target_src, *target_dst;
struct session *src, *dst;
@@ -84,4 +88,5 @@ cmd_swap_window_exec(struct cmd *self, struct cmd_q *cmdq)
recalculate_sizes();
return (CMD_RETURN_NORMAL);
+#endif
}
diff --git a/cmd-unlink-window.c b/cmd-unlink-window.c
index 39cdd8ed..46e9df36 100644
--- a/cmd-unlink-window.c
+++ b/cmd-unlink-window.c
@@ -39,6 +39,10 @@ const struct cmd_entry cmd_unlink_window_entry = {
enum cmd_retval
cmd_unlink_window_exec(struct cmd *self, struct cmd_q *cmdq)
{
+#ifdef TMATE
+ cmdq_error(cmdq, "unlink window is not supported with tmate");
+ return (CMD_RETURN_ERROR);
+#else
struct args *args = self->args;
struct winlink *wl;
struct window *w;
@@ -67,4 +71,5 @@ cmd_unlink_window_exec(struct cmd *self, struct cmd_q *cmdq)
recalculate_sizes();
return (CMD_RETURN_NORMAL);
+#endif
}
diff --git a/session.c b/session.c
index ebe1178d..25bcdf11 100644
--- a/session.c
+++ b/session.c
@@ -273,10 +273,6 @@ session_new(struct session *s,
session_group_synchronize_from(s);
-#ifdef TMATE
- tmate_sync_layout();
-#endif
-
return (wl);
}
@@ -293,6 +289,10 @@ session_attach(struct session *s, struct window *w, int idx, char **cause)
winlink_set_window(wl, w);
notify_window_linked(s, w);
+#ifdef TMATE
+ tmate_sync_layout();
+#endif
+
session_group_synchronize_from(s);
return (wl);
}
@@ -309,6 +309,11 @@ session_detach(struct session *s, struct winlink *wl)
notify_window_unlinked(s, wl->window);
winlink_stack_remove(&s->lastw, wl);
winlink_remove(&s->windows, wl);
+
+#ifdef TMATE
+ tmate_sync_layout();
+#endif
+
session_group_synchronize_from(s);
if (RB_EMPTY(&s->windows)) {
session_destroy(s);
diff --git a/tmate-encoder.c b/tmate-encoder.c
index 57f6c110..cf5d1e29 100644
--- a/tmate-encoder.c
+++ b/tmate-encoder.c
@@ -44,13 +44,13 @@ void tmate_sync_layout(void)
int num_panes = 0;
int num_windows = 0;
int active_pane_id = -1;
- int active_window_id = -1;
+ int active_window_idx = -1;
/*
* 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.
- * TODO send the winlink in the current session stack order.
+ * We make no distinction between a winlink and its window except
+ * that we send the winlink idx to draw the status bar properly.
*/
s = RB_MIN(sessions, &sessions);
@@ -78,8 +78,11 @@ void tmate_sync_layout(void)
if (!w)
continue;
+ if (active_window_idx == -1)
+ active_window_idx = wl->idx;
+
pack(array, 4);
- pack(int, w->id);
+ pack(int, wl->idx);
pack(string, w->name);
num_panes = 0;
@@ -99,17 +102,12 @@ void tmate_sync_layout(void)
active_pane_id = wp->id;
}
pack(int, active_pane_id);
-
- if (wl == s->curw)
- active_window_id = w->id;
}
- if (active_window_id == -1) {
- wl = RB_MIN(winlinks, &s->windows);
- active_window_id = wl->window->id;
- }
+ if (s->curw)
+ active_window_idx = s->curw->idx;
- pack(int, active_window_id);
+ pack(int, active_window_idx);
}
void tmate_pty_data(struct window_pane *wp, const char *buf, size_t len)
diff --git a/window.c b/window.c
index 10629042..2108e001 100644
--- a/window.c
+++ b/window.c
@@ -372,6 +372,16 @@ window_remove_ref(struct window *w)
void
window_set_name(struct window *w, const char *new_name)
{
+#ifdef TMATE
+ /*
+ * We don't want to sync the layout too much.
+ * We might want to have some sort of timer for when to
+ * sync the layout.
+ */
+ if (!strcmp(w->name, new_name))
+ return;
+#endif
+
free(w->name);
w->name = xstrdup(new_name);
notify_window_renamed(w);