mirror of
https://github.com/tmux/tmux.git
synced 2024-12-04 19:58:48 +00:00
Pass flags into cmd_find_from_* to fix prefer-unattached, reported by
Thomas Sattler.
This commit is contained in:
parent
a7d1ee5433
commit
17cf1b21c6
@ -90,9 +90,9 @@ cmd_attach_session(struct cmdq_item *item, const char *tflag, int dflag,
|
||||
window_set_active_pane(wp->window, wp);
|
||||
session_set_current(s, wl);
|
||||
if (wp != NULL)
|
||||
cmd_find_from_winlink_pane(current, wl, wp);
|
||||
cmd_find_from_winlink_pane(current, wl, wp, 0);
|
||||
else
|
||||
cmd_find_from_winlink(current, wl);
|
||||
cmd_find_from_winlink(current, wl, 0);
|
||||
}
|
||||
|
||||
if (cflag != NULL) {
|
||||
|
@ -97,7 +97,7 @@ cmd_break_pane_exec(struct cmd *self, struct cmdq_item *item)
|
||||
wl = session_attach(dst_s, w, idx, &cause); /* can't fail */
|
||||
if (!args_has(self->args, 'd')) {
|
||||
session_select(dst_s, wl->idx);
|
||||
cmd_find_from_session(current, dst_s);
|
||||
cmd_find_from_session(current, dst_s, 0);
|
||||
}
|
||||
|
||||
server_redraw_session(src_s);
|
||||
|
58
cmd-find.c
58
cmd-find.c
@ -728,9 +728,9 @@ cmd_find_log_state(const char *prefix, struct cmd_find_state *fs)
|
||||
|
||||
/* Find state from a session. */
|
||||
void
|
||||
cmd_find_from_session(struct cmd_find_state *fs, struct session *s)
|
||||
cmd_find_from_session(struct cmd_find_state *fs, struct session *s, int flags)
|
||||
{
|
||||
cmd_find_clear_state(fs, 0);
|
||||
cmd_find_clear_state(fs, flags);
|
||||
|
||||
fs->s = s;
|
||||
fs->wl = fs->s->curw;
|
||||
@ -742,9 +742,9 @@ cmd_find_from_session(struct cmd_find_state *fs, struct session *s)
|
||||
|
||||
/* Find state from a winlink. */
|
||||
void
|
||||
cmd_find_from_winlink(struct cmd_find_state *fs, struct winlink *wl)
|
||||
cmd_find_from_winlink(struct cmd_find_state *fs, struct winlink *wl, int flags)
|
||||
{
|
||||
cmd_find_clear_state(fs, 0);
|
||||
cmd_find_clear_state(fs, flags);
|
||||
|
||||
fs->s = wl->session;
|
||||
fs->wl = wl;
|
||||
@ -757,14 +757,14 @@ cmd_find_from_winlink(struct cmd_find_state *fs, struct winlink *wl)
|
||||
/* Find state from a session and window. */
|
||||
int
|
||||
cmd_find_from_session_window(struct cmd_find_state *fs, struct session *s,
|
||||
struct window *w)
|
||||
struct window *w, int flags)
|
||||
{
|
||||
cmd_find_clear_state(fs, 0);
|
||||
cmd_find_clear_state(fs, flags);
|
||||
|
||||
fs->s = s;
|
||||
fs->w = w;
|
||||
if (cmd_find_best_winlink_with_window(fs) != 0) {
|
||||
cmd_find_clear_state(fs, 0);
|
||||
cmd_find_clear_state(fs, flags);
|
||||
return (-1);
|
||||
}
|
||||
fs->wp = fs->w->active;
|
||||
@ -775,17 +775,17 @@ cmd_find_from_session_window(struct cmd_find_state *fs, struct session *s,
|
||||
|
||||
/* Find state from a window. */
|
||||
int
|
||||
cmd_find_from_window(struct cmd_find_state *fs, struct window *w)
|
||||
cmd_find_from_window(struct cmd_find_state *fs, struct window *w, int flags)
|
||||
{
|
||||
cmd_find_clear_state(fs, 0);
|
||||
cmd_find_clear_state(fs, flags);
|
||||
|
||||
fs->w = w;
|
||||
if (cmd_find_best_session_with_window(fs) != 0) {
|
||||
cmd_find_clear_state(fs, 0);
|
||||
cmd_find_clear_state(fs, flags);
|
||||
return (-1);
|
||||
}
|
||||
if (cmd_find_best_winlink_with_window(fs) != 0) {
|
||||
cmd_find_clear_state(fs, 0);
|
||||
cmd_find_clear_state(fs, flags);
|
||||
return (-1);
|
||||
}
|
||||
fs->wp = fs->w->active;
|
||||
@ -797,9 +797,9 @@ cmd_find_from_window(struct cmd_find_state *fs, struct window *w)
|
||||
/* Find state from a winlink and pane. */
|
||||
void
|
||||
cmd_find_from_winlink_pane(struct cmd_find_state *fs, struct winlink *wl,
|
||||
struct window_pane *wp)
|
||||
struct window_pane *wp, int flags)
|
||||
{
|
||||
cmd_find_clear_state(fs, 0);
|
||||
cmd_find_clear_state(fs, flags);
|
||||
|
||||
fs->s = wl->session;
|
||||
fs->wl = wl;
|
||||
@ -812,9 +812,9 @@ cmd_find_from_winlink_pane(struct cmd_find_state *fs, struct winlink *wl,
|
||||
|
||||
/* Find state from a pane. */
|
||||
int
|
||||
cmd_find_from_pane(struct cmd_find_state *fs, struct window_pane *wp)
|
||||
cmd_find_from_pane(struct cmd_find_state *fs, struct window_pane *wp, int flags)
|
||||
{
|
||||
if (cmd_find_from_window(fs, wp->window) != 0)
|
||||
if (cmd_find_from_window(fs, wp->window, flags) != 0)
|
||||
return (-1);
|
||||
fs->wp = wp;
|
||||
|
||||
@ -824,13 +824,13 @@ cmd_find_from_pane(struct cmd_find_state *fs, struct window_pane *wp)
|
||||
|
||||
/* Find state from nothing. */
|
||||
int
|
||||
cmd_find_from_nothing(struct cmd_find_state *fs)
|
||||
cmd_find_from_nothing(struct cmd_find_state *fs, int flags)
|
||||
{
|
||||
cmd_find_clear_state(fs, 0);
|
||||
cmd_find_clear_state(fs, flags);
|
||||
|
||||
fs->s = cmd_find_best_session(NULL, 0, fs->flags);
|
||||
fs->s = cmd_find_best_session(NULL, 0, flags);
|
||||
if (fs->s == NULL) {
|
||||
cmd_find_clear_state(fs, 0);
|
||||
cmd_find_clear_state(fs, flags);
|
||||
return (-1);
|
||||
}
|
||||
fs->wl = fs->s->curw;
|
||||
@ -844,16 +844,16 @@ cmd_find_from_nothing(struct cmd_find_state *fs)
|
||||
|
||||
/* Find state from mouse. */
|
||||
int
|
||||
cmd_find_from_mouse(struct cmd_find_state *fs, struct mouse_event *m)
|
||||
cmd_find_from_mouse(struct cmd_find_state *fs, struct mouse_event *m, int flags)
|
||||
{
|
||||
cmd_find_clear_state(fs, 0);
|
||||
cmd_find_clear_state(fs, flags);
|
||||
|
||||
if (!m->valid)
|
||||
return (-1);
|
||||
|
||||
fs->wp = cmd_mouse_pane(m, &fs->s, &fs->wl);
|
||||
if (fs->wp == NULL) {
|
||||
cmd_find_clear_state(fs, 0);
|
||||
cmd_find_clear_state(fs, flags);
|
||||
return (-1);
|
||||
}
|
||||
fs->w = fs->wl->window;
|
||||
@ -864,7 +864,7 @@ cmd_find_from_mouse(struct cmd_find_state *fs, struct mouse_event *m)
|
||||
|
||||
/* Find state from client. */
|
||||
int
|
||||
cmd_find_from_client(struct cmd_find_state *fs, struct client *c)
|
||||
cmd_find_from_client(struct cmd_find_state *fs, struct client *c, int flags)
|
||||
{
|
||||
struct session *s;
|
||||
struct winlink *wl;
|
||||
@ -872,14 +872,14 @@ cmd_find_from_client(struct cmd_find_state *fs, struct client *c)
|
||||
|
||||
/* If no client, treat as from nothing. */
|
||||
if (c == NULL)
|
||||
return (cmd_find_from_nothing(fs));
|
||||
return (cmd_find_from_nothing(fs, flags));
|
||||
|
||||
/* If this is an attached client, all done. */
|
||||
if (c->session != NULL) {
|
||||
cmd_find_from_session(fs, c->session);
|
||||
cmd_find_from_session(fs, c->session, flags);
|
||||
return (0);
|
||||
}
|
||||
cmd_find_clear_state(fs, 0);
|
||||
cmd_find_clear_state(fs, flags);
|
||||
|
||||
/*
|
||||
* If this is an unattached client running in a pane, we can use that
|
||||
@ -938,12 +938,12 @@ unknown_pane:
|
||||
*/
|
||||
s = cmd_find_try_TMUX(c);
|
||||
if (s != NULL) {
|
||||
cmd_find_from_session(fs, s);
|
||||
cmd_find_from_session(fs, s, flags);
|
||||
return (0);
|
||||
}
|
||||
|
||||
/* Otherwise we need to guess. */
|
||||
return (cmd_find_from_nothing(fs));
|
||||
return (cmd_find_from_nothing(fs, flags));
|
||||
}
|
||||
|
||||
/*
|
||||
@ -989,7 +989,7 @@ cmd_find_target(struct cmd_find_state *fs, struct cmdq_item *item,
|
||||
} else if (cmd_find_valid_state(&item->shared->current)) {
|
||||
fs->current = &item->shared->current;
|
||||
log_debug("%s: current is from queue", __func__);
|
||||
} else if (cmd_find_from_client(¤t, item->client) == 0) {
|
||||
} else if (cmd_find_from_client(¤t, item->client, flags) == 0) {
|
||||
fs->current = ¤t;
|
||||
log_debug("%s: current is from client", __func__);
|
||||
} else {
|
||||
|
@ -147,7 +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);
|
||||
cmd_find_from_session(current, dst_s, 0);
|
||||
server_redraw_session(dst_s);
|
||||
} else
|
||||
server_status_session(dst_s);
|
||||
|
@ -325,10 +325,10 @@ cmd_new_session_exec(struct cmd *self, struct cmdq_item *item)
|
||||
|
||||
if (!detached) {
|
||||
c->flags |= CLIENT_ATTACHED;
|
||||
cmd_find_from_session(&item->shared->current, s);
|
||||
cmd_find_from_session(&item->shared->current, s, 0);
|
||||
}
|
||||
|
||||
cmd_find_from_session(&fs, s);
|
||||
cmd_find_from_session(&fs, s, 0);
|
||||
hooks_insert(s->hooks, item, &fs, "after-new-session");
|
||||
|
||||
free(to_free);
|
||||
|
@ -133,7 +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);
|
||||
cmd_find_from_winlink(current, wl, 0);
|
||||
server_redraw_session_group(s);
|
||||
} else
|
||||
server_status_session_group(s);
|
||||
@ -146,7 +146,7 @@ cmd_new_window_exec(struct cmd *self, struct cmdq_item *item)
|
||||
free(cp);
|
||||
}
|
||||
|
||||
cmd_find_from_winlink(&fs, wl);
|
||||
cmd_find_from_winlink(&fs, wl, 0);
|
||||
hooks_insert(s->hooks, item, &fs, "after-new-window");
|
||||
|
||||
free(to_free);
|
||||
|
@ -241,7 +241,7 @@ cmdq_fire_command(struct cmdq_item *item)
|
||||
fsp = &item->target;
|
||||
else if (cmd_find_valid_state(&item->shared->current))
|
||||
fsp = &item->shared->current;
|
||||
else if (cmd_find_from_client(&fs, item->client) == 0)
|
||||
else if (cmd_find_from_client(&fs, item->client, 0) == 0)
|
||||
fsp = &fs;
|
||||
else
|
||||
goto out;
|
||||
|
@ -78,7 +78,7 @@ cmd_rotate_window_exec(struct cmd *self, struct cmdq_item *item)
|
||||
if ((wp = TAILQ_PREV(w->active, window_panes, entry)) == NULL)
|
||||
wp = TAILQ_LAST(&w->panes, window_panes);
|
||||
window_set_active_pane(w, wp);
|
||||
cmd_find_from_winlink_pane(current, wl, wp);
|
||||
cmd_find_from_winlink_pane(current, wl, wp, 0);
|
||||
server_redraw_window(w);
|
||||
} else {
|
||||
wp = TAILQ_FIRST(&w->panes);
|
||||
@ -106,7 +106,7 @@ cmd_rotate_window_exec(struct cmd *self, struct cmdq_item *item)
|
||||
if ((wp = TAILQ_NEXT(w->active, entry)) == NULL)
|
||||
wp = TAILQ_FIRST(&w->panes);
|
||||
window_set_active_pane(w, wp);
|
||||
cmd_find_from_winlink_pane(current, wl, wp);
|
||||
cmd_find_from_winlink_pane(current, wl, wp, 0);
|
||||
server_redraw_window(w);
|
||||
}
|
||||
|
||||
|
@ -68,7 +68,7 @@ cmd_run_shell_print(struct job *job, const char *msg)
|
||||
cmdq_print(cdata->item, "%s", msg);
|
||||
return;
|
||||
}
|
||||
if (cmd_find_from_nothing(&fs) != 0)
|
||||
if (cmd_find_from_nothing(&fs, 0) != 0)
|
||||
return;
|
||||
wp = fs.wp;
|
||||
if (wp == NULL)
|
||||
|
@ -77,7 +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);
|
||||
cmd_find_from_winlink(current, wl, 0);
|
||||
server_status_window(w);
|
||||
server_redraw_window_borders(w);
|
||||
}
|
||||
@ -156,7 +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_pane(current, wl, wp);
|
||||
cmd_find_from_winlink_pane(current, wl, wp, 0);
|
||||
hooks_insert(s->hooks, item, current, "after-select-pane");
|
||||
server_status_window(w);
|
||||
server_redraw_window_borders(w);
|
||||
|
@ -117,7 +117,7 @@ cmd_select_window_exec(struct cmd *self, struct cmdq_item *item)
|
||||
return (CMD_RETURN_ERROR);
|
||||
}
|
||||
}
|
||||
cmd_find_from_session(current, s);
|
||||
cmd_find_from_session(current, s, 0);
|
||||
server_redraw_session(s);
|
||||
hooks_insert(s->hooks, item, current, "after-select-window");
|
||||
} else {
|
||||
@ -131,10 +131,10 @@ cmd_select_window_exec(struct cmd *self, struct cmdq_item *item)
|
||||
return (-1);
|
||||
}
|
||||
if (current->s == s)
|
||||
cmd_find_from_session(current, s);
|
||||
cmd_find_from_session(current, s, 0);
|
||||
server_redraw_session(s);
|
||||
} else if (session_select(s, wl->idx) == 0) {
|
||||
cmd_find_from_session(current, s);
|
||||
cmd_find_from_session(current, s, 0);
|
||||
server_redraw_session(s);
|
||||
}
|
||||
hooks_insert(s->hooks, item, current, "after-select-window");
|
||||
|
@ -158,7 +158,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);
|
||||
cmd_find_from_session(current, s, 0);
|
||||
server_redraw_session(s);
|
||||
} else
|
||||
server_status_session(s);
|
||||
@ -172,7 +172,7 @@ cmd_split_window_exec(struct cmd *self, struct cmdq_item *item)
|
||||
}
|
||||
notify_window("window-layout-changed", w);
|
||||
|
||||
cmd_find_from_winlink_pane(&fs, wl, new_wp);
|
||||
cmd_find_from_winlink_pane(&fs, wl, new_wp, 0);
|
||||
hooks_insert(s->hooks, item, &fs, "after-split-window");
|
||||
|
||||
free(to_free);
|
||||
|
@ -116,7 +116,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, wl);
|
||||
cmd_find_from_session(&item->shared->current, s);
|
||||
cmd_find_from_session(&item->shared->current, s, 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
16
notify.c
16
notify.c
@ -46,7 +46,7 @@ notify_hook(struct cmdq_item *item, struct notify_entry *ne)
|
||||
|
||||
cmd_find_clear_state(&fs, 0);
|
||||
if (cmd_find_empty_state(&ne->fs) || !cmd_find_valid_state(&ne->fs))
|
||||
cmd_find_from_nothing(&fs);
|
||||
cmd_find_from_nothing(&fs, 0);
|
||||
else
|
||||
cmd_find_copy_state(&fs, &ne->fs);
|
||||
|
||||
@ -170,7 +170,7 @@ notify_client(const char *name, struct client *c)
|
||||
{
|
||||
struct cmd_find_state fs;
|
||||
|
||||
cmd_find_from_client(&fs, c);
|
||||
cmd_find_from_client(&fs, c, 0);
|
||||
notify_add(name, &fs, c, NULL, NULL, NULL);
|
||||
}
|
||||
|
||||
@ -180,9 +180,9 @@ notify_session(const char *name, struct session *s)
|
||||
struct cmd_find_state fs;
|
||||
|
||||
if (session_alive(s))
|
||||
cmd_find_from_session(&fs, s);
|
||||
cmd_find_from_session(&fs, s, 0);
|
||||
else
|
||||
cmd_find_from_nothing(&fs);
|
||||
cmd_find_from_nothing(&fs, 0);
|
||||
notify_add(name, &fs, NULL, s, NULL, NULL);
|
||||
}
|
||||
|
||||
@ -191,7 +191,7 @@ notify_winlink(const char *name, struct winlink *wl)
|
||||
{
|
||||
struct cmd_find_state fs;
|
||||
|
||||
cmd_find_from_winlink(&fs, wl);
|
||||
cmd_find_from_winlink(&fs, wl, 0);
|
||||
notify_add(name, &fs, NULL, wl->session, wl->window, NULL);
|
||||
}
|
||||
|
||||
@ -200,7 +200,7 @@ notify_session_window(const char *name, struct session *s, struct window *w)
|
||||
{
|
||||
struct cmd_find_state fs;
|
||||
|
||||
cmd_find_from_session_window(&fs, s, w);
|
||||
cmd_find_from_session_window(&fs, s, w, 0);
|
||||
notify_add(name, &fs, NULL, s, w, NULL);
|
||||
}
|
||||
|
||||
@ -209,7 +209,7 @@ notify_window(const char *name, struct window *w)
|
||||
{
|
||||
struct cmd_find_state fs;
|
||||
|
||||
cmd_find_from_window(&fs, w);
|
||||
cmd_find_from_window(&fs, w, 0);
|
||||
notify_add(name, &fs, NULL, NULL, w, NULL);
|
||||
}
|
||||
|
||||
@ -218,6 +218,6 @@ notify_pane(const char *name, struct window_pane *wp)
|
||||
{
|
||||
struct cmd_find_state fs;
|
||||
|
||||
cmd_find_from_pane(&fs, wp);
|
||||
cmd_find_from_pane(&fs, wp, 0);
|
||||
notify_add(name, &fs, NULL, NULL, NULL, wp);
|
||||
}
|
||||
|
@ -877,8 +877,8 @@ server_client_handle_key(struct client *c, key_code key)
|
||||
m->valid = 0;
|
||||
|
||||
/* Find affected pane. */
|
||||
if (!KEYC_IS_MOUSE(key) || cmd_find_from_mouse(&fs, m) != 0)
|
||||
cmd_find_from_session(&fs, s);
|
||||
if (!KEYC_IS_MOUSE(key) || cmd_find_from_mouse(&fs, m, 0) != 0)
|
||||
cmd_find_from_session(&fs, s, 0);
|
||||
wp = fs.wp;
|
||||
|
||||
/* Forward mouse keys if disabled. */
|
||||
|
20
tmux.h
20
tmux.h
@ -1768,20 +1768,22 @@ void cmd_find_copy_state(struct cmd_find_state *,
|
||||
struct cmd_find_state *);
|
||||
void cmd_find_log_state(const char *, struct cmd_find_state *);
|
||||
void cmd_find_from_session(struct cmd_find_state *,
|
||||
struct session *);
|
||||
struct session *, int);
|
||||
void cmd_find_from_winlink(struct cmd_find_state *,
|
||||
struct winlink *);
|
||||
struct winlink *, int);
|
||||
int cmd_find_from_session_window(struct cmd_find_state *,
|
||||
struct session *, struct window *);
|
||||
int cmd_find_from_window(struct cmd_find_state *, struct window *);
|
||||
struct session *, struct window *, int);
|
||||
int cmd_find_from_window(struct cmd_find_state *, struct window *,
|
||||
int);
|
||||
void cmd_find_from_winlink_pane(struct cmd_find_state *,
|
||||
struct winlink *, struct window_pane *);
|
||||
struct winlink *, struct window_pane *, int);
|
||||
int cmd_find_from_pane(struct cmd_find_state *,
|
||||
struct window_pane *);
|
||||
int cmd_find_from_client(struct cmd_find_state *, struct client *);
|
||||
struct window_pane *, int);
|
||||
int cmd_find_from_client(struct cmd_find_state *, struct client *,
|
||||
int);
|
||||
int cmd_find_from_mouse(struct cmd_find_state *,
|
||||
struct mouse_event *);
|
||||
int cmd_find_from_nothing(struct cmd_find_state *);
|
||||
struct mouse_event *, int);
|
||||
int cmd_find_from_nothing(struct cmd_find_state *, int);
|
||||
|
||||
/* cmd.c */
|
||||
int cmd_pack_argv(int, char **, char *, size_t);
|
||||
|
@ -874,7 +874,7 @@ window_tree_get_target(struct window_tree_itemdata *item,
|
||||
if (target == NULL)
|
||||
cmd_find_clear_state(fs, 0);
|
||||
else
|
||||
cmd_find_from_winlink_pane(fs, wl, wp);
|
||||
cmd_find_from_winlink_pane(fs, wl, wp, 0);
|
||||
return (target);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user