even in click to focus mode allow switching to other window when copying stuff across windows

This commit is contained in:
stefan schippers 2025-03-24 15:32:37 +01:00
parent 5ac170f2a5
commit 3443e9aff5
2 changed files with 31 additions and 19 deletions

View File

@ -4653,15 +4653,23 @@ int callback(const char *win_path, int event, int mx, int my, KeySym key, int bu
/* Schematic window context switch */
redraw_only = 0;
if((event == FocusIn || event == Expose) &&
if((event == FocusIn || event == Expose || event == EnterNotify) &&
!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",
struct stat buf;
/* This will switch context only when copying stuff across windows */
if( event == EnterNotify && (!stat(sel_file, &buf) && (xctx->ui_state & STARTCOPY))) {
dbg(1, "callback(): switching window context for copy : %s --> %s, semaphore=%d\n",
xctx->current_win_path, win_path, xctx->semaphore);
new_schematic("switch", win_path, "", 1);
/* This does a "temporary" switch just to redraw obcured window parts */
} else if(event == Expose || xctx->semaphore >= 1 ) {
dbg(1, "callback(): switching window context for redraw ONLY: %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 {
/* this is the regular context switch when window gets focused */
} else if(event == FocusIn && xctx->semaphore == 0) {
dbg(1, "callback(): switching window context: %s --> %s, semaphore=%d\n",
xctx->current_win_path, win_path, xctx->semaphore);
new_schematic("switch", win_path, "", 1);

View File

@ -8516,6 +8516,22 @@ proc getmousey {win} {
return $rely
}
proc switch_window {parent topwin event window} {
# puts "$parent $topwin $event $window"
raise_dialog $parent $topwin
if { $parent eq {.}} {
if { $window eq $parent} {
xschem callback .drw $event 0 0 0 0 0 0
}
} else {
if {$window eq $parent} {
# send a fake event just to force context switching in callback()
xschem callback $parent.drw $event 0 0 0 0 0 0
}
}
}
proc set_bindings {topwin} {
global env has_x OS autofocus_mainwindow
###
@ -8529,24 +8545,12 @@ global env has_x OS autofocus_mainwindow
bind $parent <Expose> [list raise_dialog $parent $topwin]
bind $parent <Visibility> [list raise_dialog $parent $topwin]
# 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 %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 %T 0 0 0 0 0 0
}
}
"
bind $parent <Enter> "switch_window $parent $topwin %T %W"
# This event will cause a window context switch
bind $parent <FocusIn> "switch_window $parent $topwin %T %W"
bind $topwin <Leave> "
xschem callback %W %T %x %y 0 0 0 %s
graph_show_measure stop
# $topwin configure -cursor {}
"
bind $topwin <Expose> "xschem callback %W %T %x %y 0 %w %h %s"