mirror of
https://github.com/tmate-io/tmate.git
synced 2025-02-27 15:51:12 +01:00
Synching winlinks idx instead of window ids
This commit is contained in:
parent
e70a5f8b7f
commit
2dca2c0fd5
@ -41,6 +41,10 @@ const struct cmd_entry cmd_link_window_entry = {
|
|||||||
enum cmd_retval
|
enum cmd_retval
|
||||||
cmd_link_window_exec(struct cmd *self, struct cmd_q *cmdq)
|
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 args *args = self->args;
|
||||||
struct session *src, *dst;
|
struct session *src, *dst;
|
||||||
struct winlink *wl;
|
struct winlink *wl;
|
||||||
@ -62,4 +66,5 @@ cmd_link_window_exec(struct cmd *self, struct cmd_q *cmdq)
|
|||||||
recalculate_sizes();
|
recalculate_sizes();
|
||||||
|
|
||||||
return (CMD_RETURN_NORMAL);
|
return (CMD_RETURN_NORMAL);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -41,6 +41,10 @@ const struct cmd_entry cmd_move_window_entry = {
|
|||||||
enum cmd_retval
|
enum cmd_retval
|
||||||
cmd_move_window_exec(struct cmd *self, struct cmd_q *cmdq)
|
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 args *args = self->args;
|
||||||
struct session *src, *dst, *s;
|
struct session *src, *dst, *s;
|
||||||
struct winlink *wl;
|
struct winlink *wl;
|
||||||
@ -73,4 +77,5 @@ cmd_move_window_exec(struct cmd *self, struct cmd_q *cmdq)
|
|||||||
recalculate_sizes();
|
recalculate_sizes();
|
||||||
|
|
||||||
return (CMD_RETURN_NORMAL);
|
return (CMD_RETURN_NORMAL);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -85,6 +85,13 @@ cmd_swap_pane_exec(struct cmd *self, struct cmd_q *cmdq)
|
|||||||
}
|
}
|
||||||
server_unzoom_window(src_w);
|
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)
|
if (src_wp == dst_wp)
|
||||||
return (CMD_RETURN_NORMAL);
|
return (CMD_RETURN_NORMAL);
|
||||||
|
|
||||||
|
@ -41,6 +41,10 @@ const struct cmd_entry cmd_swap_window_entry = {
|
|||||||
enum cmd_retval
|
enum cmd_retval
|
||||||
cmd_swap_window_exec(struct cmd *self, struct cmd_q *cmdq)
|
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;
|
struct args *args = self->args;
|
||||||
const char *target_src, *target_dst;
|
const char *target_src, *target_dst;
|
||||||
struct session *src, *dst;
|
struct session *src, *dst;
|
||||||
@ -84,4 +88,5 @@ cmd_swap_window_exec(struct cmd *self, struct cmd_q *cmdq)
|
|||||||
recalculate_sizes();
|
recalculate_sizes();
|
||||||
|
|
||||||
return (CMD_RETURN_NORMAL);
|
return (CMD_RETURN_NORMAL);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -39,6 +39,10 @@ const struct cmd_entry cmd_unlink_window_entry = {
|
|||||||
enum cmd_retval
|
enum cmd_retval
|
||||||
cmd_unlink_window_exec(struct cmd *self, struct cmd_q *cmdq)
|
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 args *args = self->args;
|
||||||
struct winlink *wl;
|
struct winlink *wl;
|
||||||
struct window *w;
|
struct window *w;
|
||||||
@ -67,4 +71,5 @@ cmd_unlink_window_exec(struct cmd *self, struct cmd_q *cmdq)
|
|||||||
recalculate_sizes();
|
recalculate_sizes();
|
||||||
|
|
||||||
return (CMD_RETURN_NORMAL);
|
return (CMD_RETURN_NORMAL);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
13
session.c
13
session.c
@ -273,10 +273,6 @@ session_new(struct session *s,
|
|||||||
|
|
||||||
session_group_synchronize_from(s);
|
session_group_synchronize_from(s);
|
||||||
|
|
||||||
#ifdef TMATE
|
|
||||||
tmate_sync_layout();
|
|
||||||
#endif
|
|
||||||
|
|
||||||
return (wl);
|
return (wl);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -293,6 +289,10 @@ session_attach(struct session *s, struct window *w, int idx, char **cause)
|
|||||||
winlink_set_window(wl, w);
|
winlink_set_window(wl, w);
|
||||||
notify_window_linked(s, w);
|
notify_window_linked(s, w);
|
||||||
|
|
||||||
|
#ifdef TMATE
|
||||||
|
tmate_sync_layout();
|
||||||
|
#endif
|
||||||
|
|
||||||
session_group_synchronize_from(s);
|
session_group_synchronize_from(s);
|
||||||
return (wl);
|
return (wl);
|
||||||
}
|
}
|
||||||
@ -309,6 +309,11 @@ session_detach(struct session *s, struct winlink *wl)
|
|||||||
notify_window_unlinked(s, wl->window);
|
notify_window_unlinked(s, wl->window);
|
||||||
winlink_stack_remove(&s->lastw, wl);
|
winlink_stack_remove(&s->lastw, wl);
|
||||||
winlink_remove(&s->windows, wl);
|
winlink_remove(&s->windows, wl);
|
||||||
|
|
||||||
|
#ifdef TMATE
|
||||||
|
tmate_sync_layout();
|
||||||
|
#endif
|
||||||
|
|
||||||
session_group_synchronize_from(s);
|
session_group_synchronize_from(s);
|
||||||
if (RB_EMPTY(&s->windows)) {
|
if (RB_EMPTY(&s->windows)) {
|
||||||
session_destroy(s);
|
session_destroy(s);
|
||||||
|
@ -44,13 +44,13 @@ void tmate_sync_layout(void)
|
|||||||
int num_panes = 0;
|
int num_panes = 0;
|
||||||
int num_windows = 0;
|
int num_windows = 0;
|
||||||
int active_pane_id = -1;
|
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.
|
* We only allow one session, it makes our lives easier.
|
||||||
* Especially when the HTML5 client will come along.
|
* Especially when the HTML5 client will come along.
|
||||||
* We make no distinction between a winlink and its window.
|
* We make no distinction between a winlink and its window except
|
||||||
* TODO send the winlink in the current session stack order.
|
* that we send the winlink idx to draw the status bar properly.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
s = RB_MIN(sessions, &sessions);
|
s = RB_MIN(sessions, &sessions);
|
||||||
@ -78,8 +78,11 @@ void tmate_sync_layout(void)
|
|||||||
if (!w)
|
if (!w)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
if (active_window_idx == -1)
|
||||||
|
active_window_idx = wl->idx;
|
||||||
|
|
||||||
pack(array, 4);
|
pack(array, 4);
|
||||||
pack(int, w->id);
|
pack(int, wl->idx);
|
||||||
pack(string, w->name);
|
pack(string, w->name);
|
||||||
|
|
||||||
num_panes = 0;
|
num_panes = 0;
|
||||||
@ -99,17 +102,12 @@ void tmate_sync_layout(void)
|
|||||||
active_pane_id = wp->id;
|
active_pane_id = wp->id;
|
||||||
}
|
}
|
||||||
pack(int, active_pane_id);
|
pack(int, active_pane_id);
|
||||||
|
|
||||||
if (wl == s->curw)
|
|
||||||
active_window_id = w->id;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (active_window_id == -1) {
|
if (s->curw)
|
||||||
wl = RB_MIN(winlinks, &s->windows);
|
active_window_idx = s->curw->idx;
|
||||||
active_window_id = wl->window->id;
|
|
||||||
}
|
|
||||||
|
|
||||||
pack(int, active_window_id);
|
pack(int, active_window_idx);
|
||||||
}
|
}
|
||||||
|
|
||||||
void tmate_pty_data(struct window_pane *wp, const char *buf, size_t len)
|
void tmate_pty_data(struct window_pane *wp, const char *buf, size_t len)
|
||||||
|
10
window.c
10
window.c
@ -372,6 +372,16 @@ window_remove_ref(struct window *w)
|
|||||||
void
|
void
|
||||||
window_set_name(struct window *w, const char *new_name)
|
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);
|
free(w->name);
|
||||||
w->name = xstrdup(new_name);
|
w->name = xstrdup(new_name);
|
||||||
notify_window_renamed(w);
|
notify_window_renamed(w);
|
||||||
|
Loading…
Reference in New Issue
Block a user