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

This commit is contained in:
Stefan Frederik 2022-07-15 12:32:57 +02:00
parent 8275a99d8d
commit e7f31cf3ee
3 changed files with 39 additions and 7 deletions

View File

@ -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

View File

@ -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);
}

View File

@ -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