FVWM: FvwmButtons patch here!

From: <jarl_at_cptsu5.univ-mrs.fr>
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 ########_at_@@@### 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 majordomo_at_hpc.uh.edu.
To report problems, send mail to fvwm-owner_at_hpc.uh.edu.
Received on Wed Feb 14 1996 - 01:35:13 GMT

This archive was generated by hypermail 2.3.0 : Mon Aug 29 2016 - 19:37:58 BST