diff options
author | Nicholas Marriott <nicm@cvs.openbsd.org> | 2013-06-23 13:10:49 +0000 |
---|---|---|
committer | Nicholas Marriott <nicm@cvs.openbsd.org> | 2013-06-23 13:10:49 +0000 |
commit | f6e6c82d513f1ace1f553dfdb31c9e88975209a0 (patch) | |
tree | e56c6bd94aef74d2cb63ee92753d706a81cede99 /usr.bin/tmux | |
parent | 03cec82a5001a5a6c4649b6a2392f42f169a79d6 (diff) |
Focus events can cause trouble if left on and they can't be turned off
during idle periods (like the other states are) because we'd miss
events. So add a server option to control them. Defaults to off.
Diffstat (limited to 'usr.bin/tmux')
-rw-r--r-- | usr.bin/tmux/options-table.c | 7 | ||||
-rw-r--r-- | usr.bin/tmux/server-client.c | 6 | ||||
-rw-r--r-- | usr.bin/tmux/tmux.1 | 12 | ||||
-rw-r--r-- | usr.bin/tmux/tmux.h | 3 | ||||
-rw-r--r-- | usr.bin/tmux/tty.c | 16 |
5 files changed, 36 insertions, 8 deletions
diff --git a/usr.bin/tmux/options-table.c b/usr.bin/tmux/options-table.c index 1cb3effb433..2764bc097de 100644 --- a/usr.bin/tmux/options-table.c +++ b/usr.bin/tmux/options-table.c @@ -1,4 +1,4 @@ -/* $OpenBSD: options-table.c,v 1.37 2013/06/02 07:52:15 nicm Exp $ */ +/* $OpenBSD: options-table.c,v 1.38 2013/06/23 13:10:46 nicm Exp $ */ /* * Copyright (c) 2011 Nicholas Marriott <nicm@users.sourceforge.net> @@ -76,6 +76,11 @@ const struct options_table_entry server_options_table[] = { .default_num = 0 }, + { .name = "focus-events", + .type = OPTIONS_TABLE_FLAG, + .default_num = 0 + }, + { .name = "quiet", .type = OPTIONS_TABLE_FLAG, .default_num = 0 /* overridden in main() */ diff --git a/usr.bin/tmux/server-client.c b/usr.bin/tmux/server-client.c index 829fd8dbf59..e168dc120fc 100644 --- a/usr.bin/tmux/server-client.c +++ b/usr.bin/tmux/server-client.c @@ -1,4 +1,4 @@ -/* $OpenBSD: server-client.c,v 1.102 2013/06/23 12:51:28 nicm Exp $ */ +/* $OpenBSD: server-client.c,v 1.103 2013/06/23 13:10:46 nicm Exp $ */ /* * Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net> @@ -550,6 +550,10 @@ server_client_check_focus(struct window_pane *wp) struct client *c; int push; + /* Are focus events off? */ + if (!options_get_number(&global_options, "focus-events")) + return; + /* Do we need to push the focus state? */ push = wp->flags & PANE_FOCUSPUSH; wp->flags &= ~PANE_FOCUSPUSH; diff --git a/usr.bin/tmux/tmux.1 b/usr.bin/tmux/tmux.1 index a2c97bd6dbd..1c05808e47b 100644 --- a/usr.bin/tmux/tmux.1 +++ b/usr.bin/tmux/tmux.1 @@ -1,4 +1,4 @@ -.\" $OpenBSD: tmux.1,v 1.361 2013/06/02 14:40:17 jmc Exp $ +.\" $OpenBSD: tmux.1,v 1.362 2013/06/23 13:10:47 nicm Exp $ .\" .\" Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> .\" @@ -14,7 +14,7 @@ .\" IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING .\" OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. .\" -.Dd $Mdocdate: June 2 2013 $ +.Dd $Mdocdate: June 23 2013 $ .Dt TMUX 1 .Os .Sh NAME @@ -2092,6 +2092,14 @@ The default is 500 milliseconds. .Op Ic on | off .Xc If enabled, the server will exit when there are no attached clients. +.It Xo Ic focus-events +.Op Ic on | off +.Xc +When enabled, focus events are requested from the terminal if supported and +passed through to applications running in +.Nm . +Attached clients should be detached and attached again after changing this +option. .It Xo Ic quiet .Op Ic on | off .Xc diff --git a/usr.bin/tmux/tmux.h b/usr.bin/tmux/tmux.h index 26c052aa6cb..5b7b2b7816e 100644 --- a/usr.bin/tmux/tmux.h +++ b/usr.bin/tmux/tmux.h @@ -1,4 +1,4 @@ -/* $OpenBSD: tmux.h,v 1.413 2013/06/23 12:51:29 nicm Exp $ */ +/* $OpenBSD: tmux.h,v 1.414 2013/06/23 13:10:48 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -1233,6 +1233,7 @@ struct tty { #define TTY_UTF8 0x8 #define TTY_STARTED 0x10 #define TTY_OPENED 0x20 +#define TTY_FOCUS 0x40 int flags; int term_flags; diff --git a/usr.bin/tmux/tty.c b/usr.bin/tmux/tty.c index 0557ab37251..30881f1c0df 100644 --- a/usr.bin/tmux/tty.c +++ b/usr.bin/tmux/tty.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tty.c,v 1.161 2013/06/11 19:18:02 sthen Exp $ */ +/* $OpenBSD: tty.c,v 1.162 2013/06/23 13:10:48 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -219,8 +219,13 @@ tty_start_tty(struct tty *tty) if (tty_term_has(tty->term, TTYC_KMOUS)) tty_puts(tty, "\033[?1000l\033[?1006l\033[?1005l"); - if (tty_term_has(tty->term, TTYC_XT)) + if (tty_term_has(tty->term, TTYC_XT)) { + if (options_get_number(&global_options, "focus-events")) { + tty->flags |= TTY_FOCUS; + tty_puts(tty, "\033[?1004h"); + } tty_puts(tty, "\033[c\033[>4;1m\033[m"); + } tty->cx = UINT_MAX; tty->cy = UINT_MAX; @@ -282,8 +287,13 @@ tty_stop_tty(struct tty *tty) if (tty_term_has(tty->term, TTYC_KMOUS)) tty_raw(tty, "\033[?1000l\033[?1006l\033[?1005l"); - if (tty_term_has(tty->term, TTYC_XT)) + if (tty_term_has(tty->term, TTYC_XT)) { + if (tty->flags & TTY_FOCUS) { + tty->flags &= ~TTY_FOCUS; + tty_puts(tty, "\033[?1004l"); + } tty_raw(tty, "\033[>4m\033[m"); + } tty_raw(tty, tty_term_string(tty->term, TTYC_RMCUP)); |