allow multiple instances of MrEd-based apps
svn: r239
This commit is contained in:
parent
7b3e3e09f6
commit
1fdc922b5a
|
@ -487,6 +487,11 @@ _embedr-sig.ss_ library provides the signature, _compiler:embed^_.
|
||||||
the default is 'console for a MzScheme-based application
|
the default is 'console for a MzScheme-based application
|
||||||
and 'windows for a MrEd-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
|
_'forget-exe?_ (Windows, Mac OS X) - a boolean; #t for a launcher
|
||||||
(see `launcher?' below) does not preserve the original
|
(see `launcher?' below) does not preserve the original
|
||||||
executable name for `(find-system-path 'exec-file)'; the
|
executable name for `(find-system-path 'exec-file)'; the
|
||||||
|
|
|
@ -91,14 +91,15 @@
|
||||||
exe)))
|
exe)))
|
||||||
|
|
||||||
;; Find the magic point in the binary:
|
;; Find the magic point in the binary:
|
||||||
(define (find-cmdline)
|
(define (find-cmdline what rx)
|
||||||
(let ([m (regexp-match-positions #"\\[Replace me for EXE hack" (current-input-port))])
|
(let ([m (regexp-match-positions rx (current-input-port))])
|
||||||
(if m
|
(if m
|
||||||
(caar m)
|
(caar m)
|
||||||
(error
|
(error
|
||||||
'make-embedding-executable
|
'make-embedding-executable
|
||||||
(format
|
(format
|
||||||
"can't find cmdline position in executable")))))
|
"can't find ~a position in executable"
|
||||||
|
what)))))
|
||||||
|
|
||||||
;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
|
|
||||||
|
@ -525,11 +526,25 @@
|
||||||
cmdline)])
|
cmdline)])
|
||||||
(if osx?
|
(if osx?
|
||||||
(finish-osx-mred dest full-cmdline exe keep-exe?)
|
(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)])
|
[out (open-output-file dest-exe 'update)])
|
||||||
(dynamic-wind
|
(dynamic-wind
|
||||||
void
|
void
|
||||||
(lambda ()
|
(lambda ()
|
||||||
|
(when anotherpos
|
||||||
|
(file-position out anotherpos)
|
||||||
|
(write-bytes #"no," out))
|
||||||
(if long-cmdline?
|
(if long-cmdline?
|
||||||
;; write cmdline at end:
|
;; write cmdline at end:
|
||||||
(file-position out end)
|
(file-position out end)
|
||||||
|
|
|
@ -841,6 +841,9 @@ void MrEdMSWSleep(float secs, void *fds)
|
||||||
win_extended_fd_set *r, *w, *e;
|
win_extended_fd_set *r, *w, *e;
|
||||||
DWORD msecs;
|
DWORD msecs;
|
||||||
|
|
||||||
|
if (fds && ((win_extended_fd_set *)fds)->no_sleep)
|
||||||
|
return;
|
||||||
|
|
||||||
if (wxCheckMousePosition())
|
if (wxCheckMousePosition())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|
|
@ -57,6 +57,12 @@ extern "C" { typedef int (*ACTUAL_MAIN_PTR)(int argc, char **argv); }
|
||||||
# define CAST_ACTUAL_MAIN /* empty */
|
# define CAST_ACTUAL_MAIN /* empty */
|
||||||
#endif
|
#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)
|
#if defined(_IBMR2)
|
||||||
static void dangerdanger(int)
|
static void dangerdanger(int)
|
||||||
{
|
{
|
||||||
|
@ -650,7 +656,7 @@ int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR ignored
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Check for an existing instance: */
|
/* Check for an existing instance: */
|
||||||
{
|
if (check_for_another[0] != 'n') {
|
||||||
int alreadyrunning;
|
int alreadyrunning;
|
||||||
HANDLE mutex;
|
HANDLE mutex;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user