diff --git a/collects/compiler/doc.txt b/collects/compiler/doc.txt index 85bdc6fc55..f8ef3ae233 100644 --- a/collects/compiler/doc.txt +++ b/collects/compiler/doc.txt @@ -487,6 +487,11 @@ _embedr-sig.ss_ library provides the signature, _compiler:embed^_. the default is 'console for a MzScheme-based application and 'windows for a MrEd-based application + _'single-instance?_ (Windows) - a boolean for MrEd-based apps; the + default is #t, which means that the app looks for instances + of itself on startup and merely brings the other instance to + the front; #f means that multiple instances are expected + _'forget-exe?_ (Windows, Mac OS X) - a boolean; #t for a launcher (see `launcher?' below) does not preserve the original executable name for `(find-system-path 'exec-file)'; the diff --git a/collects/compiler/embed-unit.ss b/collects/compiler/embed-unit.ss index 365c9ba89f..3b5e3ab3c2 100644 --- a/collects/compiler/embed-unit.ss +++ b/collects/compiler/embed-unit.ss @@ -91,14 +91,15 @@ exe))) ;; Find the magic point in the binary: - (define (find-cmdline) - (let ([m (regexp-match-positions #"\\[Replace me for EXE hack" (current-input-port))]) + (define (find-cmdline what rx) + (let ([m (regexp-match-positions rx (current-input-port))]) (if m (caar m) (error 'make-embedding-executable (format - "can't find cmdline position in executable"))))) + "can't find ~a position in executable" + what))))) ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; @@ -525,11 +526,25 @@ cmdline)]) (if osx? (finish-osx-mred dest full-cmdline exe keep-exe?) - (let ([cmdpos (with-input-from-file dest-exe find-cmdline)] + (let ([cmdpos (with-input-from-file dest-exe + (lambda () (find-cmdline + "cmdline" + #"\\[Replace me for EXE hack")))] + [anotherpos (and mred? + (eq? 'windows (system-type)) + (let ([m (assq 'single-instance? aux)]) + (and m (not (cdr m)))) + (with-input-from-file dest-exe + (lambda () (find-cmdline + "instance-check" + #"yes, please check for another"))))] [out (open-output-file dest-exe 'update)]) (dynamic-wind void (lambda () + (when anotherpos + (file-position out anotherpos) + (write-bytes #"no," out)) (if long-cmdline? ;; write cmdline at end: (file-position out end) diff --git a/src/mred/mredmsw.cxx b/src/mred/mredmsw.cxx index 360539f10a..3c39ff17b4 100644 --- a/src/mred/mredmsw.cxx +++ b/src/mred/mredmsw.cxx @@ -841,6 +841,9 @@ void MrEdMSWSleep(float secs, void *fds) win_extended_fd_set *r, *w, *e; DWORD msecs; + if (fds && ((win_extended_fd_set *)fds)->no_sleep) + return; + if (wxCheckMousePosition()) return; diff --git a/src/mred/mrmain.cxx b/src/mred/mrmain.cxx index 6ac73a9bb5..ea0b45d25f 100644 --- a/src/mred/mrmain.cxx +++ b/src/mred/mrmain.cxx @@ -57,6 +57,12 @@ extern "C" { typedef int (*ACTUAL_MAIN_PTR)(int argc, char **argv); } # define CAST_ACTUAL_MAIN /* empty */ #endif +#ifdef wx_msw +/* Hack: overwrite "y" with "n" in binary to disable checking for another + instance of the same app. */ +char *check_for_another = "yes, please check for another"; +#endif + #if defined(_IBMR2) static void dangerdanger(int) { @@ -650,7 +656,7 @@ int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR ignored } /* Check for an existing instance: */ - { + if (check_for_another[0] != 'n') { int alreadyrunning; HANDLE mutex;