From 60f5f7f291122abf451dc764f4e0cc62483fc9e1 Mon Sep 17 00:00:00 2001 From: stefan schippers Date: Fri, 12 Sep 2025 11:23:41 +0200 Subject: [PATCH] when closing a tab switch to previous instead of first tab --- src/xinit.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/xinit.c b/src/xinit.c index a3e1e73d..c26bca94 100644 --- a/src/xinit.c +++ b/src/xinit.c @@ -1896,7 +1896,7 @@ static void destroy_window(int *window_count, const char *win_path) static void destroy_tab(int *window_count, const char *win_path) { - int i, n; + int i, n, prev; if(*window_count) { int close = 0; dbg(1, "new_schematic() destroy_tab\n"); @@ -1940,7 +1940,15 @@ static void destroy_tab(int *window_count, const char *win_path) (*window_count)--; if(*window_count == 0) tcleval(".menubar.view entryconfigure {Tabbed interface} -state normal"); } - xctx = save_xctx[0]; /* restore main (.drw) schematic */ + + + prev = 0; + if(previous_win_path[0]) { + prev = get_tab_or_window_number(previous_win_path); + dbg(1, "%s, prev=%d\n", previous_win_path, prev); + if(prev == -1) prev = 0; + } + xctx = save_xctx[prev]; /* restore previous or main (.drw) schematic */ /* seems unnecessary; previous tab save_pixmap was not deleted */ /* resetwin(1, 0, 0, 0, 0); */ /* create pixmap. resetwin(create_pixmap, clear_pixmap, force, w, h) */