The branch, master has been updated
via c7a121cfc0137c907b7bfb0c3fd1bdee395af8aa (commit)
via 777be296ee041e7d9131110e0489e791ed389ac1 (commit)
via a0172a6ae561fd6764fcfcdd975fc7a07f43dc79 (commit)
from 1099442c0a9751a00524895c42ba1508eced0b25 (commit)
- Log -----------------------------------------------------------------
commit c7a121cfc0137c907b7bfb0c3fd1bdee395af8aa
Author: Nicholas Marriott <[email protected]>
Commit: Thomas Adam <[email protected]>
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.
---
options-table.c | 5 +++++
server-client.c | 13 +++++++++++--
tmux.1 | 8 ++++++++
tmux.h | 5 +++++
tty.c | 14 ++++++++++++--
5 files changed, 41 insertions(+), 4 deletions(-)
diff --git a/options-table.c b/options-table.c
index fe21f16..2281d65 100644
--- a/options-table.c
+++ b/options-table.c
@@ -75,6 +75,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/server-client.c b/server-client.c
index 1c15a55..01616cb 100644
--- a/server-client.c
+++ b/server-client.c
@@ -548,6 +548,15 @@ server_client_check_focus(struct window_pane *wp)
{
u_int i;
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;
/* If we don't care about focus, forget it. */
if (!(wp->base.mode & MODE_FOCUSON))
@@ -580,13 +589,13 @@ server_client_check_focus(struct window_pane *wp)
}
not_focused:
- if (wp->flags & PANE_FOCUSED)
+ if (push || (wp->flags & PANE_FOCUSED))
bufferevent_write(wp->event, "\033[O", 3);
wp->flags &= ~PANE_FOCUSED;
return;
focused:
- if (!(wp->flags & PANE_FOCUSED))
+ if (push || !(wp->flags & PANE_FOCUSED))
bufferevent_write(wp->event, "\033[I", 3);
wp->flags |= PANE_FOCUSED;
}
diff --git a/tmux.1 b/tmux.1
index f644587..0aeb5a1 100644
--- a/tmux.1
+++ b/tmux.1
@@ -2096,6 +2096,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/tmux.h b/tmux.h
index cd40d4e..5dd86d3 100644
--- a/tmux.h
+++ b/tmux.h
@@ -934,6 +934,7 @@ struct window_pane {
#define PANE_DROP 0x2
#define PANE_FOCUSED 0x4
#define PANE_RESIZE 0x8
+#define PANE_FOCUSPUSH 0x10
char *cmd;
char *shell;
@@ -1225,6 +1226,7 @@ struct tty {
#define TTY_UTF8 0x8
#define TTY_STARTED 0x10
#define TTY_OPENED 0x20
+#define TTY_FOCUS 0x40
int flags;
int term_flags;
@@ -1376,6 +1378,9 @@ struct cmd {
char *file;
u_int line;
+#define CMD_CONTROL 0x1
+ int flags;
+
TAILQ_ENTRY(cmd) qentry;
};
struct cmd_list {
diff --git a/tty.c b/tty.c
index 79887fb..d5b1aec 100644
--- a/tty.c
+++ b/tty.c
@@ -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));
commit 777be296ee041e7d9131110e0489e791ed389ac1
Author: Nicholas Marriott <[email protected]>
Commit: Thomas Adam <[email protected]>
Always push a focus event when the application turns it on, prompted by
discussion with Hayaki Saito a while ago.
---
input.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/input.c b/input.c
index 4aa02e9..30d3bb9 100644
--- a/input.c
+++ b/input.c
@@ -1333,7 +1333,7 @@ input_csi_dispatch(struct input_ctx *ictx)
if (s->mode & MODE_FOCUSON)
break;
screen_write_mode_set(&ictx->ctx, MODE_FOCUSON);
- wp->flags &= ~PANE_FOCUSED; /* force update if needed */
+ wp->flags |= PANE_FOCUSPUSH; /* force update */
break;
case 1005:
screen_write_mode_set(&ictx->ctx, MODE_MOUSE_UTF8);
commit a0172a6ae561fd6764fcfcdd975fc7a07f43dc79
Author: Nicholas Marriott <[email protected]>
Commit: Thomas Adam <[email protected]>
Mark control commands specially so the client can identify them, based
on a diff from George Nachman a while back.
---
cmd-queue.c | 7 +++++--
control.c | 3 +++
2 files changed, 8 insertions(+), 2 deletions(-)
diff --git a/cmd-queue.c b/cmd-queue.c
index 671f1e9..243f73d 100644
--- a/cmd-queue.c
+++ b/cmd-queue.c
@@ -157,14 +157,17 @@ int
cmdq_guard(struct cmd_q *cmdq, const char *guard)
{
struct client *c = cmdq->client;
+ int flags;
if (c == NULL)
return 0;
if (!(c->flags & CLIENT_CONTROL))
return 0;
- evbuffer_add_printf(c->stdout_data, "%%%s %ld %u\n", guard,
- (long) cmdq->time, cmdq->number);
+ flags = !!(cmdq->cmd->flags & CMD_CONTROL);
+
+ evbuffer_add_printf(c->stdout_data, "%%%s %ld %u %d\n", guard,
+ (long) cmdq->time, cmdq->number, flags);
server_push_stdout(c);
return 1;
}
diff --git a/control.c b/control.c
index ba243fd..aa79085 100644
--- a/control.c
+++ b/control.c
@@ -55,6 +55,7 @@ control_callback(struct client *c, int closed, unused void
*data)
{
char *line, *cause;
struct cmd_list *cmdlist;
+ struct cmd *cmd;
if (closed)
c->flags |= CLIENT_EXIT;
@@ -78,6 +79,8 @@ control_callback(struct client *c, int closed, unused void
*data)
free(cause);
} else {
+ TAILQ_FOREACH(cmd, &cmdlist->list, qentry)
+ cmd->flags |= CMD_CONTROL;
cmdq_run(c->cmdq, cmdlist);
cmd_list_free(cmdlist);
}
-----------------------------------------------------------------------
Summary of changes:
cmd-queue.c | 7 +++++--
control.c | 3 +++
input.c | 2 +-
options-table.c | 5 +++++
server-client.c | 13 +++++++++++--
tmux.1 | 8 ++++++++
tmux.h | 5 +++++
tty.c | 14 ++++++++++++--
8 files changed, 50 insertions(+), 7 deletions(-)
hooks/post-receive
--
tmux
------------------------------------------------------------------------------
This SF.net email is sponsored by Windows:
Build for Windows Store.
http://p.sf.net/sfu/windows-dev2dev
_______________________________________________
tmux-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/tmux-cvs