Merge branch 'obsd-master'

This commit is contained in:
Thomas Adam 2017-04-22 00:01:11 +01:00
commit 21240c1a8f
4 changed files with 32 additions and 23 deletions

View File

@ -748,8 +748,10 @@ cmd_find_from_session_window(struct cmd_find_state *fs, struct session *s,
fs->s = s; fs->s = s;
fs->w = w; fs->w = w;
if (cmd_find_best_winlink_with_window(fs) != 0) if (cmd_find_best_winlink_with_window(fs) != 0) {
cmd_find_clear_state(fs, 0);
return (-1); return (-1);
}
fs->wp = fs->w->active; fs->wp = fs->w->active;
cmd_find_log_state(__func__, fs); cmd_find_log_state(__func__, fs);
@ -763,10 +765,14 @@ cmd_find_from_window(struct cmd_find_state *fs, struct window *w)
cmd_find_clear_state(fs, 0); cmd_find_clear_state(fs, 0);
fs->w = w; fs->w = w;
if (cmd_find_best_session_with_window(fs) != 0) if (cmd_find_best_session_with_window(fs) != 0) {
cmd_find_clear_state(fs, 0);
return (-1); return (-1);
if (cmd_find_best_winlink_with_window(fs) != 0) }
if (cmd_find_best_winlink_with_window(fs) != 0) {
cmd_find_clear_state(fs, 0);
return (-1); return (-1);
}
fs->wp = fs->w->active; fs->wp = fs->w->active;
cmd_find_log_state(__func__, fs); cmd_find_log_state(__func__, fs);
@ -795,8 +801,10 @@ cmd_find_from_pane(struct cmd_find_state *fs, struct window_pane *wp)
{ {
if (cmd_find_from_window(fs, wp->window) != 0) if (cmd_find_from_window(fs, wp->window) != 0)
return (-1); return (-1);
if (window_pane_outside(wp)) if (window_pane_outside(wp)) {
cmd_find_clear_state(fs, 0);
return (-1); return (-1);
}
fs->wp = wp; fs->wp = wp;
cmd_find_log_state(__func__, fs); cmd_find_log_state(__func__, fs);
@ -810,8 +818,10 @@ cmd_find_from_nothing(struct cmd_find_state *fs)
cmd_find_clear_state(fs, 0); cmd_find_clear_state(fs, 0);
fs->s = cmd_find_best_session(NULL, 0, fs->flags); fs->s = cmd_find_best_session(NULL, 0, fs->flags);
if (fs->s == NULL) if (fs->s == NULL) {
cmd_find_clear_state(fs, 0);
return (-1); return (-1);
}
fs->wl = fs->s->curw; fs->wl = fs->s->curw;
fs->idx = fs->wl->idx; fs->idx = fs->wl->idx;
fs->w = fs->wl->window; fs->w = fs->wl->window;
@ -831,8 +841,10 @@ cmd_find_from_mouse(struct cmd_find_state *fs, struct mouse_event *m)
return (-1); return (-1);
fs->wp = cmd_mouse_pane(m, &fs->s, &fs->wl); fs->wp = cmd_mouse_pane(m, &fs->s, &fs->wl);
if (fs->wp == NULL) if (fs->wp == NULL) {
cmd_find_clear_state(fs, 0);
return (-1); return (-1);
}
fs->w = fs->wl->window; fs->w = fs->wl->window;
cmd_find_log_state(__func__, fs); cmd_find_log_state(__func__, fs);
@ -901,6 +913,7 @@ cmd_find_from_client(struct cmd_find_state *fs, struct client *c)
*/ */
goto unknown_pane; goto unknown_pane;
} }
cmd_find_clear_state(fs, 0);
return (-1); return (-1);
} }
fs->wl = fs->s->curw; fs->wl = fs->s->curw;
@ -960,9 +973,8 @@ cmd_find_target(struct cmd_find_state *fs, struct cmdq_item *item,
fs->current = &current; fs->current = &current;
log_debug("%s: current is from client", __func__); log_debug("%s: current is from client", __func__);
} else } else
return (-1); goto error;
if (!cmd_find_empty_state(fs->current) && if (!cmd_find_valid_state(fs->current))
!cmd_find_valid_state(fs->current))
fatalx("invalid current find state"); fatalx("invalid current find state");
/* An empty or NULL target is the current. */ /* An empty or NULL target is the current. */
@ -1082,8 +1094,8 @@ cmd_find_target(struct cmd_find_state *fs, struct cmdq_item *item,
if (pane != NULL) if (pane != NULL)
pane = cmd_find_map_table(cmd_find_pane_table, pane); pane = cmd_find_map_table(cmd_find_pane_table, pane);
log_debug("target %s (flags %#x): session=%s, window=%s, pane=%s", log_debug("%s: target %s (flags %#x): session=%s, window=%s, pane=%s",
target, flags, session == NULL ? "none" : session, __func__, target, flags, session == NULL ? "none" : session,
window == NULL ? "none" : window, pane == NULL ? "none" : pane); window == NULL ? "none" : window, pane == NULL ? "none" : pane);
/* No pane is allowed if want an index. */ /* No pane is allowed if want an index. */

View File

@ -203,14 +203,14 @@ cmdq_fire_command(struct cmdq_item *item)
flags = !!(cmd->flags & CMD_CONTROL); flags = !!(cmd->flags & CMD_CONTROL);
cmdq_guard(item, "begin", flags); cmdq_guard(item, "begin", flags);
if (item->client == NULL)
item->client = cmd_find_client(item, NULL, 1);
if (cmd_prepare_state(cmd, item) != 0) { if (cmd_prepare_state(cmd, item) != 0) {
retval = CMD_RETURN_ERROR; retval = CMD_RETURN_ERROR;
goto out; goto out;
} }
if (item->client == NULL)
item->client = cmd_find_client(item, NULL, 1);
retval = cmd->entry->exec(cmd, item); retval = cmd->entry->exec(cmd, item);
if (retval == CMD_RETURN_ERROR) if (retval == CMD_RETURN_ERROR)
goto out; goto out;

View File

@ -63,24 +63,24 @@ cmd_select_pane_exec(struct cmd *self, struct cmdq_item *item)
const char *style; const char *style;
if (self->entry == &cmd_last_pane_entry || args_has(args, 'l')) { if (self->entry == &cmd_last_pane_entry || args_has(args, 'l')) {
if (wl->window->last == NULL) { lastwp = w->last;
if (lastwp == NULL) {
cmdq_error(item, "no last pane"); cmdq_error(item, "no last pane");
return (CMD_RETURN_ERROR); return (CMD_RETURN_ERROR);
} }
if (args_has(self->args, 'e')) if (args_has(self->args, 'e'))
w->last->flags &= ~PANE_INPUTOFF; lastwp->flags &= ~PANE_INPUTOFF;
else if (args_has(self->args, 'd')) else if (args_has(self->args, 'd'))
w->last->flags |= PANE_INPUTOFF; lastwp->flags |= PANE_INPUTOFF;
else { else {
server_unzoom_window(w); server_unzoom_window(w);
window_redraw_active_switch(w, w->last); window_redraw_active_switch(w, lastwp);
if (window_set_active_pane(w, w->last)) { if (window_set_active_pane(w, lastwp)) {
server_status_window(w); server_status_window(w);
server_redraw_window_borders(w); server_redraw_window_borders(w);
} }
} }
return (CMD_RETURN_NORMAL); return (CMD_RETURN_NORMAL);
} }

View File

@ -948,9 +948,6 @@ retry:
if (KEYC_IS_MOUSE(key) && m->valid && wp != NULL) { if (KEYC_IS_MOUSE(key) && m->valid && wp != NULL) {
cmd_find_from_winlink_pane(&fs, s->curw, wp); cmd_find_from_winlink_pane(&fs, s->curw, wp);
cmd_find_log_state(__func__, &fs); cmd_find_log_state(__func__, &fs);
if (!cmd_find_valid_state(&fs))
fatalx("invalid key state");
key_bindings_dispatch(bd, c, m, &fs); key_bindings_dispatch(bd, c, m, &fs);
} else } else
key_bindings_dispatch(bd, c, m, NULL); key_bindings_dispatch(bd, c, m, NULL);