summaryrefslogtreecommitdiffstats
path: root/server-client.c
diff options
context:
space:
mode:
authorNicholas Marriott <nicm@openbsd.org>2013-06-23 13:10:46 +0000
committerNicholas Marriott <nicm@openbsd.org>2013-06-23 13:10:46 +0000
commit3977dba76139b5d4b0a6e60458d39a374beeedf3 (patch)
treec9a2eb74d17f3b685766bd460258b460eddb3a4b /server-client.c
parenta41cd8d75b55da5a1e75e187b30b33917c18c1b2 (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 'server-client.c')
-rw-r--r--server-client.c13
1 files changed, 11 insertions, 2 deletions
diff --git a/server-client.c b/server-client.c
index 3b7b988a..5f61f5c0 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;
}