diff options
author | Nicholas Marriott <nicholas.marriott@gmail.com> | 2013-02-23 10:01:34 +0000 |
---|---|---|
committer | Nicholas Marriott <nicholas.marriott@gmail.com> | 2013-02-23 10:01:34 +0000 |
commit | ee0f8adfac76cdf21cfd2c0b503d8d66dcb883cc (patch) | |
tree | 1a01c4d91d47e46fabc6782240dc0c0a8e58218f /server-client.c | |
parent | 1ed37385c66cbfe9221e9ee4025105a5370d1ef2 (diff) | |
download | rtmux-ee0f8adfac76cdf21cfd2c0b503d8d66dcb883cc.tar.gz rtmux-ee0f8adfac76cdf21cfd2c0b503d8d66dcb883cc.tar.bz2 rtmux-ee0f8adfac76cdf21cfd2c0b503d8d66dcb883cc.zip |
Handle focus events from the terminal, from Aaron Jensen.
Diffstat (limited to 'server-client.c')
-rw-r--r-- | server-client.c | 23 |
1 files changed, 17 insertions, 6 deletions
diff --git a/server-client.c b/server-client.c index 3c14ff87..9ac6088b 100644 --- a/server-client.c +++ b/server-client.c @@ -17,6 +17,7 @@ */ #include <sys/types.h> +#include <sys/ioctl.h> #include <event.h> #include <fcntl.h> @@ -95,6 +96,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++) { @@ -545,7 +548,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)) @@ -560,13 +564,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; } |