From 55d011ba7b17d24bc084f4752fe4fce3b114ece8 Mon Sep 17 00:00:00 2001 From: stefan schippers Date: Sun, 4 Jun 2023 22:54:39 +0200 Subject: [PATCH] added necessary comments in swap_windows() / swap_tabs() functions --- src/scheduler.c | 2 +- src/xinit.c | 21 ++++++++++++++------- 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/src/scheduler.c b/src/scheduler.c index f9c3d1d5..32c6a754 100644 --- a/src/scheduler.c +++ b/src/scheduler.c @@ -702,7 +702,7 @@ int xschem(ClientData clientdata, Tcl_Interp *interp, int argc, const char * arg } if(!xctx->modified || !strcmp(tclresult(), "ok")) { swap_windows(); - set_modify(0); + set_modify(0); /* set modified status to 0 to avoid another confirm in following line */ new_schematic("destroy", xctx->current_win_path, NULL); } } else { diff --git a/src/xinit.c b/src/xinit.c index 4b35390d..972c901d 100644 --- a/src/xinit.c +++ b/src/xinit.c @@ -1182,7 +1182,8 @@ void preview_window(const char *what, const char *win_path, const char *fname) semaphore--; } -/* swap primary view (.drw) with first valid tab (x1.drw, x2.drw, ...) */ +/* swap primary view (.drw) with first valid tab (x1.drw, x2.drw, ...) + * used for window close ('xschem exit' command) */ void swap_tabs(void) { int wc = window_count; @@ -1224,11 +1225,13 @@ void swap_tabs(void) set_modify(-1); xctx = ctx; set_modify(-1); + /* set context to tab that is about to be deleted */ new_schematic("switch_tab", save_xctx[j]->current_win_path, NULL); } } -/* swap primary view (.drw) with first valid tab (x1.drw, x2.drw, ...) */ +/* swap primary view (.drw) with first valid tab (x1.drw, x2.drw, ...) + * used for window close ('xschem exit' command) */ void swap_windows(void) { int wc = window_count; @@ -1258,12 +1261,15 @@ void swap_windows(void) } dbg(1, "swap_windows(): i=%d, j=%d\n", i, j); - my_snprintf(wp_i, S(wp_i), "%s", save_xctx[i]->current_win_path); - my_snprintf(wp_j, S(wp_j), "%s", save_xctx[j]->current_win_path); + my_snprintf(wp_i, S(wp_i), "%s", save_xctx[i]->current_win_path); /* primary (.drw) window */ + my_snprintf(wp_j, S(wp_j), "%s", save_xctx[j]->current_win_path); /* sub (.x?.drw) window */ mainwindow = Tk_MainWindow(interp); + /* get parent of wp_j window, since window manager reparents application windows to a + * parent window with title bar and borders. This gives accurate geometry data */ tkwin = Tk_Parent(Tk_NameToWindow(interp, wp_j, mainwindow)); + /* get sub-window geometry and position. primary window wp_i will be sized and moved there. */ dbg(1, "swap_windows(): %s: %dx%d+%d+%d\n", wp_j, Tk_Width(tkwin), Tk_Height(tkwin), Tk_X(tkwin), Tk_Y(tkwin)); my_snprintf(geometry, S(geometry), "%dx%d+%d+%d", @@ -1301,16 +1307,17 @@ void swap_windows(void) tclvareval("housekeeping_ctx", NULL); tclvareval("xschem build_colors", NULL); resetwin(1, 1, 1, 0, 0); + /* move primary window to location of deleted window */ + tclvareval("wm geometry . ", geometry, NULL); draw(); + /* set context to window that is about to be deleted */ tclvareval("restore_ctx ", wp_j, NULL); new_schematic("switch_win", wp_j, ""); tclvareval("housekeeping_ctx", NULL); tclvareval("xschem build_colors", NULL); resetwin(1, 1, 1, 0, 0); - draw(); - /* move primary window to location of deleted window */ - tclvareval("wm geometry . ", geometry, NULL); + /* draw(); */ /* avoid drawing, since usually this will be destroyed soon after */ } }