Skip to content

Commit d254293

Browse files
author
nicm
committed
Add pane focus hooks.
1 parent 2fae6a5 commit d254293

File tree

2 files changed

+18
-8
lines changed

2 files changed

+18
-8
lines changed

server-client.c

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1148,10 +1148,6 @@ server_client_check_focus(struct window_pane *wp)
11481148
push = wp->flags & PANE_FOCUSPUSH;
11491149
wp->flags &= ~PANE_FOCUSPUSH;
11501150

1151-
/* If we don't care about focus, forget it. */
1152-
if (!(wp->base.mode & MODE_FOCUSON))
1153-
return;
1154-
11551151
/* If we're not the active pane in our window, we're not focused. */
11561152
if (wp->window->active != wp)
11571153
goto not_focused;
@@ -1175,14 +1171,20 @@ server_client_check_focus(struct window_pane *wp)
11751171
}
11761172

11771173
not_focused:
1178-
if (push || (wp->flags & PANE_FOCUSED))
1179-
bufferevent_write(wp->event, "\033[O", 3);
1174+
if (push || (wp->flags & PANE_FOCUSED)) {
1175+
if (wp->base.mode & MODE_FOCUSON)
1176+
bufferevent_write(wp->event, "\033[O", 3);
1177+
notify_pane("pane-focus-out", wp);
1178+
}
11801179
wp->flags &= ~PANE_FOCUSED;
11811180
return;
11821181

11831182
focused:
1184-
if (push || !(wp->flags & PANE_FOCUSED))
1185-
bufferevent_write(wp->event, "\033[I", 3);
1183+
if (push || !(wp->flags & PANE_FOCUSED)) {
1184+
if (wp->base.mode & MODE_FOCUSON)
1185+
bufferevent_write(wp->event, "\033[I", 3);
1186+
notify_pane("pane-focus-in", wp);
1187+
}
11861188
wp->flags |= PANE_FOCUSED;
11871189
}
11881190

tmux.1

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3423,6 +3423,14 @@ Run when the program running in a pane exits, but
34233423
is on so the pane has not closed.
34243424
.It pane-exited
34253425
Run when the program running in a pane exits.
3426+
.It pane-focus-in
3427+
Run when the focus enters a pane, if the
3428+
.Ic focus-events
3429+
option is on.
3430+
.It pane-focus-out
3431+
Run when the focus exits a pane, if the
3432+
.Ic focus-events
3433+
option is on.
34263434
.It pane-set-clipboard
34273435
Run when the terminal clipboard is set using the
34283436
.Xr xterm 1

0 commit comments

Comments
 (0)