summaryrefslogtreecommitdiffstats
path: root/window.c
diff options
context:
space:
mode:
authorThomas Adam <thomas@xteddy.org>2023-07-10 12:01:12 +0100
committerThomas Adam <thomas@xteddy.org>2023-07-10 12:01:12 +0100
commit269dab4b3e593ade4995ebbcb428025f51c542fd (patch)
tree57f59066a9526c6bcf59ef24a58ac562cd3bdeb6 /window.c
parente4c4ceb2865fd9d2006a85c7f48bb7b6dd2f5c49 (diff)
parent4ece43a02961dc6726e97b05caca9a3c53793826 (diff)
Merge branch 'obsd-master'
Diffstat (limited to 'window.c')
-rw-r--r--window.c56
1 files changed, 40 insertions, 16 deletions
diff --git a/window.c b/window.c
index 3af71d66..84a32393 100644
--- a/window.c
+++ b/window.c
@@ -246,21 +246,15 @@ winlink_stack_push(struct winlink_stack *stack, struct winlink *wl)
winlink_stack_remove(stack, wl);
TAILQ_INSERT_HEAD(stack, wl, sentry);
+ wl->flags |= WINLINK_VISITED;
}
void
winlink_stack_remove(struct winlink_stack *stack, struct winlink *wl)
{
- struct winlink *wl2;
-
- if (wl == NULL)
- return;
-
- TAILQ_FOREACH(wl2, stack, sentry) {
- if (wl2 == wl) {
- TAILQ_REMOVE(stack, wl, sentry);
- return;
- }
+ if (wl != NULL && (wl->flags & WINLINK_VISITED)) {
+ TAILQ_REMOVE(stack, wl, sentry);
+ wl->flags &= ~WINLINK_VISITED;
}
}
@@ -310,6 +304,7 @@ window_create(u_int sx, u_int sy, u_int xpixel, u_int ypixel)
w->flags = 0;
TAILQ_INIT(&w->panes);
+ TAILQ_INIT(&w->last_panes);
w->active = NULL;
w->lastlayout = -1;
@@ -519,18 +514,23 @@ window_pane_update_focus(struct window_pane *wp)
int
window_set_active_pane(struct window *w, struct window_pane *wp, int notify)
{
+ struct window_pane *lastwp;
+
log_debug("%s: pane %%%u", __func__, wp->id);
if (wp == w->active)
return (0);
- w->last = w->active;
+ lastwp = w->active;
+
+ window_pane_stack_remove(&w->last_panes, wp);
+ window_pane_stack_push(&w->last_panes, lastwp);
w->active = wp;
w->active->active_point = next_active_point++;
w->active->flags |= PANE_CHANGED;
if (options_get_number(global_options, "focus-events")) {
- window_pane_update_focus(w->last);
+ window_pane_update_focus(lastwp);
window_pane_update_focus(w->active);
}
@@ -753,21 +753,21 @@ window_lost_pane(struct window *w, struct window_pane *wp)
if (wp == marked_pane.wp)
server_clear_marked();
+ window_pane_stack_remove(&w->last_panes, wp);
if (wp == w->active) {
- w->active = w->last;
- w->last = NULL;
+ w->active = TAILQ_FIRST(&w->last_panes);
if (w->active == NULL) {
w->active = TAILQ_PREV(wp, window_panes, entry);
if (w->active == NULL)
w->active = TAILQ_NEXT(wp, entry);
}
if (w->active != NULL) {
+ window_pane_stack_remove(&w->last_panes, w->active);
w->active->flags |= PANE_CHANGED;
notify_window("window-pane-changed", w);
window_update_focus(w);
}
- } else if (wp == w->last)
- w->last = NULL;
+ }
}
void
@@ -851,6 +851,11 @@ window_destroy_panes(struct window *w)
{
struct window_pane *wp;
+ while (!TAILQ_EMPTY(&w->last_panes)) {
+ wp = TAILQ_FIRST(&w->last_panes);
+ window_pane_stack_remove(&w->last_panes, wp);
+ }
+
while (!TAILQ_EMPTY(&w->panes)) {
wp = TAILQ_FIRST(&w->panes);
TAILQ_REMOVE(&w->panes, wp, entry);
@@ -1488,6 +1493,25 @@ window_pane_find_right(struct window_pane *wp)
return (best);
}
+void
+window_pane_stack_push(struct window_panes *stack, struct window_pane *wp)
+{
+ if (wp != NULL) {
+ window_pane_stack_remove(stack, wp);
+ TAILQ_INSERT_HEAD(stack, wp, sentry);
+ wp->flags |= PANE_VISITED;
+ }
+}
+
+void
+window_pane_stack_remove(struct window_panes *stack, struct window_pane *wp)
+{
+ if (wp != NULL && (wp->flags & PANE_VISITED)) {
+ TAILQ_REMOVE(stack, wp, sentry);
+ wp->flags &= ~PANE_VISITED;
+ }
+}
+
/* Clear alert flags for a winlink */
void
winlink_clear_flags(struct winlink *wl)