From f9dabb89945ec99dfa59c916eb947bddfe15f841 Mon Sep 17 00:00:00 2001 From: Matthew Flatt Date: Mon, 26 Sep 2011 17:39:37 -0600 Subject: [PATCH] add -J/--wm-class argument to set the WM_CLASS class on Unix --- collects/mred/private/wx/gtk/queue.rkt | 4 ++++ collects/scribblings/reference/startup.scrbl | 6 ++++++ src/racket/cmdline.inc | 22 +++++++++++++++++++- 3 files changed, 31 insertions(+), 1 deletion(-) diff --git a/collects/mred/private/wx/gtk/queue.rkt b/collects/mred/private/wx/gtk/queue.rkt index 06642853f9..184e2b348e 100644 --- a/collects/mred/private/wx/gtk/queue.rkt +++ b/collects/mred/private/wx/gtk/queue.rkt @@ -25,6 +25,7 @@ ;; Gtk initialization (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 (let* ([argc-ptr (scheme_register_process_global "PLT_X11_ARGUMENT_COUNT" #f)] @@ -74,6 +75,9 @@ (or display ":0")))) (when 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)))) ;; ------------------------------------------------------------ diff --git a/collects/scribblings/reference/startup.scrbl b/collects/scribblings/reference/startup.scrbl index c38310af17..815fdc8f06 100644 --- a/collects/scribblings/reference/startup.scrbl +++ b/collects/scribblings/reference/startup.scrbl @@ -275,6 +275,12 @@ flags: by @racket[(find-system-path 'run-file)] to @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 native-code just-in-time compiler by setting the @racket[eval-jit-enabled] parameter to @racket[#f].} diff --git a/src/racket/cmdline.inc b/src/racket/cmdline.inc index 93385072c0..0331500db7 100644 --- a/src/racket/cmdline.inc +++ b/src/racket/cmdline.inc @@ -590,6 +590,7 @@ static int run_from_cmd_line(int argc, char *_argv[], #ifdef CMDLINE_STDIO_FLAG int alternate_rep = 0; int no_front = 0; + char *wm_class = NULL; #endif char *init_lib = INITIAL_NAMESPACE_MODULE; 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"; else if (!strcmp("--back", argv[0])) argv[0] = "-K"; + else if (!strcmp("--wm-class", argv[0])) + argv[0] = "-J"; # endif # ifndef NO_YIELD_BEFORE_EXIT else if (!strcmp("--no-yield", argv[0])) @@ -1067,6 +1070,18 @@ static int run_from_cmd_line(int argc, char *_argv[], no_front = 1; was_config_flag = 1; 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 #ifdef USE_OSKIT_CONSOLE case 'S': @@ -1302,6 +1317,8 @@ static int run_from_cmd_line(int argc, char *_argv[], fa->a->no_front = no_front; if (no_front) 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 fa->init_lib = init_lib; fa->global_env = global_env; @@ -1353,9 +1370,12 @@ static int run_from_cmd_line(int argc, char *_argv[], " -X , --collects : Main collects at (or \"\" disables all)\n" " -S , --search : More collects at (after main collects)\n" " -A , --addon : Addon directory at \n" - " -K , --links : User-specific collection links at \n" + " -C , --links : User-specific collection links at \n" " -U, --no-user-path : Ignore user-specific collects, etc.\n" " -N , --name : Sets `(find-system-path 'run-file)' to \n" +# ifdef CMDLINE_STDIO_FLAG + " -J , ---wm-class : Set WM_CLASS class to (Unix)\n" +# endif # ifdef MZ_USE_JIT " -j, --no-jit : Disable the just-in-time compiler\n" # else