From e7f31cf3eed40b247196214f90e68602f9a0db05 Mon Sep 17 00:00:00 2001 From: Stefan Frederik Date: Fri, 15 Jul 2022 12:32:57 +0200 Subject: [PATCH] allow each window (in tabbed or window interface) to run its own simulation, preventing spawning another simulation process for same tab/window if previous not finished --- src/callback.c | 2 +- src/xinit.c | 10 ++++++++++ src/xschem.tcl | 34 ++++++++++++++++++++++++++++------ 3 files changed, 39 insertions(+), 7 deletions(-) diff --git a/src/callback.c b/src/callback.c index 61709b55..9f286714 100644 --- a/src/callback.c +++ b/src/callback.c @@ -842,9 +842,9 @@ int callback(const char *winpath, int event, int mx, int my, KeySym key, dbg(1, "callback(): switching window context: %s --> %s, semaphore=%d\n", old_winpath, winpath, xctx->semaphore); if(old_winpath[0]) tclvareval("save_ctx ", old_winpath, NULL); tclvareval("restore_ctx ", winpath, NULL); - tclvareval("housekeeping_ctx", NULL); } new_schematic("switch_win", winpath, ""); + tclvareval("housekeeping_ctx", NULL); } /* artificially set semaphore to allow only redraw operations in switched schematic, * so we don't need to switch tcl context which is costly performance-wise diff --git a/src/xinit.c b/src/xinit.c index ee67e1d1..f7bc7fd1 100644 --- a/src/xinit.c +++ b/src/xinit.c @@ -1012,6 +1012,7 @@ int check_loaded(const char *f, char *win_path) * * tclvareval("save_ctx ", old_winpath, NULL); * tclvareval("restore_ctx ", winpath, NULL); + * new_schematic("switch_win", winpath, ""); * tclvareval("housekeeping_ctx", NULL); */ static void switch_window(int *window_count, const char *win_path) @@ -1080,10 +1081,12 @@ static void create_new_window(int *window_count, const char *fname) { Window win_id; char toppath[WINDOW_PATH_SIZE]; + char prev_window[WINDOW_PATH_SIZE]; int i, n; dbg(1, "new_schematic() create: fname=%s *window_count = %d\n", fname, *window_count); + my_strncpy(prev_window, xctx->current_win_path, S(prev_window)); if(/* *window_count && */ fname && fname[0] && check_loaded(fname, toppath)) { char msg[PATH_MAX+100]; my_snprintf(msg, S(msg), @@ -1153,6 +1156,13 @@ static void create_new_window(int *window_count, const char *fname) zoom_full(1, 0, 1, 0.97); /* draw */ tclvareval("set_bindings ", window_path[n], NULL); tclvareval("save_ctx ", window_path[n], NULL); + /* restore previous context, + * because the Expose event after new window creation does a context switch prev win -> new win + */ + tclvareval("restore_ctx ", prev_window, NULL); + new_schematic("switch_win", prev_window, ""); + tclvareval("housekeeping_ctx", NULL); + windowid(toppath); } diff --git a/src/xschem.tcl b/src/xschem.tcl index 04fc8ca2..b8ee32bc 100644 --- a/src/xschem.tcl +++ b/src/xschem.tcl @@ -4551,7 +4551,7 @@ set tctx::global_list { only_probes path pathlist persistent_command preserve_unchanged_attrs prev_symbol ps_colors rainbow_colors rawfile_loaded rcode recentfile replace_key retval retval_orig rotated_text save_initialfile search_exact search_found search_schematic search_select search_value selected_tok show_hidden_texts show_infowindow - show_pin_net_names simconf_default_geometry simconf_vpos + show_pin_net_names simconf_default_geometry simconf_vpos simulate_bg spiceprefix split_files svg_colors svg_font_name symbol symbol_width sym_txt tclcmd_txt tclstop text_line_default_geometry textwindow_fileid textwindow_filename textwindow_w tmp_bus_char toolbar_horiz toolbar_visible top_subckt transparent_svg undo_type @@ -4629,15 +4629,35 @@ proc save_ctx {context} { } proc housekeeping_ctx {} { - global has_x - if {![info exists $has_x]} {return} + global has_x simulate_bg + if {![info exists has_x]} {return} uplevel #0 { - # puts housekeeping_ctx + } + # puts "housekeeping_ctx, path: [xschem get current_win_path]" + + if {![info exists ::[xschem get current_win_path]_simulate]} { + [xschem get top_path].menubar.simulate configure -bg $simulate_bg + } else { + [xschem get top_path].menubar.simulate configure -bg red } } proc simulate_button {button_path} { - simulate + global simulate_bg + if { ![info exists ::[xschem get current_win_path]_simulate] } { + set ::[xschem get current_win_path]_simulate 1 + $button_path configure -bg red + simulate "clear_simulate_button $button_path ::[xschem get current_win_path]_simulate" + } + +} + +proc clear_simulate_button {button_path simvar} { + global simulate_bg + if { "::[xschem get current_win_path]_simulate" eq $simvar } { + $button_path configure -bg $simulate_bg + } + unset $simvar } proc set_bindings {topwin} { @@ -4755,7 +4775,7 @@ proc switch_undo {} { } proc build_widgets { {topwin {} } } { - global XSCHEM_SHAREDIR tabbed_interface + global XSCHEM_SHAREDIR tabbed_interface simulate_bg global colors recentfile color_ps transparent_svg menu_debug_var enable_stretch global netlist_show flat_netlist split_files hspice_netlist tmp_bus_char global draw_grid big_grid_points sym_txt change_lw incr_hilight symbol_width @@ -4989,6 +5009,8 @@ proc build_widgets { {topwin {} } } { -padx 2 -pady 0 -command waves $bbg eval button $topwin.menubar.simulate -text "Simulate" -activebackground red -takefocus 0 \ -padx 2 -pady 0 -command \{simulate_button $topwin.menubar.simulate\} $bbg + puts "setting simulate_bg" + set simulate_bg [$topwin.menubar.simulate cget -bg] eval button $topwin.menubar.netlist -text "Netlist" -activebackground red -takefocus 0 \ -padx 2 -pady 0 -command \{xschem netlist\} $bbg # create $topwin.menubar.layers.menu