From xemacs-m  Tue Jun 10 21:49:59 1997
Received: from slave1.komtron.com (slave1.komtron.com [194.77.5.34])
	by xemacs.org (8.8.5/8.8.5) with ESMTP id VAA08135
	for <xemacs-beta@xemacs.org>; Tue, 10 Jun 1997 21:49:54 -0500 (CDT)
Received: (from Ufga@localhost) by slave1.komtron.com (8.7.5/8.7.3) with UUCP id HAA01904 for xemacs-beta@xemacs.org; Sun, 8 Jun 1997 07:09:42 +0200
X-Authentication-Warning: slave1.komtron.com: Ufga set sender to ograf@fga.de using -f
Received: by fga-intern.de (8.8.5/8.8.5) id SAA10178 for <xemacs-beta@xemacs.org>; Mon, 9 Jun 1997 18:11:30 +0200
Received: by fga-intern.de (8.8.5/8.8.5) id SAA14238
To: xemacs-beta@xemacs.org
Subject: WM_HINTS-group_leader/WM_CLIENT_LEADER (w/ patch)
X-Face: [8r}|"6`WFUT0kiC9dBT%edO~lI5Gwog0Z@Cl=Inx|2F=+DjY#0nGtclM)9lU
        c/8JJ%b&&^:&pWh&nYlQbGSk=WdL^%f!<6a:?n)V_snw7Zc+AW10az=||e8Kv
        1PV49Qe64*68G2`)M8O$mlLQ\!O}$d8]T\L?i@$;=WA~0B[k)O.^T'x?O^=EX
        %=gt6(:hG!-|%$EZGq-Dn6r%N6xqOC4voztttHxOMp!2$o+qPAcT2k&dgO~`%
        kVcW7C<3hK[g9vVpk'#B2(f"pN,jBh`
Mime-Version: 1.0 (generated by tm-edit 7.108)
Content-Type: multipart/mixed;
 boundary="Multipart_Mon_Jun__9_18:12:11_1997-1"
Content-Transfer-Encoding: 7bit
From: Oliver Graf <ograf@fga.de>
Date: 09 Jun 1997 18:12:11 +0200
Message-ID: <m3zpszoiw4.fsf@indie.fga-intern.de>
Lines: 121
X-Mailer: Gnus v5.4.56/XEmacs 20.3(beta4)

--Multipart_Mon_Jun__9_18:12:11_1997-1
Content-Type: text/plain; charset=US-ASCII

I've tried to add some functions to XEmacs, which will set the WM_HINTS
group_leader property to the frame that currently holds the WM_COMMAND
property. I use this frame, because I found no function which returns some
main frame. 

I succeeded partially. The ID is set properly, but only for all but the latest 
frame. Perhaps someone with deeper X knowledge could have a look at my
modifications and solve this problem.

The background of this is to make XEmacs dock-able. The dock is a NeXT-Step
thing, which can swallow Applications. This behavior is emulated by a
windowmanager called WindowMaker (get it at
ftp://afterstep.foo.net/pub/AfterStep/devel/ ). For each group of windows it
creates one application window, which can then be swallowed by the Dock of
WindowMaker. But to determine which window belongs to which group, it needs
some values: WM_COMMAND (to restart), WM_CLASS (group and decorations),
WM_CLIENT_LEADER or the group_leader of WM_HINTS (group).

XEmacs sets all but WM_CLIENT_LEADER :-(

If some one has a solution, knows perhaps how WM_CLIENT_LEADER is set, or has
a better way to solve this: fell free to contact me. I would be most
grateful.

Regards,
  Oliver.

--Multipart_Mon_Jun__9_18:12:11_1997-1
Content-Type: text/plain; charset=US-ASCII

*** xemacs-20.3-b4/src/frame-x.c.orig	Mon Jun  9 18:09:35 1997
--- xemacs-20.3-b4/src/frame-x.c	Mon Jun  9 18:09:40 1997
***************
*** 299,304 ****
--- 299,347 ----
  }
  
  static void
+ x_wm_hack_all_group_leader (struct frame *f)
+ {
+   Widget self = FRAME_X_SHELL_WIDGET ( f );
+   Window main;
+   struct device *d = XDEVICE (FRAME_DEVICE (f));
+   struct frame *g;
+   Lisp_Object rest = DEVICE_FRAME_LIST (d);
+ 
+   /* if the last window is deleted, no frame has WM_COMMAND */
+   if (NILP ( DEVICE_X_WM_COMMAND_FRAME (d)))
+     return;
+   
+   main = XtWindow ( FRAME_X_SHELL_WIDGET ( XFRAME ( DEVICE_X_WM_COMMAND_FRAME (d))));
+ 
+   if (!XtIsWMShell(self))
+     return;
+ 
+   /* add the WM_COMMAND bearing window's id as group_leader to the
+    * WM_HINTS of all top level frames (and to our own -- DOES NOT WORK ??) */
+   while (!NILP (rest))
+     {
+       g = XFRAME (XCAR (rest));
+       if (FRAME_X_TOP_LEVEL_FRAME_P (g))
+ 	{
+ 	  Widget w = FRAME_X_SHELL_WIDGET (g);
+ 	  XWMHints *hints;
+ 	  if (XtIsWMShell(w))
+ 	    {
+ 	      hints=XGetWMHints(XtDisplay (w), XtWindow (w));
+ 	      if (hints!=NULL)
+ 		{
+ 		  hints->window_group = main;
+ 		  hints->flags |= WindowGroupHint;
+ 		  XSetWMHints(XtDisplay (w), XtWindow (w), hints);
+ 		  XFree(hints);
+ 		}
+ 	    }
+ 	}
+       rest = XCDR (rest);
+     }
+ }
+ 
+ static void
  x_wm_store_class_hints (Widget shell, char *frame_name)
  {
    Display *dpy = XtDisplay (shell);
***************
*** 1838,1843 ****
--- 1881,1889 ----
  	x_wm_store_class_hints (shell_widget, XtName (frame_widget));
  	x_wm_maybe_store_wm_command (f);
  	x_wm_hack_wm_protocols (shell_widget);
+ 	/* this seems not the right place, because newly created frames
+ 	 * do not get the group_leader id */
+ 	x_wm_hack_all_group_leader (f);
        }
  
  #ifdef HAVE_XIM
***************
*** 2413,2419 ****
    Lisp_Object popup, frame;
  
    if (FRAME_X_TOP_LEVEL_FRAME_P (f))
!     x_wm_maybe_move_wm_command (f);
  
    /* Frames with the popup property are using other frames as their
       widget parent.  Deleting them are their parent has already been
--- 2459,2468 ----
    Lisp_Object popup, frame;
  
    if (FRAME_X_TOP_LEVEL_FRAME_P (f))
!     {
!       x_wm_maybe_move_wm_command (f);
!       x_wm_hack_all_group_leader (f);
!     }
  
    /* Frames with the popup property are using other frames as their
       widget parent.  Deleting them are their parent has already been

--Multipart_Mon_Jun__9_18:12:11_1997-1--

