Subject: FVWM: FvwmButtons patch here!

From: [email-masked]
Date: Wed, 14 Feb 1996 08:36:09 +0100 (MET)

Hmm, this wasn't too difficult! Here is the patch anyway.

Cut and paste into the two files FvwmButtons.c_diff and icons.c_diff,
in the FvwmButtons directory of your favourite version of fvwm, preferably
2.0.40, then do

  patch FvwmButtons.c < FvwmButtons.c_diff
  patch icons.c < icons.c_diff
  make install

Voila! Instant upgrade :-) Comments, ideas, everything appreciated.

And a PS to Alan Wild on swallow/unswallow etc. I don't think it would be
very hard to do, I just don't see any practical application of it.. But we
might as well keep it on the list for one of those boring sleepless night :-)

Vyrdsamt,
-Jarl

## FvwmButtons.c_diff ######### CUT ### CUT ### CUT ### CUT ### CUT ### CUT ###

68c68
< int max_icon_width = 30,max_icon_height = 0;
---
> int max_internal_width = 30,max_internal_height = 0;
73a74
> int xpad = 2, ypad = 3, framew = 2;
93c94
<  */
---
> */
174a176,192
>   /* load the font, or none */
>   if (mystrncasecmp(font_string,"none",4)==0)
>     {
>       font=NULL;
>     }
>   else 
>     {
>       if ((font = XLoadQueryFont(dpy, font_string)) == NULL)
>         {
>           if ((font = XLoadQueryFont(dpy, "fixed")) == NULL)
> 	    {
> 	      fprintf(stderr,"%s: No fonts available\n",MyName);
> 	      exit(1);
> 	    }
>         }
>     };
> 
178,181c196,207
<       if(Buttons[i].icon_w/Buttons[i].BWidth > max_icon_width)
< 	max_icon_width = Buttons[i].icon_w/Buttons[i].BWidth;
<       if(Buttons[i].icon_h/Buttons[i].BHeight > max_icon_height)
< 	max_icon_height = Buttons[i].icon_h/Buttons[i].BHeight;
---
>       if(Buttons[i].icon_w/Buttons[i].BWidth > max_internal_width)
> 	max_internal_width = Buttons[i].icon_w/Buttons[i].BWidth;
>       if(Buttons[i].title && strcmp(Buttons[i].title,"-")==0||font==NULL)
> 	{
>           if(Buttons[i].icon_h/Buttons[i].BHeight > max_internal_height)
> 	    max_internal_height = Buttons[i].icon_h/Buttons[i].BHeight;
> 	}
>       else
> 	{
> 	  if(Buttons[1].icon_h/Buttons[i].BHeight + font->ascent + font->descent > max_internal_height)
> 	    max_internal_height=Buttons[1].icon_h/Buttons[i].BHeight + font->ascent + font->descent;
> 	};
268a295,296
> 			    ih = Buttons[button].BHeight*ButtonHeight; 
> 			    iw = Buttons[button].BWidth*ButtonWidth; 
270,271c298,299
< 			      Buttons[button].BWidth * ButtonWidth - 4;
< 			    if(strcmp(Buttons[button].title,"-")==0)
---
> 			      iw - 2*framew;
> 			    if(strcmp(Buttons[button].title,"-")==0||font==NULL)
274c302
< 				  Buttons[button].BHeight*ButtonHeight - 4;
---
> 				  ih - 2*framew;
279,280c307,308
< 				  Buttons[button].BHeight*ButtonHeight - 4 
< 				    - font->ascent - font->descent;
---
> 				  ih - 2*framew - font->ascent - font->descent;
> 				ih -= font->ascent + font->descent;
283,285d310
< 			    ih = Buttons[button].icon_h + 4 ; 
< 			    iw = Buttons[button].icon_w + 4 ; 
< 
295c320
< 					(iw - Buttons[button].icon_w)/2,
---
> 					((iw - Buttons[button].icon_w)>>1),
297c322
< 					(ih - Buttons[button].icon_h)/2);
---
> 					((ih - Buttons[button].icon_h)>>1));
443,444c468,469
< 			ih = Buttons[button].icon_h + 4; 
< 			iw = Buttons[button].icon_w + 4; 
---
> 			ih = Buttons[button].icon_h + 2*framew;
> 			iw = Buttons[button].icon_w + 2*framew;
454c479
< 				    (iw - Buttons[button].icon_w)/2,
---
> 				    ((iw - Buttons[button].icon_w)>>1),
456c481
< 				    (ih - Buttons[button].icon_h)/2);
---
> 				    ((ih - Buttons[button].icon_h)>>1));
485,486d509
<   yoff = (ButtonHeight + font->ascent - font->descent)>>1;
< 
500c523
< 		if(strcmp(Buttons[button].title,"-")!=0)
---
> 		if(strcmp(Buttons[button].title,"-")!=0 && font)
504c527
< 		    while((w > (BW-4))&&(len>0))
---
> 		    while((w > (BW-2*framew))&&(len>0))
514c537
< 			    yoff2 = BH - font->descent - 4;
---
> 			    yoff2 = BH - font->descent - 2*framew;
524c547,548
< 					i*ButtonHeight+yoff,
---
> 					i*ButtonHeight+((ButtonHeight + 
>                                         font->ascent - font->descent)>>1),
622,631d645
<   /* load the font */
<   if ((font = XLoadQueryFont(dpy, font_string)) == NULL)
<     {
<       if ((font = XLoadQueryFont(dpy, "fixed")) == NULL)
< 	{
< 	  fprintf(stderr,"%s: No fonts available\n",MyName);
< 	  exit(1);
< 	}
<     };
< 
834,837c848,851
<   /* subtract one for the right/bottom border */
<   mysizehints.width = (max_icon_width+8)*num_columns-1;
<   mysizehints.height=(font->ascent+font->descent+12+max_icon_height)*
<     num_rows-1;
---
>   /* subtract one for the right/bottom border */ /* But that ruins it! Jarl */
>   mysizehints.width = (max_internal_width+2*(xpad+framew))*num_columns;
>   mysizehints.height= (max_internal_height+2*(ypad+framew))*num_rows;
> 
839a854
> /* Stupid thing to do? Makes the window too small on my Xservers. Jarl
841a857,859
> */
>   mysizehints.base_height = num_rows;
>   mysizehints.base_width = num_columns;
856c874
< 	  mysizehints.x = DisplayWidth(dpy,screen) + x - mysizehints.width - 2;
---
> 	  mysizehints.x = DisplayWidth(dpy,screen) + x - mysizehints.width;
863c881
< 	  mysizehints.y = DisplayHeight(dpy,screen) + y - mysizehints.height-2;
---
> 	  mysizehints.y = DisplayHeight(dpy,screen) + y - mysizehints.height;
911c929,934
<   gcm = GCForeground|GCBackground|GCFont;
---
>   gcm = GCForeground|GCBackground;
>   if(font)
>     {
>       gcv.font = font->fid;
>       gcm |= GCFont;
>     }
914d936
<   gcv.font =  font->fid;
1105a1128,1147
> 	      (mystrncasecmp(tline,CatString3("*",MyName,"Padding"),Clength+8)==0))
> 	{
> 	  len=sscanf(&tline[Clength+8],"%d %d",&xpad,&ypad);
> 	  if(len < 2)
> 	    ypad=xpad;
> 	  if(len < 1)
> 	    {
>   	      xpad = 2;
> 	      ypad = 3;
> 	    }
> 	}
> /*    else if((strlen(&tline[0])>1)&&
> 	      (mystrncasecmp(tline,CatString3("*",MyName,"PadY"),Clength+5)==0))
> 	{
> 	  len=sscanf(&tline[Clength+5],"%d",&ypad);
> 	  if(len < 1)
> 	    ypad = 3;
> 	}
> */
>       else if((strlen(&tline[0])>1)&&
1453c1495
< 	    if(strcmp(Buttons[button].title,"-")==0)
---
> 	    if(strcmp(Buttons[button].title,"-")==0 || font==NULL)

## icons.c_diff ########@@@@### CUT ### CUT ### CUT ### CUT ### CUT ### CUT ###

41a42,44
> extern int xpad;
> extern int ypad;
> extern int framew;
108,110c111,113
<   if(w > Buttons[button].BWidth*ButtonWidth  - 8)
<     w = Buttons[button].BWidth*ButtonWidth  - 8;
<   if(strcmp(Buttons[button].title,"-")==0)
---
>   if(w > Buttons[button].BWidth*ButtonWidth - 2*(xpad+framew))
>     w = Buttons[button].BWidth*ButtonWidth - 2*(xpad+framew);
>   if(strcmp(Buttons[button].title,"-")==0 || font==NULL)
112,113c115,116
<       if(h>Buttons[button].BHeight*ButtonHeight-8)
< 	h= Buttons[button].BHeight*ButtonHeight-8;
---
>       if(h>Buttons[button].BHeight*ButtonHeight-2*(ypad+framew))
> 	h= Buttons[button].BHeight*ButtonHeight-2*(ypad+framew);
117,118c120,121
<       if(h>Buttons[button].BHeight*ButtonHeight-8-font->ascent-font->descent)
< 	h= Buttons[button].BHeight*ButtonHeight-8-font->ascent-font->descent;
---
>       if(h>Buttons[button].BHeight*ButtonHeight-2*(ypad+framew)-font->ascent-font->descent)
> 	h= Buttons[button].BHeight*ButtonHeight-2*(ypad+framew)-font->ascent-font->descent;
121d123
< 	  
130c132,140
<   yoff = (Buttons[button].BHeight*ButtonHeight - (h + font->ascent + font->descent))>>1;
---
> 
>   if(strcmp(Buttons[button].title,"-")==0 || font==NULL)
>     {
>       yoff = (Buttons[button].BHeight*ButtonHeight - h)>>1;
>     } 
>   else
>     {
>       yoff = (Buttons[button].BHeight*ButtonHeight - (h + font->ascent + font->descent))>>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: Chris Rode <[email-masked]>
Date: Wed, 14 Feb 1996 01:48:13 CST

[email-masked] writes:

} And a PS to Alan Wild on swallow/unswallow etc. I don't think it would be
} very hard to do, I just don't see any practical application of it.. But we
} might as well keep it on the list for one of those boring sleepless night :-)

the one instance i can see this as a useful feature is i'd like to be
able to swallow my xlogout into FvwmButtons, but xlogout is started
before fvwm on my system.  right now i'm getting around this by using
fvwm as my session manager as well, but just the way our system's login
procedure works, it takes much longer for fvwm to start this way. (the
wm is loaded, then any x apps specified in a ~/.startup.X11 file, then
the session manager...)  i can't really see a use for unswallowing, but
somebody, sometime must have. :)

--chris

--
chris rode - [email-masked]			Help Room Consultant
http://www.public.iastate.edu/~crode/		138 Durham Center
"why don't we just have a stupidity tax?	294-1314
 just tax the stupid people!"
--
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: Alexander Sorg <[email-masked]>
Date: Wed, 14 Feb 1996 08:41:51 -0500 (EST)

> somebody, sometime must have. :)

as it is now, whenever you restart fvwm all the apps in the fvwmbuttons
are closed. with swallow/unswallow they could be unswallowed before
the fvwmbuttons dies and swallowed again by the new instance of the 
module. this would speed up the restart because the time to restart 
all swalloed apps is saved.

you could also change the configuration for a single swalloed app,
unswallow, kill it and swallow the new instance of the same app. 
right now you would have to restart the whole window manager.
obviously the unswallow here becomes obsolete if fvwm would allow 
swalloed apps to die (which it doesn't right now)

       alex

---

From: [email-masked] (Robert Nation 885-9815)
Date: Wed, 14 Feb 96 09:19:23 EST

>swalloed apps to die (which it doesn't right now)

Right now, you would only need to kill or close the button-bar, and
launch a new one. No need to restart the window manager.

---

From: Alexander Sorg <[email-masked]>
Date: Wed, 14 Feb 1996 10:00:47 -0500 (EST)

> launch a new one. No need to restart the window manager.

right! didn't think of that. but still it would be faster if only
the app w/ the modified configuration had to be restarted. especially
if you have a lot of apps in your fvwmbuttons.