Subject: FVWM: FvwmWharf ColorLimit

From: Vladimir Kushnir <[email-masked]>
Date: Sun, 7 Dec 1997 01:06:19 +0200 (EET)

Hello,
If there's somebody interested: here is a little (and actually very crude)
patch for those poor souls like myself who still have to run 256 colors
mode but like FvwmWharf module. It somewhat reduces its hunger for colours
(not completely, but with this and with texture buttons and with the
original AfterStep icons my fvwm uses 88 colours instead of 200++). It
requires the original ColorLimit patch, of course.
If somebody would make this better (what, I suppose, is not difficult for
any competent programmer - I'm definitely _not_ the one) please answer me
by e-mail, 'cause unfortunately I'm not on this list.

BTW, if there's somebody using fvwm95, I've got this patch for it as well,
but it's a bit bigger - about 20 kb.

Regards,
Vladimir 

/*------------------------Start patch---------------------------------*/

diff -c FvwmWharf.c.orig FvwmWharf.c
*** FvwmWharf.c.orig	Fri Nov 28 13:10:08 1997
--- FvwmWharf.c	Fri Nov 28 16:17:55 1997
***************
*** 82,87 ****
--- 82,90 ----
  #define ANIM_STEP_MAIN	1   /* same for the main folder */
  #define ANIM_DELAY	10
  
+ /* Color limit */
+ int save_color_limit;                   /* color limit from config */
+ 
  #ifdef ENABLE_SOUND
  #define WHEV_PUSH		0
  #define WHEV_CLOSE_FOLDER	1
***************
*** 261,267 ****
      }
    display_width = DisplayWidth(dpy, screen);
    display_height = DisplayHeight(dpy, screen);
!   
    d_depth = DefaultDepth(dpy, screen);
  
    SetMessageMask(fd, M_NEW_DESK | M_END_WINDOWLIST | M_MAP | M_WINDOW_NAME |
--- 264,271 ----
      }
    display_width = DisplayWidth(dpy, screen);
    display_height = DisplayHeight(dpy, screen);
! 
!   InitPictureCMap(dpy,Root);
    d_depth = DefaultDepth(dpy, screen);
  
    SetMessageMask(fd, M_NEW_DESK | M_END_WINDOWLIST | M_MAP | M_WINDOW_NAME |
***************
*** 1688,1693 ****
--- 1692,1703 ----
  	{
  	  CopyString(&pixmapPath,&tline[10]);
  	}
+       else if ((strlen(&tline[0])>1)&&(mymymymystrncasecmp(tline,"ColorLimit",10)==0))
+ 	{
+           len=sscanf(&tline[Clength+11],"%d",&save_color_limit);
+           if(len < 1)
+           save_color_limit = 256;
+         }	
  #ifdef ENABLE_SOUND	
        else if((strlen(&tline[0])>1)&&(mymymymystrncasecmp(tline,"*AudioDir",9)==0))
  	{
*** icons.c.orig	Mon Jun 23 08:53:34 1997
--- icons.c	Sat Nov 29 16:22:25 1997
***************
*** 39,45 ****
  
  #ifdef XPM
  #include <X11/xpm.h>
! #endif /* XPM */
  #include "stepgfx.h"

--- 39,47 ----
  
  #ifdef XPM
  #include <X11/xpm.h>
! extern int save_color_limit;
! #endif
! 
  #include "stepgfx.h"

***************
*** 208,214 ****
    XWindowAttributes root_attr;
    XpmAttributes xpm_attributes;
    char *path = NULL;
! 
      path = findIconFile(Buttons[button].icons[ico].file, pixmapPath,R_OK);
      if(path == NULL) return 0;
      XGetWindowAttributes(dpy,Root,&root_attr);    
--- 210,218 ----
    XWindowAttributes root_attr;
    XpmAttributes xpm_attributes;
    char *path = NULL;
!   int rc;
!   XpmImage    my_image;
!   
      path = findIconFile(Buttons[button].icons[ico].file, pixmapPath,R_OK);
      if(path == NULL) return 0;
      XGetWindowAttributes(dpy,Root,&root_attr);    
***************
*** 216,238 ****
      xpm_attributes.closeness = 40000;
      xpm_attributes.valuemask = XpmSize | XpmReturnPixels|XpmColormap
        |XpmCloseness;
!     if(XpmReadFileToPixmap(dpy, Root, path,
! 			   &Buttons[button].icons[ico].icon,
! 			   &Buttons[button].icons[ico].mask,
! 			   &xpm_attributes) == XpmSuccess)
!     {
! 	Buttons[button].icons[ico].w = xpm_attributes.width;
! 	Buttons[button].icons[ico].h = xpm_attributes.height;
! 	Buttons[button].icons[ico].depth = d_depth;
! 	free(path);
!     } else {
  	free(path);
  	Buttons[button].icons[ico].icon=None;
  	return 0;
      }
    if (button==BACK_BUTTON) {
!       BUTTONWIDTH = xpm_attributes.width;
!       BUTTONHEIGHT = xpm_attributes.height;
        if (ForceSize && (BUTTONWIDTH > 64 || BUTTONHEIGHT > 64)) {
  	  Pixmap resized;
  	  
--- 220,253 ----
      xpm_attributes.closeness = 40000;
      xpm_attributes.valuemask = XpmSize | XpmReturnPixels|XpmColormap
        |XpmCloseness;
! 
!     rc = XpmReadFileToXpmImage(path, &my_image, NULL);
!     if (rc != XpmSuccess) {
!      fprintf(stderr, "Problem reading pixmap %s, rc %d\n", path, rc);
!      free(path);
!      return;
!     }
!     color_reduce_pixmap(&my_image,save_color_limit);
!     rc = XpmCreatePixmapFromXpmImage(dpy,Root, &my_image,
!                                      &Buttons[button].icons[ico].icon,
!                                      &Buttons[button].icons[ico].mask,
!                                      &xpm_attributes);
! 
!      if (rc != XpmSuccess)
!     { 	
!         fprintf(stderr, "Problem creating pixmap from image, rc %d\n", rc);	
  	free(path);
  	Buttons[button].icons[ico].icon=None;
  	return 0;
+     } else {     
+    	Buttons[button].icons[ico].w = my_image.width;
+    	Buttons[button].icons[ico].h = my_image.height;
+ 	Buttons[button].icons[ico].depth = d_depth;
+ 	free(path);
      }
    if (button==BACK_BUTTON) {
!       BUTTONWIDTH = my_image.width;
!       BUTTONHEIGHT = my_image.height;
        if (ForceSize && (BUTTONWIDTH > 64 || BUTTONHEIGHT > 64)) {
  	  Pixmap resized;
  	  
***************
*** 262,285 ****
  #ifdef XPM
    XWindowAttributes root_attr;
    XpmAttributes xpm_attributes;
! 
    if( button != BACK_BUTTON )
  	return 0;
    XGetWindowAttributes(dpy,Root,&root_attr);
    xpm_attributes.colormap = root_attr.colormap;
    xpm_attributes.valuemask = XpmSize | XpmReturnPixels|XpmColormap;
!   if(XpmCreatePixmapFromData(dpy, Root, data,
! 			 &Buttons[button].icons[0].icon,
! 			 &Buttons[button].icons[0].mask,
! 			 &xpm_attributes) == XpmSuccess) 
!     { 
!       BUTTONWIDTH = Buttons[button].icons[0].w = xpm_attributes.width;
!       BUTTONHEIGHT = Buttons[button].icons[0].h = xpm_attributes.height;
!       Buttons[button].icons[0].depth = d_depth;
!     } 
!    else {
!        return 0;
!    }
      DrawOutline(Buttons[button].icons[0].icon,BUTTONWIDTH,BUTTONHEIGHT);
  
      return 1;
--- 277,313 ----
  #ifdef XPM
    XWindowAttributes root_attr;
    XpmAttributes xpm_attributes;
!   XpmImage my_image;
!   int rc;
!   
    if( button != BACK_BUTTON )
  	return 0;
    XGetWindowAttributes(dpy,Root,&root_attr);
    xpm_attributes.colormap = root_attr.colormap;
    xpm_attributes.valuemask = XpmSize | XpmReturnPixels|XpmColormap;
!  
!      rc = XpmCreateXpmImageFromData(data, &my_image, NULL);
!      color_reduce_pixmap(&my_image,save_color_limit);
!      if (rc != XpmSuccess) {
!      fprintf(stderr, "Problem creating xpm image from data, rc %d\n", rc);
!      return 0;
!        }
!        
!      rc = XpmCreatePixmapFromXpmImage(dpy,Root, &my_image,
!                                          &Buttons[button].icons[0].icon,
!                                          &Buttons[button].icons[0].mask,
!                                          &xpm_attributes);
!      if (rc != XpmSuccess) {
!      fprintf(stderr, "Problem creating pixmap from xpm image, rc %d\n", rc);
!      return 0;
!         }
!     else
!     	{
!    	BUTTONWIDTH = Buttons[button].icons[0].w = my_image.width;
!    	BUTTONHEIGHT = Buttons[button].icons[0].h = my_image.height;
! 	Buttons[button].icons[0].depth = d_depth;
! 	}
! 
      DrawOutline(Buttons[button].icons[0].icon,BUTTONWIDTH,BUTTONHEIGHT);
  
      return 1;

--
Visit the official FVWM web page at <URL:http://www.hpc.uh.edu/fvwm/>.
To unsubscribe from the list, send "unsubscribe fvwm" in the body of a
message to [email-masked].
To report problems, send mail to [email-masked].

---

From: Martin Bialasinski <[email-masked]>
Date: Sun, 7 Dec 1997 03:56:31 +0100 (CET)

Hi,

I have a programm "xisp" which I use for dialup. This programm can react
to SIGUSR1 (connect) and SIGUSR2 (disconnect), so I want to have a
menuoption to connect/disconnect remotely.

So far, I tried this:

I added these two lines to my menudefinition:

+ "connect" connect-xisp
+ "disconnect" exec kill -SIGUSR2 `cat /home/martinb/.xisppid`

AddToFunc       "connect-xisp"
+       "I"     None ["X-ISP"] exec xisp
+       "I"     Exec kill -SIGUSR1 `cat /home/martinb/.xisppid`

Disconnecting works quite right, but the function connect-xisp has some
problems.

If xisp is already running, it works well.
But if xisp is not started yet, fvwm will start it and the kill -SIGUSR1
gets executed too fast. 

The function should wait until the windows gets mapped, or something
similar if I change the startline to start xisp iconic.

Is there a way to do so? 

Also sometimes xisp doesn't get started. The cursor changes from X to O
and back to X (you know what I mean :-), but xisp won't start...

This is fvwm 2.0.46
 
Ciao,
	Martin

---

From: R Dicaire <[email-masked]>
Date: Sun, 7 Dec 1997 01:29:48 -0500 (EST)

> I have a programm "xisp" which I use for dialup. This programm can react
-snip-
> and back to X (you know what I mean :-), but xisp won't start...

I have a similar problem in trying to start ImageMagick from a menu in 
2.0.46. The ImageMagick docs say to use:        display logo:
to start from menu. The other way to start it is do run "display" from an
xterm.
What happens when executed from menu is the program dies as soon as the
programs logo is loaded. It works fine when executed from xterm.
A workaround I found was to create a shell script that executes "display"
and call that from the menu. It works. So perhaps a similar workaround MAY
work for you.

---

From: Martin Bialasinski <[email-masked]>
Date: Sun, 7 Dec 1997 17:47:30 +0100 (CET)

> and call that from the menu. It works. So perhaps a similar workaround MAY
Unfortunately it does not :-( To be more concrete: xisp sometmies won't
start if I started it via the menu then closed it and now want to start it
again.

Starting it from a rxvt always works.

Ciao,
	Martin

---

From: Michael M Han <[email-masked]>
Date: Sun, 07 Dec 1997 23:52:30 -0800

Previously...
>and call that from the menu. It works. So perhaps a similar workaround MAY

I'm not exactly sure why (a previous exchange of mails about spawning
execs revealed to me I'm grossly ignorant of the subject), but
ImageMagick works just fine for me (RHLinux4.1, Linux 2.0.30,
fvwm2.0.46) using:

+ "ImageMagick" Exec exec display &

whereas

+ "ImageMagick" Exec display

acts as you describe. Haven't the foggiest regarding the reason for
this.

As for the question that started the thread, it's a shame Wait won't
work under the circumstances.
_________
mike ([email-masked])
I will not encourage others to fly
 - The collected wisdom of Bart Simpson
--
Visit the official FVWM web page at <URL:http://www.hpc.uh.edu/fvwm/>.
To unsubscribe from the list, send "unsubscribe fvwm" in the body of a
message to [email-masked].
To report problems, send mail to [email-masked].

---

From: Bob Woodside <[email-masked]>
Date: Mon, 08 Dec 1997 21:02:04 -0500 (EST)

On 07-Dec-97 Martin Bialasinski wrote:

> I have a programm "xisp" which I use for dialup...
> I added these...lines to my menudefinition:
> 
> AddToFunc       "connect-xisp"
> ...if xisp is not started yet, fvwm will start it and the kill -SIGUSR1
> gets executed too fast. 
> 

        Er...you haven't told it to wait for anything. Try adding the 
line

+         "I"    Wait X-ISP

before the line where you try to signal the process, and it should work
as you want. (Note that the window name is not quoted - quirky, I know,
but it doesn't work if you quote the name.) I just tried this on my
system, and it works fine. Of course, I had to shake off my usual 
lethargy and upgrade to the latest version of X-ISP to try this - 2.2 
didn't have this feature.  :-)

        By the way, if you have a working pidof command or the equivalent,
that's probably more reliable than looking at ~/.xisppid. A crashed process
could always leave a stale pid file lying around, and things like this also
tend to be release dependent.

        - Bob

---

From: Bob Woodside <[email-masked]>
Date: Mon, 08 Dec 1997 21:02:23 -0500 (EST)

> acts as you describe. Haven't the foggiest regarding the reason for

        This seems to be a quirk in how ImageMagick attempts to figure 
out how it was started (though why it cares to know is beyond me). As 
such, its behavior is apt to differ slightly from system to system. 
Your first example doesn't work on my system -- but remove the '&' and
it does. The second one also works. However, it's not the kind of timing
problem that the original poster was experiencing.

> work under the circumstances.

        Works fine for me...assuming we're talking about the original
X-ISP problem, and not ImageMagick. See my reply to the original poster.

        - Bob

---

From: Martin Bialasinski <[email-masked]>
Date: Tue, 9 Dec 1997 04:32:35 +0100 (CET)

> didn't have this feature.  :-)
I don't have problems with the quotes. Works fine.

I tried "Wait". This doesn't do what I want. Imagine this case: I start
xisp through the menu, it dials in. I minimize the window. I disconnect
vie SIGUSR2. Now I want to cennect again via the menu. A "Wait" will wait
for the minimized (or even a new?) window to (re)appear, wouldn't it?

I use this function which works reasonable well:

DestroyFunc  connect-xisp
AddToFunc       connect-xisp
+       "I"     None ["X-ISP"] exec xtoolwait -timeout 3 xisp\
                                 -bgcol '#0000b0'; kill -SIGUSR1\
                                   `cat /home/martinb/.xisppid`
+       "I"     Exec kill -SIGUSR1 `cat /home/martinb/.xisppid` 

Sometimes (after I restart fvwm, or if I invoke the function while I am
not at page 0,0) it will not work. Either xisp won't start altogether or
it won't dial in or it will start two times... "Interesting feature" as
the programmers say :-)

> tend to be release dependent.
Where do I get such "pidof" utility from? I don't have one and it sounds
as is I really should have one :-)

Ciao,
	Martin

BTW: If you use debian linux, you can get the new xisp package from
ftp://134.95.210.54/pub

---

From: Bob Woodside <[email-masked]>
Date: Tue, 09 Dec 1997 22:05:44 -0500 (EST)

On 09-Dec-97 Martin Bialasinski wrote:
> I tried "Wait". This doesn't do what I want. Imagine this case...

        Ok, I'm a little dense. Now I see what the problem is - I thought
it was just the timing between starting X-IXP and trying to send it a signal.
Handling the case where X-IXP is already active is a job for a shell script,
really. But it's not a very complicated one - check to see if the xisp 
process is active, exec xisp if it isn't and do a check-process/sleep
loop until it looks active, then send the signal. A lot can be done with
FVWM functions, but fvwm is a window manager, not a full-fledged 
programming language - nor was it meant to be. For that, you'd need some-
thing like GWM.  :-)

        Alternatively, two menu items and functions could be used - one for
when X-ISP is active, one for when it's not. 

> as is I really should have one :-)

        It's part of the sysvinit package for Linux systems. (pidof is
actually a symlink to killall5, in the /sbin directory.) If you're using 
Debian Linux, I would think it would be installed as part of the base system.
But this is straying a bit off the subject of FVWM.... If we continue in
this vein, we should probably take it off-line from the mailing list.

        Cheers,
        - Bob

---

From: Martin Bialasinski <[email-masked]>
Date: Wed, 10 Dec 1997 12:42:32 +0100 (CET)

> Handling the case where X-IXP is already active is a job for a shell script,

Well, fvwm2 can handle this really good. No problems so far :-)

+ "connect" connect-xisp
+ "disconnect" exec kill -SIGUSR2 `/sbin/pidof xisp`       

DestroyFunc start-and-wait
AddToFunc start-and-wait
+  "I"  Exec $0
+  "I"  Wait $1

DestroyFunc connect-xisp
AddToFunc connect-xisp
+ "I" None [X-ISP] start-and-wait "xisp -bgcol '#0000b0'" "X-ISP"
+ "I" Exec kill -SIGUSR1 `/sbin/pidof xisp`         

> when X-ISP is active, one for when it's not. 
Sure, but this isn't that neat :-)
 
> Debian Linux, I would think it would be installed as part of the base system.

Yes, it is. I tried a "which pidof" as joe user, so I didn't find it in
/sbin/ . I think I better use "locate whatever|grep bin/" next time.

Thanks,
	Martin