diff --git a/src/draw.c b/src/draw.c index fba8eac6..e1be0381 100644 --- a/src/draw.c +++ b/src/draw.c @@ -662,6 +662,7 @@ void drawgrid() int i=0; int big_gr; + dbg(1, "drawgrid(): draw grid\n"); big_gr = tclgetboolvar("big_grid_points"); if( !tclgetboolvar("draw_grid") || !has_x) return; delta=tclgetdoublevar("cadgrid")*xctx->mooz; @@ -1499,7 +1500,7 @@ void draw(void) if(xctx->draw_window) XFillRectangle(display, xctx->window, xctx->gc[BACKLAYER], xctx->areax1, xctx->areay1, xctx->areaw, xctx->areah); - dbg(2, "draw(): window: %d %d %d %d\n",xctx->areax1, xctx->areay1, xctx->areax2, xctx->areay2); + dbg(1, "draw(): window: %d %d %d %d\n",xctx->areax1, xctx->areay1, xctx->areax2, xctx->areay2); drawgrid(); x1 = X_TO_XSCHEM(xctx->areax1); y1 = Y_TO_XSCHEM(xctx->areay1); diff --git a/src/xinit.c b/src/xinit.c index 5bbc9a07..608547f7 100644 --- a/src/xinit.c +++ b/src/xinit.c @@ -874,6 +874,8 @@ void new_schematic(const char *what, const char *top_path, const char *tk_win_pa enable_layers(); build_colors(0.0, 0.0); resetwin(1, 0, 1, 0, 0); /* create preview pixmap. resetwin(create_pixmap, clear_pixmap, force, w, h) */ + /* draw empty window so if following load fails due to missing file window appears correctly drawn */ + zoom_full(1, 0, 1, 0.97); load_schematic(1,filename, 1); zoom_full(1, 0, 1, 0.97); /* draw */ } else if(!strcmp(what, "destroy")) { @@ -1605,7 +1607,7 @@ int Tcl_AppInit(Tcl_Interp *inter) dbg(1, "Tcl_AppInit(): done xinit()\n"); /* Set backing store window attribute */ winattr.backing_store = WhenMapped; - /* winattr.backing_store = NotUseful;*/ + /* winattr.backing_store = NotUseful; */ Tk_ChangeWindowAttributes(tkwindow, CWBackingStore, &winattr); dbg(1, "Tcl_AppInit(): sizeof xInstance=%lu , sizeof xSymbol=%lu\n", @@ -1642,7 +1644,7 @@ int Tcl_AppInit(Tcl_Interp *inter) /* Completing tk windows creation (see xschem.tcl, pack_widgets) and event binding */ /* *AFTER* X initialization done */ /* */ - if(has_x) tcleval("pack_widgets"); + if(has_x) tcleval("pack_widgets; set_bindings .drw"); fs=tclgetintvar("fullscreen"); if(fs) { diff --git a/src/xschem.tcl b/src/xschem.tcl index 81c0b2d6..669a4e80 100644 --- a/src/xschem.tcl +++ b/src/xschem.tcl @@ -3450,7 +3450,6 @@ proc every {interval script} { after $interval [list every $interval $script] } -#### TEST MODE ##### proc new_window {what {filename {}} {path {-}}} { if { $what eq {create}} { if {$tctx::cnt == 0} { @@ -3466,9 +3465,9 @@ proc new_window {what {filename {}} {path {-}}} { } } toplevel $path -bg {} -width 400 -height 400 - update build_widgets $path pack_widgets $path ;# also does set_bindings $path.drw + set_bindings $path.drw update xschem new_schematic create $path $path.drw [abs_sym_path $filename] save_ctx $path.drw @@ -3656,49 +3655,55 @@ global env has_x OS ### ### Tk event handling ### - set parent [winfo toplevel $topwin] - - 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 " - 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 + if {($OS== "Windows" || [string length [lindex [array get env DISPLAY] 1] ] > 0 ) && [info exists has_x]} { + set parent [winfo toplevel $topwin] + + 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 " + 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 + } + } 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 + } } - } 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 - } - } - " - bind $topwin "xschem callback %W %T %x %y 0 %w %h %s" - 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 -3 %x %y 0 %b 0 %s" - bind $topwin "xschem windowid; xschem callback %W %T %x %y 0 %w %h 0" - 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" - bind $topwin "focus $topwin; xschem callback %W %T %x %y 0 0 0 %s" - bind $topwin "focus $topwin; xschem callback %W %T %x %y 0 0 0 0" - bind $topwin " wm withdraw .infotext; set show_infowindow 0 " - bind $topwin "?" {textwindow "${XSCHEM_SHAREDIR}/xschem.help"} - - # on Windows Alt key mask is reported as 131072 (1<<17) so build masks manually with values passed from C code - if {$OS == "Windows" } { - bind $topwin {xschem callback %W %T %x %y %N 0 0 [expr {$Mod1Mask}]} - bind $topwin {xschem callback %W %T %x %y %N 0 0 [expr {$ControlMask + $Mod1Mask}]} - bind $topwin {xschem callback %W %T %x %y %N 0 0 [expr {$ShiftMask + $Mod1Mask}]} - bind $topwin { - if {%D<0} { - xschem callback %W 4 %x %y 0 5 0 %s - } else { - xschem callback %W 4 %x %y 0 4 0 %s + " + bind $topwin "xschem callback %W %T %x %y 0 %w %h %s" + 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 -3 %x %y 0 %b 0 %s" + if { $topwin eq {.drw} } { + bind $topwin "xschem windowid; xschem callback %W %T %x %y 0 %w %h 0" + } else { + bind $topwin "xschem callback %W %T %x %y 0 %w %h 0" + } + 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" + bind $topwin "focus $topwin; xschem callback %W %T %x %y 0 0 0 %s" + bind $topwin "focus $topwin; xschem callback %W %T %x %y 0 0 0 0" + bind $topwin " wm withdraw .infotext; set show_infowindow 0 " + bind $topwin "?" {textwindow "${XSCHEM_SHAREDIR}/xschem.help"} + + # on Windows Alt key mask is reported as 131072 (1<<17) so build masks manually with values passed from C code + if {$OS == "Windows" } { + bind $topwin {xschem callback %W %T %x %y %N 0 0 [expr {$Mod1Mask}]} + bind $topwin {xschem callback %W %T %x %y %N 0 0 [expr {$ControlMask + $Mod1Mask}]} + bind $topwin {xschem callback %W %T %x %y %N 0 0 [expr {$ShiftMask + $Mod1Mask}]} + bind $topwin { + if {%D<0} { + xschem callback %W 4 %x %y 0 5 0 %s + } else { + xschem callback %W 4 %x %y 0 4 0 %s + } } } }