summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander Gottwald <alexander.gottwald@s1999.tu-chemnitz.de>2004-03-17 20:28:52 +0000
committerAlexander Gottwald <alexander.gottwald@s1999.tu-chemnitz.de>2004-03-17 20:28:52 +0000
commit24b087709323ddb4acc49355387c06da337151e0 (patch)
treeceabbb953226f775a7347183bcf763ca6fb11b37
parent2f241334d765ff17777a756afc81e8da6a9f1ff2 (diff)
-rw-r--r--include/X11/Xcursor/Xcursor.h35
-rw-r--r--man/Xcursor.man11
-rw-r--r--src/cursor.c14
-rw-r--r--src/display.c4
-rw-r--r--src/file.c22
-rw-r--r--src/library.c28
-rw-r--r--src/xcursorint.h14
-rw-r--r--src/xlib.c4
8 files changed, 95 insertions, 37 deletions
diff --git a/include/X11/Xcursor/Xcursor.h b/include/X11/Xcursor/Xcursor.h
index 3176020..5a6b74c 100644
--- a/include/X11/Xcursor/Xcursor.h
+++ b/include/X11/Xcursor/Xcursor.h
@@ -1,7 +1,7 @@
/*
- * $XFree86: xc/lib/Xcursor/Xcursor.h,v 1.4 2003/01/26 03:22:42 eich Exp $
+ * $Id$
*
- * Copyright © 2002 Keith Packard, member of The XFree86 Project, Inc.
+ * Copyright © 2002 Keith Packard
*
* Permission to use, copy, modify, distribute, and sell this software and its
* documentation for any purpose is hereby granted without fee, provided that
@@ -69,9 +69,26 @@ typedef XcursorUInt XcursorPixel;
#define XCURSOR_MAGIC 0x72756358 /* "Xcur" LSBFirst */
-#define XCURSOR_MAJOR 1
-#define XCURSOR_MINOR 0
-#define XCURSOR_VERSION ((XCURSOR_MAJOR << 16) | (XCURSOR_MINOR))
+/*
+ * Current Xcursor version number. This same number
+ * must appear in the Xcursor configure.ac file. Yes,
+ * it'a a pain to synchronize version numbers like this.
+ */
+
+#define XCURSOR_LIB_MAJOR 1
+#define XCURSOR_LIB_MINOR 1
+#define XCURSOR_LIB_REVISION 2
+#define XCURSOR_LIB_VERSION ((XCURSOR_LIB_MAJOR * 10000) + \
+ (XCURSOR_LIB_MINOR * 100) + \
+ (XCURSOR_LIB_REVISION))
+
+/*
+ * This version number is stored in cursor files; changes to the
+ * file format require updating this version number
+ */
+#define XCURSOR_FILE_MAJOR 1
+#define XCURSOR_FILE_MINOR 0
+#define XCURSOR_FILE_VERSION ((XCURSOR_FILE_MAJOR << 16) | (XCURSOR_FILE_MINOR))
#define XCURSOR_FILE_HEADER_LEN (4 * 4)
#define XCURSOR_FILE_TOC_LEN (3 * 4)
@@ -180,6 +197,7 @@ typedef struct _XcursorImage {
typedef struct _XcursorImages {
int nimage; /* number of images */
XcursorImage **images; /* array of XcursorImage pointers */
+ char *name; /* name used to load images */
} XcursorImages;
typedef struct _XcursorCursors {
@@ -230,6 +248,9 @@ XcursorImagesCreate (int size);
void
XcursorImagesDestroy (XcursorImages *images);
+void
+XcursorImagesSetName (XcursorImages *images, const char *name);
+
/*
* Manage Cursor objects
*/
@@ -350,6 +371,10 @@ XcursorLibraryLoadImages (const char *library, const char *theme, int size);
/*
* Library/shape API
*/
+
+const char *
+XcursorLibraryPath (void);
+
int
XcursorLibraryShape (const char *library);
diff --git a/man/Xcursor.man b/man/Xcursor.man
index 3596c6a..1f9a62a 100644
--- a/man/Xcursor.man
+++ b/man/Xcursor.man
@@ -1,7 +1,8 @@
.\"
-.\" $XFree86: xc/lib/Xcursor/Xcursor.man,v 1.4 2003/06/12 14:12:27 eich Exp $
+.\" $Id$
+.\"
+.\" Copyright © 2002 Keith Packard
.\"
-.\" Copyright 2002 Keith Packard, member of The XFree86 Project, Inc..\"
.\" Permission to use, copy, modify, distribute, and sell this software and its
.\" documentation for any purpose is hereby granted without fee, provided that
.\" the above copyright notice appear in all copies and that both that
@@ -25,7 +26,7 @@
.ns
.TP \\$1
..
-.TH XCURSOR 3 "Version 1.0" "XFree86"
+.TH XCURSOR 3 "Version 1.0" "Keith Packard"
.SH NAME
XCURSOR \- Cursor management library
@@ -140,7 +141,7 @@ Images look like:
Xcursor (mostly) follows the freedesktop.org spec for theming icons. The
default search path it uses is $HOME/.icons, /usr/share/icons,
/usr/share/pimaps, /usr/X11R6/lib/X11/icons. Within each of these
-directories, it searches for a directory using the theme name. Within the
+directorys, it searches for a directory using the theme name. Within the
theme directory, it looks for cursor files in the 'cursors' subdirectory.
It uses the first cursor file found along the path.
.PP
@@ -375,4 +376,4 @@ will probably change radically in the future; weak attempts will be made to
retain some level of source-file compatibility.
.SH AUTHOR
-Keith Packard, member of the XFree86 Project, Inc.
+Keith Packard
diff --git a/src/cursor.c b/src/cursor.c
index 9b14ce2..237d464 100644
--- a/src/cursor.c
+++ b/src/cursor.c
@@ -1,7 +1,7 @@
/*
- * $XFree86: xc/lib/Xcursor/cursor.c,v 1.5 2003/01/26 03:22:42 eich Exp $
+ * $Id$
*
- * Copyright © 2002 Keith Packard, member of The XFree86 Project, Inc.
+ * Copyright © 2002 Keith Packard
*
* Permission to use, copy, modify, distribute, and sell this software and its
* documentation for any purpose is hereby granted without fee, provided that
@@ -689,14 +689,14 @@ XcursorImagesLoadCursors (Display *dpy, const XcursorImages *images)
Cursor
XcursorImagesLoadCursor (Display *dpy, const XcursorImages *images)
{
+ Cursor cursor;
if (images->nimage == 1 || !XcursorSupportsAnim (dpy))
- return XcursorImageLoadCursor (dpy, images->images[0]);
+ cursor = XcursorImageLoadCursor (dpy, images->images[0]);
else
{
XcursorCursors *cursors = XcursorImagesLoadCursors (dpy, images);
XAnimCursor *anim;
int n;
- Cursor cursor;
if (!cursors)
return 0;
@@ -713,8 +713,12 @@ XcursorImagesLoadCursor (Display *dpy, const XcursorImages *images)
}
cursor = XRenderCreateAnimCursor (dpy, cursors->ncursor, anim);
free (anim);
- return cursor;
}
+#if defined HAVE_XFIXES && XFIXES_MAJOR >= 2
+ if (images->name)
+ XFixesSetCursorName (dpy, cursor, images->name);
+#endif
+ return cursor;
}
diff --git a/src/display.c b/src/display.c
index 1f41a57..0540d63 100644
--- a/src/display.c
+++ b/src/display.c
@@ -1,7 +1,7 @@
/*
- * $XFree86: xc/lib/Xcursor/display.c,v 1.6 2003/02/20 03:13:50 dawes Exp $
+ * $Id$
*
- * Copyright © 2002 Keith Packard, member of The XFree86 Project, Inc.
+ * Copyright © 2002 Keith Packard
*
* Permission to use, copy, modify, distribute, and sell this software and its
* documentation for any purpose is hereby granted without fee, provided that
diff --git a/src/file.c b/src/file.c
index 813ac28..0f1b212 100644
--- a/src/file.c
+++ b/src/file.c
@@ -1,7 +1,7 @@
/*
- * $XFree86: xc/lib/Xcursor/file.c,v 1.2 2002/09/18 17:11:42 tsi Exp $
+ * $Id$
*
- * Copyright © 2002 Keith Packard, member of The XFree86 Project, Inc.
+ * Copyright © 2002 Keith Packard
*
* Permission to use, copy, modify, distribute, and sell this software and its
* documentation for any purpose is hereby granted without fee, provided that
@@ -61,6 +61,7 @@ XcursorImagesCreate (int size)
return 0;
images->nimage = 0;
images->images = (XcursorImage **) (images + 1);
+ images->name = 0;
return images;
}
@@ -71,9 +72,24 @@ XcursorImagesDestroy (XcursorImages *images)
for (n = 0; n < images->nimage; n++)
XcursorImageDestroy (images->images[n]);
+ if (images->name)
+ free (images->name);
free (images);
}
+void
+XcursorImagesSetName (XcursorImages *images, const char *name)
+{
+ char *new = malloc (strlen (name) + 1);
+
+ if (!new)
+ return;
+ strcpy (new, name);
+ if (images->name)
+ free (images->name);
+ images->name = new;
+}
+
XcursorComment *
XcursorCommentCreate (XcursorUInt comment_type, int length)
{
@@ -185,7 +201,7 @@ _XcursorFileHeaderCreate (int ntoc)
return 0;
fileHeader->magic = XCURSOR_MAGIC;
fileHeader->header = XCURSOR_FILE_HEADER_LEN;
- fileHeader->version = XCURSOR_VERSION;
+ fileHeader->version = XCURSOR_FILE_VERSION;
fileHeader->ntoc = ntoc;
fileHeader->tocs = (XcursorFileToc *) (fileHeader + 1);
return fileHeader;
diff --git a/src/library.c b/src/library.c
index b359c45..99af99e 100644
--- a/src/library.c
+++ b/src/library.c
@@ -1,7 +1,7 @@
/*
- * $XFree86: xc/lib/Xcursor/library.c,v 1.4 2003/11/11 01:17:54 dawes Exp $
+ * $Id$
*
- * Copyright © 2002 Keith Packard, member of The XFree86 Project, Inc.
+ * Copyright © 2002 Keith Packard
*
* Permission to use, copy, modify, distribute, and sell this software and its
* documentation for any purpose is hereby granted without fee, provided that
@@ -32,8 +32,8 @@
#define CURSORPATH "~/.icons:/usr/share/icons:/usr/share/pixmaps:"ICONDIR
-static const char *
-_XcursorLibraryPath (void)
+const char *
+XcursorLibraryPath (void)
{
static const char *path;
@@ -101,19 +101,16 @@ _XcursorBuildThemeDir (const char *dir, const char *theme)
if (!home)
return 0;
homelen = strlen (home);
- /* A '/' gets prepended if $HOME doesn't start with one. */
- if (home[0] != '/')
- homelen++;
dir++;
dirlen--;
}
- len = homelen + dirlen + 1 + themelen + 1;
+ /*
+ * add space for any needed directory separators, one per component,
+ * and one for the trailing null
+ */
+ len = 1 + homelen + 1 + dirlen + 1 + themelen + 1;
- /* A '/' gets inserted if dir doesn't start with one. */
- if (dir[0] != '/')
- len++;
-
full = malloc (len);
if (!full)
return 0;
@@ -222,7 +219,7 @@ XcursorScanTheme (const char *theme, const char *name)
/*
* Scan this theme
*/
- for (path = _XcursorLibraryPath ();
+ for (path = XcursorLibraryPath ();
path && f == 0;
path = _XcursorNextPath (path))
{
@@ -292,6 +289,8 @@ XcursorLibraryLoadImages (const char *file, const char *theme, int size)
if (f)
{
images = XcursorFileLoadImages (f, size);
+ if (images)
+ XcursorImagesSetName (images, file);
fclose (f);
}
return images;
@@ -316,6 +315,9 @@ XcursorLibraryLoadCursor (Display *dpy, const char *file)
}
cursor = XcursorImagesLoadCursor (dpy, images);
XcursorImagesDestroy (images);
+#if defined HAVE_XFIXES && XFIXES_MAJOR >= 2
+ XFixesSetCursorName (dpy, cursor, file);
+#endif
return cursor;
}
diff --git a/src/xcursorint.h b/src/xcursorint.h
index 5d4a2f2..090c20e 100644
--- a/src/xcursorint.h
+++ b/src/xcursorint.h
@@ -1,7 +1,7 @@
/*
- * $XFree86: xc/lib/Xcursor/xcursorint.h,v 1.4 2003/01/26 03:22:42 eich Exp $
+ * $Id$
*
- * Copyright © 2002 Keith Packard, member of The XFree86 Project, Inc.
+ * Copyright © 2002 Keith Packard
*
* Permission to use, copy, modify, distribute, and sell this software and its
* documentation for any purpose is hereby granted without fee, provided that
@@ -25,10 +25,20 @@
#ifndef _XCURSORINT_H_
#define _XCURSORINT_H_
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
#include <X11/Xlib.h>
#include <X11/cursorfont.h>
#include <X11/extensions/Xrender.h>
+
+#ifdef HAVE_XFIXES
+#include <X11/extensions/Xfixes.h>
+#endif
+
#include "Xcursor.h"
+#include "config.h"
typedef struct _XcursorFontInfo {
struct _XcursorFontInfo *next;
diff --git a/src/xlib.c b/src/xlib.c
index 13e2433..716bd55 100644
--- a/src/xlib.c
+++ b/src/xlib.c
@@ -1,7 +1,7 @@
/*
- * $XFree86: xc/lib/Xcursor/xlib.c,v 1.4 2003/02/22 06:16:15 dawes Exp $
+ * $Id$
*
- * Copyright © 2002 Keith Packard, member of The XFree86 Project, Inc.
+ * Copyright © 2002 Keith Packard
*
* Permission to use, copy, modify, distribute, and sell this software and its
* documentation for any purpose is hereby granted without fee, provided that