refactor event code (FocusIn/Enter races)

This commit is contained in:
stefan schippers 2025-04-01 11:41:35 +02:00
parent 232ca9c58c
commit 36cbb84c04
2 changed files with 33 additions and 13 deletions

View File

@ -2450,16 +2450,19 @@ static void handle_enter_notify(int draw_xhair, int crosshair_size)
in another xschem xctx->window; STARTCOPY set and selection file does not exist any more */
if(stat(sel_file, &buf) && (xctx->ui_state & STARTCOPY) )
{
dbg(1, "xschem window *sending* selected objects: abort\n");
copy_objects(ABORT);
unselect_all(1);
}
/* xschem window *receiving* selected objects selection cleared --> abort */
else if(xctx->paste_from == 1 && stat(sel_file, &buf) && (xctx->ui_state & STARTMERGE)) {
dbg(1, " xschem window *receiving* selected objects selection cleared: abort\n");
abort_operation();
}
/*xschem window *receiving* selected objects
* no selected objects and selection file exists --> start merge */
else if(xctx->lastsel == 0 && !stat(sel_file, &buf)) {
dbg(1,"xschem window *receiving* selected objects: start merge\n");
xctx->mousex_snap = 490;
xctx->mousey_snap = -340;
merge_file(1, ".sch");
@ -4637,8 +4640,7 @@ static int handle_window_switching(int event, int tabbed_interface, const char *
xctx->current_win_path, win_path, xctx->semaphore);
new_schematic("switch", win_path, "", 1);
}
/* done in switch_window() */
/* tclvareval("housekeeping_ctx", NULL); */
}
} else {
/* if something needs to be done in tabbed interface do it here */

View File

@ -8537,22 +8537,29 @@ global env has_x OS autofocus_mainwindow
### Tk event handling
###
# puts "set_binding: topwin=$topwin"
if {($OS== "Windows" || [string length [lindex [array get env DISPLAY] 1] ] > 0 ) && [info exists has_x]} {
set parent [winfo toplevel $topwin]
# puts "set_binding: topwin=$topwin, parent=$parent"
bind $parent <Expose> [list raise_dialog $parent $topwin]
bind $parent <Expose> "if {{%W} eq {$parent}} {raise_dialog $parent $topwin}"
bind $parent <Visibility> [list raise_dialog $parent $topwin]
# 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
# Context switch.
bind $parent <FocusIn> "
# if {{%W} eq {$parent}} {
# xschem switch $topwin
# }
switch_window $parent $topwin %T %W
"
bind $topwin <Expose> "xschem callback %W %T %x %y 0 %w %h %s"
bind $topwin <Leave> "
if {{%W} eq {$topwin}} {
xschem callback %W %T %x %y 0 0 0 %s
graph_show_measure stop
}
"
bind $topwin <Expose> "if {{%W} eq {$topwin}} {xschem callback %W %T %x %y 0 %w %h %s}"
# transform mousewheel events into button4/5 events
if {[info tclversion] > 8.7} {
@ -8581,10 +8588,21 @@ global env has_x OS autofocus_mainwindow
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> "destroy .ctxmenu; focus $topwin; xschem callback %W %T %x %y 0 0 0 0"
bind $topwin <Enter> "
if {{%W} eq {$topwin}} {
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"
bind $topwin <Enter> "
if {{%W} eq {$topwin}} {
destroy .ctxmenu
xschem callback %W %T %x %y 0 0 0 0
}
"
}
bind $topwin <Unmap> " wm withdraw .infotext; set show_infowindow 0 "
bind $topwin "?" {textwindow "${XSCHEM_SHAREDIR}/xschem.help"}