include hostname when determining single instance

svn: r5706
This commit is contained in:
Matthew Flatt 2007-02-28 04:12:09 +00:00
parent 38d0a2795d
commit 57fa908947
2 changed files with 13 additions and 7 deletions

View File

@ -236,7 +236,6 @@ static Bool CheckPred(Display *display, XEvent *e, char *args)
over and over again. */ over and over again. */
if (e->xbutton.time > lastUngrabTime) { if (e->xbutton.time > lastUngrabTime) {
Check_Ungrab_Record *cur; Check_Ungrab_Record *cur;
if (!cur_registered) { if (!cur_registered) {
wxREGGLOB(first_cur); wxREGGLOB(first_cur);
wxREGGLOB(last_cur); wxREGGLOB(last_cur);
@ -785,7 +784,7 @@ static int has_property(Display *d, Window w, Atom atag)
return (actual != None); return (actual != None);
} }
static int wxSendOrSetTag(char *pre_tag, char *tag, char *msg) static int wxSendOrSetTag(char *tag, char *pre_tag, char *msg)
{ {
Display *d; Display *d;
Window root, parent, *children; Window root, parent, *children;
@ -899,14 +898,14 @@ static int wxSendOrSetTag(char *pre_tag, char *tag, char *msg)
} }
# define SINGLE_INSTANCE_HANDLER_CODE \ # define SINGLE_INSTANCE_HANDLER_CODE \
"(lambda (f)" \ "(lambda (f host)" \
" (let ([path (simplify-path" \ " (let ([path (simplify-path" \
" (path->complete-path" \ " (path->complete-path" \
" (or (find-executable-path (find-system-path 'run-file) #f)" \ " (or (find-executable-path (find-system-path 'run-file) #f)" \
" (find-system-path 'run-file))" \ " (find-system-path 'run-file))" \
" (current-directory)))])" \ " (current-directory)))])" \
" (let ([tag (string->bytes/utf-8" \ " (let ([tag (string->bytes/utf-8" \
" (format \"~a_~a\" path (version)))])" \ " (format \"~a:~a_~a\" host path (version)))])" \
" (f tag " \ " (f tag " \
" (bytes-append #\"pre\" tag)" \ " (bytes-append #\"pre\" tag)" \
" (apply" \ " (apply" \
@ -932,11 +931,18 @@ static Scheme_Object *prep_single_instance(int argc, Scheme_Object **argv)
int wxCheckSingleInstance(Scheme_Env *global_env) int wxCheckSingleInstance(Scheme_Env *global_env)
{ {
Scheme_Object *a[1], *v; Scheme_Object *a[2], *v;
char buf[256];
if (!wxGetHostName(buf, 256)) {
buf[0] = 0;
}
a[0] = scheme_make_prim(prep_single_instance); a[0] = scheme_make_prim(prep_single_instance);
a[1] = scheme_make_byte_string(buf);
v = scheme_apply(scheme_eval_string(SINGLE_INSTANCE_HANDLER_CODE, v = scheme_apply(scheme_eval_string(SINGLE_INSTANCE_HANDLER_CODE,
global_env), global_env),
1, 2,
a); a);
return SCHEME_TRUEP(v); return SCHEME_TRUEP(v);
} }

View File

@ -39,7 +39,7 @@
int wxGetHostName(char *buf, int sz) int wxGetHostName(char *buf, int sz)
{ {
#ifndef WX_USE_GETHOSTBYNAME #ifndef WX_USE_GETHOSTBYNAME
return (sysinfo(SI_HOSTNAME, buf, maxSize) != -1); return (sysinfo(SI_HOSTNAME, buf, sz - 1) != -1);
#else /* BSD Sockets */ #else /* BSD Sockets */
char name[255]; char name[255];
/* Get hostname */ /* Get hostname */