diff options
author | 2013-03-24 09:28:59 +0000 | |
---|---|---|
committer | 2013-03-24 09:28:59 +0000 | |
commit | 6ddcc08fed363efd4f6a87925a058282f17d0d9b (patch) | |
tree | 2fe9e89416ff0d99ff96f0a76917174b252f37dd /usr.bin/tmux/server-client.c | |
parent | Fix error reporting for client commands by adding a flag to (diff) | |
download | wireguard-openbsd-6ddcc08fed363efd4f6a87925a058282f17d0d9b.tar.xz wireguard-openbsd-6ddcc08fed363efd4f6a87925a058282f17d0d9b.zip |
Handle focus events from the terminal, from Aaron Jensen.
Diffstat (limited to 'usr.bin/tmux/server-client.c')
-rw-r--r-- | usr.bin/tmux/server-client.c | 24 |
1 files changed, 17 insertions, 7 deletions
diff --git a/usr.bin/tmux/server-client.c b/usr.bin/tmux/server-client.c index 50d3d48780e..56945a18451 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.92 2013/03/24 09:25:04 nicm Exp $ */ +/* $OpenBSD: server-client.c,v 1.93 2013/03/24 09:28:59 nicm Exp $ */ /* * Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net> @@ -97,6 +97,8 @@ server_client_create(int fd) c->tty.mouse.event = MOUSE_EVENT_UP; c->tty.mouse.flags = 0; + c->flags |= CLIENT_FOCUSED; + evtimer_set(&c->repeat_timer, server_client_repeat_timer, c); for (i = 0; i < ARRAY_LENGTH(&clients); i++) { @@ -547,7 +549,8 @@ server_client_check_resize(struct window_pane *wp) void server_client_check_focus(struct window_pane *wp) { - struct session *s; + u_int i; + struct client *c; /* If we don't care about focus, forget it. */ if (!(wp->base.mode & MODE_FOCUSON)) @@ -562,13 +565,20 @@ server_client_check_focus(struct window_pane *wp) goto not_focused; /* - * If our window is the current window in any attached sessions, we're - * focused. + * If our window is the current window in any focused clients with an + * attached session, we're focused. */ - RB_FOREACH(s, sessions, &sessions) { - if (s->flags & SESSION_UNATTACHED) + for (i = 0; i < ARRAY_LENGTH(&clients); i++) { + c = ARRAY_ITEM(&clients, i); + if (c == NULL || c->session == NULL) + continue; + + if (!(c->flags & CLIENT_FOCUSED)) continue; - if (s->curw->window == wp->window) + if (c->session->flags & SESSION_UNATTACHED) + continue; + + if (c->session->curw->window == wp->window) goto focused; } |