summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKeith Packard <keithp@keithp.com>2010-10-21 17:51:35 -0700
committerKeith Packard <keithp@keithp.com>2010-10-21 17:51:35 -0700
commit8cf3ceab5cf2f2a583bdbe13a2f23061c6458546 (patch)
tree7a08bd9a26468639be95de6b50b0d520087022c9
parente5430a15a0eed9c209f0df1b19ac79eca195088e (diff)
Add -xcf flag to load arbitrary ARGB cursor file
Instead of having to construct a whole cursor theme and play with the environment variables in Xlib to set a random ARGB cursor, this lets the user set whatever they like directly from a file. Signed-off-by: Keith Packard <keithp@keithp.com>
-rw-r--r--configure.ac2
-rw-r--r--xsetroot.c27
2 files changed, 28 insertions, 1 deletions
diff --git a/configure.ac b/configure.ac
index f34c3d0..13ad662 100644
--- a/configure.ac
+++ b/configure.ac
@@ -39,7 +39,7 @@ AC_PROG_INSTALL
XORG_DEFAULT_OPTIONS
# Checks for pkg-config packages
-PKG_CHECK_MODULES(XSETROOT, xmuu x11 xbitmaps)
+PKG_CHECK_MODULES(XSETROOT, xmuu x11 xbitmaps xcursor)
AC_SUBST(XSETROOT_CFLAGS)
AC_SUBST(XSETROOT_LIBS)
diff --git a/xsetroot.c b/xsetroot.c
index 637f623..31233d9 100644
--- a/xsetroot.c
+++ b/xsetroot.c
@@ -36,6 +36,7 @@ in this Software without prior written authorization from The Open Group.
#include <X11/Xutil.h>
#include <X11/Xatom.h>
#include <X11/Xmu/CurUtil.h>
+#include <X11/Xcursor/Xcursor.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -79,6 +80,7 @@ usage(void)
fprintf(stderr, " -name <string>\n");
fprintf(stderr, " -cursor <cursor file> <mask file>\n");
fprintf(stderr, " -cursor_name <cursor-font name>\n");
+ fprintf(stderr, " -xcf <ARGB cursor file> <cursor size>\n");
fprintf(stderr, " -solid <color>\n");
fprintf(stderr, " -gray or -grey\n");
fprintf(stderr, " -bitmap <filename>\n");
@@ -100,6 +102,8 @@ main(int argc, char *argv[])
char *cursor_mask = NULL;
char *cursor_name = NULL;
char *solid_color = NULL;
+ char *xcf = NULL;
+ int xcf_size = 32;
Cursor cursor;
int gray = 0;
char *bitmap_file = NULL;
@@ -144,6 +148,16 @@ main(int argc, char *argv[])
nonexcl++;
continue;
}
+ if (!strcmp("-xcf", argv[i])) {
+ if (++i>=argc) usage();
+ xcf = argv[i];
+ if (++i>=argc) usage();
+ xcf_size = atoi(argv[i]);
+ if (xcf_size <= 0)
+ xcf_size = 32;
+ nonexcl++;
+ continue;
+ }
if (!strcmp("-fg",argv[i]) || !strcmp("-foreground",argv[i])) {
if (++i>=argc) usage();
fore_color = argv[i];
@@ -223,6 +237,19 @@ main(int argc, char *argv[])
XFreeCursor (dpy, cursor);
}
}
+ if (xcf) {
+ XcursorImages *images = XcursorFilenameLoadImages(xcf, xcf_size);
+ if (!images) {
+ fprintf(stderr, "Invalid cursor file \"%s\"\n", xcf);
+ } else {
+ cursor = XcursorImagesLoadCursor(dpy, images);
+ if (cursor)
+ {
+ XDefineCursor (dpy, root, cursor);
+ XFreeCursor (dpy, cursor);
+ }
+ }
+ }
/* Handle -gray and -grey options */
if (gray) {
bitmap = XCreateBitmapFromData(dpy, root, gray_bits,