diff --git a/config.h.in b/config.h.in index 2b02a6a2..4ec6741a 100644 --- a/config.h.in +++ b/config.h.in @@ -23,6 +23,9 @@ print [@/*************************************************************/ print {\n\n/* Define this var if cairo is available and is to be used */\n} print_ternary ?libs/gui/cairo/presents {#define HAS_CAIRO 1} {/*#undef HAS_CAIRO */} +print {\n\n/* Define this var if Xlib's xcb is available */\n} +print_ternary ?libs/gui/xcb/presents {#define HAS_XCB 1} {/*#undef HAS_XCB */} + print {\n\n/* Define this var if dup2(2) is available */\n} print_ternary ?libs/io/dup2/presents {#define HAS_DUP2 1} {/*#undef HAS_DUP2 */} diff --git a/scconfig/hooks.c b/scconfig/hooks.c index 4dd36d69..822d20f5 100644 --- a/scconfig/hooks.c +++ b/scconfig/hooks.c @@ -164,6 +164,22 @@ int hook_detect_host() return 0; } +static void disable_xcb(void) +{ + put("libs/gui/xcb/presents", ""); + put("libs/gui/xcb/includes", ""); + put("libs/gui/xcb/cflags", ""); + put("libs/gui/xcb/ldflags", ""); + put("libs/gui/xcb_render/presents", ""); + put("libs/gui/xcb_render/includes", ""); + put("libs/gui/xcb_render/cflags", ""); + put("libs/gui/xcb_render/ldflags", ""); + put("libs/gui/xgetxcbconnection/presents", ""); + put("libs/gui/xgetxcbconnection/includes", ""); + put("libs/gui/xgetxcbconnection/cflags", ""); + put("libs/gui/xgetxcbconnection/ldflags", ""); +} + /* Runs when things should be detected for the host->target system (commands that will be executed on host but will produce files to be used on target) */ int hook_detect_target() @@ -232,6 +248,30 @@ int hook_detect_target() require("libs/gui/xpm/*", 0, 1); require("libs/gui/cairo/*", 0, 0); + + + if (require("libs/gui/cairo-xcb/*", 0, 0) != 0) { + put("libs/gui/xcb/presents", sfalse); + } + else if (require("libs/gui/xcb/*", 0, 0) == 0) { + /* if xcb is used, the code requires these: */ + require("libs/gui/xgetxcbconnection/*", 0, 0); + if (!istrue(get("libs/gui/xgetxcbconnection/presents"))) { + report("Disabling xcb because xgetxcbconnection is not found...\n"); + disable_xcb(); + } + else { + require("libs/gui/xcb_render/*", 0, 0); + if (!istrue(get("libs/gui/xcb_render/presents"))) { + report("Disabling xcb because xcb_render is not found...\n"); + disable_xcb(); + } + } + } + + + + return 0; } @@ -280,6 +320,7 @@ int hook_generate() printf(" tcl: %s\n", get("/target/libs/script/tcl/ldflags")); printf(" tk: %s\n", get("/target/libs/script/tk/ldflags")); printf(" cairo: %s\n", istrue(get("/target/libs/gui/cairo/presents")) ? "yes" : "no"); + printf(" xcb: %s\n", istrue(get("/target/libs/gui/xcb/presents")) ? "yes" : "no"); printf("\nConfiguration complete, ready to compile.\n\n"); } diff --git a/scconfig/src/default/find_cc.c b/scconfig/src/default/find_cc.c index 5522c18c..986007e1 100644 --- a/scconfig/src/default/find_cc.c +++ b/scconfig/src/default/find_cc.c @@ -1095,16 +1095,34 @@ int find_alloca(const char *name, int logdepth, int fatal) } -int find__exit(const char *name, int logdepth, int fatal) +static int find__exit_(const char *inc, int logdepth, int fatal) { - const char *test_c = + const char *test_c_ = NL "#include " + NL "%s" NL "int main() {" NL " _exit(0);" NL " puts(\"BAD\");" NL " return 0;" NL "}" NL ; + char test_c[256]; + + sprintf(test_c, test_c_, inc); /* safe because called only with a few hardwired inc values */ + + if (try_flags_inv(logdepth, NULL, test_c, NULL, NULL, "BAD")) { + put("cc/_exit/presents", strue); + put("cc/_exit/includes", inc); + report("found\n"); + return 0; + } + + return 1; +} + +int find__exit(const char *name, int logdepth, int fatal) +{ + const char **i, *incs[] = {"#include ", NULL}; require("cc/cc", logdepth, fatal); @@ -1112,11 +1130,9 @@ int find__exit(const char *name, int logdepth, int fatal) logprintf(logdepth, "find__exit: trying to find _exit()...\n"); logdepth++; - if (try_flags_inv(logdepth, NULL, test_c, NULL, NULL, "BAD")) { - put("cc/_exit/presents", strue); - report("found\n"); - return 0; - } + for(i = incs; *i != NULL; i++) + if (find__exit_(*i, logdepth, fatal) == 0) + return 0; put("cc/_exit/presents", sfalse); report("Not found.\n"); diff --git a/scconfig/src/gui/find_x.c b/scconfig/src/gui/find_x.c index 759573dd..71514de3 100644 --- a/scconfig/src/gui/find_x.c +++ b/scconfig/src/gui/find_x.c @@ -82,6 +82,7 @@ int find_xinerama(const char *name, int logdepth, int fatal) const char *node = "libs/gui/xinerama"; char **cflags, *cflags_arr[] = {"", NULL}; char **ldflags, *ldflags_arr[] = {"-lXinerama", NULL}; + char **incs, *incs_arr[] = {"#include ", "", NULL}; const char *xincludes, *xcflags, *xldflags; if (require("cc/cc", logdepth, fatal)) @@ -100,8 +101,10 @@ int find_xinerama(const char *name, int logdepth, int fatal) for(cflags = cflags_arr; *cflags != NULL; cflags++) { for(ldflags = ldflags_arr; *ldflags != NULL; ldflags++) { - if (try_icl_with_deps(logdepth, node, test_c, NULL, *cflags, *ldflags, xincludes, xcflags, xldflags, 0) != 0) { - return 0; + for(incs = incs_arr; *incs != NULL; incs++) { + if (try_icl_with_deps(logdepth, node, test_c, *incs, *cflags, *ldflags, xincludes, xcflags, xldflags, 0) != 0) { + return 0; + } } } } diff --git a/src/globals.c b/src/globals.c index 40856ccd..dea32174 100644 --- a/src/globals.c +++ b/src/globals.c @@ -27,6 +27,13 @@ /* X11 specific globals */ /* ------------------------------------------------ */ Display *display; + +#if 0 +#ifdef HAS_XCB +xcb_connection_t *xcb_conn; +#endif +#endif + Colormap colormap; unsigned char **pixdata; unsigned char pixdata_init[22][32]={ /* fill patterns... indexed by laynumb. */ diff --git a/src/scheduler.c b/src/scheduler.c index dad3fc66..e5036ebd 100644 --- a/src/scheduler.c +++ b/src/scheduler.c @@ -414,6 +414,7 @@ int xschem(ClientData clientdata, Tcl_Interp *interp, int argc, const char * arg attach_labels_to_inst(0); Tcl_ResetResult(interp); } + else { cmd_found = 0;} break; case 'b': /*----------------------------------------------*/ if(!strcmp(argv[1], "bbox")) @@ -441,6 +442,7 @@ int xschem(ClientData clientdata, Tcl_Interp *interp, int argc, const char * arg build_colors(tclgetdoublevar("dim_value"), tclgetdoublevar("dim_bg")); Tcl_ResetResult(interp); } + else { cmd_found = 0;} break; case 'c': /*----------------------------------------------*/ if(!strcmp(argv[1], "callback") ) @@ -622,6 +624,7 @@ int xschem(ClientData clientdata, Tcl_Interp *interp, int argc, const char * arg delete(1/*to_push_undo*/); Tcl_ResetResult(interp); } + else { cmd_found = 0;} break; case 'd': /*----------------------------------------------*/ if(!strcmp(argv[1], "debug")) @@ -684,6 +687,7 @@ int xschem(ClientData clientdata, Tcl_Interp *interp, int argc, const char * arg } Tcl_ResetResult(interp); } + else { cmd_found = 0;} break; case 'e': /*----------------------------------------------*/ if(!strcmp(argv[1], "edit_file") ) @@ -765,6 +769,7 @@ int xschem(ClientData clientdata, Tcl_Interp *interp, int argc, const char * arg my_free(927, &result); } } + else { cmd_found = 0;} break; case 'f': /*----------------------------------------------*/ if(!strcmp(argv[1], "find_nth")) @@ -791,6 +796,7 @@ int xschem(ClientData clientdata, Tcl_Interp *interp, int argc, const char * arg else toggle_fullscreen(".drw"); Tcl_ResetResult(interp); } + else { cmd_found = 0;} break; case 'g': /*----------------------------------------------*/ /************ xschem get subcommands *************/ @@ -1290,6 +1296,7 @@ int xschem(ClientData clientdata, Tcl_Interp *interp, int argc, const char * arg go_back(1); Tcl_ResetResult(interp); } + else { cmd_found = 0;} break; case 'h': /*----------------------------------------------*/ if(!strcmp(argv[1], "hash_file")) @@ -1348,6 +1355,7 @@ int xschem(ClientData clientdata, Tcl_Interp *interp, int argc, const char * arg } Tcl_SetResult(interp,ret ? "1" : "0" , TCL_STATIC); } + else { cmd_found = 0;} break; case 'i': /*----------------------------------------------*/ if(!strcmp(argv[1], "instance")) @@ -1577,6 +1585,7 @@ int xschem(ClientData clientdata, Tcl_Interp *interp, int argc, const char * arg Tcl_SetResult(interp, pins ? pins : "", TCL_VOLATILE); my_free(926, &pins); } + else { cmd_found = 0;} break; case 'l': /*----------------------------------------------*/ if(!strcmp(argv[1], "line")) @@ -1715,6 +1724,7 @@ int xschem(ClientData clientdata, Tcl_Interp *interp, int argc, const char * arg } Tcl_ResetResult(interp); } + else { cmd_found = 0;} break; case 'm': /*----------------------------------------------*/ if(!strcmp(argv[1], "make_sch")) /* make schematic from selected symbol 20171004 */ @@ -1760,6 +1770,7 @@ int xschem(ClientData clientdata, Tcl_Interp *interp, int argc, const char * arg else move_objects(START,0,0,0); Tcl_ResetResult(interp); } + else { cmd_found = 0;} break; case 'n': /*----------------------------------------------*/ if(!strcmp(argv[1], "net_label")) @@ -1818,6 +1829,7 @@ int xschem(ClientData clientdata, Tcl_Interp *interp, int argc, const char * arg else new_xschem_process(argv[2],0); Tcl_ResetResult(interp); } + else { cmd_found = 0;} break; case 'o': /*----------------------------------------------*/ if(!strcmp(argv[1], "only_probes")) @@ -1838,6 +1850,7 @@ int xschem(ClientData clientdata, Tcl_Interp *interp, int argc, const char * arg draw(); } } + else { cmd_found = 0;} break; case 'p': /*----------------------------------------------*/ if(!strcmp(argv[1], "parselabel")) @@ -2057,6 +2070,7 @@ int xschem(ClientData clientdata, Tcl_Interp *interp, int argc, const char * arg xctx->push_undo(); Tcl_ResetResult(interp); } + else { cmd_found = 0;} break; case 'r': /*----------------------------------------------*/ if(!strcmp(argv[1], "raw_clear")) @@ -2324,6 +2338,7 @@ int xschem(ClientData clientdata, Tcl_Interp *interp, int argc, const char * arg } Tcl_ResetResult(interp); } + else { cmd_found = 0;} break; case 's': /*----------------------------------------------*/ if(!strcmp(argv[1], "save")) @@ -2757,6 +2772,7 @@ int xschem(ClientData clientdata, Tcl_Interp *interp, int argc, const char * arg } Tcl_AppendResult(interp, "\n", NULL); } + else { cmd_found = 0;} break; case 't': /*----------------------------------------------*/ if(!strcmp(argv[1], "test")) @@ -2802,6 +2818,7 @@ int xschem(ClientData clientdata, Tcl_Interp *interp, int argc, const char * arg draw(); Tcl_ResetResult(interp); } + else { cmd_found = 0;} break; case 'u': /*----------------------------------------------*/ if(!strcmp(argv[1], "undo")) @@ -2873,6 +2890,7 @@ int xschem(ClientData clientdata, Tcl_Interp *interp, int argc, const char * arg else unselect_all(1); Tcl_ResetResult(interp); } + else { cmd_found = 0;} break; case 'v': /*----------------------------------------------*/ if(!strcmp(argv[1], "view_prop")) @@ -2880,6 +2898,7 @@ int xschem(ClientData clientdata, Tcl_Interp *interp, int argc, const char * arg edit_property(2); Tcl_ResetResult(interp); } + else { cmd_found = 0;} break; case 'w': /*----------------------------------------------*/ if(!strcmp(argv[1], "warning_overlapped_symbols")) @@ -2928,6 +2947,16 @@ int xschem(ClientData clientdata, Tcl_Interp *interp, int argc, const char * arg } else xctx->ui_state |= MENUSTARTWIRE; } + else { cmd_found = 0;} + break; + case 'x': /*----------------------------------------------*/ + #ifdef HAS_XCB + if(!strcmp(argv[1], "xcb_info")) + { + dbg(0, "maximum xcb req length=%u\n", xcb_get_maximum_request_length(xcb_conn)); + } + else { cmd_found = 0;} + #endif break; case 'z': /*----------------------------------------------*/ if(!strcmp(argv[1], "zoom_box")) @@ -2995,6 +3024,7 @@ int xschem(ClientData clientdata, Tcl_Interp *interp, int argc, const char * arg zoom_full(1, 1, 1, 0.97); Tcl_ResetResult(interp); } + else { cmd_found = 0;} break; default: diff --git a/src/xinit.c b/src/xinit.c index e150117c..66de332a 100644 --- a/src/xinit.c +++ b/src/xinit.c @@ -2313,6 +2313,13 @@ int Tcl_AppInit(Tcl_Interp *inter) return TCL_ERROR; } display = Tk_Display(mainwindow); + + #if 0 + #ifdef HAS_XCB + xcb_conn = XGetXCBConnection(display); + #endif + #endif + tkwindow = Tk_NameToWindow(interp, ".drw", mainwindow); Tk_MakeWindowExist(tkwindow); xctx->window = Tk_WindowId(tkwindow); diff --git a/src/xschem.h b/src/xschem.h index d29ff6db..527c4305 100644 --- a/src/xschem.h +++ b/src/xschem.h @@ -85,6 +85,13 @@ #include #include #include + +#if 0 +#ifdef HAS_XCB +#include +#endif +#endif + #define xunlink unlink #define xfseek fseek #define xftell ftell @@ -996,6 +1003,10 @@ extern Colormap colormap; extern unsigned char **pixdata; extern unsigned char pixdata_init[22][32]; extern Display *display; + +#ifdef HAS_XCB +extern xcb_connection_t *xcb_conn; +#endif extern int screen_number; extern int screendepth; extern Pixmap cad_icon_pixmap, cad_icon_mask, *pixmap;