From: Hamish.Macdonald@x400gate.bnr.ca (Hamish Macdonald)
Subject: Re: Lucid Emacs and WM_COMMAND
Organization: Bell Northern Research
Date: Tue, 17 Nov 92 18:54:27 GMT

>>>>> On Wed, 11 Nov 92 18:32:39 GMT,
>>>>> In message <1992Nov11.183239.7959@bmerh85.bnr.ca>,
>>>>> I wrote:

Hamish> Lucid Emacs doesn't specify a WM_COMMAND property on any of
Hamish> its screens.

Hamish> Perhaps lemacs should take pains to ensure that only one
Hamish> screen at a time has WM_COMMAND on it.

Hamish> I can work on this problem, but any comments/advice would be
Hamish> appreciated.

I've implemented the above.  I'm no X-pert, but I think what I've done
should be OK.

Here are the patches:

*** xfns.c.orig	Fri Nov 13 10:05:25 1992
--- xfns.c	Mon Nov 16 11:38:49 1992
***************
*** 711,716 ****
--- 711,718 ----
  }
  
  
+ static int wm_command_set;
+ 
  /* Creates the widgets for a screen.  Parms is an alist of
  resources/values to use for the screen.  (ignored right now).
  reslisp_window_id is a Lisp description of an X window or Xt widget to
***************
*** 787,792 ****
--- 789,800 ----
    XtManageChild (pane_widget);
    XtRealizeWidget (shell_widget);
  
+   if (!wm_command_set)
+     {
+       wm_command_set = 1;
+       set_wm_command (shell_widget);
+     }
+ 
  #if !defined(NO_FOCUS_MGMT)
    properties [0] = Xatom_WM_TAKE_FOCUS;
    XChangeProperty (XtDisplay (shell_widget), XtWindow (shell_widget),
***************
*** 2133,2138 ****
--- 2141,2149 ----
  
    /* This is zero if not using X windows.  */
    x_current_display = 0;
+ 
+   /* initially, no WM_COMMAND property is set */
+   wm_command_set = 0;
  
    DEFVAR_LISP ("x-gc-pointer-shape", &Vx_gc_pointer_shape,
     "The shape of the mouse-pointer during garbage collection.\n\
*** xterm.c.orig	Thu Sep 10 00:18:42 1992
--- xterm.c	Mon Nov 16 10:59:28 1992
***************
*** 2626,2631 ****
--- 2626,2646 ----
    UNBLOCK_INPUT;
  }
  
+ /* set the WM_COMMAND property of the window */
+ void
+ set_wm_command (w)
+     Widget w;
+ {
+     int argc;
+     char **argv;
+     extern Lisp_Object Vcommand_line_args;
+ 
+     make_argc_argv (Vcommand_line_args, &argc, &argv);
+ 
+     XSetCommand (XtDisplay(w), XtWindow(w), argv, argc);
+     free (argv);
+ }
+ 
  /* Destroy the X window of screen S.
     DISPL is the former s->display (since s->display
     has already been nulled out).  */
***************
*** 2634,2641 ****
       struct screen *s;
       union display displ;
  {
    BLOCK_INPUT;
!   XtDestroyWidget(displ.x->widget);
    UNBLOCK_INPUT;
    
    free (displ.x);
--- 2649,2675 ----
       struct screen *s;
       union display displ;
  {
+   struct x_display* x = displ.x;
+   struct screen *new_s; 
+   int argc;
+   char **argv;
+ 
    BLOCK_INPUT;
!   /* If the WM_COMMAND property is on the window, put it on another one */
!   if (XGetCommand (XtDisplay (x->widget), XtWindow (x->widget),
!                        &argv, &argc))
!     {
!       XDeleteProperty (XtDisplay (x->widget), XtWindow (x->widget),
!                        XA_WM_COMMAND);
!       
!       if (NILP (Vscreen_list)) abort ();
!       new_s = XSCREEN (Fcar (Vscreen_list));
!       XSetCommand (XtDisplay (new_s->display.x->widget),
!                    XtWindow (new_s->display.x->widget),
!                    argv, argc);
!       XFreeStringList (argv);
!     }
!   XtDestroyWidget(x->widget);
    UNBLOCK_INPUT;
    
    free (displ.x);
Newsgroups: alt.lucid-emacs.bug