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.
This commit is contained in:
Nicholas Marriott
2013-06-23 13:10:46 +00:00
parent a41cd8d75b
commit 3977dba761
5 changed files with 41 additions and 4 deletions

View File

@ -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;
}