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)

This commit is contained in:
stefan schippers 2025-03-24 13:46:15 +01:00
parent 48beb76087
commit 5ac170f2a5
3 changed files with 25 additions and 27 deletions

View File

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

View File

@ -8528,18 +8528,18 @@ global env has_x OS autofocus_mainwindow
bind $parent <Expose> [list raise_dialog $parent $topwin]
bind $parent <Visibility> [list raise_dialog $parent $topwin]
bind $parent <FocusIn> [list raise_dialog $parent $topwin]
# send non-existent event just to force change schematic window context.
bind $parent <Enter> "
# This event will cause a window context switch
bind $parent <FocusIn> "
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 <Double-Button-2> "xschem callback %W -3 %x %y 0 %b 0 %s"
bind $topwin <Double-Button-3> "xschem callback %W -3 %x %y 0 %b 0 %s"
bind $topwin <Configure> "xschem callback %W %T %x %y 0 %w %h 0"
bind $topwin <ButtonPress> "focus $topwin; xschem callback %W %T %x %y 0 %b 0 %s"
if {$autofocus_mainwindow} {
bind $topwin <ButtonPress> "focus $topwin; xschem callback %W %T %x %y 0 %b 0 %s"
} else {
bind $topwin <ButtonPress> "xschem callback %W %T %x %y 0 %b 0 %s"
}
bind $topwin <ButtonRelease> "xschem callback %W %T %x %y 0 %b 0 %s"
bind $topwin <KeyPress> "xschem callback %W %T %x %y %N 0 0 %s"
bind $topwin <KeyRelease> "xschem callback %W %T %x %y %N 0 0 %s"
if {$autofocus_mainwindow} {
bind $topwin <Motion> "focus $topwin; xschem callback %W %T %x %y 0 0 0 %s"
bind $topwin <Enter> "
# if {\$draw_crosshair} {$topwin configure -cursor none}
destroy .ctxmenu
focus $topwin
xschem callback %W %T %x %y 0 0 0 0
"
bind $topwin <Enter> "destroy .ctxmenu; focus $topwin; xschem callback %W %T %x %y 0 0 0 0"
} else {
bind $topwin <Motion> "xschem callback %W %T %x %y 0 0 0 %s"
bind $topwin <Enter> "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 {

View File

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