Merge branch 'obsd-master'

This commit is contained in:
Thomas Adam
2020-04-13 16:01:46 +01:00
24 changed files with 103 additions and 99 deletions

View File

@@ -50,8 +50,8 @@ enum cmd_retval
cmd_attach_session(struct cmdq_item *item, const char *tflag, int dflag, cmd_attach_session(struct cmdq_item *item, const char *tflag, int dflag,
int xflag, int rflag, const char *cflag, int Eflag) int xflag, int rflag, const char *cflag, int Eflag)
{ {
struct cmdq_shared *shared = cmdq_get_shared(item); struct cmdq_state *state = cmdq_get_state(item);
struct cmd_find_state *current = &shared->current; struct cmd_find_state *current = &state->current;
struct cmd_find_state target; struct cmd_find_state target;
enum cmd_find_type type; enum cmd_find_type type;
int flags; int flags;
@@ -120,7 +120,7 @@ cmd_attach_session(struct cmdq_item *item, const char *tflag, int dflag,
environ_update(s->options, c->environ, s->environ); environ_update(s->options, c->environ, s->environ);
c->session = s; c->session = s;
if (~shared->flags & CMDQ_SHARED_REPEAT) if (~state->flags & CMDQ_STATE_REPEAT)
server_client_set_key_table(c, NULL); server_client_set_key_table(c, NULL);
tty_update_client_offset(c); tty_update_client_offset(c);
status_timer_start(c); status_timer_start(c);

View File

@@ -49,8 +49,8 @@ static enum cmd_retval
cmd_break_pane_exec(struct cmd *self, struct cmdq_item *item) cmd_break_pane_exec(struct cmd *self, struct cmdq_item *item)
{ {
struct args *args = cmd_get_args(self); struct args *args = cmd_get_args(self);
struct cmdq_shared *shared = cmdq_get_shared(item); struct cmdq_state *state = cmdq_get_state(item);
struct cmd_find_state *current = &shared->current; struct cmd_find_state *current = &state->current;
struct cmd_find_state *target = cmdq_get_target(item); struct cmd_find_state *target = cmdq_get_target(item);
struct cmd_find_state *source = cmdq_get_source(item); struct cmd_find_state *source = cmdq_get_source(item);
struct client *c = cmd_find_client(item, NULL, 1); struct client *c = cmd_find_client(item, NULL, 1);

View File

@@ -57,7 +57,7 @@ static enum cmd_retval
cmd_copy_mode_exec(struct cmd *self, struct cmdq_item *item) cmd_copy_mode_exec(struct cmd *self, struct cmdq_item *item)
{ {
struct args *args = cmd_get_args(self); struct args *args = cmd_get_args(self);
struct cmdq_shared *shared = cmdq_get_shared(item); struct cmdq_state *state = cmdq_get_state(item);
struct cmd_find_state *source = cmdq_get_source(item); struct cmd_find_state *source = cmdq_get_source(item);
struct cmd_find_state *target = cmdq_get_target(item); struct cmd_find_state *target = cmdq_get_target(item);
struct client *c = cmdq_get_client(item); struct client *c = cmdq_get_client(item);
@@ -70,7 +70,7 @@ cmd_copy_mode_exec(struct cmd *self, struct cmdq_item *item)
} }
if (args_has(args, 'M')) { if (args_has(args, 'M')) {
if ((wp = cmd_mouse_pane(&shared->mouse, &s, NULL)) == NULL) if ((wp = cmd_mouse_pane(&state->event.m, &s, NULL)) == NULL)
return (CMD_RETURN_NORMAL); return (CMD_RETURN_NORMAL);
if (c == NULL || c->session != s) if (c == NULL || c->session != s)
return (CMD_RETURN_NORMAL); return (CMD_RETURN_NORMAL);
@@ -87,7 +87,7 @@ cmd_copy_mode_exec(struct cmd *self, struct cmdq_item *item)
swp = wp; swp = wp;
if (!window_pane_set_mode(wp, swp, &window_copy_mode, NULL, args)) { if (!window_pane_set_mode(wp, swp, &window_copy_mode, NULL, args)) {
if (args_has(args, 'M')) if (args_has(args, 'M'))
window_copy_start_drag(c, &shared->mouse); window_copy_start_drag(c, &state->event.m);
} }
if (args_has(args, 'u')) if (args_has(args, 'u'))
window_copy_pageup(wp, 0); window_copy_pageup(wp, 0);

View File

@@ -65,7 +65,7 @@ static void
cmd_display_menu_get_position(struct client *c, struct cmdq_item *item, cmd_display_menu_get_position(struct client *c, struct cmdq_item *item,
struct args *args, u_int *px, u_int *py, u_int w, u_int h) struct args *args, u_int *px, u_int *py, u_int w, u_int h)
{ {
struct cmdq_shared *shared = cmdq_get_shared(item); struct cmdq_state *state = cmdq_get_state(item);
struct cmd_find_state *target = cmdq_get_target(item); struct cmd_find_state *target = cmdq_get_target(item);
struct session *s = c->session; struct session *s = c->session;
struct winlink *wl = target->wl; struct winlink *wl = target->wl;
@@ -99,9 +99,9 @@ cmd_display_menu_get_position(struct client *c, struct cmdq_item *item,
*px = wp->xoff - ox; *px = wp->xoff - ox;
else else
*px = 0; *px = 0;
} else if (strcmp(xp, "M") == 0 && shared->mouse.valid) { } else if (strcmp(xp, "M") == 0) {
if (shared->mouse.x > w / 2) if (state->event.m.valid && state->event.m.x > w / 2)
*px = shared->mouse.x - w / 2; *px = state->event.m.x - w / 2;
else else
*px = 0; *px = 0;
} else if (strcmp(xp, "W") == 0) { } else if (strcmp(xp, "W") == 0) {
@@ -133,9 +133,12 @@ cmd_display_menu_get_position(struct client *c, struct cmdq_item *item,
*py = wp->yoff + wp->sy - oy; *py = wp->yoff + wp->sy - oy;
else else
*py = 0; *py = 0;
} else if (strcmp(yp, "M") == 0 && shared->mouse.valid) } else if (strcmp(yp, "M") == 0) {
*py = shared->mouse.y + h; if (state->event.m.valid)
else if (strcmp(yp, "S") == 0) { *py = state->event.m.y + h;
else
*py = 0;
} else if (strcmp(yp, "S") == 0) {
if (options_get_number(s->options, "status-position") == 0) { if (options_get_number(s->options, "status-position") == 0) {
if (lines != 0) if (lines != 0)
*py = lines + h; *py = lines + h;
@@ -147,8 +150,7 @@ cmd_display_menu_get_position(struct client *c, struct cmdq_item *item,
else else
*py = c->tty.sy; *py = c->tty.sy;
} }
} } else if (strcmp(yp, "W") == 0) {
else if (strcmp(yp, "W") == 0) {
if (options_get_number(s->options, "status-position") == 0) { if (options_get_number(s->options, "status-position") == 0) {
if (lines != 0) if (lines != 0)
*py = line + 1 + h; *py = line + 1 + h;
@@ -174,7 +176,7 @@ static enum cmd_retval
cmd_display_menu_exec(struct cmd *self, struct cmdq_item *item) cmd_display_menu_exec(struct cmd *self, struct cmdq_item *item)
{ {
struct args *args = cmd_get_args(self); struct args *args = cmd_get_args(self);
struct cmdq_shared *shared = cmdq_get_shared(item); struct cmdq_state *state = cmdq_get_state(item);
struct cmd_find_state *target = cmdq_get_target(item); struct cmd_find_state *target = cmdq_get_target(item);
struct client *c; struct client *c;
struct menu *menu = NULL; struct menu *menu = NULL;
@@ -228,7 +230,7 @@ cmd_display_menu_exec(struct cmd *self, struct cmdq_item *item)
cmd_display_menu_get_position(c, item, args, &px, &py, menu->width + 4, cmd_display_menu_get_position(c, item, args, &px, &py, menu->width + 4,
menu->count + 2); menu->count + 2);
if (!shared->mouse.valid) if (!state->event.m.valid)
flags |= MENU_NOMOUSE; flags |= MENU_NOMOUSE;
if (menu_display(menu, flags, item, px, py, c, target, NULL, NULL) != 0) if (menu_display(menu, flags, item, px, py, c, target, NULL, NULL) != 0)
return (CMD_RETURN_NORMAL); return (CMD_RETURN_NORMAL);

View File

@@ -960,8 +960,8 @@ cmd_find_target(struct cmd_find_state *fs, struct cmdq_item *item,
if (server_check_marked() && (flags & CMD_FIND_DEFAULT_MARKED)) { if (server_check_marked() && (flags & CMD_FIND_DEFAULT_MARKED)) {
fs->current = &marked_pane; fs->current = &marked_pane;
log_debug("%s: current is marked pane", __func__); log_debug("%s: current is marked pane", __func__);
} else if (cmd_find_valid_state(&cmdq_get_shared(item)->current)) { } else if (cmd_find_valid_state(&cmdq_get_state(item)->current)) {
fs->current = &cmdq_get_shared(item)->current; fs->current = &cmdq_get_state(item)->current;
log_debug("%s: current is from queue", __func__); log_debug("%s: current is from queue", __func__);
} else if (cmd_find_from_client(&current, cmdq_get_client(item), } else if (cmd_find_from_client(&current, cmdq_get_client(item),
flags) == 0) { flags) == 0) {
@@ -981,7 +981,7 @@ cmd_find_target(struct cmd_find_state *fs, struct cmdq_item *item,
/* Mouse target is a plain = or {mouse}. */ /* Mouse target is a plain = or {mouse}. */
if (strcmp(target, "=") == 0 || strcmp(target, "{mouse}") == 0) { if (strcmp(target, "=") == 0 || strcmp(target, "{mouse}") == 0) {
m = &cmdq_get_shared(item)->mouse; m = &cmdq_get_state(item)->event.m;
switch (type) { switch (type) {
case CMD_FIND_PANE: case CMD_FIND_PANE:
fs->wp = cmd_mouse_pane(m, &fs->s, &fs->wl); fs->wp = cmd_mouse_pane(m, &fs->s, &fs->wl);

View File

@@ -63,9 +63,9 @@ static enum cmd_retval
cmd_if_shell_exec(struct cmd *self, struct cmdq_item *item) cmd_if_shell_exec(struct cmd *self, struct cmdq_item *item)
{ {
struct args *args = cmd_get_args(self); struct args *args = cmd_get_args(self);
struct cmdq_shared *shared = cmdq_get_shared(item); struct cmdq_state *state = cmdq_get_state(item);
struct cmd_find_state *target = cmdq_get_target(item); struct cmd_find_state *target = cmdq_get_target(item);
struct mouse_event *m = &shared->mouse; struct mouse_event *m = &state->event.m;
struct cmd_if_shell_data *cdata; struct cmd_if_shell_data *cdata;
char *shellcmd, *cmd; char *shellcmd, *cmd;
const char *file; const char *file;

View File

@@ -63,8 +63,8 @@ static enum cmd_retval
cmd_join_pane_exec(struct cmd *self, struct cmdq_item *item) cmd_join_pane_exec(struct cmd *self, struct cmdq_item *item)
{ {
struct args *args = cmd_get_args(self); struct args *args = cmd_get_args(self);
struct cmdq_shared *shared = cmdq_get_shared(item); struct cmdq_state *state = cmdq_get_state(item);
struct cmd_find_state *current = &shared->current; struct cmd_find_state *current = &state->current;
struct cmd_find_state *target = cmdq_get_target(item); struct cmd_find_state *target = cmdq_get_target(item);
struct cmd_find_state *source = cmdq_get_source(item); struct cmd_find_state *source = cmdq_get_source(item);
struct session *dst_s; struct session *dst_s;

View File

@@ -67,8 +67,8 @@ static enum cmd_retval
cmd_new_session_exec(struct cmd *self, struct cmdq_item *item) cmd_new_session_exec(struct cmd *self, struct cmdq_item *item)
{ {
struct args *args = cmd_get_args(self); struct args *args = cmd_get_args(self);
struct cmdq_shared *shared = cmdq_get_shared(item); struct cmdq_state *state = cmdq_get_state(item);
struct cmd_find_state *current = &shared->current; struct cmd_find_state *current = &state->current;
struct cmd_find_state *target = cmdq_get_target(item); struct cmd_find_state *target = cmdq_get_target(item);
struct client *c = cmdq_get_client(item); struct client *c = cmdq_get_client(item);
struct session *s, *as, *groupwith; struct session *s, *as, *groupwith;
@@ -317,7 +317,7 @@ cmd_new_session_exec(struct cmd *self, struct cmdq_item *item)
} else if (c->session != NULL) } else if (c->session != NULL)
c->last_session = c->session; c->last_session = c->session;
c->session = s; c->session = s;
if (~shared->flags & CMDQ_SHARED_REPEAT) if (~state->flags & CMDQ_STATE_REPEAT)
server_client_set_key_table(c, NULL); server_client_set_key_table(c, NULL);
tty_update_client_offset(c); tty_update_client_offset(c);
status_timer_start(c); status_timer_start(c);

View File

@@ -52,8 +52,8 @@ static enum cmd_retval
cmd_new_window_exec(struct cmd *self, struct cmdq_item *item) cmd_new_window_exec(struct cmd *self, struct cmdq_item *item)
{ {
struct args *args = cmd_get_args(self); struct args *args = cmd_get_args(self);
struct cmdq_shared *shared = cmdq_get_shared(item); struct cmdq_state *state = cmdq_get_state(item);
struct cmd_find_state *current = &shared->current; struct cmd_find_state *current = &state->current;
struct cmd_find_state *target = cmdq_get_target(item); struct cmd_find_state *target = cmdq_get_target(item);
struct spawn_context sc; struct spawn_context sc;
struct client *c = cmd_find_client(item, NULL, 1); struct client *c = cmd_find_client(item, NULL, 1);

View File

@@ -25,6 +25,10 @@
#include "tmux.h" #include "tmux.h"
/* Command queue flags. */
#define CMDQ_FIRED 0x1
#define CMDQ_WAITING 0x2
/* Command queue item type. */ /* Command queue item type. */
enum cmdq_type { enum cmdq_type {
CMDQ_COMMAND, CMDQ_COMMAND,
@@ -47,7 +51,7 @@ struct cmdq_item {
int flags; int flags;
struct cmdq_shared *shared; struct cmdq_state *state;
struct cmd_find_state source; struct cmd_find_state source;
struct cmd_find_state target; struct cmd_find_state target;
@@ -138,11 +142,11 @@ cmdq_get_source(struct cmdq_item *item)
return (&item->source); return (&item->source);
} }
/* Get item shared. */ /* Get item state. */
struct cmdq_shared * struct cmdq_state *
cmdq_get_shared(struct cmdq_item *item) cmdq_get_state(struct cmdq_item *item)
{ {
return (item->shared); return (item->state);
} }
/* Merge formats from item. */ /* Merge formats from item. */
@@ -155,8 +159,8 @@ cmdq_merge_formats(struct cmdq_item *item, struct format_tree *ft)
entry = cmd_get_entry (item->cmd); entry = cmd_get_entry (item->cmd);
format_add(ft, "command", "%s", entry->name); format_add(ft, "command", "%s", entry->name);
} }
if (item->shared->formats != NULL) if (item->state->formats != NULL)
format_merge(ft, item->shared->formats); format_merge(ft, item->state->formats);
} }
/* Append an item. */ /* Append an item. */
@@ -224,7 +228,7 @@ cmdq_insert_hook(struct session *s, struct cmdq_item *item,
struct options_array_item *a; struct options_array_item *a;
struct cmd_list *cmdlist; struct cmd_list *cmdlist;
if (item->flags & CMDQ_NOHOOKS) if (item->state->flags & CMDQ_STATE_NOHOOKS)
return; return;
if (s == NULL) if (s == NULL)
oo = global_s_options; oo = global_s_options;
@@ -250,7 +254,8 @@ cmdq_insert_hook(struct session *s, struct cmdq_item *item,
continue; continue;
} }
new_item = cmdq_get_command(cmdlist, fs, NULL, CMDQ_NOHOOKS); new_item = cmdq_get_command(cmdlist, fs, NULL,
CMDQ_STATE_NOHOOKS);
cmdq_format(new_item, "hook", "%s", name); cmdq_format(new_item, "hook", "%s", name);
if (item != NULL) if (item != NULL)
item = cmdq_insert_after(item, new_item); item = cmdq_insert_after(item, new_item);
@@ -274,10 +279,10 @@ cmdq_continue(struct cmdq_item *item)
static void static void
cmdq_remove(struct cmdq_item *item) cmdq_remove(struct cmdq_item *item)
{ {
if (item->shared != NULL && --item->shared->references == 0) { if (item->state != NULL && --item->state->references == 0) {
if (item->shared->formats != NULL) if (item->state->formats != NULL)
format_free(item->shared->formats); format_free(item->state->formats);
free(item->shared); free(item->state);
} }
if (item->client != NULL) if (item->client != NULL)
@@ -317,19 +322,23 @@ cmdq_get_command(struct cmd_list *cmdlist, struct cmd_find_state *current,
struct cmdq_item *item, *first = NULL, *last = NULL; struct cmdq_item *item, *first = NULL, *last = NULL;
struct cmd *cmd; struct cmd *cmd;
const struct cmd_entry *entry; const struct cmd_entry *entry;
struct cmdq_shared *shared = NULL; struct cmdq_state *state = NULL;
u_int group, last_group = 0; u_int group, last_group = 0;
cmd = cmd_list_first(cmdlist, &group); cmd = cmd_list_first(cmdlist, &group);
while (cmd != NULL) { while (cmd != NULL) {
if (group != last_group) { if (group != last_group) {
shared = xcalloc(1, sizeof *shared); state = xcalloc(1, sizeof *state);
if (current != NULL) if (current != NULL)
cmd_find_copy_state(&shared->current, current); cmd_find_copy_state(&state->current, current);
else else
cmd_find_clear_state(&shared->current, 0); cmd_find_clear_state(&state->current, 0);
if (m != NULL) if (m != NULL) {
memcpy(&shared->mouse, m, sizeof shared->mouse); state->event.key = KEYC_NONE;
memcpy(&state->event.m, m,
sizeof state->event.m);
}
state->flags = flags;
last_group = group; last_group = group;
} }
entry = cmd_get_entry(cmd); entry = cmd_get_entry(cmd);
@@ -337,17 +346,15 @@ cmdq_get_command(struct cmd_list *cmdlist, struct cmd_find_state *current,
item = xcalloc(1, sizeof *item); item = xcalloc(1, sizeof *item);
xasprintf(&item->name, "[%s/%p]", entry->name, item); xasprintf(&item->name, "[%s/%p]", entry->name, item);
item->type = CMDQ_COMMAND; item->type = CMDQ_COMMAND;
item->group = group; item->group = group;
item->flags = flags;
item->shared = shared; item->state = state;
item->cmdlist = cmdlist; item->cmdlist = cmdlist;
item->cmd = cmd; item->cmd = cmd;
log_debug("%s: %s group %u", __func__, item->name, item->group); log_debug("%s: %s group %u", __func__, item->name, item->group);
shared->references++; state->references++;
cmdlist->references++; cmdlist->references++;
if (first == NULL) if (first == NULL)
@@ -387,7 +394,7 @@ cmdq_fire_command(struct cmdq_item *item)
{ {
struct client *c = item->client; struct client *c = item->client;
const char *name = cmdq_name(c); const char *name = cmdq_name(c);
struct cmdq_shared *shared = item->shared; struct cmdq_state *state = item->state;
struct cmd *cmd = item->cmd; struct cmd *cmd = item->cmd;
const struct cmd_entry *entry = cmd_get_entry(cmd); const struct cmd_entry *entry = cmd_get_entry(cmd);
enum cmd_retval retval; enum cmd_retval retval;
@@ -401,7 +408,7 @@ cmdq_fire_command(struct cmdq_item *item)
free(tmp); free(tmp);
} }
flags = !!(shared->flags & CMDQ_SHARED_CONTROL); flags = !!(state->flags & CMDQ_STATE_CONTROL);
cmdq_guard(item, "begin", flags); cmdq_guard(item, "begin", flags);
if (item->client == NULL) if (item->client == NULL)
@@ -420,8 +427,8 @@ cmdq_fire_command(struct cmdq_item *item)
if (entry->flags & CMD_AFTERHOOK) { if (entry->flags & CMD_AFTERHOOK) {
if (cmd_find_valid_state(&item->target)) if (cmd_find_valid_state(&item->target))
fsp = &item->target; fsp = &item->target;
else if (cmd_find_valid_state(&item->shared->current)) else if (cmd_find_valid_state(&item->state->current))
fsp = &item->shared->current; fsp = &item->state->current;
else if (cmd_find_from_client(&fs, item->client, 0) == 0) else if (cmd_find_from_client(&fs, item->client, 0) == 0)
fsp = &fs; fsp = &fs;
else else
@@ -447,9 +454,7 @@ cmdq_get_callback1(const char *name, cmdq_cb cb, void *data)
item = xcalloc(1, sizeof *item); item = xcalloc(1, sizeof *item);
xasprintf(&item->name, "[%s/%p]", name, item); xasprintf(&item->name, "[%s/%p]", name, item);
item->type = CMDQ_CALLBACK; item->type = CMDQ_CALLBACK;
item->group = 0; item->group = 0;
item->flags = 0;
item->cb = cb; item->cb = cb;
item->data = data; item->data = data;
@@ -487,7 +492,7 @@ cmdq_fire_callback(struct cmdq_item *item)
void void
cmdq_format(struct cmdq_item *item, const char *key, const char *fmt, ...) cmdq_format(struct cmdq_item *item, const char *key, const char *fmt, ...)
{ {
struct cmdq_shared *shared = item->shared; struct cmdq_state *state = item->state;
va_list ap; va_list ap;
char *value; char *value;
@@ -495,9 +500,9 @@ cmdq_format(struct cmdq_item *item, const char *key, const char *fmt, ...)
xvasprintf(&value, fmt, ap); xvasprintf(&value, fmt, ap);
va_end(ap); va_end(ap);
if (shared->formats == NULL) if (state->formats == NULL)
shared->formats = format_create(NULL, NULL, FORMAT_NONE, 0); state->formats = format_create(NULL, NULL, FORMAT_NONE, 0);
format_add(shared->formats, key, "%s", value); format_add(state->formats, key, "%s", value);
free(value); free(value);
} }

View File

@@ -50,7 +50,7 @@ static enum cmd_retval
cmd_resize_pane_exec(struct cmd *self, struct cmdq_item *item) cmd_resize_pane_exec(struct cmd *self, struct cmdq_item *item)
{ {
struct args *args = cmd_get_args(self); struct args *args = cmd_get_args(self);
struct cmdq_shared *shared = cmdq_get_shared(item); struct cmdq_state *state = cmdq_get_state(item);
struct cmd_find_state *target = cmdq_get_target(item); struct cmd_find_state *target = cmdq_get_target(item);
struct window_pane *wp = target->wp; struct window_pane *wp = target->wp;
struct winlink *wl = target->wl; struct winlink *wl = target->wl;
@@ -76,12 +76,12 @@ cmd_resize_pane_exec(struct cmd *self, struct cmdq_item *item)
} }
if (args_has(args, 'M')) { if (args_has(args, 'M')) {
if (cmd_mouse_window(&shared->mouse, &s) == NULL) if (cmd_mouse_window(&state->event.m, &s) == NULL)
return (CMD_RETURN_NORMAL); return (CMD_RETURN_NORMAL);
if (c == NULL || c->session != s) if (c == NULL || c->session != s)
return (CMD_RETURN_NORMAL); return (CMD_RETURN_NORMAL);
c->tty.mouse_drag_update = cmd_resize_pane_mouse_update; c->tty.mouse_drag_update = cmd_resize_pane_mouse_update;
cmd_resize_pane_mouse_update(c, &shared->mouse); cmd_resize_pane_mouse_update(c, &state->event.m);
return (CMD_RETURN_NORMAL); return (CMD_RETURN_NORMAL);
} }

View File

@@ -44,8 +44,8 @@ static enum cmd_retval
cmd_rotate_window_exec(struct cmd *self, struct cmdq_item *item) cmd_rotate_window_exec(struct cmd *self, struct cmdq_item *item)
{ {
struct args *args = cmd_get_args(self); struct args *args = cmd_get_args(self);
struct cmdq_shared *shared = cmdq_get_shared(item); struct cmdq_state *state = cmdq_get_state(item);
struct cmd_find_state *current = &shared->current; struct cmd_find_state *current = &state->current;
struct cmd_find_state *target = cmdq_get_target(item); struct cmd_find_state *target = cmdq_get_target(item);
struct winlink *wl = target->wl; struct winlink *wl = target->wl;
struct window *w = wl->window; struct window *w = wl->window;

View File

@@ -85,8 +85,8 @@ cmd_select_pane_exec(struct cmd *self, struct cmdq_item *item)
{ {
struct args *args = cmd_get_args(self); struct args *args = cmd_get_args(self);
const struct cmd_entry *entry = cmd_get_entry(self); const struct cmd_entry *entry = cmd_get_entry(self);
struct cmdq_shared *shared = cmdq_get_shared(item); struct cmdq_state *state = cmdq_get_state(item);
struct cmd_find_state *current = &shared->current; struct cmd_find_state *current = &state->current;
struct cmd_find_state *target = cmdq_get_target(item); struct cmd_find_state *target = cmdq_get_target(item);
struct client *c = cmd_find_client(item, NULL, 1); struct client *c = cmd_find_client(item, NULL, 1);
struct winlink *wl = target->wl; struct winlink *wl = target->wl;

View File

@@ -85,8 +85,8 @@ static enum cmd_retval
cmd_select_window_exec(struct cmd *self, struct cmdq_item *item) cmd_select_window_exec(struct cmd *self, struct cmdq_item *item)
{ {
struct args *args = cmd_get_args(self); struct args *args = cmd_get_args(self);
struct cmdq_shared *shared = cmdq_get_shared(item); struct cmdq_state *state = cmdq_get_state(item);
struct cmd_find_state *current = &shared->current; struct cmd_find_state *current = &state->current;
struct cmd_find_state *target = cmdq_get_target(item); struct cmd_find_state *target = cmdq_get_target(item);
struct winlink *wl = target->wl; struct winlink *wl = target->wl;
struct session *s = target->s; struct session *s = target->s;

View File

@@ -134,13 +134,13 @@ static enum cmd_retval
cmd_send_keys_exec(struct cmd *self, struct cmdq_item *item) cmd_send_keys_exec(struct cmd *self, struct cmdq_item *item)
{ {
struct args *args = cmd_get_args(self); struct args *args = cmd_get_args(self);
struct cmdq_shared *shared = cmdq_get_shared(item); struct cmdq_state *state = cmdq_get_state(item);
struct cmd_find_state *target = cmdq_get_target(item); struct cmd_find_state *target = cmdq_get_target(item);
struct client *c = cmd_find_client(item, NULL, 1); struct client *c = cmd_find_client(item, NULL, 1);
struct window_pane *wp = target->wp; struct window_pane *wp = target->wp;
struct session *s = target->s; struct session *s = target->s;
struct winlink *wl = target->wl; struct winlink *wl = target->wl;
struct mouse_event *m = &shared->mouse; struct mouse_event *m = &state->event.m;
struct window_mode_entry *wme = TAILQ_FIRST(&wp->modes); struct window_mode_entry *wme = TAILQ_FIRST(&wp->modes);
int i; int i;
key_code key; key_code key;

View File

@@ -53,8 +53,8 @@ static enum cmd_retval
cmd_split_window_exec(struct cmd *self, struct cmdq_item *item) cmd_split_window_exec(struct cmd *self, struct cmdq_item *item)
{ {
struct args *args = cmd_get_args(self); struct args *args = cmd_get_args(self);
struct cmdq_shared *shared = cmdq_get_shared(item); struct cmdq_state *state = cmdq_get_state(item);
struct cmd_find_state *current = &shared->current; struct cmd_find_state *current = &state->current;
struct cmd_find_state *target = cmdq_get_target(item); struct cmd_find_state *target = cmdq_get_target(item);
struct spawn_context sc; struct spawn_context sc;
struct client *c = cmd_find_client(item, NULL, 1); struct client *c = cmd_find_client(item, NULL, 1);

View File

@@ -48,8 +48,8 @@ static enum cmd_retval
cmd_switch_client_exec(struct cmd *self, struct cmdq_item *item) cmd_switch_client_exec(struct cmd *self, struct cmdq_item *item)
{ {
struct args *args = cmd_get_args(self); struct args *args = cmd_get_args(self);
struct cmdq_shared *shared = cmdq_get_shared(item); struct cmdq_state *state = cmdq_get_state(item);
struct cmd_find_state *current = &shared->current; struct cmd_find_state *current = &state->current;
struct cmd_find_state target; struct cmd_find_state target;
const char *tflag = args_get(args, 't'); const char *tflag = args_get(args, 't');
enum cmd_find_type type; enum cmd_find_type type;
@@ -137,7 +137,7 @@ cmd_switch_client_exec(struct cmd *self, struct cmdq_item *item)
if (c->session != NULL && c->session != s) if (c->session != NULL && c->session != s)
c->last_session = c->session; c->last_session = c->session;
c->session = s; c->session = s;
if (~shared->flags & CMDQ_SHARED_REPEAT) if (~state->flags & CMDQ_STATE_REPEAT)
server_client_set_key_table(c, NULL); server_client_set_key_table(c, NULL);
tty_update_client_offset(c); tty_update_client_offset(c);
status_timer_start(c); status_timer_start(c);

View File

@@ -86,7 +86,7 @@ control_callback(__unused struct client *c, __unused const char *path,
break; break;
case CMD_PARSE_SUCCESS: case CMD_PARSE_SUCCESS:
item = cmdq_get_command(pr->cmdlist, NULL, NULL, 0); item = cmdq_get_command(pr->cmdlist, NULL, NULL, 0);
cmdq_get_shared(item)->flags |= CMDQ_SHARED_CONTROL; cmdq_get_state(item)->flags |= CMDQ_STATE_CONTROL;
cmdq_append(c, item); cmdq_append(c, item);
cmd_list_free(pr->cmdlist); cmd_list_free(pr->cmdlist);
break; break;

View File

@@ -1124,16 +1124,16 @@ format_merge(struct format_tree *ft, struct format_tree *from)
static void static void
format_create_add_item(struct format_tree *ft, struct cmdq_item *item) format_create_add_item(struct format_tree *ft, struct cmdq_item *item)
{ {
struct cmdq_shared *shared = cmdq_get_shared(item); struct cmdq_state *state = cmdq_get_state(item);
struct mouse_event *m; struct mouse_event *m;
struct window_pane *wp; struct window_pane *wp;
u_int x, y; u_int x, y;
cmdq_merge_formats(item, ft); cmdq_merge_formats(item, ft);
if (shared == NULL) if (state == NULL)
return; return;
m = &shared->mouse; m = &state->event.m;
if (m->valid && ((wp = cmd_mouse_pane(m, NULL, NULL)) != NULL)) { if (m->valid && ((wp = cmd_mouse_pane(m, NULL, NULL)) != NULL)) {
format_add(ft, "mouse_pane", "%%%u", wp->id); format_add(ft, "mouse_pane", "%%%u", wp->id);
if (cmd_mouse_at(wp, m, &x, &y, 0) == 0) { if (cmd_mouse_at(wp, m, &x, &y, 0) == 0) {

View File

@@ -549,7 +549,7 @@ key_bindings_dispatch(struct key_binding *bd, struct cmdq_item *item,
else { else {
new_item = cmdq_get_command(bd->cmdlist, fs, m, 0); new_item = cmdq_get_command(bd->cmdlist, fs, m, 0);
if (bd->flags & KEY_BINDING_REPEAT) if (bd->flags & KEY_BINDING_REPEAT)
cmdq_get_shared(new_item)->flags |= CMDQ_SHARED_REPEAT; cmdq_get_state(new_item)->flags |= CMDQ_STATE_REPEAT;
} }
if (item != NULL) if (item != NULL)
new_item = cmdq_insert_after(item, new_item); new_item = cmdq_insert_after(item, new_item);

2
menu.c
View File

@@ -282,7 +282,7 @@ chosen:
break; break;
case CMD_PARSE_SUCCESS: case CMD_PARSE_SUCCESS:
if (md->item != NULL) if (md->item != NULL)
m = &cmdq_get_shared(md->item)->mouse; m = &cmdq_get_state(md->item)->event.m;
else else
m = NULL; m = NULL;
new_item = cmdq_get_command(pr->cmdlist, &md->fs, m, 0); new_item = cmdq_get_command(pr->cmdlist, &md->fs, m, 0);

View File

@@ -94,7 +94,8 @@ notify_insert_hook(struct cmdq_item *item, struct notify_entry *ne)
continue; continue;
} }
new_item = cmdq_get_command(cmdlist, &fs, NULL, CMDQ_NOHOOKS); new_item = cmdq_get_command(cmdlist, &fs, NULL,
CMDQ_STATE_NOHOOKS);
cmdq_format(new_item, "hook", "%s", ne->name); cmdq_format(new_item, "hook", "%s", ne->name);
notify_hook_formats(new_item, s, w, ne->pane); notify_hook_formats(new_item, s, w, ne->pane);
item = cmdq_insert_after(item, new_item); item = cmdq_insert_after(item, new_item);

View File

@@ -305,7 +305,7 @@ popup_key_cb(struct client *c, struct key_event *event)
break; break;
case CMD_PARSE_SUCCESS: case CMD_PARSE_SUCCESS:
if (pd->item != NULL) if (pd->item != NULL)
m = &cmdq_get_shared(pd->item)->mouse; m = &cmdq_get_state(pd->item)->event.m;
else else
m = NULL; m = NULL;
new_item = cmdq_get_command(pr->cmdlist, fs, m, 0); new_item = cmdq_get_command(pr->cmdlist, fs, m, 0);

18
tmux.h
View File

@@ -1380,25 +1380,21 @@ struct cmd_parse_input {
struct cmd_find_state fs; struct cmd_find_state fs;
}; };
/* Command queue item shared state. */ /* Command queue item state. */
struct cmdq_shared { struct cmdq_state {
int references; int references;
int flags; int flags;
#define CMDQ_SHARED_REPEAT 0x1 #define CMDQ_STATE_REPEAT 0x1
#define CMDQ_SHARED_CONTROL 0x2 #define CMDQ_STATE_CONTROL 0x2
#define CMDQ_STATE_NOHOOKS 0x4
struct format_tree *formats; struct format_tree *formats;
struct mouse_event mouse; struct key_event event;
struct cmd_find_state current; struct cmd_find_state current;
}; };
/* Command queue flags. */
#define CMDQ_FIRED 0x1
#define CMDQ_WAITING 0x2
#define CMDQ_NOHOOKS 0x4
/* Command queue callback. */ /* Command queue callback. */
typedef enum cmd_retval (*cmdq_cb) (struct cmdq_item *, void *); typedef enum cmd_retval (*cmdq_cb) (struct cmdq_item *, void *);
@@ -2114,7 +2110,7 @@ const char *cmdq_get_name(struct cmdq_item *);
struct client *cmdq_get_client(struct cmdq_item *); struct client *cmdq_get_client(struct cmdq_item *);
struct cmd_find_state *cmdq_get_target(struct cmdq_item *); struct cmd_find_state *cmdq_get_target(struct cmdq_item *);
struct cmd_find_state *cmdq_get_source(struct cmdq_item *); struct cmd_find_state *cmdq_get_source(struct cmdq_item *);
struct cmdq_shared *cmdq_get_shared(struct cmdq_item *); struct cmdq_state *cmdq_get_state(struct cmdq_item *);
void cmdq_merge_formats(struct cmdq_item *, struct format_tree *); void cmdq_merge_formats(struct cmdq_item *, struct format_tree *);
struct cmdq_item *cmdq_get_command(struct cmd_list *, struct cmd_find_state *, struct cmdq_item *cmdq_get_command(struct cmd_list *, struct cmd_find_state *,
struct mouse_event *, int); struct mouse_event *, int);