mirror of
				https://github.com/tmux/tmux.git
				synced 2025-11-04 01:34:18 +00:00 
			
		
		
		
	Pass in the session, rather than the client, to window modes' key() function.
We were only ever using the client to find the session anyway.
This commit is contained in:
		@@ -1,4 +1,4 @@
 | 
			
		||||
/* $Id: cmd-send-keys.c,v 1.24 2009-12-04 22:14:47 tcunha Exp $ */
 | 
			
		||||
/* $Id: cmd-send-keys.c,v 1.25 2010-05-22 21:56:04 micahcowan Exp $ */
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
 * Copyright (c) 2008 Nicholas Marriott <nicm@users.sourceforge.net>
 | 
			
		||||
@@ -105,16 +105,17 @@ cmd_send_keys_exec(struct cmd *self, struct cmd_ctx *ctx)
 | 
			
		||||
{
 | 
			
		||||
	struct cmd_send_keys_data	*data = self->data;
 | 
			
		||||
	struct window_pane		*wp;
 | 
			
		||||
	struct session			*s;
 | 
			
		||||
	u_int				 i;
 | 
			
		||||
 | 
			
		||||
	if (data == NULL)
 | 
			
		||||
		return (-1);
 | 
			
		||||
 | 
			
		||||
	if (cmd_find_pane(ctx, data->target, NULL, &wp) == NULL)
 | 
			
		||||
	if (cmd_find_pane(ctx, data->target, &s, &wp) == NULL)
 | 
			
		||||
		return (-1);
 | 
			
		||||
 | 
			
		||||
	for (i = 0; i < data->nkeys; i++)
 | 
			
		||||
		window_pane_key(wp, ctx->curclient, data->keys[i]);
 | 
			
		||||
		window_pane_key(wp, s, data->keys[i]);
 | 
			
		||||
 | 
			
		||||
	return (0);
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -1,4 +1,4 @@
 | 
			
		||||
/* $Id: cmd-send-prefix.c,v 1.28 2009-11-14 17:56:39 tcunha Exp $ */
 | 
			
		||||
/* $Id: cmd-send-prefix.c,v 1.29 2010-05-22 21:56:04 micahcowan Exp $ */
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
 * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
 | 
			
		||||
@@ -49,7 +49,7 @@ cmd_send_prefix_exec(struct cmd *self, struct cmd_ctx *ctx)
 | 
			
		||||
		return (-1);
 | 
			
		||||
 | 
			
		||||
	keylist = options_get_data(&s->options, "prefix");
 | 
			
		||||
	window_pane_key(wp, ctx->curclient, ARRAY_FIRST(keylist));
 | 
			
		||||
	window_pane_key(wp, s, ARRAY_FIRST(keylist));
 | 
			
		||||
 | 
			
		||||
	return (0);
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -1,4 +1,4 @@
 | 
			
		||||
/* $Id: server-client.c,v 1.31 2010-02-08 18:27:34 tcunha Exp $ */
 | 
			
		||||
/* $Id: server-client.c,v 1.32 2010-05-22 21:56:04 micahcowan Exp $ */
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
 * Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
 | 
			
		||||
@@ -299,7 +299,7 @@ server_client_handle_key(int key, struct mouse_event *mouse, void *data)
 | 
			
		||||
			server_redraw_window_borders(w);
 | 
			
		||||
			wp = w->active;
 | 
			
		||||
		}
 | 
			
		||||
		window_pane_mouse(wp, c, mouse);
 | 
			
		||||
		window_pane_mouse(wp, c->session, mouse);
 | 
			
		||||
		return;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
@@ -321,7 +321,7 @@ server_client_handle_key(int key, struct mouse_event *mouse, void *data)
 | 
			
		||||
			/* Try as a non-prefix key binding. */
 | 
			
		||||
			if ((bd = key_bindings_lookup(key)) == NULL) {
 | 
			
		||||
				if (!(c->flags & CLIENT_READONLY))
 | 
			
		||||
					window_pane_key(wp, c, key);
 | 
			
		||||
					window_pane_key(wp, c->session, key);
 | 
			
		||||
			} else
 | 
			
		||||
				key_bindings_dispatch(bd, c);
 | 
			
		||||
		}
 | 
			
		||||
@@ -337,7 +337,7 @@ server_client_handle_key(int key, struct mouse_event *mouse, void *data)
 | 
			
		||||
			if (isprefix)
 | 
			
		||||
				c->flags |= CLIENT_PREFIX;
 | 
			
		||||
			else if (!(c->flags & CLIENT_READONLY))
 | 
			
		||||
				window_pane_key(wp, c, key);
 | 
			
		||||
				window_pane_key(wp, c->session, key);
 | 
			
		||||
		}
 | 
			
		||||
		return;
 | 
			
		||||
	}
 | 
			
		||||
@@ -348,7 +348,7 @@ server_client_handle_key(int key, struct mouse_event *mouse, void *data)
 | 
			
		||||
		if (isprefix)
 | 
			
		||||
			c->flags |= CLIENT_PREFIX;
 | 
			
		||||
		else if (!(c->flags & CLIENT_READONLY))
 | 
			
		||||
			window_pane_key(wp, c, key);
 | 
			
		||||
			window_pane_key(wp, c->session, key);
 | 
			
		||||
		return;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										12
									
								
								tmux.h
									
									
									
									
									
								
							
							
						
						
									
										12
									
								
								tmux.h
									
									
									
									
									
								
							@@ -1,4 +1,4 @@
 | 
			
		||||
/* $Id: tmux.h,v 1.557 2010-05-14 14:33:39 tcunha Exp $ */
 | 
			
		||||
/* $Id: tmux.h,v 1.558 2010-05-22 21:56:04 micahcowan Exp $ */
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
 * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
 | 
			
		||||
@@ -759,16 +759,16 @@ struct input_ctx {
 | 
			
		||||
 * Window mode. Windows can be in several modes and this is used to call the
 | 
			
		||||
 * right function to handle input and output.
 | 
			
		||||
 */
 | 
			
		||||
struct client;
 | 
			
		||||
struct session;
 | 
			
		||||
struct window;
 | 
			
		||||
struct mouse_event;
 | 
			
		||||
struct window_mode {
 | 
			
		||||
	struct screen *(*init)(struct window_pane *);
 | 
			
		||||
	void	(*free)(struct window_pane *);
 | 
			
		||||
	void	(*resize)(struct window_pane *, u_int, u_int);
 | 
			
		||||
	void	(*key)(struct window_pane *, struct client *, int);
 | 
			
		||||
	void	(*key)(struct window_pane *, struct session *, int);
 | 
			
		||||
	void	(*mouse)(struct window_pane *,
 | 
			
		||||
		    struct client *, struct mouse_event *);
 | 
			
		||||
		    struct session *, struct mouse_event *);
 | 
			
		||||
	void	(*timer)(struct window_pane *);
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
@@ -1827,9 +1827,9 @@ void		 window_pane_alternate_off(
 | 
			
		||||
int		 window_pane_set_mode(
 | 
			
		||||
		     struct window_pane *, const struct window_mode *);
 | 
			
		||||
void		 window_pane_reset_mode(struct window_pane *);
 | 
			
		||||
void		 window_pane_key(struct window_pane *, struct client *, int);
 | 
			
		||||
void		 window_pane_key(struct window_pane *, struct session *, int);
 | 
			
		||||
void		 window_pane_mouse(struct window_pane *,
 | 
			
		||||
		     struct client *, struct mouse_event *);
 | 
			
		||||
		     struct session *, struct mouse_event *);
 | 
			
		||||
int		 window_pane_visible(struct window_pane *);
 | 
			
		||||
char		*window_pane_search(
 | 
			
		||||
		     struct window_pane *, const char *, u_int *);
 | 
			
		||||
 
 | 
			
		||||
@@ -1,4 +1,4 @@
 | 
			
		||||
/* $Id: window-choose.c,v 1.29 2010-02-02 23:55:21 tcunha Exp $ */
 | 
			
		||||
/* $Id: window-choose.c,v 1.30 2010-05-22 21:56:04 micahcowan Exp $ */
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
 * Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
 | 
			
		||||
@@ -25,9 +25,9 @@
 | 
			
		||||
struct screen *window_choose_init(struct window_pane *);
 | 
			
		||||
void	window_choose_free(struct window_pane *);
 | 
			
		||||
void	window_choose_resize(struct window_pane *, u_int, u_int);
 | 
			
		||||
void	window_choose_key(struct window_pane *, struct client *, int);
 | 
			
		||||
void	window_choose_key(struct window_pane *, struct session *, int);
 | 
			
		||||
void	window_choose_mouse(
 | 
			
		||||
	    struct window_pane *, struct client *, struct mouse_event *);
 | 
			
		||||
	    struct window_pane *, struct session *, struct mouse_event *);
 | 
			
		||||
 | 
			
		||||
void	window_choose_redraw_screen(struct window_pane *);
 | 
			
		||||
void	window_choose_write_line(
 | 
			
		||||
@@ -171,7 +171,7 @@ window_choose_resize(struct window_pane *wp, u_int sx, u_int sy)
 | 
			
		||||
 | 
			
		||||
/* ARGSUSED */
 | 
			
		||||
void
 | 
			
		||||
window_choose_key(struct window_pane *wp, unused struct client *c, int key)
 | 
			
		||||
window_choose_key(struct window_pane *wp, unused struct session *sess, int key)
 | 
			
		||||
{
 | 
			
		||||
	struct window_choose_mode_data	*data = wp->modedata;
 | 
			
		||||
	struct screen			*s = &data->screen;
 | 
			
		||||
@@ -304,7 +304,7 @@ window_choose_key(struct window_pane *wp, unused struct client *c, int key)
 | 
			
		||||
/* ARGSUSED */
 | 
			
		||||
void
 | 
			
		||||
window_choose_mouse(
 | 
			
		||||
    struct window_pane *wp, unused struct client *c, struct mouse_event *m)
 | 
			
		||||
    struct window_pane *wp, unused struct session *sess, struct mouse_event *m)
 | 
			
		||||
{
 | 
			
		||||
	struct window_choose_mode_data	*data = wp->modedata;
 | 
			
		||||
	struct screen			*s = &data->screen;
 | 
			
		||||
 
 | 
			
		||||
@@ -1,4 +1,4 @@
 | 
			
		||||
/* $Id: window-clock.c,v 1.11 2009-12-04 22:14:47 tcunha Exp $ */
 | 
			
		||||
/* $Id: window-clock.c,v 1.12 2010-05-22 21:56:04 micahcowan Exp $ */
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
 * Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
 | 
			
		||||
@@ -26,7 +26,7 @@
 | 
			
		||||
struct screen *window_clock_init(struct window_pane *);
 | 
			
		||||
void	window_clock_free(struct window_pane *);
 | 
			
		||||
void	window_clock_resize(struct window_pane *, u_int, u_int);
 | 
			
		||||
void	window_clock_key(struct window_pane *, struct client *, int);
 | 
			
		||||
void	window_clock_key(struct window_pane *, struct session *, int);
 | 
			
		||||
void	window_clock_timer(struct window_pane *);
 | 
			
		||||
 | 
			
		||||
void	window_clock_draw_screen(struct window_pane *);
 | 
			
		||||
@@ -85,7 +85,7 @@ window_clock_resize(struct window_pane *wp, u_int sx, u_int sy)
 | 
			
		||||
/* ARGSUSED */
 | 
			
		||||
void
 | 
			
		||||
window_clock_key(
 | 
			
		||||
    struct window_pane *wp, unused struct client *c, unused int key)
 | 
			
		||||
    struct window_pane *wp, unused struct session *sess, unused int key)
 | 
			
		||||
{
 | 
			
		||||
	window_pane_reset_mode(wp);
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -1,4 +1,4 @@
 | 
			
		||||
/* $Id: window-copy.c,v 1.116 2010-04-28 14:29:27 micahcowan Exp $ */
 | 
			
		||||
/* $Id: window-copy.c,v 1.117 2010-05-22 21:56:04 micahcowan Exp $ */
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
 * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
 | 
			
		||||
@@ -26,11 +26,11 @@
 | 
			
		||||
struct screen *window_copy_init(struct window_pane *);
 | 
			
		||||
void	window_copy_free(struct window_pane *);
 | 
			
		||||
void	window_copy_resize(struct window_pane *, u_int, u_int);
 | 
			
		||||
void	window_copy_key(struct window_pane *, struct client *, int);
 | 
			
		||||
void	window_copy_key(struct window_pane *, struct session *, int);
 | 
			
		||||
int	window_copy_key_input(struct window_pane *, int);
 | 
			
		||||
int	window_copy_key_numeric_prefix(struct window_pane *, int);
 | 
			
		||||
void	window_copy_mouse(
 | 
			
		||||
	    struct window_pane *, struct client *, struct mouse_event *);
 | 
			
		||||
	    struct window_pane *, struct session *, struct mouse_event *);
 | 
			
		||||
 | 
			
		||||
void	window_copy_redraw_lines(struct window_pane *, u_int, u_int);
 | 
			
		||||
void	window_copy_redraw_screen(struct window_pane *);
 | 
			
		||||
@@ -52,7 +52,7 @@ void	window_copy_goto_line(struct window_pane *, const char *);
 | 
			
		||||
void	window_copy_update_cursor(struct window_pane *, u_int, u_int);
 | 
			
		||||
void	window_copy_start_selection(struct window_pane *);
 | 
			
		||||
int	window_copy_update_selection(struct window_pane *);
 | 
			
		||||
void	window_copy_copy_selection(struct window_pane *, struct client *);
 | 
			
		||||
void	window_copy_copy_selection(struct window_pane *, struct session *);
 | 
			
		||||
void	window_copy_clear_selection(struct window_pane *);
 | 
			
		||||
void	window_copy_copy_line(
 | 
			
		||||
	    struct window_pane *, char **, size_t *, u_int, u_int, u_int);
 | 
			
		||||
@@ -340,8 +340,6 @@ window_copy_resize(struct window_pane *wp, u_int sx, u_int sy)
 | 
			
		||||
		data->cy = sy - 1;
 | 
			
		||||
	if (data->cx > sx)
 | 
			
		||||
		data->cx = sx;
 | 
			
		||||
	if (data->oy > screen_hsize(data->backing))
 | 
			
		||||
		data->oy = screen_hsize(data->backing);
 | 
			
		||||
 | 
			
		||||
	window_copy_clear_selection(wp);
 | 
			
		||||
 | 
			
		||||
@@ -353,7 +351,7 @@ window_copy_resize(struct window_pane *wp, u_int sx, u_int sy)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void
 | 
			
		||||
window_copy_key(struct window_pane *wp, struct client *c, int key)
 | 
			
		||||
window_copy_key(struct window_pane *wp, struct session *sess, int key)
 | 
			
		||||
{
 | 
			
		||||
	const char			*word_separators;
 | 
			
		||||
	struct window_copy_mode_data	*data = wp->modedata;
 | 
			
		||||
@@ -503,8 +501,8 @@ window_copy_key(struct window_pane *wp, struct client *c, int key)
 | 
			
		||||
		window_copy_redraw_screen(wp);
 | 
			
		||||
		break;
 | 
			
		||||
	case MODEKEYCOPY_COPYSELECTION:
 | 
			
		||||
		if (c != NULL && c->session != NULL) {
 | 
			
		||||
			window_copy_copy_selection(wp, c);
 | 
			
		||||
		if (sess != NULL) {
 | 
			
		||||
			window_copy_copy_selection(wp, sess);
 | 
			
		||||
			window_pane_reset_mode(wp);
 | 
			
		||||
			return;
 | 
			
		||||
		}
 | 
			
		||||
@@ -758,7 +756,7 @@ window_copy_key_numeric_prefix(struct window_pane *wp, int key)
 | 
			
		||||
/* ARGSUSED */
 | 
			
		||||
void
 | 
			
		||||
window_copy_mouse(
 | 
			
		||||
    struct window_pane *wp, unused struct client *c, struct mouse_event *m)
 | 
			
		||||
    struct window_pane *wp, unused struct session *sess, struct mouse_event *m)
 | 
			
		||||
{
 | 
			
		||||
	struct window_copy_mode_data	*data = wp->modedata;
 | 
			
		||||
	struct screen			*s = &data->screen;
 | 
			
		||||
@@ -1169,7 +1167,7 @@ window_copy_update_selection(struct window_pane *wp)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void
 | 
			
		||||
window_copy_copy_selection(struct window_pane *wp, struct client *c)
 | 
			
		||||
window_copy_copy_selection(struct window_pane *wp, struct session *sess)
 | 
			
		||||
{
 | 
			
		||||
	struct window_copy_mode_data	*data = wp->modedata;
 | 
			
		||||
	struct screen			*s = &data->screen;
 | 
			
		||||
@@ -1264,8 +1262,8 @@ window_copy_copy_selection(struct window_pane *wp, struct client *c)
 | 
			
		||||
	off--;	/* remove final \n */
 | 
			
		||||
 | 
			
		||||
	/* Add the buffer to the stack. */
 | 
			
		||||
	limit = options_get_number(&c->session->options, "buffer-limit");
 | 
			
		||||
	paste_add(&c->session->buffers, buf, off, limit);
 | 
			
		||||
	limit = options_get_number(&sess->options, "buffer-limit");
 | 
			
		||||
	paste_add(&sess->buffers, buf, off, limit);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										10
									
								
								window.c
									
									
									
									
									
								
							
							
						
						
									
										10
									
								
								window.c
									
									
									
									
									
								
							@@ -1,4 +1,4 @@
 | 
			
		||||
/* $Id: window.c,v 1.131 2010-05-14 14:30:01 tcunha Exp $ */
 | 
			
		||||
/* $Id: window.c,v 1.132 2010-05-22 21:56:04 micahcowan Exp $ */
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
 * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
 | 
			
		||||
@@ -728,7 +728,7 @@ window_pane_reset_mode(struct window_pane *wp)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void
 | 
			
		||||
window_pane_key(struct window_pane *wp, struct client *c, int key)
 | 
			
		||||
window_pane_key(struct window_pane *wp, struct session *sess, int key)
 | 
			
		||||
{
 | 
			
		||||
	struct window_pane	*wp2;
 | 
			
		||||
 | 
			
		||||
@@ -737,7 +737,7 @@ window_pane_key(struct window_pane *wp, struct client *c, int key)
 | 
			
		||||
 | 
			
		||||
	if (wp->mode != NULL) {
 | 
			
		||||
		if (wp->mode->key != NULL)
 | 
			
		||||
			wp->mode->key(wp, c, key);
 | 
			
		||||
			wp->mode->key(wp, sess, key);
 | 
			
		||||
		return;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
@@ -756,7 +756,7 @@ window_pane_key(struct window_pane *wp, struct client *c, int key)
 | 
			
		||||
 | 
			
		||||
void
 | 
			
		||||
window_pane_mouse(
 | 
			
		||||
    struct window_pane *wp, struct client *c, struct mouse_event *m)
 | 
			
		||||
    struct window_pane *wp, struct session *sess, struct mouse_event *m)
 | 
			
		||||
{
 | 
			
		||||
	if (!window_pane_visible(wp))
 | 
			
		||||
		return;
 | 
			
		||||
@@ -770,7 +770,7 @@ window_pane_mouse(
 | 
			
		||||
 | 
			
		||||
	if (wp->mode != NULL) {
 | 
			
		||||
		if (wp->mode->mouse != NULL)
 | 
			
		||||
			wp->mode->mouse(wp, c, m);
 | 
			
		||||
			wp->mode->mouse(wp, sess, m);
 | 
			
		||||
	} else if (wp->fd != -1)
 | 
			
		||||
		input_mouse(wp, m);
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user