summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAdam Jackson <ajax@nwnk.net>2005-10-19 22:26:55 +0000
committerAdam Jackson <ajax@nwnk.net>2005-10-19 22:26:55 +0000
commit7c7bdccde9d2208a9330099e3cd21060c60638be (patch)
treed6e7e0ce2979cd21cbf29e178aa57f8d69846489 /src
parent4d4de72c697217ac155231d1761db065c9a778ee (diff)
downloadxorg-lib-libXcursor-7c7bdccde9d2208a9330099e3cd21060c60638be.tar.gz
Bug #4244: Make XcursorSetTheme(dpy, NULL) restore the default theme.
(Frederico Mena-Quintero)
Diffstat (limited to 'src')
-rw-r--r--src/display.c37
-rw-r--r--src/xcursorint.h1
2 files changed, 30 insertions, 8 deletions
diff --git a/src/display.c b/src/display.c
index 73fb8b3..252a056 100644
--- a/src/display.c
+++ b/src/display.c
@@ -28,6 +28,18 @@
static XcursorDisplayInfo *_XcursorDisplayInfo;
+static void
+_XcursorFreeDisplayInfo (XcursorDisplayInfo *info)
+{
+ if (info->theme)
+ free (info->theme);
+
+ if (info->theme_from_config)
+ free (info->theme_from_config);
+
+ free (info);
+}
+
static int
_XcursorCloseDisplay (Display *dpy, XExtCodes *codes)
{
@@ -44,10 +56,8 @@ _XcursorCloseDisplay (Display *dpy, XExtCodes *codes)
break;
}
_XUnlockMutex (_Xglobal_lock);
-
- if (info->theme)
- free (info->theme);
- free (info);
+
+ _XcursorFreeDisplayInfo (info);
return 0;
}
@@ -190,6 +200,7 @@ _XcursorGetDisplayInfo (Display *dpy)
}
info->theme = 0;
+ info->theme_from_config = 0;
/*
* Get the desired theme
@@ -199,9 +210,17 @@ _XcursorGetDisplayInfo (Display *dpy)
v = XGetDefault (dpy, "Xcursor", "theme");
if (v)
{
- info->theme = malloc (strlen (v) + 1);
+ int len;
+
+ len = strlen (v) + 1;
+
+ info->theme = malloc (len);
if (info->theme)
strcpy (info->theme, v);
+
+ info->theme_from_config = malloc (len);
+ if (info->theme_from_config)
+ strcpy (info->theme_from_config, v);
}
/*
@@ -253,9 +272,7 @@ _XcursorGetDisplayInfo (Display *dpy)
break;
if (old)
{
- if (info->theme)
- free (info->theme);
- free (info);
+ _XcursorFreeDisplayInfo (info);
info = old;
}
else
@@ -313,6 +330,10 @@ XcursorSetTheme (Display *dpy, const char *theme)
if (!info)
return XcursorFalse;
+
+ if (!theme)
+ theme = info->theme_from_config;
+
if (theme)
{
copy = malloc (strlen (theme) + 1);
diff --git a/src/xcursorint.h b/src/xcursorint.h
index 1a5f50f..7887bbb 100644
--- a/src/xcursorint.h
+++ b/src/xcursorint.h
@@ -86,6 +86,7 @@ typedef struct _XcursorDisplayInfo {
int size;
XcursorFontInfo *fonts;
char *theme;
+ char *theme_from_config;
XcursorDither dither;
XcursorBitmapInfo bitmaps[NUM_BITMAPS];
} XcursorDisplayInfo;