diff --git a/src/callback.c b/src/callback.c index dacb84c4..4452c44c 100644 --- a/src/callback.c +++ b/src/callback.c @@ -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); diff --git a/src/xschem.tcl b/src/xschem.tcl index 88123696..b11139ac 100644 --- a/src/xschem.tcl +++ b/src/xschem.tcl @@ -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 [list raise_dialog $parent $topwin] bind $parent [list raise_dialog $parent $topwin] # 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 %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 "switch_window $parent $topwin %T %W" + # This event will cause a window context switch + bind $parent "switch_window $parent $topwin %T %W" bind $topwin " xschem callback %W %T %x %y 0 0 0 %s graph_show_measure stop - # $topwin configure -cursor {} " bind $topwin "xschem callback %W %T %x %y 0 %w %h %s"