Layout fixes

This commit is contained in:
Nicolas Viennot 2015-12-31 11:35:36 -05:00
parent a104b160b2
commit 66e4f554c3
5 changed files with 30 additions and 5 deletions

View File

@ -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;

View File

@ -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;
}
}

View File

@ -48,9 +48,16 @@ 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.
@ -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);
}

3
tmux.h
View File

@ -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;

View File

@ -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;