From ee7e3a965e6e46337dcc4ccc8a30e063e530fb8b Mon Sep 17 00:00:00 2001 From: stefan schippers Date: Fri, 26 Sep 2025 01:54:21 +0200 Subject: [PATCH] fix various focus issues in drawing canvas --- src/xinit.c | 2 +- src/xschem.tcl | 15 ++++++++------- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/src/xinit.c b/src/xinit.c index 58e33431..9dac8045 100644 --- a/src/xinit.c +++ b/src/xinit.c @@ -1715,7 +1715,6 @@ static void create_new_window(int *window_count, const char *win_path, const cha xctx->xorigin=CADINITIALX; xctx->yorigin=CADINITIALY; load_schematic(1, fname, 1, confirm); - tclvareval("set_bindings ", window_path[n], NULL); tclvareval("set_replace_key_binding ", window_path[n], NULL); tclvareval("save_ctx ", window_path[n], NULL); tcleval("eval_user_startup_commands"); @@ -1726,6 +1725,7 @@ static void create_new_window(int *window_count, const char *win_path, const cha * new_schematic("switch", prev_window, "", 1); */ tclvareval("housekeeping_ctx", NULL); + tclvareval("set_bindings ", window_path[n], NULL); if(has_x) windowid(toppath); if(dr) xctx->pending_fullzoom=1; } diff --git a/src/xschem.tcl b/src/xschem.tcl index 255d2686..df15c45f 100644 --- a/src/xschem.tcl +++ b/src/xschem.tcl @@ -8923,8 +8923,8 @@ global env has_x OS autofocus_mainwindow # Context switch. bind $parent " - # focus $topwin ;# propagate focus to canvas switch_window $parent $topwin %T %W + # focus $topwin ;# propagate focus to canvas " bind $topwin " @@ -8954,7 +8954,7 @@ global env has_x OS autofocus_mainwindow if {$autofocus_mainwindow} { bind $topwin "focus $topwin; xschem callback %W %T %x %y 0 %b 0 %s" } else { - bind $topwin "xschem callback %W %T %x %y 0 %b 0 %s" + bind $topwin "focus $topwin; xschem callback %W %T %x %y 0 %b 0 %s" } bind $topwin "xschem callback %W %T %x %y 0 %b 0 %s" @@ -9006,6 +9006,12 @@ global env has_x OS autofocus_mainwindow } } } + + if {$parent eq {.}} { set parent {}} + bind ${parent}.statusbar.5 \ + "focus ${parent}.drw; set cadgrid \[${parent}.statusbar.5 get\]; xschem set cadgrid \$cadgrid" + bind ${parent}.statusbar.3 \ + "focus ${parent}.drw; set cadsnap \[${parent}.statusbar.3 get\]; xschem set cadsnap \$cadsnap" } } @@ -9035,10 +9041,6 @@ proc pack_widgets { { topwin {} } } { setup_tabbed_interface if {$toolbar_visible} {toolbar_show $topwin} - bind $topwin.statusbar.5 \ - "focus $topwin.drw; set cadgrid \[$topwin.statusbar.5 get\]; xschem set cadgrid \$cadgrid" - bind $topwin.statusbar.3 \ - "focus $topwin.drw; set cadsnap \[$topwin.statusbar.3 get\]; xschem set cadsnap \$cadsnap" } if {$topwin ne {}} { $topwin.menubar.view entryconfigure {Tabbed interface} -state disabled @@ -9770,7 +9772,6 @@ tclcommand=\"xschem raw_read \$netlist_dir/[file tail [file rootname [xschem get # used to check status of Simulate button later. This variable is constant, never changed frame $topwin.drw -background {} -takefocus 1 - focus $topwin.drw if { $topwin == {} } {set rootwin .} else { set rootwin $topwin} wm title $rootwin "xschem - " wm iconname $rootwin "xschem - "