It didn't make sense to me for Esetroot -scale -mirror to produce exactly the same image as Esetroot -scale. The attached patch (for yesterday's CVS) makes that combination produce a horizontally-flipped version of the image produced with -scale.

I also added a -Flip argument for vertical flipping, which can be used either with -mirror or independently.

The only troubles I see are that the -F flag, by itself, does nothing, and that there is no indication in the usage text as to the dual functionality of the -mirror flag. If anyone sees other problems, or easy ways to handle these, please do let me know.

Apologies if this isn't in proper form; this is the first time I've ever modified C code I hadn't written myself, and what do you know, it works! ^_^

--
      The Wanderer
--- eterm/Eterm//utils/Esetroot.c       2003-04-22 11:14:20.000000000 -0400
+++ eterm_devel/Eterm/utils/Esetroot.c  2003-07-17 00:23:18.000000000 -0400
@@ -94,7 +94,7 @@
 main(int argc, char *argv[])
 {
 #ifdef PIXMAP_SUPPORT
-    unsigned char scale = 0, center = 0, fit = 0, mirror = 0;
+    unsigned char scale = 0, center = 0, fit = 0, mirror = 0, Flip = 0;
     char *displayname = NULL, *fname = NULL, *bgcolor = NULL;
     Imlib_Image im;
     Pixmap p = None, temp_pmap = None, m = None;
@@ -105,8 +105,8 @@
     int w, h, x, y;
 
     if (argc < 2) {
-        fprintf(stderr, "%s [-display <display_name>] [-bgcolor <color>] [-scale] 
[-center] [-fit] [-mirror] pixmap\n", *argv);
-        fprintf(stderr, "\t Short options are also recognized (-d, -b, -s, -c, -f, 
and -m)\n");
+        fprintf(stderr, "%s [-display <display_name>] [-bgcolor <color>] [-scale] 
[-center] [-fit] [-mirror] [-Flip] pixmap\n", *argv);
+        fprintf(stderr, "\t Short options are also recognized (-d, -b, -s, -c, -f, 
-m, and -F)\n");
         exit(0);
     }
     for (i = 1; i < argc; i++) {
@@ -125,13 +125,15 @@
             fit = 1;
         } else if (argv[i][1] == 'm') {
             mirror = 1;
+        } else if (argv[i][1] == 'F') {
+            Flip = 1;
         } else if (argv[i][1] == 'x') {
             fprintf(stderr, "Debugging activated.\n");
             debug = 1;
         } else {
             fprintf(stderr, "%s:  Unrecognized option \'%c\'\n\n", *argv, argv[i][1]);
-            fprintf(stderr, "%s [-display <display_name>] [-bgcolor <color>] [-scale] 
[-center] [-fit] [-mirror] pixmap\n", *argv);
-            fprintf(stderr, "\t Short options are also recognized (-d, -b, -s, -c, 
-f, and -m)\n");
+            fprintf(stderr, "%s [-display <display_name>] [-bgcolor <color>] [-scale] 
[-center] [-fit] [-mirror] [-Flip] pixmap\n", *argv);
+            fprintf(stderr, "\t Short options are also recognized (-d, -b, -s, -c, 
-f, -m, and -F)\n");
             exit(2);
         }
     }
@@ -139,7 +141,6 @@
     fname = argv[i];
     if (scale) {
         center = 0;
-        mirror = 0;
     }
 
     if (debug) {
@@ -212,7 +213,19 @@
     }
     gc = XCreateGC(Xdisplay, p, (GCForeground | GCBackground), &gcv);
     if (scale) {
-        XFillRectangle(Xdisplay, p, gc, 0, 0, w, h);
+        if (mirror || Flip) {
+           imlib_context_set_drawable(p);
+           if (mirror) {
+               imlib_image_flip_horizontal();
+           }
+           if (Flip) {
+               imlib_image_flip_vertical();
+           }
+           imlib_render_image_on_drawable_at_size(0,0,w,h);
+    } else {
+       XFillRectangle(Xdisplay, p, gc, 0, 0, w, h);
+    }
+       mirror = 0;
     }
     if (center || fit) {
         XFillRectangle(Xdisplay, p, gc, 0, 0, scr->width, scr->height);

Reply via email to