The mvwm repository's master branch has been updated.

The following shows the diffstat and patchsets between the merged result
and HEAD.

commit 4c9108edd61157e8e11355c2e48ca80495f1bb0a
Author: Dominik Vogt <[email protected]>
Date:   Thu Sep 11 22:09:46 2014 +0100

    Re-add bin/mvwm-root
---
 Makefile.am        |   6 +-
 bin/Makefile.am    |  11 ++
 bin/mvwm-root.1.in | 110 +++++++++++++++++
 bin/mvwm-root.c    | 346 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 configure.ac       |   2 +
 5 files changed, 472 insertions(+), 3 deletions(-)

diff --git a/Makefile.am b/Makefile.am
index cf1fe1e..f65e7de 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -6,13 +6,13 @@ AUTOMAKE_OPTIONS = 1.4
 
 SUBDIRS = \
        libs \
+       bin \
        mvwm \
        modules \
        $(MVWM_PERLLIB) \
        ## TA:  Ignore things in bin/ for now.
-       #bin \
-       doc \
-       $(POSUB)
+       #doc \
+       #$(POSUB)
 
 ## ---------------------------------------------------------------------------
 ## Manage bzip2 archive together with gzip archive
diff --git a/bin/Makefile.am b/bin/Makefile.am
new file mode 100644
index 0000000..218e7c7
--- /dev/null
+++ b/bin/Makefile.am
@@ -0,0 +1,11 @@
+## Process this file with automake to create Makefile.in
+
+bin_PROGRAMS = mvwm-root
+
+mvwm_root_SOURCE= mvwm-root.c
+mvwm_root_DEPENDENCIES = $(top_builddir)/libs/libmvwm.a
+
+LDADD = -L$(top_builddir)/libs $(X_LIBS) -lmvwm $(Xcursor_LIBS) \
+       $(X_PRE_LIBS) -lXext -lX11 -lm $(X_EXTRA_LIBS) $(Xrender_LIBS) \
+       $(Xcursor_LIBS) $(png_LIBS)
+AM_CPPFLAGS = -I$(top_srcdir) $(X_CFLAGS) $(png_CFLAGS)
diff --git a/bin/mvwm-root.1.in b/bin/mvwm-root.1.in
new file mode 100644
index 0000000..9540bfc
--- /dev/null
+++ b/bin/mvwm-root.1.in
@@ -0,0 +1,110 @@
+'\" t
+.\" @(#)@PACKAGE@-@VERSION@ @RELDATELONG@
+.TH fvwm-root 1 "@RELDATELONG@ (@VERSION@)" Fvwm "Fvwm Modules"
+.UC
+
+.SH NAME
+fvwm-root \- Sets the root window of the current X display to image
+
+.SH SYNOPSIS
+.B fvwm-root
+.RB [ "--retain-pixmap" | "-r" ]
+.RB [ "--no-retain-pixmap" ]
+.RB [ "--dummy" | "-d" ]
+.RB [ "--no-dummy" ]
+.RB [ "--dither" ]
+.RB [ "--no-dither" ]
+.RB [ "--color-limit"
+.RI       [ ncolors "] ]"
+.RB [ "--no-color-limit" ]
+.RB [ "--help" | "-h" | "-?" ]
+.RB [ "--version" | "-V" ]
+.I image_file
+
+.SH DESCRIPTION
+.I fvwm-root
+reads the image file specified in the command line and displays it in the
+root window.  The supported image formats are
+.IR " PNG "
+if appropriated libraries are compiled in.
+
+SVG rendering options
+.RB " (as described in the " " ICONS AND IMAGES "
+section of the main fvwm documentation) can be utilized.
+
+.SH OPTIONS
+These command line options are recognized by fvwm-root:
+.TP
+.BR "--retain-pixmap" " | " "-r"
+Causes fvwm-root to retain and publish the Pixmap with which the background
+has been set (the ESETROOT_PMAP_ID and _XROOTPMAP_ID properties are used).
+This is useful for applications which want to use the root
+Pixmap on the background to simulate transparency (for example,
+Eterm and Aterm use this method). This option should also be used for the
+RootTransparent colorset option, refer to the COLORSETS section of fvwm(1).
+If this option is not used, fvwm-root sets the _XSETROOT_ID property to
+None, and some programs, like fvwm modules, may use this to update their
+background if the background is transparent (Transparent colorset).
+
+Note, a well behaved program, like fvwm, should listen to both _XSETROOT_ID
+and _XROOTPMAP_ID property changes and update itself correspondingly.
+However some programs listen only to one of them, so you should either use
+this option or not depending on what part is implemented by these programs.
+You should also use this option to get fast root-transparent menus in fvwm.
+.TP
+.BI "--no-retain-pixmap"
+This is a default. May be useful to explicitly force the default even
+if "--retain-pixmap" is specified earlier.
+.TP
+.BR "--dummy" " | " "-d"
+Causes fvwm-root NOT to set the background, but to only free a memory
+associated with the ESETROOT_PMAP_ID property (if any).
+In any case the _XSETROOT_ID property is set to None.
+.TP
+.BI "--no-dummy"
+This is a default. May be useful to explicitly force the default even
+if "--dummy" is specified earlier.
+.TP
+.BI "--dither"
+Causes fvwm-root to dither images for "smoother" rendition on displays
+with color depth of 16 or lower. This the defaut with color depth  less
+or equal to 8.
+.TP
+.BI "--no-dither"
+Causes fvwm-root NOT to dither images. This is the default with color depth
+greater than 8.
+.TP
+.BI "--color-limit " ncolors
+Causes fvwm-root to limit its color use to
+.I ncolors
+(if specified). This option is taken in account only with color depth  less
+or equal to 8 (and a TrueColor or GrayScale visual). The default is
+to use the same color limit as fvwm. So in normal situation this option
+is not useful. However, if fvwm use a private colors map, as fvwm-root
+always use the default colors map you should use this option for
+limiting colors correctly. If
+.I ncolors
+is not specified a default is used.
+.TP
+.BI "--no-color-limit"
+Causes fvwm-root NOT to limit its color use.
+.TP
+.BI "--help"
+Shows a short usage.
+.TP
+.BI "--version"
+Shows a version number.
+
+.SH COMPATIBILITY
+In the past this utility was called
+.IR xpmroot .
+This name is still supported as a symlink.
+
+.SH BUGS
+Repeated use of fvwm-root with different xpm pixmaps will use up slots in
+your color table pretty darn fast.
+
+.SH AUTHOR
+Rob Nation
+
+Rewritten and enhanced by fvwm-workers.
diff --git a/bin/mvwm-root.c b/bin/mvwm-root.c
new file mode 100644
index 0000000..c3cb2b4
--- /dev/null
+++ b/bin/mvwm-root.c
@@ -0,0 +1,346 @@
+/* -*-c-*- */
+/*
+ * This is an all new program to set the root window to an Xpm pixmap.
+ * Copyright 1993, Rob Nation
+ * You may use this file for anything you want, as long as the copyright
+ * is kept intact. No guarantees of any sort are made in any way regarding
+ * this program or anything related to it.
+ */
+
+#include "config.h"
+
+#include <stdio.h>
+#include <signal.h>
+#include <X11/Xos.h>
+#include <X11/Xatom.h>
+#include "libs/mvwmlib.h"
+#include "libs/Picture.h"
+#include "libs/Graphics.h"
+
+int save_colors = 0;
+Display *dpy;
+int screen;
+Window root;
+char *display_name = NULL;
+Pixmap rootImage = None;
+Bool NoDither = False;
+Bool Dither = False;
+Bool NoColorLimit = False;
+int opt_color_limit = -1;
+Bool use_our_color_limit = False;
+
+void usage(int verbose)
+{
+       FILE *output = verbose ? stdout : stderr;
+       fprintf(
+               output, "mvwm-root version %s with support for: XBM"
+#ifdef HAVE_PNG
+               ", PNG"
+#endif
+               "\n", VERSION);
+       fprintf(output,
+               "\nUsage: mvwm-root [ options ] file\n");
+       if (verbose)
+       {
+               fprintf(output,
+                       "Options:\n"
+                       "\t--dither\n"
+                       "\t--no-dither\n"
+                       "\t--retain-pixmap\n"
+                       "\t--no-retain-pixmap\n"
+                       "\t--color-limit l\n"
+                       "\t--no-color-limit\n"
+                       "\t--dummy\n"
+                       "\t--no-dummy\n"
+                       "\t--help\n"
+                       "\t--version\n");
+       }
+}
+
+int SetRootWindow(char *tline)
+{
+       Pixmap shapeMask = None, temp_pix = None, alpha = None;
+       int w, h;
+       int depth;
+       int nalloc_pixels = 0;
+       Pixel *alloc_pixels = NULL;
+       char *file_path;
+       MvwmPictureAttributes fpa;
+
+       if (use_our_color_limit)
+       {
+               PictureColorLimitOption colorLimitop = {-1, -1, -1, -1, -1};
+               colorLimitop.color_limit = opt_color_limit;
+               PictureInitCMapRoot(
+                       dpy, !NoColorLimit, &colorLimitop, True, True);
+       }
+       else
+       {
+               /* this use the default visual (not the mvwm one) as
+                * getenv("MVWM_VISUALID") is NULL in any case. But this use
+                * the same color limit than mvwm.
+                * This is "broken" when mvwm use depth <= 8 and a private
+                * color map (i.e., mvwm is started with the -visual{ID}
+                * option), because when mvwm use a private color map the
+                * default color limit is 244. There is no way to know here if
+                * getenv("MVWM_VISUALID") !=NULL.
+                * So, in this unfortunate case the user should use the
+                * --color-limit option */
+               PictureInitCMap(dpy);
+       }
+       /* try built-in image path first, but not before pwd */
+       PictureSetImagePath(".:+");
+       file_path = PictureFindImageFile(tline, NULL, R_OK);
+
+       if (file_path == NULL)
+       {
+               file_path = tline;
+       }
+       fpa.mask = FPAM_NO_ALLOC_PIXELS | FPAM_NO_ALPHA;
+       if (Pdepth <= 8 && !NoDither)
+       {
+               fpa.mask |= FPAM_DITHER;
+       }
+       else if (Pdepth <= 16 && Dither)
+       {
+               fpa.mask |= FPAM_DITHER;
+       }
+       if (NoColorLimit)
+       {
+               fpa.mask |= FPAM_NO_COLOR_LIMIT;
+       }
+       if (!PImageLoadPixmapFromFile(
+               dpy, root, file_path, &temp_pix, &shapeMask, &alpha,
+               &w, &h, &depth, &nalloc_pixels, &alloc_pixels, 0, fpa))
+       {
+               fprintf(
+                       stderr, "[mvwm-root] failed to load image file '%s'\n",
+                       tline);
+               return -1;
+       }
+       if (depth == Pdepth)
+       {
+               rootImage = temp_pix;
+       }
+       else
+       {
+               XGCValues gcv;
+               GC gc;
+
+               gcv.background= WhitePixel(dpy, screen);
+               gcv.foreground= BlackPixel(dpy, screen);
+               gc = mvwmlib_XCreateGC(
+                       dpy, root, GCForeground | GCBackground, &gcv);
+               rootImage = XCreatePixmap(dpy, root, w, h, Pdepth);
+               XCopyPlane(dpy, temp_pix, rootImage, gc, 0, 0, w, h, 0, 0, 1);
+               XFreePixmap(dpy, temp_pix);
+               XFreeGC(dpy, gc);
+       }
+       XSetWindowBackgroundPixmap(dpy, root, rootImage);
+       save_colors = 1;
+       XClearWindow(dpy, root);
+
+       return 0;
+}
+
+int main(int argc, char **argv)
+{
+       Atom prop = None;
+       Atom e_prop = None;
+       Atom m_prop = None;
+       Atom type;
+       int format;
+       unsigned long length, after;
+       unsigned char *data;
+       int i = 1;
+       Bool e_killed = False;
+       Bool Dummy = False;
+       Bool RetainPixmap = False;
+
+       if (argc < 2)
+       {
+               usage(0);
+               fprintf(stderr, "Nothing to do, try again.\n");
+               exit(1);
+       }
+       dpy = XOpenDisplay(display_name);
+       if (!dpy)
+       {
+               fprintf(
+                       stderr, "mvwm-root: unable to open display '%s'\n",
+                       XDisplayName (display_name));
+               exit(2);
+       }
+       screen = DefaultScreen(dpy);
+       root = RootWindow(dpy, screen);
+
+       for (i = 1; i < argc - 1; i++)
+       {
+               if (
+                       strcasecmp(argv[i], "-r") == 0 ||
+                       strcasecmp(argv[i], "--retain-pixmap") == 0)
+               {
+                       RetainPixmap = True;
+               }
+               else if (
+                       strcasecmp(argv[i], "--no-retain-pixmap") == 0)
+               {
+                       RetainPixmap = False;
+               }
+               else if (
+                       strcasecmp(argv[i], "-d") == 0 ||
+                       strcasecmp(argv[i], "--dummy") == 0)
+               {
+                       Dummy = True;
+               }
+               else if (
+                       strcasecmp(argv[i], "--no-dummy") == 0)
+               {
+                       Dummy = False;
+               }
+               else if (
+                       strcasecmp(argv[i], "--dither") == 0)
+               {
+                       Dither = True;
+               }
+               else if (
+                       strcasecmp(argv[i], "--no-dither") == 0)
+               {
+                       NoDither = True;
+               }
+               else if (
+                       strcasecmp(argv[i], "--color-limit") == 0)
+               {
+                       use_our_color_limit = True;
+                       if (i+1 < argc)
+                       {
+                               i++;
+                               opt_color_limit = atoi(argv[i]);
+                       }
+               }
+               else if (
+                       strcasecmp(argv[i], "--no-color-limit") == 0)
+               {
+                       NoColorLimit = True;
+               }
+               else if (
+                       strcasecmp(argv[i], "-h") == 0 ||
+                       strcasecmp(argv[i], "-?") == 0 ||
+                       strcasecmp(argv[i], "--help") == 0)
+               {
+                       usage(1);
+                       exit(0);
+               }
+               else if (
+                       strcasecmp(argv[i], "-V") == 0 ||
+                       strcasecmp(argv[i], "--version") == 0)
+               {
+                       fprintf(stdout, "%s\n", VERSION);
+                       exit(0);
+               }
+               else
+               {
+                       fprintf(
+                               stderr, "mvwm-root: unknown option '%s'\n",
+                               argv[i]);
+                       fprintf(
+                               stderr, "Run '%s --help' to get the usage.\n",
+                               argv[0]);
+                       exit(1);
+               }
+       }
+
+       if (
+               Dummy ||
+               strcasecmp(argv[argc-1], "-d") == 0 ||
+               strcasecmp(argv[argc-1], "--dummy") == 0)
+       {
+               Dummy = True;
+       }
+       else if (
+               strcasecmp(argv[argc-1], "-h") == 0 ||
+               strcasecmp(argv[argc-1], "-?") == 0 ||
+               strcasecmp(argv[argc-1], "--help") == 0)
+       {
+               usage(1);
+               exit(0);
+       }
+       else if (
+               strcasecmp(argv[argc-1], "-V") == 0 ||
+               strcasecmp(argv[argc-1], "--version") == 0)
+       {
+               fprintf(stdout, "%s\n", VERSION);
+               exit(0);
+       }
+       else
+       {
+               int rc;
+
+               rc = SetRootWindow(argv[argc-1]);
+               if (rc == -1)
+               {
+                       exit(1);
+               }
+       }
+
+       prop = XInternAtom(dpy, "_XSETROOT_ID", False);
+       (void)XGetWindowProperty(
+               dpy, root, prop, 0L, 1L, True, AnyPropertyType,
+               &type, &format, &length, &after, &data);
+       if (type == XA_PIXMAP && format == 32 && length == 1 && after == 0 &&
+           data != NULL && (Pixmap)(*(long *)data) != None)
+       {
+               XKillClient(dpy, *((Pixmap *)data));
+       }
+
+       if (data != NULL)
+               XFree(data);
+       e_prop = XInternAtom(dpy, "ESETROOT_PMAP_ID", False);
+       (void)XGetWindowProperty(
+               dpy, root, e_prop, 0L, 1L, True, AnyPropertyType,
+               &type, &format, &length, &after, &data);
+       if (type == XA_PIXMAP && format == 32 && length == 1 && after == 0 &&
+           data != NULL && (Pixmap)(*(long *)data) != None)
+       {
+               e_killed = True;
+               XKillClient(dpy, *((Pixmap *)data));
+       }
+       if (e_killed && !Dummy)
+       {
+               m_prop = XInternAtom(dpy, "_XROOTPMAP_ID", False);
+               XDeleteProperty(dpy, root, m_prop);
+       }
+
+       if (RetainPixmap && !Dummy)
+       {
+               long prop;
+
+               prop = rootImage;
+               if (data != NULL)
+                       XFree(data);
+               XSetCloseDownMode(dpy, RetainPermanent);
+               if (e_prop == None)
+                       e_prop = XInternAtom(dpy, "ESETROOT_PMAP_ID", False);
+               if (m_prop == None)
+                       m_prop = XInternAtom(dpy, "_XROOTPMAP_ID", False);
+               XChangeProperty(
+                       dpy, root, e_prop, XA_PIXMAP, 32, PropModeReplace,
+                       (unsigned char *) &prop, 1);
+               XChangeProperty(
+                       dpy, root, m_prop, XA_PIXMAP, 32, PropModeReplace,
+                       (unsigned char *) &prop, 1);
+       }
+       else
+       {
+               long dp = (long)None;
+
+               if (prop == None)
+                       prop = XInternAtom(dpy, "_XSETROOT_ID", False);
+               XChangeProperty(
+                       dpy, root, prop, XA_PIXMAP, 32, PropModeReplace,
+                       (unsigned char *)  &dp, 1);
+       }
+       XCloseDisplay(dpy);
+
+       return 0;
+}
diff --git a/configure.ac b/configure.ac
index aabf08a..105f92e 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1192,6 +1192,8 @@ AC_OUTPUT(
        Makefile
        libs/Makefile
        mvwm/Makefile
+       bin/Makefile
+       bin/mvwm-root.1
        modules/Makefile
        modules/MvwmAuto/MvwmAuto.1
        modules/MvwmBacker/MvwmBacker.1


Reply via email to