summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--cmd-attach-session.c5
-rw-r--r--cmd-break-pane.c5
-rw-r--r--cmd-find-window.c5
-rw-r--r--cmd-join-pane.c2
-rw-r--r--cmd-new-session.c4
-rw-r--r--cmd-new-window.c2
-rw-r--r--cmd-select-pane.c4
-rw-r--r--cmd-select-window.c15
-rw-r--r--cmd-split-window.c2
-rw-r--r--cmd-switch-client.c1
-rw-r--r--server-client.c16
11 files changed, 41 insertions, 20 deletions
diff --git a/cmd-attach-session.c b/cmd-attach-session.c
index 684fc3f1..22d9320d 100644
--- a/cmd-attach-session.c
+++ b/cmd-attach-session.c
@@ -50,6 +50,7 @@ enum cmd_retval
cmd_attach_session(struct cmdq_item *item, int dflag, int rflag,
const char *cflag, int Eflag)
{
+ struct cmd_find_state *current = &item->shared->current;
struct session *s = item->state.tflag.s;
struct client *c = item->client, *c_loop;
struct winlink *wl = item->state.tflag.wl;
@@ -73,6 +74,10 @@ cmd_attach_session(struct cmdq_item *item, int dflag, int rflag,
if (wp != NULL)
window_set_active_pane(wp->window, wp);
session_set_current(s, wl);
+ if (wp != NULL)
+ cmd_find_from_winlink_pane(current, wl, wp);
+ else
+ cmd_find_from_winlink(current, wl);
}
if (cflag != NULL) {
diff --git a/cmd-break-pane.c b/cmd-break-pane.c
index 3c564a0c..a2648418 100644
--- a/cmd-break-pane.c
+++ b/cmd-break-pane.c
@@ -48,6 +48,7 @@ static enum cmd_retval
cmd_break_pane_exec(struct cmd *self, struct cmdq_item *item)
{
struct args *args = self->args;
+ struct cmd_find_state *current = &item->shared->current;
struct client *c = item->state.c;
struct winlink *wl = item->state.sflag.wl;
struct session *src_s = item->state.sflag.s;
@@ -93,8 +94,10 @@ cmd_break_pane_exec(struct cmd *self, struct cmdq_item *item)
if (idx == -1)
idx = -1 - options_get_number(dst_s->options, "base-index");
wl = session_attach(dst_s, w, idx, &cause); /* can't fail */
- if (!args_has(self->args, 'd'))
+ if (!args_has(self->args, 'd')) {
session_select(dst_s, wl->idx);
+ cmd_find_from_session(current, dst_s);
+ }
server_redraw_session(src_s);
if (src_s != dst_s)
diff --git a/cmd-find-window.c b/cmd-find-window.c
index 129f6afe..0392688a 100644
--- a/cmd-find-window.c
+++ b/cmd-find-window.c
@@ -142,6 +142,7 @@ static enum cmd_retval
cmd_find_window_exec(struct cmd *self, struct cmdq_item *item)
{
struct args *args = self->args;
+ struct cmd_find_state *current = &item->shared->current;
struct client *c = item->state.c;
struct window_choose_data *cdata;
struct session *s = item->state.tflag.s;
@@ -177,8 +178,10 @@ cmd_find_window_exec(struct cmd *self, struct cmdq_item *item)
}
if (TAILQ_NEXT(TAILQ_FIRST(&find_list), entry) == NULL) {
- if (session_select(s, TAILQ_FIRST(&find_list)->wl->idx) == 0)
+ if (session_select(s, TAILQ_FIRST(&find_list)->wl->idx) == 0) {
+ cmd_find_from_session(current, s);
server_redraw_session(s);
+ }
recalculate_sizes();
goto out;
}
diff --git a/cmd-join-pane.c b/cmd-join-pane.c
index d2a50282..eb2f6022 100644
--- a/cmd-join-pane.c
+++ b/cmd-join-pane.c
@@ -63,6 +63,7 @@ static enum cmd_retval
cmd_join_pane_exec(struct cmd *self, struct cmdq_item *item)
{
struct args *args = self->args;
+ struct cmd_find_state *current = &item->shared->current;
struct session *dst_s;
struct winlink *src_wl, *dst_wl;
struct window *src_w, *dst_w;
@@ -146,6 +147,7 @@ cmd_join_pane_exec(struct cmd *self, struct cmdq_item *item)
if (!args_has(args, 'd')) {
window_set_active_pane(dst_w, src_wp);
session_select(dst_s, dst_idx);
+ cmd_find_from_session(current, dst_s);
server_redraw_session(dst_s);
} else
server_status_session(dst_s);
diff --git a/cmd-new-session.c b/cmd-new-session.c
index 0808b60c..cf0528d3 100644
--- a/cmd-new-session.c
+++ b/cmd-new-session.c
@@ -324,8 +324,10 @@ cmd_new_session_exec(struct cmd *self, struct cmdq_item *item)
free(cp);
}
- if (!detached)
+ if (!detached) {
c->flags |= CLIENT_ATTACHED;
+ cmd_find_from_session(&item->shared->current, s);
+ }
if (to_free != NULL)
free((void *)to_free);
diff --git a/cmd-new-window.c b/cmd-new-window.c
index e99a8089..cbbcda2f 100644
--- a/cmd-new-window.c
+++ b/cmd-new-window.c
@@ -52,6 +52,7 @@ static enum cmd_retval
cmd_new_window_exec(struct cmd *self, struct cmdq_item *item)
{
struct args *args = self->args;
+ struct cmd_find_state *current = &item->shared->current;
struct session *s = item->state.tflag.s;
struct winlink *wl = item->state.tflag.wl;
struct client *c = item->state.c;
@@ -132,6 +133,7 @@ cmd_new_window_exec(struct cmd *self, struct cmdq_item *item)
}
if (!detached) {
session_select(s, wl->idx);
+ cmd_find_from_winlink(current, wl);
server_redraw_session_group(s);
} else
server_status_session_group(s);
diff --git a/cmd-select-pane.c b/cmd-select-pane.c
index 7fc5d6ee..700bacb2 100644
--- a/cmd-select-pane.c
+++ b/cmd-select-pane.c
@@ -56,6 +56,7 @@ static enum cmd_retval
cmd_select_pane_exec(struct cmd *self, struct cmdq_item *item)
{
struct args *args = self->args;
+ struct cmd_find_state *current = &item->shared->current;
struct winlink *wl = item->state.tflag.wl;
struct window *w = wl->window;
struct session *s = item->state.tflag.s;
@@ -68,7 +69,6 @@ cmd_select_pane_exec(struct cmd *self, struct cmdq_item *item)
cmdq_error(item, "no last pane");
return (CMD_RETURN_ERROR);
}
-
if (args_has(self->args, 'e'))
lastwp->flags &= ~PANE_INPUTOFF;
else if (args_has(self->args, 'd'))
@@ -77,6 +77,7 @@ cmd_select_pane_exec(struct cmd *self, struct cmdq_item *item)
server_unzoom_window(w);
window_redraw_active_switch(w, lastwp);
if (window_set_active_pane(w, lastwp)) {
+ cmd_find_from_winlink(current, wl);
server_status_window(w);
server_redraw_window_borders(w);
}
@@ -155,6 +156,7 @@ cmd_select_pane_exec(struct cmd *self, struct cmdq_item *item)
}
window_redraw_active_switch(w, wp);
if (window_set_active_pane(w, wp)) {
+ cmd_find_from_winlink(current, wl);
server_status_window(w);
server_redraw_window_borders(w);
}
diff --git a/cmd-select-window.c b/cmd-select-window.c
index b741af51..4cc4b536 100644
--- a/cmd-select-window.c
+++ b/cmd-select-window.c
@@ -84,9 +84,10 @@ const struct cmd_entry cmd_last_window_entry = {
static enum cmd_retval
cmd_select_window_exec(struct cmd *self, struct cmdq_item *item)
{
- struct winlink *wl = item->state.tflag.wl;
- struct session *s = item->state.tflag.s;
- int next, previous, last, activity;
+ struct cmd_find_state *current = &item->shared->current;
+ struct winlink *wl = item->state.tflag.wl;
+ struct session *s = item->state.tflag.s;
+ int next, previous, last, activity;
next = self->entry == &cmd_next_window_entry;
if (args_has(self->args, 'n'))
@@ -116,7 +117,7 @@ cmd_select_window_exec(struct cmd *self, struct cmdq_item *item)
return (CMD_RETURN_ERROR);
}
}
-
+ cmd_find_from_session(&item->shared->current, s);
server_redraw_session(s);
} else {
/*
@@ -128,9 +129,13 @@ cmd_select_window_exec(struct cmd *self, struct cmdq_item *item)
cmdq_error(item, "no last window");
return (-1);
}
+ if (current->s == s)
+ cmd_find_from_session(current, s);
server_redraw_session(s);
- } else if (session_select(s, wl->idx) == 0)
+ } else if (session_select(s, wl->idx) == 0) {
+ cmd_find_from_session(current, s);
server_redraw_session(s);
+ }
}
recalculate_sizes();
diff --git a/cmd-split-window.c b/cmd-split-window.c
index cb39d8f8..57513e3f 100644
--- a/cmd-split-window.c
+++ b/cmd-split-window.c
@@ -53,6 +53,7 @@ const struct cmd_entry cmd_split_window_entry = {
static enum cmd_retval
cmd_split_window_exec(struct cmd *self, struct cmdq_item *item)
{
+ struct cmd_find_state *current = &item->shared->current;
struct args *args = self->args;
struct client *c = item->state.c;
struct session *s = item->state.tflag.s;
@@ -156,6 +157,7 @@ cmd_split_window_exec(struct cmd *self, struct cmdq_item *item)
if (!args_has(args, 'd')) {
window_set_active_pane(w, new_wp);
session_select(s, wl->idx);
+ cmd_find_from_session(current, s);
server_redraw_session(s);
} else
server_status_session(s);
diff --git a/cmd-switch-client.c b/cmd-switch-client.c
index 06388d44..dbb57ff0 100644
--- a/cmd-switch-client.c
+++ b/cmd-switch-client.c
@@ -99,6 +99,7 @@ cmd_switch_client_exec(struct cmd *self, struct cmdq_item *item)
if (wp != NULL)
window_set_active_pane(wp->window, wp);
session_set_current(s, state->tflag.wl);
+ cmd_find_from_session(&item->shared->current, s);
}
}
diff --git a/server-client.c b/server-client.c
index 875f7ef7..f64e93bd 100644
--- a/server-client.c
+++ b/server-client.c
@@ -856,10 +856,9 @@ server_client_handle_key(struct client *c, key_code key)
m->valid = 0;
/* Find affected pane. */
- if (KEYC_IS_MOUSE(key) && m->valid)
- wp = cmd_mouse_pane(m, NULL, NULL);
- else
- wp = w->active;
+ if (!KEYC_IS_MOUSE(key) || cmd_find_from_mouse(&fs, m) != 0)
+ cmd_find_from_session(&fs, s);
+ wp = fs.wp;
/* Forward mouse keys if disabled. */
if (KEYC_IS_MOUSE(key) && !options_get_number(s->options, "mouse"))
@@ -946,13 +945,8 @@ retry:
}
server_status_client(c);
- /* Find default state if the pane is known. */
- if (KEYC_IS_MOUSE(key) && m->valid && wp != NULL) {
- cmd_find_from_winlink_pane(&fs, s->curw, wp);
- cmd_find_log_state(__func__, &fs);
- key_bindings_dispatch(bd, c, m, &fs);
- } else
- key_bindings_dispatch(bd, c, m, NULL);
+ /* Execute the key binding. */
+ key_bindings_dispatch(bd, c, m, &fs);
key_bindings_unref_table(table);
return;
}