diff options
Diffstat (limited to 'usr.bin/tmux')
-rw-r--r-- | usr.bin/tmux/cmd-display-panes.c | 4 | ||||
-rw-r--r-- | usr.bin/tmux/server-client.c | 51 | ||||
-rw-r--r-- | usr.bin/tmux/server-fn.c | 43 | ||||
-rw-r--r-- | usr.bin/tmux/tmux.h | 6 |
4 files changed, 53 insertions, 51 deletions
diff --git a/usr.bin/tmux/cmd-display-panes.c b/usr.bin/tmux/cmd-display-panes.c index 0994e863c02..b5bdffb97c7 100644 --- a/usr.bin/tmux/cmd-display-panes.c +++ b/usr.bin/tmux/cmd-display-panes.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cmd-display-panes.c,v 1.17 2017/01/15 22:00:56 nicm Exp $ */ +/* $OpenBSD: cmd-display-panes.c,v 1.18 2017/03/09 17:06:35 nicm Exp $ */ /* * Copyright (c) 2009 Nicholas Marriott <nicholas.marriott@gmail.com> @@ -61,7 +61,7 @@ cmd_display_panes_exec(struct cmd *self, struct cmdq_item *item) else c->identify_callback_data = xstrdup("select-pane -t '%%'"); - server_set_identify(c); + server_client_set_identify(c); return (CMD_RETURN_NORMAL); } diff --git a/usr.bin/tmux/server-client.c b/usr.bin/tmux/server-client.c index adaa332991b..bc36547bc30 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.213 2017/02/14 18:13:05 nicm Exp $ */ +/* $OpenBSD: server-client.c,v 1.214 2017/03/09 17:06:35 nicm Exp $ */ /* * Copyright (c) 2009 Nicholas Marriott <nicholas.marriott@gmail.com> @@ -49,6 +49,49 @@ static void server_client_dispatch_command(struct client *, struct imsg *); static void server_client_dispatch_identify(struct client *, struct imsg *); static void server_client_dispatch_shell(struct client *); +/* Idenfity mode callback. */ +static void +server_client_callback_identify(__unused int fd, __unused short events, void *data) +{ + server_client_clear_identify(data, NULL); +} + +/* Set identify mode on client. */ +void +server_client_set_identify(struct client *c) +{ + struct timeval tv; + int delay; + + delay = options_get_number(c->session->options, "display-panes-time"); + tv.tv_sec = delay / 1000; + tv.tv_usec = (delay % 1000) * 1000L; + + if (event_initialized(&c->identify_timer)) + evtimer_del(&c->identify_timer); + evtimer_set(&c->identify_timer, server_client_callback_identify, c); + evtimer_add(&c->identify_timer, &tv); + + c->flags |= CLIENT_IDENTIFY; + c->tty.flags |= (TTY_FREEZE|TTY_NOCURSOR); + server_redraw_client(c); +} + +/* Clear identify mode on client. */ +void +server_client_clear_identify(struct client *c, struct window_pane *wp) +{ + if (~c->flags & CLIENT_IDENTIFY) + return; + c->flags &= ~CLIENT_IDENTIFY; + + if (c->identify_callback != NULL) + c->identify_callback(c, wp); + + c->tty.flags &= ~(TTY_FREEZE|TTY_NOCURSOR); + server_redraw_client(c); +} + /* Check if this client is inside this server. */ int server_client_check_nested(struct client *c) @@ -192,7 +235,7 @@ server_client_lost(struct client *c) c->flags |= CLIENT_DEAD; - server_clear_identify(c, NULL); + server_client_clear_identify(c, NULL); status_prompt_clear(c); status_message_clear(c); @@ -760,14 +803,14 @@ server_client_handle_key(struct client *c, key_code key) wp = window_pane_at_index(w, key - '0'); if (wp != NULL && !window_pane_visible(wp)) wp = NULL; - server_clear_identify(c, wp); + server_client_clear_identify(c, wp); return; } /* Handle status line. */ if (!(c->flags & CLIENT_READONLY)) { status_message_clear(c); - server_clear_identify(c, NULL); + server_client_clear_identify(c, NULL); } if (c->prompt_string != NULL) { if (c->flags & CLIENT_READONLY) diff --git a/usr.bin/tmux/server-fn.c b/usr.bin/tmux/server-fn.c index f5957119c8f..9808851a082 100644 --- a/usr.bin/tmux/server-fn.c +++ b/usr.bin/tmux/server-fn.c @@ -1,4 +1,4 @@ -/* $OpenBSD: server-fn.c,v 1.105 2017/03/09 17:02:38 nicm Exp $ */ +/* $OpenBSD: server-fn.c,v 1.106 2017/03/09 17:06:35 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com> @@ -29,7 +29,6 @@ #include "tmux.h" static struct session *server_next_session(struct session *); -static void server_callback_identify(int, short, void *); static void server_destroy_session_group(struct session *); void @@ -405,46 +404,6 @@ server_check_unattached(void) } } -void -server_set_identify(struct client *c) -{ - struct timeval tv; - int delay; - - delay = options_get_number(c->session->options, "display-panes-time"); - tv.tv_sec = delay / 1000; - tv.tv_usec = (delay % 1000) * 1000L; - - if (event_initialized(&c->identify_timer)) - evtimer_del(&c->identify_timer); - evtimer_set(&c->identify_timer, server_callback_identify, c); - evtimer_add(&c->identify_timer, &tv); - - c->flags |= CLIENT_IDENTIFY; - c->tty.flags |= (TTY_FREEZE|TTY_NOCURSOR); - server_redraw_client(c); -} - -void -server_clear_identify(struct client *c, struct window_pane *wp) -{ - if (~c->flags & CLIENT_IDENTIFY) - return; - c->flags &= ~CLIENT_IDENTIFY; - - if (c->identify_callback != NULL) - c->identify_callback(c, wp); - - c->tty.flags &= ~(TTY_FREEZE|TTY_NOCURSOR); - server_redraw_client(c); -} - -static void -server_callback_identify(__unused int fd, __unused short events, void *data) -{ - server_clear_identify(data, NULL); -} - /* Set stdin callback. */ int server_set_stdin_callback(struct client *c, void (*cb)(struct client *, int, diff --git a/usr.bin/tmux/tmux.h b/usr.bin/tmux/tmux.h index cbcea93e27d..713634d778d 100644 --- a/usr.bin/tmux/tmux.h +++ b/usr.bin/tmux/tmux.h @@ -1,4 +1,4 @@ -/* $OpenBSD: tmux.h,v 1.731 2017/03/09 17:02:38 nicm Exp $ */ +/* $OpenBSD: tmux.h,v 1.732 2017/03/09 17:06:35 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com> @@ -1819,6 +1819,8 @@ void server_update_socket(void); void server_add_accept(int); /* server-client.c */ +void server_client_set_identify(struct client *); +void server_client_clear_identify(struct client *, struct window_pane *); void server_client_set_key_table(struct client *, const char *); const char *server_client_get_key_table(struct client *); int server_client_is_default_key_table(struct client *); @@ -1858,8 +1860,6 @@ void server_unlink_window(struct session *, struct winlink *); void server_destroy_pane(struct window_pane *, int); void server_destroy_session(struct session *); void server_check_unattached(void); -void server_set_identify(struct client *); -void server_clear_identify(struct client *, struct window_pane *); int server_set_stdin_callback(struct client *, void (*)(struct client *, int, void *), void *, char **); void server_unzoom_window(struct window *); |