From 1d2bff5f9b400218a169b124a312d309460cdcfc Mon Sep 17 00:00:00 2001 From: stefan schippers Date: Fri, 28 Mar 2025 13:12:52 +0100 Subject: [PATCH] cleanup FocusIn / window switching --- src/xinit.c | 17 +++++++++++------ src/xschem.tcl | 19 +++++++++---------- 2 files changed, 20 insertions(+), 16 deletions(-) diff --git a/src/xinit.c b/src/xinit.c index 76426c16..772d6b83 100644 --- a/src/xinit.c +++ b/src/xinit.c @@ -1299,7 +1299,8 @@ int preview_window(const char *what, const char *win_path, const char *fname) } } } - tclvareval("restore_ctx ", xctx->current_win_path, NULL); + if(xctx->current_win_path) + tclvareval("restore_ctx ", xctx->current_win_path, NULL); semaphore--; return result; } @@ -1843,10 +1844,11 @@ static void destroy_window(int *window_count, const char *win_path) } /* following 3 lines must be done also if window not closed */ xctx = savectx; /* restore previous schematic or main window if previous destroyed */ - tclvareval("restore_ctx ", xctx->current_win_path, " ; housekeeping_ctx", NULL); + if(xctx->current_win_path) + tclvareval("restore_ctx ", xctx->current_win_path, " ; housekeeping_ctx", NULL); set_modify(-1); /* sets window title */ } else { - dbg(0, "new_schematic() destroy_window: there are no additional tabs\n"); + dbg(0, "new_schematic() destroy_window: there are no additional windows\n"); } } @@ -1901,7 +1903,8 @@ static void destroy_tab(int *window_count, const char *win_path) /* 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) */ - tclvareval("restore_ctx ", xctx->current_win_path, " ; housekeeping_ctx", NULL); + if(xctx->current_win_path) + tclvareval("restore_ctx ", xctx->current_win_path, " ; housekeeping_ctx", NULL); resetwin(1, 1, 1, 0, 0); set_modify(-1); /* sets window title */ draw(); @@ -1965,7 +1968,8 @@ static void destroy_all_windows(int *window_count, int force) } /* following 3 lines must be done also if windows not closed */ xctx = savectx; /* restore previous schematic or main if old is destroyed */ - tclvareval("restore_ctx ", xctx->current_win_path, " ; housekeeping_ctx", NULL); + if(xctx->current_win_path) + tclvareval("restore_ctx ", xctx->current_win_path, " ; housekeeping_ctx", NULL); set_modify(-1); /* sets window title */ } } @@ -2007,7 +2011,8 @@ static void destroy_all_tabs(int *window_count, int force) } /* following 3 lines must be done also if windows not closed */ xctx = savectx; /* restore previous schematic or main if old is destroyed */ - tclvareval("restore_ctx ", xctx->current_win_path, " ; housekeeping_ctx", NULL); + if(xctx->current_win_path) + tclvareval("restore_ctx ", xctx->current_win_path, " ; housekeeping_ctx", NULL); set_modify(-1); /* sets window title */ draw(); } diff --git a/src/xschem.tcl b/src/xschem.tcl index f9985762..74afddf9 100644 --- a/src/xschem.tcl +++ b/src/xschem.tcl @@ -1988,13 +1988,11 @@ proc cellview { {derived_symbols {}} {upd 0}} { set font fixed } + set netlist_type $save_netlist_type + xschem set netlist_type $netlist_type + xschem reload_symbols ;# purge unused symbols + xschem netlist -keep_symbols -noalert;# traverse the hierarchy and retain all encountered symbols if {!$upd} { - set netlist_type $save_netlist_type - xschem set netlist_type $netlist_type - xschem reload_symbols ;# purge unused symbols - xschem netlist -keep_symbols -noalert;# traverse the hierarchy and retain all encountered symbols - puts "get netlist" - catch {destroy .cv} toplevel .cv wm geometry .cv 800x200 @@ -8544,14 +8542,15 @@ global env has_x OS autofocus_mainwindow bind $parent [list raise_dialog $parent $topwin] bind $parent [list raise_dialog $parent $topwin] - # This event will cause a window context switch - bind $parent "switch_window $parent $topwin %T %W" - # This event will cause a window context switch + + # Context switch bind $parent "switch_window $parent $topwin %T %W" + bind $topwin " xschem callback %W %T %x %y 0 0 0 %s graph_show_measure stop " + bind $topwin "xschem callback %W %T %x %y 0 %w %h %s" # transform mousewheel events into button4/5 events @@ -8604,7 +8603,7 @@ global env has_x OS autofocus_mainwindow bind $topwin {xschem callback %W %T %x %y %N 0 0 [expr {$ControlMask + $Mod1Mask}]} bind $topwin {xschem callback %W %T %x %y %N 0 0 [expr {$ShiftMask + $Mod1Mask}]} bind $topwin {xschem callback %W %T %x %y %N 0 0 [expr {$ShiftMask}]} - bind $topwin { + bind $topwin { ;# transform MouseWheel into button 4/5 presses. if {%D<0} { xschem callback %W 4 %x %y 0 5 0 %s } else {