1
0
mirror of https://github.com/tmate-io/tmate-ssh-server.git synced 2020-11-18 19:53:51 -08:00

Synching winlinks idx instead of window ids

This commit is contained in:
Nicolas Viennot 2013-06-12 17:57:23 -04:00
parent 5872c01dfd
commit 03948f3e3d
3 changed files with 32 additions and 22 deletions

View File

@ -52,8 +52,7 @@ static int print_resolved_stack_frame(const char *frame)
} }
#endif #endif
void void tmate_print_trace(void)
tmate_print_trace (void)
{ {
void *array[20]; void *array[20];
size_t size; size_t size;

View File

@ -118,10 +118,10 @@ static void tmate_sync_window_panes(struct window *w,
unpack_each(&uk, &tmp_uk, w_uk) { unpack_each(&uk, &tmp_uk, w_uk) {
int id = unpack_int(&uk); int id = unpack_int(&uk);
int sx = unpack_int(&uk); u_int sx = unpack_int(&uk);
int sy = unpack_int(&uk); u_int sy = unpack_int(&uk);
int xoff = unpack_int(&uk); u_int xoff = unpack_int(&uk);
int yoff = unpack_int(&uk); u_int yoff = unpack_int(&uk);
wp = window_pane_find_by_id(id); wp = window_pane_find_by_id(id);
if (!wp) { if (!wp) {
@ -131,11 +131,14 @@ static void tmate_sync_window_panes(struct window *w,
} }
wp->flags &= ~PANE_KILL; wp->flags &= ~PANE_KILL;
wp->xoff = xoff; if (wp->xoff != xoff || wp->yoff != yoff ||
wp->yoff = yoff; wp->sx != sx || wp->sx != sy) {
window_pane_resize(wp, sx, sy); wp->xoff = xoff;
wp->yoff = yoff;
window_pane_resize(wp, sx, sy);
wp->flags |= PANE_REDRAW; wp->flags |= PANE_REDRAW;
}
} }
TAILQ_FOREACH_SAFE(wp, &w->panes, entry, wp_tmp) { TAILQ_FOREACH_SAFE(wp, &w->panes, entry, wp_tmp) {
@ -154,24 +157,25 @@ static void tmate_sync_windows(struct session *s,
struct tmate_unpacker uk, tmp_uk; struct tmate_unpacker uk, tmp_uk;
struct winlink *wl, *wl_tmp; struct winlink *wl, *wl_tmp;
struct window *w; struct window *w;
int active_window_id; int active_window_idx;
char *cause; char *cause;
RB_FOREACH(wl, winlinks, &s->windows) RB_FOREACH(wl, winlinks, &s->windows)
wl->window->flags |= WINDOW_KILL; wl->flags |= WINLINK_KILL;
unpack_each(&uk, &tmp_uk, s_uk) { unpack_each(&uk, &tmp_uk, s_uk) {
int id = unpack_int(&uk); int idx = unpack_int(&uk);
char *name = unpack_string(&uk); char *name = unpack_string(&uk);
wl = winlink_find_by_window_id(&s->windows, id); wl = winlink_find_by_index(&s->windows, idx);
if (!wl) { if (!wl) {
wl = session_new(s, name, "", NULL, id, &cause); wl = session_new(s, name, "", NULL, idx, &cause);
if (!wl) if (!wl)
tmate_fatal("can't create window id=%d", id); tmate_fatal("can't create window idx=%d", idx);
} }
wl->flags &= ~WINLINK_KILL;
w = wl->window; w = wl->window;
w->flags &= ~WINDOW_KILL;
free(w->name); free(w->name);
w->name = name; w->name = name;
@ -182,12 +186,14 @@ static void tmate_sync_windows(struct session *s,
} }
RB_FOREACH_SAFE(wl, winlinks, &s->windows, wl_tmp) { RB_FOREACH_SAFE(wl, winlinks, &s->windows, wl_tmp) {
if (wl->window->flags & WINDOW_KILL) if (wl->flags & WINLINK_KILL)
winlink_remove(&s->windows, wl); session_detach(s, wl);
} }
active_window_id = unpack_int(s_uk); active_window_idx = unpack_int(s_uk);
wl = winlink_find_by_window_id(&s->windows, active_window_id); wl = winlink_find_by_index(&s->windows, active_window_idx);
if (!wl)
tmate_fatal("no valid active window");
session_set_current(s, wl); session_set_current(s, wl);
server_redraw_window(wl->window); server_redraw_window(wl->window);

7
tmux.h
View File

@ -940,6 +940,9 @@ struct window_pane {
#define PANE_DROP 0x2 #define PANE_DROP 0x2
#define PANE_FOCUSED 0x4 #define PANE_FOCUSED 0x4
#define PANE_RESIZE 0x8 #define PANE_RESIZE 0x8
#ifdef TMATE_SLAVE
#define PANE_KILL 0x80
#endif
char *cmd; char *cmd;
char *shell; char *shell;
@ -953,7 +956,6 @@ struct window_pane {
u_int changes_redraw; u_int changes_redraw;
#ifdef TMATE_SLAVE #ifdef TMATE_SLAVE
#define PANE_KILL 0x10
struct evbuffer *event_input; struct evbuffer *event_input;
#else #else
int fd; int fd;
@ -1034,6 +1036,9 @@ struct winlink {
#define WINLINK_SILENCE 0x8 #define WINLINK_SILENCE 0x8
#define WINLINK_ALERTFLAGS \ #define WINLINK_ALERTFLAGS \
(WINLINK_BELL|WINLINK_ACTIVITY|WINLINK_CONTENT|WINLINK_SILENCE) (WINLINK_BELL|WINLINK_ACTIVITY|WINLINK_CONTENT|WINLINK_SILENCE)
#ifdef TMATE_SLAVE
#define WINLINK_KILL 0x80
#endif
RB_ENTRY(winlink) entry; RB_ENTRY(winlink) entry;
TAILQ_ENTRY(winlink) sentry; TAILQ_ENTRY(winlink) sentry;