diff --git a/magic/Makefile b/magic/Makefile index cefa8062..cb147b1e 100644 --- a/magic/Makefile +++ b/magic/Makefile @@ -52,15 +52,18 @@ magicWasm.o: magicWasm.c ${RM} magicWasm.o ${CC} ${CFLAGS} ${CPPFLAGS} ${DFLAGS_NOSTUB} -c magicWasm.c -# Pull in BOTH the main TCL archive (LIB_SPECS_NOSTUB → -ltcl9.x) and the -# stub bootstrap archive (-L${TCL_LIB_DIR} -ltclstub). Magic's source uses -# USE_TCL_STUBS macros, so tclStubsPtr (defined in libtclstub.a) and -# Tcl_InitStubs must be present in the same binary as the actual TCL -# implementation from libtcl9.x.a. magic.js: lib${MODULE}.o ${EXTRA_LIBS} @echo --- building main magic WASM ${RM} magic.js magic.wasm +ifneq (${TCL_LIB_DIR},) +# TCL variant: pull in the main TCL archive (LIB_SPECS_NOSTUB → -ltcl9.x) and +# the stub-bootstrap archive (-ltclstub). Both are required: magic's objects +# use USE_TCL_STUBS macros (resolved by tclStubsPtr from libtclstub.a), and +# tclStubsPtr itself must point into the real TCL implementation (libtcl9.x.a). ${CC} ${CFLAGS} ${CPPFLAGS} ${DFLAGS} lib${MODULE}.o ${EXTRA_LIBS} -o magic.js ${LIBS} ${LIB_SPECS_NOSTUB} -L${TCL_LIB_DIR} -ltclstub +else + ${CC} ${CFLAGS} ${CPPFLAGS} ${DFLAGS} lib${MODULE}.o ${EXTRA_LIBS} -o magic.js ${LIBS} +endif endif main: magic proto.magicrc diff --git a/magic/magicWasm.c b/magic/magicWasm.c index eca5de7f..b6e454a3 100644 --- a/magic/magicWasm.c +++ b/magic/magicWasm.c @@ -157,9 +157,6 @@ magic_wasm_source_file(const char *path) if ((path == NULL) || (*path == '\0')) return -1; - TxSetPoint(GrScreenRect.r_xtop / 2, GrScreenRect.r_ytop / 2, - WIND_UNKNOWN_WINDOW); - #ifdef MAGIC_WRAPPER /* In wrapper mode the file contains Tcl; evaluate it through the * Tcl interpreter so that magic:: commands are dispatched via @@ -176,6 +173,12 @@ magic_wasm_source_file(const char *path) TxError("Unable to open command file \"%s\".\n", path); return -1; } + /* Set the current point to the center of the screen so that + * WindSendCommand routes all commands from the file to the layout + * window client. Without this, commands arrive with point (0,0) + * and end up in the border/windClient context where most are unknown. */ + TxSetPoint(GrScreenRect.r_xtop / 2, GrScreenRect.r_ytop / 2, + WIND_UNKNOWN_WINDOW); TxDispatch(f); fclose(f); return 0; diff --git a/tcltk/tclmagic.c b/tcltk/tclmagic.c index 7132d7ea..aeb097bc 100644 --- a/tcltk/tclmagic.c +++ b/tcltk/tclmagic.c @@ -656,7 +656,6 @@ process_rlimit_startup_check(void) #endif /* HAVE_GETRLIMIT */ } -/*------------------------------------------------------*/ /*--------------------------------------------------------------*/ /* Register magic:: commands with the Tcl interpreter. */ /* Called after Magic's C subsystems are fully */