Subject: Enhancement to FvwmIconMan

From: Chris Ross <[email-masked]>
Date: Wed, 11 Feb 2004 23:43:09 -0500

I know there's no good reason to stick this in beofre 2.6, but it's
a simple enough patch, can it be committed for inclusion after 2.6?

  I have an FvwmIconMan inside of FvwmButtons.  I was changing the
"Frame" definition for various buttons, and wanted to change the
relief width on the buttons in FvwmIconMan, and was suprised to find
there was no way to do that.  They're just 2.  Always 2.

  So, I fixed this.  They still default to two, but I added a
"ReliefThickness" keyword to FvwmIconMan.  You can set it to 0,
as another way to get flat buttons, or to a positive integer to
have the button-reliefs be that many pixels wide/thick.  I don't
know why you can't make it negative to get the equivalent of "Reverse"
buttons, but that doesn't work.  I don't think it's important to
fix, but I'd be happy for anyone else to fix it.

  Again, the default after this patch will be the same.  2 pixels.
But you can now change it.  (I've set mine to 1).

  Thanks.  Let me know when this can get checked in, and when
that change will hit a release.  Much appriciated.

                                - Chris

Index: 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
--- modules/FvwmIconMan/FvwmIconMan.1	19 Apr 2003 03:01:02 -0000	1.27
+++ modules/FvwmIconMan/FvwmIconMan.1	10 Feb 2004 18:39:38 -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: 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
--- modules/FvwmIconMan/FvwmIconMan.h	25 Aug 2003 06:47:09 -0000	1.55
+++ modules/FvwmIconMan/FvwmIconMan.h	10 Feb 2004 18:39:38 -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: 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
--- modules/FvwmIconMan/globals.c	29 Jun 2003 19:53:25 -0000	1.25
+++ modules/FvwmIconMan/globals.c	10 Feb 2004 18:39:38 -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: 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
--- modules/FvwmIconMan/readconfig.c	5 Jul 2003 01:37:47 -0000	1.55
+++ modules/FvwmIconMan/readconfig.c	10 Feb 2004 18:39:39 -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: 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
--- modules/FvwmIconMan/xmanager.c	25 Aug 2003 06:47:09 -0000	1.83
+++ modules/FvwmIconMan/xmanager.c	10 Feb 2004 18:39:39 -0000
@@ -1342,7 +1342,7 @@
     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);
 }

@@ -1543,13 +1543,16 @@
     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,
+		      man->relief_thickness);
     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,
+		      man->relief_thickness);
   }
   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,
+		      man->relief_thickness);
   }
 }

---

From: Chris Ross <[email-masked]>
Date: Mon, 16 Feb 2004 12:03:34 -0500

Hey there.  Any feedback on this?  Dominik: I see you're committing
things that aren't bug fixes, so that means you're accepting
new functionality for the post-2.6 work?  Any issue with checking
in this patch?

   Thanks...

                             - Chris

Chris Ross wrote:
> "ReliefThickness" keyword to FvwmIconMan.
--
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: Tue, 17 Feb 2004 10:19:05 +0100

> new functionality for the post-2.6 work?  Any issue with checking

The patch looks nice and simple, and I think I will apply it.  My
only concern is that it does not do any boundary checks.  It
should:

 - Check for negative and zero thickness.
 - Limit the thickness to what fits in a button (you do not want
   to allow relief thickness 25000 in a button that is 10 pixels
   high).

> >"ReliefThickness" keyword to FvwmIconMan.

Please post replies below the quoted portions original mail on
this list.

Ciao

Dominik ^_^  ^_^

---

From: Chris Ross <[email-masked]>
Date: Tue, 17 Feb 2004 11:44:30 -0500

Dominik Vogt wrote:
> only concern is that it does not do any boundary checks.

   Reasonable.  I can add some boundary-checking.

> It should:

   I didn't want to do this, because I thought that those were
reasonable.  Zero works, and behaves as you would expect.  It
makes the button "flat".  Do you want me to explicitly disallow
this method of making the button flat, so that it must be done
as a button style?

   As to negative, that doesn't work as expected, but I would've
expected that to act as "Reverse" causes, and if it worked should
be valid.  I also asked for any help in figuring out why that
doesn't work.  Do you want me to just ignore it, so that if you
want them sunken, you must Reverse either icon or normal?  This
prevents you from being able to reverse all states, correct?
What if someone wanted to do that?

>    to allow relief thickness 25000 in a button that is 10 pixels

   Right.  This is reasonable.  I'll take a look at how to do
this...

> Please post replies below the quoted portions original mail on

   Can do.  :-)  Thanks for the policy statement.

                           - Chris

---

From: Dominik Vogt <[email-masked]>
Date: Wed, 18 Feb 2004 09:55:15 +0100

> this method of making the button flat, so that it must be done

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

> What if someone wanted to do that?

RelieveRectangle() eventually calls do_relieve_rectangle() from
libs/Graphics.c.  This function does nothing for line_width <= 0.
It's easy to change by adding this piece of code at the beginning
of the function:

  if (line_width < 0)
  {
    GC tmpgc;

    line_width = -line_width;
    tmpgc = ReliefGC;
    ReliefGC = ShadowGC;
    ShadowGC = tmpgc;
  }

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

Ciao

Dominik ^_^  ^_^