summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Adam <thomas@xteddy.org>2019-06-12 11:02:25 +0100
committerThomas Adam <thomas@xteddy.org>2019-06-12 11:02:25 +0100
commitd5902eeae9da610b2652ffda9a66e560d179f1b8 (patch)
tree95e7fe9438d833f347efea814782f6feeb6d7697
parent057c04e32a54018f5da1c93efc107f7e05db597e (diff)
parent7e6a26cc9d857ffc53fdb2395aa5413ff1865f9e (diff)
Merge branch 'obsd-master'
-rw-r--r--cmd-find.c73
-rw-r--r--cmd-if-shell.c13
-rw-r--r--layout-custom.c5
3 files changed, 17 insertions, 74 deletions
diff --git a/cmd-find.c b/cmd-find.c
index 7ad8ad7a..154842ab 100644
--- a/cmd-find.c
+++ b/cmd-find.c
@@ -75,38 +75,12 @@ static const char *cmd_find_pane_table[][2] = {
{ NULL, NULL }
};
-/* Get session from TMUX if present. */
-static struct session *
-cmd_find_try_TMUX(struct client *c)
-{
- struct environ_entry *envent;
- char tmp[256];
- long long pid;
- u_int session;
- struct session *s;
-
- envent = environ_find(c->environ, "TMUX");
- if (envent == NULL)
- return (NULL);
-
- if (sscanf(envent->value, "%255[^,],%lld,%d", tmp, &pid, &session) != 3)
- return (NULL);
- if (pid != getpid())
- return (NULL);
- log_debug("%s: client %p TMUX %s (session $%u)", __func__, c,
- envent->value, session);
-
- s = session_find_by_id(session);
- if (s != NULL)
- log_debug("%s: session $%u still exists", __func__, s->id);
- return (s);
-}
-
/* Find pane containing client if any. */
static struct window_pane *
cmd_find_inside_pane(struct client *c)
{
struct window_pane *wp;
+ struct environ_entry *envent;
if (c == NULL)
return (NULL);
@@ -115,6 +89,11 @@ cmd_find_inside_pane(struct client *c)
if (wp->fd != -1 && strcmp(wp->tty, c->ttyname) == 0)
break;
}
+ if (wp == NULL) {
+ envent = environ_find(c->environ, "TMUX_PANE");
+ if (envent != NULL)
+ wp = window_pane_find_by_id_str(envent->value);
+ }
if (wp != NULL)
log_debug("%s: got pane %%%u (%s)", __func__, wp->id, wp->tty);
return (wp);
@@ -879,8 +858,6 @@ cmd_find_from_mouse(struct cmd_find_state *fs, struct mouse_event *m, int flags)
int
cmd_find_from_client(struct cmd_find_state *fs, struct client *c, int flags)
{
- struct session *s;
- struct winlink *wl;
struct window_pane *wp;
/* If no client, treat as from nothing. */
@@ -902,30 +879,6 @@ cmd_find_from_client(struct cmd_find_state *fs, struct client *c, int flags)
if (wp == NULL)
goto unknown_pane;
- /* If we have a session in TMUX, see if it has this pane. */
- s = cmd_find_try_TMUX(c);
- if (s != NULL) {
- RB_FOREACH(wl, winlinks, &s->windows) {
- if (window_has_pane(wl->window, wp))
- break;
- }
- if (wl != NULL) {
- log_debug("%s: session $%u has pane %%%u", __func__,
- s->id, wp->id);
-
- fs->s = s;
- fs->wl = s->curw; /* use current session */
- fs->w = fs->wl->window;
- fs->wp = fs->w->active; /* use active pane */
-
- cmd_find_log_state(__func__, fs);
- return (0);
- } else {
- log_debug("%s: session $%u does not have pane %%%u",
- __func__, s->id, wp->id);
- }
- }
-
/*
* Don't have a session, or it doesn't have this pane. Try all
* sessions.
@@ -947,17 +900,7 @@ cmd_find_from_client(struct cmd_find_state *fs, struct client *c, int flags)
return (0);
unknown_pane:
- /*
- * We're not running in a known pane, but maybe this client has TMUX
- * in the environment. That'd give us a session.
- */
- s = cmd_find_try_TMUX(c);
- if (s != NULL) {
- cmd_find_from_session(fs, s, flags);
- return (0);
- }
-
- /* Otherwise we need to guess. */
+ /* We can't find the pane so need to guess. */
return (cmd_find_from_nothing(fs, flags));
}
@@ -1005,6 +948,8 @@ cmd_find_target(struct cmd_find_state *fs, struct cmdq_item *item,
strlcat(tmp, "CANFAIL,", sizeof tmp);
if (*tmp != '\0')
tmp[strlen(tmp) - 1] = '\0';
+ else
+ strlcat(tmp, "NONE", sizeof tmp);
log_debug("%s: target %s, type %s, item %p, flags %s", __func__,
target == NULL ? "none" : target, s, item, tmp);
diff --git a/cmd-if-shell.c b/cmd-if-shell.c
index 84f66657..f795575a 100644
--- a/cmd-if-shell.c
+++ b/cmd-if-shell.c
@@ -67,10 +67,11 @@ cmd_if_shell_exec(struct cmd *self, struct cmdq_item *item)
struct cmd_if_shell_data *cdata;
char *shellcmd, *cmd;
struct cmdq_item *new_item;
+ struct cmd_find_state *fs = &item->target;
struct client *c = cmd_find_client(item, NULL, 1);
- struct session *s = item->target.s;
- struct winlink *wl = item->target.wl;
- struct window_pane *wp = item->target.wp;
+ struct session *s = fs->s;
+ struct winlink *wl = fs->wl;
+ struct window_pane *wp = fs->wp;
struct cmd_parse_input pi;
struct cmd_parse_result *pr;
@@ -92,7 +93,7 @@ cmd_if_shell_exec(struct cmd *self, struct cmdq_item *item)
pi.line = self->line;
pi.item = item;
pi.c = c;
- cmd_find_copy_state(&pi.fs, &item->target);
+ cmd_find_copy_state(&pi.fs, fs);
pr = cmd_parse_from_string(cmd, &pi);
switch (pr->status) {
@@ -103,7 +104,7 @@ cmd_if_shell_exec(struct cmd *self, struct cmdq_item *item)
free(pr->error);
return (CMD_RETURN_ERROR);
case CMD_PARSE_SUCCESS:
- new_item = cmdq_get_command(pr->cmdlist, NULL, m, 0);
+ new_item = cmdq_get_command(pr->cmdlist, fs, m, 0);
cmdq_insert_after(item, new_item);
cmd_list_free(pr->cmdlist);
break;
@@ -137,7 +138,7 @@ cmd_if_shell_exec(struct cmd *self, struct cmdq_item *item)
cdata->input.c = c;
if (cdata->input.c != NULL)
cdata->input.c->references++;
- cmd_find_copy_state(&cdata->input.fs, &item->target);
+ cmd_find_copy_state(&cdata->input.fs, fs);
if (job_run(shellcmd, s, server_client_get_cwd(item->client, s), NULL,
cmd_if_shell_callback, cmd_if_shell_free, cdata, 0) == NULL) {
diff --git a/layout-custom.c b/layout-custom.c
index 9886afe1..4d9e818b 100644
--- a/layout-custom.c
+++ b/layout-custom.c
@@ -168,10 +168,7 @@ layout_parse(struct window *w, const char *layout)
/* Update pane offsets and sizes. */
layout_fix_offsets(lc);
layout_fix_panes(w);
-
- /* Then resize the layout back to the original window size. */
- layout_resize(w, sx, sy);
- window_resize(w, sx, sy);
+ recalculate_sizes();
layout_print_cell(lc, __func__, 0);