add -J/--wm-class argument to set the WM_CLASS class on Unix

This commit is contained in:
Matthew Flatt 2011-09-26 17:39:37 -06:00
parent 8711feae2d
commit f9dabb8994
3 changed files with 31 additions and 1 deletions

View File

@ -25,6 +25,7 @@
;; Gtk initialization ;; Gtk initialization
(define-gtk gtk_init_check (_fun (_ptr io _int) (_ptr io _gcpointer) -> _gboolean)) (define-gtk gtk_init_check (_fun (_ptr io _int) (_ptr io _gcpointer) -> _gboolean))
(define-gdk gdk_set_program_class (_fun _string -> _void))
(define x11-display (define x11-display
(let* ([argc-ptr (scheme_register_process_global "PLT_X11_ARGUMENT_COUNT" #f)] (let* ([argc-ptr (scheme_register_process_global "PLT_X11_ARGUMENT_COUNT" #f)]
@ -74,6 +75,9 @@
(or display ":0")))) (or display ":0"))))
(when single-instance? (when single-instance?
(do-single-instance)) (do-single-instance))
(let ([v (scheme_register_process_global "Racket-GUI-wm-class" #f)])
(when v
(gdk_set_program_class (cast v _pointer _string))))
display)))) display))))
;; ------------------------------------------------------------ ;; ------------------------------------------------------------

View File

@ -275,6 +275,12 @@ flags:
by @racket[(find-system-path 'run-file)] to by @racket[(find-system-path 'run-file)] to
@nonterm{file}.} @nonterm{file}.}
@item{@FlagFirst{J} @nonterm{name} or @DFlagFirst{wm-class}
@nonterm{name} : GRacket, Unix only; sets the @tt{WM_CLASS}
program class to @nonterm{name} (while the @tt{WM_CLASS}
program name is derived from the executable name or a
@Flag{N}/@DFlag{name} argument).}
@item{@FlagFirst{j} or @DFlagFirst{no-jit} : Disables the @item{@FlagFirst{j} or @DFlagFirst{no-jit} : Disables the
native-code just-in-time compiler by setting the native-code just-in-time compiler by setting the
@racket[eval-jit-enabled] parameter to @racket[#f].} @racket[eval-jit-enabled] parameter to @racket[#f].}

View File

@ -590,6 +590,7 @@ static int run_from_cmd_line(int argc, char *_argv[],
#ifdef CMDLINE_STDIO_FLAG #ifdef CMDLINE_STDIO_FLAG
int alternate_rep = 0; int alternate_rep = 0;
int no_front = 0; int no_front = 0;
char *wm_class = NULL;
#endif #endif
char *init_lib = INITIAL_NAMESPACE_MODULE; char *init_lib = INITIAL_NAMESPACE_MODULE;
int was_config_flag = 0, saw_nc_flag = 0; int was_config_flag = 0, saw_nc_flag = 0;
@ -823,6 +824,8 @@ static int run_from_cmd_line(int argc, char *_argv[],
argv[0] = "-z"; argv[0] = "-z";
else if (!strcmp("--back", argv[0])) else if (!strcmp("--back", argv[0]))
argv[0] = "-K"; argv[0] = "-K";
else if (!strcmp("--wm-class", argv[0]))
argv[0] = "-J";
# endif # endif
# ifndef NO_YIELD_BEFORE_EXIT # ifndef NO_YIELD_BEFORE_EXIT
else if (!strcmp("--no-yield", argv[0])) else if (!strcmp("--no-yield", argv[0]))
@ -1067,6 +1070,18 @@ static int run_from_cmd_line(int argc, char *_argv[],
no_front = 1; no_front = 1;
was_config_flag = 1; was_config_flag = 1;
break; break;
case 'J':
if (argc < 2) {
PRINTF("%s: missing name after %s switch\n",
prog,
real_switch);
goto show_need_help;
}
argv++;
--argc;
wm_class = argv[0];
was_config_flag = 1;
break;
#endif #endif
#ifdef USE_OSKIT_CONSOLE #ifdef USE_OSKIT_CONSOLE
case 'S': case 'S':
@ -1302,6 +1317,8 @@ static int run_from_cmd_line(int argc, char *_argv[],
fa->a->no_front = no_front; fa->a->no_front = no_front;
if (no_front) if (no_front)
scheme_register_process_global("Racket-GUI-no-front", (void *)0x1); scheme_register_process_global("Racket-GUI-no-front", (void *)0x1);
if (wm_class)
scheme_register_process_global("Racket-GUI-wm-class", (void *)wm_class);
#endif #endif
fa->init_lib = init_lib; fa->init_lib = init_lib;
fa->global_env = global_env; fa->global_env = global_env;
@ -1353,9 +1370,12 @@ static int run_from_cmd_line(int argc, char *_argv[],
" -X <dir>, --collects <dir> : Main collects at <dir> (or \"\" disables all)\n" " -X <dir>, --collects <dir> : Main collects at <dir> (or \"\" disables all)\n"
" -S <dir>, --search <dir> : More collects at <dir> (after main collects)\n" " -S <dir>, --search <dir> : More collects at <dir> (after main collects)\n"
" -A <dir>, --addon <dir> : Addon directory at <dir>\n" " -A <dir>, --addon <dir> : Addon directory at <dir>\n"
" -K <file>, --links <file> : User-specific collection links at <file>\n" " -C <file>, --links <file> : User-specific collection links at <file>\n"
" -U, --no-user-path : Ignore user-specific collects, etc.\n" " -U, --no-user-path : Ignore user-specific collects, etc.\n"
" -N <file>, --name <file> : Sets `(find-system-path 'run-file)' to <file>\n" " -N <file>, --name <file> : Sets `(find-system-path 'run-file)' to <file>\n"
# ifdef CMDLINE_STDIO_FLAG
" -J <name>, ---wm-class <name> : Set WM_CLASS class to <name> (Unix)\n"
# endif
# ifdef MZ_USE_JIT # ifdef MZ_USE_JIT
" -j, --no-jit : Disable the just-in-time compiler\n" " -j, --no-jit : Disable the just-in-time compiler\n"
# else # else