[As-users] Re: Multiple wmnets in Wharf, fixed

Tom Jennings (tomj@wps.com)
Thu, 9 Dec 2004 13:36:21 -0800 (PST)


Umm hi,

I'm replying to a two-year-old-thread regarding docking multiple
instances of wmnet (in fvwm). I finally got un-lazy (that
undocked icon bugged me!)  and cobbled up this clean kludge.

For the archive I'll tell the whole tale, problem and fix:

If you try to dock two instances of wmnet, one goes in the dock
and the other lingers on the desktop. I don't know the details
(lazy...) but fvwm uses the X window name to ID things to put
into the dock; it gets confused on the second instance.

Short of fixing fvwm to dock properly, it's easier to change
wmnet.

The essential mechanism is a call to XStoreName() from within
wmnet.c tells X it's window name is the literal string "wmnet".

So I added a proper command-tail option, --instance=NAME to
wmnet 1.06. The given instance name is passed to XStoreName(). If
not specified, it defaults to (surprise) "wmnet".

I wrote to the author, and sent diffs etc, but I'll include them
here for our posteriors.

That's a joke, yo. 



In .fvwm2rc I invoke 'em like so:

*FvwmWharf wmnet1   foo.xpm     MaxSwallow "wmnet-wifi" wmnet --instance=wmnet-wifi --label=WIFI -d 100000 --device=eth1 --logscale --maxrate=10000000 --rxcolor=green --txcolor=red &
*FvwmWharf wmnet2   foo.xpm     MaxSwallow "wmnet-wire" wmnet --instance=wmnet-wire --label=ETH0 -d 100000 --device=eth0 --logscale --maxrate=10000000 --rxcolor=green --txcolor=red &


You have to tell it to Swallow the new instance name.


Thanks to [Paul Johnson <baloo at ursine.dyndns.org>] for his
quickie solution to the problem which led me to this one. Email
me directly; I only joined the list to post this.

tomj






Here's the diffs:




----- wmnet.h ---------------------------

*** wmnet.h.orig	2004-12-09 11:30:51.112186558 -0800
--- wmnet.h	2004-12-09 11:32:48.430177602 -0800
***************
*** 62,67 ****
--- 62,68 ----
  
  
  /* X Stuff */
+ char instance[32]= "wmnet";		/* window manager instance name */
  Display *dpy;
  Window root_window, main_window, icon_window, *visible_window;
  Font thefont;









----- wmnet.c ---------------------------

*** wmnet.c.orig	2004-12-09 11:25:52.000000000 -0800
--- wmnet.c	2004-12-09 12:56:54.297609229 -0800
***************
*** 47,52 ****
--- 47,54 ----
   *  6/23/1998  --  Split up to wmnet.c and wmnet.h
   *  8/5/1998   --  New options --device and --driver
   *  5/4/2000   --  Support added for OpenBSD
+  *  10/12/2004 --  Added --instance=WM_NAME to allow multiple instances
+  *                 to dock in fvwmWharf.
   */ 
  
  #include<stdlib.h>
***************
*** 100,108 ****
  	char *txcolorString = NULL, *rxcolorString = NULL, *labelfgcolorString = NULL, *labelbgcolorString = NULL;
  	char *parser = NULL;
  #ifdef linux
! 	const struct option long_options[19] = {
  #else
! 	const struct option long_options[17] = {
  #endif
  		{"device", required_argument, NULL, 'W'},
  		{"label", required_argument, NULL, 'L'},
--- 102,110 ----
  	char *txcolorString = NULL, *rxcolorString = NULL, *labelfgcolorString = NULL, *labelbgcolorString = NULL;
  	char *parser = NULL;
  #ifdef linux
! 	const struct option long_options[] = {
  #else
! 	const struct option long_options[] = {
  #endif
  		{"device", required_argument, NULL, 'W'},
  		{"label", required_argument, NULL, 'L'},
***************
*** 111,116 ****
--- 113,119 ----
  		{"logscale", no_argument, NULL, 'l'},
  		{"help", no_argument, NULL, 'h'},
  		{"execute", required_argument, NULL, 'e'}, 
+ 		{"instance", required_argument, NULL, 'i'}, 
  #ifdef linux
  		{"txrule", required_argument, NULL, 'T'}, 
  		{"rxrule", required_argument, NULL, 'R'}, 
***************
*** 131,143 ****
  
  	/* Get options */
  #ifdef linux
! 	while((c = getopt_long(argc, argv, "W:F:B:L:vp:u:wnle:R:T:r:t:D:d:x:h", long_options, NULL)) != EOF) {
  #else
! 	while((c = getopt_long(argc, argv, "W:F:B:L:vp:u:wnle:r:t:D:d:x:h", long_options, NULL)) != EOF) {
  #endif
  		switch(c) {
  			case 'v':
! 				printf("wmnet 1.06\n"
  				       "Copyright (C) 1998, 2000 Jesse B. Off, Katharine Osborne <kaos@digitalkaos.net>\n"
  				       "This program is released under the terms of the GNU Public License.\n");
  				exit(14);
--- 134,146 ----
  
  	/* Get options */
  #ifdef linux
! 	while((c = getopt_long(argc, argv, "W:F:B:L:vp:u:wnle:i:R:T:r:t:D:d:x:h", long_options, NULL)) != EOF) {
  #else
! 	while((c = getopt_long(argc, argv, "W:F:B:L:vp:u:wnle:i:r:t:D:d:x:h", long_options, NULL)) != EOF) {
  #endif
  		switch(c) {
  			case 'v':
! 				printf("wmnet 1.06a\n"
  				       "Copyright (C) 1998, 2000 Jesse B. Off, Katharine Osborne <kaos@digitalkaos.net>\n"
  				       "This program is released under the terms of the GNU Public License.\n");
  				exit(14);
***************
*** 222,227 ****
--- 225,234 ----
  					exit(17);
  				}
  				break;
+ 			case 'i':		/* window manager instance name */
+ 				strncpy(instance, optarg, sizeof(instance) );
+ 				break;
+ 
  			case 'w':
  				specified_state = WithdrawnState;
  				break;
***************
*** 275,281 ****
  				}
  				break;
  			default:
! 				printf("wmnet-- v1.06 Katharine Osborne <kaos@digitalkaos.net>\n"
  				       "http://www.digitalkaos.net/linux/wmnet/\n"
  				       "-----------------------------------------------------\n"
  				       "  -h, --help               this help\n"
--- 282,288 ----
  				}
  				break;
  			default:
! 				printf("wmnet-- v1.06a Katharine Osborne <kaos@digitalkaos.net>\n"
  				       "http://www.digitalkaos.net/linux/wmnet/\n"
  				       "-----------------------------------------------------\n"
  				       "  -h, --help               this help\n"
***************
*** 304,309 ****
--- 311,318 ----
                                         "                           connections with -x 10000000)\n"
  				       "  -d DELAY                 delay time for polling statistics\n" 
                                         "                           in microseconds  (default 25000)\n"
+ 				       "  -i, --instance=NAME      tell window manager the name is NAME\n"
+ 				       "                           to allow docking multiple instances\n"
  				       "\n");
  				printf("Compiled in drivers: [%s]\n\n", available_drivers());
                                  printf("Report bugs to joff@iastate.edu\n");
***************
*** 470,476 ****
  	XSetWMNormalHints(dpy, main_window, &shints);
  
  	
! 	XStoreName(dpy, main_window, "wmnet");	
  	XShapeCombineRectangles(dpy, *visible_window, ShapeBounding, 4, 4, &bound, 1, ShapeBounding, 0); 
  	XSelectInput(dpy, *visible_window, (ExposureMask|ButtonPressMask));
  	XMapSubwindows(dpy, *visible_window);
--- 479,485 ----
  	XSetWMNormalHints(dpy, main_window, &shints);
  
  	
! 	XStoreName(dpy, main_window, instance);		/* unique name to dock mult. instances */
  	XShapeCombineRectangles(dpy, *visible_window, ShapeBounding, 4, 4, &bound, 1, ShapeBounding, 0); 
  	XSelectInput(dpy, *visible_window, (ExposureMask|ButtonPressMask));
  	XMapSubwindows(dpy, *visible_window);


_______________________________________________
As-users mailing list
As-users@afterstep.org
http://mail.afterstep.org/mailman/listinfo/as-users