mirror of
https://github.com/tmux/tmux.git
synced 2026-10-12 13:44:44 +00:00
Keep focus on a visible pane when panes are shown, spawned or closed.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
10
spawn.c
10
spawn.c
@@ -254,7 +254,7 @@ spawn_pane(struct spawn_context *sc, char **cause)
|
|||||||
char path[PATH_MAX];
|
char path[PATH_MAX];
|
||||||
const char *cmd, *tmp, *home = find_home();
|
const char *cmd, *tmp, *home = find_home();
|
||||||
const char *actual_cwd = NULL;
|
const char *actual_cwd = NULL;
|
||||||
int argc;
|
int argc, detached;
|
||||||
u_int idx;
|
u_int idx;
|
||||||
struct termios now;
|
struct termios now;
|
||||||
u_int hlimit;
|
u_int hlimit;
|
||||||
@@ -588,6 +588,11 @@ complete:
|
|||||||
return (new_wp);
|
return (new_wp);
|
||||||
if (sc->flags & SPAWN_ZOOM)
|
if (sc->flags & SPAWN_ZOOM)
|
||||||
window_zoom(new_wp);
|
window_zoom(new_wp);
|
||||||
|
|
||||||
|
/* Make the pane active, even if detached, if keys would go nowhere. */
|
||||||
|
detached = (sc->flags & SPAWN_DETACHED);
|
||||||
|
if (w->active == NULL || (w->active->flags & PANE_HIDDEN))
|
||||||
|
detached = 0;
|
||||||
if (sc->flags & SPAWN_MODAL) {
|
if (sc->flags & SPAWN_MODAL) {
|
||||||
w->modal_last = w->active;
|
w->modal_last = w->active;
|
||||||
w->modal = new_wp;
|
w->modal = new_wp;
|
||||||
@@ -596,8 +601,7 @@ complete:
|
|||||||
window_set_active_pane(w, new_wp, 0);
|
window_set_active_pane(w, new_wp, 0);
|
||||||
else
|
else
|
||||||
window_set_active_pane(w, new_wp, 1);
|
window_set_active_pane(w, new_wp, 1);
|
||||||
} else if (((~sc->flags & SPAWN_DETACHED) || w->active == NULL) &&
|
} else if (!detached && w->modal == NULL) {
|
||||||
w->modal == NULL) {
|
|
||||||
if (sc->flags & SPAWN_NONOTIFY)
|
if (sc->flags & SPAWN_NONOTIFY)
|
||||||
window_set_active_pane(w, new_wp, 0);
|
window_set_active_pane(w, new_wp, 0);
|
||||||
else
|
else
|
||||||
|
|||||||
11
window.c
11
window.c
@@ -765,8 +765,11 @@ window_activate_pane(struct window *w, struct window_pane *wp, int notify,
|
|||||||
|
|
||||||
if (w->modal != NULL && wp != w->modal)
|
if (w->modal != NULL && wp != w->modal)
|
||||||
return (0);
|
return (0);
|
||||||
if (wp->flags & PANE_HIDDEN)
|
if (wp->flags & PANE_HIDDEN) {
|
||||||
window_show_pane(wp);
|
window_show_pane(wp);
|
||||||
|
if (wp == w->active)
|
||||||
|
return (1);
|
||||||
|
}
|
||||||
if (wp == w->active)
|
if (wp == w->active)
|
||||||
return (0);
|
return (0);
|
||||||
if (!window_pane_is_visible(wp)) {
|
if (!window_pane_is_visible(wp)) {
|
||||||
@@ -1099,6 +1102,10 @@ window_show_pane(struct window_pane *wp)
|
|||||||
events_fire_window("window-layout-changed", w);
|
events_fire_window("window-layout-changed", w);
|
||||||
redraw_invalidate_scene(w);
|
redraw_invalidate_scene(w);
|
||||||
server_redraw_window(w);
|
server_redraw_window(w);
|
||||||
|
|
||||||
|
/* Keys go nowhere if the active pane is hidden, so use this one. */
|
||||||
|
if (w->active != NULL && (w->active->flags & PANE_HIDDEN))
|
||||||
|
window_set_active_pane(w, wp, 1);
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1327,7 +1334,7 @@ window_lost_pane(struct window *w, struct window_pane *wp)
|
|||||||
w->active = lastwp;
|
w->active = lastwp;
|
||||||
else
|
else
|
||||||
w->active = TAILQ_FIRST(&w->last_panes);
|
w->active = TAILQ_FIRST(&w->last_panes);
|
||||||
if (w->active != NULL && !window_pane_is_visible(w->active)) {
|
if (w->active == NULL || !window_pane_is_visible(w->active)) {
|
||||||
/* Use the topmost pane that can be seen. */
|
/* Use the topmost pane that can be seen. */
|
||||||
TAILQ_FOREACH(lastwp, &w->z_index, zentry) {
|
TAILQ_FOREACH(lastwp, &w->z_index, zentry) {
|
||||||
if (lastwp != wp &&
|
if (lastwp != wp &&
|
||||||
|
|||||||
Reference in New Issue
Block a user