From 5ac170f2a5ceb831e8b0e4c3b2b6307201372a27 Mon Sep 17 00:00:00 2001 From: stefan schippers Date: Mon, 24 Mar 2025 13:46:15 +0100 Subject: [PATCH] changes in event system to make window context switching (in no tab mode) less "automatic", requiring a FocusIn event to switch. Will work better when working with the new symbol browser. changed default value of autofocus_mainwindow to 0 (set to 1 explicitly in xschemrc if you need that) --- src/callback.c | 23 +++++++++++------------ src/xschem.tcl | 25 ++++++++++++------------- src/xschemrc | 4 ++-- 3 files changed, 25 insertions(+), 27 deletions(-) diff --git a/src/callback.c b/src/callback.c index 52c22c69..dacb84c4 100644 --- a/src/callback.c +++ b/src/callback.c @@ -4615,6 +4615,7 @@ int callback(const char *win_path, int event, int mx, int my, KeySym key, int bu char str[PATH_MAX + 100]; int redraw_only; double c_snap; + int tabbed_interface = tclgetboolvar("tabbed_interface"); int enable_stretch = tclgetboolvar("enable_stretch"); int draw_xhair = tclgetboolvar("draw_crosshair"); int crosshair_size = tclgetintvar("crosshair_size"); @@ -4645,21 +4646,24 @@ int callback(const char *win_path, int event, int mx, int my, KeySym key, int bu #if 0 /* exclude Motion and Expose events */ if(event!=6 /* && event!=12 */) { - dbg(0, "callback(): state=%d event=%d, win_path=%s, old_win_path=%s, semaphore=%d\n", - state, event, win_path, old_win_path, xctx->semaphore+1); + dbg(0, "callback(): state=%d event=%d, win_path=%s, current_win_path=%s, semaphore=%d\n", + state, event, win_path, xctx->current_win_path, xctx->semaphore+1); } #endif /* Schematic window context switch */ - redraw_only =0; - if(strcmp(old_win_path, win_path) ) { - if( xctx->semaphore >= 1 || event == Expose) { - dbg(1, "callback(): semaphore >=2 (or Expose) switching window context: %s --> %s\n", old_win_path, win_path); + redraw_only = 0; + if((event == FocusIn || event == Expose) && + !tabbed_interface && strcmp(xctx->current_win_path, win_path) ) { + if( event == Expose || xctx->semaphore >= 1 ) { + dbg(1, "callback(): semaphore >=2 (or Expose) switching window context: %s --> %s\n", + xctx->current_win_path, win_path); redraw_only = 1; + my_strncpy(old_win_path, xctx->current_win_path, S(old_win_path)); new_schematic("switch_no_tcl_ctx", win_path, "", 1); } else { dbg(1, "callback(): switching window context: %s --> %s, semaphore=%d\n", - old_win_path, win_path, xctx->semaphore); + xctx->current_win_path, win_path, xctx->semaphore); new_schematic("switch", win_path, "", 1); } /* done in switch_window() */ @@ -4775,11 +4779,6 @@ int callback(const char *win_path, int event, int mx, int my, KeySym key, int bu dbg(1, "callback(): semaphore >=2 restoring window context: %s <-- %s\n", old_win_path, win_path); if(old_win_path[0]) new_schematic("switch_no_tcl_ctx", old_win_path, "", 1); } - else - if(strcmp(old_win_path, win_path)) { - if(old_win_path[0]) dbg(1, "callback(): reset old_win_path: %s <- %s\n", old_win_path, win_path); - my_strncpy(old_win_path, win_path, S(old_win_path)); - } return 0; } diff --git a/src/xschem.tcl b/src/xschem.tcl index 32248885..88123696 100644 --- a/src/xschem.tcl +++ b/src/xschem.tcl @@ -8528,18 +8528,18 @@ global env has_x OS autofocus_mainwindow bind $parent [list raise_dialog $parent $topwin] bind $parent [list raise_dialog $parent $topwin] - bind $parent [list raise_dialog $parent $topwin] - # send non-existent event just to force change schematic window context. - bind $parent " + # This event will cause a window context switch + bind $parent " + raise_dialog $parent $topwin if { {$parent} eq {.}} { if { {%W} eq {$parent}} { # send a fake event just to force context switching in callback() - xschem callback .drw -55 0 0 0 0 0 0 + xschem callback .drw %T 0 0 0 0 0 0 } } else { if { {%W} eq {$parent}} { # send a fake event just to force context switching in callback() - xschem callback $parent.drw -55 0 0 0 0 0 0 + xschem callback $parent.drw %T 0 0 0 0 0 0 } } " @@ -8565,18 +8565,17 @@ global env has_x OS autofocus_mainwindow bind $topwin "xschem callback %W -3 %x %y 0 %b 0 %s" bind $topwin "xschem callback %W -3 %x %y 0 %b 0 %s" bind $topwin "xschem callback %W %T %x %y 0 %w %h 0" - bind $topwin "focus $topwin; xschem callback %W %T %x %y 0 %b 0 %s" + 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 "xschem callback %W %T %x %y 0 %b 0 %s" bind $topwin "xschem callback %W %T %x %y %N 0 0 %s" bind $topwin "xschem callback %W %T %x %y %N 0 0 %s" if {$autofocus_mainwindow} { bind $topwin "focus $topwin; xschem callback %W %T %x %y 0 0 0 %s" - bind $topwin " - # if {\$draw_crosshair} {$topwin configure -cursor none} - destroy .ctxmenu - focus $topwin - xschem callback %W %T %x %y 0 0 0 0 - " + bind $topwin "destroy .ctxmenu; focus $topwin; xschem callback %W %T %x %y 0 0 0 0" } else { bind $topwin "xschem callback %W %T %x %y 0 0 0 %s" bind $topwin "destroy .ctxmenu; xschem callback %W %T %x %y 0 0 0 0" @@ -9736,7 +9735,7 @@ proc entry_replace_selection {w} { # focus the schematic window if mouse goes over it, even if a dialog box is displayed, # without needing to click. This allows to move/zoom/pan the schematic while editing attributes. -set_ne autofocus_mainwindow 1 +set_ne autofocus_mainwindow 0 if {$OS == "Windows"} { set_ne XSCHEM_TMP_DIR [xschem get temp_dir] } else { diff --git a/src/xschemrc b/src/xschemrc index dcae27bc..c4d69d6c 100644 --- a/src/xschemrc +++ b/src/xschemrc @@ -327,8 +327,8 @@ #### This allows to move/zoom/pan the schematic while editing attributes. #### Clicking in the schematic window usually closes the dialog box or starts #### editing a new component if clicking on a new component. -#### default: enabled (1) -# set autofocus_mainwindow 0 +#### default: NOT enabled (0) +# set autofocus_mainwindow 1 #### replace selected text in text widgets when pasting from clipboard #### default: enabled (1)