[PATCH 1/5] Implement option -b to set default root fill color.

Forest Bond forest at alittletooquiet.net
Sun Jun 13 08:57:54 PDT 2010


A color name must be included to specify the background fill color to
use if no root window background pixmap property is set.  For
example, "-b black" sets the fill color to black.

The previous hard-coded fill color (a gray) is used if this option is
not specified.

Signed-off-by: Forest Bond <forest at alittletooquiet.net>
---
 xcompmgr.c |   39 +++++++++++++++++++++++++++++++++------
 1 files changed, 33 insertions(+), 6 deletions(-)

diff --git a/xcompmgr.c b/xcompmgr.c
index 3a01cce..dc5b225 100644
--- a/xcompmgr.c
+++ b/xcompmgr.c
@@ -120,6 +120,7 @@ static Bool		clipChanged;
 #if HAS_NAME_WINDOW_PIXMAP
 static Bool		hasNamePixmap;
 #endif
+static XRenderColor	fill_color;
 static int		root_height, root_width;
 static ignore		*ignore_head, **ignore_tail = &ignore_head;
 static int		xfixes_event, xfixes_error;
@@ -801,11 +802,7 @@ root_tile (Display *dpy)
 				    CPRepeat, &pa);
     if (fill)
     {
-	XRenderColor    c;
-	
-	c.red = c.green = c.blue = 0x8080;
-	c.alpha = 0xffff;
-	XRenderFillRectangle (dpy, PictOpSrc, picture, &c, 
+	XRenderFillRectangle (dpy, PictOpSrc, picture, &fill_color,
 			      0, 0, 1, 1);
     }
     return picture;
@@ -1863,6 +1860,7 @@ usage (char *program)
     fprintf (stderr, "   -o opacity\n      Specifies the translucency for client-side shadows. (default .75)\n");
     fprintf (stderr, "   -l left-offset\n      Specifies the left offset for client-side shadows. (default -15)\n");
     fprintf (stderr, "   -t top-offset\n      Specifies the top offset for clinet-side shadows. (default -15)\n");
+    fprintf (stderr, "   -b color\n      Specifies the background color to use if no root pixmap is set. (default is a gray)\n");
     fprintf (stderr, "   -I fade-in-step\n      Specifies the opacity change between steps while fading in. (default 0.028)\n");
     fprintf (stderr, "   -O fade-out-step\n      Specifies the opacity change between steps while fading out. (default 0.03)\n");
     fprintf (stderr, "   -D fade-delta-time\n      Specifies the time between steps in a fade in milliseconds. (default 10)\n");
@@ -1945,8 +1943,9 @@ main (int argc, char **argv)
     int		    composite_major, composite_minor;
     char	    *display = NULL;
     int		    o;
+    char	    *fill_color_name = NULL;
 
-    while ((o = getopt (argc, argv, "D:I:O:d:r:o:l:t:scnfFCaS")) != -1)
+    while ((o = getopt (argc, argv, "D:I:O:d:r:o:l:t:b:scnfFCaS")) != -1)
     {
 	switch (o) {
 	case 'd':
@@ -2003,6 +2002,9 @@ main (int argc, char **argv)
 	case 't':
 	    shadowOffsetY = atoi (optarg);
 	    break;
+	case 'b':
+	    fill_color_name = optarg;
+	    break;
 	default:
 	    usage (argv[0]);
 	    break;
@@ -2074,6 +2076,31 @@ main (int argc, char **argv)
 	presum_gaussian (gaussianMap);
     }
 
+    if (fill_color_name)
+    {
+	XColor c;
+	if (! XParseColor (dpy, DefaultColormap (dpy, scr),
+			   fill_color_name, &c))
+	{
+	    fprintf (stderr, "Could not parse fill color.\n");
+	    exit (1);
+	}
+	if (! XAllocColor (dpy, DefaultColormap (dpy, scr), &c))
+	{
+	    fprintf (stderr, "Could not allocate color.\n");
+	    exit (1);
+	}
+
+	fill_color.red = c.red;
+	fill_color.green = c.green;
+	fill_color.blue = c.blue;
+    }
+    else
+    {
+	fill_color.red = fill_color.green = fill_color.blue = 0x8080;
+    }
+    fill_color.alpha = 0xffff;
+
     root_width = DisplayWidth (dpy, scr);
     root_height = DisplayHeight (dpy, scr);
 
-- 
1.7.0.4
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
URL: <http://lists.x.org/archives/xorg-devel/attachments/20100613/a492467d/attachment.pgp>


More information about the xorg-devel mailing list