Subject: Re: Enhancement to FvwmIconMan

From: Chris Ross <[email-masked]>
Date: Mon, 15 Mar 2004 15:38:47 -0500

Dominik Vogt wrote:
> I don't really care whether it's possible or not.  But if the
> thickness is 0, RelieveRectangle() should never be called.

   Of course.  Sorry for not catching that this first time.
Fixed in this version of the patch.

> I wouldn't mind to add this to your patch.

   Included...

                         - Chris

Index: fvwm/libs/Graphics.c
===================================================================
RCS file: /home/cvs/fvwm/fvwm/libs/Graphics.c,v
retrieving revision 1.78
diff -u -u -r1.78 Graphics.c
--- fvwm/libs/Graphics.c	16 Feb 2004 10:18:29 -0000	1.78
+++ fvwm/libs/Graphics.c	15 Mar 2004 20:29:18 -0000
@@ -87,6 +87,13 @@
 	{
 		return;
 	}
+	/* If line_width is negative, reverse the rotation, which will */
+	/* have the effect of inverting the relief. */
+	if (line_width < 0)
+	{
+		line_width *= -1;
+		rotation = (rotation + 2) % 4;
+	}
 	if (rotation == ROTATION_270)
 	{
 		rotation = ROTATION_90;
Index: fvwm/modules/FvwmIconMan/FvwmIconMan.1
===================================================================
RCS file: /home/cvs/fvwm/fvwm/modules/FvwmIconMan/FvwmIconMan.1,v
retrieving revision 1.27
diff -u -u -r1.27 FvwmIconMan.1
--- fvwm/modules/FvwmIconMan/FvwmIconMan.1	19 Apr 2003 03:01:02 -0000	1.27
+++ fvwm/modules/FvwmIconMan/FvwmIconMan.1	15 Mar 2004 20:29:19 -0000
@@ -108,6 +108,7 @@
 NoIconAction    animate iconification      NOP
 PlainButton     style for normal buttons   up black grey
 PlainColorset
+ReliefThickness size of button relief      2
 Resolution      global/desk/page/screen    page
 Reverse         normal, icon or none	   none
 SelectButton    style for selected buttons flat black grey
@@ -249,6 +250,13 @@
 .IP "*FvwmIconMan: [id] PlainColorset \fIcolorset\fP"
 Works like plainbutton but uses colorsets instead.  The style setting can
 still only be applied with plainbutton.  See FvwmTheme.
+
+.IP "*FvwmIconMan: [id] ReliefThickness \fInum\fP"
+\fInum\fP is a positive integer specifying the number of pixels thick
+that the relief at the edge of non-flat buttons should be.  This has
+no effect on flat buttons.  In theory, you should be able to set this
+to a negative number and have it act like \fIReverse\fP, but negative
+numbers don't work.  This may change later.
 
 .IP "*FvwmIconMan: [id] Resolution \fIresolution\fP"
 Specifies when the manager will display an entry for a certain
Index: fvwm/modules/FvwmIconMan/FvwmIconMan.h
===================================================================
RCS file: /home/cvs/fvwm/fvwm/modules/FvwmIconMan/FvwmIconMan.h,v
retrieving revision 1.55
diff -u -u -r1.55 FvwmIconMan.h
--- fvwm/modules/FvwmIconMan/FvwmIconMan.h	25 Aug 2003 06:47:09 -0000	1.55
+++ fvwm/modules/FvwmIconMan/FvwmIconMan.h	15 Mar 2004 20:29:19 -0000
@@ -303,6 +303,7 @@
 	Uchar showonlyiconic;
 	Uchar showtransient;
 	rectangle managed_g;    /* dimensions of managed screen portion */
+	int relief_thickness;	/* relief thickness for each non-flat button */
 
 	/* X11 state */
 	Window theWindow, theFrame;
Index: fvwm/modules/FvwmIconMan/globals.c
===================================================================
RCS file: /home/cvs/fvwm/fvwm/modules/FvwmIconMan/globals.c,v
retrieving revision 1.25
diff -u -u -r1.25 globals.c
--- fvwm/modules/FvwmIconMan/globals.c	29 Jun 2003 19:53:25 -0000	1.25
+++ fvwm/modules/FvwmIconMan/globals.c	15 Mar 2004 20:29:19 -0000
@@ -83,6 +83,7 @@
 	globals.managers[id].we_are_drawing = 1;
 	globals.managers[id].showonlyiconic = 0;
 	globals.managers[id].showtransient = 0;
+	globals.managers[id].relief_thickness = 2;
 }
 
 void print_managers(void)
Index: fvwm/modules/FvwmIconMan/readconfig.c
===================================================================
RCS file: /home/cvs/fvwm/fvwm/modules/FvwmIconMan/readconfig.c,v
retrieving revision 1.55
diff -u -u -r1.55 readconfig.c
--- fvwm/modules/FvwmIconMan/readconfig.c	5 Jul 2003 01:37:47 -0000	1.55
+++ fvwm/modules/FvwmIconMan/readconfig.c	15 Mar 2004 20:29:19 -0000
@@ -1951,6 +1951,19 @@
 	ConsoleDebug(CONFIG, "Setting usewinlist to: %d\n", i);
 	SET_MANAGER(manager, usewinlist, i);
       }
+      else if (!strcasecmp(option1, "reliefthickness")) {
+	p = read_next_cmd(READ_ARG);
+	if (!p) {
+	  ConsoleMessage("Bad line: %s\n", current_line);
+	  continue;
+	}
+	if (extract_int(p, &n) == 0) {
+	  ConsoleMessage("This is not a number: %s\n", p);
+	  ConsoleMessage("Bad line: %s\n", current_line);
+	  continue;
+	}
+	SET_MANAGER(manager, relief_thickness, n);
+      }
       else {
 	ConsoleMessage("Bad line: %s\n", current_line);
 	ConsoleMessage("Unknown option: %s\n", p);
Index: fvwm/modules/FvwmIconMan/xmanager.c
===================================================================
RCS file: /home/cvs/fvwm/fvwm/modules/FvwmIconMan/xmanager.c,v
retrieving revision 1.83
diff -u -u -r1.83 xmanager.c
--- fvwm/modules/FvwmIconMan/xmanager.c	25 Aug 2003 06:47:09 -0000	1.83
+++ fvwm/modules/FvwmIconMan/xmanager.c	15 Mar 2004 20:29:20 -0000
@@ -1336,13 +1336,13 @@
 static void draw_3d_icon(WinManager *man, int box, ButtonGeometry *g,
 			  int iconified, Contexts contextId)
 {
-  if (iconified == 0)
+  if ((iconified == 0) || (man->relief_thickness == 0))
     return;
   else
     RelieveRectangle(theDisplay, man->theWindow, g->icon_x, g->icon_y,
 		      g->icon_w - 1, g->icon_h - 1,
 		      man->reliefContext[contextId],
-		      man->shadowContext[contextId], 2);
+		      man->shadowContext[contextId], man->relief_thickness);
 }

@@ -1537,19 +1537,36 @@
 			 GC context1, GC context2)
 {
   int state;
+  int relief;
+
   state = man->buttonState[button_state];
+  relief = man->relief_thickness;
+
+  /* Make sure that the relief isn't too large for the button... */
+  if ((abs(relief) > (man->geometry.boxheight / 2)) ||
+      (abs(relief) > (man->geometry.boxwidth / 2))) {
+      relief = min(man->geometry.boxheight/2, man->geometry.boxwidth/2);
+      if (man->relief_thickness < 0)
+        relief *= -1;
+      fprintf(stderr, "%s: Requested relief (%d) too large (for %dx%d box); capped to %d.\n",
+	      MyName, man->relief_thickness, man->geometry.boxwidth, man->geometry.boxheight, relief);
+      man->relief_thickness = relief;
+  }
 
-  if (state == BUTTON_FLAT)
+  if (state == BUTTON_FLAT || relief == 0)
     return;
   if (state == BUTTON_EDGEUP || state == BUTTON_EDGEDOWN) {
     RelieveRectangle(theDisplay, man->theWindow, g->button_x, g->button_y,
-		      g->button_w - 1, g->button_h - 1, context1, context2, 2);
+		      g->button_w - 1, g->button_h - 1, context1, context2,
+		      relief);
     RelieveRectangle(theDisplay, man->theWindow, g->button_x+2, g->button_y+2,
-		      g->button_w - 5, g->button_h - 5, context2, context1, 2);
+		      g->button_w - 5, g->button_h - 5, context2, context1,
+		      relief);
   }
   else {
     RelieveRectangle(theDisplay, man->theWindow, g->button_x, g->button_y,
-		      g->button_w - 1, g->button_h - 1, context1, context2, 2);
+		      g->button_w - 1, g->button_h - 1, context1, context2,
+		      relief);
   }
 }

---

From: Dominik Vogt <[email-masked]>
Date: Fri, 19 Mar 2004 10:39:12 +0100

> >I wouldn't mind to add this to your patch.

Cool.  I'll apply the patch shortly.  Can you provide something
for the NEWS and AUTHORS files too?

Ciao

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

---

From: Dominik Vogt <[email-masked]>
Date: Fri, 19 Mar 2004 10:48:56 +0100

On Fri, Mar 19, 2004 at 10:39:12AM +0100, fvwm-workers wrote:
> Cool.  I'll apply the patch shortly.

> Can you provide something for the NEWS and AUTHORS files too?

... and the ChangeLog

Ciao

Dominik ^_^  ^_^

---

From: Chris Ross <[email-masked]>
Date: Fri, 19 Mar 2004 12:22:05 -0500

> for the NEWS and AUTHORS files too?

   (and ChangeLog, and Modules/ChangeLog)

   Done.  I also updated the entry in FvwmIconMan.1, which I
realized I hadn't updated since putting in your suggestions,
and making negative values work.

   (I'm not 100% sure that using "0" for ReliefThickness will
cause TitleButtons to be flat.  But I think so.  Anyone have
a better idea if TitleButtons are different than the other
classes of buttons?)

   Thanks!

                              - Chris

Index: ChangeLog
===================================================================
RCS file: /home/cvs/fvwm/fvwm/ChangeLog,v
retrieving revision 1.2472
diff -u -u -r1.2472 ChangeLog
--- ChangeLog	19 Mar 2004 16:39:54 -0000	1.2472
+++ ChangeLog	19 Mar 2004 17:19:04 -0000
@@ -49,6 +49,11 @@
 	(__place_window):
 	renamed function
 
+2004-03-15  Chris Ross  <[email-masked]>
+
+	* libs/Graphics.c (do_relieve_rectangle_with_rotation)
+	allow a negative line_width to invert the relief
+
 2004-03-06  Marcus Lundblad  <[email-masked]>
 
 	* libs/Flocale.c (FlocaleDrawString)
Index: NEWS
===================================================================
RCS file: /home/cvs/fvwm/fvwm/NEWS,v
retrieving revision 1.514
diff -u -u -r1.514 NEWS
--- NEWS	19 Mar 2004 16:39:54 -0000	1.514
+++ NEWS	19 Mar 2004 17:19:04 -0000
@@ -13,7 +13,7 @@
 
 * New BugOpts option ExplainWindowPlacement.
 
-* Inverted button reliefs in FvwmIconMan.
+* Adjustable button reliefs in FvwmIconMan (option ReliefThickness).
 
 * Security patch in fvwm-bug.
   See http://securitytracker.com/alerts/2004/Jan/1008781.html
Index: AUTHORS
===================================================================
RCS file: /home/cvs/fvwm/fvwm/AUTHORS,v
retrieving revision 1.90
diff -u -u -r1.90 AUTHORS
--- AUTHORS	15 Mar 2004 15:53:16 -0000	1.90
+++ AUTHORS	19 Mar 2004 17:19:04 -0000
@@ -235,6 +235,9 @@
 Autoconf & automake support, configuration & portability
 improvements, and general code gadfly a la Paul Smith.
 
+Chris Ross:
+Addition of ReliefThickness feature to FvwmIconMan.
+
 Paul D. Smith:
 Purify support (heap rot, array overwrites, memory stompage of all
 sorts). Some autoconf/automake/portability help.  Initial cut at a
Index: modules/ChangeLog
===================================================================
RCS file: /home/cvs/fvwm/fvwm/modules/ChangeLog,v
retrieving revision 1.1106
diff -u -u -r1.1106 ChangeLog
--- modules/ChangeLog	19 Mar 2004 09:50:18 -0000	1.1106
+++ modules/ChangeLog	19 Mar 2004 17:19:07 -0000
@@ -1,7 +1,15 @@
-2004-03-19  Dominik Vogt  <[email-masked]>
+2004-03-15  Chris Ross  <[email-masked]>
 
-	* FvwmIconMan/FvwmIconMan.c:
-	applied inverted relief patch by Chris Ross
+	* FvwmIconMan/FvwmIconMan.1:
+	* FvwmIconMan/FvwmIconMan.h:
+	* FvwmIconMan/globals.c (init_win_manager):
+	* FvwmIconMan/readconfig.c (read_in_resources):
+	* FvwmIconMan/xmanager.c (draw_3d_icon)
+	(draw_relief):
+	Added ReliefThickness option to FvwmIconMan to control
+	the width of the relief used for both icon manager buttons
+	and icons.  Works much the same as the Frame specification
+	of FvwmButtons.
 
 2004-03-15  Dominik Vogt  <[email-masked]>
 
Index: modules/FvwmIconMan/FvwmIconMan.1
===================================================================
RCS file: /home/cvs/fvwm/fvwm/modules/FvwmIconMan/FvwmIconMan.1,v
retrieving revision 1.28
diff -u -u -r1.28 FvwmIconMan.1
--- modules/FvwmIconMan/FvwmIconMan.1	19 Mar 2004 09:50:18 -0000	1.28
+++ modules/FvwmIconMan/FvwmIconMan.1	19 Mar 2004 17:19:07 -0000
@@ -252,11 +252,13 @@
 still only be applied with plainbutton.  See FvwmTheme.
 
 .IP "*FvwmIconMan: [id] ReliefThickness \fInum\fP"
-\fInum\fP is a positive integer specifying the number of pixels thick
-that the relief at the edge of non-flat buttons should be.  This has
-no effect on flat buttons.  In theory, you should be able to set this
-to a negative number and have it act like \fIReverse\fP, but negative
-numbers don't work.  This may change later.
+\fInum\fP is an integer specifying the number of pixels thick
+that the relief at the edge of non-flat buttons should be.  Setting
+this to 0 will produce flat buttons, as if the values for
+\fIFocusAndSelectButton\fP, \fIFocusButton\fP, \fIIconButton\fP,
+\fIPlainButton\fP, \fISelectButton\fP, and \fITitleButton\fP were
+all set to \fIflat\fP.  If \fInum\fP is negative, the button
+will be inverted as if you had used \fIReverse\fP for all classes.