diff --git a/scconfig/src/gui/Makefile.plugin b/scconfig/src/gui/Makefile.plugin index 4d3e8982..f8e1a0be 100644 --- a/scconfig/src/gui/Makefile.plugin +++ b/scconfig/src/gui/Makefile.plugin @@ -18,6 +18,9 @@ $(BIN)/gui/find_gtk2.o: $(SRC)/gui/find_gtk2.c $(BIN)/gui/find_gtk3.o: $(SRC)/gui/find_gtk3.c $(CC) $(CFLAGS) -c $(SRC)/gui/find_gtk3.c -o $(BIN)/gui/find_gtk3.o +$(BIN)/gui/find_gtk4.o: $(SRC)/gui/find_gtk4.c + $(CC) $(CFLAGS) -c $(SRC)/gui/find_gtk4.c -o $(BIN)/gui/find_gtk4.o + $(BIN)/gui/find_lesstif2.o: $(SRC)/gui/find_lesstif2.c $(CC) $(CFLAGS) -c $(SRC)/gui/find_lesstif2.c -o $(BIN)/gui/find_lesstif2.o diff --git a/scconfig/src/gui/find_gtk4.c b/scconfig/src/gui/find_gtk4.c index 869f74ce..b9adbbc0 100644 --- a/scconfig/src/gui/find_gtk4.c +++ b/scconfig/src/gui/find_gtk4.c @@ -94,3 +94,33 @@ int find_gtk4_modversion(const char *name, int logdepth, int fatal) } +int find_epoxy(const char *name, int logdepth, int fatal) +{ + static const char *node = "libs/gui/epoxy"; + static const char *pkgname = "epoxy"; + const char *test_c = + NL "#include " + NL "#include " + NL "int main() {" + NL " const char *list = \"foo bar baz\";" + NL " if (epoxy_extension_in_string(list, \"bar\") && !epoxy_extension_in_string(list, \"foobar\"))" + NL " printf(\"OK\\n\");" + NL " return 0;" + NL "}" + NL; + + if (require("cc/cc", logdepth, fatal)) + return try_fail(logdepth, node); + + report("Checking for epoxy... "); + logprintf(logdepth, "find_epoxy: running pkg-config...\n"); + logdepth++; + + if (try_icl_pkg_config(logdepth, node, test_c, NULL, "epoxy", NULL)) + return 0; + + if (try_icl(logdepth, node, test_c, NULL, "", "-lepoxy")) + return 0; + + return try_fail(logdepth, node); +} diff --git a/scconfig/src/gui/find_gtk4.h b/scconfig/src/gui/find_gtk4.h index 274c9bea..bed84b0c 100644 --- a/scconfig/src/gui/find_gtk4.h +++ b/scconfig/src/gui/find_gtk4.h @@ -1,4 +1,6 @@ int find_gtk4(const char *name, int logdepth, int fatal); int find_gtk4_modversion(const char *name, int logdepth, int fatal); +int find_epoxy(const char *name, int logdepth, int fatal, const char *call, const char *arg); + diff --git a/scconfig/src/gui/gui.c b/scconfig/src/gui/gui.c index 852482f6..065ca6e0 100644 --- a/scconfig/src/gui/gui.c +++ b/scconfig/src/gui/gui.c @@ -29,6 +29,7 @@ void deps_gui_init() dep_add("libs/gui/gtk3/*", find_gtk3); dep_add("libs/gui/gtk4/*", find_gtk4); dep_add("libs/gui/gtk4/modversion", find_gtk4_modversion); + dep_add("libs/gui/epoxy/*", find_epoxy); dep_add("libs/gui/lesstif2/exthi/*", find_lesstif2_exthi); dep_add("libs/gui/lesstif2/*", find_lesstif2); dep_add("libs/gui/libstroke/*", find_libstroke); diff --git a/src/actions.c b/src/actions.c index ac72c61a..24562408 100644 --- a/src/actions.c +++ b/src/actions.c @@ -33,17 +33,20 @@ void here(int i) void set_modify(int mod) { static int prev = -1; + char *top_path; + + top_path = xctx->top_path[0] ? xctx->top_path : "."; xctx->modified = mod; dbg(1, "set_modify(): %d\n", mod); if(mod != prev) { prev = mod; if(has_x && strcmp(get_cell(xctx->sch[xctx->currsch],1), "systemlib/font")) { if(mod == 1) { - tcleval( "wm title . \"xschem - [file tail [xschem get schname]]*\""); - tcleval( "wm iconname . \"xschem - [file tail [xschem get schname]]*\""); + Tcl_VarEval(interp, "wm title ", top_path, " \"xschem - [file tail [xschem get schname]]*\"", NULL); + Tcl_VarEval(interp, "wm iconname ", top_path, " \"xschem - [file tail [xschem get schname]]*\"", NULL); } else { - tcleval( "wm title . \"xschem - [file tail [xschem get schname]]\""); - tcleval( "wm iconname . \"xschem - [file tail [xschem get schname]]\""); + Tcl_VarEval(interp, "wm title ", top_path, " \"xschem - [file tail [xschem get schname]]\"", NULL); + Tcl_VarEval(interp, "wm iconname ", top_path, " \"xschem - [file tail [xschem get schname]]\"", NULL); } } } @@ -118,9 +121,9 @@ void set_snap(double newsnap) /* 20161212 set new snap factor and just notify n } cs = newsnap ? newsnap : default_snap; if(cs == default_snap) { - tcleval(".statusbar.3 configure -background PaleGreen"); + Tcl_VarEval(interp, xctx->top_path, ".statusbar.3 configure -background PaleGreen", NULL); } else { - tcleval(".statusbar.3 configure -background OrangeRed"); + Tcl_VarEval(interp, xctx->top_path, ".statusbar.3 configure -background OrangeRed", NULL); } tclsetdoublevar("cadsnap", cs); } @@ -138,9 +141,9 @@ void set_grid(double newgrid) cg = newgrid ? newgrid : default_grid; dbg(1, "set_grid(): default_grid = %.16g, cadgrid=%.16g\n", default_grid, cg); if(cg == default_grid) { - tcleval(".statusbar.5 configure -background PaleGreen"); + Tcl_VarEval(interp, xctx->top_path, ".statusbar.5 configure -background PaleGreen", NULL); } else { - tcleval(".statusbar.5 configure -background OrangeRed"); + Tcl_VarEval(interp, xctx->top_path, ".statusbar.5 configure -background OrangeRed", NULL); } tclsetdoublevar("cadgrid", cg); } @@ -213,7 +216,6 @@ void toggle_only_probes() void toggle_fullscreen(const char *topwin) { - char *mytopwin = NULL; char fullscr[]="add,fullscreen"; char normal[]="remove,fullscreen"; static int menu_removed = 0; @@ -225,13 +227,10 @@ void toggle_fullscreen(const char *topwin) if(!strcmp(topwin, ".drw")) { - my_strdup2(1290, &mytopwin, ""); tcleval( "winfo id ."); sscanf(tclresult(), "0x%x", (unsigned int *) &topwin_id); } else { - Tcl_VarEval(interp, "winfo toplevel ", topwin, NULL); - my_strdup2(1291, &mytopwin, tclresult()); - Tcl_VarEval(interp, "winfo id ", mytopwin, NULL); + Tcl_VarEval(interp, "winfo id ", xctx->top_path, NULL); sscanf(tclresult(), "0x%x", (unsigned int *) &topwin_id); } @@ -246,12 +245,13 @@ void toggle_fullscreen(const char *topwin) dbg(1, "toggle_fullscreen(): fullscreen=%d\n", fs); if(fs==2) { - Tcl_VarEval(interp, "pack forget ", mytopwin, ".menubar ", mytopwin, ".statusbar; update", NULL); + Tcl_VarEval(interp, "pack forget ", xctx->top_path, ".menubar ", xctx->top_path, ".statusbar; update", NULL); menu_removed = 1; } if(fs !=2 && menu_removed) { - Tcl_VarEval(interp, "pack ", mytopwin, ".menubar -anchor n -side top -fill x -before ", mytopwin, ".drw\n\ - pack ", mytopwin, ".statusbar -after ", mytopwin, ".drw -anchor sw -fill x; update", NULL); + Tcl_VarEval(interp, "pack ", xctx->top_path, + ".menubar -anchor n -side top -fill x -before ", xctx->top_path, ".drw; pack ", + xctx->top_path, ".statusbar -after ", xctx->top_path, ".drw -anchor sw -fill x; update", NULL); menu_removed=0; } @@ -265,7 +265,6 @@ void toggle_fullscreen(const char *topwin) window_state(display , parent_id,normal); } xctx->pending_fullzoom=1; - my_free(1291, &mytopwin); } #ifdef __unix__ @@ -312,12 +311,12 @@ void new_window(const char *cell, int symbol) } else { /* error */ fprintf(errfp, "new_window(): fork error 1\n"); - tcleval( "exit"); + tcleval("exit"); } } else { /* error */ fprintf(errfp, "new_window(): fork error 2\n"); - tcleval( "exit"); + tcleval("exit"); } } #else @@ -597,15 +596,15 @@ void enable_layers(void) { int i; char tmp[50]; - n_active_layers = 0; + xctx->n_active_layers = 0; for(i = 0; i< cadlayers; i++) { my_snprintf(tmp, S(tmp), "enable_layer(%d)",i); - if(tclgetvar(tmp)[0] == '0') enable_layer[i] = 0; + if(tclgetvar(tmp)[0] == '0') xctx->enable_layer[i] = 0; else { - enable_layer[i] = 1; + xctx->enable_layer[i] = 1; if(i>=7) { - active_layer[n_active_layers] = i; - n_active_layers++; + xctx->active_layer[xctx->n_active_layers] = i; + xctx->n_active_layers++; } } } @@ -921,9 +920,9 @@ int place_symbol(int pos, const char *symbol_name, double x, double y, short rot if(draw_sym & 4 ) { select_element(n, SELECTED,0, 0); - drawtemparc(gc[SELLAYER], END, 0.0, 0.0, 0.0, 0.0, 0.0); - drawtemprect(gc[SELLAYER], END, 0.0, 0.0, 0.0, 0.0); - drawtempline(gc[SELLAYER], END, 0.0, 0.0, 0.0, 0.0); + drawtemparc(xctx->gc[SELLAYER], END, 0.0, 0.0, 0.0, 0.0, 0.0); + drawtemprect(xctx->gc[SELLAYER], END, 0.0, 0.0, 0.0, 0.0); + drawtempline(xctx->gc[SELLAYER], END, 0.0, 0.0, 0.0, 0.0); xctx->need_reb_sel_arr = 1; rebuild_selected_array(); /* sets xctx->ui_state |= SELECTION; */ } @@ -1142,7 +1141,7 @@ void go_back(int confirm) /* 20171006 add confirm */ int prev_sch_type; save_ok=0; - prev_sch_type = netlist_type; /* if CAD_SYMBOL_ATTRS do not hilight_parent_pins */ + prev_sch_type = xctx->netlist_type; /* if CAD_SYMBOL_ATTRS do not hilight_parent_pins */ if(xctx->currsch>0) { /* if current sym/schematic is changed ask save before going up */ @@ -1528,12 +1527,12 @@ void zoom_rectangle(int what) bbox(START,0.0, 0.0, 0.0, 0.0); bbox(ADD, xctx->nl_xx1, xctx->nl_yy1, xctx->nl_xx2, xctx->nl_yy2); bbox(SET,0.0, 0.0, 0.0, 0.0); - draw_selection(gc[SELLAYER], 0); + draw_selection(xctx->gc[SELLAYER], 0); bbox(END,0.0, 0.0, 0.0, 0.0); xctx->nl_xx1=xctx->nl_x1;xctx->nl_yy1=xctx->nl_y1;xctx->nl_xx2=xctx->nl_x2;xctx->nl_yy2=xctx->nl_y2; RECTORDER(xctx->nl_xx1,xctx->nl_yy1,xctx->nl_xx2,xctx->nl_yy2); - drawtemprect(gc[SELLAYER], NOW, xctx->nl_xx1,xctx->nl_yy1,xctx->nl_xx2,xctx->nl_yy2); + drawtemprect(xctx->gc[SELLAYER], NOW, xctx->nl_xx1,xctx->nl_yy1,xctx->nl_xx2,xctx->nl_yy2); } } @@ -1563,7 +1562,7 @@ void draw_stuff(void) xctx->rectcolor = (int) (16.0*rand()/(RAND_MAX+1.0))+4; storeobject(-1, x1, y1, x2, y2, xRECT,xctx->rectcolor, 0, NULL); #else - drawtemprect(gc[xctx->rectcolor], ADD, x1, y1, x2, y2); + drawtemprect(xctx->gc[xctx->rectcolor], ADD, x1, y1, x2, y2); #endif } @@ -1580,7 +1579,7 @@ void draw_stuff(void) xctx->rectcolor = (int) (16.0*rand()/(RAND_MAX+1.0))+4; storeobject(-1, x1, y1, x2, y2,xRECT,xctx->rectcolor, 0, NULL); #else - drawtemprect(gc[xctx->rectcolor], ADD, x1, y1, x2, y2); + drawtemprect(xctx->gc[xctx->rectcolor], ADD, x1, y1, x2, y2); #endif } @@ -1597,11 +1596,11 @@ void draw_stuff(void) xctx->rectcolor = (int) (16.0*rand()/(RAND_MAX+1.0))+4; storeobject(-1, x1, y1, x2, y2,xRECT,xctx->rectcolor, 0, NULL); #else - drawtemprect(gc[xctx->rectcolor], ADD, x1, y1, x2, y2); + drawtemprect(xctx->gc[xctx->rectcolor], ADD, x1, y1, x2, y2); #endif } #ifndef STORE - drawtemprect(gc[xctx->rectcolor], END, 0.0, 0.0, 0.0, 0.0); + drawtemprect(xctx->gc[xctx->rectcolor], END, 0.0, 0.0, 0.0, 0.0); } #else draw(); @@ -1618,7 +1617,7 @@ void restore_selection(double x1, double y1, double x2, double y2) bbox(START,0.0, 0.0, 0.0, 0.0); bbox(ADD, xx1, yy1, xx2, yy2); bbox(SET,0.0, 0.0, 0.0, 0.0); - draw_selection(gc[SELLAYER], 0); + draw_selection(xctx->gc[SELLAYER], 0); bbox(END,0.0, 0.0, 0.0, 0.0); } @@ -1703,27 +1702,27 @@ void new_wire(int what, double mx_snap, double my_snap) xctx->nl_xx1 = xctx->nl_x1; xctx->nl_yy1 = xctx->nl_y1; xctx->nl_xx2 = xctx->nl_x2; xctx->nl_yy2 = xctx->nl_y2; ORDER(xctx->nl_xx1,xctx->nl_yy1,xctx->nl_xx2,xctx->nl_yy1); - drawtempline(gc[WIRELAYER], NOW, xctx->nl_xx1,xctx->nl_yy1,xctx->nl_xx2,xctx->nl_yy1); + drawtempline(xctx->gc[WIRELAYER], NOW, xctx->nl_xx1,xctx->nl_yy1,xctx->nl_xx2,xctx->nl_yy1); xctx->nl_xx1 = xctx->nl_x1; xctx->nl_yy1 = xctx->nl_y1; xctx->nl_xx2 = xctx->nl_x2; xctx->nl_yy2 = xctx->nl_y2; ORDER(xctx->nl_xx2,xctx->nl_yy1,xctx->nl_xx2,xctx->nl_yy2); - drawtempline(gc[WIRELAYER], NOW, xctx->nl_xx2,xctx->nl_yy1,xctx->nl_xx2,xctx->nl_yy2); + drawtempline(xctx->gc[WIRELAYER], NOW, xctx->nl_xx2,xctx->nl_yy1,xctx->nl_xx2,xctx->nl_yy2); } else if(xctx->manhattan_lines==2) { xctx->nl_x2 = mx_snap; xctx->nl_y2 = my_snap; xctx->nl_xx1 = xctx->nl_x1; xctx->nl_yy1 = xctx->nl_y1; xctx->nl_xx2 = xctx->nl_x2; xctx->nl_yy2 = xctx->nl_y2; ORDER(xctx->nl_xx1,xctx->nl_yy1,xctx->nl_xx1,xctx->nl_yy2); - drawtempline(gc[WIRELAYER], NOW, xctx->nl_xx1,xctx->nl_yy1,xctx->nl_xx1,xctx->nl_yy2); + drawtempline(xctx->gc[WIRELAYER], NOW, xctx->nl_xx1,xctx->nl_yy1,xctx->nl_xx1,xctx->nl_yy2); xctx->nl_xx1 = xctx->nl_x1; xctx->nl_yy1 = xctx->nl_y1; xctx->nl_xx2 = xctx->nl_x2; xctx->nl_yy2 = xctx->nl_y2; ORDER(xctx->nl_xx1,xctx->nl_yy2,xctx->nl_xx2,xctx->nl_yy2); - drawtempline(gc[WIRELAYER], NOW, xctx->nl_xx1,xctx->nl_yy2,xctx->nl_xx2,xctx->nl_yy2); + drawtempline(xctx->gc[WIRELAYER], NOW, xctx->nl_xx1,xctx->nl_yy2,xctx->nl_xx2,xctx->nl_yy2); } else { xctx->nl_x2 = mx_snap; xctx->nl_y2 = my_snap; xctx->nl_xx1 = xctx->nl_x1; xctx->nl_yy1 = xctx->nl_y1; xctx->nl_xx2 = xctx->nl_x2; xctx->nl_yy2 = xctx->nl_y2; ORDER(xctx->nl_xx1,xctx->nl_yy1,xctx->nl_xx2,xctx->nl_yy2); - drawtempline(gc[WIRELAYER], NOW, xctx->nl_xx1,xctx->nl_yy1,xctx->nl_xx2,xctx->nl_yy2); + drawtempline(xctx->gc[WIRELAYER], NOW, xctx->nl_xx1,xctx->nl_yy1,xctx->nl_xx2,xctx->nl_yy2); } } xctx->ui_state |= STARTWIRE; @@ -1747,11 +1746,11 @@ void new_wire(int what, double mx_snap, double my_snap) xctx->nl_xx1 = xctx->nl_x1; xctx->nl_yy1 = xctx->nl_y1; xctx->nl_xx2 = xctx->nl_x2; xctx->nl_yy2 = xctx->nl_y2; ORDER(xctx->nl_xx1,xctx->nl_yy1,xctx->nl_xx2,xctx->nl_yy1); - drawtempline(gc[WIRELAYER], NOW, xctx->nl_xx1,xctx->nl_yy1,xctx->nl_xx2,xctx->nl_yy1); + drawtempline(xctx->gc[WIRELAYER], NOW, xctx->nl_xx1,xctx->nl_yy1,xctx->nl_xx2,xctx->nl_yy1); xctx->nl_xx1 = xctx->nl_x1; xctx->nl_yy1 = xctx->nl_y1; xctx->nl_xx2 = xctx->nl_x2; xctx->nl_yy2 = xctx->nl_y2; ORDER(xctx->nl_xx2,xctx->nl_yy1,xctx->nl_xx2,xctx->nl_yy2); - drawtempline(gc[WIRELAYER], NOW, xctx->nl_xx2,xctx->nl_yy1,xctx->nl_xx2,xctx->nl_yy2); + drawtempline(xctx->gc[WIRELAYER], NOW, xctx->nl_xx2,xctx->nl_yy1,xctx->nl_xx2,xctx->nl_yy2); } } else if(xctx->manhattan_lines==2) { xctx->nl_xx1 = xctx->nl_x1; xctx->nl_yy1 = xctx->nl_y1; @@ -1768,11 +1767,11 @@ void new_wire(int what, double mx_snap, double my_snap) xctx->nl_xx1 = xctx->nl_x1; xctx->nl_yy1 = xctx->nl_y1; xctx->nl_xx2 = xctx->nl_x2; xctx->nl_yy2 = xctx->nl_y2; ORDER(xctx->nl_xx1,xctx->nl_yy1,xctx->nl_xx1,xctx->nl_yy2); - drawtempline(gc[WIRELAYER], NOW, xctx->nl_xx1,xctx->nl_yy1,xctx->nl_xx1,xctx->nl_yy2); + drawtempline(xctx->gc[WIRELAYER], NOW, xctx->nl_xx1,xctx->nl_yy1,xctx->nl_xx1,xctx->nl_yy2); xctx->nl_xx1 = xctx->nl_x1; xctx->nl_yy1 = xctx->nl_y1; xctx->nl_xx2 = xctx->nl_x2; xctx->nl_yy2 = xctx->nl_y2; ORDER(xctx->nl_xx1,xctx->nl_yy2,xctx->nl_xx2,xctx->nl_yy2); - drawtempline(gc[WIRELAYER], NOW, xctx->nl_xx1,xctx->nl_yy2,xctx->nl_xx2,xctx->nl_yy2); + drawtempline(xctx->gc[WIRELAYER], NOW, xctx->nl_xx1,xctx->nl_yy2,xctx->nl_xx2,xctx->nl_yy2); } } else { xctx->nl_xx1 = xctx->nl_x1; xctx->nl_yy1 = xctx->nl_y1; @@ -1785,7 +1784,7 @@ void new_wire(int what, double mx_snap, double my_snap) xctx->nl_xx1 = xctx->nl_x1; xctx->nl_yy1 = xctx->nl_y1; xctx->nl_xx2 = xctx->nl_x2; xctx->nl_yy2 = xctx->nl_y2; ORDER(xctx->nl_xx1,xctx->nl_yy1,xctx->nl_xx2,xctx->nl_yy2); - drawtempline(gc[WIRELAYER], NOW, xctx->nl_xx1,xctx->nl_yy1,xctx->nl_xx2,xctx->nl_yy2); + drawtempline(xctx->gc[WIRELAYER], NOW, xctx->nl_xx1,xctx->nl_yy1,xctx->nl_xx2,xctx->nl_yy2); } } } @@ -1872,7 +1871,7 @@ void new_arc(int what, double sweep) xctx->nl_yy2 = xctx->mousey_snap; xctx->nl_xx1 = xctx->nl_x1;xctx->nl_yy1 = xctx->nl_y1; ORDER(xctx->nl_xx1,xctx->nl_yy1,xctx->nl_xx2,xctx->nl_yy2); - drawtempline(gc[SELLAYER], NOW, xctx->nl_xx1,xctx->nl_yy1,xctx->nl_xx2,xctx->nl_yy2); + drawtempline(xctx->gc[SELLAYER], NOW, xctx->nl_xx1,xctx->nl_yy1,xctx->nl_xx2,xctx->nl_yy2); } else if(xctx->nl_state==1) { xctx->nl_x3 = xctx->mousex_snap; @@ -1881,7 +1880,7 @@ void new_arc(int what, double sweep) arc_3_points(xctx->nl_x1, xctx->nl_y1, xctx->nl_x2, xctx->nl_y2, xctx->nl_x3, xctx->nl_y3, &xctx->nl_x, &xctx->nl_y, &xctx->nl_r, &xctx->nl_a, &xctx->nl_b); if(xctx->nl_sweep_angle==360.) xctx->nl_b=360.; - if(xctx->nl_r>0.) drawtemparc(gc[xctx->rectcolor], NOW, xctx->nl_x, xctx->nl_y, xctx->nl_r, xctx->nl_a, xctx->nl_b); + if(xctx->nl_r>0.) drawtemparc(xctx->gc[xctx->rectcolor], NOW, xctx->nl_x, xctx->nl_y, xctx->nl_r, xctx->nl_a, xctx->nl_b); } } } @@ -1956,11 +1955,11 @@ void new_line(int what) xctx->nl_xx1 = xctx->nl_x1; xctx->nl_yy1 = xctx->nl_y1; xctx->nl_xx2 = xctx->nl_x2; xctx->nl_yy2 = xctx->nl_y2; ORDER(xctx->nl_xx1,xctx->nl_yy1,xctx->nl_xx2,xctx->nl_yy1); - drawtempline(gc[xctx->rectcolor], NOW, xctx->nl_xx1,xctx->nl_yy1,xctx->nl_xx2,xctx->nl_yy1); + drawtempline(xctx->gc[xctx->rectcolor], NOW, xctx->nl_xx1,xctx->nl_yy1,xctx->nl_xx2,xctx->nl_yy1); xctx->nl_xx1 = xctx->nl_x1; xctx->nl_yy1 = xctx->nl_y1; xctx->nl_xx2 = xctx->nl_x2; xctx->nl_yy2 = xctx->nl_y2; ORDER(xctx->nl_xx2,xctx->nl_yy1,xctx->nl_xx2,xctx->nl_yy2); - drawtempline(gc[xctx->rectcolor], NOW, xctx->nl_xx2,xctx->nl_yy1,xctx->nl_xx2,xctx->nl_yy2); + drawtempline(xctx->gc[xctx->rectcolor], NOW, xctx->nl_xx2,xctx->nl_yy1,xctx->nl_xx2,xctx->nl_yy2); } } else if(xctx->manhattan_lines==2) { xctx->nl_xx1 = xctx->nl_x1; xctx->nl_yy1 = xctx->nl_y1; @@ -1977,11 +1976,11 @@ void new_line(int what) xctx->nl_xx1 = xctx->nl_x1; xctx->nl_yy1 = xctx->nl_y1; xctx->nl_xx2 = xctx->nl_x2; xctx->nl_yy2 = xctx->nl_y2; ORDER(xctx->nl_xx1,xctx->nl_yy1,xctx->nl_xx1,xctx->nl_yy2); - drawtempline(gc[xctx->rectcolor], NOW, xctx->nl_xx1,xctx->nl_yy1,xctx->nl_xx1,xctx->nl_yy2); + drawtempline(xctx->gc[xctx->rectcolor], NOW, xctx->nl_xx1,xctx->nl_yy1,xctx->nl_xx1,xctx->nl_yy2); xctx->nl_xx1 = xctx->nl_x1; xctx->nl_yy1 = xctx->nl_y1; xctx->nl_xx2 = xctx->nl_x2; xctx->nl_yy2 = xctx->nl_y2; ORDER(xctx->nl_xx1,xctx->nl_yy2,xctx->nl_xx2,xctx->nl_yy2); - drawtempline(gc[xctx->rectcolor], NOW, xctx->nl_xx1,xctx->nl_yy2,xctx->nl_xx2,xctx->nl_yy2); + drawtempline(xctx->gc[xctx->rectcolor], NOW, xctx->nl_xx1,xctx->nl_yy2,xctx->nl_xx2,xctx->nl_yy2); } } else { xctx->nl_xx1 = xctx->nl_x1; xctx->nl_yy1 = xctx->nl_y1; @@ -1994,7 +1993,7 @@ void new_line(int what) xctx->nl_xx1 = xctx->nl_x1; xctx->nl_yy1 = xctx->nl_y1; xctx->nl_xx2 = xctx->nl_x2; xctx->nl_yy2 = xctx->nl_y2; ORDER(xctx->nl_xx1,xctx->nl_yy1,xctx->nl_xx2,xctx->nl_yy2); - drawtempline(gc[xctx->rectcolor], NOW, xctx->nl_xx1,xctx->nl_yy1,xctx->nl_xx2,xctx->nl_yy2); + drawtempline(xctx->gc[xctx->rectcolor], NOW, xctx->nl_xx1,xctx->nl_yy1,xctx->nl_xx2,xctx->nl_yy2); } } } @@ -2010,11 +2009,11 @@ void new_rect(int what) RECTORDER(xctx->nl_x1,xctx->nl_y1,xctx->nl_x2,xctx->nl_y2); push_undo(); drawrect(xctx->rectcolor, NOW, xctx->nl_x1,xctx->nl_y1,xctx->nl_x2,xctx->nl_y2, 0); - save_draw = draw_window; - draw_window = 1; + save_draw = xctx->draw_window; + xctx->draw_window = 1; /* draw fill pattern even in XCopyArea mode */ filledrect(xctx->rectcolor, NOW, xctx->nl_x1,xctx->nl_y1,xctx->nl_x2,xctx->nl_y2); - draw_window = save_draw; + xctx->draw_window = save_draw; storeobject(-1, xctx->nl_x1,xctx->nl_y1,xctx->nl_x2,xctx->nl_y2,xRECT,xctx->rectcolor, 0, NULL); } xctx->nl_x1=xctx->nl_x2=xctx->mousex_snap;xctx->nl_y1=xctx->nl_y2=xctx->mousey_snap; @@ -2032,7 +2031,7 @@ void new_rect(int what) xctx->nl_x2=xctx->mousex_snap;xctx->nl_y2=xctx->mousey_snap; xctx->nl_xx1=xctx->nl_x1;xctx->nl_yy1=xctx->nl_y1;xctx->nl_xx2=xctx->nl_x2;xctx->nl_yy2=xctx->nl_y2; RECTORDER(xctx->nl_xx1,xctx->nl_yy1,xctx->nl_xx2,xctx->nl_yy2); - drawtemprect(gc[xctx->rectcolor], NOW, xctx->nl_xx1,xctx->nl_yy1,xctx->nl_xx2,xctx->nl_yy2); + drawtemprect(xctx->gc[xctx->rectcolor], NOW, xctx->nl_xx1,xctx->nl_yy1,xctx->nl_xx2,xctx->nl_yy2); } } @@ -2088,7 +2087,7 @@ void new_polygon(int what) drawtemppolygon(xctx->gctiled, NOW, xctx->nl_polyx, xctx->nl_polyy, xctx->nl_points+1); store_poly(-1, xctx->nl_polyx, xctx->nl_polyy, xctx->nl_points, xctx->rectcolor, 0, NULL); /* fprintf(errfp, "new_poly: finish: nl_points=%d\n", xctx->nl_points); */ - drawtemppolygon(gc[xctx->rectcolor], NOW, xctx->nl_polyx, xctx->nl_polyy, xctx->nl_points); + drawtemppolygon(xctx->gc[xctx->rectcolor], NOW, xctx->nl_polyx, xctx->nl_polyy, xctx->nl_points); xctx->ui_state &= ~STARTPOLYGON; drawpolygon(xctx->rectcolor, NOW, xctx->nl_polyx, xctx->nl_polyy, xctx->nl_points, 0, 0); my_free(711, &xctx->nl_polyx); @@ -2101,7 +2100,7 @@ void new_polygon(int what) drawtemppolygon(xctx->gctiled, NOW, xctx->nl_polyx, xctx->nl_polyy, xctx->nl_points+1); xctx->nl_polyy[xctx->nl_points] = xctx->mousey_snap; xctx->nl_polyx[xctx->nl_points] = xctx->mousex_snap; - drawtemppolygon(gc[xctx->rectcolor], NOW, xctx->nl_polyx, xctx->nl_polyy, xctx->nl_points+1); + drawtemppolygon(xctx->gc[xctx->rectcolor], NOW, xctx->nl_polyx, xctx->nl_polyy, xctx->nl_points+1); } } @@ -2326,12 +2325,12 @@ int place_text(int draw_text, double mx, double my) cairo_select_font_face (xctx->cairo_save_ctx, textfont, slant, weight); } #endif - save_draw=draw_window; - draw_window=1; + save_draw=xctx->draw_window; + xctx->draw_window=1; if(draw_text) { draw_string(textlayer, NOW, t->txt_ptr, 0, 0, t->hcenter, t->vcenter, t->x0,t->y0, t->xscale, t->yscale); } - draw_window = save_draw; + xctx->draw_window = save_draw; #if HAS_CAIRO==1 if((textfont && textfont[0]) || t->flags) { cairo_restore(xctx->cairo_ctx); @@ -2341,8 +2340,8 @@ int place_text(int draw_text, double mx, double my) xctx->texts++; select_text(xctx->texts - 1, SELECTED, 0); rebuild_selected_array(); /* sets xctx->ui_state |= SELECTION */ - drawtemprect(gc[SELLAYER], END, 0.0, 0.0, 0.0, 0.0); - drawtempline(gc[SELLAYER], END, 0.0, 0.0, 0.0, 0.0); + drawtemprect(xctx->gc[SELLAYER], END, 0.0, 0.0, 0.0, 0.0); + drawtempline(xctx->gc[SELLAYER], END, 0.0, 0.0, 0.0, 0.0); set_modify(1); return 1; } @@ -2386,7 +2385,7 @@ void pan(int what) xpan2=xctx->mousex_snap;ypan2=xctx->mousey_snap; xx1=xpan;yy1=ypan;xx2=xpan2;yy2=ypan2; ORDER(xx1,yy1,xx2,yy2); - drawtempline(gc[SELLAYER], NOW, xx1,yy1,xx2,yy2); + drawtempline(xctx->gc[SELLAYER], NOW, xx1,yy1,xx2,yy2); } if(what & START) { @@ -2420,12 +2419,12 @@ void select_rect(int what, int select) bbox(START,0.0, 0.0, 0.0, 0.0); bbox(ADD, xctx->nl_xx1, xctx->nl_yy1, xctx->nl_xx2, xctx->nl_yy2); bbox(SET,0.0, 0.0, 0.0, 0.0); - draw_selection(gc[SELLAYER], 0); + draw_selection(xctx->gc[SELLAYER], 0); if(!xctx->nl_sel) select_inside(xctx->nl_xx1, xctx->nl_yy1, xctx->nl_xx2, xctx->nl_yy2, xctx->nl_sel); bbox(END,0.0, 0.0, 0.0, 0.0); xctx->nl_xx1=xctx->nl_xr;xctx->nl_xx2=xctx->nl_xr2;xctx->nl_yy1=xctx->nl_yr;xctx->nl_yy2=xctx->nl_yr2; RECTORDER(xctx->nl_xx1,xctx->nl_yy1,xctx->nl_xx2,xctx->nl_yy2); - drawtemprect(gc[SELLAYER],NOW, xctx->nl_xx1,xctx->nl_yy1,xctx->nl_xx2,xctx->nl_yy2); + drawtemprect(xctx->gc[SELLAYER],NOW, xctx->nl_xx1,xctx->nl_yy1,xctx->nl_xx2,xctx->nl_yy2); } else if(what & START) { @@ -2452,14 +2451,14 @@ void select_rect(int what, int select) { RECTORDER(xctx->nl_xr,xctx->nl_yr,xctx->nl_xr2,xctx->nl_yr2); drawtemprect(xctx->gctiled, NOW, xctx->nl_xr,xctx->nl_yr,xctx->nl_xr2,xctx->nl_yr2); - /* draw_selection(gc[SELLAYER], 0); */ + /* draw_selection(xctx->gc[SELLAYER], 0); */ select_inside(xctx->nl_xr,xctx->nl_yr,xctx->nl_xr2,xctx->nl_yr2, xctx->nl_sel); bbox(START,0.0, 0.0, 0.0, 0.0); bbox(ADD, xctx->nl_xr, xctx->nl_yr, xctx->nl_xr2, xctx->nl_yr2); bbox(SET,0.0, 0.0, 0.0, 0.0); - draw_selection(gc[SELLAYER], 0); + draw_selection(xctx->gc[SELLAYER], 0); bbox(END,0.0, 0.0, 0.0, 0.0); /* /20171219 */ diff --git a/src/callback.c b/src/callback.c index 8926c750..966ef978 100644 --- a/src/callback.c +++ b/src/callback.c @@ -141,49 +141,74 @@ void start_wire(double mx, double my) int callback(const char *winpath, int event, int mx, int my, KeySym key, int button, int aux, int state) { - char str[PATH_MAX + 100]; /* overflow safe 20161122 */ + char str[PATH_MAX + 100]; struct stat buf; + int redraw_only; unsigned short sel; int c_snap; #ifndef __unix__ short cstate = GetKeyState(VK_CAPITAL); short nstate = GetKeyState(VK_NUMLOCK); - - if(cstate & 0x0001) { /* caps lock */ - tcleval(".statusbar.8 configure -state active -text {CAPS LOCK SET! }"); - } else if (nstate & 0x0001) { /* num lock */ - tcleval(".statusbar.8 configure -state active -text {NUM LOCK SET! }"); - } else { /* normal state */ - tcleval(".statusbar.8 configure -state normal -text {}"); - } #else XKeyboardState kbdstate; - XGetKeyboardControl(display, &kbdstate); +#endif - if(kbdstate.led_mask & 1) { /* caps lock */ - tcleval(".statusbar.8 configure -state active -text {CAPS LOCK SET! }"); - } else if(kbdstate.led_mask & 2) { /* num lock */ - tcleval(".statusbar.8 configure -state active -text {NUM LOCK SET! }"); + +#ifndef __unix__ + if(cstate & 0x0001) { /* caps lock */ + Tcl_VarEval(interp, xctx->top_path, ".statusbar.8 configure -state active -text {CAPS LOCK SET! }", NULL); + } else if (nstate & 0x0001) { /* num lock */ + Tcl_VarEval(interp, xctx->top_path, ".statusbar.8 configure -state active -text {NUM LOCK SET! }", NULL); } else { /* normal state */ - tcleval(".statusbar.8 configure -state normal -text {}"); + Tcl_VarEval(interp, xctx->top_path, ".statusbar.8 configure -state normal -text {}", NULL); + } +#else + XGetKeyboardControl(display, &kbdstate); + if(kbdstate.led_mask & 1) { /* caps lock */ + Tcl_VarEval(interp, xctx->top_path, ".statusbar.8 configure -state active -text {CAPS LOCK SET! }", NULL); + } else if(kbdstate.led_mask & 2) { /* num lock */ + Tcl_VarEval(interp, xctx->top_path, ".statusbar.8 configure -state active -text {NUM LOCK SET! }", NULL); + } else { /* normal state */ + Tcl_VarEval(interp, xctx->top_path, ".statusbar.8 configure -state normal -text {}", NULL); } #endif + + #if 0 + /* exclude Motion and Expose events */ + if(event!=6 /* && event!=12 */) dbg(0, "callback(): event=%d, winpath=%s, old_winpath=%s, semaphore=%d\n", + event, winpath, old_winpath, xctx->semaphore+1); + #endif + + /* Schematic window context switch */ + redraw_only =0; + if(strcmp(old_winpath, winpath) ) { + if( xctx->semaphore >= 1 || event == Expose) { + dbg(1, "callback(): semaphore >=2 (or Expose) switching window context: %s --> %s\n", old_winpath, winpath); + redraw_only = 1; + } else { + dbg(1, "callback(): switching window context: %s --> %s\n", old_winpath, winpath); + if(old_winpath[0]) Tcl_VarEval(interp, "save_ctx ", old_winpath, NULL); + Tcl_VarEval(interp, "restore_ctx ", winpath, NULL); + Tcl_VarEval(interp, "housekeeping_ctx", NULL); + } + new_schematic("switch", xctx->top_path, winpath, ""); + } + /* artificially set semaphore to allow only redraw operations in switched schematic, + * so we don't need to switch tcl context which is costly performance-wise + */ + if(redraw_only) xctx->semaphore++; + + xctx->semaphore++; /* to recognize recursive callback() calls */ + c_snap = tclgetdoublevar("cadsnap"); state &=~Mod2Mask; /* 20170511 filter out NumLock status */ - if(xctx->semaphore) + if(xctx->semaphore >= 2) { if(debug_var>=2) if(event != MotionNotify) fprintf(errfp, "callback(): reentrant call of callback(), semaphore=%d, ev=%d, ui_state=%ld\n", xctx->semaphore, event, xctx->ui_state); - /* if(event==Expose) { - * XCopyArea(display, xctx->save_pixmap, xctx->window, xctx->gctiled, mx,my,button,aux,mx,my); - * - * } - */ - /* return 0; */ } - xctx->semaphore++; /* used to debug Tcl-Tk frontend */ xctx->mousex=X_TO_XSCHEM(mx); xctx->mousey=Y_TO_XSCHEM(my); xctx->mousex_snap=ROUND(xctx->mousex / c_snap) * c_snap; @@ -196,7 +221,8 @@ int callback(const char *winpath, int event, int mx, int my, KeySym key, { case EnterNotify: tcleval("catch {destroy .ctxmenu}"); - if(!xctx->sel_or_clip[0]) my_snprintf(xctx->sel_or_clip, S(xctx->sel_or_clip), "%s/%s", user_conf_dir, ".selection.sch"); + if(!xctx->sel_or_clip[0]) my_snprintf(xctx->sel_or_clip, S(xctx->sel_or_clip), "%s/%s", + user_conf_dir, ".selection.sch"); /* xschem window *sending* selected objects when the pointer comes back in abort copy operation since it has been done @@ -218,6 +244,7 @@ int callback(const char *winpath, int event, int mx, int my, KeySym key, break; case Expose: + dbg(1, "callback: Expose, winpath=%s, %dx%d+%d+%d\n", winpath, button, aux, mx, my); XCopyArea(display, xctx->save_pixmap, xctx->window, xctx->gctiled, mx,my,button,aux,mx,my); { XRectangle xr[1]; @@ -226,10 +253,10 @@ int callback(const char *winpath, int event, int mx, int my, KeySym key, xr[0].width=button; xr[0].height=aux; /* redraw selection on expose, needed if no backing store available on the server 20171112 */ - XSetClipRectangles(display, gc[SELLAYER], 0,0, xr, 1, Unsorted); + XSetClipRectangles(display, xctx->gc[SELLAYER], 0,0, xr, 1, Unsorted); rebuild_selected_array(); - draw_selection(gc[SELLAYER],0); - XSetClipMask(display, gc[SELLAYER], None); + draw_selection(xctx->gc[SELLAYER],0); + XSetClipMask(display, xctx->gc[SELLAYER], None); } dbg(1, "callback(): Expose\n"); break; @@ -368,8 +395,8 @@ int callback(const char *winpath, int event, int mx, int my, KeySym key, } if(key == 'b' && state==ControlMask) /* toggle show text in symbol */ { - sym_txt =!sym_txt; - if(sym_txt) { + xctx->sym_txt =!xctx->sym_txt; + if(xctx->sym_txt) { /* tcleval("alert_ { enabling text in symbol} {}"); */ tclsetvar("sym_txt","1"); draw(); @@ -500,8 +527,8 @@ int callback(const char *winpath, int event, int mx, int my, KeySym key, } if(key == '$' && (state &ControlMask) ) /* toggle window drawing */ { - draw_window =!draw_window; - if(draw_window) { + xctx->draw_window =!xctx->draw_window; + if(xctx->draw_window) { tcleval("alert_ { enabling draw window} {}"); tclsetvar("draw_window","1"); } else { @@ -513,25 +540,25 @@ int callback(const char *winpath, int event, int mx, int my, KeySym key, if(key == '=' && (state &ControlMask)) /* toggle fill rectangles */ { int x; - fill_pattern++; - if(fill_pattern==3) fill_pattern=0; + xctx->fill_pattern++; + if(xctx->fill_pattern==3) xctx->fill_pattern=0; - if(fill_pattern==1) { + if(xctx->fill_pattern==1) { tcleval("alert_ { Stippled pattern fill} {}"); for(x=0;xfill_type[x]==1) XSetFillStyle(display,xctx->gcstipple[x],FillSolid); + else XSetFillStyle(display,xctx->gcstipple[x],FillStippled); } } - else if(fill_pattern==2) { + else if(xctx->fill_pattern==2) { tcleval("alert_ { solid pattern fill} {}"); for(x=0;xgcstipple[x],FillSolid); } else { tcleval("alert_ { No pattern fill} {}"); for(x=0;xgcstipple[x],FillStippled); } draw(); @@ -659,7 +686,7 @@ int callback(const char *winpath, int event, int mx, int my, KeySym key, } else { Tcl_VarEval(interp, "reconfigure_layers_button [winfo parent ", winpath, "]", NULL); } - dbg(1, "callback(): new color: %d\n",color_index[xctx->rectcolor]); + dbg(1, "callback(): new color: %d\n",xctx->color_index[xctx->rectcolor]); break; } if(key==XK_Delete && (xctx->ui_state & SELECTION) ) /* delete selection */ @@ -697,15 +724,26 @@ int callback(const char *winpath, int event, int mx, int my, KeySym key, } if(key=='q' && state == ControlMask) /* exit */ { + char * top_path; + top_path = xctx->top_path[0] ? xctx->top_path : "."; if(xctx->semaphore >= 2) break; - if(xctx->modified) { - tcleval("tk_messageBox -type okcancel -message {UNSAVED data: want to exit?}"); - if(strcmp(tclresult(),"ok")==0) { - tcleval( "exit"); + if(!strcmp(winpath, ".drw")) { + tcleval("new_window destroy_all"); /* close child schematics */ + if(tclresult()[0] == '1') { + if(xctx->modified) { + tcleval("tk_messageBox -type okcancel -message \"" + "[get_cell [xschem get schname] 0]" + ": UNSAVED data: want to exit?\""); + } + if(!xctx->modified || !strcmp(tclresult(),"ok")) tcleval( "exit"); } - } - else { - tcleval( "exit"); + } else { + /* xschem new_schematic destroy asks user confirmation if schematic changed */ + Tcl_VarEval(interp, "xschem new_schematic destroy ", top_path, " ", winpath," {}" , NULL); + /* ================================================================ */ + /* We must return here, since current schematic is no more existing */ + /* ================================================================ */ + return 0; } break; } @@ -734,7 +772,7 @@ int callback(const char *winpath, int event, int mx, int my, KeySym key, } if(key=='V' && state == ShiftMask) /* toggle spice/vhdl netlist */ { - netlist_type++; if(netlist_type==6) netlist_type=1; + xctx->netlist_type++; if(xctx->netlist_type==6) xctx->netlist_type=1; override_netlist_type(-1); break; } @@ -863,8 +901,9 @@ int callback(const char *winpath, int event, int mx, int my, KeySym key, d_c = tclgetboolvar("dark_colorscheme"); d_c = !d_c; tclsetboolvar("dark_colorscheme", d_c); - tclsetdoublevar("color_dim", 0.0); - build_colors(0.0); + tclsetdoublevar("dim_value", 0.0); + tclsetdoublevar("dim_bg", 0.0); + build_colors(0.0, 0.0); draw(); break; } @@ -1251,13 +1290,13 @@ int callback(const char *winpath, int event, int mx, int my, KeySym key, unselect_all(); if(set_netlist_dir(0, NULL)) { dbg(1, "callback(): -------------\n"); - if(netlist_type == CAD_SPICE_NETLIST) + if(xctx->netlist_type == CAD_SPICE_NETLIST) global_spice_netlist(1); - else if(netlist_type == CAD_VHDL_NETLIST) + else if(xctx->netlist_type == CAD_VHDL_NETLIST) global_vhdl_netlist(1); - else if(netlist_type == CAD_VERILOG_NETLIST) + else if(xctx->netlist_type == CAD_VERILOG_NETLIST) global_verilog_netlist(1); - else if(netlist_type == CAD_TEDAX_NETLIST) + else if(xctx->netlist_type == CAD_TEDAX_NETLIST) global_tedax_netlist(1); else if(has_x) tcleval("tk_messageBox -type ok -message {Please Set netlisting mode (Options menu)}"); @@ -1273,13 +1312,13 @@ int callback(const char *winpath, int event, int mx, int my, KeySym key, unselect_all(); if( set_netlist_dir(0, NULL) ) { dbg(1, "callback(): -------------\n"); - if(netlist_type == CAD_SPICE_NETLIST) + if(xctx->netlist_type == CAD_SPICE_NETLIST) global_spice_netlist(0); - else if(netlist_type == CAD_VHDL_NETLIST) + else if(xctx->netlist_type == CAD_VHDL_NETLIST) global_vhdl_netlist(0); - else if(netlist_type == CAD_VERILOG_NETLIST) + else if(xctx->netlist_type == CAD_VERILOG_NETLIST) global_verilog_netlist(0); - else if(netlist_type == CAD_TEDAX_NETLIST) + else if(xctx->netlist_type == CAD_TEDAX_NETLIST) global_tedax_netlist(0); else if(has_x) tcleval("tk_messageBox -type ok -message {Please Set netlisting mode (Options menu)}"); @@ -1336,9 +1375,9 @@ int callback(const char *winpath, int event, int mx, int my, KeySym key, if(key=='b' && state==Mod1Mask) /* hide/show instance details */ { if(xctx->semaphore >= 2) break; - hide_symbols++; - if(hide_symbols >= 3) hide_symbols = 0; - tclsetintvar("hide_symbols", hide_symbols); + xctx->hide_symbols++; + if(xctx->hide_symbols >= 3) xctx->hide_symbols = 0; + tclsetintvar("hide_symbols", xctx->hide_symbols); draw(); break; } @@ -1771,7 +1810,7 @@ int callback(const char *winpath, int event, int mx, int my, KeySym key, sel = select_object(xctx->mousex, xctx->mousey, SELECTED, 0); rebuild_selected_array(); #ifndef __unix__ - draw_selection(gc[SELLAYER], 0); /* 20181009 moved outside of cadlayers loop */ + draw_selection(xctx->gc[SELLAYER], 0); /* 20181009 moved outside of cadlayers loop */ #endif if(sel && state == ControlMask) { launcher(); @@ -1848,9 +1887,19 @@ int callback(const char *winpath, int event, int mx, int my, KeySym key, default: dbg(1, "callback(): Event:%d\n",event); break; - } + } /* switch(event) */ xctx->semaphore--; + if(redraw_only) { + xctx->semaphore--; /* decrement articially incremented semaphore (see above) */ + dbg(1, "callback(): semaphore >=2 restoring window context: %s <-- %s\n", old_winpath, winpath); + if(old_winpath[0]) new_schematic("switch", xctx->top_path, old_winpath, ""); + } + else + if(strcmp(old_winpath, winpath)) { + if(old_winpath[0]) dbg(1, "callback(): reset old_winpath: %s <- %s\n", old_winpath, winpath); + my_strncpy(old_winpath, winpath, S(old_winpath)); + } return 0; } diff --git a/src/check.c b/src/check.c index ec2d2f70..7d2732ca 100644 --- a/src/check.c +++ b/src/check.c @@ -98,7 +98,7 @@ void update_conn_cues(int draw_cues, int dr_win) } dbg(3, "update_conn_cues(): check3\n"); if(draw_cues) { - save_draw = draw_window; draw_window = dr_win; + save_draw = xctx->draw_window; xctx->draw_window = dr_win; for(init_wire_iterator(&ctx, x1, y1, x2, y2); ( wireptr = wire_iterator_next(&ctx) ) ;) { i = wireptr->n; /* optimization when editing small areas (detailed zoom) of a huge schematic */ @@ -112,7 +112,7 @@ void update_conn_cues(int draw_cues, int dr_win) } } filledarc(WIRELAYER, END, 0.0, 0.0, 0.0, 0.0, 0.0); - draw_window = save_draw; + xctx->draw_window = save_draw; } } diff --git a/src/draw.c b/src/draw.c index 9ef1e092..fba8eac6 100644 --- a/src/draw.c +++ b/src/draw.c @@ -39,7 +39,7 @@ int textclip(int x1,int y1,int x2,int y2, { dbg(2, "textclip(): %.16g %.16g %.16g %.16g - %d %d %d %d\n", X_TO_SCREEN(xa),Y_TO_SCREEN(ya), X_TO_SCREEN(xb),Y_TO_SCREEN(yb),x1,y1,x2,y2); - /* drawtemprect(gc[WIRELAYER],xa,ya,xb,yb); */ + /* drawtemprect(xctx->gc[WIRELAYER],xa,ya,xb,yb); */ if (X_TO_SCREEN(xa)>x2) return 0; else if (Y_TO_SCREEN(ya)>y2) return 0; else if (X_TO_SCREEN(xb)xrect, 1, Unsorted); - * XSetClipRectangles(display, gcstipple[tmp], 0,0, xctx->xrect, 1, Unsorted); + * XSetClipRectangles(display, xctx->gc[tmp], 0,0, xctx->xrect, 1, Unsorted); + * XSetClipRectangles(display, xctx->gcstipple[tmp], 0,0, xctx->xrect, 1, Unsorted); * } * XSetClipRectangles(display, xctx->gctiled, 0,0, xctx->xrect, 1, Unsorted); #endif @@ -102,13 +102,13 @@ void print_image() void set_cairo_color(int layer) { cairo_set_source_rgb(xctx->cairo_ctx, - (double)xcolor_array[layer].red/65535.0, - (double)xcolor_array[layer].green/65535.0, - (double)xcolor_array[layer].blue/65535.0); + (double)xctx->xcolor_array[layer].red/65535.0, + (double)xctx->xcolor_array[layer].green/65535.0, + (double)xctx->xcolor_array[layer].blue/65535.0); cairo_set_source_rgb(xctx->cairo_save_ctx, - (double)xcolor_array[layer].red/65535.0, - (double)xcolor_array[layer].green/65535.0, - (double)xcolor_array[layer].blue/65535.0); + (double)xctx->xcolor_array[layer].red/65535.0, + (double)xctx->xcolor_array[layer].green/65535.0, + (double)xctx->xcolor_array[layer].blue/65535.0); } /* remember to call cairo_restore(xctx->cairo_ctx) when done !! */ @@ -243,7 +243,7 @@ void draw_string(int layer, int what, const char *str, short rot, short flip, in if(c=='\n' || c==0) { *ss='\0'; /*fprintf(errfp, "cairo_draw_string(): tt=%s, longest line: %d\n", tt, longest_line); */ - if(draw_window) cairo_draw_string_line(xctx->cairo_ctx, tt, x, y, rot, flip, + if(xctx->draw_window) cairo_draw_string_line(xctx->cairo_ctx, tt, x, y, rot, flip, lineno, fext.height, fext.ascent, fext.descent, llength, no_of_lines, longest_line); if(xctx->draw_pixmap) cairo_draw_string_line(xctx->cairo_save_ctx, tt, x, y, rot, flip, lineno, fext.height, fext.ascent, fext.descent, llength, no_of_lines, longest_line); @@ -362,10 +362,10 @@ void draw_symbol(int what,int c, int n,int layer,short tmp_flip, short rot, #endif if(xctx->inst[n].ptr == -1) return; - if( (layer != PINLAYER && !enable_layer[layer]) ) return; + if( (layer != PINLAYER && !xctx->enable_layer[layer]) ) return; if(!has_x) return; - if( (hide_symbols==1 && (xctx->inst[n].ptr+ xctx->sym)->prop_ptr && - !strcmp( (xctx->inst[n].ptr+ xctx->sym)->type, "subcircuit") ) || (hide_symbols == 2) ) { + if( (xctx->hide_symbols==1 && (xctx->inst[n].ptr+ xctx->sym)->prop_ptr && + !strcmp( (xctx->inst[n].ptr+ xctx->sym)->type, "subcircuit") ) || (xctx->hide_symbols == 2) ) { hide = 1; } else { hide = 0; @@ -461,8 +461,8 @@ void draw_symbol(int what,int c, int n,int layer,short tmp_flip, short rot, } } /* if(!hide) */ - if( (!hide && enable_layer[layer]) || - (hide && layer == PINLAYER && enable_layer[layer]) ) { + if( (!hide && xctx->enable_layer[layer]) || + (hide && layer == PINLAYER && xctx->enable_layer[layer]) ) { for(j=0;j< symptr->rects[layer];j++) { box = (symptr->rect[layer])[j]; @@ -474,7 +474,7 @@ void draw_symbol(int what,int c, int n,int layer,short tmp_flip, short rot, } } if( (layer==TEXTWIRELAYER && !(xctx->inst[n].flags&2) ) || - (sym_txt && (layer==TEXTLAYER) && (xctx->inst[n].flags&2) ) ) { + (xctx->sym_txt && (layer==TEXTLAYER) && (xctx->inst[n].flags&2) ) ) { const char *txtptr; for(j=0;j< symptr->texts;j++) { @@ -490,7 +490,7 @@ void draw_symbol(int what,int c, int n,int layer,short tmp_flip, short rot, if(textlayer < 0 || textlayer >= cadlayers) textlayer = c; } /* display PINLAYER colored instance texts even if PINLAYER disabled */ - if(xctx->inst[n].color == -PINLAYER || enable_layer[textlayer]) { + if(xctx->inst[n].color == -PINLAYER || xctx->enable_layer[textlayer]) { #if HAS_CAIRO==1 textfont = symptr->text[j].font; if((textfont && textfont[0]) || symptr->text[j].flags) { @@ -632,7 +632,7 @@ void draw_temp_symbol(int what, GC gc, int n,int layer,short tmp_flip, short rot drawtemparc(gc, what, x0+x1, y0+y1, arc.r, angle, arc.b); } - if(layer==PROPERTYLAYER && sym_txt) + if(layer==PROPERTYLAYER && xctx->sym_txt) { const char *txtptr; for(j=0;j< symptr->texts;j++) @@ -668,31 +668,31 @@ void drawgrid() while(delta < CADGRIDTHRESHOLD) delta*=CADGRIDMULTIPLY; /* <-- to be improved,but works */ x = xctx->xorigin*xctx->mooz; y = xctx->yorigin*xctx->mooz; if(y>xctx->areay1 && y < xctx->areay2) { - if(draw_window) XDrawLine(display, xctx->window, gc[GRIDLAYER],xctx->areax1+1,(int)y, xctx->areax2-1, (int)y); + if(xctx->draw_window) XDrawLine(display, xctx->window, xctx->gc[GRIDLAYER],xctx->areax1+1,(int)y, xctx->areax2-1, (int)y); if(xctx->draw_pixmap) - XDrawLine(display, xctx->save_pixmap, gc[GRIDLAYER],xctx->areax1+1,(int)y, xctx->areax2-1, (int)y); + XDrawLine(display, xctx->save_pixmap, xctx->gc[GRIDLAYER],xctx->areax1+1,(int)y, xctx->areax2-1, (int)y); } if(x>xctx->areax1 && x < xctx->areax2) { - if(draw_window) XDrawLine(display, xctx->window, gc[GRIDLAYER],(int)x,xctx->areay1+1, (int)x, xctx->areay2-1); + if(xctx->draw_window) XDrawLine(display, xctx->window, xctx->gc[GRIDLAYER],(int)x,xctx->areay1+1, (int)x, xctx->areay2-1); if(xctx->draw_pixmap) - XDrawLine(display, xctx->save_pixmap, gc[GRIDLAYER],(int)x,xctx->areay1+1, (int)x, xctx->areay2-1); + XDrawLine(display, xctx->save_pixmap, xctx->gc[GRIDLAYER],(int)x,xctx->areay1+1, (int)x, xctx->areay2-1); } tmp = floor((xctx->areay1+1)/delta)*delta-fmod(-xctx->yorigin*xctx->mooz,delta); for(x=floor((xctx->areax1+1)/delta)*delta-fmod(-xctx->xorigin*xctx->mooz,delta); x < xctx->areax2; x += delta) { for(y=tmp; y < xctx->areay2; y += delta) { if(i>=CADMAXGRIDPOINTS) { - if(draw_window) { + if(xctx->draw_window) { if(big_gr) { - XDrawSegments(display,xctx->window,gc[GRIDLAYER],xctx->biggridpoint,i); + XDrawSegments(display,xctx->window,xctx->gc[GRIDLAYER],xctx->biggridpoint,i); } else { - XDrawPoints(display,xctx->window,gc[GRIDLAYER],xctx->gridpoint,i,CoordModeOrigin); + XDrawPoints(display,xctx->window,xctx->gc[GRIDLAYER],xctx->gridpoint,i,CoordModeOrigin); } } if(xctx->draw_pixmap) { if(big_gr) { - XDrawSegments(display,xctx->save_pixmap,gc[GRIDLAYER],xctx->biggridpoint,i); + XDrawSegments(display,xctx->save_pixmap,xctx->gc[GRIDLAYER],xctx->biggridpoint,i); } else { - XDrawPoints(display,xctx->save_pixmap,gc[GRIDLAYER],xctx->gridpoint,i,CoordModeOrigin); + XDrawPoints(display,xctx->save_pixmap,xctx->gc[GRIDLAYER],xctx->gridpoint,i,CoordModeOrigin); } } i=0; @@ -708,18 +708,18 @@ void drawgrid() } } } - if(draw_window) { + if(xctx->draw_window) { if(big_gr) { - XDrawSegments(display,xctx->window,gc[GRIDLAYER],xctx->biggridpoint,i); + XDrawSegments(display,xctx->window,xctx->gc[GRIDLAYER],xctx->biggridpoint,i); } else { - XDrawPoints(display,xctx->window,gc[GRIDLAYER],xctx->gridpoint,i,CoordModeOrigin); + XDrawPoints(display,xctx->window,xctx->gc[GRIDLAYER],xctx->gridpoint,i,CoordModeOrigin); } } if(xctx->draw_pixmap) { if(big_gr) { - XDrawSegments(display,xctx->save_pixmap,gc[GRIDLAYER],xctx->biggridpoint,i); + XDrawSegments(display,xctx->save_pixmap,xctx->gc[GRIDLAYER],xctx->biggridpoint,i); } else { - XDrawPoints(display,xctx->save_pixmap,gc[GRIDLAYER],xctx->gridpoint,i,CoordModeOrigin); + XDrawPoints(display,xctx->save_pixmap,xctx->gc[GRIDLAYER],xctx->gridpoint,i,CoordModeOrigin); } } } @@ -745,15 +745,15 @@ void drawline(int c, int what, double linex1, double liney1, double linex2, doub if(i>=CADDRAWBUFFERSIZE) { #ifdef __unix__ - if(draw_window) XDrawSegments(display, xctx->window, gc[c], rr,i); + if(xctx->draw_window) XDrawSegments(display, xctx->window, xctx->gc[c], rr,i); if(xctx->draw_pixmap) - XDrawSegments(display, xctx->save_pixmap, gc[c], rr,i); + XDrawSegments(display, xctx->save_pixmap, xctx->gc[c], rr,i); #else for (j = 0; j < i; ++j) { - if (draw_window) - XDrawLine(display, xctx->window, gc[c], rr[j].x1, rr[j].y1, rr[j].x2, rr[j].y2); + if (xctx->draw_window) + XDrawLine(display, xctx->window, xctx->gc[c], rr[j].x1, rr[j].y1, rr[j].x2, rr[j].y2); if (xctx->draw_pixmap) - XDrawLine(display, xctx->save_pixmap, gc[c], rr[j].x1, rr[j].y1, rr[j].x2, rr[j].y2); + XDrawLine(display, xctx->save_pixmap, xctx->gc[c], rr[j].x1, rr[j].y1, rr[j].x2, rr[j].y2); } #endif i=0; @@ -783,14 +783,14 @@ void drawline(int c, int what, double linex1, double liney1, double linex2, doub { if(dash) { dash_arr[0] = dash_arr[1] = dash; - XSetDashes(display, gc[c], 0, dash_arr, 2); - XSetLineAttributes (display, gc[c], INT_WIDTH(xctx->lw), xDashType, CapButt, JoinBevel); + XSetDashes(display, xctx->gc[c], 0, dash_arr, 2); + XSetLineAttributes (display, xctx->gc[c], INT_WIDTH(xctx->lw), xDashType, CapButt, JoinBevel); } - if(draw_window) XDrawLine(display, xctx->window, gc[c], x1, y1, x2, y2); + if(xctx->draw_window) XDrawLine(display, xctx->window, xctx->gc[c], x1, y1, x2, y2); if(xctx->draw_pixmap) - XDrawLine(display, xctx->save_pixmap, gc[c], x1, y1, x2, y2); + XDrawLine(display, xctx->save_pixmap, xctx->gc[c], x1, y1, x2, y2); if(dash) { - XSetLineAttributes (display, gc[c], INT_WIDTH(xctx->lw), LineSolid, CapRound, JoinRound); + XSetLineAttributes (display, xctx->gc[c], INT_WIDTH(xctx->lw), LineSolid, CapRound, JoinRound); } } } @@ -806,28 +806,28 @@ void drawline(int c, int what, double linex1, double liney1, double linex2, doub { if(dash) { dash_arr[0] = dash_arr[1] = dash; - XSetDashes(display, gc[c], 0, dash_arr, 2); - XSetLineAttributes (display, gc[c], INT_BUS_WIDTH(xctx->lw), xDashType, CapButt, JoinBevel); + XSetDashes(display, xctx->gc[c], 0, dash_arr, 2); + XSetLineAttributes (display, xctx->gc[c], INT_BUS_WIDTH(xctx->lw), xDashType, CapButt, JoinBevel); } else { - XSetLineAttributes (display, gc[c], INT_BUS_WIDTH(xctx->lw), LineSolid, CapRound, JoinRound); + XSetLineAttributes (display, xctx->gc[c], INT_BUS_WIDTH(xctx->lw), LineSolid, CapRound, JoinRound); } - if(draw_window) XDrawLine(display, xctx->window, gc[c], x1, y1, x2, y2); - if(xctx->draw_pixmap) XDrawLine(display, xctx->save_pixmap, gc[c], x1, y1, x2, y2); - XSetLineAttributes (display, gc[c], INT_WIDTH(xctx->lw), LineSolid, CapRound , JoinRound); + if(xctx->draw_window) XDrawLine(display, xctx->window, xctx->gc[c], x1, y1, x2, y2); + if(xctx->draw_pixmap) XDrawLine(display, xctx->save_pixmap, xctx->gc[c], x1, y1, x2, y2); + XSetLineAttributes (display, xctx->gc[c], INT_WIDTH(xctx->lw), LineSolid, CapRound , JoinRound); } } else if(what & START) i=0; else if((what & END) && i) { #ifdef __unix__ - if(draw_window) XDrawSegments(display, xctx->window, gc[c], rr,i); - if(xctx->draw_pixmap) XDrawSegments(display, xctx->save_pixmap, gc[c], rr,i); + if(xctx->draw_window) XDrawSegments(display, xctx->window, xctx->gc[c], rr,i); + if(xctx->draw_pixmap) XDrawSegments(display, xctx->save_pixmap, xctx->gc[c], rr,i); #else for (j = 0; j < i; ++j) { - if (draw_window) - XDrawLine(display, xctx->window, gc[c], rr[j].x1, rr[j].y1, rr[j].x2, rr[j].y2); + if (xctx->draw_window) + XDrawLine(display, xctx->window, xctx->gc[c], rr[j].x1, rr[j].y1, rr[j].x2, rr[j].y2); if (xctx->draw_pixmap) - XDrawLine(display, xctx->save_pixmap, gc[c], rr[j].x1, rr[j].y1, rr[j].x2, rr[j].y2); + XDrawLine(display, xctx->save_pixmap, xctx->gc[c], rr[j].x1, rr[j].y1, rr[j].x2, rr[j].y2); } #endif i=0; @@ -1016,8 +1016,8 @@ void filledarc(int c, int what, double x, double y, double r, double a, double b { if(i>=CADDRAWBUFFERSIZE) { - if(draw_window) XFillArcs(display, xctx->window, gc[c], xarc,i); - if(xctx->draw_pixmap) XFillArcs(display, xctx->save_pixmap, gc[c], xarc,i); + if(xctx->draw_window) XFillArcs(display, xctx->window, xctx->gc[c], xarc,i); + if(xctx->draw_pixmap) XFillArcs(display, xctx->save_pixmap, xctx->gc[c], xarc,i); i=0; } xx1=X_TO_SCREEN(x-r); @@ -1053,15 +1053,15 @@ void filledarc(int c, int what, double x, double y, double r, double a, double b y2=Y_TO_SCREEN(y2); if( rectclip(xctx->areax1,xctx->areay1,xctx->areax2,xctx->areay2,&x1,&y1,&x2,&y2) ) { - if(draw_window) XFillArc(display, xctx->window, gc[c], xx1, yy1, xx2-xx1, yy2-yy1, a*64, b*64); - if(xctx->draw_pixmap) XFillArc(display, xctx->save_pixmap, gc[c], xx1, yy1, xx2-xx1, yy2-yy1, a*64, b*64); + if(xctx->draw_window) XFillArc(display, xctx->window, xctx->gc[c], xx1, yy1, xx2-xx1, yy2-yy1, a*64, b*64); + if(xctx->draw_pixmap) XFillArc(display, xctx->save_pixmap, xctx->gc[c], xx1, yy1, xx2-xx1, yy2-yy1, a*64, b*64); } } else if(what & START) i=0; else if((what & END) && i) { - if(draw_window) XFillArcs(display, xctx->window, gc[c], xarc,i); - if(xctx->draw_pixmap) XFillArcs(display, xctx->save_pixmap, gc[c], xarc,i); + if(xctx->draw_window) XFillArcs(display, xctx->window, xctx->gc[c], xarc,i); + if(xctx->draw_pixmap) XFillArcs(display, xctx->save_pixmap, xctx->gc[c], xarc,i); i=0; } } @@ -1081,8 +1081,8 @@ void drawarc(int c, int what, double x, double y, double r, double a, double b, { if(i>=CADDRAWBUFFERSIZE) { - if(draw_window) XDrawArcs(display, xctx->window, gc[c], xarc,i); - if(xctx->draw_pixmap) XDrawArcs(display, xctx->save_pixmap, gc[c], xarc,i); + if(xctx->draw_window) XDrawArcs(display, xctx->window, xctx->gc[c], xarc,i); + if(xctx->draw_pixmap) XDrawArcs(display, xctx->save_pixmap, xctx->gc[c], xarc,i); i=0; } xx1=X_TO_SCREEN(x-r); @@ -1124,35 +1124,35 @@ void drawarc(int c, int what, double x, double y, double r, double a, double b, if(dash) { char dash_arr[2]; dash_arr[0] = dash_arr[1] = dash; - XSetDashes(display, gc[c], 0, dash_arr, 2); - XSetLineAttributes (display, gc[c], INT_WIDTH(xctx->lw), xDashType, CapButt, JoinBevel); + XSetDashes(display, xctx->gc[c], 0, dash_arr, 2); + XSetLineAttributes (display, xctx->gc[c], INT_WIDTH(xctx->lw), xDashType, CapButt, JoinBevel); } - if(draw_window) { - XDrawArc(display, xctx->window, gc[c], xx1, yy1, xx2-xx1, yy2-yy1, a*64, b*64); + if(xctx->draw_window) { + XDrawArc(display, xctx->window, xctx->gc[c], xx1, yy1, xx2-xx1, yy2-yy1, a*64, b*64); } if(xctx->draw_pixmap) { - XDrawArc(display, xctx->save_pixmap, gc[c], xx1, yy1, xx2-xx1, yy2-yy1, a*64, b*64); + XDrawArc(display, xctx->save_pixmap, xctx->gc[c], xx1, yy1, xx2-xx1, yy2-yy1, a*64, b*64); } - if(fill_pattern && fill_type[c]){ + if(xctx->fill_pattern && xctx->fill_type[c]){ if(arc_fill) { - if(draw_window) - XFillArc(display, xctx->window, gcstipple[c], xx1, yy1, xx2-xx1, yy2-yy1, a*64, b*64); + if(xctx->draw_window) + XFillArc(display, xctx->window, xctx->gcstipple[c], xx1, yy1, xx2-xx1, yy2-yy1, a*64, b*64); if(xctx->draw_pixmap) - XFillArc(display, xctx->save_pixmap, gcstipple[c], xx1, yy1, xx2-xx1, yy2-yy1, a*64, b*64); + XFillArc(display, xctx->save_pixmap, xctx->gcstipple[c], xx1, yy1, xx2-xx1, yy2-yy1, a*64, b*64); } } if(dash) { - XSetLineAttributes (display, gc[c], INT_WIDTH(xctx->lw) ,LineSolid, CapRound , JoinRound); + XSetLineAttributes (display, xctx->gc[c], INT_WIDTH(xctx->lw) ,LineSolid, CapRound , JoinRound); } } } else if(what & START) i=0; else if((what & END) && i) { - if(draw_window) XDrawArcs(display, xctx->window, gc[c], xarc,i); - if(xctx->draw_pixmap) XDrawArcs(display, xctx->save_pixmap, gc[c], xarc,i); + if(xctx->draw_window) XDrawArcs(display, xctx->window, xctx->gc[c], xarc,i); + if(xctx->draw_pixmap) XDrawArcs(display, xctx->save_pixmap, xctx->gc[c], xarc,i); i=0; } } @@ -1165,7 +1165,7 @@ void filledrect(int c, int what, double rectx1,double recty1,double rectx2,doubl double x1,y1,x2,y2; if(!has_x) return; - if(!fill_pattern || !fill_type[c]) return; + if(!xctx->fill_pattern || !xctx->fill_type[c]) return; if(what & NOW) { x1=X_TO_SCREEN(rectx1); @@ -1175,11 +1175,11 @@ void filledrect(int c, int what, double rectx1,double recty1,double rectx2,doubl if(!only_probes && (x2-x1)< 3.0 && (y2-y1)< 3.0) return; if( rectclip(xctx->areax1,xctx->areay1,xctx->areax2,xctx->areay2,&x1,&y1,&x2,&y2) ) { - if(draw_window) XFillRectangle(display, xctx->window, gcstipple[c], (int)x1, (int)y1, + if(xctx->draw_window) XFillRectangle(display, xctx->window, xctx->gcstipple[c], (int)x1, (int)y1, (unsigned int)x2 - (unsigned int)x1, (unsigned int)y2 - (unsigned int)y1); if(xctx->draw_pixmap) - XFillRectangle(display, xctx->save_pixmap,gcstipple[c], (int)x1, (int)y1, + XFillRectangle(display, xctx->save_pixmap,xctx->gcstipple[c], (int)x1, (int)y1, (unsigned int)x2 - (unsigned int)x1, (unsigned int)y2 - (unsigned int)y1); } @@ -1189,9 +1189,9 @@ void filledrect(int c, int what, double rectx1,double recty1,double rectx2,doubl { if(i>=CADDRAWBUFFERSIZE) { - if(draw_window) XFillRectangles(display, xctx->window, gcstipple[c], r,i); + if(xctx->draw_window) XFillRectangles(display, xctx->window, xctx->gcstipple[c], r,i); if(xctx->draw_pixmap) - XFillRectangles(display, xctx->save_pixmap, gcstipple[c], r,i); + XFillRectangles(display, xctx->save_pixmap, xctx->gcstipple[c], r,i); i=0; } x1=X_TO_SCREEN(rectx1); @@ -1210,8 +1210,8 @@ void filledrect(int c, int what, double rectx1,double recty1,double rectx2,doubl } else if((what & END) && i) { - if(draw_window) XFillRectangles(display, xctx->window, gcstipple[c], r,i); - if(xctx->draw_pixmap) XFillRectangles(display, xctx->save_pixmap, gcstipple[c], r,i); + if(xctx->draw_window) XFillRectangles(display, xctx->window, xctx->gcstipple[c], r,i); + if(xctx->draw_pixmap) XFillRectangles(display, xctx->save_pixmap, xctx->gcstipple[c], r,i); i=0; } } @@ -1313,21 +1313,21 @@ void drawpolygon(int c, int what, double *x, double *y, int points, int poly_fil if(dash) { char dash_arr[2]; dash_arr[0] = dash_arr[1] = dash; - XSetDashes(display, gc[c], 0, dash_arr, 2); - XSetLineAttributes (display, gc[c], INT_WIDTH(xctx->lw), xDashType, CapButt, JoinBevel); + XSetDashes(display, xctx->gc[c], 0, dash_arr, 2); + XSetLineAttributes (display, xctx->gc[c], INT_WIDTH(xctx->lw), xDashType, CapButt, JoinBevel); } - if(draw_window) XDrawLines(display, xctx->window, gc[c], p, points, CoordModeOrigin); + if(xctx->draw_window) XDrawLines(display, xctx->window, xctx->gc[c], p, points, CoordModeOrigin); if(xctx->draw_pixmap) - XDrawLines(display, xctx->save_pixmap, gc[c], p, points, CoordModeOrigin); - if(fill_pattern && fill_type[c]){ + XDrawLines(display, xctx->save_pixmap, xctx->gc[c], p, points, CoordModeOrigin); + if(xctx->fill_pattern && xctx->fill_type[c]){ if(poly_fill && (x[0] == x[points-1]) && (y[0] == y[points-1])) { - if(draw_window) XFillPolygon(display, xctx->window, gcstipple[c], p, points, Polygontype, CoordModeOrigin); + if(xctx->draw_window) XFillPolygon(display, xctx->window, xctx->gcstipple[c], p, points, Polygontype, CoordModeOrigin); if(xctx->draw_pixmap) - XFillPolygon(display, xctx->save_pixmap, gcstipple[c], p, points, Polygontype, CoordModeOrigin); + XFillPolygon(display, xctx->save_pixmap, xctx->gcstipple[c], p, points, Polygontype, CoordModeOrigin); } } if(dash) { - XSetLineAttributes (display, gc[c], INT_WIDTH(xctx->lw) ,LineSolid, CapRound , JoinRound); + XSetLineAttributes (display, xctx->gc[c], INT_WIDTH(xctx->lw) ,LineSolid, CapRound , JoinRound); } my_free(722, &p); @@ -1377,20 +1377,20 @@ void drawrect(int c, int what, double rectx1,double recty1,double rectx2,double { if(dash) { dash_arr[0] = dash_arr[1] = dash; - XSetDashes(display, gc[c], 0, dash_arr, 2); - XSetLineAttributes (display, gc[c], INT_WIDTH(xctx->lw), xDashType, CapButt, JoinBevel); + XSetDashes(display, xctx->gc[c], 0, dash_arr, 2); + XSetLineAttributes (display, xctx->gc[c], INT_WIDTH(xctx->lw), xDashType, CapButt, JoinBevel); } - if(draw_window) XDrawRectangle(display, xctx->window, gc[c], (int)x1, (int)y1, + if(xctx->draw_window) XDrawRectangle(display, xctx->window, xctx->gc[c], (int)x1, (int)y1, (unsigned int)x2 - (unsigned int)x1, (unsigned int)y2 - (unsigned int)y1); if(xctx->draw_pixmap) { - XDrawRectangle(display, xctx->save_pixmap, gc[c], (int)x1, (int)y1, + XDrawRectangle(display, xctx->save_pixmap, xctx->gc[c], (int)x1, (int)y1, (unsigned int)x2 - (unsigned int)x1, (unsigned int)y2 - (unsigned int)y1); } if(dash) { - XSetLineAttributes (display, gc[c], INT_WIDTH(xctx->lw) ,LineSolid, CapRound , JoinRound); + XSetLineAttributes (display, xctx->gc[c], INT_WIDTH(xctx->lw) ,LineSolid, CapRound , JoinRound); } } } @@ -1399,9 +1399,9 @@ void drawrect(int c, int what, double rectx1,double recty1,double rectx2,double { if(i>=CADDRAWBUFFERSIZE) { - if(draw_window) XDrawRectangles(display, xctx->window, gc[c], r,i); + if(xctx->draw_window) XDrawRectangles(display, xctx->window, xctx->gc[c], r,i); if(xctx->draw_pixmap) - XDrawRectangles(display, xctx->save_pixmap, gc[c], r,i); + XDrawRectangles(display, xctx->save_pixmap, xctx->gc[c], r,i); i=0; } x1=X_TO_SCREEN(rectx1); @@ -1420,8 +1420,8 @@ void drawrect(int c, int what, double rectx1,double recty1,double rectx2,double } else if((what & END) && i) { - if(draw_window) XDrawRectangles(display, xctx->window, gc[c], r,i); - if(xctx->draw_pixmap) XDrawRectangles(display, xctx->save_pixmap, gc[c], r,i); + if(xctx->draw_window) XDrawRectangles(display, xctx->window, xctx->gc[c], r,i); + if(xctx->draw_pixmap) XDrawRectangles(display, xctx->save_pixmap, xctx->gc[c], r,i); i=0; } } @@ -1494,10 +1494,10 @@ void draw(void) rebuild_selected_array(); if(has_x) { if(xctx->draw_pixmap) - XFillRectangle(display, xctx->save_pixmap, gc[BACKLAYER], xctx->areax1, xctx->areay1, + XFillRectangle(display, xctx->save_pixmap, xctx->gc[BACKLAYER], xctx->areax1, xctx->areay1, xctx->areaw, xctx->areah); - if(draw_window) - XFillRectangle(display, xctx->window, gc[BACKLAYER], xctx->areax1, xctx->areay1, + 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); drawgrid(); @@ -1516,21 +1516,21 @@ void draw(void) for(c=0;cdraw_single_layer!=-1 && c != xctx->draw_single_layer) continue; - if(enable_layer[c]) for(i=0;ilines[c];i++) { + if(xctx->enable_layer[c]) for(i=0;ilines[c];i++) { xLine *l = &xctx->line[c][i]; if(l->bus) drawline(c, THICK, l->x1, l->y1, l->x2, l->y2, l->dash); else drawline(c, ADD, l->x1, l->y1, l->x2, l->y2, l->dash); } - if(enable_layer[c]) for(i=0;irects[c];i++) { + if(xctx->enable_layer[c]) for(i=0;irects[c];i++) { xRect *r = &xctx->rect[c][i]; drawrect(c, ADD, r->x1, r->y1, r->x2, r->y2, r->dash); filledrect(c, ADD, r->x1, r->y1, r->x2, r->y2); } - if(enable_layer[c]) for(i=0;iarcs[c];i++) { + if(xctx->enable_layer[c]) for(i=0;iarcs[c];i++) { xArc *a = &xctx->arc[c][i]; drawarc(c, ADD, a->x, a->y, a->r, a->a, a->b, a->fill, a->dash); } - if(enable_layer[c]) for(i=0;ipolygons[c];i++) { + if(xctx->enable_layer[c]) for(i=0;ipolygons[c];i++) { xPoly *p = &xctx->poly[c][i]; drawpolygon(c, NOW, p->x, p->y, p->points, p->fill, p->dash); } @@ -1584,7 +1584,7 @@ void draw(void) drawline(WIRELAYER, ADD, xctx->wire[i].x1,xctx->wire[i].y1, xctx->wire[i].x2,xctx->wire[i].y2, 0); } - update_conn_cues(1, draw_window); + update_conn_cues(1, xctx->draw_window); filledrect(WIRELAYER, END, 0.0, 0.0, 0.0, 0.0); drawline(WIRELAYER, END, 0.0, 0.0, 0.0, 0.0, 0); } @@ -1595,7 +1595,7 @@ void draw(void) if(textlayer < 0 || textlayer >= cadlayers) textlayer = TEXTLAYER; dbg(1, "draw(): drawing string %d = %s\n",i, xctx->text[i].txt_ptr); #if HAS_CAIRO==1 - if(!enable_layer[textlayer]) continue; + if(!xctx->enable_layer[textlayer]) continue; textfont = xctx->text[i].font; if( (textfont && textfont[0]) || xctx->text[i].flags) { cairo_font_slant_t slant; @@ -1630,12 +1630,12 @@ void draw(void) } } } /* !only_probes, 20110112 */ - draw_hilight_net(draw_window); - if(!draw_window) { + draw_hilight_net(xctx->draw_window); + if(!xctx->draw_window) { XCopyArea(display, xctx->save_pixmap, xctx->window, xctx->gctiled, xctx->xrect[0].x, xctx->xrect[0].y, xctx->xrect[0].width, xctx->xrect[0].height, xctx->xrect[0].x, xctx->xrect[0].y); } - draw_selection(gc[SELLAYER], 0); /* 20181009 moved outside of cadlayers loop */ + draw_selection(xctx->gc[SELLAYER], 0); /* 20181009 moved outside of cadlayers loop */ dbg(1, "draw(): INT_WIDTH(lw)=%d\n",INT_WIDTH(xctx->lw)); } /* if(has_x) */ diff --git a/src/editprop.c b/src/editprop.c index 75a8cb5d..497c2f76 100644 --- a/src/editprop.c +++ b/src/editprop.c @@ -296,7 +296,7 @@ void *my_calloc(int id, size_t nmemb, size_t size) if(size*nmemb > 0) { ptr=calloc(nmemb, size); if(ptr == NULL) fprintf(errfp,"my_calloc(%d,): allocation failure\n", id); - dbg(3, "my_calloc(%d,): allocating %p , %lu bytes\n", + dbg(3, "\nmy_calloc(%d,): allocating %p , %lu bytes\n", id, ptr, (unsigned long) (size*nmemb)); } else ptr = NULL; @@ -309,7 +309,7 @@ void *my_malloc(int id, size_t size) if(size>0) { ptr=malloc(size); if(ptr == NULL) fprintf(errfp,"my_malloc(%d,): allocation failure\n", id); - dbg(3, "my_malloc(%d,): allocating %p , %lu bytes\n", id, ptr, (unsigned long) size); + dbg(3, "\nmy_malloc(%d,): allocating %p , %lu bytes\n", id, ptr, (unsigned long) size); } else ptr=NULL; return ptr; @@ -321,12 +321,12 @@ void my_realloc(int id, void *ptr,size_t size) a = *(void **)ptr; if(size == 0) { free(*(void **)ptr); - dbg(3, "my_free(%d,): my_realloc_freeing %p\n",id, *(void **)ptr); + dbg(3, "\nmy_free(%d,): my_realloc_freeing %p\n",id, *(void **)ptr); *(void **)ptr=NULL; } else { *(void **)ptr=realloc(*(void **)ptr,size); if(*(void **)ptr == NULL) fprintf(errfp,"my_realloc(%d,): allocation failure\n", id); - dbg(3, "my_realloc(%d,): reallocating %p --> %p to %lu bytes\n", + dbg(3, "\nmy_realloc(%d,): reallocating %p --> %p to %lu bytes\n", id, a, *(void **)ptr,(unsigned long) size); } @@ -336,10 +336,10 @@ void my_free(int id, void *ptr) { if(*(void **)ptr) { free(*(void **)ptr); - dbg(3, "my_free(%d,): freeing %p\n", id, *(void **)ptr); + dbg(3, "\nmy_free(%d,): freeing %p\n", id, *(void **)ptr); *(void **)ptr=NULL; } else { - dbg(3, "--> my_free(%d,): trying to free NULL pointer\n", id); + dbg(3, "\n--> my_free(%d,): trying to free NULL pointer\n", id); } } @@ -1151,31 +1151,31 @@ void edit_property(int x) char *old_prop = NULL; char *new_prop = NULL; - if(netlist_type==CAD_SYMBOL_ATTRS) { + if(xctx->netlist_type==CAD_SYMBOL_ATTRS) { if(xctx->schsymbolprop!=NULL) tclsetvar("retval",xctx->schsymbolprop); else tclsetvar("retval",""); } - else if(netlist_type==CAD_VHDL_NETLIST) { + else if(xctx->netlist_type==CAD_VHDL_NETLIST) { if(xctx->schvhdlprop!=NULL) tclsetvar("retval",xctx->schvhdlprop); else tclsetvar("retval",""); } - else if(netlist_type==CAD_VERILOG_NETLIST) { + else if(xctx->netlist_type==CAD_VERILOG_NETLIST) { if(xctx->schverilogprop!=NULL) tclsetvar("retval",xctx->schverilogprop); else tclsetvar("retval",""); } - else if(netlist_type==CAD_SPICE_NETLIST) { + else if(xctx->netlist_type==CAD_SPICE_NETLIST) { if(xctx->schprop!=NULL) tclsetvar("retval",xctx->schprop); else tclsetvar("retval",""); } - else if(netlist_type==CAD_TEDAX_NETLIST) { + else if(xctx->netlist_type==CAD_TEDAX_NETLIST) { if(xctx->schtedaxprop!=NULL) tclsetvar("retval",xctx->schtedaxprop); else @@ -1200,27 +1200,27 @@ void edit_property(int x) if(strcmp(tclgetvar("rcode"),"") ) { - if(netlist_type==CAD_SYMBOL_ATTRS && + if(xctx->netlist_type==CAD_SYMBOL_ATTRS && (!xctx->schsymbolprop || strcmp(xctx->schsymbolprop, tclgetvar("retval") ) ) ) { set_modify(1); push_undo(); my_strdup(422, &xctx->schsymbolprop, (char *) tclgetvar("retval")); - } else if(netlist_type==CAD_VERILOG_NETLIST && + } else if(xctx->netlist_type==CAD_VERILOG_NETLIST && (!xctx->schverilogprop || strcmp(xctx->schverilogprop, tclgetvar("retval") ) ) ) { set_modify(1); push_undo(); my_strdup(94, &xctx->schverilogprop, (char *) tclgetvar("retval")); - } else if(netlist_type==CAD_SPICE_NETLIST && + } else if(xctx->netlist_type==CAD_SPICE_NETLIST && (!xctx->schprop || strcmp(xctx->schprop, tclgetvar("retval") ) ) ) { set_modify(1); push_undo(); my_strdup(95, &xctx->schprop, (char *) tclgetvar("retval")); - } else if(netlist_type==CAD_TEDAX_NETLIST && + } else if(xctx->netlist_type==CAD_TEDAX_NETLIST && (!xctx->schtedaxprop || strcmp(xctx->schtedaxprop, tclgetvar("retval") ) ) ) { set_modify(1); push_undo(); my_strdup(96, &xctx->schtedaxprop, (char *) tclgetvar("retval")); - } else if(netlist_type==CAD_VHDL_NETLIST && + } else if(xctx->netlist_type==CAD_VHDL_NETLIST && (!xctx->schvhdlprop || strcmp(xctx->schvhdlprop, tclgetvar("retval") ) ) ) { set_modify(1); push_undo(); my_strdup(97, &xctx->schvhdlprop, (char *) tclgetvar("retval")); diff --git a/src/findnet.c b/src/findnet.c index f7c562c7..f892144b 100644 --- a/src/findnet.c +++ b/src/findnet.c @@ -62,7 +62,7 @@ void find_closest_polygon(double mx,double my) threshold = CADWIREMINDIST * CADWIREMINDIST * cg * cg / 400; for(c=0;cenable_layer[c]) continue; for(i=0;ipolygons[c];i++) { /*fprintf(errfp, "points=%d\n", xctx->poly[c][i].points); */ @@ -99,7 +99,7 @@ void find_closest_line(double mx,double my) threshold = CADWIREMINDIST * CADWIREMINDIST * cg * cg / 400; for(c=0;cenable_layer[c]) continue; for(i=0;ilines[c];i++) { if( (tmp = dist(xctx->line[c][i].x1,xctx->line[c][i].y1,xctx->line[c][i].x2,xctx->line[c][i].y2,mx,my)) @@ -189,7 +189,7 @@ void find_closest_arc(double mx,double my) for(c=0;cenable_layer[c]) continue; for(i=0;iarcs[c];i++) { dist = sqrt(pow(mx-xctx->arc[c][i].x,2) + pow(my-xctx->arc[c][i].y,2)) - xctx->arc[c][i].r; @@ -236,7 +236,7 @@ void find_closest_box(double mx,double my) int i,c,r=-1, col = 0; for(c=0;cenable_layer[c]) continue; for(i=0;irects[c];i++) { if( POINTINSIDE(mx,my,xctx->rect[c][i].x1,xctx->rect[c][i].y1,xctx->rect[c][i].x2,xctx->rect[c][i].y2) ) diff --git a/src/globals.c b/src/globals.c index bcf3dab7..441d8a8a 100644 --- a/src/globals.c +++ b/src/globals.c @@ -23,7 +23,10 @@ #include "xschem.h" -/* X11 specific globals */ +/* ------------------------------------------------ */ +/* X11 specific globals */ +/* ------------------------------------------------ */ +Display *display; Colormap colormap; unsigned char **pixdata; unsigned char pixdata_init[22][32]={ /* fill patterns... indexed by laynumb. */ @@ -93,12 +96,12 @@ unsigned char pixdata_init[22][32]={ /* fill patterns... indexed by laynumb. {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},/*20 */ {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}/*21 */ }; -GC *gcstipple,*gc; -Pixmap *pixmap = NULL; -Display *display; int screen_number; +int screendepth; Pixmap cad_icon_pixmap=0, cad_icon_mask=0; -XColor xcolor_array[256]; +/* following global is declared in icon.c */ +/* char *cad_icon[] */ +Pixmap *pixmap = NULL; Visual *visual; #if HAS_XRENDER==1 XRenderPictFormat *render_format; @@ -111,71 +114,75 @@ xcb_screen_t *screen_xcb; xcb_visualtype_t *visual_xcb; #endif /*HAS_XCB */ -/* these variables are mirrored in tcl code */ -char *netlist_dir=NULL; /* user set netlist directory via cmd-option or menu or xschemrc */ -char initial_netlist_name[PATH_MAX]={0}; -int has_x=1; -int color_ps=-1; -int flat_netlist = 0; +/* ---------------------------------------------- */ +/* These variables are mirrored in tcl code */ +/* ---------------------------------------------- */ int cadlayers=0; +int has_x=1; int rainbow_colors = 0; -double cairo_font_scale=1.0; /* default: 1.0, allows to adjust font size */ +int flat_netlist = 0; +char *netlist_dir = NULL; +int color_ps=-1; +int only_probes = 0; +double nocairo_vert_correct=0.0; /* lift up the text by 'n' pixels (zoom corrected) within the bbox. */ /* This correction is used to better align existing schematics */ /* compared to the nocairo xschem version. */ /* allowed values should be in the range [-4, 4] */ double cairo_vert_correct=0.0; -double nocairo_vert_correct=0.0; +int constrained_move = 0; +double cairo_font_scale=1.0; /* default: 1.0, allows to adjust font size */ double cairo_font_line_spacing = 1.0; /* value taken from xschemrc / xschem.tcl */ -int netlist_type=-1; +int debug_var=-10; /* will be set to 0 in xinit.c */ +/* -------------------------------------------- */ +/* These variables are NOT mirrored in tcl code */ +/* -------------------------------------------- */ int help=0; /* help option set to global scope, printing help is deferred */ /* when configuration ~/.schem has been read 20140406 */ FILE *errfp; +int no_readline=0; char *filename=NULL; /* filename given on cmdline */ -char user_conf_dir[PATH_MAX]; char home_dir[PATH_MAX]; /* home dir obtained via getpwuid */ +char user_conf_dir[PATH_MAX]; char pwd_dir[PATH_MAX]; /* obtained via getcwd() */ +int load_initfile=1; +char rcfile[PATH_MAX] = {'\0'}; +char *tcl_command = NULL; /* tcl command given on command line with --tcl